Author: ips
Date: 2008-12-15 15:13:29 -0500 (Mon, 15 Dec 2008)
New Revision: 72
Modified:
trunk/core/src/main/java/org/jboss/on/embedded/BootstrapAction.java
trunk/core/src/main/java/org/jboss/on/embedded/EmbeddedInventoryEventListener.java
trunk/core/src/main/java/org/jboss/on/embedded/manager/ResourceManager.java
trunk/core/src/main/java/org/jboss/on/embedded/manager/pc/PluginContainerResourceManager.java
trunk/core/src/main/java/org/jboss/on/embedded/ui/NavigationAction.java
trunk/core/src/main/java/org/jboss/on/embedded/ui/nav/NonSingletonResourceTypeTreeNode.java
Log:
Rebuild content behind navigation nodes using InventoryEventListener
(
https://jira.jboss.org/jira/browse/EMBJOPR-55)
Modified: trunk/core/src/main/java/org/jboss/on/embedded/BootstrapAction.java
===================================================================
--- trunk/core/src/main/java/org/jboss/on/embedded/BootstrapAction.java 2008-12-12
20:11:31 UTC (rev 71)
+++ trunk/core/src/main/java/org/jboss/on/embedded/BootstrapAction.java 2008-12-15
20:13:29 UTC (rev 72)
@@ -76,6 +76,9 @@
@In(value = "contentHistoryManager", create = true)
private ContentHistoryManagerBean contentHistoryManager;
+ @In(value = "inventoryEventListener", create = true)
+ private EmbeddedInventoryEventListener inventoryEventListener;
+
private File tempDir;
@Create
@@ -118,7 +121,7 @@
pluginContainer.initialize();
logLoadedPlugins(pluginContainer);
// Add our inventory listener BEFORE initiating Resource discovery.
- pluginContainer.getInventoryManager().addInventoryEventListener(new
EmbeddedInventoryEventListener());
+
pluginContainer.getInventoryManager().addInventoryEventListener(this.inventoryEventListener);
ResourceManager resourceManager = ResourceManagerFactory.resourceManager();
resourceManager.discoverResources();
LOG.info("Done bootstrapping Administration Console.");
Modified:
trunk/core/src/main/java/org/jboss/on/embedded/EmbeddedInventoryEventListener.java
===================================================================
---
trunk/core/src/main/java/org/jboss/on/embedded/EmbeddedInventoryEventListener.java 2008-12-12
20:11:31 UTC (rev 71)
+++
trunk/core/src/main/java/org/jboss/on/embedded/EmbeddedInventoryEventListener.java 2008-12-15
20:13:29 UTC (rev 72)
@@ -32,17 +32,32 @@
import org.rhq.core.domain.content.PackageType;
import org.rhq.core.clientapi.agent.PluginContainerException;
+import org.jboss.seam.core.Events;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Observer;
+import org.jboss.seam.ScopeType;
+
+import org.jboss.on.embedded.manager.ResourceManager;
+
/**
* @author Ian Springer
*/
+@Name("inventoryEventListener")
+(a)Scope(ScopeType.APPLICATION)
public class EmbeddedInventoryEventListener implements InventoryEventListener
{
private final Log log = LogFactory.getLog(this.getClass());
+ private boolean navTreeInitialized;
+
public void resourcesAdded(Set<Resource> resources)
{
for (Resource resource : resources)
{
+ if (this.navTreeInitialized)
+ Events.instance().raiseEvent(ResourceManager.RESOURCE_CREATED_EVENT,
resource.getResourceType(),
+ resource.getParentResource());
ResourceType resourceType = resource.getResourceType();
if (isContentBacked(resourceType))
{
@@ -66,7 +81,10 @@
public void resourcesRemoved(Set<Resource> resources)
{
- return;
+ if (this.navTreeInitialized)
+ for (Resource resource : resources)
+ Events.instance().raiseEvent(ResourceManager.RESOURCE_DELETED_EVENT,
resource.getResourceType(),
+ resource.getParentResource());
}
public void resourceActivated(Resource resource)
@@ -74,6 +92,11 @@
return;
}
+ @Observer(ResourceManager.NAV_TREE_INITIALIZED)
+ public void navTreeInitialized() {
+ this.navTreeInitialized = true;
+ }
+
private static boolean isContentBacked(ResourceType resourceType)
{
return resourceType.isCreatable() && resourceType.getCreationDataType()
== ResourceCreationDataType.CONTENT;
Modified: trunk/core/src/main/java/org/jboss/on/embedded/manager/ResourceManager.java
===================================================================
--- trunk/core/src/main/java/org/jboss/on/embedded/manager/ResourceManager.java 2008-12-12
20:11:31 UTC (rev 71)
+++ trunk/core/src/main/java/org/jboss/on/embedded/manager/ResourceManager.java 2008-12-15
20:13:29 UTC (rev 72)
@@ -42,6 +42,14 @@
*/
public interface ResourceManager
{
+ String RESOURCE_CREATED_EVENT = "resourceCreated";
+
+ String RESOURCE_UPDATED_EVENT = "resourceUpdated";
+
+ String RESOURCE_DELETED_EVENT = "resourceDeleted";
+
+ String NAV_TREE_INITIALIZED = "navTreeInitialized";
+
/**
* Tells this instance to discover all resources. Calls to methods in this interface
will return empty data until
* resources have been discovered. This is a blocking method.
Modified:
trunk/core/src/main/java/org/jboss/on/embedded/manager/pc/PluginContainerResourceManager.java
===================================================================
---
trunk/core/src/main/java/org/jboss/on/embedded/manager/pc/PluginContainerResourceManager.java 2008-12-12
20:11:31 UTC (rev 71)
+++
trunk/core/src/main/java/org/jboss/on/embedded/manager/pc/PluginContainerResourceManager.java 2008-12-15
20:13:29 UTC (rev 72)
@@ -253,7 +253,7 @@
if (response.getStatus() == DeleteResourceStatus.SUCCESS)
{
discoverServicesSync();
- Events.instance().raiseEvent("resourceDeleted", resource);
+ //Events.instance().raiseEvent(ResourceManager.RESOURCE_DELETED_EVENT,
resource);
}
}
catch (PluginContainerException e)
@@ -291,7 +291,7 @@
if (response.getStatus() == CreateResourceStatus.SUCCESS)
{
discoverServicesSync();
- Events.instance().raiseEvent("resourceCreated", resourceType,
parentResource);
+ Events.instance().raiseEvent(ResourceManager.RESOURCE_CREATED_EVENT,
resourceType, parentResource);
}
}
catch (PluginContainerException e)
Modified: trunk/core/src/main/java/org/jboss/on/embedded/ui/NavigationAction.java
===================================================================
--- trunk/core/src/main/java/org/jboss/on/embedded/ui/NavigationAction.java 2008-12-12
20:11:31 UTC (rev 71)
+++ trunk/core/src/main/java/org/jboss/on/embedded/ui/NavigationAction.java 2008-12-15
20:13:29 UTC (rev 72)
@@ -40,6 +40,7 @@
import org.jboss.on.embedded.ui.nav.ResourceTypeTreeNode;
import org.jboss.on.embedded.ui.nav.TreeNodeWithResource;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.core.Events;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
@@ -56,15 +57,14 @@
import org.richfaces.component.html.HtmlTree;
/**
- * NavigationAction creates the navigation objects.
- * <p/>
- * TODO go through this class and try to ensure the minimum amount of things
- * are public. Most actions should be dealing with CommonActionUtil for getting hold of
resources etc
+ * NavigationAction creates the navigation objects.
*
* @author Jessica Sant
* @author Charles Crouch
* @author Ian Springer
*/
+// TODO: Go through this class and try to ensure the minimum amount of things are
public.
+// Most actions should be dealing with CommonActionUtil for getting hold of
resources etc.
@Name("navigationAction")
@Scope(ScopeType.SESSION)
public class NavigationAction
@@ -139,6 +139,7 @@
DummyTreeNode dummy = new DummyTreeNode();
PlatformResourceTreeNode platform = new
PlatformResourceTreeNode(ResourceManagerFactory.resourceManager().getPlatform());
dummy.addChild(platform);
+ Events.instance().raiseEvent(ResourceManager.NAV_TREE_INITIALIZED);
return dummy;
}
@@ -397,15 +398,15 @@
// TODO could consider renaming this getCurrentNavigationNode()
public JONTreeNode getSelectedNode()
{
+ log.debug("Finding node for path [" + getCurrentPath() +
"]...");
JONTreeNode selectedNode = getRootNode().findNode(getCurrentPath());
- if (selectedNode == null)
- {
- // I'm seeing this on login now?
+ ResourceManager resourceManager = ResourceManagerFactory.resourceManager();
+ if (selectedNode == null) {
+ log.debug("Unable to find node with path [" + this.currentPath +
"]; defaulting to platform node...");
+ // TODO (ccrouch): I'm seeing this on login now. Comment out for now.
// String errorMsg = "Unable to find node with path [" +
this.currentPath + "]; defaulting to platform node...";
// LOG.error(errorMsg);
// this.facesMessages.add(FacesMessage.SEVERITY_ERROR, errorMsg);
- log.debug("Unable to find node with path [" + this.currentPath +
"]; defaulting to platform node...");
- ResourceManager resourceManager = ResourceManagerFactory.resourceManager();
this.currentPath = getResourcePath(resourceManager.getPlatform());
selectedNode = getRootNode().findNode(this.currentPath);
}
@@ -440,7 +441,7 @@
return getResourcePath(resource.getId());
}
- @Observer("resourceCreated")
+ @Observer(ResourceManager.RESOURCE_CREATED_EVENT)
public void updateNavWithNewResource(ResourceType typeOfNewResource, Resource
parentResource)
{
log.info("Resource of type [" + typeOfNewResource + "] added
beneath Resource [" + parentResource + "].");
@@ -449,7 +450,7 @@
node.reInitializeChildrenMap();
}
- @Observer("resourceDeleted")
+ @Observer(ResourceManager.RESOURCE_DELETED_EVENT)
public void updateNavWithDeletedResource(Resource deletedResource)
{
log.info("Resource [" + deletedResource + "] deleted.");
@@ -465,7 +466,7 @@
parent.reInitializeChildrenMap();
}
- @Observer("resourceUpdated")
+ @Observer(ResourceManager.RESOURCE_UPDATED_EVENT)
public void updateNavWithUpdatedResource(Resource updatedResource)
{
// doesn't do anything right now, but in the future this could
@@ -509,8 +510,8 @@
public void changeExpandListener(org.richfaces.event.NodeExpandedEvent event) {
UIComponent comp = event.getComponent();
UITree tree = (UITree) comp;
- JONTreeNode data = (JONTreeNode) (tree.getTreeNode().getData());
- data.reInitializeChildrenMap();
+ JONTreeNode jonTreeNode = (JONTreeNode) (tree.getTreeNode().getData());
+ jonTreeNode.reInitializeChildrenMap();
}
// /**
Modified:
trunk/core/src/main/java/org/jboss/on/embedded/ui/nav/NonSingletonResourceTypeTreeNode.java
===================================================================
---
trunk/core/src/main/java/org/jboss/on/embedded/ui/nav/NonSingletonResourceTypeTreeNode.java 2008-12-12
20:11:31 UTC (rev 71)
+++
trunk/core/src/main/java/org/jboss/on/embedded/ui/nav/NonSingletonResourceTypeTreeNode.java 2008-12-15
20:13:29 UTC (rev 72)
@@ -61,8 +61,9 @@
public String getPath()
{
- return getParent() == null ? getName() :
- getParent().getPath() + "/" + getName();
+ String resourceTypeName = getResourceType().getName();
+ return getParent() == null ? resourceTypeName :
+ getParent().getPath() + "/" + resourceTypeName;
}
public String getName()