org.apache.jetspeed.util.descriptor
Class PortletApplicationWar

java.lang.Object
  extended by org.apache.jetspeed.util.descriptor.PortletApplicationWar

public class PortletApplicationWar
extends Object

This class facilitates operations a portlet applications WAR file or WAR file-like structure.

This class is utility class used mainly implementors of org.apache.jetspeed.pamanager.Deploymentand org.apache.jetspeed.pamanager.Registrationto assist in deployment and undeployment of portlet applications.

Version:
$Id: PortletApplicationWar.java,v 1.10 2004/07/06 16:56:19 weaver Exp $
Author:
Scott T. Weaver , Matt Avery

Field Summary
protected static String[] ELEMENTS_BEFORE_SERVLET
           
protected static String[] ELEMENTS_BEFORE_SERVLET_MAPPING
           
static String EXTENDED_PORTLET_XML_PATH
           
static String JETSPEED_SERVLET_MAPPING_XPATH
           
static String JETSPEED_SERVLET_XPATH
           
protected static org.apache.commons.logging.Log log
           
protected static int MAX_BUFFER_SIZE
           
protected  List openedResources
           
private  long paChecksum
           
protected  String paName
           
static String PORTLET_XML_PATH
           
private  org.apache.jetspeed.om.common.portlet.MutablePortletApplication portletApp
           
protected  org.apache.jetspeed.util.FileSystemHelper warStruct
           
static String WEB_XML_PATH
           
protected static String WEB_XML_STRING
           
private  org.apache.jetspeed.om.common.servlet.MutableWebApplication webApp
           
protected  String webAppContextRoot
           
 
Constructor Summary
PortletApplicationWar(org.apache.jetspeed.util.FileSystemHelper warStruct, String paName, String webAppContextRoot)
           
PortletApplicationWar(org.apache.jetspeed.util.FileSystemHelper warStruct, String paName, String webAppContextRoot, long paChecksum)
           
 
Method Summary
 void close()
           close
 PortletApplicationWar copyWar(String targetAppRoot)
           copyWar
 ClassLoader createClassloader(ClassLoader parent)
           createClassloader
 org.apache.jetspeed.om.common.portlet.MutablePortletApplication createPortletApp()
           
 org.apache.jetspeed.om.common.portlet.MutablePortletApplication createPortletApp(ClassLoader classLoader)
           createPortletApp
 org.apache.jetspeed.om.common.servlet.MutableWebApplication createWebApp()
           createWebApp
 String getDeployedPath()
           getDeployedPath
 org.apache.jetspeed.util.FileSystemHelper getFileSystem()
           
protected  InputStream getInputStream(String path)
           getInputStream
protected  OutputStream getOutputStream(String path)
           getOutputStream
 long getPortletApplicationChecksum()
           
 String getPortletApplicationName()
           
protected  Reader getReader(String path)
           getReader
protected  Writer getWriter(String path)
           
 void processWebXML()
           processWebXML
 void removeWar()
           removeWar
 void validate()
          Validate a PortletApplicationDefinition tree AFTER its WebApplicationDefinition has been loaded.
private  void validatePortletApplicationName(String paName)
           validatePortletApplicationName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEB_XML_STRING

protected static final String WEB_XML_STRING
See Also:
Constant Field Values

PORTLET_XML_PATH

public static final String PORTLET_XML_PATH
See Also:
Constant Field Values

WEB_XML_PATH

public static final String WEB_XML_PATH
See Also:
Constant Field Values

EXTENDED_PORTLET_XML_PATH

public static final String EXTENDED_PORTLET_XML_PATH
See Also:
Constant Field Values

MAX_BUFFER_SIZE

protected static final int MAX_BUFFER_SIZE
See Also:
Constant Field Values

JETSPEED_SERVLET_XPATH

public static final String JETSPEED_SERVLET_XPATH
See Also:
Constant Field Values

JETSPEED_SERVLET_MAPPING_XPATH

public static final String JETSPEED_SERVLET_MAPPING_XPATH
See Also:
Constant Field Values

log

protected static final org.apache.commons.logging.Log log

paName

protected String paName

webAppContextRoot

protected String webAppContextRoot

warStruct

protected org.apache.jetspeed.util.FileSystemHelper warStruct

webApp

private org.apache.jetspeed.om.common.servlet.MutableWebApplication webApp

portletApp

private org.apache.jetspeed.om.common.portlet.MutablePortletApplication portletApp

paChecksum

private long paChecksum

openedResources

protected final List openedResources

ELEMENTS_BEFORE_SERVLET

protected static final String[] ELEMENTS_BEFORE_SERVLET

ELEMENTS_BEFORE_SERVLET_MAPPING

protected static final String[] ELEMENTS_BEFORE_SERVLET_MAPPING
Constructor Detail

PortletApplicationWar

public PortletApplicationWar(org.apache.jetspeed.util.FileSystemHelper warStruct,
                             String paName,
                             String webAppContextRoot)
