Author: bdaw
Date: 2007-03-26 12:32:11 -0400 (Mon, 26 Mar 2007)
New Revision: 6832
Modified:
trunk/core/src/main/org/jboss/portlet/content/ContentTypeRegistration.java
Log:
- corrected ContentTypeRegistration listener (was breaking portal-samples.sar deployment)
Modified: trunk/core/src/main/org/jboss/portlet/content/ContentTypeRegistration.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/content/ContentTypeRegistration.java 2007-03-26
16:25:49 UTC (rev 6831)
+++ trunk/core/src/main/org/jboss/portlet/content/ContentTypeRegistration.java 2007-03-26
16:32:11 UTC (rev 6832)
@@ -23,14 +23,25 @@
package org.jboss.portlet.content;
import org.jboss.portal.core.impl.model.content.generic.GenericContentProviderRegistry;
+import org.jboss.portal.core.impl.model.content.generic.InternalGenericContentProvider;
+import org.jboss.portal.core.impl.model.content.InternalContentProviderRegistry;
+import org.jboss.portal.core.impl.model.instance.PersistentInstanceContainer;
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
+import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
+import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.Mode;
+import org.jboss.portal.jems.as.system.JBossServiceModelMBean;
+import org.jboss.mx.util.MBeanProxy;
+import org.jboss.mx.util.MBeanServerLocator;
import org.apache.log4j.Logger;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContext;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.Attribute;
/**
* Provide registration of a content type with a portlet instance. This listener can be
used
@@ -69,17 +80,52 @@
return;
}
+ ContentPortlet contentPortlet = new ContentPortlet()
+ {
+ public String getPortletName(Mode mode)
+ {
+ return portletInstanceName;
+ }
+ };
+
//
log.debug("About to register content type "+ contentType + " with
portlet instance " + portletInstanceName);
GenericContentProviderRegistry providerRegistry =
GenericContentProviderRegistry.getInstance();
- providerRegistry.register(contentType, new ContentPortlet()
+
+ if (providerRegistry != null)
{
- public String getPortletName(Mode mode)
+
+ providerRegistry.register(contentType, contentPortlet);
+ log.debug("Registered content type "+ contentType + " with
portlet instance " + portletInstanceName);
+ }
+ else
+ {
+ InternalGenericContentProvider provider = new InternalGenericContentProvider();
+ provider.setContentType(contentType.toString());
+
+ provider.setDecorateContent(true);
+ provider.setContentPortletInfo(contentPortlet);
+
+ try
{
- return portletInstanceName;
+ String name = "portal:service=InternalGenericContentProvider,type="
+ portletInstanceName;
+ MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
+ JBossServiceModelMBean mbean = new JBossServiceModelMBean(provider);
+ Object registry = MBeanProxy.get(InternalContentProviderRegistry.class, new
ObjectName("portal:service=ContentProviderRegistry"), mbeanServer);
+ Object container = MBeanProxy.get(InstanceContainer.class, new
ObjectName("portal:container=Instance"), mbeanServer);
+ mbeanServer.registerMBean(mbean, new ObjectName(name));
+ log.debug("Registered InternalGenericContentProvider with name:" +
name);
+ mbean.setAttribute(new Attribute("Registry", registry));
+ mbean.setAttribute(new Attribute("InstanceContainer", container));
+
}
- });
- log.debug("Registered content type "+ contentType + " with portlet
instance " + portletInstanceName);
+ catch(Exception e)
+ {
+ log.warn("Couldn't perform ContentProvider registration", e);
+ return;
+ }
+ log.debug("Registered content type "+ contentType + " with
portlet instance " + portletInstanceName);
+ }
}
public void contextDestroyed(ServletContextEvent event)