public void startNestedComponent(ILifecycleComponent component, ILifecycleProgressMonitor monitor, String errorMessage, boolean require) throws SiteWhereException { component.lifecycleStart(monitor); if (require) { if (component.getLifecycleStatus() == LifecycleStatus.Error) { throw new ServerStartupException(component, errorMessage); } } getLifecycleComponents().put(component.getComponentId(), component); }
public void startNestedComponent(ILifecycleComponent component, ILifecycleProgressMonitor monitor, boolean require) throws SiteWhereException { component.lifecycleStart(monitor); if (require) { if (component.getLifecycleStatus() == LifecycleStatus.LifecycleError) { throw new ServerStartupException(component, "Unable to start '" + component.getComponentName() + "'", component.getLifecycleError()); } } getLifecycleComponents().put(component.getComponentId(), component); }
@Override public ILifecycleComponentState getComponentState() { LifecycleComponentState state = new LifecycleComponentState(); state.setComponentId(getComponentId()); state.setComponentName(getComponentName()); state.setStatus(getLifecycleStatus()); if (getLifecycleError() != null) { state.setErrorStack(parseErrors(getLifecycleError())); } if (getLifecycleComponents().size() > 0) { List<LifecycleComponentState> childStates = new ArrayList<>(); for (ILifecycleComponent child : getLifecycleComponents().values()) { childStates.add((LifecycleComponentState) child.getComponentState()); } Collections.sort(childStates, new Comparator<LifecycleComponentState>() { @Override public int compare(LifecycleComponentState o1, LifecycleComponentState o2) { return o1.getComponentName().compareTo(o2.getComponentName()); } }); state.setChildComponentStates(childStates); } return state; }
@Override public void stopNestedComponent(ILifecycleComponent component, ILifecycleProgressMonitor monitor) throws SiteWhereException { component.lifecycleStop(monitor); if (component.getLifecycleStatus() == LifecycleStatus.LifecycleError) { getLogger().error("Unable to stop '" + component.getComponentName() + "'", component.getLifecycleError()); } getLifecycleComponents().remove(component.getComponentId(), component); }
@Override public void initializeNestedComponent(ILifecycleComponent component, ILifecycleProgressMonitor monitor, boolean require) throws SiteWhereException { if (getMicroservice() == null) { throw new SiteWhereException("Microservice reference not set in parent component: " + getClass().getName()); } component.setMicroservice(getMicroservice()); component.lifecycleInitialize(monitor); if (require) { if (component.getLifecycleStatus() == LifecycleStatus.InitializationError) { throw new ServerStartupException(component, "Error initializing '" + component.getComponentName() + "'", component.getLifecycleError()); } } getLifecycleComponents().put(component.getComponentId(), component); }
for (UUID id : getLifecycleComponents().keySet()) { ILifecycleComponent sub = getLifecycleComponents().get(id); if ((sub.getLifecycleStatus() == LifecycleStatus.LifecycleError) || (sub.getLifecycleStatus() == LifecycleStatus.StoppedWithErrors)) {
for (UUID id : getLifecycleComponents().keySet()) { ILifecycleComponent sub = getLifecycleComponents().get(id); if ((sub.getLifecycleStatus() == LifecycleStatus.LifecycleError) || (sub.getLifecycleStatus() == LifecycleStatus.StartedWithErrors)) {