[portal-commits] JBoss Portal SVN: r13097 - in modules/deployer/trunk: portal and 9 other directories.
portal-commits at lists.jboss.org
portal-commits at lists.jboss.org
Fri Mar 27 17:12:45 EDT 2009
Author: mwringe
Date: 2009-03-27 17:12:45 -0400 (Fri, 27 Mar 2009)
New Revision: 13097
Added:
modules/deployer/trunk/portal/
modules/deployer/trunk/portal/pom.xml
modules/deployer/trunk/portal/src/
modules/deployer/trunk/portal/src/main/
modules/deployer/trunk/portal/src/main/java/
modules/deployer/trunk/portal/src/main/java/org/
modules/deployer/trunk/portal/src/main/java/org/jboss/
modules/deployer/trunk/portal/src/main/java/org/jboss/portal/
modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/
modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/
modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/LibDirectoryStructure.java
modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalEntityResolver.java
modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalPostWebDeployer.java
modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalResolverFactory.java
modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalUnmarshallerFactory.java
modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/RuntimeContext.java
modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/WebDeploymentListener.java
modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/webapp/
modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/webapp/WebAppContextDeployer.java
modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/webapp/WebAppDeployer.java
Log:
Add portlet module separated from main deployer module.
Added: modules/deployer/trunk/portal/pom.xml
===================================================================
--- modules/deployer/trunk/portal/pom.xml (rev 0)
+++ modules/deployer/trunk/portal/pom.xml 2009-03-27 21:12:45 UTC (rev 13097)
@@ -0,0 +1,62 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal.deployer</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>trunk-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>deployer-portal</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Portal Modules Portal Deployer</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-spi</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-vfs</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-server</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.portal.metadata</groupId>
+ <artifactId>metadata-metadata</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+
+<pluginManagement>
+<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.2</version>
+</plugin>
+</plugins>
+</pluginManagement>
+
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <encoding>iso-8859-1</encoding>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
Added: modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/LibDirectoryStructure.java
===================================================================
--- modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/LibDirectoryStructure.java (rev 0)
+++ modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/LibDirectoryStructure.java 2009-03-27 21:12:45 UTC (rev 13097)
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * 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.portal;
+
+import java.util.List;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSStructureDeployer;
+import org.jboss.deployers.vfs.spi.structure.StructureContext;
+import org.jboss.deployers.vfs.spi.structure.VFSStructuralDeployers;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * may no longer be needed with jboss as5 ga, research this further
+ *
+ */
+public class LibDirectoryStructure extends AbstractVFSStructureDeployer
+{
+
+ public LibDirectoryStructure()
+ {
+ setRelativeOrder(Integer.MAX_VALUE);
+ }
+
+ /**
+ * Add jars from with a lib subdirectory.
+ *
+ * @param context The StrucutureContext to use
+ * @return Always returns false
+ */
+ public boolean determineStructure(StructureContext context) throws DeploymentException
+ {
+ try
+ {
+ VirtualFile file = context.getFile();
+ if (context.isTopLevel() == false && isLeaf(file) == false && context.getName().equals("lib"))
+ {
+ try
+ {
+ List<VirtualFile> children = context.getFile().getChildren();
+ if (children != null && children.isEmpty() == false)
+ {
+ for (int i = 0; i < children.size(); i++)
+ {
+ VFSStructuralDeployers structuralDeployers = context.getDeployers();
+
+ structuralDeployers.determineStructure(children.get(i), context.getParentContext());
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+ }
+ catch (Exception e)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Error determining Structure", e);
+ }
+ // always return false
+ return false;
+ }
+
+}
Added: modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalEntityResolver.java
===================================================================
--- modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalEntityResolver.java (rev 0)
+++ modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalEntityResolver.java 2009-03-27 21:12:45 UTC (rev 13097)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.portal;
+
+import org.jboss.logging.Logger;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public class PortalEntityResolver implements org.xml.sax.EntityResolver
+{
+ Logger log = Logger.getLogger(PortalEntityResolver.class);
+
+ /** . */
+ private Properties dtdMapping;
+
+ public Properties getDTDMapping()
+ {
+ return dtdMapping;
+ }
+
+ public void setDTDMapping(Properties dtdMapping)
+ {
+ this.dtdMapping = dtdMapping;
+ }
+
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
+ {
+ // Let the parser open a regular URI connection to systemId
+ if (publicId == null)
+ {
+ //return null;
+ }
+
+ //
+ String dtdResourceName = (String) dtdMapping.get(publicId);
+ if (dtdResourceName != null)
+ {
+
+ log.debug("Looking up resource " + dtdResourceName + " for dtd publicId=" + publicId + ", systemId=" + systemId);
+ InputStream dtdStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(dtdResourceName);
+ if (dtdStream != null)
+ {
+ return new InputSource(dtdStream);
+ }
+ else
+ {
+ log.debug("No resource found for dtd publicId=" + publicId + ", systemId=" + systemId);
+ }
+ }
+ else
+ {
+ log.debug("No resource name found for dtd publicId=" + publicId + ", systemId=" + systemId);
+ }
+
+ //
+ return null;
+ }
+
+}
Added: modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalPostWebDeployer.java
===================================================================
--- modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalPostWebDeployer.java (rev 0)
+++ modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalPostWebDeployer.java 2009-03-27 21:12:45 UTC (rev 13097)
@@ -0,0 +1,117 @@
+/******************************************************************************
+ * 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.portal;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractComponentDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.web.WebApplication;
+import org.jboss.web.deployers.AbstractWarDeployer;
+
+/*
+ * Initial testing deployer used to get JBoss 2.7 working on JBoss AS 5
+ * This should be replaced with a full deployer.
+ *
+ * TODO: remove this file once full deployment has been done.
+ */
+public class PortalPostWebDeployer extends AbstractComponentDeployer
+{
+
+ //the relative order of the war deployer in the main deployer.
+ private int warDeployerOrder;
+
+ private AbstractWarDeployer warDeployer;
+
+ private ArrayList listeners = new ArrayList();
+
+ public PortalPostWebDeployer()
+ {
+ //addInput(PortalMetaData.class);
+ this.setStage(DeploymentStages.INSTALLED);
+ }
+
+ public void setWarDeployer(AbstractWarDeployer warDeployer)
+ {
+ this.warDeployer = warDeployer;
+ }
+
+ public void setWarDeployerOrder(int order)
+ {
+ this.warDeployerOrder = order;
+ }
+
+ public int getRelativeOrder()
+ {
+ //return the order just after the war deployer
+ //note: should really be +1 but other portal deployer is getting in the way right now
+ return warDeployerOrder + 2;
+ }
+
+ @Override
+ public void internalDeploy(DeploymentUnit unit) throws DeploymentException
+ {
+ WebApplication webapp = warDeployer.getDeployedApp(unit.getName());
+
+ if (webapp != null)
+ {
+ Iterator<WebDeploymentListener> iter = listeners.listIterator();
+ while (iter.hasNext())
+ {
+ iter.next().portalDeployed(webapp);
+ }
+ }
+ }
+
+ @Override
+ public void internalUndeploy(DeploymentUnit unit)
+ {
+ if (warDeployer != null)
+ {
+ WebApplication webapp = warDeployer.getDeployedApp(unit.getName());
+
+ if (webapp != null)
+ {
+ Iterator<WebDeploymentListener> iter = listeners.listIterator();
+ while (iter.hasNext())
+ {
+ iter.next().portalUndeployed(webapp);
+ }
+ }
+ }
+ }
+
+ public void addDeploymentListener(WebDeploymentListener deploymentListener)
+ {
+ listeners.add(deploymentListener);
+ }
+
+ public void removeDeploymentListener(WebDeploymentListener deploymentListener)
+ {
+ listeners.remove(deploymentListener);
+ }
+
+}
\ No newline at end of file
Added: modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalResolverFactory.java
===================================================================
--- modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalResolverFactory.java (rev 0)
+++ modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalResolverFactory.java 2009-03-27 21:12:45 UTC (rev 13097)
@@ -0,0 +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.portal;
+
+import java.util.Enumeration;
+import java.util.Properties;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaResolverFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * @author <a href="mailto:mwringe at redhat.com">Matt Wringe</a>
+ * @version $Revision$
+ */
+public class PortalResolverFactory implements SchemaResolverFactory
+{
+
+ private static final Logger log = Logger.getLogger(PortalResolverFactory.class);
+
+ protected static SchemaResolverFactory factory = new PortalResolverFactory();
+
+ private final DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+
+ public static SchemaResolverFactory getInstance()
+ {
+ return factory;
+ }
+
+ public SchemaBindingResolver getSchemaBindingResolver()
+ {
+ return (SchemaBindingResolver) resolver;
+ }
+
+ private PortalResolverFactory()
+ {
+ }
+
+ /**
+ * Get the DTD mappings and set the resolver to use them.
+ * @param mapping The mapping to use
+ */
+ public void setDTDMapping(Properties mapping)
+ {
+ ClassLoader classloader = Thread.currentThread().getContextClassLoader();
+ if (mapping != null && mapping.size() > 0)
+ {
+ Enumeration enumer = mapping.keys();
+ while (enumer.hasMoreElements())
+ {
+ String location = (String) enumer.nextElement();
+ String classname = (String) mapping.get(location);
+ try
+ {
+ Class clazz = classloader.loadClass(classname);
+ resolver.addClassBindingForLocation(location, clazz);
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.warn("Could not find class " + classname);
+ }
+ }
+ }
+ }
+
+ public void setXSDMapping(Properties mapping)
+ {
+ ClassLoader classloader = Thread.currentThread().getContextClassLoader();
+ if (mapping != null && mapping.size() > 0)
+ {
+ Enumeration enumer = mapping.keys();
+ while (enumer.hasMoreElements())
+ {
+ String location = (String) enumer.nextElement();
+ String classname = (String) mapping.get(location);
+ try
+ {
+ Class clazz = classloader.loadClass(classname);
+ resolver.addClassBinding(location, clazz);
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.warn("Could not find class " + classname);
+ }
+ }
+ }
+ }
+
+}
Added: modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalUnmarshallerFactory.java
===================================================================
--- modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalUnmarshallerFactory.java (rev 0)
+++ modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/PortalUnmarshallerFactory.java 2009-03-27 21:12:45 UTC (rev 13097)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * 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.portal;
+
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.xml.sax.EntityResolver;
+
+/**
+ * @author <a href="mailto:mwringe at redhat.com">Matt Wringe</a>
+ * @version $Revision$
+ */
+public class PortalUnmarshallerFactory
+{
+
+ protected static PortalUnmarshallerFactory factory = new PortalUnmarshallerFactory();
+
+ protected Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+
+ protected EntityResolver entityResolver;
+
+ protected boolean schemaValidation;
+
+ protected boolean validation;
+
+ public static PortalUnmarshallerFactory getInstance()
+ {
+ return factory;
+ }
+
+ private PortalUnmarshallerFactory()
+ {
+ //set the default validation values.
+ this.schemaValidation = false;
+ this.validation = false;
+ }
+
+ public Unmarshaller getUnmarshaller()
+ {
+ // add the entityresolver if it exists
+ if (entityResolver != null)
+ {
+ try
+ {
+ unmarshaller.setEntityResolver(entityResolver);
+ }
+ catch (JBossXBException exception)
+ {
+ exception.printStackTrace();
+ }
+ }
+
+ // try and set the validations for the unmarshaller
+ try
+ {
+ unmarshaller.setSchemaValidation(schemaValidation);
+ unmarshaller.setValidation(validation);
+ }
+ catch (JBossXBException exception)
+ {
+ exception.printStackTrace();
+ }
+ return unmarshaller;
+ }
+
+ public void setEntityResolver(EntityResolver entityResolver)
+ {
+ this.entityResolver = entityResolver;
+ }
+
+ public void setSchemaValidation(boolean validate)
+ {
+ this.schemaValidation = validate;
+ }
+
+ public void setValidation(boolean validate)
+ {
+ this.validation = validate;
+ }
+
+}
Added: modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/RuntimeContext.java
===================================================================
--- modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/RuntimeContext.java (rev 0)
+++ modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/RuntimeContext.java 2009-03-27 21:12:45 UTC (rev 13097)
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * 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.deployer.portal;
+
+import javax.servlet.ServletContext;
+
+/**
+ * @author <a href="mailto:mwringe at redhat.com">Matt Wringe</a>
+ * @version $Revision$
+ */
+public class RuntimeContext
+{
+ private final String appId;
+ private final ServletContext servletContext;
+ private final String contextPath;
+ private final ClassLoader classLoader;
+
+ public RuntimeContext(String appId, ServletContext context, String contextPath, ClassLoader loader)
+ {
+ if (appId == null)
+ {
+ throw new IllegalArgumentException("appId is null");
+ }
+ if (context == null)
+ {
+ throw new IllegalArgumentException("servletContext is null");
+ }
+ if (contextPath == null)
+ {
+ throw new IllegalArgumentException("contextPath is null");
+ }
+ if (loader == null)
+ {
+ throw new IllegalArgumentException("class loader is null");
+ }
+
+ this.appId = appId;
+ this.servletContext = context;
+ this.classLoader = loader;
+ this.contextPath = contextPath;
+ }
+
+ public String getAppId()
+ {
+ return appId;
+ }
+
+ public ServletContext getServletContext()
+ {
+ return servletContext;
+ }
+
+ public String getContextPath()
+ {
+ return contextPath;
+ }
+
+ public ClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+}
+
Added: modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/WebDeploymentListener.java
===================================================================
--- modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/WebDeploymentListener.java (rev 0)
+++ modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/WebDeploymentListener.java 2009-03-27 21:12:45 UTC (rev 13097)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * 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.portal;
+
+import org.jboss.web.WebApplication;
+
+/*
+ * This is only to get portal 2.7 working with JBoss AS 5 initially, should be replaced with a
+ * full deployment implementation.
+ *
+ * TODO: remove this file once full deployment has been done.
+ */
+public interface WebDeploymentListener
+{
+ public void portalDeployed(WebApplication webapp);
+
+ public void portalUndeployed(WebApplication webapp);
+}
Added: modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/webapp/WebAppContextDeployer.java
===================================================================
--- modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/webapp/WebAppContextDeployer.java (rev 0)
+++ modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/webapp/WebAppContextDeployer.java 2009-03-27 21:12:45 UTC (rev 13097)
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * 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.portal.webapp;
+
+import java.lang.reflect.Method;
+
+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.web.WebApplication;
+
+/**
+ * @author <a href="mailto:mwringe at redhat.com">Matt Wringe</a>
+ * @version $Revision$
+ */
+public class WebAppContextDeployer extends AbstractDeployer
+{
+ protected MBeanServer server;
+ public static String PORTLET_APP_CONTEXT_PATH_ATTACHMENT = "portletAppContextPath." + String.class.getName();
+ public static String PORTLET_APP_SERVLET_CONTEXT_ATTACHMENT = "portletAppServletContext." + ServletContext.class.getName();
+
+ public WebAppContextDeployer()
+ {
+ setAllInputs(false);
+ setInput(WebApplication.class);
+ setStage(DeploymentStages.INSTALLED);
+ addOutput(PORTLET_APP_SERVLET_CONTEXT_ATTACHMENT);
+ addOutput(PORTLET_APP_CONTEXT_PATH_ATTACHMENT);
+ }
+
+ public void setMBeanServer(MBeanServer server)
+ {
+ this.server = server;
+ }
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ WebApplication webApp = unit.getAttachment(WebApplication.class);
+
+ ObjectName objectName = (ObjectName)webApp.getAppData();
+
+ try
+ {
+ Object standardContextObject = server.getAttribute(objectName, "managedResource");
+ String contextPath = getContextPath(standardContextObject);
+ ServletContext servletContext = getServletContext(standardContextObject);
+
+ unit.addAttachment(PORTLET_APP_CONTEXT_PATH_ATTACHMENT, contextPath, String.class);
+ unit.addAttachment(PORTLET_APP_SERVLET_CONTEXT_ATTACHMENT, servletContext, ServletContext.class);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException ("Could not get the Standard Context for " + unit.getName());
+ }
+ }
+
+ //TODO: determine a better way to get the contextpath string
+ protected String getContextPath(Object standardContextObject) throws DeploymentException
+ {
+ try
+ {
+ Class standardContextClass = standardContextObject.getClass();
+ Method getPathMethod = standardContextClass.getMethod("getPath", new Class[0]);
+
+ return (String) getPathMethod.invoke(standardContextObject, new Object[0]);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Error trying to get the ContextPath from the web server.", e);
+ }
+ }
+
+ // TODO: determine a better way to get the servlet context
+ protected ServletContext getServletContext(Object standardContextObject) throws DeploymentException
+ {
+ try
+ {
+ Class standardContextClass = standardContextObject.getClass();
+ Method getServletContextMethod = standardContextClass.getMethod("getServletContext", new Class[0]);
+
+ return (ServletContext) getServletContextMethod.invoke(standardContextObject, new Object[0]);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Error trying to get Reference to the ServletContext from the web server.", e);
+ }
+ }
+
+}
+
Added: modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/webapp/WebAppDeployer.java
===================================================================
--- modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/webapp/WebAppDeployer.java (rev 0)
+++ modules/deployer/trunk/portal/src/main/java/org/jboss/portal/deployer/portal/webapp/WebAppDeployer.java 2009-03-27 21:12:45 UTC (rev 13097)
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * 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.portal.webapp;
+
+import javax.management.MBeanServer;
+
+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.portal.metadata.portlet.PortletApplication10MetaData;
+import org.jboss.web.WebApplication;
+import org.jboss.web.deployers.AbstractWarDeployer;
+
+/**
+ * This class is used to get a WebApplication object for the deployed
+ * webapp.
+ * NOTE: that this class does not perform like a normal deployer, it is not
+ * metadata driven as the information required is not determined by the webapp's
+ * metadata but how it is deployed into the server.
+ * TODO: More research should be done to determine if this information can be more
+ * sanely extracted from the server.
+ *
+ * @author <a href="mailto:mwringe at redhat.com">Matt Wringe</a>
+ * @version $Revision$
+ */
+public class WebAppDeployer extends AbstractDeployer
+{
+
+ protected AbstractWarDeployer warDeployer;
+
+ public WebAppDeployer()
+ {
+ setAllInputs(false);
+ setInput(PortletApplication10MetaData.class);
+ setOutput(WebApplication.class);
+ setStage(DeploymentStages.INSTALLED);
+ }
+
+ @Override
+ public int getRelativeOrder()
+ {
+ // must be set relative to the warDeployer as the data we
+ // need is only set after the webapp has been deployed.
+ return warDeployer.getRelativeOrder() + 1;
+ }
+
+ public void setWarDeployer(AbstractWarDeployer warDeployer)
+ {
+ this.warDeployer = warDeployer;
+ }
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ // the unit name of the deployed application is the string
+ // used to store the apps in the warDeployer
+ String name = unit.getName();
+ WebApplication webApp = warDeployer.getDeployedApp(name);
+ if (webApp == null)
+ {
+ throw new DeploymentException ("Could not find a deployed webapp with name " + name);
+ }
+ unit.addAttachment(WebApplication.class, webApp);
+ }
+
+}
+
More information about the portal-commits
mailing list