javax.management.RuntimeOperationsException Java Examples
The following examples show how to use
javax.management.RuntimeOperationsException.
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: DescriptorSupport.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Descriptor constructor. Takes as parameter the initial * capacity of the Map that stores the descriptor fields. * Capacity will grow as needed.<br> Note that the created empty * descriptor is not a valid descriptor (the method {@link * #isValid isValid} returns <CODE>false</CODE>). * * @param initNumFields The initial capacity of the Map that * stores the descriptor fields. * * @exception RuntimeOperationsException for illegal value for * initNumFields (<= 0) * @exception MBeanException Wraps a distributed communication Exception. */ public DescriptorSupport(int initNumFields) throws MBeanException, RuntimeOperationsException { if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { MODELMBEAN_LOGGER.logp(Level.FINEST, DescriptorSupport.class.getName(), "Descriptor(initNumFields = " + initNumFields + ")", "Constructor"); } if (initNumFields <= 0) { if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { MODELMBEAN_LOGGER.logp(Level.FINEST, DescriptorSupport.class.getName(), "Descriptor(initNumFields)", "Illegal arguments: initNumFields <= 0"); } final String msg = "Descriptor field limit invalid: " + initNumFields; final RuntimeException iae = new IllegalArgumentException(msg); throw new RuntimeOperationsException(iae, msg); } init(null); }
Example #2
Source File: BaseModelMBean.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Send an <code>AttributeChangeNotification</code> to all registered * listeners. * * @param notification The <code>AttributeChangeNotification</code> * that will be passed * * @exception MBeanException if an object initializer throws an * exception * @exception RuntimeOperationsException wraps IllegalArgumentException * when the specified notification is <code>null</code> or invalid */ @Override public void sendAttributeChangeNotification (AttributeChangeNotification notification) throws MBeanException, RuntimeOperationsException { if (notification == null) throw new RuntimeOperationsException (new IllegalArgumentException("Notification is null"), "Notification is null"); if (attributeBroadcaster == null) return; // This means there are no registered listeners if( log.isDebugEnabled() ) log.debug( "AttributeChangeNotification " + notification ); attributeBroadcaster.sendNotification(notification); }
Example #3
Source File: BaseModelMBean.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Send an <code>AttributeChangeNotification</code> to all registered * listeners. * * @param oldValue The original value of the <code>Attribute</code> * @param newValue The new value of the <code>Attribute</code> * * @exception MBeanException if an object initializer throws an * exception * @exception RuntimeOperationsException wraps IllegalArgumentException * when the specified notification is <code>null</code> or invalid */ @Override public void sendAttributeChangeNotification (Attribute oldValue, Attribute newValue) throws MBeanException, RuntimeOperationsException { // Calculate the class name for the change notification String type = null; if (newValue.getValue() != null) type = newValue.getValue().getClass().getName(); else if (oldValue.getValue() != null) type = oldValue.getValue().getClass().getName(); else return; // Old and new are both null == no change AttributeChangeNotification notification = new AttributeChangeNotification (this, 1, System.currentTimeMillis(), "Attribute value has changed", oldValue.getName(), type, oldValue.getValue(), newValue.getValue()); sendAttributeChangeNotification(notification); }
Example #4
Source File: SlowQueryReportJmx.java From Tomcat8-Source-Read with MIT License | 6 votes |
protected void notifyJmx(String query, String type) { try { long sequence = notifySequence.incrementAndGet(); if (isNotifyPool()) { if (this.pool!=null && this.pool.getJmxPool()!=null) { this.pool.getJmxPool().notify(type, query); } } else { if (notifier!=null) { Notification notification = new Notification(type, this, sequence, System.currentTimeMillis(), query); notifier.sendNotification(notification); } } } catch (RuntimeOperationsException e) { if (log.isDebugEnabled()) { log.debug("Unable to send failed query notification.",e); } } }
Example #5
Source File: RepositoryWildcardTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static int mbeanCreation(MBeanServer mbs, String name) throws Exception { int error = 0; try { System.out.println("Test: createMBean(" + name + ")"); mbs.createMBean(classname, ObjectName.getInstance(name)); error++; System.out.println("Didn't get expected exception!"); System.out.println("Test failed!"); } catch (RuntimeOperationsException e) { System.out.println("Got expected exception = " + e.getCause().toString()); System.out.println("Test passed!"); } return error; }
Example #6
Source File: MBeanServerDelegateImpl.java From dragonwell8_jdk with 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 File: MBeanInstantiator.java From TencentKona-8 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 #8
Source File: MBeanInstantiator.java From dragonwell8_jdk 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: MBeanInstantiator.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * Loads the class with the specified name using this object's * Default Loader Repository. **/ public Class<?> findClassWithDefaultLoaderRepository(String className) 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 (clr == null) throw new ClassNotFoundException(className); theClass = clr.loadClass(className); } catch (ClassNotFoundException ee) { throw new ReflectionException(ee, "The MBean class could not be loaded by the default loader repository"); } return theClass; }
Example #10
Source File: MBeanInstantiator.java From jdk1.8-source-analysis with Apache License 2.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 #11
Source File: MBeanInstantiator.java From jdk1.8-source-analysis with Apache License 2.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: RepositoryWildcardTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static int mbeanCreation(MBeanServer mbs, String name) throws Exception { int error = 0; try { System.out.println("Test: createMBean(" + name + ")"); mbs.createMBean(classname, ObjectName.getInstance(name)); error++; System.out.println("Didn't get expected exception!"); System.out.println("Test failed!"); } catch (RuntimeOperationsException e) { System.out.println("Got expected exception = " + e.getCause().toString()); System.out.println("Test passed!"); } return error; }
Example #13
Source File: DescriptorSupport.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * Descriptor constructor. Takes as parameter the initial * capacity of the Map that stores the descriptor fields. * Capacity will grow as needed.<br> Note that the created empty * descriptor is not a valid descriptor (the method {@link * #isValid isValid} returns <CODE>false</CODE>). * * @param initNumFields The initial capacity of the Map that * stores the descriptor fields. * * @exception RuntimeOperationsException for illegal value for * initNumFields (<= 0) * @exception MBeanException Wraps a distributed communication Exception. */ public DescriptorSupport(int initNumFields) throws MBeanException, RuntimeOperationsException { if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { MODELMBEAN_LOGGER.logp(Level.FINEST, DescriptorSupport.class.getName(), "Descriptor(initNumFields = " + initNumFields + ")", "Constructor"); } if (initNumFields <= 0) { if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { MODELMBEAN_LOGGER.logp(Level.FINEST, DescriptorSupport.class.getName(), "Descriptor(initNumFields)", "Illegal arguments: initNumFields <= 0"); } final String msg = "Descriptor field limit invalid: " + initNumFields; final RuntimeException iae = new IllegalArgumentException(msg); throw new RuntimeOperationsException(iae, msg); } init(null); }
Example #14
Source File: DescriptorSupport.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
public synchronized Object getFieldValue(String fieldName) throws RuntimeOperationsException { if ((fieldName == null) || (fieldName.equals(""))) { if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { MODELMBEAN_LOGGER.logp(Level.FINEST, DescriptorSupport.class.getName(), "getFieldValue(String fieldName)", "Illegal arguments: null field name"); } final String msg = "Fieldname requested is null"; final RuntimeException iae = new IllegalArgumentException(msg); throw new RuntimeOperationsException(iae, msg); } Object retValue = descriptorMap.get(fieldName); if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { MODELMBEAN_LOGGER.logp(Level.FINEST, DescriptorSupport.class.getName(), "getFieldValue(String fieldName = " + fieldName + ")", "Returns '" + retValue + "'"); } return(retValue); }
Example #15
Source File: MBeanInstantiator.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Loads the class with the specified name using this object's * Default Loader Repository. **/ public Class<?> findClassWithDefaultLoaderRepository(String className) 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 (clr == null) throw new ClassNotFoundException(className); theClass = clr.loadClass(className); } catch (ClassNotFoundException ee) { throw new ReflectionException(ee, "The MBean class could not be loaded by the default loader repository"); } return theClass; }
Example #16
Source File: MBeanInstantiator.java From dragonwell8_jdk 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 #17
Source File: MBeanServerDelegateImpl.java From TencentKona-8 with 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 #18
Source File: KnowledgeBaseMonitoring.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public Object getAttribute(String attributeName) throws AttributeNotFoundException, MBeanException, ReflectionException { if ( attributeName == null ) { throw new RuntimeOperationsException( new IllegalArgumentException( "attributeName cannot be null" ), "Cannot invoke a getter of " + getClass().getName() ); } else if ( attributeName.equals( ATTR_ID ) ) { return getId(); } else if ( attributeName.equals( ATTR_SESSION_COUNT ) ) { return Long.valueOf( getSessionCount() ); } else if ( attributeName.equals( ATTR_GLOBALS ) ) { try { return getGlobals(); } catch ( OpenDataException e ) { throw new RuntimeOperationsException( new RuntimeException( "Error retrieving globals list", e ), "Error retrieving globals list " + e.getMessage() ); } } else if ( attributeName.equals( ATTR_PACKAGES ) ) { return getPackages(); } throw new AttributeNotFoundException( "Cannot find " + attributeName + " attribute " ); }
Example #19
Source File: ModelMBeanInfoSupport.java From TencentKona-8 with GNU General Public License v2.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 #20
Source File: RequiredModelMBean.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Returns the values of several attributes in the ModelMBean. * Executes a getAttribute for each attribute name in the * attrNames array passed in. * * @param attrNames A String array of names of the attributes * to be retrieved. * * @return The array of the retrieved attributes. * * @exception RuntimeOperationsException Wraps an * {@link IllegalArgumentException}: The object name in parameter is * null or attributes in parameter is null. * * @see #setAttributes(javax.management.AttributeList) */ public AttributeList getAttributes(String[] attrNames) { if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), "getAttributes(String[])","Entry"); } if (attrNames == null) throw new RuntimeOperationsException(new IllegalArgumentException("attributeNames must not be null"), "Exception occurred trying to get attributes of a "+ "RequiredModelMBean"); AttributeList responseList = new AttributeList(); for (int i = 0; i < attrNames.length; i++) { try { responseList.add(new Attribute(attrNames[i], getAttribute(attrNames[i]))); } catch (Exception e) { // eat exceptions because interface doesn't have an // exception on it if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), "getAttributes(String[])", "Failed to get \"" + attrNames[i] + "\": ", e); } } } if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), "getAttributes(String[])","Exit"); } return responseList; }
Example #21
Source File: ModelMBeanInfoSupport.java From TencentKona-8 with 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 #22
Source File: DefaultMBeanServerInterceptor.java From TencentKona-8 with GNU General Public License v2.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 #23
Source File: DefaultMBeanServerInterceptor.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public boolean isRegistered(ObjectName name) { if (name == null) { throw new RuntimeOperationsException( new IllegalArgumentException("Object name cannot be null"), "Object name cannot be null"); } name = nonDefaultDomain(name); /* No Permission check */ // isRegistered is always unchecked as per JMX spec. return (repository.contains(name)); }
Example #24
Source File: ContextResourceMBean.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Obtain and return the value of a specific attribute of this MBean. * * @param name Name of the requested attribute * * @exception AttributeNotFoundException if this attribute is not * supported by this MBean * @exception MBeanException if the initializer of an object * throws an exception * @exception ReflectionException if a Java reflection exception * occurs when invoking the getter */ @Override public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException { // Validate the input parameters if (name == null) { throw new RuntimeOperationsException( new IllegalArgumentException("Attribute name is null"), "Attribute name is null"); } ContextResource cr = doGetManagedResource(); String value = null; if ("auth".equals(name)) { return cr.getAuth(); } else if ("description".equals(name)) { return cr.getDescription(); } else if ("name".equals(name)) { return cr.getName(); } else if ("scope".equals(name)) { return cr.getScope(); } else if ("type".equals(name)) { return cr.getType(); } else { value = (String) cr.getProperty(name); if (value == null) { throw new AttributeNotFoundException ("Cannot find attribute [" + name + "]"); } } return value; }
Example #25
Source File: RequiredModelMBean.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Sets the values of an array of attributes of this ModelMBean. * Executes the setAttribute() method for each attribute in the list. * * @param attributes A list of attributes: The identification of the * attributes to be set and the values they are to be set to. * * @return The array of attributes that were set, with their new * values in Attribute instances. * * @exception RuntimeOperationsException Wraps an * {@link IllegalArgumentException}: The object name in parameter * is null or attributes in parameter is null. * * @see #getAttributes **/ public AttributeList setAttributes(AttributeList attributes) { if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), "setAttribute(Attribute)", "Entry"); } if (attributes == null) throw new RuntimeOperationsException(new IllegalArgumentException("attributes must not be null"), "Exception occurred trying to set attributes of a "+ "RequiredModelMBean"); final AttributeList responseList = new AttributeList(); // Go through the list of attributes for (Attribute attr : attributes.asList()) { try { setAttribute(attr); responseList.add(attr); } catch (Exception excep) { responseList.remove(attr); } } return responseList; }
Example #26
Source File: BaseCatalinaMBean.java From Tomcat8-Source-Read with MIT License | 5 votes |
protected T doGetManagedResource() throws MBeanException { try { @SuppressWarnings("unchecked") T resource = (T) getManagedResource(); return resource; } catch (InstanceNotFoundException | RuntimeOperationsException | InvalidTargetObjectTypeException e) { throw new MBeanException(e); } }
Example #27
Source File: BaseModelMBean.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Set the instance handle of the object against which we will execute * all methods in this ModelMBean management interface. * * The caller can provide the mbean instance or the object name to * the resource, if needed. * * @param resource The resource object to be managed * @param type The type of reference for the managed resource * ("ObjectReference", "Handle", "IOR", "EJBHandle", or * "RMIReference") * * @exception InstanceNotFoundException if the managed resource object * cannot be found * @exception MBeanException if the initializer of the object throws * an exception * @exception RuntimeOperationsException if the managed resource or the * resource type is <code>null</code> or invalid */ public void setManagedResource(Object resource, String type) throws InstanceNotFoundException, MBeanException, RuntimeOperationsException { if (resource == null) throw new RuntimeOperationsException (new IllegalArgumentException("Managed resource is null"), "Managed resource is null"); // if (!"objectreference".equalsIgnoreCase(type)) // throw new InvalidTargetObjectTypeException(type); this.resource = resource; this.resourceType = resource.getClass().getName(); // // Make the resource aware of the model mbean. // try { // Method m=resource.getClass().getMethod("setModelMBean", // new Class[] {ModelMBean.class}); // if( m!= null ) { // m.invoke(resource, new Object[] {this}); // } // } catch( NoSuchMethodException t ) { // // ignore // } catch( Throwable t ) { // log.error( "Can't set model mbean ", t ); // } }
Example #28
Source File: ContextResourceLinkMBean.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Set the value of a specific attribute of this MBean. * * @param attribute The identification of the attribute to be set * and the new value * * @exception AttributeNotFoundException if this attribute is not * supported by this MBean * @exception MBeanException if the initializer of an object * throws an exception * @exception ReflectionException if a Java reflection exception * occurs when invoking the getter */ @Override public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { // Validate the input parameters if (attribute == null) { throw new RuntimeOperationsException( new IllegalArgumentException("Attribute is null"), "Attribute is null"); } String name = attribute.getName(); Object value = attribute.getValue(); if (name == null) { throw new RuntimeOperationsException( new IllegalArgumentException("Attribute name is null"), "Attribute name is null"); } ContextResourceLink crl = doGetManagedResource(); if ("global".equals(name)) { crl.setGlobal((String) value); } else if ("description".equals(name)) { crl.setDescription((String) value); } else if ("name".equals(name)) { crl.setName((String) value); } else if ("type".equals(name)) { crl.setType((String) value); } else { crl.setProperty(name, "" + value); } // cannot use side-effects. It's removed and added back each time // there is a modification in a resource. NamingResources nr = crl.getNamingResources(); nr.removeResourceLink(crl.getName()); nr.addResourceLink(crl); }
Example #29
Source File: MBeanServerDelegateImpl.java From jdk1.8-source-analysis with Apache License 2.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 #30
Source File: JmxMBeanServer.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * De-serializes a byte array in the context of a given MBean class loader. * The class loader is the one that loaded the class with name "className". * * @param className The name of the class whose class loader should be * used for the de-serialization. * @param data The byte array to be de-sererialized. * * @return The de-serialized object stream. * * @exception OperationsException Any of the usual Input/Output * related exceptions. * @exception ReflectionException The specified class could not be * loaded by the default loader repository * */ @Deprecated public ObjectInputStream deserialize(String className, byte[] data) throws OperationsException, ReflectionException { if (className == null) { throw new RuntimeOperationsException( new IllegalArgumentException(), "Null className passed in parameter"); } /* Permission check */ // This call requires MBeanPermission 'getClassLoaderRepository' final ClassLoaderRepository clr = getClassLoaderRepository(); Class<?> theClass; try { if (clr == null) throw new ClassNotFoundException(className); theClass = clr.loadClass(className); } catch (ClassNotFoundException e) { throw new ReflectionException(e, "The given class could not be " + "loaded by the default loader " + "repository"); } return instantiator.deserialize(theClass.getClassLoader(), data); }