Parameters:
warFile - FileSystemHelperrepresenting the WAR file we are working with. This FileSystemHelper can be an actual WAR file or a directory structure layed out in a WAR-like fashion. name of the portlet application the warPath contains
webAppContextRoot - context root relative to the servlet container of this app

PortletApplicationWar

public PortletApplicationWar(org.apache.jetspeed.util.FileSystemHelper warStruct,
                             String paName,
                             String webAppContextRoot,
                             long paChecksum)
Method Detail

getPortletApplicationChecksum

public long getPortletApplicationChecksum()
                                   throws IOException
Throws:
IOException

validatePortletApplicationName

private void validatePortletApplicationName(String paName)

validatePortletApplicationName

Parameters:
paName -

createWebApp

public org.apache.jetspeed.om.common.servlet.MutableWebApplication createWebApp()
                                                                         throws PortletApplicationException,
                                                                                IOException

createWebApp

Creates a web applicaiton object based on the values in this WAR's WEB-INF/web.xml

Returns:
@throws PortletApplicationException
Throws:
IOException
PortletApplicationException
See Also:
WebApplicationDescriptor

createPortletApp

public org.apache.jetspeed.om.common.portlet.MutablePortletApplication createPortletApp(ClassLoader classLoader)
                                                                                 throws PortletApplicationException,
                                                                                        IOException

createPortletApp

Creates a portlet application object based of the WAR file's WEB-INF/portlet.xml

Returns:
@throws PortletApplicationException
Throws:
IOException
PortletApplicationException
See Also:
org.apache.jetspeed.uitl.descriptor.PortletApplicationDescriptor

createPortletApp

public org.apache.jetspeed.om.common.portlet.MutablePortletApplication createPortletApp()
                                                                                 throws PortletApplicationException,
                                                                                        IOException
Throws:
PortletApplicationException
IOException

getReader

protected Reader getReader(String path)
                    throws IOException

getReader

Returns a java.io.Reader to a resource within this WAR's structure.

Parameters:
path - realtive to an object within this WAR's file structure
Returns:
java.io.Reader to the file within the WAR
Throws:
IOException - if the path does not exist or there was a problem reading the WAR.

getInputStream

protected InputStream getInputStream(String path)
                              throws IOException

getInputStream

Returns a java.io.InputStream to a resource within this WAR's structure.

Parameters:
path - realtive to an object within this WAR's file structure
Returns:
java.io.InputStream to the file within the WAR
Throws:
IOException - if the path does not exist or there was a problem reading the WAR.

getOutputStream

protected OutputStream getOutputStream(String path)
                                throws IOException

getOutputStream

Returns a java.io.OutputStream to a resource within this WAR's structure.

Parameters:
path - realtive to an object within this WAR's file structure
Returns:
java.io.Reader to the file within the WAR
Throws:
IOException - if the path does not exist or there was a problem reading the WAR.

getWriter

protected Writer getWriter(String path)
                    throws IOException
Throws:
IOException

copyWar

public PortletApplicationWar copyWar(String targetAppRoot)
                              throws IOException

copyWar

Copies the entire WAR structure to the path defined in targetAppRoot

Parameters:
targetAppRoot - target to copy this WAR's content to. If the path ends in .war or .jar. The war will be copied into that file in jar format.
Returns:
PortletApplicationWar representing the newly created WAR.
Throws:
IOException

removeWar

public void removeWar()
               throws IOException

removeWar

Deletes this WAR. If the WAR is a file structure and not an actual WAR file, all children are delted first, then the directory is removed.

Throws:
IOException - if there is an error removing the WAR from the file system.

validate

public void validate()
              throws PortletApplicationException
Validate a PortletApplicationDefinition tree AFTER its WebApplicationDefinition has been loaded. Currently, only the security role references of the portlet definitions are validated:

Throws:
PortletApplicationException

processWebXML

public void processWebXML()
                   throws MetaDataException

processWebXML

Infuses this PortletApplicationWar's web.xml file with servlet and a servlet-mapping element for the JetspeedContainer servlet. This is only done if the descriptor does not already contain these items.

Throws:
MetaDataException - if there is a problem infusing

close

public void close()
           throws IOException

close

Closes any resource this PortletApplicationWar may have opened.

Throws:
IOException

createClassloader

public ClassLoader createClassloader(ClassLoader parent)
                              throws IOException

createClassloader

Use this method to create a classloader based on this wars structure. I.e. it will create a ClassLoader containing the contents of WEB-INF/classes and WEB-INF/lib and the ClassLoader will be searched in that order.

Parameters:
parent - Parent ClassLoader. Can be null
Returns:
@throws IOException
Throws:
IOException

getPortletApplicationName

public String getPortletApplicationName()
Returns:
Returns the paName.

getDeployedPath

public String getDeployedPath()

getDeployedPath

Returns:
A string representing the path to this WAR in the form of a URL or null is the URL could not be created.

getFileSystem

public org.apache.jetspeed.util.FileSystemHelper getFileSystem()


Copyright © 1999-2007 Apache Software Foundation. All Rights Reserved.