Example usage for org.springframework.beans.factory.config ConfigurableListableBeanFactory registerSingleton

List of usage examples for org.springframework.beans.factory.config ConfigurableListableBeanFactory registerSingleton

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config ConfigurableListableBeanFactory registerSingleton.

Prototype

void registerSingleton(String beanName, Object singletonObject);

Source Link

Document

Register the given existing object as singleton in the bean registry, under the given bean name.

Usage

From source file:com.github.srgg.springmockito.MockitoPropagatingFactoryPostProcessor.java

@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    final Map<Field, Object> fields = new LinkedHashMap();

    for (Object c : contexts) {
        for (Field f : FieldUtils.getAllFields(c.getClass())) {
            if (f.isAnnotationPresent(Mock.class) || f.isAnnotationPresent(Spy.class)
                    || includeInjectMocks && f.isAnnotationPresent(InjectMocks.class)) {
                try {
                    if (!f.isAccessible()) {
                        f.setAccessible(true);
                    }// w w w  .  j  av a 2 s .com

                    Object o = f.get(c);

                    fields.put(f, o);
                } catch (IllegalAccessException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }

    for (final Map.Entry<Field, Object> e : fields.entrySet()) {
        final Field f = e.getKey();

        /*
         * To be processed by BeanPostProcessors, value must be an instance of FactoryBean
         */
        final FactoryBean fb = new SimpleHolderFactoryBean(e.getValue());
        beanFactory.registerSingleton(f.getName(), fb);
    }
}

From source file:com.newtranx.util.cassandra.spring.MapperScannerConfigurer.java

@SuppressWarnings("unused") // compiler bug?
@Override/*from ww  w  .ja v a 2 s . c  om*/
public void postProcessBeanFactory(ConfigurableListableBeanFactory context) throws BeansException {
    synchronized (lock) {
        ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(
                false);
        scanner.addIncludeFilter(new AnnotationTypeFilter(Table.class));
        for (BeanDefinition bd : scanner.findCandidateComponents(basePackage)) {
            Class<?> entityCls;
            try {
                entityCls = Class.forName(bd.getBeanClassName());
            } catch (ClassNotFoundException e) {
                throw new AssertionError(e);
            }
            log.info("Creating proxy mapper for entity: " + entityCls.getName());
            CassandraMapper annotation = entityCls.getAnnotation(CassandraMapper.class);
            Mapper<?> bean = createProxy(Mapper.class, new MyInterceptor(entityCls, annotation.singleton()));
            String beanName;
            if (annotation == null)
                beanName = StringUtils.uncapitalize(entityCls.getSimpleName()) + "Mapper";
            else
                beanName = annotation.value();
            context.registerSingleton(beanName, bean);
            log.info("Bean registed, name=" + beanName + ", bean=" + bean.toString());
        }
    }
}

From source file:com.newtranx.util.cassandra.spring.AccessorScannerConfigurer.java

@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory context) throws BeansException {
    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(
            false) {//from  w ww.  j a  v  a 2s  .c om

        @Override
        protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
            return beanDefinition.getMetadata().isInterface();
        }

    };
    scanner.addIncludeFilter(new AnnotationTypeFilter(Accessor.class));
    for (BeanDefinition bd : scanner.findCandidateComponents(basePackage)) {
        Class<?> accessorCls;
        try {
            accessorCls = Class.forName(bd.getBeanClassName());
        } catch (ClassNotFoundException e) {
            throw new AssertionError(e);
        }
        log.info("Creating proxy accessor: " + accessorCls.getName());
        MethodInterceptor interceptor = new MethodInterceptor() {

            private final Lazy<?> target = new Lazy<>(() -> {
                log.info("Creating actual accessor: " + accessorCls.getName());
                Session session;
                if (AccessorScannerConfigurer.this.session == null)
                    session = mainContext.getBean(Session.class);
                else
                    session = AccessorScannerConfigurer.this.session;
                MappingManager mappingManager = new MappingManager(session);
                return mappingManager.createAccessor(accessorCls);
            });

            @Override
            public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy)
                    throws Throwable {
                if ("toString".equals(method.getName())) {
                    return accessorCls.getName();
                }
                return method.invoke(target.get(), args);
            }

        };
        Enhancer enhancer = new Enhancer();
        enhancer.setInterfaces(new Class<?>[] { accessorCls });
        enhancer.setCallback(interceptor);
        Object bean = enhancer.create();
        String beanName = StringUtils.uncapitalize(accessorCls.getSimpleName());
        context.registerSingleton(beanName, bean);
        log.info("Bean registed, name=" + beanName + ", bean=" + bean.toString());
    }
}

