Package com.foreach.across.core.installers

Examples of com.foreach.across.core.installers.AcrossBootstrapInstallerRegistry


      prepareForBootstrap( contextInfo );

      BootstrapLockManager bootstrapLockManager = new BootstrapLockManager( contextInfo );

      try {
        AcrossBootstrapInstallerRegistry installerRegistry =
            new AcrossBootstrapInstallerRegistry( contextInfo.getBootstrapConfiguration(),
                                                  bootstrapLockManager );

        // Run installers that don't need anything bootstrapped
        installerRegistry.runInstallers( InstallerPhase.BeforeContextBootstrap );

        boolean pushExposedToParentContext = shouldPushExposedBeansToParent( contextInfo );
        ExposedContextBeanRegistry exposedBeanRegistry = new ExposedContextBeanRegistry(
            AcrossContextUtils.getBeanRegistry( contextInfo ),
            rootContext.getBeanFactory(),
            null
        );

        // TODO add global hook to expose beans from the root context
        exposedBeanRegistry.add( AcrossContextInfo.BEAN );
        exposedBeanRegistry.add( "cacheManager" );

        for ( AcrossModuleInfo moduleInfo : contextInfo.getModules() ) {
          ConfigurableAcrossModuleInfo configurableAcrossModuleInfo =
              (ConfigurableAcrossModuleInfo) moduleInfo;
          ModuleBootstrapConfig config = moduleInfo.getBootstrapConfiguration();
          LOG.debug( "Bootstrapping {} module", config.getModuleName() );

          configurableAcrossModuleInfo.setBootstrapStatus( ModuleBootstrapStatus.BootstrapBusy );

          context.publishEvent( new AcrossModuleBeforeBootstrapEvent( contextInfo, moduleInfo ) );

          // Run installers before bootstrapping this particular module
          installerRegistry.runInstallersForModule( moduleInfo.getName(),
                                                    InstallerPhase.BeforeModuleBootstrap );

          // Create the module context
          AbstractApplicationContext child =
              applicationContextFactory.createApplicationContext( context, config, root );

          AcrossApplicationContextHolder moduleApplicationContext = new AcrossApplicationContextHolder( child,
                                                                                                        root );
          AcrossContextUtils.setAcrossApplicationContextHolder( config.getModule(),
                                                                moduleApplicationContext );

          AcrossModuleSettings moduleSettings = moduleInfo.getSettings();

          if ( moduleSettings != null ) {
            moduleSettings.setEnvironment( child.getEnvironment() );
          }

          applicationContextFactory.loadApplicationContext( context, config, moduleApplicationContext );

          // Bootstrap the module
          config.getModule().bootstrap();

          configurableAcrossModuleInfo.setBootstrapStatus( ModuleBootstrapStatus.Bootstrapped );

          // Send event that this module has bootstrapped
          context.publishEvent( new AcrossModuleBootstrappedEvent( moduleInfo ) );

          // Run installers after module itself has bootstrapped
          installerRegistry.runInstallersForModule( moduleInfo.getName(),
                                                    InstallerPhase.AfterModuleBootstrap );

          // Copy the beans to the parent context
          exposeBeans( configurableAcrossModuleInfo, config.getExposeFilter(), config.getExposeTransformer(),
                       rootContext );

          if ( pushExposedToParentContext ) {
            exposedBeanRegistry.addAll( configurableAcrossModuleInfo.getExposedBeanDefinitions() );
          }

          AcrossContextUtils.autoRegisterEventHandlers( child, rootContext.getBean(
              AcrossEventPublisher.class ) );
        }

        LOG.info( "Bootstrapping {} modules - finished", modulesInOrder.size() );

        if ( pushExposedToParentContext ) {
          pushExposedBeansToParent( exposedBeanRegistry, rootContext.getParent() );
        }

        // Refresh beans
        AcrossContextUtils.refreshBeans( context );

        // Bootstrapping done, run installers that require context bootstrap finished
        installerRegistry.runInstallers( InstallerPhase.AfterContextBootstrap );
      }
      finally {
        bootstrapLockManager.ensureUnlocked();
      }
View Full Code Here

TOP

Related Classes of com.foreach.across.core.installers.AcrossBootstrapInstallerRegistry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.