/** * Initializes the container. * * @throws Exception generic exception */ public void initialize() throws Exception { this.manager = ServiceContainerFactory.create( this.config ); }
/** * @return Returns the tempRootDir. */ private File getTempRootDir() { return makeAbsoluteFile(this.getApplicationRootDir(),this.tempRootDir); }
/** * Loads a containerConfiguration file and set is as the Avalon configuration to * be used for Configurable.configure(). Take care that the implementation uses * an InputStreamLocator to find the containerConfiguration which uses the * previously set application root directory. * * @param location the location of the containerConfiguration * @throws IOException loading the configuration failed */ public void loadContainerConfiguration(String location) throws IOException { this.loadContainerConfiguration(location, "false"); }
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); }
/** * 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(); }
ServiceContainerFactory.logger = serviceManagerConfig.getLogger(); configuration = serviceManagerConfig.createFinalConfiguration(); clazzName = getServiceContainerClazzName(configuration); Logger serviceContainerLogger = serviceManagerConfig.getLogger(); ); ContainerUtil.enableLogging( result, serviceManagerConfig.getLogger() ); ContainerUtil.contextualize( result, context ); if(serviceManagerConfig.getParentServiceManager() != null) ContainerUtil.service(result, serviceManagerConfig.getParentServiceManager());
/** * 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 ); }
/** * Constructor. */ public YAAFIContainer() { this.enableLogging( new ConsoleLogger( logLevel ) ); this.config = new ServiceContainerConfiguration(); }
/** * Add a new entry to the context by creating a new one. * * @param name the name of the new entry * @param value the value of the new entry */ public void addToContext(String name, Object value) { Validate.notEmpty(name, "name"); Validate.notNull(value, "value"); this.getContext().put(name, value); }
/** * 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.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();
/** * 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 ); }
/** * @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(); }
/** * Loads a containerConfiguration file and set is as the Avalon * configuration to be used for Configurable.configure(). Take * care that the implementation uses an InputStreamLocator to * find the containerConfiguration which uses the previously * set application root directory. * * @param location the location of the containerConfiguration * @throws IOException loading the configuration failed */ public void loadContainerConfiguration( String location ) throws IOException { this.loadContainerConfiguration( location, "false" ); }
/** * Add a new entry to the context by creating a new one. * @param name the name of the new entry * @param value the value of the new entry */ public void addToContext( String name, Object value ) { Validate.notEmpty(name,"name"); Validate.notNull(value,"value"); this.getContext().put( name, value ); }
/** * 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); } }