List of usage examples for org.springframework.jmx JmxException JmxException
public JmxException(String msg, Throwable cause)
From source file:net.nicoll.boot.daemon.SpringApplicationAdminClient.java
/** * Check if the spring application managed by this instance is ready. Returns * {@code false} if the mbean is not yet deployed so this method should be repeatedly * called until a timeout is reached.//from w ww. j av a 2 s .c o m * @return {@code true} if the application is ready to service requests * @throws org.springframework.jmx.JmxException if the JMX service could not be contacted */ public boolean isReady() { try { return (Boolean) this.connection.getAttribute(this.objectName, "Ready"); } catch (InstanceNotFoundException ex) { return false; // Instance not available yet } catch (AttributeNotFoundException ex) { throw new IllegalStateException("Unexpected: attribute 'Ready' not available", ex); } catch (ReflectionException ex) { throw new JmxException("Failed to retrieve Ready attribute", ex.getCause()); } catch (MBeanException ex) { throw new JmxException(ex.getMessage(), ex); } catch (IOException ex) { throw new JmxException(ex.getMessage(), ex); } }
From source file:net.nicoll.boot.daemon.SpringApplicationAdminClient.java
/** * Stop the application managed by this instance. * @throws JmxException if the JMX service could not be contacted * @throws IOException if an I/O error occurs * @throws InstanceNotFoundException if the lifecycle mbean cannot be found *///from www .ja v a 2 s. c o m public void stop() throws IOException, InstanceNotFoundException { try { this.connection.invoke(this.objectName, "shutdown", null, null); } catch (ReflectionException ex) { throw new JmxException("Shutdown failed", ex.getCause()); } catch (MBeanException ex) { throw new JmxException("Could not invoke shutdown operation", ex); } }
From source file:org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanRegistrar.java
/** * Unregister the specified {@link ObjectName} if necessary. * @param objectName the {@link ObjectName} of the endpoint to unregister * @return {@code true} if the endpoint was unregistered, {@code false} if no such * endpoint was found/* w w w. ja v a 2s . co m*/ */ public boolean unregisterEndpointMbean(ObjectName objectName) { try { if (logger.isDebugEnabled()) { logger.debug("Unregister endpoint with ObjectName '" + objectName + "' " + "from the JMX domain"); } this.mBeanServer.unregisterMBean(objectName); return true; } catch (InstanceNotFoundException ex) { return false; } catch (MBeanRegistrationException ex) { throw new JmxException("Failed to unregister MBean with ObjectName '" + objectName + "'", ex); } }
From source file:org.springframework.boot.actuate.endpoint.jmx.JmxEndpointExporter.java
private void unregister(ObjectName objectName) { try {//from w w w.j av a2 s .co m if (logger.isDebugEnabled()) { logger.debug("Unregister endpoint with ObjectName '" + objectName + "' " + "from the JMX domain"); } this.mBeanServer.unregisterMBean(objectName); } catch (InstanceNotFoundException ex) { // Ignore and continue } catch (MBeanRegistrationException ex) { throw new JmxException("Failed to unregister MBean with ObjectName '" + objectName + "'", ex); } }
From source file:org.springframework.jmx.access.NotificationListenerRegistrar.java
/** * Registers the specified {@code NotificationListener}. * <p>Ensures that an {@code MBeanServerConnection} is configured and attempts * to detect a local connection if one is not supplied. *///ww w . ja va 2s . c o m public void prepare() { if (this.server == null) { this.server = this.connector.connect(this.serviceUrl, this.environment, this.agentId); } try { this.actualObjectNames = getResolvedObjectNames(); if (this.actualObjectNames != null) { if (logger.isDebugEnabled()) { logger.debug( "Registering NotificationListener for MBeans " + Arrays.asList(this.actualObjectNames)); } for (ObjectName actualObjectName : this.actualObjectNames) { this.server.addNotificationListener(actualObjectName, getNotificationListener(), getNotificationFilter(), getHandback()); } } } catch (IOException ex) { throw new MBeanServerNotFoundException( "Could not connect to remote MBeanServer at URL [" + this.serviceUrl + "]", ex); } catch (Exception ex) { throw new JmxException("Unable to register NotificationListener", ex); } }