/** * Index and optimize the controller state for the current controller * * @param the state * @return the indexed state */ protected ControllerState indexState(ControllerState state) { if (controller == null || controller instanceof AbstractController == false || state.equals(ControllerState.ERROR)) return state; return ((AbstractController)controller).indexState(state); } }
if (state == null || state.equals(item.getWhenRequired()))
public Set<ControllerContext> getNotInstalled() { lockWrite(); try { Set<ControllerContext> result = new HashSet<ControllerContext>(errorContexts.values()); for (ControllerState state : stateModel) { if (indexedInstalledState.equals(state)) break; Set<ControllerContext> stateContexts = getContextsByState(state); result.addAll(stateContexts); } return result; } finally { unlockWrite(); } }
public void toString(JBossStringBuilder buffer) { if (bean != null) buffer.append("bean=").append(bean); if (ControllerState.INSTALLED.equals(dependentState) == false) buffer.append(" dependentState=" + dependentState); buffer.append(" "); super.toString(buffer); }
/** * Check complete on deployment context. * * @param context the deployment context * @param contextsInError contexts in error map * @param contextsMissingDependencies contexts missing dependecies map * @param notInstalled the not installed contexts * @param states controller states */ protected void checkControllerContext( ControllerContext context, Map<String, Throwable> contextsInError, Map<String, Set<MissingDependency>> contextsMissingDependencies, Set<ControllerContext> notInstalled, List<ControllerState> states) { if (context != null) { if (context.getState().equals(context.getRequiredState()) == false && notInstalled.contains(context)) { checkControllerContext(context, contextsInError, contextsMissingDependencies, states); } } }
public ControllerContext getContext(Object name, ControllerState state) { ControllerContext context = super.getContext(name, state); if (context != null) return context; if (state == null || ControllerState.INSTALLED.equals(state)) { org.jboss.kernel.spi.registry.KernelRegistry registry = kernel.getRegistry(); try { return registry.findEntry(name); } catch (Throwable ignored) { } } return null; }
for (CallbackItem<?> item : items) if (item.getWhenRequired().equals(state))
/** * Change a bean * * @param controller the controller * @param context the context * @param state the state * @throws Throwable for any error */ protected void changeBean(KernelController controller, KernelControllerContext context, ControllerState state) throws Throwable { if (ControllerMode.MANUAL.equals(context.getMode()) && ControllerState.ERROR.equals(context.getState()) == false) controller.change(context, state); }
if (ControllerState.ERROR.equals(fromState)) return; if (!stateModel.isValidState(fromState))
if (context.getState().equals(context.getRequiredState())) i.remove();
public void toString(JBossStringBuilder buffer) { super.toString(buffer); if (property != null) buffer.append(" property=").append(property); if (cardinality != null) buffer.append(" cardinality=").append(cardinality); if (signature != null) buffer.append(" signature=").append(signature); if (ControllerState.INSTALLED.equals(dependentState) == false) buffer.append(" dependentState=" + dependentState); }
if (callback.getWhenRequired().equals(state) == false) throw new IllegalArgumentException(callback + " does not have the required state " + state);
/** * Change a context * * @param controller the controller * @param context the context * @param requiredState the require state * @param logWait log the waiting dependencies * @throws Throwable for any error */ private void doChange(KernelController controller, ServiceControllerContext context, ControllerState requiredState, String logWait) throws Throwable { if (ControllerMode.ON_DEMAND.equals(context.getMode()) == false) { controller.change(context, requiredState); ControllerState state = context.getState(); if (logWait != null && requiredState.equals(state) == false && state != ControllerState.ERROR) log.debug("Waiting in " + logWait + " of " + context.getObjectName() + " on " + getUnresolvedDependencies(context, requiredState)); } }
public void addAlias(Object alias, Object original) throws Throwable { Map<ControllerState, ControllerContextAction> map = createAliasActions(); ControllerContextActions actions = new AbstractControllerContextActions(map); AliasControllerContext context = new InnerAliasControllerContext(alias, getId(), original, actions); preAliasInstall(context); install(context); // is alias in error Throwable error = context.getError(); if (error != null) throw error; if (ControllerState.ERROR.equals(context.getState())) throw new IllegalArgumentException("Alias " + context + " is in error."); }
/** * Handle lifecycle callbacks. * * @param context the context * @param state the state * @param install is it install or uninstall * @throws Throwable for any error */ protected void handleLifecycleCallbacks(ControllerContext context, ControllerState state, boolean install) throws Throwable { DependencyInfo di = context.getDependencyInfo(); if (di != null) { List<LifecycleCallbackItem> callbacks = di.getLifecycleCallbacks(); for (LifecycleCallbackItem callback : callbacks) { if (callback.getWhenRequired().equals(state)) { if (install) callback.install(context); else callback.uninstall(context); } } } }
if (otherState.equals(previousState) == false) return ResolvedState.UNRESOLVED;
/** * Change a context * * @param controller the controller * @param context the context * @param requiredState the require state * @param logWait log the waiting dependencies * @throws Throwable for any error */ private void doChange(KernelController controller, ServiceControllerContext context, ControllerState requiredState, String logWait) throws Throwable { if (ControllerMode.ON_DEMAND.equals(context.getMode()) == false) { controller.change(context, requiredState); ControllerState state = context.getState(); if (logWait != null && requiredState.equals(state) == false && state != ControllerState.ERROR) log.debugf("Waiting in %1s of %2s on %3s", logWait, context.getObjectName(), getUnresolvedDependencies(context, requiredState)); } }
public void toString(JBossStringBuilder buffer) { buffer.append("name=").append(name); if (aliases != null) buffer.append(" aliases=").append(aliases); buffer.append(" target=").append(target); if (error != null || state.equals(ControllerState.ERROR) == false) buffer.append(" state=").append(state.getStateString()); if (ControllerMode.AUTOMATIC.equals(mode) == false) { buffer.append(" mode=").append(mode.getModeString()); buffer.append(" requiredState=").append(requiredState.getStateString()); } if (ErrorHandlingMode.DISCARD.equals(errorHandlingMode) == false) buffer.append(" error-handling=").append(errorHandlingMode); if (dependencies != null) buffer.append(" depends=").append(dependencies); if (error != null) { StringWriter stringWriter = new StringWriter(); PrintWriter writer = new PrintWriter(stringWriter); error.printStackTrace(writer); writer.flush(); buffer.append(" error=").append(stringWriter.getBuffer()); } }
public void toShortString(JBossStringBuilder buffer) { buffer.append("name=").append(name); if (aliases != null) buffer.append(" aliases=").append(aliases); if (error != null || state.equals(ControllerState.ERROR) == false) buffer.append(" state=").append(state.getStateString()); if (ControllerMode.AUTOMATIC.equals(mode) == false) { buffer.append(" mode=").append(mode.getModeString()); buffer.append(" requiredState=").append(requiredState.getStateString()); } if (ErrorHandlingMode.DISCARD.equals(errorHandlingMode) == false) buffer.append(" error-handling=").append(errorHandlingMode); if (error != null) buffer.append(" error=").append(error.getClass().getName()).append(": ").append(error.getMessage()); }
if (indexedInstalledState.equals(context.getRequiredState())) return;