/** * Returns all active modules. This array does only contain modules which were successfully configured and * initialized. * * @return the list of all active modules. */ public Module[] getActiveModules() { final ArrayList<Module> mods = new ArrayList<Module>(); for ( int i = 0; i < this.modules.size(); i++ ) { final PackageState state = this.modules.get( i ); if ( state.getState() == PackageState.STATE_INITIALIZED ) { mods.add( state.getModule() ); } } return mods.toArray( new Module[ mods.size() ] ); }
final PackageState mod = this.modules.get( i ); if ( isConfigurable( mod ) == false ) { mod.markError(); continue; if ( mod.configure( this.booter ) ) { if ( LOGGER.isDebugEnabled() ) { LOGGER.debug( "Conf: " + new PadMessage( mod.getModule().getModuleClass(), 70 ) + " [" + mod.getModule().getSubSystem() + ']' ); final PackageState mod = this.modules.get( i ); if ( isInitializable( mod ) == false ) { mod.markError(); continue; if ( mod.initialize( this.booter ) ) { if ( LOGGER.isDebugEnabled() ) { LOGGER.debug( "Init: " + new PadMessage( mod.getModule().getModuleClass(), 70 ) + " [" + mod.getModule().getSubSystem() + ']' ); times.add( new BootTimeEntry( mod.getModule().getModuleClass(), stopWatch.getElapsedTime() ) );
/** * Returns an array of the currently active modules. The module definition returned contain all known modules, * including buggy and unconfigured instances. * * @return the modules. */ public Module[] getAllModules() { final Module[] mods = new Module[ this.modules.size() ]; for ( int i = 0; i < this.modules.size(); i++ ) { final PackageState state = this.modules.get( i ); mods[ i ] = state.getModule(); } return mods; }
public void testAll() throws Exception { final ArrayList states = new ArrayList(); final Module[] mods = ClassicEngineBoot.getInstance().getPackageManager().getAllModules(); int swingPreviewPos = 0; int fileConfigPos = 0; for ( int i = 0; i < mods.length; i++ ) { states.add( new PackageState( mods[i] ) ); } PackageSorter.sort( states ); for ( int i = 0; i < states.size(); i++ ) { final PackageState state = (PackageState) states.get( i ); if ( state.getModule().getClass().equals( SwingPreviewModule.class ) ) { logger.debug( "SwingPreviewModule: " + i ); swingPreviewPos = i; } if ( state.getModule().getClass().equals( FileConfigStoreModule.class ) ) { logger.debug( "File: " + i ); fileConfigPos = i; } } assertTrue( fileConfigPos < swingPreviewPos ); }
/** * Adds a module to the package manager. Once all modules are added, you have to call initializeModules() to configure * and initialize the new modules. * * @param modClass the module class */ public synchronized void addModule( final String modClass ) { if ( modClass == null ) { throw new NullPointerException(); } final ArrayList<Module> loadModules = new ArrayList<Module>(); final ModuleInfo modInfo = new DefaultModuleInfo( modClass, null, null, null ); if ( loadModule( modInfo, new ArrayList<Module>(), loadModules, false ) ) { for ( int i = 0; i < loadModules.size(); i++ ) { final Module mod = loadModules.get( i ); final PackageState state = new PackageState( mod ); this.modules.add( state ); this.modulesByClass.put( mod.getModuleClass(), state ); } } }
/** * Checks whether the given module is available. The method returns true if the module is defined and has been * properly initialized. * * @param moduleClass the module class to be checked. * @return true, if the module is available and initialized, false otherwise. */ public boolean isModuleAvailable( final String moduleClass ) { if ( moduleClass == null ) { throw new NullPointerException(); } final PackageState state = modulesByClass.get( moduleClass ); if ( state == null ) { return false; } return state.getState() == PackageState.STATE_INITIALIZED; }
if (isConfigurable(mod) == false) mod.markError(); continue; if (mod.configure(this.booter)) new PadMessage(mod.getModule().getModuleClass(), 70) + " [" + mod.getModule().getSubSystem() + ']'); if (isInitializable(mod) == false) mod.markError(); continue; if (mod.initialize(this.booter)) new PadMessage(mod.getModule().getModuleClass(), 70) + " [" + mod.getModule().getSubSystem() + ']'); times.add(new BootTimeEntry(mod.getModule().getModuleClass(), stopWatch.getElapsedTime()));
/** * Returns an array of the currently active modules. The module definition returned contain all known modules, * including buggy and unconfigured instances. * * @return the modules. */ public Module[] getAllModules() { final Module[] mods = new Module[this.modules.size()]; for (int i = 0; i < this.modules.size(); i++) { final PackageState state = this.modules.get(i); mods[i] = state.getModule(); } return mods; }
/** * Adds a module to the package manager. Once all modules are added, you have to call initializeModules() to configure * and initialize the new modules. * * @param modClass the module class */ public synchronized void addModule(final String modClass) { if (modClass == null) { throw new NullPointerException(); } final ArrayList<Module> loadModules = new ArrayList<Module>(); final ModuleInfo modInfo = new DefaultModuleInfo(modClass, null, null, null); if (loadModule(modInfo, new ArrayList<Module>(), loadModules, false)) { for (int i = 0; i < loadModules.size(); i++) { final Module mod = loadModules.get(i); final PackageState state = new PackageState(mod); this.modules.add(state); this.modulesByClass.put(mod.getModuleClass(), state); } } }
/** * Checks whether the given module is available. The method returns true if the module is defined and has been * properly initialized. * * @param moduleClass the module class to be checked. * @return true, if the module is available and initialized, false otherwise. */ public boolean isModuleAvailable(final String moduleClass) { if (moduleClass == null) { throw new NullPointerException(); } final PackageState state = modulesByClass.get(moduleClass); if (state == null) { return false; } return state.getState() == PackageState.STATE_INITIALIZED; }
/** * Returns all active modules. This array does only contain modules which were successfully configured and * initialized. * * @return the list of all active modules. */ public Module[] getActiveModules() { final ArrayList<Module> mods = new ArrayList<Module>(); for (int i = 0; i < this.modules.size(); i++) { final PackageState state = this.modules.get(i); if (state.getState() == PackageState.STATE_INITIALIZED) { mods.add(state.getModule()); } } return mods.toArray(new Module[mods.size()]); }
/** * Returns a basic string representation of this SortModule. This should be used for debugging purposes only. * * @return a string representation of this module. * @see Object#toString() */ public String toString() { final StringBuilder buffer = new StringBuilder( 100 ); buffer.append( "SortModule: " ); buffer.append( this.position ); buffer.append( ' ' ); buffer.append( this.state.getModule().getName() ); buffer.append( ' ' ); buffer.append( this.state.getModule().getModuleClass() ); return buffer.toString(); }
final PackageState state = new PackageState( module, PackageState.STATE_ERROR ); dropFailedModule( state ); return false; final PackageState state = new PackageState( module, PackageState.STATE_ERROR ); dropFailedModule( state ); return false; ( "Circular module reference: This module definition is invalid: " + module.getClass() ); final PackageState state = new PackageState( module, PackageState.STATE_ERROR ); dropFailedModule( state ); return false; if ( loadModule( required[ i ], incompleteModules, modules, true ) == false ) { LOGGER.debug( "Indicated failure for module: " + module.getModuleClass() ); final PackageState state = new PackageState( module, PackageState.STATE_ERROR ); dropFailedModule( state ); return false;
/** * Checks, whether a certain module is available. * * @param moduleDescription the module description of the desired module. * @return true, if the module is available and the version of the module is compatible, false otherwise. */ public boolean isModuleAvailable( final ModuleInfo moduleDescription ) { if ( moduleDescription == null ) { throw new NullPointerException(); } final PackageState[] packageStates = this.modules.toArray( new PackageState[ this.modules.size() ] ); for ( int i = 0; i < packageStates.length; i++ ) { final PackageState state = packageStates[ i ]; if ( state.getModule().getModuleClass().equals( moduleDescription.getModuleClass() ) ) { return ( state.getState() == PackageState.STATE_INITIALIZED ); } } return false; }
/** * Returns a basic string representation of this SortModule. This * should be used for debugging purposes only. * * @return a string representation of this module. * @see Object#toString() */ public String toString() { final StringBuilder buffer = new StringBuilder(100); buffer.append("SortModule: "); buffer.append(this.position); buffer.append(' '); buffer.append(this.state.getModule().getName()); buffer.append(' '); buffer.append(this.state.getModule().getModuleClass()); return buffer.toString(); }
final PackageState state = new PackageState(module, PackageState.STATE_ERROR); dropFailedModule(state); return false; final PackageState state = new PackageState(module, PackageState.STATE_ERROR); dropFailedModule(state); return false; ("Circular module reference: This module definition is invalid: " + module.getClass()); final PackageState state = new PackageState(module, PackageState.STATE_ERROR); dropFailedModule(state); return false; final PackageState state = new PackageState(module, PackageState.STATE_ERROR); dropFailedModule(state); return false;
/** * Checks whether the module is configurable. A module is considered configurable if all dependencies exist and are * configured. * * @param state the package state that should be checked. * @return true, if the module can be configured, false otherwise. */ private boolean isConfigurable( final PackageState state ) { final ModuleInfo[] requiredModules = state.getModule().getRequiredModules(); for ( int i = 0; i < requiredModules.length; i++ ) { final ModuleInfo module = requiredModules[ i ]; final String key = module.getModuleClass(); final PackageState dependentState = modulesByClass.get( key ); if ( dependentState == null ) { LOGGER.warn( "Required dependency '" + key + "' for module '" + state.getModule().getModuleClass() + " not found." ); return false; } if ( dependentState.getState() != PackageState.STATE_CONFIGURED ) { LOGGER.warn( "Required dependency '" + key + "' for module '" + state.getModule().getModuleClass() + " not configured." ); return false; } } return true; }
/** * Checks, whether a certain module is available. * * @param moduleDescription the module description of the desired module. * @return true, if the module is available and the version of the module is compatible, false otherwise. */ public boolean isModuleAvailable(final ModuleInfo moduleDescription) { if (moduleDescription == null) { throw new NullPointerException(); } final PackageState[] packageStates = this.modules.toArray(new PackageState[this.modules.size()]); for (int i = 0; i < packageStates.length; i++) { final PackageState state = packageStates[i]; if (state.getModule().getModuleClass().equals(moduleDescription.getModuleClass())) { return (state.getState() == PackageState.STATE_INITIALIZED); } } return false; }