com.ouncelabs.core.appserverimporter
Class BaseAppServerImporter

java.lang.Object
  extended by com.ouncelabs.core.appserverimporter.BaseAppServerImporter
All Implemented Interfaces:
AppServerImporter

public abstract class BaseAppServerImporter
extends java.lang.Object
implements AppServerImporter

The base class to extend when defining a custom application server importer.


Field Summary
protected static java.lang.String DOT_EAR
           
protected static java.lang.String DOT_JAR
           
protected static java.lang.String DOT_JSP
           
protected static java.lang.String DOT_WAR
           
protected static java.lang.String EAR_DIR
           
protected static java.lang.String ICF_DIR
           
protected  java.lang.String id
          The ID used to register this application server importer.
protected static java.lang.String JSP_MAP_FILE
           
protected static java.lang.String MANIFEST_CLASSPATH
           
protected  boolean multiProfile
          True if the application server supports multiple profiles, false if it does not.
protected  java.lang.String name
          The name for the application server importer, which is also the name of the application server it handles.
 
Constructor Summary
BaseAppServerImporter()
           
 
Method Summary
 void calculateInterdependencies(AppServer appServer)
          Calculates the interdependencies between the projects on an application server based on their manifests.
protected  void calculateInterdependencies(AppServerProfile profile)
          Calculates the project interdepencies for the specified application server profile.
 void cleanUp()
          Performs any clean up, if needed.
protected  java.util.Map<java.lang.String,java.lang.String> computeJSPMap(AppServer appServer, WebProject project, java.io.File stagingDir)
          Computes the JSP map for the specified Web project.
 BaseAppServerClasspathProvider createClasspathProvider()
          Creates an instance of the AppServerClasspathProvider implementation for the application server, defining the runtime classpath for it.
 JSPCompilerSupport createJSPCompilerSupprt()
          This implementation returns null.
 java.util.List<java.lang.String> generateICF(AppServer appServer)
          Generates ICF files describing the selected applications in an application server, so that they can be imported into the AppScan applications manager.
 void generateJSPMaps(AppServer appServer)
          Generates the JSP map files for the application server if the precompiled JSP Compiler type is used.
protected  void generateJSPMaps(AppServer appServer, WebProject project, java.io.File stagingDir)
           
 java.lang.String getId()
          Returns the ID used to register this application server importer.
 JSPCompilerType getJSPCompilerType()
          This implementation returns null, indicating that the product default JSP compiler should be used.
 java.lang.String getName()
          Returns the name for the application server importer, which is also the name of the application server it handles.
 boolean handleImportResult(org.eclipse.core.runtime.IStatus result, java.lang.Object shell)
          This implementation does nothing, and returns false to let the caller handle it.
 void initializeAppServer(AppServer appServer)
          Initializes an application server instance with the following basic data provided by the importer: name JSP compiler type JSP compiler support classpath provider
 boolean isMultiProfile()
          Indicates whether or not the application server type supports multiple profiles.
protected  boolean isValidDropInFile(java.io.File dropInFile)
          Indicates whether the specified file represents EAR file or Java EE module in the drop-ins folder.
 void precompileJSPs(AppServer appServer)
          This implementation does nothing.
protected  void processDropInsFolder(AppServerProfile profile, java.io.File dropinsFolder)
          Non-recursively imports EAR files and Java EE modules from the drop-ins folder of an application server profile.
protected  void processEARFile(AppServerProfile profile, java.io.File earFile)
          Imports an EAR file in an application server profile.
 org.eclipse.core.runtime.IStatus validatePrecompiledJSPs(AppServer appServer)
          Validates precompiled JSPs for the application server if the precompiled JSP Compiler type is used.
protected  void validatePrecompiledJSPs(AppServer appServer, Project project, java.io.File stagingDir, java.io.File dir, JSPCompileStatus status)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ouncelabs.core.appserverimporter.AppServerImporter
importAppServer, isValidLocation
 

Field Detail

MANIFEST_CLASSPATH

protected static final java.lang.String MANIFEST_CLASSPATH
See Also:
Constant Field Values

DOT_JSP

protected static final java.lang.String DOT_JSP
See Also:
Constant Field Values

JSP_MAP_FILE

protected static final java.lang.String JSP_MAP_FILE
See Also:
Constant Field Values

DOT_EAR

protected static final java.lang.String DOT_EAR
See Also:
Constant Field Values

DOT_JAR

protected static final java.lang.String DOT_JAR
See Also:
Constant Field Values

DOT_WAR

