Skip to content

Commit da56b60

Browse files
committed
Add framework context
1 parent 6bb47a8 commit da56b60

4 files changed

Lines changed: 81 additions & 1 deletion

File tree

weaverbird-core/src/main/java/com/techsenger/weaverbird/core/api/Framework.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
package com.techsenger.weaverbird.core.api;
1818

19+
import com.techsenger.toolkit.core.version.Version;
1920
import com.techsenger.weaverbird.core.api.registry.Registry;
2021
import com.techsenger.weaverbird.core.spi.repo.RepoService;
21-
import com.techsenger.toolkit.core.version.Version;
2222

2323
/**
2424
*
@@ -36,6 +36,11 @@ public interface Framework {
3636
*/
3737
FrameworkSettings getSettings();
3838

39+
/**
40+
* Returns the framework context.
41+
*/
42+
FrameworkContext getContext();
43+
3944
/**
4045
* Returns the component manager.
4146
*/
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2018-2026 Pavel Castornii.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.techsenger.weaverbird.core.api;
18+
19+
import java.util.Map;
20+
21+
/**
22+
* This context is used by application developers.
23+
*
24+
* @author Pavel Castornii
25+
*/
26+
public interface FrameworkContext {
27+
28+
/**
29+
* Returns a thread-safe map of properties.
30+
*/
31+
Map<Object, Object> getProperties();
32+
}

weaverbird-core/src/main/java/com/techsenger/weaverbird/core/impl/DefaultFramework.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.techsenger.weaverbird.core.api.Constants;
2323
import com.techsenger.weaverbird.core.api.DefaultPathManager;
2424
import com.techsenger.weaverbird.core.api.Framework;
25+
import com.techsenger.weaverbird.core.api.FrameworkContext;
2526
import com.techsenger.weaverbird.core.api.FrameworkSettings;
2627
import com.techsenger.weaverbird.core.api.JvmInspector;
2728
import com.techsenger.weaverbird.core.api.LogManager;
@@ -52,6 +53,8 @@ public class DefaultFramework implements Framework {
5253

5354
private final FrameworkSettings settings;
5455

56+
private final FrameworkContext context = new DefaultFrameworkContext();
57+
5558
/**
5659
* Log manager.
5760
*/
@@ -119,6 +122,11 @@ public FrameworkSettings getSettings() {
119122
return settings;
120123
}
121124

125+
@Override
126+
public FrameworkContext getContext() {
127+
return context;
128+
}
129+
122130
@Override
123131
public Version getVersion() {
124132
return ProjectInfo.getVersion();
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2018-2026 Pavel Castornii.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.techsenger.weaverbird.core.impl;
18+
19+
import com.techsenger.weaverbird.core.api.FrameworkContext;
20+
import java.util.Map;
21+
import java.util.concurrent.ConcurrentHashMap;
22+
23+
/**
24+
*
25+
* @author Pavel Castornii
26+
*/
27+
public class DefaultFrameworkContext implements FrameworkContext {
28+
29+
private final Map<Object, Object> properties = new ConcurrentHashMap<>();
30+
31+
@Override
32+
public Map<Object, Object> getProperties() {
33+
return properties;
34+
}
35+
}

0 commit comments

Comments
 (0)