Methods Summary |
---|
protected void | createMBeans()Create the MBeans for the interesting global JNDI resources.
// Look up our global naming context
Context context = null;
try {
context = (Context) (new InitialContext()).lookup("java:/");
} catch (NamingException e) {
log.error("No global naming context defined for server");
return;
}
// Recurse through the defined global JNDI resources context
try {
createMBeans("", context);
} catch (NamingException e) {
log.error("Exception processing Global JNDI Resources", e);
}
|
protected void | createMBeans(java.lang.String prefix, javax.naming.Context context)Create the MBeans for the interesting global JNDI resources in
the specified naming context.
if (log.isDebugEnabled()) {
log.debug("Creating MBeans for Global JNDI Resources in Context '" +
prefix + "'");
}
try {
NamingEnumeration bindings = context.listBindings("");
while (bindings.hasMore()) {
Binding binding = (Binding) bindings.next();
String name = prefix + binding.getName();
Object value = context.lookup(binding.getName());
if (log.isDebugEnabled()) {
log.debug("Checking resource " + name);
}
if (value instanceof Context) {
createMBeans(name + "/", (Context) value);
} else if (value instanceof UserDatabase) {
try {
createMBeans(name, (UserDatabase) value);
} catch (Exception e) {
log.error("Exception creating UserDatabase MBeans for " + name,
e);
}
}
}
} catch( RuntimeException ex) {
log.error("RuntimeException " + ex);
} catch( OperationNotSupportedException ex) {
log.error("Operation not supported " + ex);
}
|
protected void | createMBeans(java.lang.String name, org.apache.catalina.UserDatabase database)Create the MBeans for the specified UserDatabase and its contents.
// Create the MBean for the UserDatabase itself
if (log.isDebugEnabled()) {
log.debug("Creating UserDatabase MBeans for resource " + name);
log.debug("Database=" + database);
}
if (MBeanUtils.createMBean(database) == null) {
throw new IllegalArgumentException
("Cannot create UserDatabase MBean for resource " + name);
}
// Create the MBeans for each defined Role
Iterator roles = database.getRoles();
while (roles.hasNext()) {
Role role = (Role) roles.next();
if (log.isDebugEnabled()) {
log.debug(" Creating Role MBean for role " + role);
}
if (MBeanUtils.createMBean(role) == null) {
throw new IllegalArgumentException
("Cannot create Role MBean for role " + role);
}
}
// Create the MBeans for each defined Group
Iterator groups = database.getGroups();
while (groups.hasNext()) {
Group group = (Group) groups.next();
if (log.isDebugEnabled()) {
log.debug(" Creating Group MBean for group " + group);
}
if (MBeanUtils.createMBean(group) == null) {
throw new IllegalArgumentException
("Cannot create Group MBean for group " + group);
}
}
// Create the MBeans for each defined User
Iterator users = database.getUsers();
while (users.hasNext()) {
User user = (User) users.next();
if (log.isDebugEnabled()) {
log.debug(" Creating User MBean for user " + user);
}
if (MBeanUtils.createMBean(user) == null) {
throw new IllegalArgumentException
("Cannot create User MBean for user " + user);
}
}
|
protected void | destroyMBeans()Destroy the MBeans for the interesting global JNDI resources.
if (log.isDebugEnabled()) {
log.debug("Destroying MBeans for Global JNDI Resources");
}
|
public void | lifecycleEvent(org.apache.catalina.LifecycleEvent event)Primary entry point for startup and shutdown events.
// ---------------------------------------------- LifecycleListener Methods
if (Lifecycle.START_EVENT.equals(event.getType())) {
component = event.getLifecycle();
createMBeans();
} else if (Lifecycle.STOP_EVENT.equals(event.getType())) {
destroyMBeans();
component = null;
}
|