/** * The <code>getNextNotificationSequenceNumber</code> method returns the next sequence number for use in notifications. * * @return a <code>long</code> value */ protected long getNextNotificationSequenceNumber() { return nextNotificationSequenceNumber(); }
public void create() throws Exception { jbossInternalCreate(); }
public void start() throws Exception { jbossInternalStart(); }
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();
public void jbossInternalLifecycle(String method) throws Exception { if (method == null) throw ServiceMBeanLogger.ROOT_LOGGER.nullMethodName(); if (method.equals("create")) jbossInternalCreate(); else if (method.equals("start")) jbossInternalStart(); else if (method.equals("stop")) jbossInternalStop(); else if (method.equals("destroy")) jbossInternalDestroy(); else throw ServiceMBeanLogger.ROOT_LOGGER.unknownLifecycleMethod(method); }
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 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 installAction(ServiceControllerContext context) throws Throwable { MBeanServer server = context.getServiceController().getMBeanServer(); ObjectName objectName = context.getObjectName(); ServiceMetaData metaData = context.getServiceMetaData(); Object mbean = context.getTarget(); ServiceInstance instance = ServiceCreator.install(server, objectName, metaData, mbean); context.setTarget(instance.getResource()); }
public void destroy() { try { jbossInternalDestroy(); } catch (Throwable t) { log.warn(ServiceMBeanLogger.ROOT_LOGGER.errorInDestroy(jbossInternalDescription()), t); } }
public void stop() { try { jbossInternalStop(); } catch (Throwable t) { log.warn(ServiceMBeanLogger.ROOT_LOGGER.errorInStop(jbossInternalDescription()), t); } }
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); } }
protected void createService() throws Exception { // create the Barrier barrier = new Barrier(getServiceName()); initBarrier(); }
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); } } }
/** * 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; }
protected String jbossInternalDescription() { if (serviceName != null) return serviceName.toString(); else return getName(); }
public void postDeregister() { if (state != DESTROYED) { unregisterIgnored = true; if (log.isDebugEnabled()) { log.debug("Ignoring postDeregister call; current state is " + getStateString()); } return; } unregisterIgnored = false; server = null; serviceName = null; state = UNREGISTERED; }
protected void createService() throws Exception { // create the Barrier barrier = new Barrier(getServiceName()); initBarrier(); }
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); } } }