From source file:no.kantega.publishing.spring.OpenAksessContextLoaderListener.java

private void addConfigurationAndLoaderAsSingletonsInContext(ConfigurableWebApplicationContext wac,
        final Configuration configuration, final ConfigurationLoader loader) {
    wac.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {
        public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
            beanFactory.registerSingleton("aksessConfiguration", configuration);
            beanFactory.registerSingleton("aksessConfigurationLoader", loader);

        }//ww w . java  2  s.com
    });
}

From source file:org.apereo.portal.utils.cache.EhcacheManagerBeanConfigurer.java

@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    final String[] cacheNames = this.cacheManager.getCacheNames();
    for (final String cacheName : cacheNames) {
        final Ehcache ehcache = this.cacheManager.getEhcache(cacheName);
        this.logger.debug("Registering Ehcache '" + cacheName + "' with bean factory");
        if (beanFactory.containsBean(cacheName)) {
            if (skipDuplicates) {
                continue;
            }/* w  w w  .j  a  v a  2  s.com*/

            throw new BeanCreationException(
                    "Duplicate Ehcache " + cacheName + " from CacheManager " + cacheManager.getName());
        }

        try {
            beanFactory.registerSingleton(cacheName, ehcache);
        } catch (Exception e) {
            throw new BeanCreationException(
                    "Failed to register Ehcache " + cacheName + " from CacheManager " + cacheManager.getName(),
                    e);
        }
    }
    this.logger.debug("Registered " + cacheNames.length + " Ehcaches with bean factory");
}

From source file:org.devproof.portal.core.config.factory.DevproofClassPathBeanDefinitionScanner.java

private void registerModuleConfigurationAsSingleton() {
    ConfigurableListableBeanFactory f = (ConfigurableListableBeanFactory) registry;
    String basePackage = moduleConfiguration.getBasePackage();
    if (f.containsBean(basePackage)) {
        throw new IllegalStateException(
                "You tried to register a devproof module twice with the same base-package: " + basePackage
                        + "!");
    }// w ww. j  av  a  2s. c  om
    System.out.println("Register module: " + basePackage + " - " + moduleConfiguration.getName());
    f.registerSingleton(basePackage, moduleConfiguration);
}

From source file:org.eclipse.gemini.blueprint.extender.internal.blueprint.activator.BlueprintContainerProcessor.java

