Java Code Examples for javax.management.MBeanException
The following examples show how to use
javax.management.MBeanException. These examples are extracted from open source projects.
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 Project: Tomcat8-Source-Read Source File: JMXProxyServlet.java License: MIT License | 6 votes |
/** * Invokes an operation on an MBean. * * @param onameStr The name of the MBean. * @param operation The name of the operation to invoke. * @param parameters An array of Strings containing the parameters to the * operation. They will be converted to the appropriate types to * call the requested operation. * @return The value returned by the requested operation. */ private Object invokeOperationInternal(String onameStr, String operation, String[] parameters) throws OperationsException, MBeanException, ReflectionException { ObjectName oname = new ObjectName(onameStr); MBeanOperationInfo methodInfo = registry.getMethodInfo(oname, operation); MBeanParameterInfo[] signature = methodInfo.getSignature(); String[] signatureTypes = new String[signature.length]; Object[] values = new Object[signature.length]; for (int i = 0; i < signature.length; i++) { MBeanParameterInfo pi = signature[i]; signatureTypes[i] = pi.getType(); values[i] = registry.convertValue(pi.getType(), parameters[i]); } return mBeanServer.invoke(oname, operation, values, signatureTypes); }
Example 2
Source Project: dragonwell8_jdk Source File: MBeanServerAccessController.java License: 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 3
Source Project: openjdk-jdk8u Source File: MBeanServerAccessController.java License: 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 4
Source Project: TencentKona-8 Source File: PerInterface.java License: 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 Project: openjdk-jdk8u Source File: DefaultMBeanServerInterceptor.java License: 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 6
Source Project: TencentKona-8 Source File: MBeanServerDelegateImpl.java License: GNU General Public License v2.0 | 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 7
Source Project: JDKSourceCode1.8 Source File: PerInterface.java License: MIT License | 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 8
Source Project: jdk1.8-source-analysis Source File: MBeanServerAccessController.java License: Apache License 2.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 9
Source Project: JDKSourceCode1.8 Source File: MBeanServerAccessController.java License: MIT License | 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 10
Source Project: openjdk-jdk8u Source File: DefaultMBeanServerInterceptor.java License: 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 11
Source Project: TencentKona-8 Source File: FlightRecorderMXBeanImpl.java License: GNU General Public License v2.0 | 6 votes |
private Notification createNotication(Recording recording) { try { Long id = recording.getId(); Object oldValue = changes.get(recording.getId()); Object newValue = getAttribute(ATTRIBUTE_RECORDINGS); if (recording.getState() != RecordingState.CLOSED) { changes.put(id, newValue); } else { changes.remove(id); } return new AttributeChangeNotification(getObjectName(), sequenceNumber.incrementAndGet(), System.currentTimeMillis(), "Recording " + recording.getName() + " is " + recording.getState(), ATTRIBUTE_RECORDINGS, newValue.getClass().getName(), oldValue, newValue); } catch (AttributeNotFoundException | MBeanException | ReflectionException e) { throw new RuntimeException("Could not create notifcation for FlightRecorderMXBean. " + e.getMessage(), e); } }
Example 12
Source Project: jdk8u60 Source File: MBeanServerAccessController.java License: 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 13
Source Project: Tomcat8-Source-Read Source File: ContextMBean.java License: MIT License | 5 votes |
/** * Return the set of application parameters for this application. * @return a string array with a representation of each parameter * @throws MBeanException propagated from the managed resource access */ public String[] findApplicationParameters() throws MBeanException { Context context = doGetManagedResource(); ApplicationParameter[] params = context.findApplicationParameters(); String[] stringParams = new String[params.length]; for (int counter = 0; counter < params.length; counter++) { stringParams[counter] = params[counter].toString(); } return stringParams; }
Example 14
Source Project: dragonwell8_jdk Source File: MXBeanIntrospector.java License: GNU General Public License v2.0 | 5 votes |
@Override Object invokeM2(ConvertingMethod m, Object target, Object[] args, Object cookie) throws InvocationTargetException, IllegalAccessException, MBeanException { return m.invokeWithOpenReturn((MXBeanLookup) cookie, target, args); }
Example 15
Source Project: TencentKona-8 Source File: OldMBeanServerTest.java License: 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 { try { return createMBean(className, name, clrName, params, signature); } catch (InstanceNotFoundException ex) { throw new RuntimeException(ex); // can't happen } }
Example 16
Source Project: jdk1.8-source-analysis Source File: MBeanServerAccessController.java License: Apache License 2.0 | 5 votes |
/** * Call <code>checkRead()</code>, then forward this method to the * wrapped object. */ public Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException { checkRead(); return getMBeanServer().getAttribute(name, attribute); }
Example 17
Source Project: Tomcat8-Source-Read Source File: ServiceMBean.java License: MIT License | 5 votes |
/** * Retrieves all executors. * @return an array of string representations of the executors * @throws MBeanException error accessing the associated service */ public String[] findExecutors() throws MBeanException { Service service = doGetManagedResource(); Executor[] executors = service.findExecutors(); String[] str = new String[executors.length]; for(int i = 0; i < executors.length; i++){ str[i] = executors[i].toString(); } return str; }
Example 18
Source Project: openjdk-jdk8u Source File: ModelMBeanInfoSupport.java License: GNU General Public License v2.0 | 5 votes |
public void setMBeanDescriptor(Descriptor inMBeanDescriptor) throws MBeanException, RuntimeOperationsException { if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { MODELMBEAN_LOGGER.logp(Level.FINER, ModelMBeanInfoSupport.class.getName(), "setMBeanDescriptor(Descriptor)", "Entry"); } modelMBeanDescriptor = validDescriptor(inMBeanDescriptor); }
Example 19
Source Project: TencentKona-8 Source File: OldMBeanServerTest.java License: 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 20
Source Project: dragonwell8_jdk Source File: DefaultMBeanServerInterceptor.java License: 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 21
Source Project: TencentKona-8 Source File: ModelMBeanInfoSupport.java License: GNU General Public License v2.0 | 5 votes |
public ModelMBeanNotificationInfo getNotification(String inName) throws MBeanException, RuntimeOperationsException { ModelMBeanNotificationInfo retInfo = null; if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { MODELMBEAN_LOGGER.logp(Level.FINER, ModelMBeanInfoSupport.class.getName(), "getNotification(String)", "Entry"); } if (inName == null) { throw new RuntimeOperationsException( new IllegalArgumentException("Notification name is null"), "Exception occurred trying to get the " + "ModelMBeanNotificationInfo of the MBean"); } MBeanNotificationInfo[] notifList = modelMBeanNotifications; //this.getNotifications(); int numNotifs = 0; if (notifList != null) numNotifs = notifList.length; for (int i=0; (i < numNotifs) && (retInfo == null); i++) { if (inName.equals(notifList[i].getName())) { retInfo = ((ModelMBeanNotificationInfo) notifList[i].clone()); } } if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { MODELMBEAN_LOGGER.logp(Level.FINER, ModelMBeanInfoSupport.class.getName(), "getNotification(String)", "Exit"); } return retInfo; }
Example 22
Source Project: dragonwell8_jdk Source File: ConvertingMethod.java License: GNU General Public License v2.0 | 5 votes |
Object invokeWithOpenReturn(MXBeanLookup lookup, Object obj, Object[] params) throws MBeanException, IllegalAccessException, InvocationTargetException { MXBeanLookup old = MXBeanLookup.getLookup(); try { MXBeanLookup.setLookup(lookup); return invokeWithOpenReturn(obj, params); } finally { MXBeanLookup.setLookup(old); } }
Example 23
Source Project: jdk1.8-source-analysis Source File: ModelMBeanInfoSupport.java License: Apache License 2.0 | 5 votes |
public ModelMBeanOperationInfo getOperation(String inName) throws MBeanException, RuntimeOperationsException { ModelMBeanOperationInfo retInfo = null; if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { MODELMBEAN_LOGGER.logp(Level.FINER, ModelMBeanInfoSupport.class.getName(), "getOperation(String)", "Entry"); } if (inName == null) { throw new RuntimeOperationsException( new IllegalArgumentException("inName is null"), "Exception occurred trying to get the " + "ModelMBeanOperationInfo of the MBean"); } MBeanOperationInfo[] operList = modelMBeanOperations; //this.getOperations(); int numOpers = 0; if (operList != null) numOpers = operList.length; for (int i=0; (i < numOpers) && (retInfo == null); i++) { if (inName.equals(operList[i].getName())) { retInfo = ((ModelMBeanOperationInfo) operList[i].clone()); } } if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { MODELMBEAN_LOGGER.logp(Level.FINER, ModelMBeanInfoSupport.class.getName(), "getOperation(String)", "Exit"); } return retInfo; }
Example 24
Source Project: java-svc Source File: PerfCounters.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { if (attribute == null) { throw new RuntimeOperationsException(new IllegalArgumentException("The attribute name cannot be null."), "Cannot invoke getAttribute on " + MBEAN_OBJECT_NAME + " with null as attribute name."); } Counter c = counterMap.get(attribute); if (c == null) { throw new AttributeNotFoundException("Could not find the attribute " + attribute); } return c.getValue(); }
Example 25
Source Project: JDKSourceCode1.8 Source File: RMIConnector.java License: MIT License | 5 votes |
public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object params[], String signature[]) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException { if (logger.debugOn()) logger.debug( "createMBean(String,ObjectName,ObjectName,Object[],String[])", "className=" + className + ", name=" + name + ", loaderName=" + loaderName + ", signature=" + strings(signature)); final MarshalledObject<Object[]> sParams = new MarshalledObject<Object[]>(params); final ClassLoader old = pushDefaultClassLoader(); try { return connection.createMBean(className, name, loaderName, sParams, signature, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.createMBean(className, name, loaderName, sParams, signature, delegationSubject); } finally { popDefaultClassLoader(old); } }
Example 26
Source Project: jdk1.8-source-analysis Source File: DefaultMBeanServerInterceptor.java License: Apache License 2.0 | 5 votes |
public Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException { if (name == null) { throw new RuntimeOperationsException(new IllegalArgumentException("Object name cannot be null"), "Exception occurred trying to invoke the getter on the MBean"); } if (attribute == null) { throw new RuntimeOperationsException(new IllegalArgumentException("Attribute cannot be null"), "Exception occurred trying to invoke the getter on the MBean"); } name = nonDefaultDomain(name); if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { MBEANSERVER_LOGGER.logp(Level.FINER, DefaultMBeanServerInterceptor.class.getName(), "getAttribute", "Attribute = " + attribute + ", ObjectName = " + name); } final DynamicMBean instance = getMBean(name); checkMBeanPermission(instance, attribute, name, "getAttribute"); try { return instance.getAttribute(attribute); } catch (AttributeNotFoundException e) { throw e; } catch (Throwable t) { rethrowMaybeMBeanException(t); throw new AssertionError(); // not reached } }
Example 27
Source Project: TencentKona-8 Source File: MBeanServerAccessController.java License: 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 28
Source Project: TencentKona-8 Source File: MBeanExceptionTest.java License: GNU General Public License v2.0 | 5 votes |
public Object invoke(String opName, Object[] params, String[] sig) throws MBeanException { assert params == null && sig == null; if (opName.equals("UncheckedException")) throw theUncheckedException; else throw new AssertionError(); }
Example 29
Source Project: jdk1.8-source-analysis Source File: MBeanServerAccessController.java License: Apache License 2.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 30
Source Project: jdk8u60 Source File: MXBeanIntrospector.java License: GNU General Public License v2.0 | 5 votes |
@Override Object invokeM2(ConvertingMethod m, Object target, Object[] args, Object cookie) throws InvocationTargetException, IllegalAccessException, MBeanException { return m.invokeWithOpenReturn((MXBeanLookup) cookie, target, args); }