javax.management.ObjectInstance Java Examples
The following examples show how to use
javax.management.ObjectInstance.
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: OldMBeanServerTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) { Set<ObjectInstance> instances = newSet(); if (name == null) name = ObjectName.WILDCARD; if (query == null) query = trueQuery; MBeanServer oldMBS = QueryEval.getMBeanServer(); try { query.setMBeanServer(this); for (ObjectName n : mbeans.keySet()) { if (name.apply(n)) { try { if (query.apply(n)) instances.add(getObjectInstance(n)); } catch (Exception e) { // OK: Ignore this MBean in the result } } } } finally { query.setMBeanServer(oldMBS); } return instances; }
Example #2
Source File: DefaultMBeanServerInterceptor.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { // ------------------------------ // ------------------------------ Class<?> theClass = object.getClass(); Introspector.checkCompliance(theClass); final String infoClassName = getNewMBeanClassName(object); checkMBeanPermission(infoClassName, null, name, "registerMBean"); checkMBeanTrustPermission(theClass); return registerObject(infoClassName, object, name); }
Example #3
Source File: PluggableMBeanServerImpl.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException { Throwable error = null; MBeanServerPlugin delegate = null; final boolean readOnly = false; try { delegate = findDelegateForNewObject(name); authorizeMBeanOperation(delegate, name, CREATE_MBEAN, null, JmxAction.Impact.WRITE); return checkNotAReservedDomainRegistrationIfObjectNameWasChanged(name, delegate.createMBean(className, name, loaderName), delegate); } catch (Exception e) { error = e; if (e instanceof ReflectionException) throw (ReflectionException)e; if (e instanceof InstanceAlreadyExistsException) throw (InstanceAlreadyExistsException)e; if (e instanceof MBeanException) throw (MBeanException)e; if (e instanceof NotCompliantMBeanException) throw (NotCompliantMBeanException)e; if (e instanceof InstanceNotFoundException) throw (InstanceNotFoundException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).createMBean(className, name, loaderName); } } }
Example #4
Source File: OldMBeanServerTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) { Set<ObjectInstance> instances = newSet(); if (name == null) name = ObjectName.WILDCARD; if (query == null) query = trueQuery; MBeanServer oldMBS = QueryEval.getMBeanServer(); try { query.setMBeanServer(this); for (ObjectName n : mbeans.keySet()) { if (name.apply(n)) { try { if (query.apply(n)) instances.add(getObjectInstance(n)); } catch (Exception e) { // OK: Ignore this MBean in the result } } } } finally { query.setMBeanServer(oldMBS); } return instances; }
Example #5
Source File: TestMBeans.java From javamelody with Apache License 2.0 | 6 votes |
/** Before. * @throws JMException e */ @Before public void setUp() throws JMException { Utils.initialize(); mbeans = new MBeans(); mBeanServer = MBeans.getPlatformMBeanServer(); final ObjectInstance mBean1 = mBeanServer.registerMBean(new ThreadPool(), new ObjectName("Catalina:type=ThreadPool")); mbeansList.add(mBean1.getObjectName()); final ObjectInstance mBean2 = mBeanServer.registerMBean(new GlobalRequestProcessor(), new ObjectName("Catalina:type=GlobalRequestProcessor,name=http-8080")); mbeansList.add(mBean2.getObjectName()); final ObjectInstance mBean3 = mBeanServer.registerMBean(new GlobalRequestProcessor(), new ObjectName("jboss.deployment:type=Servlet")); mbeansList.add(mBean3.getObjectName()); }
Example #6
Source File: OldMBeanServerTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) { Set<ObjectInstance> instances = newSet(); if (name == null) name = ObjectName.WILDCARD; if (query == null) query = trueQuery; MBeanServer oldMBS = QueryEval.getMBeanServer(); try { query.setMBeanServer(this); for (ObjectName n : mbeans.keySet()) { if (name.apply(n)) { try { if (query.apply(n)) instances.add(getObjectInstance(n)); } catch (Exception e) { // OK: Ignore this MBean in the result } } } } finally { query.setMBeanServer(oldMBS); } return instances; }
Example #7
Source File: DefaultMBeanServerInterceptor.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { // ------------------------------ // ------------------------------ Class<?> theClass = object.getClass(); Introspector.checkCompliance(theClass); final String infoClassName = getNewMBeanClassName(object); checkMBeanPermission(infoClassName, null, name, "registerMBean"); checkMBeanTrustPermission(theClass); return registerObject(infoClassName, object, name); }
Example #8
Source File: DefaultMBeanServerInterceptor.java From openjdk-8 with GNU General Public License v2.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: MBeanServerAccessController.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Call <code>checkCreate(className)</code>, then forward this method to the * wrapped object. */ public ObjectInstance createMBean(String className, ObjectName name, Object params[], String signature[]) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { checkCreate(className); SecurityManager sm = System.getSecurityManager(); if (sm == null) { Object object = getMBeanServer().instantiate(className, params, signature); checkClassLoader(object); return getMBeanServer().registerMBean(object, name); } else { return getMBeanServer().createMBean(className, name, params, signature); } }
Example #10
Source File: MBeanServerAccessController.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Call <code>checkCreate(className)</code>, then forward this method to the * wrapped object. */ public ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { checkCreate(className); SecurityManager sm = System.getSecurityManager(); if (sm == null) { Object object = getMBeanServer().instantiate(className); checkClassLoader(object); return getMBeanServer().registerMBean(object, name); } else { return getMBeanServer().createMBean(className, name); } }
Example #11
Source File: PurgeCommandTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
/** * This test ensures that the queueViewMbean will work. * * @throws Exception */ public void testQueueViewMbean() throws Exception { try { addMessages(); validateCounts(MESSAGE_COUNT, MESSAGE_COUNT, MESSAGE_COUNT * 2); List<String> tokens = Arrays.asList(new String[]{"*"}); for (String token : tokens) { List<ObjectInstance> queueList = JmxMBeansUtil.queryMBeans(createJmxConnection(), "type=Broker,brokerName=localbroker,destinationType=Queue,destinationName=" + token); for (ObjectInstance queue : queueList) { ObjectName queueName = queue.getObjectName(); QueueViewMBean proxy = MBeanServerInvocationHandler.newProxyInstance(createJmxConnection(), queueName, QueueViewMBean.class, true); int removed = proxy.removeMatchingMessages(MSG_SEL_WITH_PROPERTY); LOG.info("Removed: " + removed); } } validateCounts(0, MESSAGE_COUNT, MESSAGE_COUNT); } finally { purgeAllMessages(); } }
Example #12
Source File: DefaultMBeanServerInterceptor.java From JDKSourceCode1.8 with MIT License | 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 #13
Source File: MBeanServerAccessController.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Call <code>checkCreate(className)</code>, then forward this method to the * wrapped object. */ public ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { checkCreate(className); SecurityManager sm = System.getSecurityManager(); if (sm == null) { Object object = getMBeanServer().instantiate(className); checkClassLoader(object); return getMBeanServer().registerMBean(object, name); } else { return getMBeanServer().createMBean(className, name); } }
Example #14
Source File: ROConnection.java From scheduling with GNU Affero General Public License v3.0 | 6 votes |
/** * @see javax.management.MBeanServerConnection#getObjectInstance(javax.management.ObjectName) */ public ObjectInstance getObjectInstance(final ObjectName name) throws InstanceNotFoundException, IOException { if (this.subject == null) { return this.mbs.getObjectInstance(name); } try { return (ObjectInstance) Subject.doAsPrivileged(this.subject, new PrivilegedExceptionAction<ObjectInstance>() { public final ObjectInstance run() throws Exception { return mbs.getObjectInstance(name); } }, this.context); } catch (final PrivilegedActionException pe) { final Exception e = JMXProviderUtils.extractException(pe); if (e instanceof InstanceNotFoundException) throw (InstanceNotFoundException) e; if (e instanceof IOException) throw (IOException) e; throw JMXProviderUtils.newIOException("Got unexpected server exception: " + e, e); } }
Example #15
Source File: MBeanTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
private void checkMemberView(boolean expectedBeans, MBeanServerConnection mbeanServer, String memberId, String serverGroup) throws MalformedObjectNameException, IOException, TestException { Log.getLogWriter().info("Checking GFXDMemberMBean for server group " + serverGroup + " and memberId : " + memberId); String memberONstr = memberONTemplate.replace("{0}", serverGroup); memberONstr = memberONstr.replace("{1}", memberId); ObjectName memberON = new ObjectName(memberONstr); // check memberMBean Log.getLogWriter().info("Querying for member instance " + memberON); try { ObjectInstance instance = mbeanServer.getObjectInstance(memberON); Log.getLogWriter().info("Found instance " + memberON + " Expected " + expectedBeans); if (!expectedBeans && instance != null) throw new TestException("Found member instance " + memberON + " when not expected "); } catch (InstanceNotFoundException e) { if (expectedBeans) { logMBeans(MessageFormat.format(ManagementConstants.OBJECTNAME__GFXDMEMBER_MXBEAN, new Object[] {"*", "*"}), mbeanServer); throw new TestException("checkMemberViewFromManager\n" + TestHelper.getStackTrace(e)); } } }
Example #16
Source File: DefaultMBeanServerInterceptor.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { // ------------------------------ // ------------------------------ Class<?> theClass = object.getClass(); Introspector.checkCompliance(theClass); final String infoClassName = getNewMBeanClassName(object); checkMBeanPermission(infoClassName, null, name, "registerMBean"); checkMBeanTrustPermission(theClass); return registerObject(infoClassName, object, name); }
Example #17
Source File: RMIConnector.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) throws IOException { if (logger.debugOn()) logger.debug("queryMBeans", "name=" + name + ", query=" + query); final MarshalledObject<QueryExp> sQuery = new MarshalledObject<QueryExp>(query); final ClassLoader old = pushDefaultClassLoader(); try { return connection.queryMBeans(name, sQuery, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.queryMBeans(name, sQuery, delegationSubject); } finally { popDefaultClassLoader(old); } }
Example #18
Source File: MBeanServerAccessController.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Call <code>checkCreate(className)</code>, then forward this method to the * wrapped object. */ public ObjectInstance createMBean(String className, ObjectName name, Object params[], String signature[]) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { checkCreate(className); SecurityManager sm = System.getSecurityManager(); if (sm == null) { Object object = getMBeanServer().instantiate(className, params, signature); checkClassLoader(object); return getMBeanServer().registerMBean(object, name); } else { return getMBeanServer().createMBean(className, name, params, signature); } }
Example #19
Source File: MBeanServerAccessController.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Call <code>checkWrite()</code>, then forward this method to the * wrapped object. */ public ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { checkWrite(); return getMBeanServer().registerMBean(object, name); }
Example #20
Source File: RMIConnector.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, IOException { if (logger.debugOn()) logger.debug("createMBean(String,ObjectName)", "className=" + className + ", name=" + name); final ClassLoader old = pushDefaultClassLoader(); try { return connection.createMBean(className, name, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.createMBean(className, name, delegationSubject); } finally { popDefaultClassLoader(old); } }
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) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException { return createMBean(className, name, loaderName, null, null); }
Example #22
Source File: RMIConnector.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, IOException { if (logger.debugOn()) logger.debug("createMBean(String,ObjectName)", "className=" + className + ", name=" + name); final ClassLoader old = pushDefaultClassLoader(); try { return connection.createMBean(className, name, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.createMBean(className, name, delegationSubject); } finally { popDefaultClassLoader(old); } }
Example #23
Source File: DefaultMBeanServerInterceptor.java From TencentKona-8 with GNU General Public License v2.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 #24
Source File: RMIConnector.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public ObjectInstance createMBean(String className, ObjectName name, Object params[], String signature[]) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, IOException { if (logger.debugOn()) logger.debug("createMBean(String,ObjectName,Object[],String[])", "className=" + className + ", name=" + name + ", params=" + objects(params) + ", signature=" + strings(signature)); final MarshalledObject<Object[]> sParams = new MarshalledObject<Object[]>(params); final ClassLoader old = pushDefaultClassLoader(); try { return connection.createMBean(className, name, sParams, signature, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.createMBean(className, name, sParams, signature, delegationSubject); } finally { popDefaultClassLoader(old); } }
Example #25
Source File: MBeanServerAccessController.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Call <code>checkCreate(className)</code>, then forward this method to the * wrapped object. */ public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object params[], String signature[]) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException { checkCreate(className); SecurityManager sm = System.getSecurityManager(); if (sm == null) { Object object = getMBeanServer().instantiate(className, loaderName, params, signature); checkClassLoader(object); return getMBeanServer().registerMBean(object, name); } else { return getMBeanServer().createMBean(className, name, loaderName, params, signature); } }
Example #26
Source File: DefaultMBeanServerInterceptor.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { return createMBean(className, name, (Object[]) null, (String[]) null); }
Example #27
Source File: MBeanServerAccessController.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Call <code>checkWrite()</code>, then forward this method to the * wrapped object. */ public ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { checkWrite(); return getMBeanServer().registerMBean(object, name); }
Example #28
Source File: MBeanServerAccessController.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Call <code>checkWrite()</code>, then forward this method to the * wrapped object. */ public ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { checkWrite(); return getMBeanServer().registerMBean(object, name); }
Example #29
Source File: RMIConnector.java From JDKSourceCode1.8 with MIT License | 5 votes |
public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException { if (logger.debugOn()) logger.debug("createMBean(String,ObjectName,ObjectName)", "className=" + className + ", name=" + name + ", loaderName=" + loaderName + ")"); final ClassLoader old = pushDefaultClassLoader(); try { return connection.createMBean(className, name, loaderName, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.createMBean(className, name, loaderName, delegationSubject); } finally { popDefaultClassLoader(old); } }
Example #30
Source File: DefaultMBeanServerInterceptor.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Applies the specified queries to the set of ObjectInstances. */ private Set<ObjectInstance> filterListOfObjectInstances(Set<ObjectInstance> list, QueryExp query) { // Null query. // if (query == null) { return list; } else { Set<ObjectInstance> result = new HashSet<ObjectInstance>(); // Access the filter. // for (ObjectInstance oi : list) { boolean res = false; MBeanServer oldServer = QueryEval.getMBeanServer(); query.setMBeanServer(server); try { res = query.apply(oi.getObjectName()); } catch (Exception e) { res = false; } finally { /* * query.setMBeanServer is probably * QueryEval.setMBeanServer so put back the old * value. Since that method uses a ThreadLocal * variable, this code is only needed for the * unusual case where the user creates a custom * QueryExp that calls a nested query on another * MBeanServer. */ query.setMBeanServer(oldServer); } if (res) { result.add(oi); } } return result; } }