use of org.apache.tomcat.util.modeler.ManagedBean in project tomcat by apache.
the class MBeanUtils method destroyMBean.
/**
* Deregister the MBean for this
* <code>ContextEnvironment</code> object.
*
* @param environment The ContextEnvironment to be managed
*
* @exception Exception if an MBean cannot be deregistered
*/
public static void destroyMBean(ContextEnvironment environment) throws Exception {
String mname = createManagedName(environment);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
return;
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
ObjectName oname = createObjectName(domain, environment);
if (mserver.isRegistered(oname))
mserver.unregisterMBean(oname);
}
use of org.apache.tomcat.util.modeler.ManagedBean in project tomcat by apache.
the class MBeanUtils method createMBean.
/**
* Create, register, and return an MBean for this
* <code>Group</code> object.
*
* @param group The Group to be managed
* @return a new MBean
* @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);
}
use of org.apache.tomcat.util.modeler.ManagedBean in project tomcat by apache.
the class MbeansDescriptorsDigesterSource method execute.
public void execute() throws Exception {
if (registry == null) {
registry = Registry.getRegistry(null, null);
}
InputStream stream = (InputStream) source;
ArrayList<ManagedBean> loadedMbeans = new ArrayList<>();
synchronized (dLock) {
if (digester == null) {
digester = createDigester();
}
// Process the input file to configure our registry
try {
// Push our registry object onto the stack
digester.push(loadedMbeans);
digester.parse(stream);
} catch (Exception e) {
log.error("Error digesting Registry data", e);
throw e;
} finally {
digester.reset();
}
}
Iterator<ManagedBean> iter = loadedMbeans.iterator();
while (iter.hasNext()) {
registry.addManagedBean(iter.next());
}
}
use of org.apache.tomcat.util.modeler.ManagedBean in project tomcat by apache.
the class MBeanUtils method createMBean.
/**
* Create, register, and return an MBean for this
* <code>ContextEnvironment</code> object.
*
* @param environment The ContextEnvironment to be managed
* @return a new MBean
* @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);
}
Aggregations