[jboss-cvs] JBossAS SVN: r95134 - in projects/ejb3/trunk: package-manager and 41 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 19 14:51:57 EDT 2009
Author: jaikiran
Date: 2009-10-19 14:51:56 -0400 (Mon, 19 Oct 2009)
New Revision: 95134
Added:
projects/ejb3/trunk/package-manager/
projects/ejb3/trunk/package-manager/docs/
projects/ejb3/trunk/package-manager/docs/guide/
projects/ejb3/trunk/package-manager/docs/guide/en/
projects/ejb3/trunk/package-manager/docs/guide/en/Authors.xml
projects/ejb3/trunk/package-manager/docs/guide/en/master.xml
projects/ejb3/trunk/package-manager/docs/guide/en/modules/
projects/ejb3/trunk/package-manager/docs/guide/en/modules/components.xml
projects/ejb3/trunk/package-manager/docs/guide/en/modules/overview.xml
projects/ejb3/trunk/package-manager/docs/guide/en/modules/status.xml
projects/ejb3/trunk/package-manager/docs/guide/pom.xml
projects/ejb3/trunk/package-manager/pom.xml
projects/ejb3/trunk/package-manager/src/
projects/ejb3/trunk/package-manager/src/main/
projects/ejb3/trunk/package-manager/src/main/java/
projects/ejb3/trunk/package-manager/src/main/java/org/
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/PackageManager.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/PackageManagerEnvironment.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/PackageSource.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/exception/
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/exception/InstallerException.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/exception/PackageRetrievalException.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/exception/ScriptProcessingException.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/impl/
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/impl/DefaultPackageManagerImpl.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/AbstractInstaller.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/DefaultInstaller.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/Installer.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/MergingInstaller.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/Dependencies.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/FileType.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/InstallFile.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/Package.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/PackageInstallationPhase.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/PostInstall.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/PreInstall.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/Script.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/SystemRequirements.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/DependenciesImpl.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/InstallFileImpl.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PackageImpl.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PostInstallImpl.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PostInstallScript.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PreInstallImpl.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PreInstallScript.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/ScriptImpl.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/SystemRequirementsImpl.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/PackageRetriever.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/impl/
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/impl/FileSystemPackageRetriever.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/impl/HttpPackageRetriever.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/impl/PackageRetrievalFactory.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/script/
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/script/ScriptProcessor.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/script/impl/
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/script/impl/AntScriptProcessor.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/util/
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/util/IOUtil.java
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/xml/
projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/xml/PackageUnmarshaller.java
projects/ejb3/trunk/package-manager/src/main/resources/
projects/ejb3/trunk/package-manager/src/main/resources/log4j.xml
projects/ejb3/trunk/package-manager/src/main/resources/package.xsd
projects/ejb3/trunk/package-manager/src/test/
projects/ejb3/trunk/package-manager/src/test/java/
projects/ejb3/trunk/package-manager/src/test/java/org/
projects/ejb3/trunk/package-manager/src/test/java/org/jboss/
projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/
projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/
projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/
projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/common/
projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/common/Dummy.java
projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/common/PackageManagerTestCase.java
projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/install/
projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/install/unit/
projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/install/unit/BasicInstallTestCase.java
projects/ejb3/trunk/package-manager/src/test/resources/
projects/ejb3/trunk/package-manager/src/test/resources/log4j.xml
projects/ejb3/trunk/package-manager/src/test/resources/org/
projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/
projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/
projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/
projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/test/
projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/test/install/
projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/test/install/unit/
projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/test/install/unit/build.xml
projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/test/install/unit/package-with-just-install-file.xml
projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/test/install/unit/package-with-pre-install-script.xml
Log:
Initial commit of package manager
Added: projects/ejb3/trunk/package-manager/docs/guide/en/Authors.xml
===================================================================
--- projects/ejb3/trunk/package-manager/docs/guide/en/Authors.xml (rev 0)
+++ projects/ejb3/trunk/package-manager/docs/guide/en/Authors.xml 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,6 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE authorgroup PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<authorgroup>
+ <corpauthor>Jaikiran Pai</corpauthor>
+</authorgroup>
Added: projects/ejb3/trunk/package-manager/docs/guide/en/master.xml
===================================================================
--- projects/ejb3/trunk/package-manager/docs/guide/en/master.xml (rev 0)
+++ projects/ejb3/trunk/package-manager/docs/guide/en/master.xml 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,25 @@
+<?xml version='1.0' encoding='ISO-8859-1'?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"
+[
+<!ENTITY overview SYSTEM "modules/overview.xml">
+<!ENTITY components SYSTEM "modules/components.xml">
+<!ENTITY status SYSTEM "modules/status.xml">
+]>
+<book lang="en">
+ <bookinfo>
+ <title>JBoss Package Manager</title>
+ <subtitle>A guide for using the JBoss Package Manager</subtitle>
+ <releaseinfo>1.0</releaseinfo>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Authors.xml"/>
+ </bookinfo>
+ <toc/>
+ <preface id="target" revision="1">
+ <title>Target Audience</title>
+ <para>This guide is meant for users who want to install/update/remove packages from a JBoss Application Server installation</para>
+ </preface>
+
+ &overview;
+ &components;
+ &status;
+</book>
\ No newline at end of file
Added: projects/ejb3/trunk/package-manager/docs/guide/en/modules/components.xml
===================================================================
--- projects/ejb3/trunk/package-manager/docs/guide/en/modules/components.xml (rev 0)
+++ projects/ejb3/trunk/package-manager/docs/guide/en/modules/components.xml 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,513 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2005, JBoss Inc., 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.
+ -->
+<chapter id="packagemanager_components">
+ <title>JBoss Package Manager Components</title>
+ <para>
+ So let's see what the JBoss Package Manager comprises of.
+ </para>
+ <sect1>
+ <title>Package</title>
+ <para>
+ A "package" is nothing more than a .jar file (or a .zip file) which in-turn contains the set of files that
+ are required for a particular service to be made available within the JBoss Application Server. A package
+ is expected to contain a file named package.xml at the root of the package. The package.xml contains all the
+ necessary information about the package which it represents. A package can contain libraries (.jar files)
+ or configuration files (.xml files) or script files (.bat, .sh) or anything else. Expect for the presence of
+ the "package.xml" file, a package is not restricted to contain any other files that might be required in that
+ package.
+ </para>
+ <para>
+ As we mentioned in our earlier sections, installing a package is equivalent to adding a new service to the
+ application server. And since services are nothing more than a set of files, a package is expected to contain
+ those set of files to be installed. These files are listed in the package.xml through the <file>
+ element. In a later section, we will go into the details about this <file> element. A package can also
+ specify dependencies on other packages. These dependencies are externalized from the package.xml and are
+ listed in a separate file within the package. The name, structure and the location of the file listing these
+ dependencies isn't restricted - except that it should be located within the package. The package.xml will
+ then just point to this dependencies file through the <dependencies> element. This will looked in greater
+ detail, in a later section.
+ </para>
+ <para>
+ When the package manager installs/uninstalls a package, it allows the packages to do some pre-install, post-install,
+ pre-uninstall, post-uninstall activities. The package manager allows the package to run scripts during either
+ or all of these phases. The package.xml, through <pre-install>, <post-install>, <pre-uninstall> and
+ <post-uninstall>, elements allows the package to specify such scripts.
+ </para>
+ <para>
+ Apart from dependencies on other packages, a package might have some restriction on the systems where this
+ package can be installed. For example, a package XYZ, might only work against JBoss AS-5.1.0 version. Such
+ requirements can also be declared in a package.xml file through the use of <system-requirements> element.
+ </para>
+ <para>
+ Now let's see each of these elements in the package.xml in detail.
+ <note>
+ <para>
+ The xsd for package.xml is available at http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/trunk/package-manager/src/main/resources/package.xsd
+ </para>
+ </note>
+ </para>
+ <sect2>
+ <title><file> element in the package.xml</title>
+ <para>
+ A <file> element is the minimal content that's expected in a package.xml (other than the name of
+ the package and it's version). The file element declares the file within that package which has to be
+ installed into the server. The file element has the following attributes:
+ <informaltable frame="all">
+ <tgroup cols='4' colsep="1" rowsep="1">
+ <colspec colwidth='0.5in'/>
+ <thead>
+ <row>
+ <entry>Attribute Name</entry>
+ <entry>Mandatory/Optional</entry>
+ <entry>Default Value</entry>
+ <entry>Details</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>name</entry>
+ <entry>Mandatory</entry>
+ <entry></entry>
+ <entry>This is the name of the file within the package</entry>
+ </row>
+ </tbody>
+ <tbody>
+ <row>
+ <entry>src-path</entry>
+ <entry>Optional</entry>
+ <entry></entry>
+ <entry>
+ The value for this attribute, specifies the relative path of the file within this package.
+ If the file is located at the root of this package, then the src-path need not be specified.
+ If however, the file is located within a sub-folder (eg: lib) of the package, then
+ the value for the src-path should be set to "lib".
+ </entry>
+ </row>
+ </tbody>
+ <tbody>
+ <row>
+ <entry>dest-path</entry>
+ <entry>Mandatory</entry>
+ <entry></entry>
+ <entry>
+ The value for this attribute, specifies the path relative to the JBoss Application Server
+ Home directory. It mandatory to specify this value, because it's the package which
+ knows where this file has to be installed within the application server. For example,
+ if the file is= to be installed to JBOSS_HOME/common/lib folder, then the value of
+ the dest-path should be set to "common/lib".
+ </entry>
+ </row>
+ </tbody>
+ <tbody>
+ <row>
+ <entry>type</entry>
+ <entry>Optional</entry>
+ <entry></entry>
+ <entry>
+ The value of this attribute, specifies the type of this file. Allowed values are
+ "config", "library" and "script". This attribute is optional and is only useful
+ if the package manager is able to handle each of these file types differently.
+ For example, for "config" type of files, if the package manager is able to support
+ diff/merge support, then setting this attribute makes sense.
+ <para>
+ In it's current form, the package manager treats all types of files in the same
+ way and the file type does not play an role.
+ </para>
+ </entry>
+ </row>
+ </tbody>
+
+ </tgroup>
+ </informaltable>
+
+ </para>
+ <para>
+ A single package can have multiple files to be installed and hence the package.xml allows multiple <file>
+ file elements. It however mandates that there be at-least one file to be installed.
+ </para>
+ <sect3>
+ <title>Example usage of <file></title>
+ <para>
+ Here's an example on how you can use the file element in the package.xml:
+ <programlisting>
+<![CDATA[
+<package name="jboss-ejb3-nointerface" version="1.0.0-Alpha1">
+
+ <!-- Package to install a dummy jar into JBOSS_AS/common/lib -->
+ <file name="dummy.jar" dest-path="common/lib" />
+
+
+</package>
+]]>
+ </programlisting>
+ </para>
+ <para>
+ One more example on how you can use the file element in the package.xml:
+ <programlisting>
+<![CDATA[
+<package name="jboss-ejb3-nointerface" version="1.0.0-Alpha1">
+
+ <!-- Package to install a dummy jar into JBOSS_AS/common/lib -->
+ <file name="dummy.jar" dest-path="common/lib" />
+
+ <!-- Package to install a another jar into JBOSS_AS/server/default/deployers -->
+ <file name="mydeployer.jar" src-path="deployers" dest-path="server/default/deployers" />
+
+
+</package>
+]]>
+ </programlisting>
+ </para>
+ </sect3>
+ </sect2>
+
+ <sect2>
+ <title><pre-install>, <post-install> and other similar scripts</title>
+ <para>
+ A package can contain scripts which could be configured to run during the pre-install, post-install,
+ pre-uninstall and/or post-uninstall phases of a package installation/un-installation. The package.xml
+ allows for <pre-install>, <post-install>, <pre-uninstall> and <post-uninstall>
+ elements. Each of these elements can contain one or more <script> elements.
+ By default, a script file is an Ant build file containing some pre-defined targets. However, the
+ script element allows for any other script types to be used. The script element allows the "processor"
+ attribute to be set to a class which implements the org.jboss.ejb3.packagemanager.script.ScriptProcessor
+ interface. It's then upto that script processor implementation to process the script file. A pre-install,
+ post-install element can have multiple script and each script can be of a different type and can be
+ processed by different script processor implementations.
+ </para>
+ <para>
+ By default, the JBoss Package Manager uses org.jboss.ejb3.packagemanager.script.impl.AntScriptProcessor
+ which is capable of processing Ant build files. The Ant build file is expected to contain certain pre-defined
+ targets. The targets that are mandated in the Ant build script file, depend on the context in which the
+ script file is run. For example, if the script has to be run during the pre-install phase of the installation
+ of the package, then the file is expected to contain a target named "pre-install". Here's the entire
+ set of expected targets and the context when they are expected:
+ <informaltable frame="all">
+ <tgroup cols='2' colsep="1" rowsep="1">
+ <colspec colwidth='0.5in'/>
+ <thead>
+ <row>
+ <entry>Target Name</entry>
+ <entry>Context</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>pre-install</entry>
+ <entry>This target is expected to be present in the Ant script, if the
+ script is configured to run during the pre-install phase of the package
+ installation.
+ </entry>
+
+ </row>
+ </tbody>
+
+ <tbody>
+ <row>
+ <entry>post-install</entry>
+ <entry>This target is expected to be present in the Ant script, if the
+ script is configured to run during the post-install phase of the package
+ installation.
+ </entry>
+
+ </row>
+ </tbody>
+ <tbody>
+ <row>
+ <entry>pre-uninstall</entry>
+ <entry>This target is expected to be present in the Ant script, if the
+ script is configured to run during the pre-uninstall phase of the package
+ installation.
+ </entry>
+
+ </row>
+ </tbody>
+ <tbody>
+ <row>
+ <entry>post-uninstall</entry>
+ <entry>This target is expected to be present in the Ant script, if the
+ script is configured to run during the post-uninstall phase of the package
+ installation.
+ </entry>
+
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+ <para>
+ A single Ant script file can be used for the various package installation phases, provided it
+ has the required targets in that single Ant build file. Furthermore, the JBoss Package Manager
+ guarantees that the following two Ant properties will be set by the package manager so that they can
+ be referenced within the build scripts:
+ <itemizedlist mark="opencircle">
+ <listitem>
+ <para>
+ JBOSS_HOME - This property will point to the JBoss Application Server home folder against
+ which this package manager is processing this package.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ PM_HOME - This property will point to the JBoss Package Manager home folder.
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ The <script> element allows the following attributes:
+ <informaltable frame="all">
+ <tgroup cols='4' colsep="1" rowsep="1">
+ <colspec colwidth='0.5in'/>
+ <thead>
+ <row>
+ <entry>Attribute Name</entry>
+ <entry>Mandatory/Optional</entry>
+ <entry>Default Value</entry>
+ <entry>Details</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>script</entry>
+ <entry>Mandatory</entry>
+ <entry></entry>
+ <entry>The value of this attribute, is the relative path to the script file (including
+ the name of the file), within the package. The path is relative to the location of
+ package.xml. For example, if the script file is named build.xml and is located at the root
+ of the package (i.e. at the same level as package.xml), then the value of this attribute
+ should be set to "build.xml".
+ </entry>
+ </row>
+ </tbody>
+ <tbody>
+ <row>
+ <entry>processor</entry>
+ <entry>Optional</entry>
+ <entry>org.jboss.ejb3.packagemanager.script.impl.AntScriptProcessor</entry>
+ <entry>
+ The value for this attribute, specifies the fully qualified class name of the class
+ which implements the org.jboss.ejb3.packagemanager.script.ScriptProcessor. The
+ implementation class will then be allowed to process this script file.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ </para>
+
+ <sect3>
+ <title>Example usage of the <pre-install>, <post-install></title>
+ <para>
+ Following is an example usage of the pre-install, post-install scripts:
+ <programlisting>
+<![CDATA[
+<package name="jboss-ejb3-nointerface" version="1.0.0-Alpha1">
+
+ <!-- Package to install a dummy jar into JBOSS_AS/server/default/deploy -->
+ <file name="dummy.jar" dest-path="server/default/deploy" type="library"/>
+
+ <!-- A couple of pre-install files for this package -->
+ <pre-install>
+ <!-- The default Ant script processor is used for this script -->
+ <script file="build.xml"/>
+ <!-- A custom script processor org.somepackage.DotShScriptProcessor
+ will be used to process the other.sh file which is located in the bin
+ sub-folder within the package
+ -->
+ <script file="bin/other.sh" processor="org.somepackage.DotShScriptProcessor"/>
+ </pre-install>
+
+ <!-- A post-install script -->
+ <post-install>
+ <!-- We use the same build.xml file that was used for pre-install,
+ because that build.xml can contain both pre-install and post-install
+ targets -->
+ <script file="build.xml"/>
+ </post-install>
+
+
+</package>
+]]>
+ </programlisting>
+
+
+ </para>
+ </sect3>
+ </sect2>
+
+ <sect2>
+ <title><system-requirements> element</title>
+ <para>
+ The <system-requirements> element in the package.xml allows the package to specify it's requirements.
+ This element currently just a place-holder. We have to think more about this, specifically what
+ kind of requirements the package is allowed to specify and how is the package manager going to check
+ whether the system where the package is being installed, satisfies those requirements. At the minimal,
+ probably the version of the JBoss Application Server can act as the system requirement. But again, that
+ would require some kind of non-trivial interaction with the application server to check the requirements.
+ Overall, this needs a bit more thinking. This section will be updated appropriately once we have decided
+ upon something.
+ </para>
+ </sect2>
+
+ <sect2>
+ <title><dependencies> element</title>
+ <para>
+ As we have already mentioned various times in the document, a package usually has dependencies on other
+ packages. The <dependencies> element in the package.xml allows the package to point to a file
+ within the package which lists those dependencies.
+ </para>
+ <para>
+ The package.xml intentionally lets the dependencies to be specified in a separate file within the package,
+ whose location and format is not restricted. This allows for the various different ways in which the
+ dependencies can be listed and processed.
+ </para>
+ <para>
+ By default, the JBoss Package Manager expects the dependencies (if any) to be specified in a xml file
+ which is an Ivy dependency file. For any other type of dependencies file, the <dependencies>
+ element allows, through it's "manager" attribute to specify the fully qualified class name of the class
+ which implements the org.jboss.ejb3.packagemanager.dependency.DependencyManager interface.
+ This implementation of the "manager" will then be responsible for parsing and processing the
+ dependencies listed in the dependency file. By default, JBoss Package Manager uses the
+ org.jboss.ejb3.packagemanager.dependency.IvyDependencyManager for processing the dependency file.
+ </para>
+ <para>
+ A single package can have only one dependencies file, and hence only one dependency manager implementation,
+ listing all the dependencies in that single file.
+ </para>
+ <para>
+ TODO: More thinking and PoC has to be done around this and this section will be updated in the next
+ few days with more details and specific examples. Right now, this is work-in-progress (well, the entire
+ document is actually work-in-progress :-) )
+ </para>
+ </sect2>
+ </sect1>
+
+ <sect1>
+ <title>Package Build tool</title>
+ <para>
+ As we have seen so far, an package is nothing more than a .jar/.zip file. Expect for the presence of the
+ package.xml in the package, the JBoss Package Manager does not add any other requirements/restrictions on
+ the package format or contents. As such, i personally, don't see any need for an new build tool which allows
+ to create the packages. Already existing tools (there are lots) like Ant build script or anything else
+ can always be used to create these packages.
+ </para>
+ <para>
+ But, if at some point of time, the requirement for such a build tool arises, then we will update this section
+ with the details.
+ </para>
+ </sect1>
+ <sect1>
+ <title>Package Manager</title>
+ <para>
+ Now that we have seen what a package contains and how to create a package, let's now see some details
+ around the JBoss Package Manager which processes these packages.
+ </para>
+ <sect2>
+ <title>Running the Package Manager</title>
+ <para>
+ Note that we currently don't have a script for the package manager. Until then, you can use the
+ org.jboss.ejb3.packagemanager.impl.DefaultPackageManagerImpl class and pass it the appropriate command
+ line arguments. This class has the "main" method which acts as an entry point for the package manager.
+ In it's current form, the JBoss Package Manager can handle the following options:
+ <informaltable frame="all">
+ <tgroup cols='2' colsep="1" rowsep="1">
+ <colspec colwidth='0.5in'/>
+ <thead>
+ <row>
+ <entry>Option</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>-i</entry>
+ <entry>The -i option can be used to install a package.
+ When the -i option is used, it expects the path to the package to be specified too.
+ See later section on what the valid values for path are.
+ </entry>
+ </row>
+ </tbody>
+ <tbody>
+ <row>
+ <entry>-p</entry>
+ <entry>This option right now is mandatory and it points to
+ the JBoss Package Manager home folder. The JBoss Package Manager folder can be
+ any folder on the file system. The package manager will use this as it working
+ environment and create, extract any of the files it needs to, while processing
+ packages.
+ </entry>
+ </row>
+ </tbody>
+ <tbody>
+ <row>
+ <entry>-s</entry>
+ <entry>
+ This option is mandatory and it points to home folder of JBoss Application Server,
+ to which this package manager is installing packages.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <note>
+ <para>
+ None of these options have been finalized yet. This section will be updated appropriately when
+ the final set of options is decided.
+ </para>
+ </note>
+ </para>
+
+ </sect2>
+ <sect2>
+ <title>Installing a Package</title>
+ <para>
+ To install a package you can pass the -i <packagepath> arguments to the package manager script.
+ </para>
+ <para>
+ The -i argument to the package manager is to let the package manager install a package. The -i argument
+ expects the path to the package manager to be specified. In it's current form, the JBoss Package Manager
+ can handle file:// protocol and http:// protocols. So the JBoss Package Manager, in it's current
+ form is able to work on package available either on the file system or through an HTTP URL.
+ </para>
+ </sect2>
+ <sect2>
+ <title>Removing a Package</title>
+ <para>
+ This is still work-in-progress. Details will be added soon.
+ </para>
+ </sect2>
+ <sect2>
+ <title>Updating a Package</title>
+ <para>
+ This is still work-in-progress. Details will be added soon.
+ </para>
+ </sect2>
+ </sect1>
+</chapter>
+
Added: projects/ejb3/trunk/package-manager/docs/guide/en/modules/overview.xml
===================================================================
--- projects/ejb3/trunk/package-manager/docs/guide/en/modules/overview.xml (rev 0)
+++ projects/ejb3/trunk/package-manager/docs/guide/en/modules/overview.xml 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,76 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2005, JBoss Inc., 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.
+ -->
+
+<chapter id="overview">
+ <title>Overview</title>
+ <sect1>
+ <title>What is JBoss Package Manager</title>
+ <para>
+ JBoss Package Manager is an utility to install, update or remove packages from a JBoss Application Server installation.
+ </para>
+ </sect1>
+ <sect1 id="motivation">
+ <title>Motivation</title>
+ <para>
+ To put in very simple terms, JBoss Application Server, or for that matter any application server is nothing
+ more than a collection of files which collectively provide various services. The files within the application
+ server are either scripts (eg: .bat, .sh), configuration files (eg: .xml) or library files (eg: .jar). The
+ application server provides an environment where various services can co-exist. The existence of each of these
+ services is controlled by the presence of the different type of files mentioned earlier.
+ </para>
+ <para>
+ So ideally, a new service within the application server could be made available by adding appropriate files
+ required by that service, at the right place in the application server. Similar, is the case with removing
+ an existing service - the files that make up that service, could simply be removed from the application server
+ instance. To take this one step further, an existing service can be upgraded by updating the set of files that
+ make up the service.
+ </para>
+ <para>
+ In a real world, however, this is not so simple. So far, we just assumed that each of these services were
+ independent of each other. What happens if one service depends on some other service? For example, if Service
+ A depended on Service B and we decided to remove Service B from the server, Service A would no longer function.
+ Again, this is a very simple dependency scenario. Dependencies can be (or rather are) far more complicated.
+ </para>
+ <para>
+ If you think about all this, for a while, you will see that this is quite similar to an Operating System,
+ which hosts multiple applications/services/packages. It too is nothing more than a collection of files and these
+ files together govern the services within the operating system. An operating system too has to deal with exactly
+ the same issues that we talked about earlier (like dependencies, new service installations etc...).
+
+ </para>
+ <para>
+ We can thus consider the application server as a mini-operating system. If you look around, you would find that
+ operating systems provide tools to take care of these issues. Each operating system has its own tool or
+ terminology for such tools. Let's just simply call them package managers and let's henceforth call the "services",
+ that we have been talking about so far, as "packages". I guess, this much of an overview is enough to give an
+ idea about what we are trying to achieve with the JBoss Package Manager.
+ The rest of the documentation will only talk about the package manager for JBoss Application Server.
+ <important>
+ Although this utility is currently being developed under the EJBTHREE project, this in no way is tied
+ to be EJBTHREE specifies. If things turn out well, we could probably move it outside EJBTHREE project
+ and make it available to other JBoss projects which end up in JBoss Application Server as packages. But
+ that's still some way to go, so until then you will find this residing in EJBTHREE project SVN trunk.
+ </important>
+ </para>
+ </sect1>
+</chapter>
Added: projects/ejb3/trunk/package-manager/docs/guide/en/modules/status.xml
===================================================================
--- projects/ejb3/trunk/package-manager/docs/guide/en/modules/status.xml (rev 0)
+++ projects/ejb3/trunk/package-manager/docs/guide/en/modules/status.xml 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,80 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2005, JBoss Inc., 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.
+ -->
+<chapter id="status">
+ <title>Current status</title>
+ <sect1>
+ <title>What's the current state of JBoss Package Manager?</title>
+ <para>
+ There's still lots to be done in the JBoss Package Manager. The current state of JBoss Package Manager
+ has the very basic implementation of installing a package. It's currently in a PoC state and more
+ functionality is being worked on.
+ </para>
+ <para>
+ Some of features/functionalities that need to be thought about, but not limited to, are:
+ <itemizedlist>
+ <listitem>
+ <para>
+ Dependency Management implementation through Ivy
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ A simple database management which allows for maintaining/tracking installed package information
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Update/Remove(Un-Install) features
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Diff/Merging of configuration files and maybe checksum comparisons on files being installed
+ </para>
+ </listitem>
+
+ </itemizedlist>
+ </para>
+ </sect1>
+ <sect1>
+ <title>Enough of these docs, i need some action!</title>
+ <para>
+ In the next few days, i'll add a simple script which can be used to run the package manager. But right now,
+ you can try out the org.jboss.ejb3.packagemanager.impl.DefaultPackageManagerImpl.main(Stringp[] args)
+ method by passing it the appropriate arguments, listed in the previous sections.
+ </para>
+ <para>
+ You can also have a look at the org.jboss.ejb3.packagemanager.test.install.unit.BasicInstallTestCase to
+ see how the install works. That test case has been written with many comments to make sure that each step
+ is explained clearly. It covers almost all of the currently implemented functionality in the JBoss Package
+ Manager, including HTTP URL support. You can add your own tests there to try out the JBoss Package Manager.
+ To run the tests, use the following Maven command on the package-manager project root:
+ <programlisting>
+<![CDATA[
+mvn clean test
+]]>
+ </programlisting>
+
+ </para>
+ </sect1>
+</chapter>
Added: projects/ejb3/trunk/package-manager/docs/guide/pom.xml
===================================================================
--- projects/ejb3/trunk/package-manager/docs/guide/pom.xml (rev 0)
+++ projects/ejb3/trunk/package-manager/docs/guide/pom.xml 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,42 @@
+<!--
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2005, JBoss Inc., 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.
+ -->
+ <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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>documentation</artifactId>
+ <version>1.0</version>
+ </parent>
+
+ <groupId>org.jboss.ejb3.packagemanager</groupId>
+ <artifactId>jboss-ejb3-packagemanager-user-guide-${translation}</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jdocbook</packaging>
+ <name>JBoss Package Manager</name>
+
+
+
+</project>
Added: projects/ejb3/trunk/package-manager/pom.xml
===================================================================
--- projects/ejb3/trunk/package-manager/pom.xml (rev 0)
+++ projects/ejb3/trunk/package-manager/pom.xml 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,164 @@
+<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">
+
+
+ <!-- POM Model Version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Information -->
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-package-manager</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss EJB3 Package Manager</name>
+ <version>1.0.0-SNAPSHOT</version>
+ <description>Package manager for JBoss EJB3 package installations into JBoss AS</description>
+ <repositories>
+ <repository>
+ <id>maven2-repository.dev.java.net</id>
+ <name>Java.net Repository for Maven</name>
+ <url>http://download.java.net/maven/2/</url>
+ <layout>default</layout>
+ </repository>
+ </repositories>
+
+
+ <build>
+ <plugins>
+ <!-- JDK6 Enforcer -->
+ <plugin>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>enforce-jdk6</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireJavaVersion>
+ <version>1.6</version>
+ </requireJavaVersion>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+
+ </plugin>
+ <!-- Compiler -->
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <showDeprecation>false</showDeprecation>
+ <showWarnings>true</showWarnings>
+ <optimize>true</optimize>
+ <compilerVersion>1.6</compilerVersion>
+ <fork>true</fork>
+ <executable>${JAVA_HOME}/bin/javac</executable>
+ </configuration>
+ </plugin>
+
+ <!-- Surefire (test plugin) -->
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <printSummary>true</printSummary>
+ <includes>
+ <include>**/*TestCase.java</include>
+ <include>**/*TestSuite.java</include>
+ </includes>
+ <forkMode>always</forkMode>
+ <argLine>-ea</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+ <dependencies>
+
+ <!-- Ant for script processors -->
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <!-- Would have prefered 1.7.x, but there's no jar available for that
+ version in either maven central or jboss repo -->
+ <version>1.6.5</version>
+ </dependency>
+
+ <!-- Ant Contrib -->
+ <dependency>
+ <groupId>ant-contrib</groupId>
+ <artifactId>ant-contrib</artifactId>
+ <version>1.0b2</version>
+ </dependency>
+
+ <!-- File operation utils -->
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+
+ <!-- Logging spi -->
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <version>2.1.0.GA</version>
+ </dependency>
+ <!-- Log4j logging -->
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <version>2.1.0.GA</version>
+ </dependency>
+
+
+ <!-- Command line parsing -->
+ <dependency>
+ <groupId>gnu-getopt</groupId>
+ <artifactId>getopt</artifactId>
+ <version>1.0.13</version>
+ </dependency>
+
+
+
+ <!-- XML parsing -->
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>woodstox-core-lgpl</artifactId>
+ <version>4.0.6</version>
+ </dependency>
+ <!-- XML MSV schema validator -->
+ <dependency>
+ <groupId>net.java.dev.msv</groupId>
+ <artifactId>msv-core</artifactId>
+ <version>2009.1</version>
+ </dependency>
+
+ <!-- Support for http: protocol for package retrieval -->
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.0</version>
+ </dependency>
+
+ <!-- Tests -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.6</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- Useful util for creating jars within testcases -->
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-impl-base</artifactId>
+ <version>1.0.0-alpha-1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/PackageManager.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/PackageManager.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/PackageManager.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager;
+
+import java.net.URL;
+
+import org.jboss.ejb3.packagemanager.exception.InstallerException;
+import org.jboss.ejb3.packagemanager.installer.Installer;
+import org.jboss.ejb3.packagemanager.metadata.InstallFile;
+import org.jboss.ejb3.packagemanager.metadata.Script;
+import org.jboss.ejb3.packagemanager.script.ScriptProcessor;
+
+/**
+ * PackageManager
+ *
+ * Package Manager can be used to install/update/remove packages against
+ * JBoss Application Server.
+ * TODO: More javadocs (once we have something usable)
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface PackageManager
+{
+
+ /**
+ * Returns the environment associated with this package manager
+ * @return
+ */
+ PackageManagerEnvironment getPackageManagerEnvironment();
+
+ /**
+ * Updates the package
+ *
+ * @param packagePath The URL path to the package file
+ */
+ void updatePackage(String packagePath);
+
+ /**
+ * Updates the package
+ *
+ * @param packageURL The URL of the package file
+ */
+ void updatePackage(URL packageURL);
+
+ /**
+ * Installs a package
+ *
+ * @param packagePath The URL path of the package file
+ * @throws InstallerException If any exceptions occur during installation
+ */
+ void installPackage(String packagePath) throws InstallerException;
+
+ /**
+ * Installs a package
+ *
+ * @param packageURL The URL of the package file
+ * @throws InstallerException If any exceptions occur during installation
+ */
+ void installPackage(URL packageURL) throws InstallerException;
+
+ /**
+ * Removes a package using the name of the package
+ * @param packageName Name of the package to be uninstalled
+ */
+ void removePackage(String packageName);
+
+ /**
+ * Returns an appropriate {@link Installer} for the {@link InstallFile}
+ * @param fileMeta The file in the package, to be installed
+ * @return
+ */
+ Installer getInstaller(InstallFile fileMeta);
+
+ /**
+ * Returns an appropriate {@link ScriptProcessor} for the {@link Script}
+ * @param script The script in a package
+ * @return
+ */
+ ScriptProcessor getScriptProcessor(Script script);
+
+ /**
+ * A package manager works against a JBoss AS server. This method returns the
+ * absolute path of the JBoss AS Home.
+ *
+ * @return Returns the JBoss Server Home
+ */
+ String getServerHome();
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/PackageManagerEnvironment.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/PackageManagerEnvironment.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/PackageManagerEnvironment.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager;
+
+import java.io.File;
+
+/**
+ * PackageManagerEnvironment
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class PackageManagerEnvironment
+{
+
+ private File packageManagerHome;
+
+ private File packageManagerBuildDir;
+
+ private File packageManagerTmpDir;
+
+ /**
+ *
+ */
+ public PackageManagerEnvironment(String home)
+ {
+ this.packageManagerHome = new File(home);
+ if (!this.packageManagerHome.exists() || !this.packageManagerHome.isDirectory())
+ {
+ throw new RuntimeException("Package manager home " + home + " doesn't exist or is not a directory");
+
+ }
+ initEnvironment();
+ }
+
+ private void initEnvironment()
+ {
+ this.packageManagerBuildDir = new File(packageManagerHome, "build");
+ if (!this.packageManagerBuildDir.exists())
+ {
+ this.packageManagerBuildDir.mkdirs();
+ }
+ this.packageManagerTmpDir = new File(packageManagerHome, "tmp");
+ if (!this.packageManagerTmpDir.exists())
+ {
+ this.packageManagerTmpDir.mkdirs();
+ }
+ }
+
+ public File getPackageManagerHome()
+ {
+ return this.packageManagerHome;
+ }
+
+ public File getPackageManagerBuildDir()
+ {
+ return this.packageManagerBuildDir;
+ }
+
+ public File getPackageManagerTmpDir()
+ {
+ return this.packageManagerTmpDir;
+ }
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/PackageSource.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/PackageSource.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/PackageSource.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager;
+
+import java.io.File;
+
+import org.jboss.ejb3.packagemanager.metadata.Package;
+import org.jboss.ejb3.packagemanager.xml.PackageUnmarshaller;
+
+/**
+ * PackageSource
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class PackageSource
+{
+
+ private File pkgSource;
+
+ private Package packageMetadata;
+
+ /**
+ *
+ */
+ public PackageSource(String packageFilePath)
+ {
+ this(new File(packageFilePath));
+ }
+
+ public PackageSource(File src)
+ {
+ this.pkgSource = src;
+ initMetadata();
+ }
+
+ private void initMetadata()
+ {
+ File packageXmlFile = new File(this.pkgSource, "package.xml");
+ try
+ {
+ this.packageMetadata = new PackageUnmarshaller().unmarshal(packageXmlFile.toURL());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not create metadata from package.xml file " + packageXmlFile, e);
+ }
+ }
+
+ public Package getPackageMetadata()
+ {
+ return this.packageMetadata;
+ }
+
+ public File getSource()
+ {
+ return this.pkgSource;
+ }
+
+ /**
+ * Returns the string representation of this {@link PackageSource}
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Package [source = ");
+ sb.append(this.pkgSource);
+ sb.append(" ,name = ");
+ sb.append(this.packageMetadata.getName());
+ sb.append(" ,version = ");
+ sb.append(this.packageMetadata.getVersion());
+ sb.append(" ]");
+ return sb.toString();
+ }
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/exception/InstallerException.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/exception/InstallerException.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/exception/InstallerException.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.exception;
+
+/**
+ * InstallerException
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class InstallerException extends Exception
+{
+
+ public InstallerException(String msg)
+ {
+ super(msg);
+ }
+
+ public InstallerException(Exception e)
+ {
+ super(e);
+ }
+
+ public InstallerException(String msg, Exception e)
+ {
+ super(msg,e);
+ }
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/exception/PackageRetrievalException.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/exception/PackageRetrievalException.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/exception/PackageRetrievalException.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.exception;
+
+/**
+ * PackageRetrievalException
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class PackageRetrievalException extends Exception
+{
+ public PackageRetrievalException(String msg)
+ {
+ super(msg);
+ }
+
+ public PackageRetrievalException(Exception e)
+ {
+ super(e);
+ }
+
+ public PackageRetrievalException(String msg, Exception e)
+ {
+ super(msg, e);
+ }
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/exception/ScriptProcessingException.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/exception/ScriptProcessingException.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/exception/ScriptProcessingException.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.exception;
+
+/**
+ * ScriptProcessingException
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ScriptProcessingException extends Exception
+{
+ public ScriptProcessingException(String msg)
+ {
+ super(msg);
+ }
+
+ public ScriptProcessingException(Exception e)
+ {
+ super(e);
+ }
+
+ public ScriptProcessingException(String msg, Exception e)
+ {
+ super(msg, e);
+ }
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/impl/DefaultPackageManagerImpl.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/impl/DefaultPackageManagerImpl.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/impl/DefaultPackageManagerImpl.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,461 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.impl;
+
+import gnu.getopt.Getopt;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.jboss.ejb3.packagemanager.PackageManager;
+import org.jboss.ejb3.packagemanager.PackageManagerEnvironment;
+import org.jboss.ejb3.packagemanager.PackageSource;
+import org.jboss.ejb3.packagemanager.exception.InstallerException;
+import org.jboss.ejb3.packagemanager.exception.PackageRetrievalException;
+import org.jboss.ejb3.packagemanager.exception.ScriptProcessingException;
+import org.jboss.ejb3.packagemanager.installer.DefaultInstaller;
+import org.jboss.ejb3.packagemanager.installer.Installer;
+import org.jboss.ejb3.packagemanager.installer.MergingInstaller;
+import org.jboss.ejb3.packagemanager.metadata.Dependencies;
+import org.jboss.ejb3.packagemanager.metadata.FileType;
+import org.jboss.ejb3.packagemanager.metadata.InstallFile;
+import org.jboss.ejb3.packagemanager.metadata.Package;
+import org.jboss.ejb3.packagemanager.metadata.PostInstall;
+import org.jboss.ejb3.packagemanager.metadata.PreInstall;
+import org.jboss.ejb3.packagemanager.metadata.Script;
+import org.jboss.ejb3.packagemanager.retriever.PackageRetriever;
+import org.jboss.ejb3.packagemanager.retriever.impl.PackageRetrievalFactory;
+import org.jboss.ejb3.packagemanager.script.ScriptProcessor;
+import org.jboss.ejb3.packagemanager.script.impl.AntScriptProcessor;
+import org.jboss.logging.Logger;
+
+/**
+ * DefaultPackageManagerImpl
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class DefaultPackageManagerImpl implements PackageManager
+{
+
+ /**
+ * Logger
+ */
+ private static Logger logger = Logger.getLogger(DefaultPackageManagerImpl.class);
+
+ /**
+ * The server against which this package manager will carry out the installation/uninstallation
+ *
+ */
+ private String installationServerHome;
+
+ /**
+ * Package manager environment
+ */
+ private PackageManagerEnvironment environment;
+
+ /**
+ * Creates the default package manager for a server
+ *
+ * @param environment The package manager environment
+ * @param jbossHome The JBoss AS server home
+ */
+ public DefaultPackageManagerImpl(PackageManagerEnvironment environment, String jbossHome)
+ {
+ this.environment = environment;
+ this.installationServerHome = jbossHome;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.PackageManager#getPackageManagerEnvironment()
+ */
+ public PackageManagerEnvironment getPackageManagerEnvironment()
+ {
+ return this.environment;
+ }
+
+ /**
+ * Returns the server home against which this package manager operates
+ */
+ public String getServerHome()
+ {
+ return this.installationServerHome;
+ }
+
+ /**
+ * Installs a package
+ *
+ * @param pkgPath The URL to the package that is to be installed
+ * @throws InstallerException If any exceptions occur during installation of the package
+ * @see org.jboss.ejb3.packagemanager.PackageManager#installPackage(java.lang.String)
+ */
+ @Override
+ public void installPackage(String pkgPath) throws InstallerException
+ {
+ if (pkgPath == null)
+ {
+ throw new InstallerException("Package path is null");
+ }
+ URL packageURL = null;
+ try
+ {
+ packageURL = this.getPackageURL(pkgPath);
+ }
+ catch (MalformedURLException mue)
+ {
+ throw new InstallerException("Cannot parse path " + pkgPath, mue);
+ }
+ this.installPackage(packageURL);
+ }
+
+ /**
+ * Installs the package from the {@code packageURL}
+ *
+ * @param packageURL The URL to the package that is to be installed
+ * @throws InstallerException If any exceptions occur during installation of the package
+ * @see org.jboss.ejb3.packagemanager.PackageManager#installPackage(URL)
+ *
+ */
+ @Override
+ public void installPackage(URL packageURL) throws InstallerException
+ {
+ if (packageURL == null)
+ {
+ throw new InstallerException("Package URL is null");
+ }
+ // get the appropriate retriever
+ PackageRetriever pkgRetriever = PackageRetrievalFactory.getPackageRetriever(packageURL);
+ // retrieve the package source
+ PackageSource pkgSource = null;
+ try
+ {
+ logger.debug("Retrieving package from " + packageURL + " using retriever " + pkgRetriever);
+ pkgSource = pkgRetriever.retrievePackage(this, packageURL);
+ }
+ catch (PackageRetrievalException pre)
+ {
+ throw new InstallerException("Could not retrieve package: " + packageURL, pre);
+ }
+ // proceed with installation of the package
+ Package pkgToInstall = pkgSource.getPackageMetadata();
+ if (pkgToInstall.getFiles() == null)
+ {
+ throw new InstallerException("There are no files to install for package: " + pkgToInstall.getName()
+ + " version: " + pkgToInstall.getVersion());
+ }
+ // work on dependencies first
+ this.processDependencies(pkgSource);
+ // pre-installation step
+ this.preInstallPackage(pkgSource);
+ // install files in this package
+ for (InstallFile fileToInstall : pkgToInstall.getFiles())
+ {
+ Installer installer = getInstaller(fileToInstall);
+ installer.install(this, pkgSource, fileToInstall);
+ }
+ // post-installation step
+ this.postInstallPackage(pkgSource);
+
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.PackageManager#removePackage(java.lang.String)
+ */
+ public void removePackage(String packageName)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.PackageManager#updatePackage(java.lang.String)
+ */
+ @Override
+ public void updatePackage(String packageFilePath)
+ {
+ // WIP
+ // URL packageUrl = null;
+ // try
+ // {
+ // packageUrl = this.getPackageURL(packageFilePath);
+ // }
+ // catch (MalformedURLException mue)
+ // {
+ // throw new InstallerException("Cannot parse path " + packageFilePath, mue);
+ // }
+ // this.updatePackage(packageUrl);
+ }
+
+ @Override
+ public void updatePackage(URL packageURL)
+ {
+
+ }
+
+ /**
+ * Parses the {@code pkgPath} string and returns an appropriate URL.
+ *
+ * @param pkgPath
+ * @return
+ *
+ * @throws MalformedURLException If the URL cannot be parsed
+ */
+ private URL getPackageURL(String pkgPath) throws MalformedURLException
+ {
+ URL url = null;
+ try
+ {
+ url = new URL(pkgPath);
+ }
+ catch (MalformedURLException e)
+ {
+ logger.debug("Cannot handle " + pkgPath + " - will try using file: URL");
+ // fall back to file based URL
+ File file = new File(pkgPath);
+ url = file.toURI().toURL();
+ }
+ return url;
+ }
+
+ /**
+ * Returns the appropriate {@link Installer} for the {@link InstallFile}
+ */
+ public Installer getInstaller(InstallFile file)
+ {
+ if (file == null)
+ {
+ return null;
+ }
+ FileType fileType = file.getType();
+ if (fileType == FileType.CONFIG)
+ {
+ return new MergingInstaller();
+ }
+ return new DefaultInstaller();
+ }
+
+ /**
+ * The pre-installation step for packages. Each package can have multiple
+ * pre-install scripts to be run. This method runs those pre-install scripts
+ *
+ * @param pkgSource The package source
+ * @throws InstallerException If any exception occurs during pre-installation of the
+ * package
+ */
+ protected void preInstallPackage(PackageSource pkgSource) throws InstallerException
+ {
+ Package pkgMetadata = pkgSource.getPackageMetadata();
+ // find any pre-install scripts
+ PreInstall preInstall = pkgMetadata.getPreInstall();
+ if (preInstall == null || preInstall.getScripts() == null || preInstall.getScripts().isEmpty())
+ {
+ logger.debug("There are no pre-install scripts for " + pkgSource);
+ return;
+ }
+ for (Script script : preInstall.getScripts())
+ {
+ ScriptProcessor scriptProcessor = this.getScriptProcessor(script);
+ try
+ {
+ scriptProcessor.processScript(this, pkgSource, script);
+ }
+ catch (ScriptProcessingException spe)
+ {
+ throw new InstallerException("Error while processing script: " + script.getFile() + " for " + pkgSource,
+ spe);
+ }
+ }
+
+ }
+
+ /**
+ * The post-installation step for packages. Each package can have multiple
+ * post-install scripts to be run. This method runs those post-install scripts
+ *
+ * @param pkgSource The package source
+ * @throws InstallerException If any exception occurs during post-installation of the
+ * package
+ */
+ protected void postInstallPackage(PackageSource pkgSource) throws InstallerException
+ {
+ Package pkgMetadata = pkgSource.getPackageMetadata();
+ // find any post-install scripts
+ PostInstall postInstall = pkgMetadata.getPostInstall();
+ if (postInstall == null || postInstall.getScripts() == null || postInstall.getScripts().isEmpty())
+ {
+ logger.debug("There are no post-install scripts for " + pkgSource);
+ return;
+ }
+ for (Script script : postInstall.getScripts())
+ {
+ ScriptProcessor scriptProcessor = this.getScriptProcessor(script);
+ try
+ {
+ scriptProcessor.processScript(this, pkgSource, script);
+ }
+ catch (ScriptProcessingException spe)
+ {
+ throw new InstallerException("Error while processing script: " + script.getFile() + " for " + pkgSource,
+ spe);
+ }
+ }
+ }
+
+ /**
+ * Process any dependencies listed for the package. Dependency processing
+ * will include resolving and retrieving the appropriate dependency packages
+ * and install (/un-installing?) those packages.
+ *
+ * TODO: Work-in-progress
+ * @param pkgSource
+ * @throws InstallerException
+ */
+ protected void processDependencies(PackageSource pkgSource) throws InstallerException
+ {
+ Package pkgMeta = pkgSource.getPackageMetadata();
+ Dependencies dependencies = pkgMeta.getDependencies();
+ if (dependencies == null)
+ {
+ logger.debug(pkgSource + " does not have any dependencies");
+ return;
+ }
+ File dependencyFile = new File(pkgSource.getSource(), dependencies.getFile());
+ if (!dependencyFile.exists())
+ {
+ throw new InstallerException("Dependency file " + dependencyFile + " not found for " + pkgSource);
+ }
+
+ }
+
+ /**
+ * One of the entry points to the package manager.
+ * Accepts the command line arguments and carries out appropriate operations
+ * through the package-manager.
+ *
+ * TODO: The command line arguments, haven't yet been finalized
+ *
+ * @param args
+ */
+ public static void main(String[] args)
+ {
+ logger.debug("comm line length = " + args.length);
+ StringBuffer sb = new StringBuffer();
+ for (String arg : args)
+ {
+ sb.append(arg);
+ sb.append(" ");
+ }
+ logger.debug(DefaultPackageManagerImpl.class + " invoked with args: " + sb.toString());
+
+ Getopt getOpt = new Getopt("packagemanager", args, "i:u:e:s:p:");
+ int opt;
+ String packageFilePath = null;
+ String jbossHome = null;
+ String packageNameToUninstall = null;
+ String pmHome = System.getProperty("java.io.tmpdir");
+ while ((opt = getOpt.getopt()) != -1)
+ {
+ switch (opt)
+ {
+ case 'i' :
+ packageFilePath = getOpt.getOptarg();
+ break;
+ case 'u' :
+ packageFilePath = getOpt.getOptarg();
+ break;
+ case 'e' :
+ packageNameToUninstall = getOpt.getOptarg();
+ break;
+ case 's' :
+ jbossHome = getOpt.getOptarg();
+ break;
+ case 'p' :
+ pmHome = getOpt.getOptarg();
+ break;
+ default :
+ throw new Error("Unhandled code " + opt);
+ }
+ }
+ if (jbossHome == null || packageFilePath == null)
+ {
+ throw new Error("JBoss home or package file not specified");
+ }
+ PackageManagerEnvironment env = new PackageManagerEnvironment(pmHome);
+ PackageManager pm = new DefaultPackageManagerImpl(env, jbossHome);
+
+ // install the package
+ try
+ {
+ pm.installPackage(packageFilePath);
+ }
+ catch (InstallerException ie)
+ {
+ throw new RuntimeException(ie);
+ }
+
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.PackageManager#getScriptProcessor(org.jboss.ejb3.packagemanager.metadata.Script)
+ */
+ public ScriptProcessor getScriptProcessor(Script script)
+ {
+ if (script == null)
+ {
+ return null;
+ }
+ String scriptProcessorClassName = script.getProcessor();
+ if (scriptProcessorClassName == null)
+ {
+ // our default is ant script processor
+ return new AntScriptProcessor();
+ }
+ Class<?> scriptProcessor = null;
+ // load the script processor
+ try
+ {
+ scriptProcessor = Class
+ .forName(scriptProcessorClassName, true, Thread.currentThread().getContextClassLoader());
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new RuntimeException("Could not load script processor: " + scriptProcessorClassName, cnfe);
+ }
+ // make sure the script processor specified in the metadata
+ // does indeed implement the ScriptProcessor interface
+ if (!ScriptProcessor.class.isAssignableFrom(scriptProcessor))
+ {
+ throw new RuntimeException("Script processor " + scriptProcessorClassName + " does not implement "
+ + ScriptProcessor.class);
+ }
+ try
+ {
+ return (ScriptProcessor) scriptProcessor.newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not instantiate script processor " + scriptProcessorClassName, e);
+ }
+
+ }
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/AbstractInstaller.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/AbstractInstaller.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/AbstractInstaller.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,101 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.installer;
+
+import java.io.File;
+
+import org.jboss.ejb3.packagemanager.PackageManager;
+import org.jboss.ejb3.packagemanager.PackageSource;
+import org.jboss.ejb3.packagemanager.exception.InstallerException;
+import org.jboss.ejb3.packagemanager.metadata.InstallFile;
+import org.jboss.ejb3.packagemanager.metadata.Package;
+import org.jboss.logging.Logger;
+
+/**
+ * AbstractInstaller
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public abstract class AbstractInstaller implements Installer
+{
+
+ private static Logger logger = Logger.getLogger(AbstractInstaller.class);
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.installer.Installer#install(org.jboss.ejb3.packagemanager.PackageSource, org.jboss.ejb3.packagemanager.metadata.InstallFile)
+ */
+ public final void install(PackageManager pkgManager, PackageSource pkgSource, InstallFile fileMeta)
+ throws InstallerException
+ {
+ // do templating
+ File pkgRoot = pkgSource.getSource();
+ File srcPathOfFileToInstall = pkgRoot;
+ if (fileMeta.getSrcPath() != null)
+ {
+ srcPathOfFileToInstall = new File(pkgRoot, fileMeta.getSrcPath());
+ }
+ File fileToInstall = new File(srcPathOfFileToInstall, fileMeta.getName());
+ Package pkg = pkgSource.getPackageMetadata();
+ if (!fileToInstall.exists())
+ {
+ throw new InstallerException(fileToInstall.getAbsolutePath() + " does not exist, package: " + pkg.getName()
+ + " version: " + pkg.getVersion() + " being installed from " + pkgSource.getSource()
+ + " is probably corrupt!");
+ }
+
+ if (fileMeta.getDestPath() == null)
+ {
+ throw new InstallerException("File " + fileMeta.getName() + " in package: " + pkg.getName() + " version: "
+ + pkg.getVersion() + " does not specify a destination");
+ }
+ String destServerHome = pkgManager.getServerHome();
+ File locationToInstall = new File(destServerHome, fileMeta.getDestPath());
+ // TODO: Provide an option on <file> to allow for creating missing destination folders
+ // Till then just throw an exception if dest-path is not actually available
+ if (!locationToInstall.exists() || !locationToInstall.isDirectory())
+ {
+ throw new InstallerException("dest-path " + locationToInstall.getAbsolutePath() + " for file: "
+ + fileMeta.getName() + " in package: " + pkg.getName() + " version: " + pkg.getVersion()
+ + " is either not present or is not a directory");
+ }
+ try
+ {
+ doInstall(fileMeta, fileToInstall, locationToInstall);
+ logger.info("Installed file " + fileMeta.getName() + " from package: " + pkg.getName() + " version: "
+ + pkg.getVersion() + " to " + locationToInstall.getAbsolutePath());
+
+ // TODO: Write to DB about file install completion
+ }
+ catch (Throwable t)
+ {
+ // TODO: Think about this - do we need to do something specific in DB when a package file
+ // fails to install?
+ throw new RuntimeException(t);
+ }
+ }
+
+ protected abstract void doInstall(InstallFile fileMetadata, File fileToInstall, File dest)
+ throws InstallerException;
+
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/DefaultInstaller.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/DefaultInstaller.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/DefaultInstaller.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,71 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.installer;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.jboss.ejb3.packagemanager.exception.InstallerException;
+import org.jboss.ejb3.packagemanager.metadata.InstallFile;
+import org.jboss.ejb3.packagemanager.metadata.Package;
+import org.jboss.ejb3.packagemanager.util.IOUtil;
+import org.jboss.logging.Logger;
+
+/**
+ * DefaultInstaller
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class DefaultInstaller extends AbstractInstaller
+{
+
+ private static Logger logger = Logger.getLogger(DefaultInstaller.class);
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.installer.AbstractInstaller#doInstall(org.jboss.ejb3.packagemanager.metadata.InstallFile, java.io.File, java.io.File)
+ */
+ @Override
+ protected void doInstall(InstallFile fileMetadata, File fileToInstall, File dest) throws InstallerException
+ {
+ // just copy from source to dest
+ File destFile = new File(dest, fileMetadata.getName());
+ Package pkgMeta = fileMetadata.getPackage();
+ if (destFile.exists())
+ {
+ logger.info("File " + fileMetadata.getName() + " from package: " + pkgMeta.getName() + " version: "
+ + pkgMeta.getVersion() + " already exists in " + dest + " - installer will overwrite it");
+ }
+ try
+ {
+ IOUtil.copy(fileToInstall, destFile);
+ }
+ catch (IOException e)
+ {
+
+ throw new InstallerException("Could not install file: " + fileMetadata.getName() + " from package: "
+ + pkgMeta.getName() + " version: " + pkgMeta.getVersion() + " into " + dest.getAbsolutePath());
+ }
+
+ }
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/Installer.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/Installer.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/Installer.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.installer;
+
+import org.jboss.ejb3.packagemanager.PackageManager;
+import org.jboss.ejb3.packagemanager.PackageSource;
+import org.jboss.ejb3.packagemanager.exception.InstallerException;
+import org.jboss.ejb3.packagemanager.metadata.InstallFile;
+
+/**
+ * Installer
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface Installer
+{
+
+ void install(PackageManager pkgMgr, PackageSource pkgSource, InstallFile file) throws InstallerException;
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/MergingInstaller.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/MergingInstaller.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/installer/MergingInstaller.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.installer;
+
+import java.io.File;
+
+import org.jboss.ejb3.packagemanager.exception.InstallerException;
+import org.jboss.ejb3.packagemanager.metadata.InstallFile;
+
+/**
+ * MergingInstaller
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class MergingInstaller extends AbstractInstaller
+{
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.installer.AbstractInstaller#doInstall(org.jboss.ejb3.packagemanager.metadata.InstallFile, java.io.File, java.io.File)
+ */
+ @Override
+ protected void doInstall(InstallFile fileMetadata, File fileToInstall, File dest) throws InstallerException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/Dependencies.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/Dependencies.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/Dependencies.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata;
+
+/**
+ * Represents the metadata for dependencies within a package.
+ *
+ * A package can have dependencies on other packages. Dependencies are configured in
+ * separate files. The dependencies element just points to that file. The file path is
+ * relative to the location of the package.xml within a package.
+ * Optionally a dependency manager can be specified through the
+ * "manager" attribute. The manager attribute should contain the fully qualified class name
+ * of the dependency manager which is responsible for parsing the dependencies file and
+ * managing the dependencies listed in that file. The class should implement the
+ * org.jboss.ejb3.packagemanager.dependency.DependencyManager interface.
+ * By default, org.jboss.ejb3.packagemanager.dependency.impl.IvyDependencyManager will be
+ * used as the dependency manager.
+ *
+ * @see Package
+ *
+ *
+ */
+public interface Dependencies
+{
+
+ /**
+ * @return Returns the file path (including the filename) of the dependencies file,
+ * relative to the location of package.xml file in the package
+ */
+ String getFile();
+
+ /**
+ * Sets the file path (including hte filename) of the dependencies file.
+ *
+ * @param depFile Relative file path of the dependencies file of this package
+ *
+ */
+ void setFile(String depFile);
+
+ /**
+ * Returns the fully qualified class name of the dependencies manager.
+ *
+ * @return
+ */
+ String getManager();
+
+ /**
+ * Sets the fully qualified class name of the dependencies manager.
+ *
+ * @param depManager Fully qualified class name of the dependencies manager
+ */
+ void setManager(String depManager);
+
+ /**
+ * Returns the package for which this is an dependency
+ * @return
+ */
+ Package getPackage();
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/FileType.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/FileType.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/FileType.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata;
+
+/**
+ * The type of file being installed by the package manager
+ * Author: Jaikiran Pai
+ */
+public enum FileType
+{
+ CONFIG,
+ LIBRARY,
+ SCRIPT
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/InstallFile.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/InstallFile.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/InstallFile.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata;
+
+/**
+ *
+ * A file element contains the information of the source and destination of the file to be installed.
+ * The src-path of the file is always relative to the location of the package.xml within a package.
+ * The dest-path of the file is always relative to the JBoss AS server home (JBOSS_HOME).
+ * A file can be of type library or config or script file.
+ *
+ * @author Jaikiran Pai
+ *
+ */
+public interface InstallFile
+{
+
+ /**
+ * @return Returns the name of the file
+ *
+ */
+ String getName();
+
+ /**
+ * Sets the file name
+ *
+ * @param name The name of the file
+ *
+ */
+ void setName(String name);
+
+ /**
+ * @return Returns the src-path of the file. The src-path
+ * is relative to the location of the package.xml file in the package
+ *
+ */
+ String getSrcPath();
+
+ /**
+ * Sets the src-path of the file. The path is expected to be
+ * relative to the location of package.xml file in the package
+ *
+ * @param path Relative source path
+ *
+ */
+ void setSrcPath(String path);
+
+ /**
+ * @return Returns the dest-path of the file. The dest-path
+ * is relative to the location of the package.xml file in the package
+ *
+ */
+ String getDestPath();
+
+ /**
+ * Sets the dest-path of the file. The path is expected to be
+ * relative to the location of package.xml file in the package
+ *
+ * @param path Relative destination path
+ *
+ */
+ void setDestPath(String path);
+
+ /**
+ * @return Returns the type of this file
+ *
+ */
+ FileType getType();
+
+ /**
+ * Sets the type of the file
+ *
+ * @param ftype File type
+ *
+ */
+ void setFileType(FileType ftype);
+
+ /**
+ * Sets the file type
+ *
+ * @param type The type of file
+ * @see #setFileType(FileType)
+ */
+ void setType(String type);
+
+ /**
+ * Returns the package through which this file was installed
+ *
+ * @return
+ */
+ Package getPackage();
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/Package.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/Package.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/Package.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,147 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata;
+
+import java.util.List;
+
+/**
+ * Represents the metadata for a package.
+ *
+ * A package represents a collection of files that are to be installed into
+ * the JBoss AS.
+ * A package can optionally have dependencies on other packages.
+ * A package can also optionally specify system requirements (example: A package might require a JBoss AS
+ * 5.1.0 version of the server)
+ * A package also has optional pre-install, post-install, pre-uninstall, post-uninstall scripts
+ *
+ * @author Jaikiran Pai
+ *
+ */
+public interface Package
+{
+
+ /**
+ * @return Returns the system requirements of this package
+ *
+ */
+ SystemRequirements getSystemRequirements();
+
+ /**
+ * Sets the system requirements of this package
+ *
+ * @param sysRequirements The system requirements for this package
+ *
+ */
+ void setSystemRequirements(SystemRequirements sysRequirements);
+
+ /**
+ * @return Returns the files that are to be installed for this package
+ *
+ */
+ List<InstallFile> getFiles();
+
+ /**
+ * Sets the files to be installed by the package
+ *
+ * @param files The files to be installed by the package
+ *
+ */
+ void setFiles(List<InstallFile> files);
+
+ /**
+ * Add a file to be installed, into the list of files to install
+ * through this package.
+ *
+ * @param file File to install
+ */
+ void addFile(InstallFile file);
+
+ /**
+ *
+ * @return Returns the dependencies of this package
+ */
+ Dependencies getDependencies();
+
+ /**
+ * Sets the dependencies of this package
+ *
+ * @param dependencies Dependencies of this package
+ *
+ */
+ void setDependencies(Dependencies deps);
+
+ /**
+ * @return Returns the name of this package
+ *
+ */
+ String getName();
+
+ /**
+ * Sets the name of this package
+ *
+ * @param name Package name
+ *
+ */
+ void setName(String name);
+
+ /**
+ * @return Returns the version of this package
+ *
+ */
+ String getVersion();
+
+ /**
+ * Sets the version of this package
+ *
+ * @param version Package version
+ *
+ */
+ void setVersion(String version);
+
+ /**
+ * Returns any pre-install metadata related to this package
+ *
+ * @return
+ */
+ PreInstall getPreInstall();
+
+ /**
+ * Sets the pre-install related metadata for this package
+ *
+ * @param preInstall Pre-install
+ */
+ void setPreInstall(PreInstall preInstall);
+
+ /**
+ * Returns any post-install metadata related to this package
+ *
+ * @return
+ */
+ PostInstall getPostInstall();
+
+ /**
+ * Sets the post-install related metadata for this package
+ *
+ * @param postInstall Post-install
+ */
+ void setPostInstall(PostInstall postInstall);
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/PackageInstallationPhase.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/PackageInstallationPhase.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/PackageInstallationPhase.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata;
+
+/**
+ * PackageInstallationPhase
+ *
+ * Represents a phase during package installation.
+ * Possible phases are pre-install and post-install
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public enum PackageInstallationPhase
+{
+ PRE_INSTALL,
+ POST_INSTALL
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/PostInstall.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/PostInstall.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/PostInstall.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,66 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata;
+
+import java.util.List;
+
+/**
+ * PostInstallMetadata
+ *
+ * Represents the metadata for the post-install element
+ * in a package.xml file
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface PostInstall
+{
+
+ /**
+ * Returns the list of post-install scripts for a package
+ *
+ * @return
+ */
+ List<Script> getScripts();
+
+ /**
+ * Sets the list of post-install scripts for a package
+ *
+ * @param scripts The post-install scripts
+ */
+ void setScripts(List<Script> scripts);
+
+ /**
+ * Adds a pre-install script to the list of post-install scripts
+ * for this package
+ * @param script
+ */
+ void addScript(Script script);
+
+ /**
+ * Returns the package to which this post-install step
+ * belongs to
+ * @return
+ */
+ Package getPackage();
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/PreInstall.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/PreInstall.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/PreInstall.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,68 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata;
+
+import java.util.List;
+
+/**
+ * PreInstallMetadata
+ *
+ * Represents the metadata for the pre-install element
+ * in a package.xml file
+ *
+ *
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface PreInstall
+{
+
+ /**
+ * Returns the list of pre-install scripts for a package
+ *
+ * @return
+ */
+ List<Script> getScripts();
+
+ /**
+ * Sets the list of pre-install scripts for a package
+ *
+ * @param scripts The pre-install scripts
+ */
+ void setScripts(List<Script> scripts);
+
+ /**
+ * Adds a pre-install script to the list of pre-install scripts
+ * for this package
+ * @param script
+ */
+ void addScript(Script script);
+
+ /**
+ * Returns the package to which this pre-install step
+ * belongs to
+ * @return
+ */
+ Package getPackage();
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/Script.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/Script.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/Script.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,76 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata;
+
+import org.jboss.ejb3.packagemanager.script.ScriptProcessor;
+
+/**
+ * ScriptMetadata
+ *
+ * Represents the metadata for a script element used in pre-install
+ * or post-install of a package.
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface Script
+{
+
+ /**
+ * Returns the file path (including the file name) relative to
+ * the location of the package.xml in the package
+ * @return
+ */
+ String getFile();
+
+ /**
+ * Sets the file path (including the name of the file)
+ *
+ * @param scriptFile Path relative to the location of package.xml in the package
+ */
+ void setFile(String scriptFile);
+
+ /**
+ * Returns the fully qualified name of the class which implements
+ * {@link ScriptProcessor} and is responsible for processing the
+ * {@link #getFile()} script file
+ * @return
+ */
+ String getProcessor();
+
+ /**
+ * Sets the script processor which is responsible for processing the
+ * {@link #getFile()} script file
+ *
+ * @param scriptProcessor Fully qualified name of the class which implements
+ * {@link ScriptProcessor}
+ */
+ void setProcessor(String scriptProcessor);
+
+ /**
+ * Returns the package installation phase, during which this script
+ * is expected to be executed
+ *
+ * @return
+ */
+ PackageInstallationPhase getScriptExecutionPhase();
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/SystemRequirements.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/SystemRequirements.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/SystemRequirements.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata;
+
+/**
+ * Represents the system requirements of a package being installed
+ * by package manager
+ *
+ *
+ */
+public interface SystemRequirements
+{
+ Package getPackage();
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/DependenciesImpl.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/DependenciesImpl.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/DependenciesImpl.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata.impl;
+
+import org.jboss.ejb3.packagemanager.metadata.Dependencies;
+import org.jboss.ejb3.packagemanager.metadata.Package;
+
+public class DependenciesImpl implements Dependencies
+{
+
+ /**
+ * The package to which this dependency metadata corresponds
+ */
+ private Package pkg;
+
+ /**
+ * Fully qualified class name of the dependencies manager
+ */
+ private String depManager;
+
+ /**
+ * The file containing the dependencies
+ */
+ private String file;
+
+ /**
+ * Constructor
+ * @param pkgMetadata The package to which this dependencies correspond
+ */
+ public DependenciesImpl(Package pkgMetadata)
+ {
+ this.pkg = pkgMetadata;
+ }
+
+ /**
+ * Returns the file path, which contains the dependency listing.
+ * The file path is relative to the location of package.xml in the package
+ */
+ public String getFile()
+ {
+ return file;
+ }
+
+ /**
+ * Sets the file path containing the dependency listing.
+ * The file path is relative to the location of package.xml in the package
+ */
+ public void setFile(String value)
+ {
+ this.file = value;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.Dependencies#getPackage()
+ */
+ public Package getPackage()
+ {
+ return this.pkg;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.Dependencies#getManager()
+ */
+ public String getManager()
+ {
+ return this.depManager;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.Dependencies#setManager(java.lang.String)
+ */
+ public void setManager(String depManager)
+ {
+ this.depManager = depManager;
+
+ }
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/InstallFileImpl.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/InstallFileImpl.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/InstallFileImpl.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata.impl;
+
+import org.jboss.ejb3.packagemanager.metadata.InstallFile;
+import org.jboss.ejb3.packagemanager.metadata.FileType;
+import org.jboss.ejb3.packagemanager.metadata.Package;
+
+public class InstallFileImpl implements InstallFile
+{
+
+ private Package pkg;
+
+ public InstallFileImpl(Package pkgMetadata)
+ {
+ if (pkgMetadata == null)
+ {
+ throw new IllegalArgumentException("File metadata cannot be constructed out of a null package metadata");
+ }
+ this.pkg = pkgMetadata;
+
+ }
+
+ protected String name;
+
+ protected String srcPath;
+
+ protected String destPath;
+
+ protected String type;
+
+ protected FileType fileType;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String value)
+ {
+ this.name = value;
+ }
+
+ public String getSrcPath()
+ {
+ return srcPath;
+ }
+
+ public void setSrcPath(String value)
+ {
+ this.srcPath = value;
+ }
+
+ public String getDestPath()
+ {
+ return destPath;
+ }
+
+ public void setDestPath(String value)
+ {
+ this.destPath = value;
+ }
+
+ public FileType getType()
+ {
+ return this.fileType;
+ }
+
+ public void setType(String ftype)
+ {
+
+ if (ftype == null)
+ {
+ return;
+ }
+
+ if (ftype.equals("config"))
+ {
+ this.setFileType(FileType.CONFIG);
+ }
+ else if (ftype.equals("library"))
+ {
+ this.setFileType(FileType.LIBRARY);
+ }
+ else if (ftype.equals("script"))
+ {
+ this.setFileType(FileType.SCRIPT);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unrecognized file type " + ftype);
+ }
+ this.type = ftype;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.InstallFile#setType(org.jboss.ejb3.packagemanager.metadata.FileType)
+ */
+ public void setFileType(FileType ftype)
+ {
+ this.fileType = ftype;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.InstallFile#getPackage()
+ */
+ public Package getPackage()
+ {
+ return this.pkg;
+ }
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PackageImpl.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PackageImpl.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PackageImpl.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.ejb3.packagemanager.metadata.Dependencies;
+import org.jboss.ejb3.packagemanager.metadata.InstallFile;
+import org.jboss.ejb3.packagemanager.metadata.Package;
+import org.jboss.ejb3.packagemanager.metadata.PostInstall;
+import org.jboss.ejb3.packagemanager.metadata.PreInstall;
+import org.jboss.ejb3.packagemanager.metadata.SystemRequirements;
+
+public class PackageImpl implements Package
+{
+
+ protected SystemRequirements systemRequirements;
+
+ protected List<InstallFile> files;
+
+ protected Dependencies dependencies;
+
+ protected String name;
+
+ protected String version;
+
+ /**
+ * Post-install for this package
+ */
+ protected PostInstall postInstall;
+
+ /**
+ * Pre-install for this package
+ */
+ protected PreInstall preInstall;
+
+ public PackageImpl()
+ {
+
+ }
+
+ public SystemRequirements getSystemRequirements()
+ {
+ return systemRequirements;
+ }
+
+ public void setSystemRequirements(SystemRequirements value)
+ {
+ this.systemRequirements = ((SystemRequirementsImpl) value);
+ }
+
+ public List<InstallFile> getFiles()
+ {
+ return this.files;
+ }
+
+ public void setFiles(List<InstallFile> files)
+ {
+ if (files == null || files.isEmpty())
+ {
+ throw new IllegalArgumentException("A package is expected to have atleast one file to install");
+ }
+ this.files = files;
+ }
+
+ public Dependencies getDependencies()
+ {
+ return dependencies;
+ }
+
+ public void setDependencies(Dependencies value)
+ {
+ this.dependencies = value;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String value)
+ {
+ this.name = value;
+ }
+
+ public String getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion(String value)
+ {
+ this.version = value;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.Package#addFile(org.jboss.ejb3.packagemanager.metadata.InstallFile)
+ */
+ public void addFile(InstallFile file)
+ {
+ if (file == null)
+ {
+ return;
+ }
+ if (this.files == null)
+ {
+ this.files = new ArrayList<InstallFile>();
+ }
+ this.files.add(file);
+
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.Package#getPostInstall()
+ */
+ public PostInstall getPostInstall()
+ {
+ return this.postInstall;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.Package#getPreInstall()
+ */
+ public PreInstall getPreInstall()
+ {
+ return this.preInstall;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.Package#setPostInstall(org.jboss.ejb3.packagemanager.metadata.PostInstall)
+ */
+ public void setPostInstall(PostInstall postInstall)
+ {
+ this.postInstall = postInstall;
+
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.Package#setPreInstall(org.jboss.ejb3.packagemanager.metadata.PreInstall)
+ */
+ public void setPreInstall(PreInstall preInstall)
+ {
+ this.preInstall = preInstall;
+
+ }
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PostInstallImpl.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PostInstallImpl.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PostInstallImpl.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,105 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.ejb3.packagemanager.metadata.Package;
+import org.jboss.ejb3.packagemanager.metadata.PostInstall;
+import org.jboss.ejb3.packagemanager.metadata.Script;
+
+/**
+ * PostInstallMetadataImpl
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class PostInstallImpl implements PostInstall
+{
+
+ /**
+ * The package to which this post-install belongs
+ */
+ private Package pkgMetadata;
+
+ /**
+ * post-install scripts
+ */
+ private List<Script> scripts;
+
+ /**
+ * Constructor
+ * @param pkgMeta The {@link Package} to which this post-install belongs
+ */
+ public PostInstallImpl(Package pkgMeta)
+ {
+ this.pkgMetadata = pkgMeta;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.PostInstall#addScript(org.jboss.ejb3.packagemanager.metadata.Script)
+ */
+ public void addScript(Script script)
+ {
+ if (script == null)
+ {
+ return;
+ }
+ if (this.scripts == null)
+ {
+ this.scripts = new ArrayList<Script>();
+ }
+ this.scripts.add(script);
+
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.PostInstall#getPackage()
+ */
+ public Package getPackage()
+ {
+ return this.pkgMetadata;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.PostInstall#getScripts()
+ */
+ public List<Script> getScripts()
+ {
+ return this.scripts;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.PostInstall#setScripts(java.util.List)
+ */
+ public void setScripts(List<Script> scripts)
+ {
+ if (scripts == null)
+ {
+ throw new IllegalArgumentException("post-install scripts cannot be set to null scripts");
+ }
+ this.scripts = scripts;
+
+ }
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PostInstallScript.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PostInstallScript.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PostInstallScript.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,73 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata.impl;
+
+import org.jboss.ejb3.packagemanager.metadata.PackageInstallationPhase;
+import org.jboss.ejb3.packagemanager.metadata.PostInstall;
+
+/**
+ * PostInstallScript
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class PostInstallScript extends ScriptImpl
+{
+
+ /**
+ * The post-install step to which this script
+ * belongs
+ */
+ private PostInstall postInstallMeta;
+
+ /**
+ * Constructor
+ *
+ * @param postInstallMeta The {@link PostInstall} to which this
+ * post-install script belongs to
+ */
+ public PostInstallScript(PostInstall postInstallMeta)
+ {
+ this.postInstallMeta = postInstallMeta;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.impl.ScriptImpl#getScriptExecutionPhase()
+ */
+ @Override
+ public PackageInstallationPhase getScriptExecutionPhase()
+ {
+ return PackageInstallationPhase.POST_INSTALL;
+ }
+
+ /**
+ * Returns the {@link PostInstall} to which this post-install script
+ * belongs to
+ *
+ * @return
+ */
+ public PostInstall getPostInstallMetadata()
+ {
+ return this.postInstallMeta;
+ }
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PreInstallImpl.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PreInstallImpl.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PreInstallImpl.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,104 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.ejb3.packagemanager.metadata.Package;
+import org.jboss.ejb3.packagemanager.metadata.PreInstall;
+import org.jboss.ejb3.packagemanager.metadata.Script;
+
+/**
+ * PreInstallMetadataImpl
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class PreInstallImpl implements PreInstall
+{
+
+ /**
+ * The package to which this pre-install belongs
+ */
+ private Package pkgMetadata;
+
+ /**
+ * pre-install scripts
+ */
+ private List<Script> scripts;
+
+ /**
+ * Constructor
+ * @param pkgMeta The {@link Package} to which this pre-install belongs
+ */
+ public PreInstallImpl(Package pkgMeta)
+ {
+ this.pkgMetadata = pkgMeta;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.PreInstall#addScript(org.jboss.ejb3.packagemanager.metadata.Script)
+ */
+ public void addScript(Script script)
+ {
+ if (script == null)
+ {
+ return;
+ }
+ if (this.scripts == null)
+ {
+ this.scripts = new ArrayList<Script>();
+ }
+ this.scripts.add(script);
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.PreInstall#getPackage()
+ */
+ public Package getPackage()
+ {
+ return this.pkgMetadata;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.PreInstall#getScripts()
+ */
+ public List<Script> getScripts()
+ {
+ return this.scripts;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.PreInstall#setScripts(java.util.List)
+ */
+ public void setScripts(List<Script> scripts)
+ {
+ if (scripts == null)
+ {
+ throw new IllegalArgumentException("pre-install scripts cannot be set to null scripts");
+ }
+ this.scripts = scripts;
+
+ }
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PreInstallScript.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PreInstallScript.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/PreInstallScript.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,72 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata.impl;
+
+import org.jboss.ejb3.packagemanager.metadata.PackageInstallationPhase;
+import org.jboss.ejb3.packagemanager.metadata.PreInstall;
+
+/**
+ * PreInstallScript
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class PreInstallScript extends ScriptImpl
+{
+ /**
+ * The pre-install step to which this script
+ * belongs
+ */
+ private PreInstall preInstallMeta;
+
+ /**
+ * Constructor
+ *
+ * @param preInstallMeta The {@link PreInstall} to which this
+ * pre-install script belongs to
+ */
+ public PreInstallScript(PreInstall preInstallMeta)
+ {
+ this.preInstallMeta = preInstallMeta;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.impl.ScriptImpl#getScriptExecutionPhase()
+ */
+ @Override
+ public PackageInstallationPhase getScriptExecutionPhase()
+ {
+ return PackageInstallationPhase.PRE_INSTALL;
+ }
+
+ /**
+ * Returns the {@link PreInstall} to which this pre-install script
+ * belongs to
+ *
+ * @return
+ */
+ public PreInstall getPreInstallMetadata()
+ {
+ return this.preInstallMeta;
+ }
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/ScriptImpl.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/ScriptImpl.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/ScriptImpl.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,88 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata.impl;
+
+import org.jboss.ejb3.packagemanager.metadata.PackageInstallationPhase;
+import org.jboss.ejb3.packagemanager.metadata.Script;
+
+/**
+ * ScriptMetadataImpl
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public abstract class ScriptImpl implements Script
+{
+
+ /**
+ * The script processor
+ */
+ private String scriptProcessor;
+
+ /**
+ * The script file
+ */
+ private String scriptFile;
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.Script#getFile()
+ */
+ public String getFile()
+ {
+ return this.scriptFile;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.Script#getProcessor()
+ */
+ public String getProcessor()
+ {
+ return this.scriptProcessor;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.Script#setFile(java.lang.String)
+ */
+ public void setFile(String scriptFile)
+ {
+ if (scriptFile == null)
+ {
+ throw new IllegalArgumentException("Script file value cannot be null");
+ }
+ this.scriptFile = scriptFile;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.Script#setProcessor(java.lang.String)
+ */
+ public void setProcessor(String scriptProcessor)
+ {
+ this.scriptProcessor = scriptProcessor;
+
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.Script#getScriptExecutionPhase()
+ */
+ public abstract PackageInstallationPhase getScriptExecutionPhase();
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/SystemRequirementsImpl.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/SystemRequirementsImpl.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/metadata/impl/SystemRequirementsImpl.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.metadata.impl;
+
+import org.jboss.ejb3.packagemanager.metadata.Package;
+import org.jboss.ejb3.packagemanager.metadata.SystemRequirements;
+
+public class SystemRequirementsImpl implements SystemRequirements
+{
+ private Package pkg;
+
+ public SystemRequirementsImpl(Package pkgMetadata)
+ {
+ this.pkg = pkgMetadata;
+ }
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.metadata.SystemRequirements#getPackage()
+ */
+ public Package getPackage()
+ {
+ return this.pkg;
+ }
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/PackageRetriever.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/PackageRetriever.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/PackageRetriever.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.retriever;
+
+import java.net.URL;
+
+import org.jboss.ejb3.packagemanager.PackageManager;
+import org.jboss.ejb3.packagemanager.PackageSource;
+import org.jboss.ejb3.packagemanager.exception.PackageRetrievalException;
+
+/**
+ * PackageRetriever
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface PackageRetriever
+{
+ PackageSource retrievePackage(PackageManager pkgMgr, URL packagePath) throws PackageRetrievalException;
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/impl/FileSystemPackageRetriever.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/impl/FileSystemPackageRetriever.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/impl/FileSystemPackageRetriever.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,93 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.retriever.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.jar.JarFile;
+
+import org.jboss.ejb3.packagemanager.PackageManager;
+import org.jboss.ejb3.packagemanager.PackageSource;
+import org.jboss.ejb3.packagemanager.exception.PackageRetrievalException;
+import org.jboss.ejb3.packagemanager.retriever.PackageRetriever;
+import org.jboss.ejb3.packagemanager.util.IOUtil;
+
+/**
+ * FileSystemPackageRetriever
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class FileSystemPackageRetriever implements PackageRetriever
+{
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.retriever.PackageRetriever#retrievePackage(org.jboss.ejb3.packagemanager.PackageManager, java.net.URL)
+ */
+ public PackageSource retrievePackage(PackageManager pkgMgr, URL packagePathURL) throws PackageRetrievalException
+ {
+ if (packagePathURL == null)
+ {
+ throw new PackageRetrievalException("Invalid url " + packagePathURL);
+ }
+ if (!packagePathURL.getProtocol().equals("file"))
+ {
+ throw new PackageRetrievalException(FileSystemPackageRetriever.class
+ + " can only retrieve package from a file: URL. It can't handle " + packagePathURL);
+ }
+ File pkg = new File(packagePathURL.getFile());
+ // TODO: There should be a better way to check for a jar file
+ if (!pkg.getName().endsWith(".jar"))
+ {
+ throw new PackageRetrievalException("File system package retriever can handle only .jar package files. " + pkg
+ + " is not a .jar file");
+ }
+ if (!pkg.exists())
+ {
+ throw new PackageRetrievalException("Package file " + pkg + " does not exist");
+ }
+ try
+ {
+ // the directory to which the package will be extracted
+ File extractedPkgDir = new File(pkgMgr.getPackageManagerEnvironment().getPackageManagerBuildDir(), pkg.getName());
+ if (!extractedPkgDir.exists())
+ {
+ extractedPkgDir.mkdirs();
+ }
+ JarFile jar = new JarFile(pkg);
+ IOUtil.extractJarFile(extractedPkgDir, jar);
+ // validate that it contains a package.xml
+ File packageXml = new File(extractedPkgDir, "package.xml");
+ if (!packageXml.exists())
+ {
+ throw new PackageRetrievalException(pkg + " is not a valid package - it does not contain a package.xml");
+ }
+ return new PackageSource(extractedPkgDir);
+ }
+ catch (IOException ioe)
+ {
+ throw new PackageRetrievalException("Error while processing package file " + pkg, ioe);
+ }
+ }
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/impl/HttpPackageRetriever.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/impl/HttpPackageRetriever.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/impl/HttpPackageRetriever.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,138 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.retriever.impl;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.jar.JarFile;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.jboss.ejb3.packagemanager.PackageManager;
+import org.jboss.ejb3.packagemanager.PackageSource;
+import org.jboss.ejb3.packagemanager.exception.PackageRetrievalException;
+import org.jboss.ejb3.packagemanager.retriever.PackageRetriever;
+import org.jboss.ejb3.packagemanager.util.IOUtil;
+
+/**
+ * HttpPackageRetriever
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class HttpPackageRetriever implements PackageRetriever
+{
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.retriever.PackageRetriever#retrievePackage(PackageManager, URL)
+ */
+ public PackageSource retrievePackage(PackageManager pkgMgr, URL packagePath) throws PackageRetrievalException
+ {
+ if (!packagePath.getProtocol().equals("http"))
+ {
+ throw new PackageRetrievalException("Cannot handle " + packagePath);
+ }
+ HttpClient httpClient = new DefaultHttpClient();
+ HttpGet httpGet = new HttpGet(packagePath.toExternalForm());
+ HttpResponse httpResponse = null;
+ try
+ {
+ httpResponse = httpClient.execute(httpGet);
+ }
+ catch (Exception e)
+ {
+ throw new PackageRetrievalException("Exception while retrieving package " + packagePath, e);
+ }
+ if (httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK)
+ {
+ throw new PackageRetrievalException("Http retrieval wasn't successful, returned status code " + httpResponse.getStatusLine().getStatusCode());
+ }
+ HttpEntity httpEntity = httpResponse.getEntity();
+
+ try
+ {
+ // TODO: should this tmp be deleted on exit?
+ File tmpPkgFile = File.createTempFile("tmp", ".jar", pkgMgr.getPackageManagerEnvironment().getPackageManagerTmpDir());
+ FileOutputStream fos = new FileOutputStream(tmpPkgFile);
+ BufferedOutputStream bos = null;
+ BufferedInputStream bis = null;
+ try
+ {
+ bos = new BufferedOutputStream(fos);
+ InputStream is = httpEntity.getContent();
+ bis = new BufferedInputStream(is);
+ byte[] content = new byte[4096];
+ int length;
+ while ((length = bis.read(content)) != -1)
+ {
+ bos.write(content, 0, length);
+ }
+ bos.flush();
+ }
+ finally
+ {
+ if (bos != null)
+ {
+ bos.close();
+ }
+ if (bis != null)
+ {
+ bis.close();
+ }
+ }
+
+ // package has been retrieved to tmp location, now unpack it to a subfolder in package-manager build folder
+ File extractedPackageDir = new File(pkgMgr.getPackageManagerEnvironment().getPackageManagerBuildDir(), tmpPkgFile
+ .getName());
+ if (!extractedPackageDir.exists())
+ {
+ extractedPackageDir.mkdirs();
+ }
+
+ IOUtil.extractJarFile(extractedPackageDir, new JarFile(tmpPkgFile));
+ // validate that it contains a package.xml
+ File packageXml = new File(extractedPackageDir, "package.xml");
+ if (!packageXml.exists())
+ {
+ throw new PackageRetrievalException(packagePath + " is not a valid package - it does not contain a package.xml");
+ }
+ // create a package source out of this
+ return new PackageSource(extractedPackageDir);
+ }
+ catch (IOException ioe)
+ {
+ throw new PackageRetrievalException("Could not process the retrieved package", ioe);
+ }
+ // TODO: I need to read the HttpClient 4.x javadocs to figure out the API for closing the
+ // Http connection
+
+ }
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/impl/PackageRetrievalFactory.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/impl/PackageRetrievalFactory.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/retriever/impl/PackageRetrievalFactory.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.retriever.impl;
+
+import java.net.URL;
+
+import org.jboss.ejb3.packagemanager.retriever.PackageRetriever;
+import org.jboss.logging.Logger;
+
+/**
+ * PackageRetrievalFactory
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class PackageRetrievalFactory
+{
+
+ /**
+ * Logger
+ */
+ private static Logger logger = Logger.getLogger(PackageRetrievalFactory.class);
+
+ /**
+ *
+ * @param packagePath
+ * @return
+ */
+ public static PackageRetriever getPackageRetriever(URL packagePath)
+ {
+ if (packagePath.getProtocol().equals("file"))
+ {
+ return new FileSystemPackageRetriever();
+ }
+ else if (packagePath.getProtocol().equals("http"))
+ {
+ return new HttpPackageRetriever();
+ }
+ else
+ {
+ throw new RuntimeException("Only file: and http: protocols are supported for package retrievers");
+ }
+ }
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/script/ScriptProcessor.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/script/ScriptProcessor.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/script/ScriptProcessor.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.script;
+
+import org.jboss.ejb3.packagemanager.PackageManager;
+import org.jboss.ejb3.packagemanager.PackageSource;
+import org.jboss.ejb3.packagemanager.exception.ScriptProcessingException;
+import org.jboss.ejb3.packagemanager.metadata.Script;
+
+/**
+ * ScriptProcessor
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface ScriptProcessor
+{
+
+ void processScript(PackageManager pkgManager, PackageSource pkgSource, Script script) throws ScriptProcessingException;
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/script/impl/AntScriptProcessor.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/script/impl/AntScriptProcessor.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/script/impl/AntScriptProcessor.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,216 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.script.impl;
+
+import java.io.File;
+
+import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+import org.jboss.ejb3.packagemanager.PackageManager;
+import org.jboss.ejb3.packagemanager.PackageSource;
+import org.jboss.ejb3.packagemanager.exception.ScriptProcessingException;
+import org.jboss.ejb3.packagemanager.metadata.PackageInstallationPhase;
+import org.jboss.ejb3.packagemanager.metadata.Script;
+import org.jboss.ejb3.packagemanager.script.ScriptProcessor;
+import org.jboss.logging.Logger;
+
+/**
+ * AntScriptProcessor
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class AntScriptProcessor implements ScriptProcessor
+{
+
+ /**
+ * Logger
+ */
+ private static Logger logger = Logger.getLogger(AntScriptProcessor.class);
+
+ /**
+ * @see org.jboss.ejb3.packagemanager.script.ScriptProcessor#processScript(org.jboss.ejb3.packagemanager.PackageSource, org.jboss.ejb3.packagemanager.metadata.Script)
+ */
+ public void processScript(PackageManager pkgManager, PackageSource pkgSource, Script script)
+ throws ScriptProcessingException
+ {
+ File root = pkgSource.getSource();
+ File antBuildFile = new File(root, script.getFile());
+ if (!antBuildFile.exists())
+ {
+ throw new ScriptProcessingException("Ant script " + script.getFile() + " does not exist in " + pkgSource);
+ }
+ Project antProject = new Project();
+ // add our build listener to capture ant logging and other stuff
+ antProject.addBuildListener(new AntBuildListener());
+ // Set the basedir for the ant project to point to the
+ // root of the package.xml file of the package being installed
+ antProject.setBaseDir(pkgSource.getSource());
+ // Also set the properties JBOSS_HOME and PM_HOME for the
+ // build scripts to use (if they find it necessary)
+ antProject.setProperty("JBOSS_HOME", pkgManager.getServerHome());
+ antProject.setProperty("PM_HOME",pkgManager.getPackageManagerEnvironment().getPackageManagerHome().getAbsolutePath());
+ // init the project
+ antProject.init();
+
+ ProjectHelper antProjHelper = ProjectHelper.getProjectHelper();
+ // parse the project from the build file
+ antProjHelper.parse(antProject, antBuildFile);
+
+ // now run the appropriate target
+ String targetName = null;
+ PackageInstallationPhase phase = script.getScriptExecutionPhase();
+ if (phase == PackageInstallationPhase.PRE_INSTALL)
+ {
+ targetName = "pre-install";
+ }
+ else if (phase == PackageInstallationPhase.POST_INSTALL)
+ {
+ targetName = "post-install";
+ }
+ else
+ {
+ throw new ScriptProcessingException(
+ "Ant script processor is only capable of running pre-install or post-install scripts. It cannot handle "
+ + phase + " for script " + script);
+ }
+ // check whether the target exists in the build file
+ if (!antProject.getTargets().containsKey(targetName))
+ {
+ throw new ScriptProcessingException("Target " + targetName + " not present in Ant script " + antBuildFile
+ + " for " + pkgSource);
+ }
+ logger.info("Running pre-install script " + antBuildFile + " ,target= " + targetName + " for " + pkgSource);
+ try
+ {
+ antProject.executeTarget(targetName);
+ }
+ catch (Exception e)
+ {
+ throw new ScriptProcessingException("Exception while running target " + targetName + " in script "
+ + antBuildFile + " for " + pkgSource);
+ }
+
+ }
+
+ private class AntBuildListener implements BuildListener
+ {
+ /**
+ *
+ */
+ public AntBuildListener()
+ {
+
+ }
+
+ /**
+ * @see org.apache.tools.ant.BuildListener#buildFinished(org.apache.tools.ant.BuildEvent)
+ */
+ public void buildFinished(BuildEvent buildEvent)
+ {
+
+ }
+
+ /**
+ * @see org.apache.tools.ant.BuildListener#buildStarted(org.apache.tools.ant.BuildEvent)
+ */
+ public void buildStarted(BuildEvent buildEvent)
+ {
+
+ }
+
+ /**
+ * @see org.apache.tools.ant.BuildListener#messageLogged(org.apache.tools.ant.BuildEvent)
+ */
+ public void messageLogged(BuildEvent buildEvent)
+ {
+
+ int logLevel = buildEvent.getPriority();
+ switch (logLevel)
+ {
+ case Project.MSG_VERBOSE :
+ logger.trace(buildEvent.getMessage());
+ break;
+ case Project.MSG_DEBUG :
+ logger.debug(buildEvent.getMessage());
+ break;
+ case Project.MSG_INFO :
+ logger.info(buildEvent.getMessage());
+ break;
+ case Project.MSG_WARN :
+ logger.warn(buildEvent.getMessage());
+ break;
+ case Project.MSG_ERR :
+ logger.error(buildEvent.getMessage());
+ break;
+ default :
+ logger.debug(buildEvent.getMessage());
+
+ }
+
+ }
+
+ /**
+ * @see org.apache.tools.ant.BuildListener#targetFinished(org.apache.tools.ant.BuildEvent)
+ */
+ public void targetFinished(BuildEvent buildEvent)
+ {
+ Throwable failure = buildEvent.getException();
+ if (failure != null)
+ {
+ logger.error(buildEvent.getTarget() + " failed", failure);
+ }
+ else
+ {
+ logger.info(buildEvent.getTarget() + " completed successfully");
+ }
+
+ }
+
+ /**
+ * @see org.apache.tools.ant.BuildListener#targetStarted(org.apache.tools.ant.BuildEvent)
+ */
+ public void targetStarted(BuildEvent buildEvent)
+ {
+
+ }
+
+ /**
+ * @see org.apache.tools.ant.BuildListener#taskFinished(org.apache.tools.ant.BuildEvent)
+ */
+ public void taskFinished(BuildEvent buildEvent)
+ {
+
+ }
+
+ /**
+ * @see org.apache.tools.ant.BuildListener#taskStarted(org.apache.tools.ant.BuildEvent)
+ */
+ public void taskStarted(BuildEvent buildEvent)
+ {
+
+ }
+ }
+
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/util/IOUtil.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/util/IOUtil.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/util/IOUtil.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import org.apache.commons.io.IOUtils;
+
+/**
+ * IOUtil
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class IOUtil
+{
+ public static void copy(File src, File dest) throws IOException
+ {
+ FileInputStream fis = new FileInputStream(src);
+ FileOutputStream fos = new FileOutputStream(dest);
+ IOUtils.copy(fis, fos);
+ }
+
+ public static void extractJarFile(File destDir, JarFile jar) throws IOException
+ {
+ if (!destDir.exists())
+ {
+ destDir.mkdirs();
+ }
+ Enumeration<JarEntry> jarEntries = jar.entries();
+ while (jarEntries.hasMoreElements())
+ {
+ JarEntry entry = jarEntries.nextElement();
+ File destFile = new File(destDir, entry.getName());
+ if (entry.isDirectory())
+ { // if its a directory, create it
+ destFile.mkdirs();
+ continue;
+ }
+ else
+ {
+ // if this is a file and not a directory, make
+ // sure that it's parent directories have been
+ // created. Remember, while iterating the entries
+ // in a jar file, it's not guaranteed that the directories will be
+ // processed first and then the file. So we need to check if the file's
+ // parent directories exist
+ File parentDir = destFile.getParentFile();
+ if (!parentDir.exists())
+ {
+ parentDir.mkdirs();
+ }
+ }
+
+ java.io.InputStream is = null;
+ java.io.FileOutputStream fos = null;
+
+ try
+ {
+ is = jar.getInputStream(entry); // get the input stream
+ fos = new java.io.FileOutputStream(destFile);
+ while (is.available() > 0)
+ { // write contents of 'is' to 'fos'
+ fos.write(is.read());
+ }
+ }
+ finally
+ {
+ if (fos != null)
+ {
+ fos.close();
+ }
+ if (is != null)
+ {
+ is.close();
+ }
+ }
+
+ }
+
+ }
+}
Added: projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/xml/PackageUnmarshaller.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/xml/PackageUnmarshaller.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/java/org/jboss/ejb3/packagemanager/xml/PackageUnmarshaller.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,357 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.xml;
+
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.events.XMLEvent;
+
+import org.codehaus.stax2.XMLInputFactory2;
+import org.codehaus.stax2.XMLStreamReader2;
+import org.codehaus.stax2.validation.XMLValidationSchema;
+import org.codehaus.stax2.validation.XMLValidationSchemaFactory;
+import org.jboss.ejb3.packagemanager.metadata.Dependencies;
+import org.jboss.ejb3.packagemanager.metadata.InstallFile;
+import org.jboss.ejb3.packagemanager.metadata.Package;
+import org.jboss.ejb3.packagemanager.metadata.PostInstall;
+import org.jboss.ejb3.packagemanager.metadata.PreInstall;
+import org.jboss.ejb3.packagemanager.metadata.Script;
+import org.jboss.ejb3.packagemanager.metadata.SystemRequirements;
+import org.jboss.ejb3.packagemanager.metadata.impl.InstallFileImpl;
+import org.jboss.ejb3.packagemanager.metadata.impl.PackageImpl;
+import org.jboss.ejb3.packagemanager.metadata.impl.PostInstallImpl;
+import org.jboss.ejb3.packagemanager.metadata.impl.PostInstallScript;
+import org.jboss.ejb3.packagemanager.metadata.impl.PreInstallImpl;
+import org.jboss.ejb3.packagemanager.metadata.impl.PreInstallScript;
+
+/**
+ * PackageXMLParser
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class PackageUnmarshaller
+{
+
+ /**
+ * Creates {@link Package} out of the URL pointing to a package.xml file
+ *
+ * @param packageXml package.xml URL
+ * @return Returns the {@link Package} corresponding to the package.xml
+ * @throws Exception If any exceptions occur during processing the package.xml
+ */
+ public Package unmarshal(URL packageXml) throws Exception
+ {
+
+
+ XMLInputFactory2 xmlFactory = (XMLInputFactory2) XMLInputFactory2.newInstance();
+ XMLStreamReader2 xmlStreamReader = (XMLStreamReader2) xmlFactory.createXMLStreamReader(packageXml.openStream());
+
+ // create a validator for the package.xml
+ XMLValidationSchemaFactory validationSchemaFactory = XMLValidationSchemaFactory
+ .newInstance(XMLValidationSchema.SCHEMA_ID_W3C_SCHEMA);
+ // TODO: Is this good enough to get hold of package.xsd? Need to think about this.
+ URL packageXsd = Thread.currentThread().getContextClassLoader().getResource("package.xsd");
+ XMLValidationSchema schema = validationSchemaFactory.createSchema(packageXsd);;
+ // enable validation (note: validation will happen during parse)
+ xmlStreamReader.validateAgainst(schema);
+
+ // parse the xml
+ Package pkgMetadata = null;
+ while (xmlStreamReader.hasNext())
+ {
+ int event = xmlStreamReader.next();
+ if (event == XMLEvent.START_ELEMENT && xmlStreamReader.getLocalName().equals("package"))
+ {
+ pkgMetadata = processPackage(xmlStreamReader);
+ }
+ }
+ return pkgMetadata;
+ }
+
+ private Package processPackage(XMLStreamReader2 xmlStreamReader) throws Exception
+ {
+ Package pkgMeta = new PackageImpl();
+ for (int i = 0; i < xmlStreamReader.getAttributeCount(); i++)
+ {
+ String name = xmlStreamReader.getAttributeLocalName(i);
+ if ("name".equals(name))
+ {
+ pkgMeta.setName(xmlStreamReader.getAttributeValue(i));
+ }
+ else if ("version".equals(name))
+ {
+ pkgMeta.setVersion(xmlStreamReader.getAttributeValue(i));
+ }
+
+ }
+ int event = xmlStreamReader.next();
+ while (event != XMLEvent.END_ELEMENT)
+ {
+ switch (event)
+ {
+ case XMLEvent.START_ELEMENT :
+ String childElement = xmlStreamReader.getLocalName();
+ if (childElement.equals("system-requirements"))
+ {
+ SystemRequirements sysReqs = processSystemRequirements(pkgMeta, xmlStreamReader);
+ pkgMeta.setSystemRequirements(sysReqs);
+ }
+ else if (childElement.equals("file"))
+ {
+ InstallFile file = processFiles(pkgMeta, xmlStreamReader);
+ pkgMeta.addFile(file);
+ }
+ else if (childElement.equals("pre-install"))
+ {
+ PreInstall preInstall = processPreInstall(pkgMeta, xmlStreamReader);
+ pkgMeta.setPreInstall(preInstall);
+ }
+ else if (childElement.equals("post-install"))
+ {
+ PostInstall postInstall = processPostInstall(pkgMeta, xmlStreamReader);
+ pkgMeta.setPostInstall(postInstall);
+ }
+ else if (childElement.equals("dependencies"))
+ {
+ this.processDependencies(pkgMeta, xmlStreamReader);
+ }
+ break;
+
+ }
+ event = xmlStreamReader.next();
+ }
+ return pkgMeta;
+
+ }
+
+ /**
+ *
+ * @param pkgMeta
+ * @param xmlStreamReader
+ * @return
+ * @throws Exception
+ */
+ private SystemRequirements processSystemRequirements(Package pkgMeta,
+ XMLStreamReader2 xmlStreamReader) throws Exception
+ {
+ // TODO Implement
+ int event = xmlStreamReader.next();
+ while (event != XMLEvent.END_ELEMENT)
+ {
+ event = xmlStreamReader.next();
+
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param pkgMeta
+ * @param xmlStreamReader
+ * @return
+ * @throws Exception
+ */
+ private InstallFile processFiles(Package pkgMeta, XMLStreamReader2 xmlStreamReader) throws Exception
+ {
+ InstallFile fileMeta = new InstallFileImpl(pkgMeta);
+ for (int i = 0; i < xmlStreamReader.getAttributeCount(); i++)
+ {
+ String name = xmlStreamReader.getAttributeLocalName(i);
+ if ("src-path".equals(name))
+ {
+ fileMeta.setSrcPath(xmlStreamReader.getAttributeValue(i));
+ }
+ else if ("name".equals(name))
+ {
+ fileMeta.setName(xmlStreamReader.getAttributeValue(i));
+ }
+ else if ("dest-path".equals(name))
+ {
+ fileMeta.setDestPath(xmlStreamReader.getAttributeValue(i));
+ }
+ else if ("type".equals(name))
+ {
+ fileMeta.setType(xmlStreamReader.getAttributeValue(i));
+ }
+
+ }
+ // consume the end event of file
+ int event = xmlStreamReader.next();
+ while (event != XMLEvent.END_ELEMENT)
+ {
+ event = xmlStreamReader.next();
+
+ }
+
+ return fileMeta;
+ }
+
+ /**
+ *
+ * @param pkgMeta
+ * @param xmlStreamReader
+ * @return
+ * @throws Exception
+ */
+ private PreInstall processPreInstall(Package pkgMeta, XMLStreamReader2 xmlStreamReader)
+ throws Exception
+ {
+ PreInstall preInstall = new PreInstallImpl(pkgMeta);
+ int event = xmlStreamReader.next();
+ while (event != XMLEvent.END_ELEMENT)
+ {
+ switch (event)
+ {
+ case XMLEvent.START_ELEMENT :
+ String childElement = xmlStreamReader.getLocalName();
+ if (childElement.equals("script"))
+ {
+ Script script = processPreInstallScript(preInstall, xmlStreamReader);
+ preInstall.addScript(script);
+ }
+ break;
+ }
+ event = xmlStreamReader.next();
+ }
+ return preInstall;
+ }
+
+ /**
+ *
+ * @param pkgMeta
+ * @param xmlStreamReader
+ * @return
+ * @throws Exception
+ */
+ private PostInstall processPostInstall(Package pkgMeta, XMLStreamReader2 xmlStreamReader)
+ throws Exception
+ {
+ PostInstall postInstall = new PostInstallImpl(pkgMeta);
+ int event = xmlStreamReader.next();
+ while (event != XMLEvent.END_ELEMENT)
+ {
+ switch (event)
+ {
+ case XMLEvent.START_ELEMENT :
+ String childElement = xmlStreamReader.getLocalName();
+ if (childElement.equals("script"))
+ {
+ Script script = processPostInstallScript(postInstall, xmlStreamReader);
+ postInstall.addScript(script);
+ }
+ break;
+ }
+ event = xmlStreamReader.next();
+ }
+ return postInstall;
+ }
+
+ /**
+ *
+ * @param preInstallMeta
+ * @param xmlStreamReader
+ * @return
+ * @throws Exception
+ */
+ private PreInstallScript processPreInstallScript(PreInstall preInstallMeta, XMLStreamReader2 xmlStreamReader)
+ throws Exception
+ {
+ PreInstallScript preInstallScript = new PreInstallScript(preInstallMeta);
+ processScript(preInstallScript, xmlStreamReader);
+ return preInstallScript;
+ }
+
+ /**
+ *
+ * @param preInstallMeta
+ * @param xmlStreamReader
+ * @return
+ * @throws Exception
+ */
+ private PostInstallScript processPostInstallScript(PostInstall postInstallMeta,
+ XMLStreamReader2 xmlStreamReader) throws Exception
+ {
+ PostInstallScript postInstallScript = new PostInstallScript(postInstallMeta);
+ processScript(postInstallScript, xmlStreamReader);
+ return postInstallScript;
+ }
+
+ /**
+ *
+ * @param xmlStreamReader
+ * @return
+ */
+ private Script processScript(Script script, XMLStreamReader2 xmlStreamReader) throws Exception
+ {
+
+ for (int i = 0; i < xmlStreamReader.getAttributeCount(); i++)
+ {
+ String name = xmlStreamReader.getAttributeLocalName(i);
+ if ("file".equals(name))
+ {
+ script.setFile(xmlStreamReader.getAttributeValue(i));
+ }
+ else if ("processor".equals(name))
+ {
+ script.setProcessor(xmlStreamReader.getAttributeValue(i));
+ }
+
+ }
+ // consume the end event of file
+ int event = xmlStreamReader.next();
+ while (event != XMLEvent.END_ELEMENT)
+ {
+ event = xmlStreamReader.next();
+
+ }
+
+ return script;
+ }
+
+ private Dependencies processDependencies(Package pkgMetadata, XMLStreamReader2 xmlStreamReader) throws Exception
+ {
+ Dependencies depMetadata = null;
+// for (int i = 0; i < xmlStreamReader.getAttributeCount(); i++)
+// {
+// String name = xmlStreamReader.getAttributeLocalName(i);
+// if ("file".equals(name))
+// {
+// script.setFile(xmlStreamReader.getAttributeValue(i));
+// }
+// else if ("processor".equals(name))
+// {
+// script.setProcessor(xmlStreamReader.getAttributeValue(i));
+// }
+//
+// }
+ // consume the end event of file
+ int event = xmlStreamReader.next();
+ while (event != XMLEvent.END_ELEMENT)
+ {
+ event = xmlStreamReader.next();
+
+ }
+ return depMetadata;
+ }
+}
Added: projects/ejb3/trunk/package-manager/src/main/resources/log4j.xml
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/resources/log4j.xml (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/resources/log4j.xml 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml 68671 2008-01-08 10:04:25Z wolfc $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <param name="File" value="target/test.log"/>
+ <param name="Threshold" value="INFO"/>
+ <param name="Append" value="false"/>
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <category name="org.jboss">
+ <priority value="INFO"/>
+ </category>
+
+ <category name="org.jboss.ejb3">
+ <priority value="ALL"/>
+ </category>
+
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Added: projects/ejb3/trunk/package-manager/src/main/resources/package.xsd
===================================================================
--- projects/ejb3/trunk/package-manager/src/main/resources/package.xsd (rev 0)
+++ projects/ejb3/trunk/package-manager/src/main/resources/package.xsd 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2005, JBoss Inc., 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.
+ -->
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.jboss.org/schema"
+ xmlns:jboss="http://www.jboss.org/schema">
+
+ <xs:element name="package" type="jboss:packageType">
+ <xs:annotation>
+ <xs:documentation>
+ A package represents a collection of files that are to be installed into
+ the JBoss AS.
+ A package can optionally have dependencies on other packages.
+ A package can also optionally specify system requirements (example: A package might require a JBoss AS
+ 5.1.0 version of the server)
+ A package also has optional pre-install, post-install, pre-uninstall, post-uninstall scripts
+
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+
+ <xs:complexType name="packageType">
+
+ <xs:sequence>
+ <xs:element name="system-requirements" minOccurs="0" maxOccurs="1" type="jboss:system-requirementsType"/>
+ <xs:element name="file" minOccurs="1" maxOccurs="unbounded" type="jboss:fileType"/>
+ <xs:element name="dependencies" minOccurs="0" maxOccurs="1" type="jboss:dependenciesType"/>
+ <xs:element name="pre-install" minOccurs="0" maxOccurs="1" type="jboss:pre-installType"/>
+ <xs:element name="post-install" minOccurs="0" maxOccurs="1" type="jboss:post-installType"/>
+ </xs:sequence>
+ <xs:attribute name="name" use="required" type="xs:string"/>
+ <xs:attribute name="version" use="required" type="xs:string"/>
+ </xs:complexType>
+
+ <xs:complexType name="system-requirementsType">
+
+ </xs:complexType>
+
+ <xs:complexType name="fileType">
+ <xs:annotation>
+ <xs:documentation>
+ A file element contains the information of the source and destination of the file to be installed.
+ The src-path of the file is always relative to the location of the package.xml within a package.
+ The dest-path of the file is always relative to the JBoss AS server home (JBOSS_HOME).
+ A file can be of type library or config or script file.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="src-path" type="xs:string" use="optional"/>
+ <xs:attribute name="dest-path" type="xs:string" use="required"/>
+ <xs:attribute name="type" use="optional">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="config"/>
+ <xs:enumeration value="library"/>
+ <xs:enumeration value="script"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:complexType>
+
+ <xs:complexType name="dependenciesType">
+ <xs:annotation>
+ <xs:documentation>
+ A package can have dependencies on other packages. Dependencies are configured in
+ separate files. The dependencies element just points to that file. The file path is
+ relative to the location of the package.xml within a package.
+ Optionally a dependency manager can be specified through the
+ "manager" attribute. The manager attribute should contain the fully qualified class name
+ of the dependency manager which is responsible for parsing the dependencies file and
+ managing the dependencies listed in that file. The class should implement the
+ org.jboss.ejb3.packagemanager.dependency.DependencyManager interface.
+ By default, org.jboss.ejb3.packagemanager.dependency.impl.IvyDependencyManager will be
+ used as the dependency manager.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:attribute name="file" type="xs:string" use="required"/>
+ <xs:attribute name="manager" type="xs:string" use="optional"
+ default="org.jboss.ejb3.packagemanager.dependency.impl.IvyDependencyManager"/>
+ </xs:complexType>
+
+
+ <xs:complexType name="pre-installType">
+ <xs:annotation>
+ <xs:documentation>
+ A pre-install element is used to point to pre-install scripts that
+ are to be run before installing the package. There can be any number
+ of pre-install scripts and they will be run in the same order as
+ they appear in the xml
+ </xs:documentation>
+
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="script" minOccurs="1" maxOccurs="unbounded" type="jboss:scriptType"/>
+ </xs:sequence>
+
+ </xs:complexType>
+
+ <xs:complexType name="post-installType">
+ <xs:annotation>
+ <xs:documentation>
+ A post-install element is used to point to post-install scripts that
+ are to be run after installing the package. There can be any number
+ of post-install scripts and they will be run in the same order as
+ they appear in the xml
+ </xs:documentation>
+
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="script" minOccurs="1" maxOccurs="unbounded" type="jboss:scriptType"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="scriptType">
+ <xs:annotation>
+ <xs:documentation>
+ A script element points to a file containing a script.
+ The file attribute of this element should contain the path of the script, relative to the location of
+ package.xml in the package.
+ The processor attribute of a script can be used to specify the fully qualified name of the
+ class which implements the org.jboss.ejb3.packagemanager.script.ScriptProcessor interface.
+ By default the processor of a script is the Ant processor
+ (org.jboss.ejb3.packagemanager.script.impl.AntScriptProcessor) which processes Ant build script
+
+ </xs:documentation>
+
+ </xs:annotation>
+ <xs:attribute name="file" type="xs:string" use="required"/>
+ <xs:attribute name="processor" type="xs:string" use="optional"
+ default="org.jboss.ejb3.packagemanager.script.impl.AntScriptProcessor"/>
+ </xs:complexType>
+
+</xs:schema>
\ No newline at end of file
Added: projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/common/Dummy.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/common/Dummy.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/common/Dummy.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.test.common;
+
+/**
+ * Dummy
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class Dummy
+{
+
+}
Added: projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/common/PackageManagerTestCase.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/common/PackageManagerTestCase.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/common/PackageManagerTestCase.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,226 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.test.common;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.shrinkwrap.api.export.ZipExporter;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+/**
+ * PackageManagerTestCase
+ *
+ * Common utility methods for testcases involving package-manager
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public abstract class PackageManagerTestCase
+{
+
+ /**
+ * Base dir
+ */
+ protected static File baseDir = new File(System.getProperty("basedir"));
+
+ /**
+ * The project's target dir
+ */
+ protected static File targetDir = new File(baseDir, "target");
+
+ /**
+ * Sets up an dummy JBoss instance and returns the File corresponding
+ * to this JBoss instance. This "JBoss instance" will just be a directory
+ * structure similar to the JBoss AS-5 directory structure and can be
+ * used for testing the package manager functionalities without having
+ * to download/setup a real JBoss instance
+ *
+ * @return Returns the File corresponding to the (dummy) JBOSS_HOME
+ * @throws IOException If there are any IO exceptions during creation of the
+ * JBoss AS directory structure
+ */
+ protected static File setupDummyJBoss() throws IOException
+ {
+ File dummyJBossHome = new File(targetDir, "jboss-as");
+ dummyJBossHome.mkdirs();
+ createJBossDirectoryStructure(dummyJBossHome);
+ return dummyJBossHome;
+
+ }
+
+ /**
+ * Sets up a "home" for the package manager within the project's
+ * "target" folder. Returns the File corresponding to this
+ * home folder of the package manager. This can be used
+ * within package manager tests
+ *
+ * @return Returns the File corresponding to the package manager home
+ * @throws IOException
+ */
+ protected static File setupPackageManagerHome() throws IOException
+ {
+ File pkgMgrHome = new File(targetDir, "pm-home");
+ pkgMgrHome.mkdirs();
+ return pkgMgrHome;
+ }
+
+ /**
+ * Returns the URLs to the {@code resources}. The resources are looked
+ * under {@code klass}'s package name. For example, if the
+ * klass is org.jboss.ejb3.packagemanager.test.install.unit.BasicInstallTestCase and the
+ * resource name is package.xml, then this method looks for package.xml under
+ * org/jboss/ejb3/packagemanager/test/install/unit in the classpath.
+ *
+ * Note: The list returned by the method could contain null elements if the
+ * corresponding resource wasn't found in the classpath.
+ *
+ * @param klass The Class under whose package the resources are searched for
+ * @param resources The name of the resources
+ * @return Returns a list of resource URLs
+ */
+ protected List<URL> getResources(Class<?> klass, String... resources)
+ {
+ List<URL> urls = new ArrayList<URL>();
+ for (String resource : resources)
+ {
+ urls.add(this.getResource(klass, resource));
+ }
+ return urls;
+ }
+
+ /**
+ * Returns the URL to the {@code resourceName}. The resource is looked
+ * under {@code klass}'s package name. For example, if the
+ * klass is org.jboss.ejb3.packagemanager.test.install.unit.BasicInstallTestCase and the
+ * resource name is package.xml, then this method looks for package.xml under
+ * org/jboss/ejb3/packagemanager/test/install/unit in the classpath.
+ *
+ * This method returns null if the resource was not found in the classpath
+ * @param klass The Class under whose package the resources are searched for
+ * @param resourceName The name of the resource
+ * @return Returns the URL to the resource or NULL if not found in classpath
+ */
+ protected URL getResource(Class<?> klass, String resourceName)
+ {
+ String resourceDir = klass.getPackage().getName().toString() + ".";
+ resourceDir = resourceDir.replace('.', '/');
+ String resourcePath = resourceDir + resourceName;
+ return klass.getClassLoader().getResource(resourcePath);
+ }
+
+ /**
+ * Writes out an {@link JavaArchive} to the {@code destFile}
+ * The directories under which this {@code destFile} is to be
+ * created are expected to be present. This method does *not* create
+ * any non-existent directories
+ *
+ * @param jar The jar file which is to be written to the file system
+ * @param destFile The file to which the jar is to be written
+ * @throws Exception
+ */
+ protected void exportZip(JavaArchive jar, File destFile) throws Exception
+ {
+ InputStream is = ZipExporter.exportZip(jar);
+ FileOutputStream fos = new FileOutputStream(destFile);
+ BufferedOutputStream bos = null;
+ BufferedInputStream bis = null;
+ try
+ {
+ bos = new BufferedOutputStream(fos);
+ bis = new BufferedInputStream(is);
+ byte[] content = new byte[4096];
+ int length;
+ while ((length = bis.read(content)) != -1)
+ {
+ bos.write(content, 0, length);
+ }
+ bos.flush();
+ }
+ finally
+ {
+ if (bos != null)
+ {
+ bos.close();
+ }
+ if (bis != null)
+ {
+ bis.close();
+ }
+ }
+ }
+
+ /**
+ * Creates a JBoss AS-5 directory structure for the given {@code jbossHome}
+ *
+ * @param jbossHome The server home
+ * @throws IOException
+ */
+ private static void createJBossDirectoryStructure(File jbossHome) throws IOException
+ {
+ // bin folder
+ File jbossBin = new File(jbossHome, "bin");
+ jbossBin.mkdirs();
+ // common/lib
+ File jbossCommonLib = new File(jbossHome, "common/lib");
+ jbossCommonLib.mkdirs();
+ // server
+ File serverDefault = new File(jbossHome, "server");
+ serverDefault.mkdirs();
+ // create "default" and "all" server configs
+ createServerProfile(jbossHome, "default");
+ createServerProfile(jbossHome, "all");
+ }
+
+ /**
+ * Create the directory structure for a JBoss AS-5 server profile
+ *
+ * @param jbossHome JBOSS_HOME
+ * @param serverProfileName The name of the server profile (ex: "default", "all")
+ * @throws IOException
+ */
+ private static void createServerProfile(File jbossHome, String serverProfileName) throws IOException
+ {
+ // server/<servername>
+ File serverProf = new File(jbossHome, "server/" + serverProfileName);
+ serverProf.mkdirs();
+ // server/<servername>/lib
+ File serverProfLib = new File(serverProf, "lib");
+ serverProfLib.mkdirs();
+ // server/<servername>/conf
+ File serverConf = new File(serverProf, "conf");
+ serverConf.mkdirs();
+ // server/<servername>/deploy
+ File serverDeploy = new File(serverProf, "deploy");
+ serverDeploy.mkdirs();
+ // server/<servername>/deployers
+ File serverDeployers = new File(serverProf, "deployers");
+ serverDeployers.mkdirs();
+ }
+}
Added: projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/install/unit/BasicInstallTestCase.java
===================================================================
--- projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/install/unit/BasicInstallTestCase.java (rev 0)
+++ projects/ejb3/trunk/package-manager/src/test/java/org/jboss/ejb3/packagemanager/test/install/unit/BasicInstallTestCase.java 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,299 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.ejb3.packagemanager.test.install.unit;
+
+import java.io.File;
+import java.net.URL;
+
+import org.jboss.ejb3.packagemanager.PackageManager;
+import org.jboss.ejb3.packagemanager.PackageManagerEnvironment;
+import org.jboss.ejb3.packagemanager.impl.DefaultPackageManagerImpl;
+import org.jboss.ejb3.packagemanager.test.common.Dummy;
+import org.jboss.ejb3.packagemanager.test.common.PackageManagerTestCase;
+import org.jboss.logging.Logger;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.JavaArchiveFactory;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests the basic install feature of the package manager
+ *
+ * Author: Jaikiran Pai
+ */
+public class BasicInstallTestCase extends PackageManagerTestCase
+{
+
+ /**
+ * Logger
+ */
+ private static Logger logger = Logger.getLogger(BasicInstallTestCase.class);
+
+ /**
+ * Package manager
+ */
+ private static PackageManager pkgMgr;
+
+ /**
+ * The JBoss Home used in this test
+ */
+ private static File jbossHome;
+
+ /**
+ * Package manager home used in this test
+ */
+ private static File pkgMgrHome;
+
+ /**
+ * Do the necessary setup
+ * @throws Exception
+ */
+ @BeforeClass
+ public static void setup() throws Exception
+ {
+ pkgMgrHome = setupPackageManagerHome();
+ jbossHome = setupDummyJBoss();
+ PackageManagerEnvironment env = new PackageManagerEnvironment(pkgMgrHome.getAbsolutePath());
+ pkgMgr = new DefaultPackageManagerImpl(env, jbossHome.getAbsolutePath());
+ }
+
+ /**
+ * Tests that a simple install feature works. The package to be installed
+ * by the package manager contains a dummy jar file to be installed at
+ * JBOSS_HOME/common/lib and a build script for the pre-install phase.
+ *
+ * The package does *not* have any dependencies, system-requirements, pre-install or
+ * post-install steps
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testSimpleInstall() throws Exception
+ {
+ File dummyJar = this.createDummyJar();
+
+ // Now let's package the dummy.jar, package.xml into a package
+ File simplePackage = new File(targetDir, "simple-package.jar");
+ JavaArchive pkg = JavaArchiveFactory.create(simplePackage.getName());
+ pkg.addResource("dummy.jar", dummyJar);
+ URL packageXmlURL = this.getResource(this.getClass(), "package-with-just-install-file.xml");
+ File file = new File(packageXmlURL.getFile());
+ pkg.addResource("package.xml", file);
+ // now write out the package to disk
+ logger.debug("Writing out the created package " + pkg.toString(true));
+ this.exportZip(pkg, simplePackage);
+
+ // We are done with the package creation, now let's install it
+ // using the package manager
+ // But let's first make sure that the jar file to be installed
+ // through this package is not already in the JBoss AS (this check
+ // is just for the sanity of this test case). If it exists, just
+ // clean it up before running the package manager
+ File dummyJarInJBoss = new File(jbossHome, "common/lib/dummy.jar");
+ if (dummyJarInJBoss.exists())
+ {
+ logger
+ .debug("JBOSS_HOME/common/lib/dummy.jar already exists - cleaning it up before running the package manager test");
+ dummyJarInJBoss.delete();
+ }
+ // run the package manager
+ pkgMgr.installPackage(simplePackage.toURL());
+
+ // now check that the file was installed in that location
+ Assert.assertTrue("Package manager did NOT install dummy.jar into JBOSS_HOME/common/lib", dummyJarInJBoss
+ .exists());
+ }
+
+ /**
+ * Tests that a pre-install script packaged in a package runs as expected.
+ * The pre-install script is written such that it places a test.txt file
+ * in JBOSS_HOME/bin to prove that the script was run.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testPreInstallScriptExecution() throws Exception
+ {
+ File dummyJar = this.createDummyJar();
+
+ // Now let's package the dummy.jar, package.xml and build.xml into a package
+ File packageWithPreInstallScript = new File(targetDir, "package-with-preinstall-script.jar");
+ JavaArchive pkg = JavaArchiveFactory.create(packageWithPreInstallScript.getName());
+ pkg.addResource("dummy.jar", dummyJar);
+ URL packageXmlURL = this.getResource(this.getClass(), "package-with-pre-install-script.xml");
+ File packageXmlFile = new File(packageXmlURL.getFile());
+ pkg.addResource("package.xml", packageXmlFile);
+ URL buildXmlURL = this.getResource(this.getClass(), "build.xml");
+ File buildFile = new File(buildXmlURL.getFile());
+ pkg.addResource("build.xml", buildFile);
+
+ // now write out the package to disk
+ logger.debug("Writing out the created package " + pkg.toString(true));
+ this.exportZip(pkg, packageWithPreInstallScript);
+
+ // The pre-install build script is written such that it creates a test.txt file in the JBOSS_HOME/bin
+ // folder. So before running the package manager, just cleanup the JBOSS_HOME/bin folder of any such existing
+ // files
+ File testFileInJBossBin = new File(this.jbossHome, "bin/test.txt");
+ if (testFileInJBossBin.exists())
+ {
+ logger
+ .debug("JBOSS_HOME/bin/test.txt already exists - cleaning it up before running the package manager test");
+ testFileInJBossBin.delete();
+ }
+ // now run the package manager
+ this.pkgMgr.installPackage(packageWithPreInstallScript.getAbsolutePath());
+ // now assert that the JBOSS_HOME/bin/test.txt was created
+ // If that file was created then it's enough to guarantee that the pre-install script was run
+ Assert.assertTrue(
+ testFileInJBossBin.getAbsolutePath() + " was NOT created. The pre-install script in the package "
+ + packageWithPreInstallScript + " did not run", testFileInJBossBin.exists());
+
+ // As a further test, also check that the dummy.jar packaged in this package was
+ // also installed (at JBOSS_HOME/server/default/deploy folder)
+ File dummyJarInServerDefaultDeploy = new File(this.jbossHome, "server/default/deploy/dummy.jar");
+ Assert.assertTrue(dummyJarInServerDefaultDeploy + " was not installed by the package manager",
+ dummyJarInServerDefaultDeploy.exists());
+ }
+
+ /**
+ * The {@link DefaultPackageManagerImpl}'s {@link DefaultPackageManagerImpl#main(String[])}
+ * method acts as a valid entry point for package manager clients. Test that it parses the
+ * command line arguments corrects and functionalities of the package manager work as expected
+ *
+ * TODO: Note that the params passed through the command line are still work-in-progress
+ * and they might change in future. This test case then needs to change appropriately.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testMainMethodOfDefaultPackageManager() throws Exception
+ {
+ File dummyJar = this.createDummyJar();
+ // Now let's package the dummy.jar, package.xml into a package
+ File commandLineTestPackage = new File(targetDir, "commandline-test-package.jar");
+ JavaArchive pkg = JavaArchiveFactory.create(commandLineTestPackage.getName());
+ pkg.addResource("dummy.jar", dummyJar);
+ URL packageXmlURL = this.getResource(this.getClass(), "package-with-just-install-file.xml");
+ File packageXmlFile = new File(packageXmlURL.getFile());
+ pkg.addResource("package.xml", packageXmlFile);
+ // now write out the package to disk
+ logger.debug("Writing out the created package " + pkg.toString(true));
+ this.exportZip(pkg, commandLineTestPackage);
+
+ String commandLineArgs[] = new String[]
+ {"-i", commandLineTestPackage.getAbsolutePath(), "-p", this.pkgMgrHome.getAbsolutePath(), "-s",
+ this.jbossHome.getAbsolutePath()};
+
+ // cleanup any appropriate existing files in JBoss server
+ File dummyJarInJBoss = new File(jbossHome, "common/lib/dummy.jar");
+ if (dummyJarInJBoss.exists())
+ {
+ logger
+ .debug("JBOSS_HOME/common/lib/dummy.jar already exists - cleaning it up before running the package manager test");
+ dummyJarInJBoss.delete();
+ }
+
+ // run the package manager
+ DefaultPackageManagerImpl.main(commandLineArgs);
+
+ // now check that the file was installed in that location
+ Assert.assertTrue("Package manager did NOT install dummy.jar into JBOSS_HOME/common/lib", dummyJarInJBoss
+ .exists());
+
+ }
+
+ /**
+ * Note: This test assumes the presence of a "package" at
+ * http://snapshots.jboss.org/maven2/org/jboss/ejb3/tmp/simple-package.jar
+ *
+ * TODO: Once we have packages uploaded to Maven repo, we can point to a different
+ * URL from this tmp one.
+ * This test currently, is really just to show that the package manager can install
+ * packages from a HTTP URL.
+ *
+ * This test does *not* upload this package (not all users running this test will have
+ * the upload privileges). So if the "package" is unavailable at that location then this
+ * test will fail
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testHttpPackageInstall() throws Exception
+ {
+ // cleanup any appropriate existing files in JBoss server
+ File dummyJarInJBoss = new File(jbossHome, "common/lib/dummy.jar");
+ if (dummyJarInJBoss.exists())
+ {
+ logger
+ .debug("JBOSS_HOME/common/lib/dummy.jar already exists - cleaning it up before running the package manager test");
+ dummyJarInJBoss.delete();
+ }
+ // TODO: See javadocs of this test. This URL will change in near future
+ String httpPackageURL = "http://snapshots.jboss.org/maven2/org/jboss/ejb3/tmp/simple-package.jar";
+ // install the package
+ this.pkgMgr.installPackage(httpPackageURL);
+
+ // now check that the file was installed in that location
+ Assert.assertTrue("Package manager did NOT install dummy.jar into JBOSS_HOME/common/lib", dummyJarInJBoss
+ .exists());
+ }
+
+ /**
+ * Creates a dummy jar file containing a dummy .class file
+ * The dummy.jar file is created in the project's "target" directory. If target/dummy.jar
+ * already exists, then the existing File is returned.
+ *
+ * @return Returns target/dummy.jar File
+ * @throws Exception
+ */
+ private File createDummyJar() throws Exception
+ {
+ // Create a jar using ShrinkWrap API.
+ // The jar will look like:
+ // dummy.jar
+ // |
+ // |--- org/jboss/ejb3/packagemanager/test/common/Dummy.class
+ // |--- jboss
+ // |--- ejb3
+ // |--- packagemanager
+ // |--- test
+ // |--- common
+ // |--- Dummy.class
+
+ File dummyJar = new File(targetDir, "dummy.jar");
+ // if it already exists then no need to recreate it
+ if (dummyJar.exists())
+ {
+ return dummyJar;
+ }
+ JavaArchive jar = JavaArchiveFactory.create(dummyJar.getName());
+ jar.addClass(Dummy.class);
+ // write out to file system at target/dummy.jar
+ logger.debug("Writing out the created jar " + jar.toString(true));
+ this.exportZip(jar, dummyJar);
+ return dummyJar;
+
+ }
+}
Added: projects/ejb3/trunk/package-manager/src/test/resources/log4j.xml
===================================================================
--- projects/ejb3/trunk/package-manager/src/test/resources/log4j.xml (rev 0)
+++ projects/ejb3/trunk/package-manager/src/test/resources/log4j.xml 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml 68671 2008-01-08 10:04:25Z wolfc $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <param name="File" value="target/test.log"/>
+ <param name="Threshold" value="DEBUG"/>
+ <param name="Append" value="false"/>
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <category name="org.jboss">
+ <priority value="INFO"/>
+ </category>
+
+ <category name="org.jboss.ejb3">
+ <priority value="ALL"/>
+ </category>
+
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Added: projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/test/install/unit/build.xml
===================================================================
--- projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/test/install/unit/build.xml (rev 0)
+++ projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/test/install/unit/build.xml 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,37 @@
+<!--
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2005, JBoss Inc., 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.
+ -->
+
+<project name="Package Install Script">
+
+ <property name="test" value="testvalue"/>
+
+
+ <target name="pre-install">
+ <echo level="info">***************************************************************</echo>
+ <echo level="info">This is the pre-install target in the dummy package!</echo>
+ <echo level="info">Package manager home is = ${PM_HOME}</echo>
+ <echo level="info">JBoss AS home is = ${JBOSS_HOME}</echo>
+ <echo level="info">***************************************************************</echo>
+ <echo file="${JBOSS_HOME}/bin/test.txt" message="This proves that the pre-install script was run"/>
+ <echo level="debug" message="Test property value is = ${test}"/>
+ </target>
+</project>
\ No newline at end of file
Added: projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/test/install/unit/package-with-just-install-file.xml
===================================================================
--- projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/test/install/unit/package-with-just-install-file.xml (rev 0)
+++ projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/test/install/unit/package-with-just-install-file.xml 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,8 @@
+<sh:package name="jboss-ejb3-nointerface" version="1.0.0-Alpha1"
+xmlns:sh="http://www.jboss.org/schema">
+
+ <!-- Package to install a dummy jar into JBOSS_AS/common/lib -->
+ <file name="dummy.jar" dest-path="common/lib" type="library"/>
+
+
+</sh:package>
\ No newline at end of file
Added: projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/test/install/unit/package-with-pre-install-script.xml
===================================================================
--- projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/test/install/unit/package-with-pre-install-script.xml (rev 0)
+++ projects/ejb3/trunk/package-manager/src/test/resources/org/jboss/ejb3/packagemanager/test/install/unit/package-with-pre-install-script.xml 2009-10-19 18:51:56 UTC (rev 95134)
@@ -0,0 +1,11 @@
+<sh:package name="jboss-ejb3-nointerface" version="1.0.0-Alpha1"
+xmlns:sh="http://www.jboss.org/schema">
+
+ <!-- Package to install a dummy jar into JBOSS_AS/server/default/deploy -->
+ <file name="dummy.jar" dest-path="server/default/deploy" type="library"/>
+
+ <pre-install>
+ <script file="build.xml"/>
+ </pre-install>
+
+</sh:package>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list