Improve ACR.
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / runtime / StaticCms.java
index 27b23233f3f982a3052bebfac8fa61e9fb5bdb14..e4087e13903ee00f707ea5ec159f9f5335c86b37 100644 (file)
@@ -35,12 +35,19 @@ public class StaticCms {
        private CompletableFuture<Void> stopped = new CompletableFuture<Void>();
 
        public void start() {
+               // UID factory
+               CmsUuidFactory uuidFactory = new CmsUuidFactory();
+               Component<CmsUuidFactory> uuidFactoryC = new Component.Builder<>(uuidFactory) //
+                               .addType(UuidFactory.class) //
+                               .build(register);
+
                // CMS State
                CmsStateImpl cmsState = new CmsStateImpl();
                Component<CmsStateImpl> cmsStateC = new Component.Builder<>(cmsState) //
                                .addType(CmsState.class) //
                                .addActivation(cmsState::start) //
                                .addDeactivation(cmsState::stop) //
+                               .addDependency(uuidFactoryC.getType(UuidFactory.class), cmsState::setUuidFactory, null) //
                                .build(register);
 
                // Deployment Configuration
@@ -81,6 +88,17 @@ public class StaticCms {
                                }, null) //
                                .build(register);
 
+               // Content Repository
+               DeployedContentRepository contentRepository = new DeployedContentRepository();
+               Component<DeployedContentRepository> contentRepositoryC = new Component.Builder<>(contentRepository) //
+                               .addType(ProvidedRepository.class) //
+                               .addType(ContentRepository.class) //
+                               .addActivation(contentRepository::start) //
+                               .addDeactivation(contentRepository::stop) //
+                               .addDependency(cmsStateC.getType(CmsState.class), contentRepository::setCmsState, null) //
+                               .addDependency(uuidFactoryC.getType(UuidFactory.class), contentRepository::setUuidFactory, null) //
+                               .build(register);
+
                // CMS Context
                CmsContextImpl cmsContext = new CmsContextImpl();
                Component<CmsContextImpl> cmsContextC = new Component.Builder<>(cmsContext) //
@@ -90,26 +108,12 @@ public class StaticCms {
                                .addDependency(cmsStateC.getType(CmsState.class), cmsContext::setCmsState, null) //
                                .addDependency(cmsDeploymentC.getType(CmsDeployment.class), cmsContext::setCmsDeployment, null) //
                                .addDependency(userAdminC.getType(UserAdmin.class), cmsContext::setUserAdmin, null) //
+                               .addDependency(uuidFactoryC.getType(UuidFactory.class), cmsContext::setUuidFactory, null) //
+                               .addDependency(contentRepositoryC.getType(ProvidedRepository.class), cmsContext::setContentRepository,
+                                               null) //
                                .build(register);
                assert cmsContextC.get() == cmsContext;
 
-               // UID factory
-               CmsUuidFactory uuidFactory = new CmsUuidFactory();
-               Component<CmsUuidFactory> uuidFactoryC = new Component.Builder<>(uuidFactory) //
-                               .addType(UuidFactory.class) //
-                               .build(register);
-
-               // Content Repository
-               DeployedContentRepository contentRepository = new DeployedContentRepository();
-               Component<DeployedContentRepository> contentRepositoryC = new Component.Builder<>(contentRepository) //
-                               .addType(ProvidedRepository.class) //
-                               .addType(ContentRepository.class) //
-                               .addActivation(contentRepository::start) //
-                               .addDeactivation(contentRepository::stop) //
-                               .addDependency(cmsStateC.getType(CmsState.class), contentRepository::setCmsState, null) //
-                               .addDependency(uuidFactoryC.getType(UuidFactory.class), contentRepository::setUuidFactory, null) //
-                               .build(register);
-
                register.activate();
        }