protected static final java.lang.String DOT_WAR
See Also:
Constant Field Values

EAR_DIR

protected static final java.lang.String EAR_DIR
See Also:
Constant Field Values

ICF_DIR

protected static final java.lang.String ICF_DIR
See Also:
Constant Field Values

id

protected java.lang.String id
The ID used to register this application server importer.


name

protected java.lang.String name
The name for the application server importer, which is also the name of the application server it handles.


multiProfile

protected boolean multiProfile
True if the application server supports multiple profiles, false if it does not.

Constructor Detail

BaseAppServerImporter

public BaseAppServerImporter()
Method Detail

getId

public java.lang.String getId()
Returns the ID used to register this application server importer. This is automatically read from the extension declaring the importer and set by the framework.

Specified by:
getId in interface AppServerImporter
Returns:
the application server importer ID

getName

public java.lang.String getName()
Returns the name for the application server importer, which is also the name of the application server it handles. This is automatically read from the extension declaring the importer and set by the framework.

Specified by:
getName in interface AppServerImporter
Returns:
the application server importer name

isMultiProfile

public boolean isMultiProfile()
Indicates whether or not the application server type supports multiple profiles. For example, WebSphere Application Sever does, Tomcat does not. This is automatically read from the extension declaring the importer and set by the framework.

Specified by:
isMultiProfile in interface AppServerImporter
Returns:
true if the application server supports multiple profiles, false otherwise

initializeAppServer

public void initializeAppServer(AppServer appServer)
Initializes an application server instance with the following basic data provided by the importer:

This method is invoked from the AppServer constructor, to automatically propagate this data.

Parameters:
appServer - the application server to initialize
See Also:
AppServer.setName(String), AppServer.setJSPCompilerType(JSPCompilerType), AppServer.setJSPCompilerSupport(JSPCompilerSupport), AppServer.setClasspathProvider(BaseAppServerClasspathProvider), AppServer.AppServer(String, BaseAppServerImporter)

processDropInsFolder

protected void processDropInsFolder(AppServerProfile profile,
                                    java.io.File dropinsFolder)
                             throws java.io.IOException
Non-recursively imports EAR files and Java EE modules from the drop-ins folder of an application server profile. This implementation only attempts to import files for which isValidDropInFile(File) returns true.

Parameters:
profile - the application server profile
dropinsFolder - the drop-ins folder that can contain EAR files and Java EE modules
Throws:
java.io.IOException - if an I/O operation fails
See Also:
isValidDropInFile(File)

isValidDropInFile

protected boolean isValidDropInFile(java.io.File dropInFile)
Indicates whether the specified file represents EAR file or Java EE module in the drop-ins folder.

This implementation only checks that the file is not a hidden file. Subclasses can override this to define further requirements.

Parameters:
dropInFile - a file in the drop-ins folder
Returns:
true if the file is a valid drop-in file, false if it is not

processEARFile

protected void processEARFile(AppServerProfile profile,
                              java.io.File earFile)
                       throws java.io.IOException
Imports an EAR file in an application server profile. A project is added to the profile for the EAR file, itself, and for each module it contains.

Parameters:
profile - the application server profile
earFile - the EAR file to be imported
Throws:
java.io.IOException - if an I/O operation fails

calculateInterdependencies

public void calculateInterdependencies(AppServer appServer)
                                throws java.io.IOException
Calculates the interdependencies between the projects on an application server based on their manifests.

This implementation simply invokes calculateInterdependencies(AppServerProfile) for each of the application server's profiles.

Parameters:
appServer - the application server
Throws:
java.io.IOException - if an I/O operation fails
See Also:
calculateInterdependencies(AppServerProfile)

calculateInterdependencies

protected void calculateInterdependencies(AppServerProfile profile)
                                   throws java.io.IOException
Calculates the project interdepencies for the specified application server profile.

Parameters:
profile - an application server profile
Throws:
java.io.IOException - if an I/O operation fails

generateICF

public java.util.List<java.lang.String> generateICF(AppServer appServer)
                                             throws java.io.IOException
Generates ICF files describing the selected applications in an application server, so that they can be imported into the AppScan applications manager.

Parameters:
appServer - the application server
Returns:
a list of path names for the generated ICF files, or an empty list if no ICF files are generated
Throws:
java.io.IOException - if an I/O operation fails

getJSPCompilerType

public JSPCompilerType getJSPCompilerType()
This implementation returns null, indicating that the product default JSP compiler should be used.

