Committed by
Gerrit Code Review
Fixed SubjectFactories to support app subject properly.
Change-Id: Ib9de2c0f4af815c54f18954d83f4259089274e91
Showing
2 changed files
with
24 additions
and
8 deletions
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | package org.onosproject.incubator.net.config.basics; | 16 | package org.onosproject.incubator.net.config.basics; |
17 | 17 | ||
18 | import org.onosproject.core.ApplicationId; | 18 | import org.onosproject.core.ApplicationId; |
19 | +import org.onosproject.core.CoreService; | ||
19 | import org.onosproject.incubator.net.config.SubjectFactory; | 20 | import org.onosproject.incubator.net.config.SubjectFactory; |
20 | import org.onosproject.net.ConnectPoint; | 21 | import org.onosproject.net.ConnectPoint; |
21 | import org.onosproject.net.DeviceId; | 22 | import org.onosproject.net.DeviceId; |
... | @@ -33,12 +34,14 @@ public final class SubjectFactories { | ... | @@ -33,12 +34,14 @@ public final class SubjectFactories { |
33 | private SubjectFactories() { | 34 | private SubjectFactories() { |
34 | } | 35 | } |
35 | 36 | ||
37 | + // Required for resolving application identifiers | ||
38 | + private static CoreService coreService; | ||
39 | + | ||
36 | public static final SubjectFactory<ApplicationId> APP_SUBJECT_FACTORY = | 40 | public static final SubjectFactory<ApplicationId> APP_SUBJECT_FACTORY = |
37 | new SubjectFactory<ApplicationId>(ApplicationId.class, "apps") { | 41 | new SubjectFactory<ApplicationId>(ApplicationId.class, "apps") { |
38 | @Override | 42 | @Override |
39 | public ApplicationId createSubject(String key) { | 43 | public ApplicationId createSubject(String key) { |
40 | - // FIXME: figure out how to safely create sanctioned app ids | 44 | + return coreService.registerApplication(key); |
41 | - return null; | ||
42 | } | 45 | } |
43 | }; | 46 | }; |
44 | 47 | ||
... | @@ -77,4 +80,14 @@ public final class SubjectFactories { | ... | @@ -77,4 +80,14 @@ public final class SubjectFactories { |
77 | } | 80 | } |
78 | }; | 81 | }; |
79 | 82 | ||
83 | + /** | ||
84 | + * Provides reference to the core service, which is required for | ||
85 | + * application subject factory. | ||
86 | + * | ||
87 | + * @param service core service reference | ||
88 | + */ | ||
89 | + public static void setCoreService(CoreService service) { | ||
90 | + coreService = service; | ||
91 | + } | ||
92 | + | ||
80 | } | 93 | } | ... | ... |
... | @@ -21,12 +21,14 @@ import org.apache.felix.scr.annotations.Component; | ... | @@ -21,12 +21,14 @@ import org.apache.felix.scr.annotations.Component; |
21 | import org.apache.felix.scr.annotations.Deactivate; | 21 | import org.apache.felix.scr.annotations.Deactivate; |
22 | import org.apache.felix.scr.annotations.Reference; | 22 | import org.apache.felix.scr.annotations.Reference; |
23 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 23 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
24 | +import org.onosproject.core.CoreService; | ||
24 | import org.onosproject.incubator.net.config.ConfigFactory; | 25 | import org.onosproject.incubator.net.config.ConfigFactory; |
25 | import org.onosproject.incubator.net.config.NetworkConfigRegistry; | 26 | import org.onosproject.incubator.net.config.NetworkConfigRegistry; |
26 | import org.onosproject.incubator.net.config.basics.BasicDeviceConfig; | 27 | import org.onosproject.incubator.net.config.basics.BasicDeviceConfig; |
27 | import org.onosproject.incubator.net.config.basics.BasicHostConfig; | 28 | import org.onosproject.incubator.net.config.basics.BasicHostConfig; |
28 | import org.onosproject.incubator.net.config.basics.BasicLinkConfig; | 29 | import org.onosproject.incubator.net.config.basics.BasicLinkConfig; |
29 | import org.onosproject.incubator.net.config.basics.BasicPortConfig; | 30 | import org.onosproject.incubator.net.config.basics.BasicPortConfig; |
31 | +import org.onosproject.incubator.net.config.basics.SubjectFactories; | ||
30 | import org.onosproject.net.ConnectPoint; | 32 | import org.onosproject.net.ConnectPoint; |
31 | import org.onosproject.net.DeviceId; | 33 | import org.onosproject.net.DeviceId; |
32 | import org.onosproject.net.HostId; | 34 | import org.onosproject.net.HostId; |
... | @@ -36,10 +38,7 @@ import org.slf4j.LoggerFactory; | ... | @@ -36,10 +38,7 @@ import org.slf4j.LoggerFactory; |
36 | 38 | ||
37 | import java.util.Set; | 39 | import java.util.Set; |
38 | 40 | ||
39 | -import static org.onosproject.incubator.net.config.basics.SubjectFactories.CONNECT_POINT_SUBJECT_FACTORY; | 41 | +import static org.onosproject.incubator.net.config.basics.SubjectFactories.*; |
40 | -import static org.onosproject.incubator.net.config.basics.SubjectFactories.DEVICE_SUBJECT_FACTORY; | ||
41 | -import static org.onosproject.incubator.net.config.basics.SubjectFactories.HOST_SUBJECT_FACTORY; | ||
42 | -import static org.onosproject.incubator.net.config.basics.SubjectFactories.LINK_SUBJECT_FACTORY; | ||
43 | 42 | ||
44 | /** | 43 | /** |
45 | * Component for registration of builtin basic network configurations. | 44 | * Component for registration of builtin basic network configurations. |
... | @@ -59,8 +58,8 @@ public class BasicNetworkConfigs { | ... | @@ -59,8 +58,8 @@ public class BasicNetworkConfigs { |
59 | } | 58 | } |
60 | }, | 59 | }, |
61 | new ConfigFactory<ConnectPoint, BasicPortConfig>(CONNECT_POINT_SUBJECT_FACTORY, | 60 | new ConfigFactory<ConnectPoint, BasicPortConfig>(CONNECT_POINT_SUBJECT_FACTORY, |
62 | - BasicPortConfig.class, | 61 | + BasicPortConfig.class, |
63 | - "basic") { | 62 | + "basic") { |
64 | @Override | 63 | @Override |
65 | public BasicPortConfig createConfig() { | 64 | public BasicPortConfig createConfig() { |
66 | return new BasicPortConfig(); | 65 | return new BasicPortConfig(); |
... | @@ -85,10 +84,14 @@ public class BasicNetworkConfigs { | ... | @@ -85,10 +84,14 @@ public class BasicNetworkConfigs { |
85 | ); | 84 | ); |
86 | 85 | ||
87 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 86 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
87 | + protected CoreService coreService; | ||
88 | + | ||
89 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
88 | protected NetworkConfigRegistry registry; | 90 | protected NetworkConfigRegistry registry; |
89 | 91 | ||
90 | @Activate | 92 | @Activate |
91 | public void activate() { | 93 | public void activate() { |
94 | + SubjectFactories.setCoreService(coreService); | ||
92 | factories.forEach(registry::registerConfigFactory); | 95 | factories.forEach(registry::registerConfigFactory); |
93 | log.info("Started"); | 96 | log.info("Started"); |
94 | } | 97 | } | ... | ... |
-
Please register or login to post a comment