public void preProcessRefresh(final ConfigurableOsgiBundleApplicationContext context) {
    final BundleContext bundleContext = context.getBundleContext();
    // create the ModuleContext adapter
    final BlueprintContainer blueprintContainer = createBlueprintContainer(context);

    // 1. add event listeners
    // add service publisher
    context.addApplicationListener(new BlueprintContainerServicePublisher(blueprintContainer, bundleContext));
    // add waiting event broadcaster
    context.addApplicationListener(new BlueprintWaitingEventDispatcher(context.getBundleContext()));

    // 2. add environmental managers
    context.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {

        private static final String BLUEPRINT_BUNDLE = "blueprintBundle";
        private static final String BLUEPRINT_BUNDLE_CONTEXT = "blueprintBundleContext";
        private static final String BLUEPRINT_CONTAINER = "blueprintContainer";
        private static final String BLUEPRINT_EXTENDER = "blueprintExtenderBundle";
        private static final String BLUEPRINT_CONVERTER = "blueprintConverter";

        public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
            // lazy logger evaluation
            Log logger = LogFactory.getLog(context.getClass());

            if (!(beanFactory instanceof BeanDefinitionRegistry)) {
                logger.warn("Environmental beans will be registered as singletons instead "
                        + "of usual bean definitions since beanFactory " + beanFactory
                        + " is not a BeanDefinitionRegistry");
            }//from   w w  w . jav  a 2s. c  om

            // add blueprint container bean
            addPredefinedBlueprintBean(beanFactory, BLUEPRINT_BUNDLE, bundleContext.getBundle(), logger);
            addPredefinedBlueprintBean(beanFactory, BLUEPRINT_BUNDLE_CONTEXT, bundleContext, logger);
            addPredefinedBlueprintBean(beanFactory, BLUEPRINT_CONTAINER, blueprintContainer, logger);
            // addPredefinedBlueprintBean(beanFactory, BLUEPRINT_EXTENDER, extenderBundle, logger);
            addPredefinedBlueprintBean(beanFactory, BLUEPRINT_CONVERTER,
                    new SpringBlueprintConverter(beanFactory), logger);

            // add Blueprint conversion service
            // String[] beans = beanFactory.getBeanNamesForType(BlueprintConverterConfigurer.class, false, false);
            // if (ObjectUtils.isEmpty(beans)) {
            // beanFactory.addPropertyEditorRegistrar(new BlueprintEditorRegistrar());
            // }
            beanFactory.setConversionService(
                    new SpringBlueprintConverterService(beanFactory.getConversionService(), beanFactory));
        }

        private void addPredefinedBlueprintBean(ConfigurableListableBeanFactory beanFactory, String beanName,
                Object value, Log logger) {
            if (!beanFactory.containsLocalBean(beanName)) {
                logger.debug("Registering pre-defined bean named " + beanName);
                if (beanFactory instanceof BeanDefinitionRegistry) {
                    BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;

                    GenericBeanDefinition def = new GenericBeanDefinition();
                    def.setBeanClass(ENV_FB_CLASS);
                    ConstructorArgumentValues cav = new ConstructorArgumentValues();
                    cav.addIndexedArgumentValue(0, value);
                    def.setConstructorArgumentValues(cav);
                    def.setLazyInit(false);
                    def.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
                    registry.registerBeanDefinition(beanName, def);

                } else {
                    beanFactory.registerSingleton(beanName, value);
                }

            } else {
                logger.warn("A bean named " + beanName
                        + " already exists; aborting registration of the predefined value...");
            }
        }
    });

    // 3. add cycle breaker
    context.addBeanFactoryPostProcessor(cycleBreaker);

    BlueprintEvent creatingEvent = new BlueprintEvent(BlueprintEvent.CREATING, context.getBundle(),
            extenderBundle);
    listenerManager.blueprintEvent(creatingEvent);
    dispatcher.beforeRefresh(creatingEvent);
}

From source file:org.fao.geonet.OgpAppHandler.java

/**
 * Inits the engine, loading all needed data.
 *///from   w  w  w  .  j  a  v a2 s.co m
