Methods Summary |
---|
protected void | bindProxyInJndi()
InitialContext ctx = new InitialContext ();
Object proxy = RMIRemoteMBeanProxy.create (PluginManagerMBean.class, this.getServiceName (), this.getServer ());
Util.rebind (ctx, this.jndiName, proxy);
|
public void | createService()
this.bootstrapResource = new MBeanResource (this.getServiceName (), this.getClass ().toString ());
|
protected java.util.HashSet | findSubResources(org.jboss.console.manager.interfaces.TreeNode tree)
HashSet result = new HashSet ();
// first add the tree node itself if it is an instance
// of an ResourceTreeNode
//
if (tree instanceof ResourceTreeNode)
{
result.add (((ResourceTreeNode)tree).getResource ());
}
// then add local resources
//
ResourceTreeNode[] rns = tree.getNodeManagableResources ();
if (rns != null && rns.length > 0)
{
// Then travel to sub-nodes resources...
//
for (int i=0; i<rns.length; i++)
{
result.add (rns[i].getResource ());
HashSet subResult = findSubResources (rns[i]);
if (subResult != null && subResult.size () > 0)
result.addAll (subResult);
}
}
// ..and to other sub-nodes (which are not resources)
//
TreeNode[] ns = tree.getSubNodes ();
if (ns != null && ns.length > 0)
{
for (int i=0; i<ns.length; i++)
{
HashSet subResult = findSubResources (ns[i]);
if (subResult != null && subResult.size () > 0)
result.addAll (subResult);
}
}
return result;
|
public org.jboss.console.manager.interfaces.ManageableResource | getBootstrapResource()
return this.bootstrapResource;
|
public java.lang.String | getJndiName()
return jndiName;
|
public javax.management.MBeanServer | getMBeanServer()
return this.server;
|
public java.lang.String | getMainLinkUrl()
return mainLinkUrl;
|
public java.lang.String | getMainLogoUrl()
return mainLogoUrl;
|
protected java.util.ArrayList | getPluginsSubsetForProfile(java.lang.String profile)
ArrayList result = new ArrayList ();
for (int i = 0; i < plugins.size(); i++)
{
ConsolePlugin cp = (ConsolePlugin)plugins.get(i);
String [] set = cp.getSupportedProfiles ();
if (java.util.Arrays.asList (set).contains (profile))
result.add (cp);
}
return result;
|
public synchronized org.jboss.console.manager.interfaces.TreeInfo | getTreeForProfile(java.lang.String profile)
TreeInfo currentTree = (TreeInfo)currentTrees.get(profile);
if (currentTree == null)
{
HashSet resourcesToManage = new HashSet ();
TreeInfo result = new DefaultTreeInfo ();
ArrayList pluginsSubset = getPluginsSubsetForProfile (profile);
HashSet resourcesAlreadyScanned = new HashSet ();
result.setRootResources (new ManageableResource[] {bootstrapResource});
// Bootstrap tree creation
//
resourcesToManage.add (bootstrapResource);
while (resourcesToManage.size () > 0)
{
ManageableResource currentResource = (ManageableResource)resourcesToManage.iterator ().next ();
// pre-clean resources environment
//
resourcesToManage.remove (currentResource);
resourcesAlreadyScanned.add (currentResource);
Iterator iter = getTreesForResource(currentResource, profile, pluginsSubset);
while (iter.hasNext ())
{
TreeNode subTree = (TreeNode)iter.next ();
result.addTreeToResource (currentResource, subTree);
HashSet subResources = findSubResources (subTree);
if (subResources != null && subResources.size () > 0)
{
Iterator subsRes = subResources.iterator ();
while (subsRes.hasNext ())
{
ManageableResource subRes = (ManageableResource)subsRes.next ();
if (!resourcesAlreadyScanned.contains (subRes))
resourcesToManage.add (subRes);
}
}
}
}
this.treeVersion++;
result.setTreeVersion (this.treeVersion);
try
{
TreeNodeMenuEntry[] base = new TreeNodeMenuEntry[]
{
new SimpleTreeNodeMenuEntryImpl ("Update tree", new RefreshTreeAction (false)),
new SimpleTreeNodeMenuEntryImpl ("Force update tree", new RefreshTreeAction (true)),
};
if (enableShutdown)
{
result.setRootMenus (new TreeNodeMenuEntry[]
{
base[0],
base[1],
new SeparatorTreeNodeMenuEntry (),
new SimpleTreeNodeMenuEntryImpl ("Shutdown JBoss instance",
new MBeanAction (new ObjectName("jboss.system:type=Server"),
"shutdown", new Object[0], new String[0])
),
new SimpleTreeNodeMenuEntryImpl ("Shutdown and Restart JBoss instance",
new MBeanAction (new ObjectName("jboss.system:type=Server"),
"exit", new Object[] {new Integer (10)},
new String[] {"int"})
),
new SimpleTreeNodeMenuEntryImpl ("HALT and Restart JBoss instance",
new MBeanAction (new ObjectName("jboss.system:type=Server"),
"halt", new Object[] {new Integer (10)},
new String[] {"int"})
)
}
);
}
else
{
result.setRootMenus (base);
}
result.setHomeAction(new HttpLinkTreeAction (this.mainLinkUrl));
result.setIconUrl (this.mainLogoUrl);
}
catch (Exception bla) {}
currentTree = result;
currentTrees.put(profile, currentTree);
}
return currentTree;
|
protected java.util.Iterator | getTreesForResource(org.jboss.console.manager.interfaces.ManageableResource res, java.lang.String profile, java.util.ArrayList pluginsSubset)
ArrayList result = new ArrayList ();
for (int i = 0; i < pluginsSubset.size(); i++)
{
ConsolePlugin cp = (ConsolePlugin)pluginsSubset.get(i);
TreeNode node = null;
try
{
node = cp.getSubTreeForResource (this, profile, res);
}
catch (Throwable t)
{
t.printStackTrace();
}
if (node != null)
result.add (node);
}
return result.iterator ();
|
public synchronized org.jboss.console.manager.interfaces.TreeInfo | getUpdateTreeForProfile(java.lang.String profile, long knownVersion)Only return the tree if the actual version is bigger than the known version
TreeInfo currentTree = (TreeInfo)currentTrees.get(profile);
if (this.treeVersion > knownVersion || currentTree==null)
return getTreeForProfile (profile);
else
return null;
|
public void | handleNotification(javax.management.Notification notif, java.lang.Object handback)
// Very simple implementation: could be optimized to minimize tree regeneration
// (local invalidation for example)//
//
regenerateAdminTree ();
|
protected void | initNotificationReception()
ObjectName mbsDelegate =
new ObjectName ("JMImplementation:type=MBeanServerDelegate");
NotificationFilter filter = new NotificationFilter ()
{
public boolean isNotificationEnabled (Notification n)
{
return ( n.getType().equals("JMX.mbean.registered") ||
n.getType().equals("JMX.mbean.unregistered") );
}
};
this.getServer().addNotificationListener(mbsDelegate, this, filter, null);
|
public boolean | isEnableShutdown()
return enableShutdown;
|
public synchronized void | regenerateAdminTree()
// remove all cached trees
//
currentTrees.clear();
|
public synchronized void | regenerateAdminTreeForProfile(java.lang.String profile)
// remove cached tree for profile (if any)
//
currentTrees.remove(profile);
|
public void | registerPlugin(java.lang.String consolePluginClassName)send a message
Class pluginClass = Thread.currentThread ().getContextClassLoader ().
loadClass (consolePluginClassName);
ConsolePlugin plugin = (ConsolePlugin)pluginClass.newInstance ();
this.registerPlugin (plugin);
|
public synchronized void | registerPlugin(org.jboss.console.manager.interfaces.ConsolePlugin plugin)send a message
plugins.add (plugin);
regenerateAdminTree();
|
public void | setEnableShutdown(boolean enableShutdown)
this.enableShutdown = enableShutdown;
treeVersion++;
|
public void | setJndiName(java.lang.String jndiName)
this.jndiName = jndiName;
|
public void | setMainLinkUrl(java.lang.String mainLinkUrl)
this.mainLinkUrl = mainLinkUrl;
treeVersion++;
|
public void | setMainLogoUrl(java.lang.String mainLogoUrl)
this.mainLogoUrl = mainLogoUrl;
treeVersion++;
|
public void | startService()
bindProxyInJndi ();
PLUGIN_MANAGER_NAME = this.getServiceName().toString();
Registry.bind(PLUGIN_MANAGER_NAME, this);
initNotificationReception ();
|
public void | stopService()
Registry.unbind(this.getServiceName().toString());
|
public synchronized void | unregisterPlugin(org.jboss.console.manager.interfaces.ConsolePlugin plugin)send a message
plugins.remove (plugin);
regenerateAdminTree();
|