[portal-commits] JBoss Portal SVN: r12959 - in modules/deployer/trunk/deployer/src/main: deployer/dtd and 1 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Fri Mar 6 11:32:40 EST 2009


Author: mwringe
Date: 2009-03-06 11:32:40 -0500 (Fri, 06 Mar 2009)
New Revision: 12959

Modified:
   modules/deployer/trunk/deployer/src/main/deployer/META-INF/deployer-jboss-beans.xml
   modules/deployer/trunk/deployer/src/main/deployer/dtd/portal-object_2_6.dtd
   modules/deployer/trunk/deployer/src/main/java/org/jboss/portal/deployer/portlet/CommandServletDeployer.java
   modules/deployer/trunk/deployer/src/main/java/org/jboss/portal/deployer/portlet/PortletDeployer.java
   modules/deployer/trunk/deployer/src/main/java/org/jboss/portal/deployer/portlet/ServiceInjectorDeployer.java
Log:
Add initial service deployer implementation.
Fix issue with null appId not being defaulted to the context path.

Modified: modules/deployer/trunk/deployer/src/main/deployer/META-INF/deployer-jboss-beans.xml
===================================================================
--- modules/deployer/trunk/deployer/src/main/deployer/META-INF/deployer-jboss-beans.xml	2009-03-06 16:30:08 UTC (rev 12958)
+++ modules/deployer/trunk/deployer/src/main/deployer/META-INF/deployer-jboss-beans.xml	2009-03-06 16:32:40 UTC (rev 12959)
@@ -135,6 +135,9 @@
      <property name="MBeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
      <property name="TLDDirectory">tld</property>
    </bean>
+   <bean name="PortletServiceInjectionDeployer" class="org.jboss.portal.deployer.portlet.ServiceInjectorDeployer">
+     <property name="MBeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
+   </bean>
    <!-- end war deployer beans -->
 
    <bean name="CommandServletDeployer" class="org.jboss.portal.deployer.portlet.CommandServletDeployer">

Modified: modules/deployer/trunk/deployer/src/main/deployer/dtd/portal-object_2_6.dtd
===================================================================
--- modules/deployer/trunk/deployer/src/main/deployer/dtd/portal-object_2_6.dtd	2009-03-06 16:30:08 UTC (rev 12958)
+++ modules/deployer/trunk/deployer/src/main/deployer/dtd/portal-object_2_6.dtd	2009-03-06 16:32:40 UTC (rev 12959)
@@ -380,8 +380,6 @@
 This element defines window for coordination. It can be either source or destination window for event distribution or
 participate in parameter binding
 -->
-<!ELEMENT window-coordination (window-name, qname)>
-
 <!ELEMENT window-coordination (window-name, qname+)>
 
 <!--

Modified: modules/deployer/trunk/deployer/src/main/java/org/jboss/portal/deployer/portlet/CommandServletDeployer.java
===================================================================
--- modules/deployer/trunk/deployer/src/main/java/org/jboss/portal/deployer/portlet/CommandServletDeployer.java	2009-03-06 16:30:08 UTC (rev 12958)
+++ modules/deployer/trunk/deployer/src/main/java/org/jboss/portal/deployer/portlet/CommandServletDeployer.java	2009-03-06 16:32:40 UTC (rev 12959)
@@ -43,7 +43,7 @@
  * @author <a href="mailto:mwringe at redhat.com">Matt Wringe</a>
  * @version $Revision$
  */
-public class CommandServletDeployer extends AbstractSimpleVFSRealDeployer<AnnotationPortletApplication10MetaData>
+public class CommandServletDeployer extends AbstractSimpleVFSRealDeployer<PortletApplication10MetaData>
 {
 
    //the name of the CommandServlet class to use. Set initially to default value
@@ -51,7 +51,7 @@
    
    public CommandServletDeployer()
    {
-      super(AnnotationPortletApplication10MetaData.class);
+      super(PortletApplication10MetaData.class);
       setStage(DeploymentStages.POST_PARSE);
    }
 
@@ -61,7 +61,7 @@
    }
    
    @Override
