本文整理汇总了Java中javax.management.MBeanException类的典型用法代码示例。如果您正苦于以下问题:Java MBeanException类的具体用法?Java MBeanException怎么用?Java MBeanException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MBeanException类属于javax.management包,在下文中一共展示了MBeanException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMBean
import javax.management.MBeanException; //导入依赖的package包/类
/**
* Create, register, and return an MBean for this
* <code>Context</code> object.
*
* @param context The Context to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
public static ModelMBean createMBean(Context context)
throws Exception {
String mname = createManagedName(context);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
Exception e = new Exception("ManagedBean is not found with "+mname);
throw new MBeanException(e);
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
ModelMBean mbean = managed.createMBean(context);
ObjectName oname = createObjectName(domain, context);
mserver.registerMBean(mbean, oname);
return (mbean);
}
示例2: invoke
import javax.management.MBeanException; //导入依赖的package包/类
@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;
}
示例3: setAttribute
import javax.management.MBeanException; //导入依赖的package包/类
@Override
public synchronized void setAttribute(final Attribute attribute)
throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
Attribute newAttribute = attribute;
if (configBeanModificationDisabled.get()) {
throw new IllegalStateException("Operation is not allowed now");
}
if ("Attribute".equals(newAttribute.getName())) {
setAttribute((Attribute) newAttribute.getValue());
return;
}
try {
if (newAttribute.getValue() instanceof ObjectName) {
newAttribute = fixDependencyAttribute(newAttribute);
} else if (newAttribute.getValue() instanceof ObjectName[]) {
newAttribute = fixDependencyListAttribute(newAttribute);
}
internalServer.setAttribute(objectNameInternal, newAttribute);
} catch (final InstanceNotFoundException e) {
throw new MBeanException(e);
}
}
示例4: createMBean
import javax.management.MBeanException; //导入依赖的package包/类
/**
* 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);
}
}
示例5: setAttribute
import javax.management.MBeanException; //导入依赖的package包/类
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);
}
示例6: createMBean
import javax.management.MBeanException; //导入依赖的package包/类
/**
* Create, register, and return an MBean for this
* <code>ContextEnvironment</code> object.
*
* @param environment
* The ContextEnvironment to be managed
*
* @exception Exception
* if an MBean cannot be created or registered
*/
public static DynamicMBean createMBean(ContextEnvironment environment) throws Exception {
String mname = createManagedName(environment);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
Exception e = new Exception("ManagedBean is not found with " + mname);
throw new MBeanException(e);
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
DynamicMBean mbean = managed.createMBean(environment);
ObjectName oname = createObjectName(domain, environment);
if (mserver.isRegistered(oname)) {
mserver.unregisterMBean(oname);
}
mserver.registerMBean(mbean, oname);
return (mbean);
}
示例7: createMBean
import javax.management.MBeanException; //导入依赖的package包/类
/**
* Create, register, and return an MBean for this
* <code>Group</code> object.
*
* @param group The Group to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
static DynamicMBean createMBean(Group group)
throws Exception {
String mname = createManagedName(group);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
Exception e = new Exception("ManagedBean is not found with "+mname);
throw new MBeanException(e);
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
DynamicMBean mbean = managed.createMBean(group);
ObjectName oname = createObjectName(domain, group);
if( mserver.isRegistered( oname )) {
mserver.unregisterMBean(oname);
}
mserver.registerMBean(mbean, oname);
return (mbean);
}
示例8: sendAttributeChangeNotification
import javax.management.MBeanException; //导入依赖的package包/类
public void sendAttributeChangeNotification(Attribute oldAttribute, Attribute newAttribute)
throws MBeanException, RuntimeOperationsException {
if (oldAttribute == null || newAttribute == null)
throw new RuntimeOperationsException(new IllegalArgumentException(
LocalizedStrings.MX4JModelMBean_ATTRIBUTE_CANNOT_BE_NULL.toLocalizedString()));
if (!oldAttribute.getName().equals(newAttribute.getName()))
throw new RuntimeOperationsException(new IllegalArgumentException(
LocalizedStrings.MX4JModelMBean_ATTRIBUTE_NAMES_CANNOT_BE_DIFFERENT.toLocalizedString()));
// TODO: the source must be the object name of the MBean if the listener was registered through
// MBeanServer
Object oldValue = oldAttribute.getValue();
AttributeChangeNotification n = new AttributeChangeNotification(this, 1,
System.currentTimeMillis(), "Attribute value changed", oldAttribute.getName(),
oldValue == null ? null : oldValue.getClass().getName(), oldValue, newAttribute.getValue());
sendAttributeChangeNotification(n);
}
示例9: createMBean
import javax.management.MBeanException; //导入依赖的package包/类
/**
* 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);
}
}
示例10: getAttribute
import javax.management.MBeanException; //导入依赖的package包/类
public Object getAttribute(ObjectName name,
String attribute)
throws MBeanException,
AttributeNotFoundException,
InstanceNotFoundException,
ReflectionException,
IOException {
if (logger.debugOn()) logger.debug("getAttribute",
"name=" + name + ", attribute="
+ attribute);
final ClassLoader old = pushDefaultClassLoader();
try {
return connection.getAttribute(name,
attribute,
delegationSubject);
} catch (IOException ioe) {
communicatorAdmin.gotIOException(ioe);
return connection.getAttribute(name,
attribute,
delegationSubject);
} finally {
popDefaultClassLoader(old);
}
}
示例11: createMBean
import javax.management.MBeanException; //导入依赖的package包/类
/**
* Create, register, and return an MBean for this
* <code>Engine</code> object.
*
* @param engine The Engine to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
static DynamicMBean createMBean(Engine engine)
throws Exception {
String mname = createManagedName(engine);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
Exception e = new Exception("ManagedBean is not found with "+mname);
throw new MBeanException(e);
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
DynamicMBean mbean = managed.createMBean(engine);
ObjectName oname = createObjectName(domain, engine);
if( mserver.isRegistered( oname )) {
mserver.unregisterMBean(oname);
}
mserver.registerMBean(mbean, oname);
return (mbean);
}
示例12: setAttribute
import javax.management.MBeanException; //导入依赖的package包/类
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
try {
mbsc.setAttribute(objectName, attribute);
} catch (Exception ex) {
throw new MBeanException(ex);
}
}
示例13: createMBean
import javax.management.MBeanException; //导入依赖的package包/类
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);
}
}
示例14: setAttribute
import javax.management.MBeanException; //导入依赖的package包/类
@Override
public void setAttribute(ObjectName name, Attribute attribute)
throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException,
MBeanException, ReflectionException {
ResourcePermission ctx = getOperationContext(name, attribute.getName(), false);
this.securityService.authorize(ctx);
mbs.setAttribute(name, attribute);
}
示例15: createMBean
import javax.management.MBeanException; //导入依赖的package包/类
public ObjectInstance createMBean(String className, ObjectName name,
ObjectName loaderName,
Object[] params, String[] signature)
throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException, MBeanException,
NotCompliantMBeanException, InstanceNotFoundException {
return createMBean(className, name, loaderName, false,
params, signature);
}