Specified by:
getJSPCompilerType in interface AppServerImporter
Returns:
the JSP compiler type, or null for the product default
See Also:
AppServerImporter.precompileJSPs(AppServer), AppServerImporter.createJSPCompilerSupprt(), AppServerImporter.createClasspathProvider()

createJSPCompilerSupprt

public JSPCompilerSupport createJSPCompilerSupprt()

This implementation returns null. Subclasses must override it if getJSPCompilerType() returns JSPCompilerType.PRECOMPILED.

Specified by:
createJSPCompilerSupprt in interface AppServerImporter
Returns:
an instance of JSPCompilerSupport or null
See Also:
getJSPCompilerType(), JSPCompilerType.PRECOMPILED

createClasspathProvider

public BaseAppServerClasspathProvider createClasspathProvider()
Creates an instance of the AppServerClasspathProvider implementation for the application server, defining the runtime classpath for it.

This implementation returns null. Subclasses must override it if getJSPCompilerType() returns JSPCompilerType.PRECOMPILED. They may also override it for an application server that provides an unusual classpath to its applications.

Specified by:
createClasspathProvider in interface AppServerImporter
Returns:
an instance of BaseAppServerClasspathProvider or null
See Also:
AppServerClasspathProvider, getJSPCompilerType(), JSPCompilerType.PRECOMPILED

precompileJSPs

public void precompileJSPs(AppServer appServer)
                    throws java.lang.Exception
This implementation does nothing. Subclasses must override it if getJSPCompilerType() returns JSPCompilerType.PRECOMPILED.

Specified by:
precompileJSPs in interface AppServerImporter
Parameters:
appServer - the application server
Throws:
java.lang.Exception - exceptions thrown by the implementations of this method are handled by the caller
See Also:
getJSPCompilerType(), JSPCompilerType.PRECOMPILED

generateJSPMaps

public void generateJSPMaps(AppServer appServer)
                     throws java.io.IOException
Generates the JSP map files for the application server if the precompiled JSP Compiler type is used.

JSP map files are used at scan time to locate the precompiled class files corresponding to JSP files.

Parameters:
appServer - the application server
Throws:
java.io.IOException - if an I/O operation fails
See Also:
getJSPCompilerType(), JSPCompilerType.PRECOMPILED

generateJSPMaps

protected void generateJSPMaps(AppServer appServer,
                               WebProject project,
                               java.io.File stagingDir)
                        throws java.io.IOException
Throws:
java.io.IOException

computeJSPMap

protected java.util.Map<java.lang.String,java.lang.String> computeJSPMap(AppServer appServer,
                                                                         WebProject project,
                                                                         java.io.File stagingDir)
                                                                  throws java.io.IOException
Computes the JSP map for the specified Web project.

The JSP map is a mapping of JSP files to compiled class files, where entries are defined as follows:

key JSP file path relative to the root of the staging directory
value corresponding class file path relative to the root of the staging directory

This method is only invoked for application servers that use the precompiled JSP Compiler type.

Parameters:
appServer - the application server
project - a Web project for which to compute a JSP map
stagingDir - the staging directory for the project
Returns:
the mapping of JSP fioles to compiled class files
Throws:
java.io.IOException - if an I/O operation fails
See Also:
getJSPCompilerType(), JSPCompilerType.PRECOMPILED

validatePrecompiledJSPs

public org.eclipse.core.runtime.IStatus validatePrecompiledJSPs(AppServer appServer)
                                                         throws java.io.IOException
Validates precompiled JSPs for the application server if the precompiled JSP Compiler type is used.

Parameters:
appServer - the application server
Returns:
the result of the validation
Throws:
java.io.IOException - if an I/O operation fails
See Also:
getJSPCompilerType(), JSPCompilerType.PRECOMPILED

validatePrecompiledJSPs

protected void validatePrecompiledJSPs(AppServer appServer,
                                       Project project,
                                       java.io.File stagingDir,
                                       java.io.File dir,
                                       JSPCompileStatus status)
                                throws java.io.IOException
Throws:
java.io.IOException

handleImportResult

public boolean handleImportResult(org.eclipse.core.runtime.IStatus result,
                                  java.lang.Object shell)
This implementation does nothing, and returns false to let the caller handle it. Subclasses may override this to provide special handling and return true.

Specified by:
handleImportResult in interface AppServerImporter
Parameters:
result - result of the import process
shell - the shell of the active window, or null in a non-UI environment
Returns:
true if the status has been handled, false if the caller should handle it
See Also:
Shell

cleanUp

public void cleanUp()
Performs any clean up, if needed. This implementation does nothing.