startIgnored = true; if (log.isDebugEnabled()) { log.debug("Ignoring start call; current state is " + getStateString()); sendStateChangeNotification(STOPPED, STARTING, getName() + " starting", null); if (log.isDebugEnabled()) { log.debug("Starting " + jbossInternalDescription()); startService(); } catch (Exception e) { state = FAILED; sendStateChangeNotification(STARTING, FAILED, getName() + " failed", e); log.warn(ServiceMBeanLogger.ROOT_LOGGER.startingFailed(jbossInternalDescription()), e); throw e; sendStateChangeNotification(STARTING, STARTED, getName() + " started", null); if (log.isDebugEnabled()) { log.debug("Started " + jbossInternalDescription()); stop();
stopIgnored = true; if (log.isDebugEnabled()) { log.debug("Ignoring stop call; current state is " + getStateString()); sendStateChangeNotification(STARTED, STOPPING, getName() + " stopping", null); if (log.isDebugEnabled()) { log.debug("Stopping " + jbossInternalDescription()); stopService(); } catch (Throwable e) { state = FAILED; sendStateChangeNotification(STOPPING, FAILED, getName() + " failed", e); log.warn(ServiceMBeanLogger.ROOT_LOGGER.stoppingFailed(jbossInternalDescription()), e); return; sendStateChangeNotification(STOPPING, STOPPED, getName() + " stopped", null); if (log.isDebugEnabled()) { log.debug("Stopped " + jbossInternalDescription()); destroy();
protected void jbossInternalCreate() throws Exception { // if (state == CREATED || state == STARTING || state == STARTED // || state == STOPPING || state == STOPPED) if (state != REGISTERED) { createIgnored = true; if (log.isDebugEnabled()) { log.debug("Ignoring create call; current state is " + getStateString()); } return; } createIgnored = false; if (log.isDebugEnabled()) { log.debug("Creating " + jbossInternalDescription()); } try { createService(); state = CREATED; } catch (Exception e) { log.warn(ServiceMBeanLogger.ROOT_LOGGER.initializationFailed(jbossInternalDescription()), e); throw e; } if (log.isDebugEnabled()) { log.debug("Created " + jbossInternalDescription()); } if (startIgnored) { start(); } }
public void postRegister(Boolean registrationDone) { if (!registrationDone.booleanValue()) { log.debug("Registration is not done -> stop"); stop(); } else { state = REGISTERED; if (createIgnored) { try { create(); } catch (Exception e) { log.error(ServiceMBeanLogger.ROOT_LOGGER.postRegisterInitializationFailed(), e); } } } }
/** * Helper for sending out state change notifications */ private void sendStateChangeNotification(int oldState, int newState, String msg, Throwable t) { long now = System.currentTimeMillis(); AttributeChangeNotification stateChangeNotification = new AttributeChangeNotification(this, getNextNotificationSequenceNumber(), now, msg, "State", "java.lang.Integer", new Integer(oldState), new Integer(newState)); stateChangeNotification.setUserData(t); sendNotification(stateChangeNotification); } }
log.debug("Ignoring start call; current state is " + getStateString()); return; create(); sendStateChangeNotification(STOPPED, STARTING, getName() + " starting", null); log.debug("Starting " + jbossInternalDescription()); startService(); sendStateChangeNotification(STARTING, FAILED, getName() + " failed", e); log.debug("Starting failed " + jbossInternalDescription(), e); throw e; sendStateChangeNotification(STARTING, STARTED, getName() + " started", null); log.debug("Started " + jbossInternalDescription());
protected void jbossInternalDestroy() { if (state != STOPPED) { destroyIgnored = true; if (log.isDebugEnabled()) { log.debug("Ignoring destroy call; current state is " + getStateString()); } return; } destroyIgnored = false; if (log.isDebugEnabled()) { log.debug("Destroying " + jbossInternalDescription()); } try { destroyService(); } catch (Throwable t) { log.warn(ServiceMBeanLogger.ROOT_LOGGER.destroyingFailed(jbossInternalDescription()), t); } state = DESTROYED; if (log.isDebugEnabled()) { log.debug("Destroyed " + jbossInternalDescription()); } if (unregisterIgnored) { postDeregister(); } }
protected void jbossInternalDestroy() { if (state == DESTROYED) { log.debug("Ignoring destroy call; current state is " + getStateString()); return; } if (state == STARTED) { log.debug("Destroy requested before stop, calling stop now"); stop(); } log.debug("Destroying " + jbossInternalDescription()); try { destroyService(); } catch (Throwable t) { log.warn("Destroying failed " + jbossInternalDescription(), t); } state = DESTROYED; log.debug("Destroyed " + jbossInternalDescription()); }
protected void jbossInternalCreate() throws Exception { if (state == CREATED || state == STARTING || state == STARTED || state == STOPPING || state == STOPPED) { log.debug("Ignoring create call; current state is " + getStateString()); return; } log.debug("Creating " + jbossInternalDescription()); try { createService(); state = CREATED; } catch (Exception e) { log.debug("Initialization failed " + jbossInternalDescription(), e); throw e; } log.debug("Created " + jbossInternalDescription()); }
@Override protected void startService() throws Exception { super.startService(); try { if (startMethod != null) startMethod.invoke(delegate); } catch (InvocationTargetException e) { Throwable t = e.getCause(); if (t instanceof Exception) throw (Exception)t; else throw new RuntimeException(t); } }
@Override protected void stopService() throws Exception { super.stopService(); try { if (stopMethod != null) stopMethod.invoke(delegate); } catch (InvocationTargetException e) { Throwable t = e.getCause(); if (t instanceof Exception) throw (Exception)t; else throw new RuntimeException(t); } }
public void setJndiName(String jndiName) throws Exception { String oldName = this.jndiName; this.jndiName = jndiName; if (super.getState() == STARTED) { unbind(oldName); try { rebind(); } catch (NamingException ne) { log.error("Failed to rebind Scheduler", ne); throw new SchedulerConfigException( "Failed to rebind Scheduler - ", ne); } } }
protected String jbossInternalDescription() { if (serviceName != null) return serviceName.toString(); else return getName(); }
/** * Callback method of {@link javax.management.MBeanRegistration} before the MBean is registered at the JMX Agent. * * <p> * <b>Attention</b>: Always call this method when you overwrite it in a subclass because it saves the Object Name of the * MBean. * * @param server Reference to the JMX Agent this MBean is registered on * @param name Name specified by the creator of the MBean. Note that you can overwrite it when the given ObjectName is null * otherwise the change is discarded (maybe a bug in JMX-RI). * @return the ObjectName * @throws Exception for any error */ public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { this.server = server; serviceName = getObjectName(server, name); return serviceName; }
/** * @see org.jboss.ha.framework.server.EventFacility#notifyListeners(java.util.EventObject) */ public void notifyListeners(Notification notification) { super.sendNotification(notification); }
@Override protected void destroyService() throws Exception { super.destroyService(); try { if (destroyMethod != null) destroyMethod.invoke(delegate); } catch (InvocationTargetException e) { Throwable t = e.getCause(); if (t instanceof Exception) throw (Exception)t; else throw new RuntimeException(t); } }
@Override protected void createService() throws Exception { super.createService(); try { if (createMethod != null) createMethod.invoke(delegate); } catch (InvocationTargetException e) { Throwable t = e.getCause(); if (t instanceof Exception) throw (Exception)t; else throw new RuntimeException(t); } }
log.debugf("Ignoring start call; current state is %1s", getStateString()); return; create(); sendStateChangeNotification(STOPPED, STARTING, getName() + " starting", null); log.debugf("Starting %1s", jbossInternalDescription()); startService(); sendStateChangeNotification(STARTING, FAILED, getName() + " failed", e); log.debugf(e, "Starting failed %1s", jbossInternalDescription()); throw e; sendStateChangeNotification(STARTING, STARTED, getName() + " started", null); log.debugf("Started %1s", jbossInternalDescription());
protected void jbossInternalDestroy() { if (state != STOPPED) { destroyIgnored = true; if (log.isDebugEnabled()) { log.debug("Ignoring destroy call; current state is " + getStateString()); } return; } destroyIgnored = false; if (log.isDebugEnabled()) { log.debug("Destroying " + jbossInternalDescription()); } try { destroyService(); } catch (Throwable t) { log.warn(ServiceMBeanLogger.ROOT_LOGGER.destroyingFailed(jbossInternalDescription()), t); } state = DESTROYED; if (log.isDebugEnabled()) { log.debug("Destroyed " + jbossInternalDescription()); } if (unregisterIgnored) { postDeregister(); } }
protected void jbossInternalDestroy() { if (state == DESTROYED) { log.debugf("Ignoring destroy call; current state is %1s", getStateString()); return; } if (state == STARTED) { log.debugf("Destroy requested before stop, calling stop now"); stop(); } log.debugf("Destroying %1s", jbossInternalDescription()); try { destroyService(); } catch (Throwable t) { log.warn("Destroying failed " + jbossInternalDescription(), t); } state = DESTROYED; log.debugf("Destroyed %1s", jbossInternalDescription()); }