javax.management.InstanceNotFoundException Java Examples
The following examples show how to use
javax.management.InstanceNotFoundException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArrayNotificationBuffer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static boolean isInstanceOf(final MBeanServer mbs, final ObjectName name, final String className) { PrivilegedExceptionAction<Boolean> act = new PrivilegedExceptionAction<Boolean>() { public Boolean run() throws InstanceNotFoundException { return mbs.isInstanceOf(name, className); } }; try { return AccessController.doPrivileged(act); } catch (Exception e) { logger.fine("isInstanceOf", "failed: " + e); logger.debug("isInstanceOf", e); return false; } }
Example #2
Source File: RMIConnector.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException, IOException { if (logger.debugOn()) logger.debug("getAttribute", "name=" + name + ", attribute=" + attribute); final ClassLoader old = pushDefaultClassLoader(); try { return connection.getAttribute(name, attribute, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.getAttribute(name, attribute, delegationSubject); } finally { popDefaultClassLoader(old); } }
Example #3
Source File: DefaultMBeanServerInterceptor.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private NotificationListener getListener(ObjectName listener) throws ListenerNotFoundException { // ---------------- // Get listener object // ---------------- DynamicMBean instance; try { instance = getMBean(listener); } catch (InstanceNotFoundException e) { throw EnvHelp.initCause( new ListenerNotFoundException(e.getMessage()), e); } Object resource = getResource(instance); if (!(resource instanceof NotificationListener)) { final RuntimeException exc = new IllegalArgumentException(listener.getCanonicalName()); final String msg = "MBean " + listener.getCanonicalName() + " does not " + "implement " + NotificationListener.class.getName(); throw new RuntimeOperationsException(exc, msg); } return (NotificationListener) resource; }
Example #4
Source File: DefaultMBeanServerInterceptor.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
public Object invoke(ObjectName name, String operationName, Object params[], String signature[]) throws InstanceNotFoundException, MBeanException, ReflectionException { name = nonDefaultDomain(name); DynamicMBean instance = getMBean(name); checkMBeanPermission(instance, operationName, name, "invoke"); try { return instance.invoke(operationName, params, signature); } catch (Throwable t) { rethrowMaybeMBeanException(t); throw new AssertionError(); } }
Example #5
Source File: RMIConnector.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
protected void removeListenerForMBeanRemovedNotif(Integer id) throws IOException, InstanceNotFoundException, ListenerNotFoundException { try { connection.removeNotificationListeners( MBeanServerDelegate.DELEGATE_NAME, new Integer[] {id}, null); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); connection.removeNotificationListeners( MBeanServerDelegate.DELEGATE_NAME, new Integer[] {id}, null); } }
Example #6
Source File: ConnectorServerFactoryBeanTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void noRegisterWithMBeanServer() throws Exception { ConnectorServerFactoryBean bean = new ConnectorServerFactoryBean(); bean.afterPropertiesSet(); try { // Try to get the connector bean. getServer().getObjectInstance(ObjectName.getInstance(OBJECT_NAME)); fail("Instance should not be found"); } catch (InstanceNotFoundException ex) { // expected } finally { bean.destroy(); } }
Example #7
Source File: RMIConnector.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, IOException { final boolean debug = logger.debugOn(); if (debug) logger.debug("addNotificationListener" + "(ObjectName,NotificationListener,"+ "NotificationFilter,Object)", "name=" + name + ", listener=" + listener + ", filter=" + filter + ", handback=" + handback); final Integer listenerID = addListenerWithSubject(name, new MarshalledObject<NotificationFilter>(filter), delegationSubject,true); rmiNotifClient.addNotificationListener(listenerID, name, listener, filter, handback, delegationSubject); }
Example #8
Source File: DefaultMBeanServerInterceptor.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
public ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { try { return createMBean(className, name, null, true, params, signature); } catch (InstanceNotFoundException e) { /* Can only happen if loaderName doesn't exist, but we just passed null, so we shouldn't get this exception. */ throw EnvHelp.initCause( new IllegalArgumentException("Unexpected exception: " + e), e); } }
Example #9
Source File: RMIConnectorLogAttributesTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private void doTest(JMXConnector connector) throws IOException, MalformedObjectNameException, ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException { MBeanServerConnection mbsc = connector.getMBeanServerConnection(); ObjectName objName = new ObjectName("com.redhat.test.jmx:type=NameMBean"); System.out.println("DEBUG: Calling createMBean"); mbsc.createMBean(Name.class.getName(), objName); System.out.println("DEBUG: Calling setAttributes"); AttributeList attList = new AttributeList(); attList.add(new Attribute("FirstName", ANY_NAME)); attList.add(new Attribute("LastName", ANY_NAME)); mbsc.setAttributes(objName, attList); }
Example #10
Source File: RMIConnector.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException, IOException { if (logger.debugOn()) logger.debug("getObjectInstance", "name=" + name); final ClassLoader old = pushDefaultClassLoader(); try { return connection.getObjectInstance(name, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.getObjectInstance(name, delegationSubject); } finally { popDefaultClassLoader(old); } }
Example #11
Source File: RMIConnector.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
protected Integer addListenerForMBeanRemovedNotif() throws IOException, InstanceNotFoundException { NotificationFilterSupport clientFilter = new NotificationFilterSupport(); clientFilter.enableType( MBeanServerNotification.UNREGISTRATION_NOTIFICATION); MarshalledObject<NotificationFilter> sFilter = new MarshalledObject<NotificationFilter>(clientFilter); Integer[] listenerIDs; final ObjectName[] names = new ObjectName[] {MBeanServerDelegate.DELEGATE_NAME}; final MarshalledObject<NotificationFilter>[] filters = Util.cast(new MarshalledObject<?>[] {sFilter}); final Subject[] subjects = new Subject[] {null}; try { listenerIDs = connection.addNotificationListeners(names, filters, subjects); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); listenerIDs = connection.addNotificationListeners(names, filters, subjects); } return listenerIDs[0]; }
Example #12
Source File: SnmpGenericObjectServer.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Set the value of an SNMP variable. * * <p><b><i> * You should never need to use this method directly. * </i></b></p> * * @param meta The impacted metadata object * @param name The ObjectName of the impacted MBean * @param x The new requested SnmpValue * @param id The OID arc identifying the variable we're trying to set. * @param data User contextual data allocated through the * {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory} * * @return The new value of the variable after the operation. * * @exception SnmpStatusException whenever an SNMP exception must be * raised. Raising an exception will abort the request. <br> * Exceptions should never be raised directly, but only by means of * <code> * req.registerSetException(<i>VariableId</i>,<i>SnmpStatusException</i>) * </code> **/ public SnmpValue set(SnmpGenericMetaServer meta, ObjectName name, SnmpValue x, long id, Object data) throws SnmpStatusException { final String attname = meta.getAttributeName(id); final Object attvalue= meta.buildAttributeValue(id,x); final Attribute att = new Attribute(attname,attvalue); Object result = null; try { server.setAttribute(name,att); result = server.getAttribute(name,attname); } catch(InvalidAttributeValueException iv) { throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue); } catch (InstanceNotFoundException f) { throw new SnmpStatusException(SnmpStatusException.snmpRspInconsistentName); } catch (ReflectionException r) { throw new SnmpStatusException(SnmpStatusException.snmpRspInconsistentName); } catch (MBeanException m) { Exception t = m.getTargetException(); if (t instanceof SnmpStatusException) throw (SnmpStatusException) t; throw new SnmpStatusException(SnmpStatusException.noAccess); } catch (Exception e) { throw new SnmpStatusException(SnmpStatusException.noAccess); } return meta.buildSnmpValue(id,result); }
Example #13
Source File: Timer.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Removes all the timer notifications corresponding to the specified type from the list of notifications. * * @param type The timer notification type. * * @exception InstanceNotFoundException The specified type does not correspond to any timer notification * in the list of notifications of this timer MBean. */ public synchronized void removeNotifications(String type) throws InstanceNotFoundException { Vector<Integer> v = getNotificationIDs(type); if (v.isEmpty()) throw new InstanceNotFoundException("Timer notifications to remove not in the list of notifications"); for (Integer i : v) removeNotification(i); }
Example #14
Source File: RMIConnector.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
public Object invoke(ObjectName name, String operationName, Object params[], String signature[]) throws InstanceNotFoundException, MBeanException, ReflectionException, IOException { if (logger.debugOn()) logger.debug("invoke", "name=" + name + ", operationName=" + operationName + ", signature=" + strings(signature)); final MarshalledObject<Object[]> sParams = new MarshalledObject<Object[]>(params); final ClassLoader old = pushDefaultClassLoader(); try { return connection.invoke(name, operationName, sParams, signature, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.invoke(name, operationName, sParams, signature, delegationSubject); } finally { popDefaultClassLoader(old); } }
Example #15
Source File: MBeanServerAccessController.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Call <code>checkRead()</code>, then forward this method to the * wrapped object. */ @Deprecated public ObjectInputStream deserialize(ObjectName name, byte[] data) throws InstanceNotFoundException, OperationsException { checkRead(); return getMBeanServer().deserialize(name, data); }
Example #16
Source File: DefaultMBeanServerInterceptor.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException { return createMBean(className, name, loaderName, (Object[]) null, (String[]) null); }
Example #17
Source File: OldMBeanServerTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public boolean isInstanceOf(ObjectName name, String className) throws InstanceNotFoundException { DynamicMBean mbean = getMBean(name); String mbeanClassName = mbean.getMBeanInfo().getClassName(); if (className.equals(mbeanClassName)) return true; ClassLoader loader = getUserMBean(mbean).getClass().getClassLoader(); try { Class<?> mbeanClass = Class.forName(mbeanClassName, false, loader); Class<?> isInstClass = Class.forName(className, false, loader); return isInstClass.isAssignableFrom(mbeanClass); } catch (ClassNotFoundException e) { return false; } }
Example #18
Source File: OldMBeanServerTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public Object instantiate( String className, Object[] params, String[] signature) throws ReflectionException, MBeanException { try { return instantiate(className, clrName, params, signature); } catch (InstanceNotFoundException e) { throw new RuntimeException(e); // can't happen } }
Example #19
Source File: JmxReporter.java From metrics with Apache License 2.0 | 5 votes |
private void unregisterMBean(ObjectName originalObjectName) throws InstanceNotFoundException, MBeanRegistrationException { ObjectName storedObjectName = registered.remove(originalObjectName); if (storedObjectName != null) { mBeanServer.unregisterMBean(storedObjectName); } else { mBeanServer.unregisterMBean(originalObjectName); } }
Example #20
Source File: MBeanServerAccessController.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Call <code>checkRead()</code>, then forward this method to the * wrapped object. */ public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException { checkRead(); getMBeanServer().addNotificationListener(name, listener, filter, handback); }
Example #21
Source File: OldMBeanServerTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public ObjectInstance createMBean( String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException { Object mbean = instantiate(className, loaderName, params, signature); return registerMBean(mbean, name); }
Example #22
Source File: DefaultMBeanServerInterceptor.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
public void removeNotificationListener(ObjectName name, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException { NotificationListener instance = getListener(listener); if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { MBEANSERVER_LOGGER.logp(Level.FINER, DefaultMBeanServerInterceptor.class.getName(), "removeNotificationListener", "ObjectName = " + name + ", Listener = " + listener); } server.removeNotificationListener(name, instance); }
Example #23
Source File: MBeanServerAccessController.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Call <code>checkWrite()</code>, then forward this method to the * wrapped object. */ public Object invoke(ObjectName name, String operationName, Object params[], String signature[]) throws InstanceNotFoundException, MBeanException, ReflectionException { checkWrite(); checkMLetMethods(name, operationName); return getMBeanServer().invoke(name, operationName, params, signature); }
Example #24
Source File: DefaultMBeanServerInterceptor.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException { // ------------------------------ // ------------------------------ // ---------------- // Get listener object // ---------------- DynamicMBean instance = getMBean(listener); Object resource = getResource(instance); if (!(resource instanceof NotificationListener)) { throw new RuntimeOperationsException(new IllegalArgumentException(listener.getCanonicalName()), "The MBean " + listener.getCanonicalName() + "does not implement the NotificationListener interface") ; } // ---------------- // Add a listener on an MBean // ---------------- if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { MBEANSERVER_LOGGER.logp(Level.FINER, DefaultMBeanServerInterceptor.class.getName(), "addNotificationListener", "ObjectName = " + name + ", Listener = " + listener); } server.addNotificationListener(name,(NotificationListener) resource, filter, handback) ; }
Example #25
Source File: DefaultMBeanServerInterceptor.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException { // ------------------------------ // ------------------------------ if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { MBEANSERVER_LOGGER.logp(Level.FINER, DefaultMBeanServerInterceptor.class.getName(), "addNotificationListener", "ObjectName = " + name); } DynamicMBean instance = getMBean(name); checkMBeanPermission(instance, null, name, "addNotificationListener"); NotificationBroadcaster broadcaster = getNotificationBroadcaster(name, instance, NotificationBroadcaster.class); // ------------------ // Check listener // ------------------ if (listener == null) { throw new RuntimeOperationsException(new IllegalArgumentException("Null listener"),"Null listener"); } NotificationListener listenerWrapper = getListenerWrapper(listener, name, instance, true); broadcaster.addNotificationListener(listenerWrapper, filter, handback); }
Example #26
Source File: ServerNotifForwarder.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
static void checkMBeanPermission( final MBeanServer mbs, final ObjectName name, final String actions) throws InstanceNotFoundException, SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { AccessControlContext acc = AccessController.getContext(); ObjectInstance oi; try { oi = AccessController.doPrivileged( new PrivilegedExceptionAction<ObjectInstance>() { public ObjectInstance run() throws InstanceNotFoundException { return mbs.getObjectInstance(name); } }); } catch (PrivilegedActionException e) { throw (InstanceNotFoundException) extractException(e); } String classname = oi.getClassName(); MBeanPermission perm = new MBeanPermission( classname, null, name, actions); sm.checkPermission(perm, acc); } }
Example #27
Source File: JmxMBeanServer.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException { mbsInterceptor.removeNotificationListener(cloneObjectName(name), listener, filter, handback); }
Example #28
Source File: DefaultMBeanServerInterceptor.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
private void exclusiveUnregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException { DynamicMBean instance = getMBean(name); // may throw InstanceNotFoundException checkMBeanPermission(instance, null, name, "unregisterMBean"); if (instance instanceof MBeanRegistration) preDeregisterInvoke((MBeanRegistration) instance); final Object resource = getResource(instance); // Unregisters the MBean from the repository. // Returns the resource context that was used. // The returned context does nothing for regular MBeans. // For ClassLoader MBeans and JMXNamespace (and JMXDomain) // MBeans - the context makes it possible to unregister these // objects from the appropriate framework artifacts, such as // the CLR or the dispatcher, from within the repository lock. // In case of success, we also need to call context.done() at the // end of this method. // final ResourceContext context = unregisterFromRepository(resource, instance, name); try { if (instance instanceof MBeanRegistration) postDeregisterInvoke(name,(MBeanRegistration) instance); } finally { context.done(); } }
Example #29
Source File: JmxReporterTest.java From metrics with Apache License 2.0 | 5 votes |
@Test public void cleansUpAfterItselfWhenStopped() throws Exception { reporter.stop(); try { getAttributes("gauge", "Value"); Assertions.failBecauseExceptionWasNotThrown(InstanceNotFoundException.class); } catch (InstanceNotFoundException e) { } }
Example #30
Source File: SnmpGenericObjectServer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Set the value of an SNMP variable. * * <p><b><i> * You should never need to use this method directly. * </i></b></p> * * @param meta The impacted metadata object * @param name The ObjectName of the impacted MBean * @param x The new requested SnmpValue * @param id The OID arc identifying the variable we're trying to set. * @param data User contextual data allocated through the * {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory} * * @return The new value of the variable after the operation. * * @exception SnmpStatusException whenever an SNMP exception must be * raised. Raising an exception will abort the request. <br> * Exceptions should never be raised directly, but only by means of * <code> * req.registerSetException(<i>VariableId</i>,<i>SnmpStatusException</i>) * </code> **/ public SnmpValue set(SnmpGenericMetaServer meta, ObjectName name, SnmpValue x, long id, Object data) throws SnmpStatusException { final String attname = meta.getAttributeName(id); final Object attvalue= meta.buildAttributeValue(id,x); final Attribute att = new Attribute(attname,attvalue); Object result = null; try { server.setAttribute(name,att); result = server.getAttribute(name,attname); } catch(InvalidAttributeValueException iv) { throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue); } catch (InstanceNotFoundException f) { throw new SnmpStatusException(SnmpStatusException.snmpRspInconsistentName); } catch (ReflectionException r) { throw new SnmpStatusException(SnmpStatusException.snmpRspInconsistentName); } catch (MBeanException m) { Exception t = m.getTargetException(); if (t instanceof SnmpStatusException) throw (SnmpStatusException) t; throw new SnmpStatusException(SnmpStatusException.noAccess); } catch (Exception e) { throw new SnmpStatusException(SnmpStatusException.noAccess); } return meta.buildSnmpValue(id,result); }