org.apache.jetspeed.util.descriptor
Class PortletApplicationWar

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

public class PortletApplicationWar
extends java.lang.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 java.lang.String[] ELEMENTS_BEFORE_SERVLET
           
protected static java.lang.String[] ELEMENTS_BEFORE_SERVLET_MAPPING
           
static java.lang.String EXTENDED_PORTLET_XML_PATH
           
static java.lang.String JETSPEED_SERVLET_MAPPING_XPATH
           
static java.lang.String JETSPEED_SERVLET_XPATH
           
protected static org.apache.commons.logging.Log log
           
protected static int MAX_BUFFER_SIZE
           
protected  java.util.List openedResources
           
protected  java.lang.String paName
           
static java.lang.String PORTLET_XML_PATH
           
protected  FileSystemHelper warStruct
           
static java.lang.String WEB_XML_PATH
           
protected static java.lang.String WEB_XML_STRING
           
protected  java.lang.String webAppContextRoot
           
 
Constructor Summary
PortletApplicationWar(FileSystemHelper warStruct, java.lang.String paName, java.lang.String webAppContextRoot)
           
PortletApplicationWar(FileSystemHelper warStruct, java.lang.String paName, java.lang.String webAppContextRoot, long paChecksum)
           
 
Method Summary
 void close()
           close
 PortletApplicationWar copyWar(java.lang.String targetAppRoot)
           copyWar
 java.lang.ClassLoader createClassloader(java.lang.ClassLoader parent)
           createClassloader
 MutablePortletApplication createPortletApp()
           
 MutablePortletApplication createPortletApp(java.lang.ClassLoader classLoader)
           createPortletApp
 MutableWebApplication createWebApp()
           createWebApp
 java.lang.String getDeployedPath()
           getDeployedPath
 FileSystemHelper getFileSystem()
           
protected  java.io.InputStream getInputStream(java.lang.String path)
           getInputStream
protected  java.io.OutputStream getOutputStream(java.lang.String path)
           getOutputStream
 long getPortletApplicationChecksum()
           
 java.lang.String getPortletApplicationName()
           
protected  java.io.Reader getReader(java.lang.String path)
           getReader
protected  java.io.Writer getWriter(java.lang.String path)
           
 void processWebXML()
           processWebXML
 void removeWar()
           removeWar
 void validate()
          Validate a PortletApplicationDefinition tree AFTER its WebApplicationDefinition has been loaded.
 
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 java.lang.String WEB_XML_STRING
See Also:
Constant Field Values

PORTLET_XML_PATH

public static final java.lang.String PORTLET_XML_PATH
See Also:
Constant Field Values

WEB_XML_PATH

public static final java.lang.String WEB_XML_PATH
See Also:
Constant Field Values

EXTENDED_PORTLET_XML_PATH

public static final java.lang.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 java.lang.String JETSPEED_SERVLET_XPATH
See Also:
Constant Field Values

JETSPEED_SERVLET_MAPPING_XPATH

public static final java.lang.String JETSPEED_SERVLET_MAPPING_XPATH
See Also:
Constant Field Values

log

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

paName

protected java.lang.String paName

webAppContextRoot

protected java.lang.String webAppContextRoot

warStruct

protected FileSystemHelper warStruct

openedResources

protected final java.util.List openedResources

ELEMENTS_BEFORE_SERVLET

protected static final java.lang.String[] ELEMENTS_BEFORE_SERVLET

ELEMENTS_BEFORE_SERVLET_MAPPING

protected static final java.lang.String[] ELEMENTS_BEFORE_SERVLET_MAPPING
Constructor Detail

PortletApplicationWar

public PortletApplicationWar(FileSystemHelper warStruct,
                             java.lang.String paName,
                             java.lang.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(FileSystemHelper warStruct,
                             java.lang.String paName,
                             java.lang.String webAppContextRoot,
                             long paChecksum)
Method Detail

getPortletApplicationChecksum

public long getPortletApplicationChecksum()
                                   throws java.io.IOException
Throws:
java.io.IOException

createWebApp

public MutableWebApplication createWebApp()
                                   throws PortletApplicationException,
                                          java.io.IOException

createWebApp

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

Returns:
@throws PortletApplicationException
Throws:
java.io.IOException
PortletApplicationException
See Also:
WebApplicationDescriptor

createPortletApp

public MutablePortletApplication createPortletApp(java.lang.ClassLoader classLoader)
                                           throws PortletApplicationException,
                                                  java.io.IOException

createPortletApp

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

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

createPortletApp

public MutablePortletApplication createPortletApp()
                                           throws PortletApplicationException,
                                                  java.io.IOException
Throws:
PortletApplicationException
java.io.IOException

getReader

protected java.io.Reader getReader(java.lang.String path)
                            throws java.io.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:
java.io.IOException - if the path does not exist or there was a problem reading the WAR.

getInputStream

protected java.io.InputStream getInputStream(java.lang.String path)
                                      throws java.io.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:
java.io.IOException - if the path does not exist or there was a problem reading the WAR.

getOutputStream

protected java.io.OutputStream getOutputStream(java.lang.String path)
                                        throws java.io.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:
java.io.IOException - if the path does not exist or there was a problem reading the WAR.

getWriter

protected java.io.Writer getWriter(java.lang.String path)
                            throws java.io.IOException
Throws:
java.io.IOException

copyWar

public PortletApplicationWar copyWar(java.lang.String targetAppRoot)
                              throws java.io.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:
java.io.IOException

removeWar

public void removeWar()
               throws java.io.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:
java.io.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 java.io.IOException

close

Closes any resource this PortletApplicationWar may have opened.

Throws:
java.io.IOException

createClassloader

public java.lang.ClassLoader createClassloader(java.lang.ClassLoader parent)
                                        throws java.io.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:
java.io.IOException

getPortletApplicationName

public java.lang.String getPortletApplicationName()
Returns:
Returns the paName.

getDeployedPath

public java.lang.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 FileSystemHelper getFileSystem()


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