Author: chris.laprun(a)jboss.com
Date: 2009-05-08 11:23:03 -0400 (Fri, 08 May 2009)
New Revision: 13325
Added:
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/InvokerComponent.java
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/InvokerDiscovery.java
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/ManagedPortletInvoker.java
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/ManagedPortletInvokerImpl.java
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/PortletComponent.java
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortletDiscovery.java
modules/jopr-plugin/trunk/plugin/src/main/resources/META-INF/rhq-plugin.xml
modules/jopr-plugin/trunk/portal-management-service/src/main/resources/META-INF/jboss-service.xml
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/Portal.java
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortalImpl.java
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortletDiscovery.java
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortletDiscoveryService.java
Log:
- Separated portlets per invokers which makes things clearer and will allow
metrics/operations to be done on an invoker-basis.
- Improved display of portlet metadata by using the portlet name instead of the id and
using the context name as version.
- Started better handling of portlets (they should be now removed when they are
undeployed).
- Still needs quite a bit of cleaning up and testing.
Added:
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/InvokerComponent.java
===================================================================
---
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/InvokerComponent.java
(rev 0)
+++
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/InvokerComponent.java 2009-05-08
15:23:03 UTC (rev 13325)
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * 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.jopr;
+
+import org.jboss.portal.management.ManagedPortletInvoker;
+import org.jboss.portal.management.Portal;
+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;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class InvokerComponent implements ResourceComponent, MeasurementFacet,
OperationFacet
+{
+ private ManagedPortletInvoker invoker;
+ private final static Portal portal;
+
+ static
+ {
+ portal = PortalServer.getPortalManagement();
+ }
+
+ public void start(ResourceContext resourceContext) throws
InvalidPluginConfigurationException, Exception
+ {
+ invoker =
portal.getManagedPortletInvokers().get(resourceContext.getResourceKey());
+ }
+
+ public void stop()
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public AvailabilityType getAvailability()
+ {
+ return invoker.isAvailable() ? AvailabilityType.UP : AvailabilityType.DOWN;
+ }
+
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest>
metrics) throws Exception
+ {
+ for (MeasurementScheduleRequest req : metrics)
+ {
+ if (req.getName().equals("portletNumber"))
+ {
+ MeasurementDataNumeric res = new MeasurementDataNumeric(req,
(double)invoker.getPortletNumber());
+ report.addData(res);
+ }
+ }
+ }
+
+ public OperationResult invokeOperation(String name, Configuration configuration)
throws InterruptedException, Exception
+ {
+ OperationResult res = new OperationResult();
+ if ("refreshPortletList".equals(name))
+ {
+ invoker.refreshPortlets();
+ }
+ return res;
+ }
+
+ public ManagedPortletInvoker getInvoker()
+ {
+ return invoker;
+ }
+}
Added:
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/InvokerDiscovery.java
===================================================================
---
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/InvokerDiscovery.java
(rev 0)
+++
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/InvokerDiscovery.java 2009-05-08
15:23:03 UTC (rev 13325)
@@ -0,0 +1,80 @@
+/******************************************************************************
+ * 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.jopr;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.portal.management.ManagedPortletInvoker;
+import org.jboss.portal.management.PortalServer;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class InvokerDiscovery implements ResourceDiscoveryComponent
+{
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public Set discoverResources(ResourceDiscoveryContext discoveryContext) throws
InvalidPluginConfigurationException, Exception
+ {
+ if (PortalServer.isRunning())
+ {
+
+ Map<String, ManagedPortletInvoker> invokers =
PortalServer.getPortalManagement().getManagedPortletInvokers();
+
+
+ if (invokers.isEmpty())
+ {
+ return Collections.emptySet();
+ }
+
+ Set<DiscoveredResourceDetails> discoveredResources = new
HashSet<DiscoveredResourceDetails>(invokers.size());
+
+ for (String invokerName : invokers.keySet())
+ {
+
+ DiscoveredResourceDetails detail = new
DiscoveredResourceDetails(discoveryContext.getResourceType(), invokerName,
+ invokerName, "N/A", "Monitoring of Portlet Invoker " +
invokerName, null, null);
+
+
+ // Add to return values
+ discoveredResources.add(detail);
+ log.info("Discovered new portlet invoker: " + invokerName);
+ }
+
+ return discoveredResources;
+ }
+
+ return Collections.emptySet();
+ }
+}
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-05-07
21:58:57 UTC (rev 13324)
+++
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortalComponent.java 2009-05-08
15:23:03 UTC (rev 13325)
@@ -110,10 +110,9 @@
*/
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest>
metrics) throws Exception
{
-
for (MeasurementScheduleRequest req : metrics)
{
- if (req.getName().equals("portletNumber"))
+ if (req.getName().equals("portletInstances"))
{
MeasurementDataNumeric res = new MeasurementDataNumeric(req,
(double)portal.getNbInstances());
report.addData(res);
@@ -137,13 +136,13 @@
*/
public OperationResult invokeOperation(String name, Configuration params) throws
Exception
{
-
OperationResult res = new OperationResult();
if ("refreshPortletList".equals(name))
{
System.out.println("refreshPortletList called res = " + res);
}
return res;
+
}
Modified:
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortletComponent.java
===================================================================
---
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortletComponent.java 2009-05-07
21:58:57 UTC (rev 13324)
+++
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortletComponent.java 2009-05-08
15:23:03 UTC (rev 13325)
@@ -53,7 +53,8 @@
public void start(ResourceContext resourceContext) throws
InvalidPluginConfigurationException, Exception
{
- portlet =
portal.getRegisteredPortletManagements().get(resourceContext.getResourceKey());
+ InvokerComponent invoker =
(InvokerComponent)resourceContext.getParentResourceComponent();
+ portlet =
invoker.getInvoker().getRegisteredPortlets().get(resourceContext.getResourceKey());
}
public void stop()
Modified:
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortletDiscovery.java
===================================================================
---
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortletDiscovery.java 2009-05-07
21:58:57 UTC (rev 13324)
+++
modules/jopr-plugin/trunk/plugin/src/main/java/org/jboss/portal/jopr/PortletDiscovery.java 2009-05-08
15:23:03 UTC (rev 13325)
@@ -50,9 +50,11 @@
if (PortalServer.isRunning())
{
- Map<String, LocalPortletManagementMBean> portlets =
PortalServer.getPortalManagement().getRegisteredPortletManagements();
+ String invokerName =
discoveryContext.getParentResourceContext().getResourceKey();
+ Map<String, LocalPortletManagementMBean> portlets =
PortalServer.getPortalManagement().getManagedPortletInvokers().get(invokerName).getRegisteredPortlets();
+
if (portlets.isEmpty())
{
return Collections.emptySet();
@@ -60,16 +62,15 @@
Set<DiscoveredResourceDetails> discoveredResources = new
HashSet<DiscoveredResourceDetails>(portlets.size());
- for (String portletName : portlets.keySet())
+ for (String portletId : portlets.keySet())
{
+ String name = getPortletNameFromId(portletId);
+ DiscoveredResourceDetails detail = new
DiscoveredResourceDetails(discoveryContext.getResourceType(), portletId,
+ name, getPortletVersionFromId(portletId), "Monitoring of Portlet
" + name, null, null);
- DiscoveredResourceDetails detail = new
DiscoveredResourceDetails(discoveryContext.getResourceType(), portletName,
- portletName, "N/A", "Monitoring of Portlet " +
portletName, null, null);
-
-
// Add to return values
discoveredResources.add(detail);
- log.info("Discovered new portlet: " + portletName);
+ log.info("Discovered new portlet: " + portletId);
}
return discoveredResources;
@@ -77,4 +78,14 @@
return Collections.emptySet();
}
+
+ private String getPortletVersionFromId(String id)
+ {
+ return id.substring(id.indexOf('.') + 1, id.lastIndexOf('.')) +
" (deployment context)";
+ }
+
+ private String getPortletNameFromId(String id)
+ {
+ return id.substring(id.lastIndexOf('.') + 1);
+ }
}
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-05-07
21:58:57 UTC (rev 13324)
+++ modules/jopr-plugin/trunk/plugin/src/main/resources/META-INF/rhq-plugin.xml 2009-05-08
15:23:03 UTC (rev 13325)
@@ -30,40 +30,29 @@
xmlns:c="urn:xmlns:rhq-configuration">
- <server name="JBoss Portal"
- discovery="PortalDiscovery"
- class="PortalComponent"
- singleton="true">
+ <server name="JBoss Portal" discovery="PortalDiscovery"
class="PortalComponent" singleton="true">
- <!--<plugin-configuration>
- --><!-- TODO add your own here --><!--
- </plugin-configuration>-->
+ <metric property="instanceNumber" displayName="Display the number
of portlet instances"/>
- <operation name="refreshPortletList" displayName="Refresh portlet
list"
- description="Refreshes the list of deployed portlets"/>
+ <server name="Portlet Invoker" class="InvokerComponent"
discovery="InvokerDiscovery">
+ <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"/>
- <service name="Portlet" class="PortletComponent"
discovery="PortletDiscovery">
- <metric property="averageRenderTime" displayName="Average
render time" units="milliseconds"/>
- <metric property="averageActionTime" displayName="Average
action time" units="milliseconds"/>
- <metric property="maxRenderTime" displayName="Maximum render
time" units="milliseconds"/>
- <metric property="maxActionTime" displayName="Maximum action
time" units="milliseconds"/>
- <metric property="renderRequestCount" displayName="Number of
render requests" measurementType="trendsup"
- units="none"/>
- <metric property="actionRequestCount" displayName="Number of
action requests" measurementType="trendsup"
- units="none"/>
- <metric property="renderErrorCount" displayName="Number of
render errors" measurementType="trendsup"
- units="none"/>
- <metric property="actionErrorCount" displayName="Number of
action errors" measurementType="trendsup"
- units="none"/>
- </service>
-
-
- <!--<event name="portal-jopr-pluginDummyEvent"/>-->
-
- <!--<resource-configuration>
- --><!-- TODO supply your configuration parameters --><!--
- </resource-configuration>-->
+ <service name="Portlet" class="PortletComponent"
discovery="PortletDiscovery">
+ <metric property="averageRenderTime" displayName="Average
render time" units="milliseconds"/>
+ <metric property="averageActionTime" displayName="Average
action time" units="milliseconds"/>
+ <metric property="maxRenderTime" displayName="Maximum
render time" units="milliseconds"/>
+ <metric property="maxActionTime" displayName="Maximum
action time" units="milliseconds"/>
+ <metric property="renderRequestCount" displayName="Number
of render requests" measurementType="trendsup"
+ units="none"/>
+ <metric property="actionRequestCount" displayName="Number
of action requests" measurementType="trendsup"
+ units="none"/>
+ <metric property="renderErrorCount" displayName="Number of
render errors" measurementType="trendsup"
+ units="none"/>
+ <metric property="actionErrorCount" displayName="Number of
action errors" measurementType="trendsup"
+ units="none"/>
+ </service>
+ </server>
</server>
</plugin>
\ No newline at end of file
Added:
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/ManagedPortletInvoker.java
===================================================================
---
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/ManagedPortletInvoker.java
(rev 0)
+++
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/ManagedPortletInvoker.java 2009-05-08
15:23:03 UTC (rev 13325)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * 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.portal.portlet.management.LocalPortletManagementMBean;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public interface ManagedPortletInvoker
+{
+ boolean isWSRP();
+
+ boolean isAvailable();
+
+ Map<String, LocalPortletManagementMBean> getRegisteredPortlets();
+
+ int getPortletNumber();
+
+ void refreshPortlets();
+}
Added:
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/ManagedPortletInvokerImpl.java
===================================================================
---
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/ManagedPortletInvokerImpl.java
(rev 0)
+++
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/ManagedPortletInvokerImpl.java 2009-05-08
15:23:03 UTC (rev 13325)
@@ -0,0 +1,119 @@
+/******************************************************************************
+ * 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.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.portal.portlet.InvokerUnavailableException;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.federation.FederatedPortletInvoker;
+import org.jboss.portal.portlet.management.LocalPortletManagementMBean;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class ManagedPortletInvokerImpl implements ManagedPortletInvoker
+{
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ private PortletDiscoveryService discoveryService;
+
+ private FederatedPortletInvoker invoker;
+ private Map<String, LocalPortletManagementMBean> registeredPortlets = new
HashMap<String, LocalPortletManagementMBean>();
+ private boolean available = true;
+
+ public ManagedPortletInvokerImpl(PortletDiscoveryService discoveryService,
FederatedPortletInvoker invoker)
+ {
+ this.discoveryService = discoveryService;
+ this.invoker = invoker;
+ }
+
+ public boolean isWSRP()
+ {
+ return "local".equals(invoker.getId());
+ }
+
+ public boolean isAvailable()
+ {
+ return available;
+ }
+
+ public Map<String, LocalPortletManagementMBean> getRegisteredPortlets()
+ {
+ return registeredPortlets;
+ }
+
+ public int getPortletNumber()
+ {
+ return registeredPortlets.size();
+ }
+
+ public void refreshPortlets()
+ {
+ Set<Portlet> portlets = Collections.emptySet();
+ try
+ {
+ portlets = invoker.getPortlets();
+ available = true;
+ }
+ catch (PortletInvokerException e)
+ {
+ if (e instanceof InvokerUnavailableException)
+ {
+ log.info("Couldn't access portlets from invoker " +
invoker.getId() + ". Cause: " + e.getLocalizedMessage());
+ available = false;
+ }
+ log.debug(e);
+ }
+
+ boolean wsrp = isWSRP();
+
+ // remove portlets that have been undeployed...
+ Set<String> previous = new
HashSet<String>(registeredPortlets.keySet());
+ previous.removeAll(portlets);
+ for (String portlet : previous)
+ {
+ discoveryService.unregisterPortlet(portlet);
+ registeredPortlets.remove(portlet);
+ }
+
+ for (Portlet portlet : portlets)
+ {
+ String portletId = portlet.getContext().getId();
+
+ if (!registeredPortlets.containsKey(portletId))
+ {
+ registeredPortlets.put(portletId, discoveryService.registerPortlet(portlet,
wsrp));
+ }
+ }
+ }
+}
Modified:
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/Portal.java
===================================================================
---
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/Portal.java 2009-05-07
21:58:57 UTC (rev 13324)
+++
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/Portal.java 2009-05-08
15:23:03 UTC (rev 13325)
@@ -20,10 +20,9 @@
* 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.portal.portlet.management.LocalPortletManagementMBean;
-
import java.util.Map;
/**
@@ -35,5 +34,5 @@
public int getNbInstances();
- Map<String, LocalPortletManagementMBean> getRegisteredPortletManagements();
+ Map<String, ManagedPortletInvoker> getManagedPortletInvokers();
}
Modified:
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortalImpl.java
===================================================================
---
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortalImpl.java 2009-05-07
21:58:57 UTC (rev 13324)
+++
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortalImpl.java 2009-05-08
15:23:03 UTC (rev 13325)
@@ -25,7 +25,6 @@
import org.jboss.portal.core.impl.model.instance.InstanceContainerContext;
import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.portlet.management.LocalPortletManagementMBean;
import javax.naming.InitialContext;
import javax.transaction.UserTransaction;
@@ -61,7 +60,7 @@
return nbInstances;
}
- public Map<String, LocalPortletManagementMBean>
getRegisteredPortletManagements()
+ public Map<String, ManagedPortletInvoker> getManagedPortletInvokers()
{
try
{
@@ -72,7 +71,7 @@
log.debug(e);
log.info("Could not refresh list of portlets: " +
e.getLocalizedMessage());
}
- return discoveryService.getRegisteredPortlets();
+ return discoveryService.getManagedPortletInvokers();
}
public void setContainerContext(InstanceContainerContext containerContext)
Modified:
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortletDiscovery.java
===================================================================
---
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortletDiscovery.java 2009-05-07
21:58:57 UTC (rev 13324)
+++
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortletDiscovery.java 2009-05-08
15:23:03 UTC (rev 13325)
@@ -36,4 +36,6 @@
void processPortletDiscovery() throws Exception;
Map<String, LocalPortletManagementMBean> getRegisteredPortlets();
+
+ Map<String, ManagedPortletInvoker> getManagedPortletInvokers();
}
Modified:
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortletDiscoveryService.java
===================================================================
---
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortletDiscoveryService.java 2009-05-07
21:58:57 UTC (rev 13324)
+++
modules/jopr-plugin/trunk/portal-management/src/main/java/org/jboss/portal/management/PortletDiscoveryService.java 2009-05-08
15:23:03 UTC (rev 13325)
@@ -48,6 +48,7 @@
private Map<String, ObjectName> registeredPortletsNames = new HashMap<String,
ObjectName>();
private Map<String, LocalPortletManagementMBean> registeredPortlets = new
HashMap<String, LocalPortletManagementMBean>();
+ private Map<String, ManagedPortletInvoker> invokers = new HashMap<String,
ManagedPortletInvoker>();
public void start()
{
@@ -63,16 +64,9 @@
public void stop()
{
- for (ObjectName objectName : registeredPortletsNames.values())
+ for (String portlet : registeredPortletsNames.keySet())
{
- try
- {
- getServer().unregisterMBean(objectName);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
+ unregisterPortlet(portlet);
}
if (registeredPortletsNames.size() != 0)
{
@@ -97,17 +91,20 @@
public void processPortletDiscovery() throws Exception
{
+ //todo: should deal with removal of invokers...
Collection<FederatedPortletInvoker> federatedInvokers =
federatingPortletInvoker.getFederatedInvokers();
- for (FederatedPortletInvoker federatedPortletInvoker : federatedInvokers)
+ for (FederatedPortletInvoker invoker : federatedInvokers)
{
- if (federatedPortletInvoker.getId().equals("local"))
+ String id = invoker.getId();
+
+ ManagedPortletInvoker managed = invokers.get(id);
+ if (managed == null)
{
- registerPortlets(federatedPortletInvoker.getPortlets(), false);
+ managed = new ManagedPortletInvokerImpl(this, invoker);
+ invokers.put(id, managed);
}
- else
- {
- registerPortlets(federatedPortletInvoker.getPortlets(), true);
- }
+
+ managed.refreshPortlets();
}
}
@@ -116,40 +113,55 @@
return Collections.unmodifiableMap(registeredPortlets);
}
- private void registerPortlets(Collection<Portlet> portlets, boolean wsrp)
+ public Map<String, ManagedPortletInvoker> getManagedPortletInvokers()
{
- for (Portlet portlet : portlets)
+ return Collections.unmodifiableMap(invokers);
+ }
+
+ LocalPortletManagementMBean registerPortlet(Portlet portlet, boolean wsrp)
+ {
+ String portletId = portlet.getContext().getId();
+
+ LocalPortletManagementMBean management = new LocalPortletManagement(portlet,
interceptor);
+
+ // attempt to register MBean with server
+ try
{
- String portletId = portlet.getContext().getId();
+ ObjectName objectName = new ObjectName(getMBeanName(portletId, wsrp));
+ getServer().registerMBean(management, objectName);
- if (!registeredPortletsNames.containsKey(portletId))
- {
- try
- {
- registerPortlet(portlet, wsrp);
- }
- catch (Exception e)
- {
- log.info("Couldn't register " + (wsrp ? "WSRP " :
"") + portletId + " portlet. Cause: " + e.getLocalizedMessage());
- log.debug(e);
- }
- }
+ registeredPortletsNames.put(portletId, objectName);
+
+ log.debug("Registered Management MBean for: " + portletId);
}
+ catch (Exception e)
+ {
+ log.info("Couldn't register " + (wsrp ? "WSRP " :
"") + portletId + " portlet. Cause: " + e.getLocalizedMessage());
+ log.debug(e);
+ }
+
+ return management;
}
- private ObjectName registerPortlet(Portlet portlet, boolean wsrp) throws Exception
+ void unregisterPortlet(String portlet)
{
- LocalPortletManagementMBean management;
- management = new LocalPortletManagement(portlet, interceptor);
- String id = portlet.getContext().getId();
- ObjectName objectName = new ObjectName(getMBeanName(id, wsrp));
- getServer().registerMBean(management, objectName);
+ ObjectName objectName = registeredPortletsNames.get(portlet);
- registeredPortletsNames.put(id, objectName);
- registeredPortlets.put(id, management);
+ if (objectName == null)
+ {
+ log.debug("No known MBean associated with portlet " + portlet);
+ return;
+ }
- log.debug("Registered Management MBean for: " + id);
- return objectName;
+ try
+ {
+ getServer().unregisterMBean(objectName);
+ }
+ catch (Exception e)
+ {
+ log.info("Couldn't unregister MBean associated with portlet " +
portlet + ". Cause: " + e.getLocalizedMessage());
+ log.debug(e);
+ }
}
private String getMBeanName(String id, boolean wsrp)
@@ -163,5 +175,4 @@
return LOCAL_JMX_PREFIX + id;
}
}
-
}
Modified:
modules/jopr-plugin/trunk/portal-management-service/src/main/resources/META-INF/jboss-service.xml
===================================================================
---
modules/jopr-plugin/trunk/portal-management-service/src/main/resources/META-INF/jboss-service.xml 2009-05-07
21:58:57 UTC (rev 13324)
+++
modules/jopr-plugin/trunk/portal-management-service/src/main/resources/META-INF/jboss-service.xml 2009-05-08
15:23:03 UTC (rev 13325)
@@ -24,8 +24,8 @@
<server>
- <!-- Portlet discovery executed every 30 seconds -->
- <mbean
+ <!-- Portlet discovery executed every 30 seconds only needed if you want to use the
JMX beans directly -->
+ <!--<mbean
code="org.jboss.varia.scheduler.Scheduler"
name="portal:service=Management,type=Scheduler">
<attribute
@@ -36,7 +36,7 @@
<attribute name="SchedulePeriod">30000</attribute>
<attribute name="InitialRepetitions">-1</attribute>
<attribute name="StartAtStartup">true</attribute>
- </mbean>
+ </mbean>-->
<mbean
code="org.jboss.portal.management.PortalImpl"