public Object start(Element config, ServiceContext context) throws Exception {
    context.setAsThreadLocal();
    this._applicationContext = context.getApplicationContext();
    ApplicationContextHolder.set(this._applicationContext);

    logger = context.getLogger();
    // If an error occur during logger configuration
    // Continue starting the application with
    // a logger initialized with the default log4j.xml.
    try {
        LogUtils.refreshLogConfiguration();
    } catch (OperationAbortedEx e) {
        logger.error("Error while setting log configuration. "
                + "Check the setting in the database for logger configuration file.");
        logger.error(e.getMessage());
    }
    ConfigurableListableBeanFactory beanFactory = context.getApplicationContext().getBeanFactory();

    ServletPathFinder finder = new ServletPathFinder(this._applicationContext.getBean(ServletContext.class));
    appPath = finder.getAppPath();
    String baseURL = context.getBaseUrl();
    String webappName = baseURL.substring(1);
    // TODO : if webappName is "". ie no context

    final SystemInfo systemInfo = _applicationContext.getBean(SystemInfo.class);
    String version = systemInfo.getVersion();
    String subVersion = systemInfo.getSubVersion();

    logger.info("Initializing GeoNetwork " + version + "." + subVersion + " ...");

    // Get main service config handler
    @SuppressWarnings("unchecked")
    List<Element> serviceConfigElems = config.getChildren();
    ServiceConfig handlerConfig = new ServiceConfig(serviceConfigElems);

    // Init configuration directory
    final GeonetworkDataDirectory dataDirectory = _applicationContext.getBean(GeonetworkDataDirectory.class);
    dataDirectory.init(webappName, appPath, handlerConfig, context.getServlet());

    // Get config handler properties
    String systemDataDir = handlerConfig.getMandatoryValue(Geonet.Config.SYSTEM_DATA_DIR);
    String thesauriDir = handlerConfig.getMandatoryValue(Geonet.Config.CODELIST_DIR);
    String luceneDir = handlerConfig.getMandatoryValue(Geonet.Config.LUCENE_DIR);
    String luceneConfigXmlFile = handlerConfig.getMandatoryValue(Geonet.Config.LUCENE_CONFIG);

    logger.info("Data directory: " + systemDataDir);

    setProps(appPath, handlerConfig);

    importDatabaseData(context);

    // Status actions class - load it
    String statusActionsClassName = handlerConfig.getMandatoryValue(Geonet.Config.STATUS_ACTIONS_CLASS);
    @SuppressWarnings("unchecked")
    Class<StatusActions> statusActionsClass = (Class<StatusActions>) Class.forName(statusActionsClassName);

    JeevesJCS.setConfigFilename(appPath.resolve("WEB-INF/classes/cache.ccf"));

    // force caches to be config'd so shutdown hook works correctly
    JeevesJCS.getInstance(Processor.XLINK_JCS);
    JeevesJCS.getInstance(XmlResolver.XMLRESOLVER_JCS);

    //------------------------------------------------------------------------
    //--- initialize settings subsystem

    logger.info("  - Setting manager...");

    SettingManager settingMan = this._applicationContext.getBean(SettingManager.class);

    //--- initialize ThreadUtils with setting manager and rm props
    final DataSource dataSource = context.getBean(DataSource.class);
    Connection conn = null;
    try {
        conn = dataSource.getConnection();
        ThreadUtils.init(conn.getMetaData().getURL(), settingMan);
    } finally {
        if (conn != null) {
            conn.close();
        }
    }

    //------------------------------------------------------------------------
    //--- initialize Z39.50

    logger.info("  - Z39.50...");

    boolean z3950Enable = settingMan.getValueAsBool("system/z3950/enable", false);
    String z3950port = settingMan.getValue("system/z3950/port");

    logger.info("     - Z39.50 is enabled: " + z3950Enable);
    if (z3950Enable) {
        // build Z3950 repositories file first from template
        URL url = getClass().getClassLoader().getResource(Geonet.File.JZKITCONFIG_TEMPLATE);

        if (Repositories.build(url, context)) {
            logger.info("     Repositories file built from template.");

            try {
                ConfigurableApplicationContext appContext = context.getApplicationContext();

                // to have access to the GN context in spring-managed objects
                ContextContainer cc = (ContextContainer) appContext.getBean("ContextGateway");
                cc.setSrvctx(context);

                if (!z3950Enable) {
                    logger.info("     Server is Disabled.");
                } else {
                    logger.info("     Server is Enabled.");

                    Server.init(z3950port, appContext);
                }
            } catch (Exception e) {
                logger.error(
                        "     Repositories file init FAILED - Z3950 server disabled and Z3950 client services (remote search, "
                                + "harvesting) may not work. Error is:" + e.getMessage());
                e.printStackTrace();
            }

        } else {
            logger.error(
                    "     Repositories file builder FAILED - Z3950 server disabled and Z3950 client services (remote search, "
                            + "harvesting) may not work.");
        }
    }
    //------------------------------------------------------------------------
    //--- initialize SchemaManager

    logger.info("  - Schema manager...");

    Path schemaPluginsDir = dataDirectory.getSchemaPluginsDir();
    Path schemaCatalogueFile = dataDirectory.getConfigDir().resolve(Geonet.File.SCHEMA_PLUGINS_CATALOG);
    boolean createOrUpdateSchemaCatalog = handlerConfig
            .getMandatoryValue(Geonet.Config.SCHEMA_PLUGINS_CATALOG_UPDATE).equals("true");
    logger.info("         - Schema plugins directory: " + schemaPluginsDir);
    logger.info("         - Schema Catalog File     : " + schemaCatalogueFile);
    SchemaManager schemaMan = _applicationContext.getBean(SchemaManager.class);
    schemaMan.configure(_applicationContext, appPath, dataDirectory.getResourcesDir(), schemaCatalogueFile,
            schemaPluginsDir, context.getLanguage(),
            handlerConfig.getMandatoryValue(Geonet.Config.PREFERRED_SCHEMA), createOrUpdateSchemaCatalog);

    //------------------------------------------------------------------------
    //--- initialize search and editing

    logger.info("  - Search...");

    boolean logSpatialObject = "true"
            .equalsIgnoreCase(handlerConfig.getMandatoryValue(Geonet.Config.STAT_LOG_SPATIAL_OBJECTS));
    boolean logAsynch = "true".equalsIgnoreCase(handlerConfig.getMandatoryValue(Geonet.Config.STAT_LOG_ASYNCH));
    logger.info("  - Log spatial object: " + logSpatialObject);
    logger.info("  - Log in asynch mode: " + logAsynch);

    String luceneTermsToExclude = "";
    luceneTermsToExclude = handlerConfig.getMandatoryValue(Geonet.Config.STAT_LUCENE_TERMS_EXCLUDE);

    LuceneConfig lc = _applicationContext.getBean(LuceneConfig.class);
    lc.configure(luceneConfigXmlFile);
    logger.info("  - Lucene configuration is:");
    logger.info(lc.toString());

    try {
        _applicationContext.getBean(DataStore.class);
    } catch (NoSuchBeanDefinitionException e) {
        DataStore dataStore = createShapefileDatastore(luceneDir);
        _applicationContext.getBeanFactory().registerSingleton("dataStore", dataStore);
        //--- no datastore for spatial indexing means that we can't continue
        if (dataStore == null) {
            throw new IllegalArgumentException(
                    "GeoTools datastore creation failed - check logs for more info/exceptions");
        }
    }

    String maxWritesInTransactionStr = handlerConfig.getMandatoryValue(Geonet.Config.MAX_WRITES_IN_TRANSACTION);
    int maxWritesInTransaction = SpatialIndexWriter.MAX_WRITES_IN_TRANSACTION;
    try {
        maxWritesInTransaction = Integer.parseInt(maxWritesInTransactionStr);
    } catch (NumberFormatException nfe) {
        logger.error(
                "Invalid config parameter: maximum number of writes to spatial index in a transaction (maxWritesInTransaction)"
                        + ", Using " + maxWritesInTransaction + " instead.");
        nfe.printStackTrace();
    }

    SettingInfo settingInfo = context.getBean(SettingInfo.class);
    searchMan = _applicationContext.getBean(SearchManager.class);
    searchMan.init(logAsynch, logSpatialObject, luceneTermsToExclude, maxWritesInTransaction);

    // if the validator exists the proxyCallbackURL needs to have the external host and
    // servlet name added so that the cas knows where to send the validation notice
    ServerBeanPropertyUpdater.updateURL(settingInfo.getSiteUrl(true) + baseURL, _applicationContext);

    //------------------------------------------------------------------------
    //--- extract intranet ip/mask and initialize AccessManager

    logger.info("  - Access manager...");

    //------------------------------------------------------------------------
    //--- get edit params and initialize DataManager

    logger.info("  - Xml serializer and Data manager...");

    SvnManager svnManager = _applicationContext.getBean(SvnManager.class);
    XmlSerializer xmlSerializer = _applicationContext.getBean(XmlSerializer.class);

    if (xmlSerializer instanceof XmlSerializerSvn && svnManager != null) {
        svnManager.setContext(context);
        Path subversionPath = dataDirectory.getMetadataRevisionDir().toAbsolutePath().normalize();
        svnManager.setSubversionPath(subversionPath.toString());
        svnManager.init();
    }

    /**
     * Initialize language detector
     */
    LanguageDetector.init(
            appPath.resolve(_applicationContext.getBean(Geonet.Config.LANGUAGE_PROFILES_DIR, String.class)));

    //------------------------------------------------------------------------
    //--- Initialize thesaurus

    logger.info("  - Thesaurus...");

    _applicationContext.getBean(ThesaurusManager.class).init(false, context, thesauriDir);

    //------------------------------------------------------------------------
    //--- initialize catalogue services for the web

    logger.info("  - Open Archive Initiative (OAI-PMH) server...");

    OaiPmhDispatcher oaipmhDis = new OaiPmhDispatcher(settingMan, schemaMan);

    GeonetContext gnContext = new GeonetContext(_applicationContext, false, statusActionsClass);

    //------------------------------------------------------------------------
    //--- return application context

    beanFactory.registerSingleton("serviceHandlerConfig", handlerConfig);
    beanFactory.registerSingleton("oaipmhDisatcher", oaipmhDis);

    _applicationContext.getBean(DataManager.class).init(context, false);
    _applicationContext.getBean(HarvestManager.class).init(context, gnContext.isReadOnly());

    _applicationContext.getBean(ThumbnailMaker.class).init(context);

    logger.info("Site ID is : " + settingMan.getSiteId());

    // Creates a default site logo, only if the logo image doesn't exists
    // This can happen if the application has been updated with a new version preserving the database and
    // images/logos folder is not copied from old application
    createSiteLogo(settingMan.getSiteId(), context, context.getAppPath());

    // Notify unregistered metadata at startup. Needed, for example, when the user enables the notifier config
    // to notify the existing metadata in database
    // TODO: Fix DataManager.getUnregisteredMetadata and uncomment next lines
    metadataNotifierControl = new MetadataNotifierControl(context);
    metadataNotifierControl.runOnce();

    // Reindex Blank template metadata
    DataManager dm = _applicationContext.getBean(DataManager.class);
    Set<Integer> metadataToReindex = new HashSet<>();
    metadataToReindex.add(new Integer(1));
    context.info("Re-indexing metadata");
    BatchOpsMetadataReindexer r = new BatchOpsMetadataReindexer(dm, metadataToReindex);
    r.process();

    //--- load proxy information from settings into Jeeves for observers such
    //--- as jeeves.utils.XmlResolver to use
    ProxyInfo pi = JeevesProxyInfo.getInstance();
    boolean useProxy = settingMan.getValueAsBool("system/proxy/use", false);
    if (useProxy) {
        String proxyHost = settingMan.getValue("system/proxy/host");
        String proxyPort = settingMan.getValue("system/proxy/port");
        String username = settingMan.getValue("system/proxy/username");
        String password = settingMan.getValue("system/proxy/password");
        pi.setProxyInfo(proxyHost, Integer.valueOf(proxyPort), username, password);
    }

    boolean inspireEnable = settingMan.getValueAsBool("system/inspire/enable", false);

    if (inspireEnable) {

        String atomType = settingMan.getValue("system/inspire/atom");
        String atomSchedule = settingMan.getValue("system/inspire/atomSchedule");

        if (StringUtils.isNotEmpty(atomType) && StringUtils.isNotEmpty(atomSchedule)
                && atomType.equalsIgnoreCase(InspireAtomType.ATOM_REMOTE)) {
            logger.info("  - INSPIRE ATOM feed harvester ...");

            InspireAtomHarvesterScheduler.schedule(atomSchedule, context, gnContext);
        }
    }

    //
    // db heartbeat configuration -- for failover to readonly database
    //
    boolean dbHeartBeatEnabled = Boolean
            .parseBoolean(handlerConfig.getValue(Geonet.Config.DB_HEARTBEAT_ENABLED, "false"));
    if (dbHeartBeatEnabled) {
        Integer dbHeartBeatInitialDelay = Integer
                .parseInt(handlerConfig.getValue(Geonet.Config.DB_HEARTBEAT_INITIALDELAYSECONDS, "5"));
        Integer dbHeartBeatFixedDelay = Integer
                .parseInt(handlerConfig.getValue(Geonet.Config.DB_HEARTBEAT_FIXEDDELAYSECONDS, "60"));
        createDBHeartBeat(gnContext, dbHeartBeatInitialDelay, dbHeartBeatFixedDelay);
    }

    fillCaches(context);

    AbstractEntityListenerManager.setSystemRunning(true);
    return gnContext;
}

