/**
* 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);
}
java类javax.management.MBeanException的实例源码
MBeanUtils.java 文件源码
项目:jerrydog
阅读 22
收藏 0
点赞 0
评论 0
MetricsDynamicMBeanBase.java 文件源码
项目:hadoop-oss
阅读 24
收藏 0
点赞 0
评论 0
@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;
}
DynamicWritableWrapper.java 文件源码
项目:hashsdn-controller
阅读 23
收藏 0
点赞 0
评论 0
@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);
}
}
MBeanServerAccessController.java 文件源码
项目:OpenJSharp
阅读 23
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
PerInterface.java 文件源码
项目:OpenJSharp
阅读 28
收藏 0
点赞 0
评论 0
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);
}
MBeanUtils.java 文件源码
项目:lazycat
阅读 23
收藏 0
点赞 0
评论 0
/**
* 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);
}
MBeanUtils.java 文件源码
项目:apache-tomcat-7.0.73-with-comment
阅读 32
收藏 0
点赞 0
评论 0
/**
* 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);
}
MX4JModelMBean.java 文件源码
项目:monarch
阅读 28
收藏 0
点赞 0
评论 0
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);
}
MBeanServerAccessController.java 文件源码
项目:jdk8u-jdk
阅读 24
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
MBeanUtils.java 文件源码
项目:apache-tomcat-7.0.73-with-comment
阅读 26
收藏 0
点赞 0
评论 0
/**
* Create, register, and return an MBean for this
* <code>ContextResource</code> object.
*
* @param resource The ContextResource to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
public static DynamicMBean createMBean(ContextResource resource)
throws Exception {
String mname = createManagedName(resource);
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(resource);
ObjectName oname = createObjectName(domain, resource);
if( mserver.isRegistered( oname )) {
mserver.unregisterMBean(oname);
}
mserver.registerMBean(mbean, oname);
return (mbean);
}
RMIConnector.java 文件源码
项目:jdk8u-jdk
阅读 20
收藏 0
点赞 0
评论 0
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);
}
}
MBeanUtils.java 文件源码
项目:lams
阅读 33
收藏 0
点赞 0
评论 0
/**
* 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);
}
MBeanUtils.java 文件源码
项目:jerrydog
阅读 24
收藏 0
点赞 0
评论 0
/**
* Create, register, and return an MBean for this
* <code>Service</code> object.
*
* @param service The Service to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
public static ModelMBean createMBean(Service service)
throws Exception {
String mname = createManagedName(service);
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(service);
ObjectName oname = createObjectName(domain, service);
mserver.registerMBean(mbean, oname);
return (mbean);
}
MBeanUtils.java 文件源码
项目:lams
阅读 32
收藏 0
点赞 0
评论 0
/**
* Create, register, and return an MBean for this
* <code>Valve</code> object.
*
* @param valve The Valve to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
static DynamicMBean createMBean(Valve valve)
throws Exception {
String mname = createManagedName(valve);
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(valve);
ObjectName oname = createObjectName(domain, valve);
if( mserver.isRegistered( oname )) {
mserver.unregisterMBean(oname);
}
mserver.registerMBean(mbean, oname);
return (mbean);
}
DynamicProxy.java 文件源码
项目:Pogamut3
阅读 26
收藏 0
点赞 0
评论 0
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
try {
mbsc.setAttribute(objectName, attribute);
} catch (Exception ex) {
throw new MBeanException(ex);
}
}
RMIConnector.java 文件源码
项目:OpenJSharp
阅读 25
收藏 0
点赞 0
评论 0
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);
}
}
MBeanServerWrapper.java 文件源码
项目:monarch
阅读 23
收藏 0
点赞 0
评论 0
@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);
}
DefaultMBeanServerInterceptor.java 文件源码
项目:openjdk-jdk10
阅读 28
收藏 0
点赞 0
评论 0
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);
}
PogamutMBeanServer.java 文件源码
项目:Pogamut3
阅读 20
收藏 0
点赞 0
评论 0
@Override
public synchronized ObjectInstance createMBean(String className, ObjectName name,
ObjectName loaderName, Object[] params, String[] signature)
throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException, MBeanException,
NotCompliantMBeanException, InstanceNotFoundException {
throw new UnsupportedOperationException("Not supported by PogamutMBeanServer yet...");
}
MetricsSourceAdapter.java 文件源码
项目:hadoop
阅读 45
收藏 0
点赞 0
评论 0
@Override
public Object getAttribute(String attribute)
throws AttributeNotFoundException, MBeanException, ReflectionException {
updateJmxCache();
synchronized(this) {
Attribute a = attrCache.get(attribute);
if (a == null) {
throw new AttributeNotFoundException(attribute +" not found");
}
if (LOG.isDebugEnabled()) {
LOG.debug(attribute +": "+ a);
}
return a.getValue();
}
}
TestUnifiedLoggingSwitchStress.java 文件源码
项目:openjdk-jdk10
阅读 20
收藏 0
点赞 0
评论 0
@Override
public void run() {
while (!shouldStop) {
int fileNum = RND.nextInt(logCount);
int logLevel = RND.nextInt(LOG_LEVELS.length);
String outputCommand = String.format("output=%s_%d.log", logFilePrefix, fileNum);
String logLevelCommand = "what='gc*=" + LOG_LEVELS[logLevel] + "'";
try {
Object out = MBS.invoke(new ObjectName("com.sun.management:type=DiagnosticCommand"),
"vmLog",
new Object[]{new String[]{outputCommand, logLevelCommand}},
new String[]{String[].class.getName()});
if (!out.toString().isEmpty()) {
System.out.format("WARNING: Diagnostic command vmLog with arguments %s,%s returned not empty"
+ " output %s\n",
outputCommand, logLevelCommand, out);
}
} catch (InstanceNotFoundException | MBeanException | ReflectionException | MalformedObjectNameException e) {
System.out.println("Got exception trying to change log level:" + e);
e.printStackTrace();
throw new Error(e);
}
Thread.yield();
}
System.out.println("Log Switcher finished");
}
DefaultMBeanServerInterceptor.java 文件源码
项目:OpenJSharp
阅读 32
收藏 0
点赞 0
评论 0
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);
}
MetricsSourceAdapter.java 文件源码
项目:hadoop-oss
阅读 30
收藏 0
点赞 0
评论 0
@Override
public Object getAttribute(String attribute)
throws AttributeNotFoundException, MBeanException, ReflectionException {
updateJmxCache();
synchronized(this) {
Attribute a = attrCache.get(attribute);
if (a == null) {
throw new AttributeNotFoundException(attribute +" not found");
}
if (LOG.isDebugEnabled()) {
LOG.debug(attribute +": "+ a);
}
return a.getValue();
}
}
ModelMBeanInfoSupport.java 文件源码
项目:openjdk-jdk10
阅读 19
收藏 0
点赞 0
评论 0
public ModelMBeanOperationInfo getOperation(String inName)
throws MBeanException, RuntimeOperationsException {
ModelMBeanOperationInfo retInfo = null;
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE, "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.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
}
return retInfo;
}
JMXProxyServlet.java 文件源码
项目:tomcat7
阅读 27
收藏 0
点赞 0
评论 0
/**
* Sets an MBean attribute's value.
*/
private void setAttributeInternal(String onameStr,
String attributeName,
String value)
throws OperationsException, MBeanException, ReflectionException {
ObjectName oname=new ObjectName( onameStr );
String type=registry.getType(oname, attributeName);
Object valueObj=registry.convertValue(type, value );
mBeanServer.setAttribute( oname, new Attribute(attributeName, valueObj));
}
ConfigTransactionClientsTest.java 文件源码
项目:hashsdn-controller
阅读 18
收藏 0
点赞 0
评论 0
@Test(expected = ValidationException.class)
public void testValidateBean2() throws Exception {
MBeanServer mbsLocal = mock(MBeanServer.class);
MBeanException mBeanException = new MBeanException(new ValidationException(
Collections.<String, Map<String, ExceptionMessageWithStackTrace>>emptyMap()));
doThrow(mBeanException).when(mbsLocal).invoke(transactionControllerON, "validate", null, null);
ConfigTransactionJMXClient jmxTransactionClientFake = new ConfigTransactionJMXClient(null,
transactionControllerON,
mbsLocal);
jmxTransactionClientFake.validateBean(transactionControllerON);
}
JmxReporterTest.java 文件源码
项目:tqdev-metrics
阅读 28
收藏 0
点赞 0
评论 0
/**
* Should throw exception on unknown type.
*
* @throws MBeanException
* the MBean exception
* @throws AttributeNotFoundException
* the attribute not found exception
* @throws ReflectionException
* the reflection exception
*/
@Test
public void shouldThrowExceptionOnUnknownType()
throws MBeanException, AttributeNotFoundException, ReflectionException {
try {
readJmx("jdbc.Statement.Invocations", "select");
Assert.fail("readJmx should have thrown an AttributeNotFoundException");
} catch (Exception e) {
assertThat(e.getClass().getSimpleName()).isEqualTo("AttributeNotFoundException");
}
}
MBeanServerAccessController.java 文件源码
项目:jdk8u-jdk
阅读 32
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
BaseModelMBean.java 文件源码
项目:lazycat
阅读 21
收藏 0
点赞 0
评论 0
/**
* 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);
}
MBeanServerAccessController.java 文件源码
项目:jdk8u-jdk
阅读 27
收藏 0
点赞 0
评论 0
/**
* Call <code>checkCreate(className)</code>, then forward this method to the
* wrapped object.
*/
public Object instantiate(String className,
Object params[],
String signature[])
throws ReflectionException, MBeanException {
checkCreate(className);
return getMBeanServer().instantiate(className, params, signature);
}