/** * Create the final Avalon context passed to YAAFI containing * <ul> * <li>user-supplied context</li> * <li>urn:avalon:home</li> * <li>urn:avalon:temp</li> * <li>urn:avalon:name</li> * <li>urn:avalon:partition</li> * <li>urn:avalon:classloader</li> * </ul> * * @return the final Context * @throws Exception if filename not defined * @throws IOException if file not found */ public Context createFinalContext() throws IOException, Exception { // 1) add the application root dir this.addToContext(AvalonMerlinConstants.URN_AVALON_HOME, this.getApplicationRootDir()); // 2) add the temp root dir this.addToContext(AvalonMerlinConstants.URN_AVALON_TEMP, this.getTempRootDir()); // 3) add the Avalon name this.addToContext(AvalonMerlinConstants.URN_AVALON_NAME, ServiceConstants.ROLE_NAME); // 4) add the Avalon partition name this.addToContext(AvalonMerlinConstants.URN_AVALON_PARTITION, "root"); // 5) add the class loader this.addToContext(AvalonMerlinConstants.URN_AVALON_CLASSLOADER, this.getComponentClassLoader()); return this.getContext(); }
/** * @return Returns the tempRootDir. */ private File getTempRootDir() { return makeAbsoluteFile(this.getApplicationRootDir(),this.tempRootDir); }
DefaultConfiguration result = null; if (this.getContainerConfiguration() != null) { return this.getContainerConfiguration(); } else { ServiceConstants.CONTAINERFLAVOUR_CONFIG_KEY); containerFlavourConfig.setValue(this.getContainerFlavour()); containerClazzNameConfig.setValue(this.getServiceContainerClazzName()); componentRolesLocation.setValue(this.getComponentRolesLocation()); componentRolesIsEncrypted.setValue(this.isComponentRolesEncrypted()); componentConfigurationLocation.setValue(this.getComponentConfigurationLocation()); componentConfigurationIsEncrypted.setValue(this.isComponentConfigurationEncrypted()); parameterConfigurationLocation.setValue(this.getParametersLocation()); parameterConfigurationIsEncrypted.setValue(this.isParametersEncrypted()); if (this.hasServiceManagerList()) { DefaultConfiguration serviceManagerListConfig = new DefaultConfiguration( ServiceConstants.SERVICEMANAGER_LIST_KEY);
/** * Initialize the instance * * @throws Exception the initialization failed */ public void initialize() throws Exception { this.getLogger().debug( "Initializing " + this.getClass().getName() ); ServiceContainerConfiguration config = new ServiceContainerConfiguration(); // initialize the Avalon container config.setLogger( this.getLogger() ); config.setApplicationRootDir( this.getApplicationHome() ); config.setTempRootDir( this.getTempHome() ); config.loadContainerConfiguration( this.getContainerConfigValue(), "auto" ); this.container = ServiceContainerFactory.create( config ); // initialize shutdown hook of JVM for a server application if( this.hasShutdownHook() ) { this.getLogger().debug( "Registering shutdown hook" ); Shutdown shutdown = new Shutdown( this ); this.shutdownThread = new Thread( shutdown, "ShutdownThread" ); Runtime.getRuntime().addShutdownHook( this.shutdownThread ); } this.setInitialized(true); }
Configuration result = null; InputStreamLocator locator = new InputStreamLocator(this.getApplicationRootDir(), this.getLogger()); is = CryptoStreamFactory.getDecryptingInputStream(is, isEncrypted); result = builder.build(is); this.setContainerConfiguration(result); } catch (Exception e) { String msg = "Unable to parse the following file : " + location; this.getLogger().error(msg, e); throw new IOException(msg); this.getLogger().error(msg); throw new IOException(msg);
ServiceContainerFactory.logger = serviceManagerConfig.getLogger(); configuration = serviceManagerConfig.createFinalConfiguration(); Logger serviceContainerLogger = serviceManagerConfig.getLogger(); ); ContainerUtil.enableLogging( result, serviceManagerConfig.getLogger() ); ContainerUtil.contextualize( result, context ); if(serviceManagerConfig.getParentServiceManager() != null) ContainerUtil.service(result, serviceManagerConfig.getParentServiceManager());
this.config.setComponentConfigurationLocation( configFileName ); this.config.setComponentRolesLocation( roleFileName ); this.config.setParametersLocation( parametersFileName ); this.config.setLogger( new ConsoleLogger( logLevel ) );
/** * Constructor. */ public YAAFIContainer() { this.enableLogging( new ConsoleLogger( logLevel ) ); this.config = new ServiceContainerConfiguration(); }
/** * Create a fully initialized YAFFI service container. * * @param serviceManagerConfig the configuration to use * @return the service container * @throws Exception the creation failed */ public static ServiceContainer create( ServiceContainerConfiguration serviceManagerConfig) throws Exception { Validate.notNull(serviceManagerConfig,"serviceManagerConfig"); Context context = serviceManagerConfig.createFinalContext(); return ServiceContainerFactory.create( serviceManagerConfig, context ); }
/** * Add a hashtable to the context * @param hashtable the Hashtable to be added */ public void addToContext( Hashtable hashtable ) { Validate.notNull(hashtable,"hashtable"); String name = null; Object value = null; Enumeration keys = hashtable.keys(); while( keys.hasMoreElements() ) { name = (String) keys.nextElement(); value = hashtable.get( name ); this.addToContext( name, value ); } }
if( this.getContainerConfiguration() != null ) return this.getContainerConfiguration(); containerFlavourConfig.setValue( this.getContainerFlavour() ); containerClazzNameConfig.setValue( this.getServiceContainerClazzName() ); this.getComponentRolesLocation() ); this.isComponentRolesEncrypted() ); this.getComponentConfigurationLocation() ); this.isComponentConfigurationEncrypted() ); this.getParametersLocation() ); this.isParametersEncrypted() ); if(this.hasServiceManagerList())
/** * Initialize the instance * * @throws Exception the initialization failed */ public void initialize() throws Exception { this.getLogger().debug( "Initializing " + this.getClass().getName() ); ServiceContainerConfiguration config = new ServiceContainerConfiguration(); // initialize the Avalon container config.setLogger( this.getLogger() ); config.setApplicationRootDir( this.getApplicationHome() ); config.setTempRootDir( this.getTempHome() ); config.loadContainerConfiguration( this.getContainerConfigValue(), "auto" ); this.container = ServiceContainerFactory.create( config ); // initialize shutdown hook of JVM for a server application if( this.hasShutdownHook() ) { this.getLogger().debug( "Registering shutdown hook" ); Shutdown shutdown = new Shutdown( this ); this.shutdownThread = new Thread( shutdown, "ShutdownThread" ); Runtime.getRuntime().addShutdownHook( this.shutdownThread ); } this.setInitialized(true); }
this.getApplicationRootDir(), this.getLogger() ); this.setContainerConfiguration( result ); this.getLogger().error( msg , e ); throw new IOException(msg); this.getLogger().error(msg); throw new IOException(msg);
ServiceContainerFactory.logger = serviceManagerConfig.getLogger(); configuration = serviceManagerConfig.createFinalConfiguration(); Logger serviceContainerLogger = serviceManagerConfig.getLogger(); ); ContainerUtil.enableLogging( result, serviceManagerConfig.getLogger() ); ContainerUtil.contextualize( result, context ); if(serviceManagerConfig.getParentServiceManager() != null) ContainerUtil.service(result, serviceManagerConfig.getParentServiceManager());
/** * @return Returns the tempRootDir. * @throws Exception * @throws IOException */ private File getTempRootDir() throws IOException, Exception { return makeAbsoluteFile(this.getApplicationRootDir(), this.tempRootDir); }
/** * Constructor. * * @param logLevel the log level to be used */ public YAAFIContainer(int logLevel) { this.logLevel = logLevel; this.enableLogging( new ConsoleLogger( logLevel ) ); this.config = new ServiceContainerConfiguration(); }
/** * Create a fully initialized YAFFI service container. * * @param serviceManagerConfig the configuration to use * @return the service container * @throws Exception the creation failed */ public static ServiceContainer create( ServiceContainerConfiguration serviceManagerConfig) throws Exception { Validate.notNull(serviceManagerConfig,"serviceManagerConfig"); Context context = serviceManagerConfig.createFinalContext(); return ServiceContainerFactory.create( serviceManagerConfig, context ); }
/** * Add a hashtable to the context * * @param hashtable the Hashtable to be added */ public void addToContext(Hashtable<?, ?> hashtable) { Validate.notNull(hashtable, "hashtable"); String name = null; Object value = null; Enumeration<?> keys = hashtable.keys(); while (keys.hasMoreElements()) { name = (String) keys.nextElement(); value = hashtable.get(name); this.addToContext(name, value); } }
this.addToContext( AvalonMerlinConstants.URN_AVALON_HOME, this.getApplicationRootDir() ); this.addToContext( AvalonMerlinConstants.URN_AVALON_TEMP, this.getTempRootDir() ); this.addToContext( AvalonMerlinConstants.URN_AVALON_NAME, ServiceConstants.ROLE_NAME this.addToContext( AvalonMerlinConstants.URN_AVALON_PARTITION, "root" this.addToContext( AvalonMerlinConstants.URN_AVALON_CLASSLOADER, this.getComponentClassLoader() ); return this.getContext();