Author: chris.laprun(a)jboss.com
Date: 2009-04-27 06:18:18 -0400 (Mon, 27 Apr 2009)
New Revision: 13271
Added:
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortalServer.java
Removed:
modules/jopr-plugin/trunk/plugin/src/main/assemble/
Modified:
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortalComponent.java
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortalDiscovery.java
modules/jopr-plugin/trunk/plugin/src/main/resources/META-INF/rhq-plugin.xml
Log:
- Extracted PortalServer information from PortalComponent as a component is not loaded
until after discovery
and discovery needs PortalServer to provided more detailed information.
- Removed useless assemble directory.
Modified:
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortalComponent.java
===================================================================
---
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortalComponent.java 2009-04-27
08:23:57 UTC (rev 13270)
+++
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortalComponent.java 2009-04-27
10:18:18 UTC (rev 13271)
@@ -25,10 +25,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.mx.util.MBeanServerLocator;
import org.jboss.portal.jems.as.JMX;
import org.jboss.portal.management.Portal;
-import org.jboss.portal.server.Server;
+import org.jboss.portal.management.PortalServer;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
@@ -48,9 +47,6 @@
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
import java.util.Set;
@@ -64,9 +60,6 @@
EventContext eventContext;
- private static final String PORTAL_SERVICE_SERVER =
"portal:service=Server";
- private Server portalServer;
-
private static final String PORTAL_MANAGEMENT_SERVICE =
"portal.management:service=Management,type=Portal,name=Default";
private Portal portal;
@@ -78,7 +71,7 @@
*/
public AvailabilityType getAvailability()
{
- return isRegistered(PORTAL_SERVICE_SERVER) ? AvailabilityType.UP :
AvailabilityType.DOWN;
+ return PortalServer.isRunning() ? AvailabilityType.UP : AvailabilityType.DOWN;
}
@@ -94,8 +87,6 @@
try
{
- portalServer = (Server)JMX.getMBeanProxy(Server.class, PORTAL_SERVICE_SERVER);
-
portal = (Portal)JMX.getMBeanProxy(Portal.class, PORTAL_MANAGEMENT_SERVICE);
}
catch (Exception e)
@@ -210,29 +201,4 @@
{
// TODO supply code to delete a child resource
}
-
- private static ObjectName createObjectName(String name)
- {
- ObjectName objecName;
- try
- {
- objecName = new ObjectName(name);
- }
- catch (MalformedObjectNameException e)
- {
- throw new IllegalArgumentException("'" + name + "' is not
a valid ObjectName");
- }
- return objecName;
- }
-
- public static boolean isRegistered(String name)
- {
- MBeanServer server = MBeanServerLocator.locateJBoss();
- return server.isRegistered(createObjectName(name));
- }
-
- public String getVersion()
- {
- return portalServer.getVersion().toString();
- }
}
\ No newline at end of file
Modified:
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortalDiscovery.java
===================================================================
---
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortalDiscovery.java 2009-04-27
08:23:57 UTC (rev 13270)
+++
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortalDiscovery.java 2009-04-27
10:18:18 UTC (rev 13271)
@@ -25,6 +25,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.portal.management.PortalServer;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
@@ -50,8 +51,9 @@
* stay the same when the resource is discovered the next
* time
*/
- DiscoveredResourceDetails detail = new
DiscoveredResourceDetails(discoveryContext.getResourceType(), "Portal",
- "JBoss Portal", "1.0.0.Alpha1", "Monitoring of JBoss
Portal resources", null, null);
+ String portalVersion = PortalServer.getVersion();
+ DiscoveredResourceDetails detail = new
DiscoveredResourceDetails(discoveryContext.getResourceType(), "JBossPortal",
+ portalVersion, portalVersion, "Monitoring of JBoss Portal resources",
null, null);
// Add to return values
Modified: modules/jopr-plugin/trunk/plugin/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- modules/jopr-plugin/trunk/plugin/src/main/resources/META-INF/rhq-plugin.xml 2009-04-27
08:23:57 UTC (rev 13270)
+++ modules/jopr-plugin/trunk/plugin/src/main/resources/META-INF/rhq-plugin.xml 2009-04-27
10:18:18 UTC (rev 13271)
@@ -41,7 +41,8 @@
--><!-- TODO add your own here --><!--
</plugin-configuration>-->
- <operation name="refreshPortletList" description="Refreshes the
portlet list"/>
+ <operation name="refreshPortletList" displayName="Refresh portlet
list"
+ description="Refreshes the list of deployed portlets"/>
<metric property="portletNumber" displayName="Display the number
of currently deployed portlets"/>
Added:
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortalServer.java
===================================================================
---
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortalServer.java
(rev 0)
+++
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortalServer.java 2009-04-27
10:18:18 UTC (rev 13271)
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.management;
+
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.portal.jems.as.JMX;
+import org.jboss.portal.server.Server;
+
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class PortalServer
+{
+ private static final String PORTAL_SERVICE_SERVER =
"portal:service=Server";
+ private static Server portalServer;
+
+ private PortalServer()
+ {
+ }
+
+ static
+ {
+ portalServer = (Server)JMX.getMBeanProxy(Server.class, PORTAL_SERVICE_SERVER);
+ }
+
+ public static boolean isRunning()
+ {
+ return isRegistered(PORTAL_SERVICE_SERVER);
+ }
+
+ private static ObjectName createObjectName(String name)
+ {
+ ObjectName objecName;
+ try
+ {
+ objecName = new ObjectName(name);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw new IllegalArgumentException("'" + name + "' is not
a valid ObjectName");
+ }
+ return objecName;
+ }
+
+ public static boolean isRegistered(String name)
+ {
+ MBeanServer server = MBeanServerLocator.locateJBoss();
+ return server.isRegistered(createObjectName(name));
+ }
+
+ public static String getVersion()
+ {
+ if (portalServer == null)
+ {
+ return "Unavailable";
+ }
+
+ return portalServer.getVersion().toString();
+ }
+}