/** * Compares this object with the given other object for equality. * * @param o the other object to be compared * @return true, if the other object is also a PackageState containing the same module, false otherwise. * @see Object#equals(Object) */ public boolean equals( final Object o ) { if ( this == o ) { return true; } if ( !( o instanceof PackageState ) ) { return false; } final PackageState packageState = (PackageState) o; if ( !this.module.getModuleClass().equals( packageState.module.getModuleClass() ) ) { return false; } return true; }
/** * Compares this object with the given other object for equality. * * @param o the other object to be compared * @return true, if the other object is also a PackageState containing * the same module, false otherwise. * @see Object#equals(Object) */ public boolean equals(final Object o) { if (this == o) { return true; } if (!(o instanceof PackageState)) { return false; } final PackageState packageState = (PackageState) o; if (!this.module.getModuleClass().equals(packageState.module.getModuleClass())) { return false; } return true; }
/** * 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 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(); }
/** * 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 ); } } }
/** * 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 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 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; }
for ( int i = 0; i < activeModules.size(); i++ ) { final Module mod = activeModules.get( i ); p.print( new PadMessage( mod.getModuleClass(), 70 ) ); p.print( " [" ); p.print( mod.getSubSystem() );
/** * 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; }
p.print(new PadMessage(mod.getModuleClass(), 70)); p.print(" ["); p.print(mod.getSubSystem());
/** * 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 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; }
/** * 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; }
for (int i = 0; i < packageStates.length; i++) if (packageStates[i].getModule().getModuleClass().equals(module.getModuleClass()))
final SortModule mod = new SortModule( state ); weightModules.add( mod ); moduleMap.put( state.getModule().getModuleClass(), mod );
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() ) );
if ( moduleContained == RETURN_MODULE_ERROR ) { LOGGER.debug( "Indicated failure for module: " + module.getModuleClass() ); final PackageState state = new PackageState( module, PackageState.STATE_ERROR ); dropFailedModule( state ); for ( int i = 0; i < required.length; i++ ) { 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 );
new PadMessage(mod.getModule().getModuleClass(), 70) + " [" + mod.getModule().getSubSystem() + ']'); new PadMessage(mod.getModule().getModuleClass(), 70) + " [" + mod.getModule().getSubSystem() + ']'); times.add(new BootTimeEntry(mod.getModule().getModuleClass(), stopWatch.getElapsedTime()));