Package org.springframework.beans.factory.config

Examples of org.springframework.beans.factory.config.ConfigurableListableBeanFactory


                + ": no view controller name found for view " + viewId);
        }

        // Look up the definition with the specified name.
        ConfigurableApplicationContext appContext = getApplicationContext();
        ConfigurableListableBeanFactory beanFactory = appContext.getBeanFactory();
        BeanDefinition beanDefinition = beanFactory.getBeanDefinition(viewControllerName);

        if (beanDefinition.getBeanClassName().equals(ScopedProxyFactoryBean.class.getName()))
        {
            // The BeanDefinition we found is one that contains a nested aop:scopedProxy tag.
            // In this case, Spring has actually renamed the original BeanDefinition which
            // contains the data we need. So here we need to look up the renamed definition.
            //
            // It would be nice if the fake definition that Spring creates had some way of
            // fetching the definition it wraps, but instead it appears that we need to
            // rely on the magic string prefix...
            beanDefinition = beanFactory.getBeanDefinition("scopedTarget." + viewControllerName);
        }

        String scopeName = beanDefinition.getScope();
       
        if (scopeName == null)
        {
            // should never happen
            throw new OrchestraException(
                "Error while processing bean " + beanName
                + ": view controller " + viewControllerName + " has no scope.");
        }

        Scope registeredScope = beanFactory.getRegisteredScope(scopeName);
        if (registeredScope == null)
        {
            throw new OrchestraException(
                "Error while processing bean " + beanName
                + ": view controller " + viewControllerName
View Full Code Here


    try {
      ClassPathXmlApplicationContext parentSpringAppContext =
          new ClassPathXmlApplicationContext();
      parentSpringAppContext.refresh();
      ConfigurableListableBeanFactory factory = parentSpringAppContext.
          getBeanFactory();
      factory.registerSingleton("guiceInjector",
          injector);
      factory.registerSingleton("passwordEncoder",
          injector.getInstance(PasswordEncoder.class));
      factory.registerSingleton("ambariLocalUserService",
          injector.getInstance(AmbariLocalUserDetailsService.class));
      factory.registerSingleton("ambariLdapAuthenticationProvider",
          injector.getInstance(AmbariLdapAuthenticationProvider.class));
      //Spring Security xml config depends on this Bean

      String[] contextLocations = {SPRING_CONTEXT_LOCATION};
      ClassPathXmlApplicationContext springAppContext = new
View Full Code Here

    log.error(type, pe);
  }

  private static void run(CommandLine cmd) throws Exception {
    String configName = cmd.getOptionValue("x");
    ConfigurableListableBeanFactory appCtxt = SavedLogFormatLoader.loadAppContext(configName);

    LogFormat format = SpringBeanLogFormatLoader.getLogFormat(appCtxt);

    final ReportPrinter reportPrinter = createReportPrinter(cmd, format);
View Full Code Here

    try {
      ClassPathXmlApplicationContext parentSpringAppContext =
          new ClassPathXmlApplicationContext();
      parentSpringAppContext.refresh();
      ConfigurableListableBeanFactory factory = parentSpringAppContext.
          getBeanFactory();
      factory.registerSingleton("guiceInjector",
          injector);
      factory.registerSingleton("passwordEncoder",
          injector.getInstance(PasswordEncoder.class));
      factory.registerSingleton("ambariLocalUserService",
          injector.getInstance(AmbariLocalUserDetailsService.class));
      factory.registerSingleton("ambariLdapAuthenticationProvider",
          injector.getInstance(AmbariLdapAuthenticationProvider.class));
      factory.registerSingleton("internalTokenAuthenticationFilter",
          injector.getInstance(InternalTokenAuthenticationFilter.class));
      factory.registerSingleton("ambariInternalAuthenticationProvider",
          injector.getInstance(AmbariInternalAuthenticationProvider.class));

      //Spring Security xml config depends on this Bean

      String[] contextLocations = {SPRING_CONTEXT_LOCATION};
View Full Code Here

    try {
      ClassPathXmlApplicationContext parentSpringAppContext =
          new ClassPathXmlApplicationContext();
      parentSpringAppContext.refresh();
      ConfigurableListableBeanFactory factory = parentSpringAppContext.
          getBeanFactory();
      factory.registerSingleton("guiceInjector",
          injector);
      factory.registerSingleton("passwordEncoder",
          injector.getInstance(PasswordEncoder.class));
      factory.registerSingleton("ambariLocalUserService",
          injector.getInstance(AmbariLocalUserDetailsService.class));
      factory.registerSingleton("ambariLdapAuthenticationProvider",
          injector.getInstance(AmbariLdapAuthenticationProvider.class));

      //Spring Security xml config depends on this Bean
      String[] contextLocations = {SPRING_CONTEXT_LOCATION};
      ClassPathXmlApplicationContext springAppContext = new
View Full Code Here

    try {
      ClassPathXmlApplicationContext parentSpringAppContext =
          new ClassPathXmlApplicationContext();
      parentSpringAppContext.refresh();
      ConfigurableListableBeanFactory factory = parentSpringAppContext.
          getBeanFactory();
      factory.registerSingleton("guiceInjector",
          injector);
      factory.registerSingleton("passwordEncoder",
          injector.getInstance(PasswordEncoder.class));
      factory.registerSingleton("ambariLocalUserService",
          injector.getInstance(AmbariLocalUserDetailsService.class));
      factory.registerSingleton("ambariLdapAuthenticationProvider",
          injector.getInstance(AmbariLdapAuthenticationProvider.class));
      //Spring Security xml config depends on this Bean

      String[] contextLocations = {SPRING_CONTEXT_LOCATION};
      ClassPathXmlApplicationContext springAppContext = new
View Full Code Here

            scriptStorage = new ScriptStorage();
            scriptStorage.setResourceLoader(ctx);
            scriptStorage.afterPropertiesSet();
            if(ctx instanceof ConfigurableApplicationContext)
            {
                ConfigurableListableBeanFactory bf = ((ConfigurableApplicationContext)ctx).getBeanFactory();
                bf.registerSingleton("scriptStorage", scriptStorage);
            }
        }
        return scriptStorage;
    }
View Full Code Here

     */
    public void doRuntimeConfiguration(RuntimeSpringConfiguration springConfig) {
        ApplicationContext context = springConfig.getUnrefreshedApplicationContext();
        AutowireCapableBeanFactory autowireCapableBeanFactory = context.getAutowireCapableBeanFactory();
        if(autowireCapableBeanFactory instanceof ConfigurableListableBeanFactory) {
            ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory)autowireCapableBeanFactory;
            ConversionService existingConversionService = beanFactory.getConversionService();
            ConverterRegistry converterRegistry;
            if(existingConversionService == null) {
                GenericConversionService conversionService = new GenericConversionService();
                converterRegistry = conversionService;
                beanFactory.setConversionService(conversionService);
            }
            else {
                converterRegistry = (ConverterRegistry)existingConversionService;
            }

View Full Code Here

        }

        // Apply any factory post processors in case the change listener has changed any
        // bean definitions (GRAILS-5763)
        GenericApplicationContext ctx = (GenericApplicationContext) applicationContext;
        ConfigurableListableBeanFactory beanFactory = ctx.getBeanFactory();
        for (BeanFactoryPostProcessor postProcessor : ctx.getBeanFactoryPostProcessors()) {
            try {
                postProcessor.postProcessBeanFactory(beanFactory);
            } catch (IllegalStateException e) {
                // post processor doesn't allow running again, just continue
View Full Code Here

     * Inits the engine, loading all needed data.
     */
    public Object start(Element config, ServiceContext context) throws Exception {
        logger = context.getLogger();
        this._applicationContext = context.getApplicationContext();
        ConfigurableListableBeanFactory beanFactory = context.getApplicationContext().getBeanFactory();

        appPath = context.getAppPath();
        String baseURL = context.getBaseUrl();
        String webappName = baseURL.substring(1);
        // TODO : if webappName is "". ie no context

        ServletContext servletContext = null;
        if (context.getServlet() != null) {
            servletContext = context.getServlet().getServletContext();
        }
        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 + "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 thread pool

        logger.info("  - Thread Pool...");

        threadPool = new ThreadPool();

        //------------------------------------------------------------------------
        //--- 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...");

        String schemaPluginsDir = dataDirectory.getSchemaPluginsDir().getAbsolutePath();
        String schemaCatalogueFile = dataDirectory.getConfigDir()+File.separator+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, Resources.locateResourcesDir(context), 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);
            String subversionPath = dataDirectory.getMetadataRevisionDir().getCanonicalPath();
            svnManager.setSubversionPath(subversionPath);
            svnManager.init();
        }

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

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

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

        _applicationContext.getBean(ThesaurusManager.class).init(context, appPath, 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, threadPool);

        //------------------------------------------------------------------------
        //--- 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());

View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.config.ConfigurableListableBeanFactory

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.