-   public void deploy(VFSDeploymentUnit unit, AnnotationPortletApplication10MetaData deployment) throws DeploymentException
+   public void deploy(VFSDeploymentUnit unit, PortletApplication10MetaData deployment) throws DeploymentException
    {
       JBossWebMetaData jbossWebMetaData = (JBossWebMetaData) unit.getAttachment(JBossWebMetaData.class);
 

Modified: modules/deployer/trunk/deployer/src/main/java/org/jboss/portal/deployer/portlet/PortletDeployer.java
===================================================================
--- modules/deployer/trunk/deployer/src/main/java/org/jboss/portal/deployer/portlet/PortletDeployer.java	2009-03-06 16:30:08 UTC (rev 12958)
+++ modules/deployer/trunk/deployer/src/main/java/org/jboss/portal/deployer/portlet/PortletDeployer.java	2009-03-06 16:32:40 UTC (rev 12959)
@@ -78,6 +78,11 @@
       ServletContext servletContext = unit.getAttachment(WebAppContextDeployer.PORTLET_APP_SERVLET_CONTEXT_ATTACHMENT, ServletContext.class);
       WebApplication webapp = unit.getAttachment(WebApplication.class);
         
+      if (jbossPortletMetaData.getAppId() == null)
+      {
+         jbossPortletMetaData.setAppId(contextPath);
+      }
+         
       this.deployment.deployPortlets(servletContext, webapp.getURL(), webapp.getClassLoader(), contextPath, jbossPortletMetaData, portletMetaData);
 
       unit.addAttachment(PORLET_DEPLOYED, "deployed");

Modified: modules/deployer/trunk/deployer/src/main/java/org/jboss/portal/deployer/portlet/ServiceInjectorDeployer.java
===================================================================
--- modules/deployer/trunk/deployer/src/main/java/org/jboss/portal/deployer/portlet/ServiceInjectorDeployer.java	2009-03-06 16:30:08 UTC (rev 12958)
+++ modules/deployer/trunk/deployer/src/main/java/org/jboss/portal/deployer/portlet/ServiceInjectorDeployer.java	2009-03-06 16:32:40 UTC (rev 12959)
@@ -1,64 +1,112 @@
-///******************************************************************************
-// * JBoss, a division of Red Hat                                               *
-// * Copyright 2008, 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.deployer.portlet;
-//
-//import java.util.Iterator;
-//
-//import org.jboss.deployers.spi.DeploymentException;
-//import org.jboss.deployers.spi.deployer.DeploymentStages;
-//import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
-//import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-//import org.jboss.portal.core.metadata.ServiceMetaData;
-//import org.jboss.portal.core.metadata.portlet.JBossApplicationMetaData;
-//
-///**
-// * This class injects portlet specific services into the war
-// * 
-// * @author <a href="mailto:mwringe at redhat.com">Matt Wringe</a>
-// * @version $Revision$
-// */
-//public class ServiceInjectorDeployer extends AbstractSimpleVFSRealDeployer<JBossApplicationMetaData>
-//{
-//
-//   public ServiceInjectorDeployer()
-//   {
-//      super(JBossApplicationMetaData.class);
-//      setStage(DeploymentStages.POST_PARSE);
-//   }
-//
-//   @Override
-//   public void deploy(VFSDeploymentUnit unit, JBossApplicationMetaData deployment) throws DeploymentException
-//   {
-//      Iterator<ServiceMetaData> iterator = deployment.getServices().values().iterator();
-//      while (iterator.hasNext())
-//      {
-//         ServiceMetaData serviceMD = iterator.next();
-//         //TODO: finish this deployer. This deployer needs to inject the services into the portlet servlets
-//         // need to figure out if this can be done with an xml file or if this is going to need to have 
-//         // access to the server like the tld deployer.
-//      }
-//   }
-//   
-//
-//}
-//
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2008, 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.deployer.portlet;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.servlet.ServletContext;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.portal.deployer.parsing.MergedPortletParsingDeployer;
+import org.jboss.portal.deployer.webapp.WebAppContextDeployer;
+import org.jboss.portal.metadata.jboss.portlet.JBossPortletAppMetaData;
+import org.jboss.portal.metadata.jboss.portlet.ServiceMetaData;
+
+/**
+ * This class injects portlet specific services into the war
+ * 
+ * @author <a href="mailto:mwringe at redhat.com">Matt Wringe</a>
+ * @version $Revision$
+ */
+public class ServiceInjectorDeployer extends AbstractDeployer
+{
+
+   protected MBeanServer mbeanServer;
+   protected String serverDomain = "portal";
+   
+   public void setMBeanServer(MBeanServer mbeanServer)
+   {
+      this.mbeanServer = mbeanServer;
+   }
+   
+   public void setServerDomain(String serverDomain)
+   {
+      this.serverDomain = serverDomain;
+   }
+   
+   public ServiceInjectorDeployer()
+   {
+      this.setAllInputs(false);
+      this.setInput(JBossPortletAppMetaData.class);
+      this.addInput(WebAppContextDeployer.PORTLET_APP_SERVLET_CONTEXT_ATTACHMENT);
+      this.setStage(DeploymentStages.INSTALLED);
+   }
+
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+      JBossPortletAppMetaData jbossPortletMD = unit.getAttachment(MergedPortletParsingDeployer.PORTLET_MERGED_ATTACHMENT_NAME, JBossPortletAppMetaData.class);
+      ServletContext servletContext = unit.getAttachment(WebAppContextDeployer.PORTLET_APP_SERVLET_CONTEXT_ATTACHMENT, ServletContext.class);
+      
+      if (jbossPortletMD.getServices() != null)
+      {
+         for (ServiceMetaData serviceMetaData : jbossPortletMD.getServices())
+         {
+            injectService(serviceMetaData, servletContext, unit.getClassLoader());
+         }
+      }
+      
+   }
+
+   public void injectService (ServiceMetaData serviceMetaData ,ServletContext servletContext, ClassLoader classloader)
+   {
+      try
+      {
+         String serviceClass = serviceMetaData.getServiceClass();
+         String serviceRef = serviceMetaData.getServiceRef();
+         String serviceName = serviceMetaData.getServiceName();
+         
+         if (serviceRef.startsWith(":"))
+         {
+            log.debug("Detecting a relative service reference " + serviceRef + " prepending it with " + serverDomain);
+            serviceRef = serverDomain + serviceRef;
+         }
+         
+         Class proxyClass = classloader.loadClass(serviceClass);
+         ObjectName objectName = ObjectName.getInstance(serviceRef);
+         Object proxy = MBeanProxyExt.create(proxyClass, objectName, this.mbeanServer, true);
+         
+         servletContext.setAttribute(serviceName, proxy);
+      }
+      catch (Exception e)
+      {
+         log.error("Was not able to create service proxy", e);
+      }
+   }
+
+   
+}
+




More information about the portal-commits mailing list