javax.management.ReflectionException Java Examples
The following examples show how to use
javax.management.ReflectionException.
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: ProxyClient.java From jvmtop with GNU General Public License v2.0 | 6 votes |
private synchronized NameValueMap getCachedAttributes( ObjectName objName, Set<String> attrNames) throws InstanceNotFoundException, ReflectionException, IOException { NameValueMap values = cachedValues.get(objName); if (values != null && values.keySet().containsAll(attrNames)) { return values; } attrNames = new TreeSet<String>(attrNames); Set<String> oldNames = cachedNames.get(objName); if (oldNames != null) { attrNames.addAll(oldNames); } values = new NameValueMap(); final AttributeList attrs = conn.getAttributes( objName, attrNames.toArray(new String[attrNames.size()])); for (Attribute attr : attrs.asList()) { values.put(attr.getName(), attr.getValue()); } cachedValues.put(objName, values); cachedNames.put(objName, attrNames); return values; }
Example #2
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, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException { params = nullAsEmpty(params); signature = nullAsEmpty(signature); 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, params, signature), 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; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).createMBean(className, name, params, signature); } } }
Example #3
Source File: MdbContainer.java From tomee with Apache License 2.0 | 6 votes |
@Override public Object invoke(final String actionName, final Object[] params, final String[] signature) throws MBeanException, ReflectionException { if (actionName.equals("stop")) { activationContext.stop(); } else if (actionName.equals("start")) { try { activationContext.start(); } catch (ResourceException e) { logger.error("Error invoking " + actionName + ": " + e.getMessage()); throw new MBeanException(new IllegalStateException(e.getMessage(), e)); } } else { throw new MBeanException(new IllegalStateException("unsupported operation: " + actionName)); } return null; }
Example #4
Source File: PerInterface.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
Object getAttribute(Object resource, String attribute, Object cookie) throws AttributeNotFoundException, MBeanException, ReflectionException { final M cm = getters.get(attribute); if (cm == null) { final String msg; if (setters.containsKey(attribute)) msg = "Write-only attribute: " + attribute; else msg = "No such attribute: " + attribute; throw new AttributeNotFoundException(msg); } return introspector.invokeM(cm, resource, (Object[]) null, cookie); }
Example #5
Source File: MetricsDynamicMBeanBase.java From big-c with Apache License 2.0 | 6 votes |
@Override public Object invoke(String actionName, Object[] parms, String[] signature) throws MBeanException, ReflectionException { if (actionName == null || actionName.isEmpty()) throw new IllegalArgumentException(); // Right now we support only one fixed operation (if it applies) if (!(actionName.equals(RESET_ALL_MIN_MAX_OP)) || mbeanInfo.getOperations().length != 1) { throw new ReflectionException(new NoSuchMethodException(actionName)); } for (MetricsBase m : metricsRegistry.getMetricsList()) { if ( MetricsTimeVaryingRate.class.isInstance(m) ) { MetricsTimeVaryingRate.class.cast(m).resetMinMax(); } } return null; }
Example #6
Source File: JvmOptions.java From netbeans with Apache License 2.0 | 6 votes |
public void setAttribute(Attribute attribute) throws RemoteException, InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException, java.io.IOException{ if(attribute.getName().equals(this.JPDA_PORT)){ if(attribute.getValue() != null){ setAddressValue(attribute.getValue().toString()); } }else if(attribute.getName().equals(this.SHARED_MEM)){ if(attribute.getValue() != null){ setAddressValue(attribute.getValue().toString()); } }else if(attribute.getName().equals(this.DEBUG_OPTIONS)){ //Fix for bug# 4989322 - solaris does not support shmem if((attribute.getValue() != null) && (attribute.getValue().toString().indexOf(ISMEM) == -1)){ this.conn.setAttribute(this.configObjName, attribute); }else{ if(isWindows()){ this.conn.setAttribute(this.configObjName, attribute); } //ludo else //ludo Util.setStatusBar(bundle.getString("Msg_SolarisShmem")); } }else{ this.conn.setAttribute(this.configObjName, attribute); } }
Example #7
Source File: DefaultMBeanServerInterceptor.java From openjdk-jdk9 with GNU General Public License v2.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 #8
Source File: MBeanInstantiator.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Gets the class for the specified class name using the specified * class loader */ public Class<?> findClass(String className, ObjectName aLoader) throws ReflectionException, InstanceNotFoundException { if (aLoader == null) throw new RuntimeOperationsException(new IllegalArgumentException(), "Null loader passed in parameter"); // Retrieve the class loader from the repository ClassLoader loader = null; synchronized (this) { loader = getClassLoader(aLoader); } if (loader == null) { throw new InstanceNotFoundException("The loader named " + aLoader + " is not registered in the MBeanServer"); } return findClass(className,loader); }
Example #9
Source File: ROConnection.java From scheduling with GNU Affero General Public License v3.0 | 6 votes |
/** * @see javax.management.MBeanServerConnection#invoke(javax.management.ObjectName, java.lang.String, java.lang.Object[], java.lang.String[]) */ public Object invoke(final ObjectName name, final String operationName, final Object[] params, final String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException, IOException { if (this.subject == null) { return this.mbs.invoke(name, operationName, params, signature); } try { return Subject.doAsPrivileged(this.subject, new PrivilegedExceptionAction<Object>() { public final Object run() throws Exception { return mbs.invoke(name, operationName, params, signature); } }, this.context); } catch (final PrivilegedActionException pe) { final Exception e = JMXProviderUtils.extractException(pe); if (e instanceof InstanceNotFoundException) throw (InstanceNotFoundException) e; if (e instanceof MBeanException) throw (MBeanException) e; if (e instanceof ReflectionException) throw (ReflectionException) e; if (e instanceof IOException) throw (IOException) e; throw JMXProviderUtils.newIOException("Got unexpected server exception: " + e, e); } }
Example #10
Source File: PerInterface.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
void setAttribute(Object resource, String attribute, Object value, Object cookie) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { final M cm = setters.get(attribute); if (cm == null) { final String msg; if (getters.containsKey(attribute)) msg = "Read-only attribute: " + attribute; else msg = "No such attribute: " + attribute; throw new AttributeNotFoundException(msg); } introspector.invokeSetter(attribute, cm, resource, value, cookie); }
Example #11
Source File: MBeanInstantiator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Load a class with the specified loader, or with this object * class loader if the specified loader is null. **/ static Class<?> loadClass(String className, ClassLoader loader) throws ReflectionException { Class<?> theClass; if (className == null) { throw new RuntimeOperationsException(new IllegalArgumentException("The class name cannot be null"), "Exception occurred during object instantiation"); } ReflectUtil.checkPackageAccess(className); try { if (loader == null) loader = MBeanInstantiator.class.getClassLoader(); if (loader != null) { theClass = Class.forName(className, false, loader); } else { theClass = Class.forName(className); } } catch (ClassNotFoundException e) { throw new ReflectionException(e, "The MBean class could not be loaded"); } return theClass; }
Example #12
Source File: RMIConnector.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException, IOException { if (logger.debugOn()) logger.debug("getAttributes", "name=" + name + ", attributes=" + strings(attributes)); final ClassLoader old = pushDefaultClassLoader(); try { return connection.getAttributes(name, attributes, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.getAttributes(name, attributes, delegationSubject); } finally { popDefaultClassLoader(old); } }
Example #13
Source File: MBeanServerAccessController.java From jdk8u60 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, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException { checkCreate(className); SecurityManager sm = System.getSecurityManager(); if (sm == null) { Object object = getMBeanServer().instantiate(className, loaderName); checkClassLoader(object); return getMBeanServer().registerMBean(object, name); } else { return getMBeanServer().createMBean(className, name, loaderName); } }
Example #14
Source File: MBeanInstantiator.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Gets the class for the specified class name using the specified * class loader */ public Class<?> findClass(String className, ObjectName aLoader) throws ReflectionException, InstanceNotFoundException { if (aLoader == null) throw new RuntimeOperationsException(new IllegalArgumentException(), "Null loader passed in parameter"); // Retrieve the class loader from the repository ClassLoader loader = null; synchronized (this) { loader = getClassLoader(aLoader); } if (loader == null) { throw new InstanceNotFoundException("The loader named " + aLoader + " is not registered in the MBeanServer"); } return findClass(className,loader); }
Example #15
Source File: MBeanServerDelegateImpl.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * Always fails since the MBeanServerDelegate MBean has no operation. * * @param actionName The name of the action to be invoked. * @param params An array containing the parameters to be set when the * action is invoked. * @param signature An array containing the signature of the action. * * @return The object returned by the action, which represents * the result of invoking the action on the MBean specified. * * @exception MBeanException Wraps a <CODE>java.lang.Exception</CODE> * thrown by the MBean's invoked method. * @exception ReflectionException Wraps a * <CODE>java.lang.Exception</CODE> thrown while trying to invoke * the method. */ public Object invoke(String actionName, Object params[], String signature[]) throws MBeanException, ReflectionException { // Check that operation name is not null. // if (actionName == null) { final RuntimeException r = new IllegalArgumentException("Operation name cannot be null"); throw new RuntimeOperationsException(r, "Exception occurred trying to invoke the operation on the MBean"); } throw new ReflectionException( new NoSuchMethodException(actionName), "The operation with name " + actionName + " could not be found"); }
Example #16
Source File: SpringModelMBean.java From java-technology-stack with MIT License | 5 votes |
/** * Switches the {@link Thread#getContextClassLoader() context ClassLoader} for the * managed resources {@link ClassLoader} before allowing the invocation to occur. * @see javax.management.modelmbean.ModelMBean#getAttribute */ @Override public Object getAttribute(String attrName) throws AttributeNotFoundException, MBeanException, ReflectionException { ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(this.managedResourceClassLoader); return super.getAttribute(attrName); } finally { Thread.currentThread().setContextClassLoader(currentClassLoader); } }
Example #17
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 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 #18
Source File: MBeanServerDelegateImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * This method always fail since all MBeanServerDelegateMBean attributes * are read-only. * * @param attribute The identification of the attribute to * be set and the value it is to be set to. * * @exception AttributeNotFoundException */ public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { // Now we will always fail: // Either because the attribute is null or because it is not // accessible (or does not exist). // final String attname = (attribute==null?null:attribute.getName()); if (attname == null) { final RuntimeException r = new IllegalArgumentException("Attribute name cannot be null"); throw new RuntimeOperationsException(r, "Exception occurred trying to invoke the setter on the MBean"); } // This is a hack: we call getAttribute in order to generate an // AttributeNotFoundException if the attribute does not exist. // Object val = getAttribute(attname); // If we reach this point, we know that the requested attribute // exists. However, since all attributes are read-only, we throw // an AttributeNotFoundException. // throw new AttributeNotFoundException(attname + " not accessible"); }
Example #19
Source File: MBeanSupport.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public final void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { final String name = attribute.getName(); final Object value = attribute.getValue(); perInterface.setAttribute(resource, name, value, getCookie()); }
Example #20
Source File: ConfigurationManagerService.java From attic-polygene-java with Apache License 2.0 | 5 votes |
@Override public Object getAttribute( String name ) throws AttributeNotFoundException, MBeanException, ReflectionException { UnitOfWork uow = uowf.newUnitOfWork(); try { EntityComposite configuration = uow.get( EntityComposite.class, identity ); AssociationStateHolder state = spi.stateOf( configuration ); AccessibleObject accessor = propertyNames.get( name ); Property<Object> property = state.propertyFor( accessor ); Object object = property.get(); if( object instanceof Enum ) { object = object.toString(); } return object; } catch( Exception ex ) { throw new ReflectionException( ex, "Could not get attribute " + name ); } finally { uow.discard(); } }
Example #21
Source File: IgniteSnapshotMXBeanTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param mBean Ignite snapshot MBean. * @return Value of snapshot end time. */ private static long getLastSnapshotEndTime(DynamicMBean mBean) { try { return (long)mBean.getAttribute("LastSnapshotEndTime"); } catch (MBeanException | ReflectionException | AttributeNotFoundException e) { throw new RuntimeException(e); } }
Example #22
Source File: RemoteResourceMonitor.java From tomee with Apache License 2.0 | 5 votes |
@Override public Object invoke(final String actionName, final Object[] params, final String[] signature) throws MBeanException, ReflectionException { if (hosts.contains(actionName)) { return ping(actionName); } else if (PING.equals(actionName) && params != null && params.length == 1) { return ping((String) params[0]); } throw new MBeanException(new IllegalArgumentException(), actionName + " doesn't exist"); }
Example #23
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 void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { checkWrite(); getMBeanServer().setAttribute(name, attribute); }
Example #24
Source File: MBeanTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private void validateTableIntAttr(String tableName, MBeanServerConnection mBeanServer, ObjectName name, Attribute attribute, Number value) throws AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException, IOException { int actual = ((Integer)mBeanServer.getAttribute(name, attribute.getName())).intValue(); if(actual - value.intValue() < 0) { saveError(attribute.getName() + " attribute did not match for " + tableName + " where expected = " + value + " and actuals : " + actual); } else { Log.getLogWriter().info(attribute.getName() + " attribute match for " + tableName + " where expected = " + value + " and actuals : " + actual); } }
Example #25
Source File: MBeanServerAccessController.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Call <code>checkRead()</code>, then forward this method to the * wrapped object. */ @Deprecated public ObjectInputStream deserialize(String className, byte[] data) throws OperationsException, ReflectionException { checkRead(); return getMBeanServer().deserialize(className, data); }
Example #26
Source File: RMIConnector.java From jdk8u-dev-jdk 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 #27
Source File: RMRest.java From scheduling with GNU Affero General Public License v3.0 | 5 votes |
@Override public Object getNodeMBeanInfo(String sessionId, String nodeJmxUrl, String objectName, List<String> attrs) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException, NotConnectedException, MalformedObjectNameException, NullPointerException, PermissionRestException { // checking that still connected to the RM RMProxyUserInterface rmProxy = checkAccess(sessionId); return orThrowRpe(rmProxy.getNodeMBeanInfo(nodeJmxUrl, objectName, attrs)); }
Example #28
Source File: MBeanServerAccessController.java From openjdk-jdk9 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 #29
Source File: RMIConnector.java From jdk1.8-source-analysis with Apache License 2.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 + ", 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 #30
Source File: MBeanServerAccessController.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Call <code>checkWrite()</code>, then forward this method to the * wrapped object. */ public AttributeList setAttributes(ObjectName name, AttributeList attributes) throws InstanceNotFoundException, ReflectionException { checkWrite(); return getMBeanServer().setAttributes(name, attributes); }