本文整理匯總了Java中javax.management.RuntimeOperationsException類的典型用法代碼示例。如果您正苦於以下問題:Java RuntimeOperationsException類的具體用法?Java RuntimeOperationsException怎麽用?Java RuntimeOperationsException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RuntimeOperationsException類屬於javax.management包,在下文中一共展示了RuntimeOperationsException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: mbeanCreation
import javax.management.RuntimeOperationsException; //導入依賴的package包/類
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;
}
示例2: getAttributes
import javax.management.RuntimeOperationsException; //導入依賴的package包/類
/**
* Obtain and return the values of several attributes of this MBean.
*
* @param names
* Names of the requested attributes
*/
@Override
public AttributeList getAttributes(String names[]) {
// Validate the input parameters
if (names == null)
throw new RuntimeOperationsException(new IllegalArgumentException("Attribute names list is null"),
"Attribute names list is null");
// Prepare our response, eating all exceptions
AttributeList response = new AttributeList();
for (int i = 0; i < names.length; i++) {
try {
response.add(new Attribute(names[i], getAttribute(names[i])));
} catch (Exception e) {
// Not having a particular attribute in the response
// is the indication of a getter problem
}
}
return (response);
}
示例3: getAttributes
import javax.management.RuntimeOperationsException; //導入依賴的package包/類
/**
* Obtain and return the values of several attributes of this MBean.
*
* @param names Names of the requested attributes
*/
@Override
public AttributeList getAttributes(String names[]) {
// Validate the input parameters
if (names == null)
throw new RuntimeOperationsException
(new IllegalArgumentException("Attribute names list is null"),
"Attribute names list is null");
// Prepare our response, eating all exceptions
AttributeList response = new AttributeList();
for (int i = 0; i < names.length; i++) {
try {
response.add(new Attribute(names[i],getAttribute(names[i])));
} catch (Exception e) {
// Not having a particular attribute in the response
// is the indication of a getter problem
}
}
return (response);
}
示例4: getListener
import javax.management.RuntimeOperationsException; //導入依賴的package包/類
private NotificationListener getListener(ObjectName listener)
throws ListenerNotFoundException {
// ----------------
// Get listener object
// ----------------
DynamicMBean instance;
try {
instance = getMBean(listener);
} catch (InstanceNotFoundException e) {
throw EnvHelp.initCause(
new ListenerNotFoundException(e.getMessage()), e);
}
Object resource = getResource(instance);
if (!(resource instanceof NotificationListener)) {
final RuntimeException exc =
new IllegalArgumentException(listener.getCanonicalName());
final String msg =
"MBean " + listener.getCanonicalName() + " does not " +
"implement " + NotificationListener.class.getName();
throw new RuntimeOperationsException(exc, msg);
}
return (NotificationListener) resource;
}
示例5: notifyJmx
import javax.management.RuntimeOperationsException; //導入依賴的package包/類
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);
}
}
}
示例6: findClassWithDefaultLoaderRepository
import javax.management.RuntimeOperationsException; //導入依賴的package包/類
/**
* 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;
}
示例7: loadClass
import javax.management.RuntimeOperationsException; //導入依賴的package包/類
/**
* 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;
}
示例8: if
import javax.management.RuntimeOperationsException; //導入依賴的package包/類
/**
* 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
*/
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);
}
示例9: addAttributeChangeNotificationListener
import javax.management.RuntimeOperationsException; //導入依賴的package包/類
public void addAttributeChangeNotificationListener(NotificationListener listener,
String attributeName, Object handback)
throws MBeanException, RuntimeOperationsException, IllegalArgumentException {
if (listener == null)
throw new RuntimeOperationsException(new IllegalArgumentException(
LocalizedStrings.MX4JModelMBean_LISTENER_CANNOT_BE_NULL.toLocalizedString()));
AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
if (attributeName != null) {
filter.enableAttribute(attributeName);
} else {
MBeanAttributeInfo[] ai = m_modelMBeanInfo.getAttributes();
for (int i = 0; i < ai.length; i++) {
Descriptor d = ((ModelMBeanAttributeInfo) ai[i]).getDescriptor();
filter.enableAttribute((String) d.getFieldValue("name"));
}
}
getAttributeChangeBroadcaster().addNotificationListener(listener, filter, handback);
Logger logger = getLogger();
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("Listener " + listener + " for attribute " + attributeName
+ " added successfully, handback is " + handback);
}
示例10: sendAttributeChangeNotification
import javax.management.RuntimeOperationsException; //導入依賴的package包/類
public void sendAttributeChangeNotification(AttributeChangeNotification notification)
throws MBeanException, RuntimeOperationsException {
if (notification == null)
throw new RuntimeOperationsException(new IllegalArgumentException(
LocalizedStrings.MX4JModelMBean_NOTIFICATION_CANNOT_BE_NULL.toLocalizedString()));
getAttributeChangeBroadcaster().sendNotification(notification);
Logger modelMBeanLogger = getModelMBeanLogger(notification.getType());
if (modelMBeanLogger != null)
if (modelMBeanLogger.isEnabledFor(Logger.DEBUG))
modelMBeanLogger.debug("ModelMBean log: " + new Date() + " - " + notification);
Logger logger = getLogger();
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("Attribute change notification " + notification + " sent");
}
示例11: sendAttributeChangeNotification
import javax.management.RuntimeOperationsException; //導入依賴的package包/類
/**
* 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);
}
示例12: getNotificationBroadcaster
import javax.management.RuntimeOperationsException; //導入依賴的package包/類
private static <T extends NotificationBroadcaster>
T getNotificationBroadcaster(ObjectName name, Object instance,
Class<T> reqClass) {
if (reqClass.isInstance(instance))
return reqClass.cast(instance);
if (instance instanceof DynamicMBean2)
instance = ((DynamicMBean2) instance).getResource();
if (reqClass.isInstance(instance))
return reqClass.cast(instance);
final RuntimeException exc =
new IllegalArgumentException(name.getCanonicalName());
final String msg =
"MBean " + name.getCanonicalName() + " does not " +
"implement " + reqClass.getName();
throw new RuntimeOperationsException(exc, msg);
}
示例13: addClassLoader
import javax.management.RuntimeOperationsException; //導入依賴的package包/類
/**
* Registers a ClassLoader with the CLR.
* This method is called by the ResourceContext from within the
* repository lock.
* @param loader The ClassLoader.
* @param logicalName The ClassLoader MBean ObjectName.
*/
private void addClassLoader(ClassLoader loader,
final ObjectName logicalName) {
/**
* Called when the newly registered MBean is a ClassLoader
* If so, tell the ClassLoaderRepository (CLR) about it. We do
* this even if the loader is a PrivateClassLoader. In that
* case, the CLR remembers the loader for use when it is
* explicitly named (e.g. as the loader in createMBean) but
* does not add it to the list that is consulted by
* ClassLoaderRepository.loadClass.
*/
final ModifiableClassLoaderRepository clr = getInstantiatorCLR();
if (clr == null) {
final RuntimeException wrapped =
new IllegalArgumentException(
"Dynamic addition of class loaders" +
" is not supported");
throw new RuntimeOperationsException(wrapped,
"Exception occurred trying to register" +
" the MBean as a class loader");
}
clr.addClassLoader(logicalName, loader);
}
示例14: getAttributes
import javax.management.RuntimeOperationsException; //導入依賴的package包/類
@Override
public AttributeList getAttributes(String[] attributeNames) {
if (attributeNames == null) {
throw new RuntimeOperationsException(new IllegalArgumentException("attributeNames[] cannot be null"),
"Cannot call getAttributes with null attribute names");
}
AttributeList resultList = new AttributeList();
if (attributeNames.length == 0) {
return resultList;
}
for (String attributeName : attributeNames) {
try {
Object value = getAttribute(attributeName);
resultList.add(new Attribute(attributeName, value));
} catch (Exception e) {
e.printStackTrace();
}
}
return (resultList);
}
示例15: getFieldValue
import javax.management.RuntimeOperationsException; //導入依賴的package包/類
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);
}