From source file:org.libreplan.web.common.entrypoints.RedirectorSynthetiser.java

public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    long elapsedTime = System.currentTimeMillis();

    for (Class<?> pageInterface : findInterfacesMarkedEntryPoints()) {

        beanFactory.registerSingleton(getBeanName(pageInterface),
                createRedirectorImplementationFor(beanFactory, pageInterface));
    }/*from w  w  w  .  java  2  s .c o m*/
    elapsedTime = System.currentTimeMillis() - elapsedTime;

    LOG.debug("Took " + elapsedTime + " ms to search for interfaces annotated with "
            + EntryPoints.class.getSimpleName());
}

From source file:org.robospring.RoboSpring.java

private static void createParentContextForAndroid(Context androidContext) {
    if (parentContext != null) {
        return;/*w  w  w .j  av a2 s . co m*/
    }
    log.info("Creating parent context with bean 'androidContext' for you to use in your configuration");
    // http://stackoverflow.com/questions/1109953/how-can-i-inject-a-bean-into-an-applicationcontext-before-it-loads-from-a-file
    parentContext = new ClassPathXmlApplicationContext();
    parentContext.refresh(); // THIS IS REQUIRED
    androidAppContext = androidContext.getApplicationContext();
    ConfigurableListableBeanFactory beanFactory = parentContext.getBeanFactory();
    beanFactory.registerSingleton("androidContext", androidAppContext);
}