/** * 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; }
/** * 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; }
/** * 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(); }
/** * 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(); }
/** * 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; }
/** * Checks whether the module is configurable. A module is considered configurable if all dependencies exist and are * initialized. * * @param state the package state that should be checked. * @return true, if the module can be configured, false otherwise. */ private boolean isInitializable( 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_INITIALIZED ) { LOGGER.warn( "Required dependency '" + key + "' for module '" + state.getModule().getModuleClass() + " not initializable." ); return false; } } return true; }
/** * Checks whether the module is configurable. A module is considered configurable if all dependencies exist and * are initialized. * * @param state the package state that should be checked. * @return true, if the module can be configured, false otherwise. */ private boolean isInitializable(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_INITIALIZED) { LOGGER.warn("Required dependency '" + key + "' for module '" + state.getModule().getModuleClass() + " not initializable."); return false; } } return true; }
/** * 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; }
/** * Checks, whether the given module is already loaded in either the given tempModules list or the global package * registry. If tmpModules is null, only the previously installed modules are checked. * * @param tempModules a list of previously loaded modules. * @param module the module specification that is checked. * @return true, if the module is already loaded, false otherwise. */ private int containsModule( final ArrayList<Module> tempModules, final ModuleInfo module ) { if ( tempModules != null ) { final ModuleInfo[] mods = tempModules.toArray( new ModuleInfo[ tempModules.size() ] ); for ( int i = 0; i < mods.length; i++ ) { if ( mods[ i ].getModuleClass().equals( module.getModuleClass() ) ) { return RETURN_MODULE_LOADED; } } } final PackageState[] packageStates = this.modules.toArray( new PackageState[ this.modules.size() ] ); for ( int i = 0; i < packageStates.length; i++ ) { if ( packageStates[ i ].getModule().getModuleClass().equals( module.getModuleClass() ) ) { if ( packageStates[ i ].getState() == PackageState.STATE_ERROR ) { return RETURN_MODULE_ERROR; } else { return RETURN_MODULE_LOADED; } } } return RETURN_MODULE_UNKNOWN; }
for (int i = 0; i < packageStates.length; i++) if (packageStates[i].getModule().getModuleClass().equals(module.getModuleClass()))
if ( LOGGER.isDebugEnabled() ) { LOGGER.debug( "Conf: " + new PadMessage( mod.getModule().getModuleClass(), 70 ) + " [" + mod.getModule().getSubSystem() + ']' ); if ( LOGGER.isDebugEnabled() ) { LOGGER.debug( "Init: " + new PadMessage( mod.getModule().getModuleClass(), 70 ) + " [" + mod.getModule().getSubSystem() + ']' ); times.add( new BootTimeEntry( mod.getModule().getModuleClass(), stopWatch.getElapsedTime() ) );
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 ); }