Author: psharples
Date: Wed Nov 9 15:02:15 2011
New Revision: 1199782
URL: http://svn.apache.org/viewvc?rev=1199782&view=rev
Log:
Changes to allow us to build a maven WAR archive which by default uses a derby
database and runs without having to preconfigure a database. The intention is
to be able to download this artifact and deploy it under a container, such as
tomcat.
Added:
incubator/wookie/trunk/src/org/apache/wookie/beans/util/DatabaseUtils.java
(with props)
Modified:
incubator/wookie/trunk/ant/ivy-java-common.xml
incubator/wookie/trunk/ant/ivy-release-common.xml
incubator/wookie/trunk/ivy.xml
incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/JPAPersistenceManager.java
Modified: incubator/wookie/trunk/ant/ivy-java-common.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/ant/ivy-java-common.xml?rev=1199782&r1=1199781&r2=1199782&view=diff
==============================================================================
--- incubator/wookie/trunk/ant/ivy-java-common.xml (original)
+++ incubator/wookie/trunk/ant/ivy-java-common.xml Wed Nov 9 15:02:15 2011
@@ -17,6 +17,8 @@
-->
<project xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:m="http://ant.apache.org/ivy/maven"
xmlns:openpgp="antlib:org.apache.commons.openpgp.ant">
+ <tstamp/>
+
<import file="ivy-common.xml"/>
<property name="project.lib.dir"
location="${project.webapp.dir}/WEB-INF/lib" />
@@ -159,10 +161,11 @@
<include name="DISCLAIMER"/>
</metainf>
<manifest>
- <attribute name="Built-By"
value="${user.name}"/>
<attribute name="Implementation-Vendor"
value="Apache Software Foundation"/>
<attribute name="Implementation-Title"
value="${ant.project.name}"/>
<attribute name="Implementation-Version"
value="${version}"/>
+ <attribute name="Built-By"
value="${user.name}"/>
+ <attribute name="Build-Date" value="${TODAY}"/>
</manifest>
</jar>
</target>
@@ -189,10 +192,11 @@
<include name="DISCLAIMER"/>
</metainf>
<manifest>
- <attribute name="Built-By"
value="${user.name}"/>
<attribute name="Implementation-Vendor"
value="Apache Software Foundation"/>
<attribute name="Implementation-Title"
value="${ant.project.name}"/>
<attribute name="Implementation-Version"
value="${version}"/>
+ <attribute name="Built-By"
value="${user.name}"/>
+ <attribute name="Build-Date" value="${TODAY}"/>
</manifest>
</jar>
<!--remove folder-->
@@ -211,11 +215,12 @@
<include name="NOTICE"/>
<include name="DISCLAIMER"/>
</metainf>
- <manifest>
- <attribute name="Built-By"
value="${user.name}"/>
+ <manifest>
<attribute name="Implementation-Vendor"
value="Apache Software Foundation"/>
<attribute name="Implementation-Title"
value="${ant.project.name}"/>
<attribute name="Implementation-Version"
value="${version}"/>
+ <attribute name="Built-By"
value="${user.name}"/>
+ <attribute name="Build-Date" value="${TODAY}"/>
</manifest>
</jar>
</target>
@@ -236,44 +241,71 @@
</target>
<target name="init-war" unless="subproject"
depends="test-calling-project-true" >
- <ivy:cachepath pathid="project.core.class.path" conf="dev" />
- <copy
todir="${servletEngine.webapp.dir}/${ant.project.name}/WEB-INF/classes">
+
+ <copy
todir="${build.dir}/maven-webapp/${ant.project.name}/WEB-INF/classes">
<fileset dir="${project.build.classes.dir}" />
</copy>
- <copy todir="${servletEngine.webapp.dir}/${ant.project.name}">
+ <copy todir="${build.dir}/maven-webapp/${ant.project.name}">
<fileset dir="${project.webapp.dir}" />
</copy>
- <ivy:retrieve conf="deploy"
pattern="${servletEngine.webapp.dir}/${ant.project.name}/WEB-INF/lib/[artifact]-[revision].[ext]"/>
- <antcall target="post-deploy-webapp" inheritRefs="true"/>
- <echo>Building war</echo>
-
- <!-- back the widgetserver.properties file up -->
- <copy
file="${build.dir}/webapp/wookie/WEB-INF/classes/widgetserver.properties"
- tofile="${build.dir}/widgetserver.properties"
overwrite="true"/>
+ <ivy:retrieve conf="deploy"
pattern="${build.dir}/maven-webapp/wookie/WEB-INF/lib/[artifact]-[revision].[ext]"/>
+ <ivy:retrieve conf="database"
pattern="${build.dir}/maven-webapp/wookie/WEB-INF/lib/[artifact]-[revision].[ext]"
/>
- <!-- update widgetserver.properties file so that it points to
mysql as db type-->
+ <!-- update widgetserver.properties file so that it points to
derby as db type-->
<copy file="${project.core.src.dir}/widgetserver.properties"
- todir="${build.dir}/webapp/wookie/WEB-INF/classes/"
overwrite="true">
+
todir="${build.dir}/maven-webapp/wookie/WEB-INF/classes/" overwrite="true">
<filterset>
<filter token="PERSISTENCE_MANAGER_CLASSNAME"
value="org.apache.wookie.beans.jpa.JPAPersistenceManager"/>
- <filter token="DATABASE_TYPE" value="mysql"/>
+ <filter token="DATABASE_TYPE" value="derby"/>
<filter token="REPOSITORY_USER" value=""/>
<filter token="REPOSITORY_PASSWORD" value=""/>
<filter token="REPOSITORY_ROOTPATH" value=""/>
<filter token="REPOSITORY_WORKSPACE" value=""/>
</filterset>
</copy>
-
+
+ <!-- configure JPA context.xml configuration -->
+ <copy file="${etc.dir}/tomcat/conf/jpa-context.xml"
+
tofile="${build.dir}/maven-webapp/wookie/META-INF/context.xml"
+ overwrite="true">
+ <filterset>
+ <filter token="DATABASE_USER" value="java"/>
+ <filter token="DATABASE_PASSWORD" value="java"/>
+ <filter token="DATABASE_DRIVER"
value="org.apache.derby.jdbc.EmbeddedDriver"/>
+ <filter token="DATABASE_URI"
value="jdbc:derby:widgetDatabase/widgetDB;create=true"/>
+ </filterset>
+ </copy>
+
+ <copy file="${project.webapp.dir}/WEB-INF/web.xml"
+ todir="${build.dir}/maven-webapp/wookie/WEB-INF"
overwrite="true">
+ <filterset>
+ <filter token="RESOURCE_REF_DESCRIPTION" value="The JPA
database connection."/>
+ <filter token="RESOURCE_REF_NAME" value="jdbc/widgetdb"/>
+ <filter token="RESOURCE_REF_TYPE"
value="javax.sql.DataSource"/>
+ </filterset>
+ </copy>
+
+ <mkdir dir="${build.dir}/maven-webapp/wookie/features"/>
+ <copy todir="${build.dir}/maven-webapp/wookie/features">
+ <fileset dir="${user.dir}/features"/>
+ </copy>
+
+ <!-- make all the widgets -->
+ <antcall target="post-deploy-webapp-widgets-extra"/>
+ <!-- copy them into the maven webapp -->
+ <copy todir="${build.dir}/maven-webapp/wookie/deploy">
+ <fileset dir="${build.dir}/widgets"/>
+ </copy>
+
<!-- build war file -->
+ <echo>Building war...</echo>
<war
destfile="${dist.dir}/wookie.war"
- webxml="${build.dir}/webapp/wookie/WEB-INF/web.xml">
- <lib dir="${build.dir}/webapp/wookie/WEB-INF/lib">
- <exclude name="derby-10.2.1.6.jar"/>
- </lib>
- <classes
dir="${build.dir}/webapp/wookie/WEB-INF/classes" />
- <fileset dir="${build.dir}/webapp/wookie/">
+
webxml="${build.dir}/maven-webapp/wookie/WEB-INF/web.xml">
+ <lib
dir="${build.dir}/maven-webapp/wookie/WEB-INF/lib"/>
+ <classes
dir="${build.dir}/maven-webapp/wookie/WEB-INF/classes" />
+ <fileset dir="${build.dir}/maven-webapp/wookie/">
<exclude name="WEB-INF/classes/" />
<exclude name="WEB-INF/lib/" />
</fileset>
@@ -284,13 +316,16 @@
<include name="LICENSE"/>
<include name="NOTICE"/>
</metainf>
+ <manifest>
+ <attribute name="Implementation-Vendor"
value="Apache Software Foundation"/>
+ <attribute name="Implementation-Title"
value="${ant.project.name}"/>
+ <attribute name="Implementation-Version"
value="${version}"/>
+ <attribute name="Built-By"
value="${user.name}"/>
+ <attribute name="Build-Date" value="${TODAY}"/>
+ </manifest>
</war>
-
- <!-- put original widgetserver.properties file back -->
- <copy file="${build.dir}/widgetserver.properties"
-
tofile="${build.dir}/webapp/wookie/WEB-INF/classes/widgetserver.properties"
- overwrite="true" />
- <delete file="${build.dir}/widgetserver.properties" />
+ <!-- clean up -->
+ <delete dir="${build.dir}/maven-webapp" />
</target>
Modified: incubator/wookie/trunk/ant/ivy-release-common.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/ant/ivy-release-common.xml?rev=1199782&r1=1199781&r2=1199782&view=diff
==============================================================================
--- incubator/wookie/trunk/ant/ivy-release-common.xml (original)
+++ incubator/wookie/trunk/ant/ivy-release-common.xml Wed Nov 9 15:02:15 2011
@@ -133,7 +133,7 @@
destfile="${wookie.release.dir}/${version}/binary/war/${wookie.war.folder.name}/wookie.war"
webxml="${build.dir}/webapp/wookie/WEB-INF/web.xml">
<lib dir="${build.dir}/webapp/wookie/WEB-INF/lib">
- <exclude name="derby-10.2.1.6.jar"/>
+ <exclude name="derby-10.4.2.0.jar"/>
</lib>
<classes
dir="${build.dir}/webapp/wookie/WEB-INF/classes" />
<fileset dir="${build.dir}/webapp/wookie/">
Modified: incubator/wookie/trunk/ivy.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/ivy.xml?rev=1199782&r1=1199781&r2=1199782&view=diff
==============================================================================
--- incubator/wookie/trunk/ivy.xml (original)
+++ incubator/wookie/trunk/ivy.xml Wed Nov 9 15:02:15 2011
@@ -19,9 +19,10 @@
<configurations>
<conf name="deploy" description="Provide the necessary files and
libraries to deploy in a production environment"/>
- <conf name="runtime" description="Provide the libraries to run in
standalone without the deploy libraries"/>
- <conf name="dev" extends="deploy, runtime" description="Provide the
necessary files and libraries to run in standalone (development) mode"/>
- <conf name="test" extends="dev" visibility="private" description="for
our testing frameowrk"/>
+ <conf name="database" description="Provide the libraries to run the
wookie database in standalone mode"/>
+ <conf name="runtime" extends="database" description="Provide the
libraries to run in standalone without the deploy libraries"/>
+ <conf name="dev" extends="deploy, database, runtime"
description="Provide the necessary files and libraries to run in standalone
(development) mode"/>
+ <conf name="test" extends="dev" visibility="private" description="for
our testing framework"/>
<conf name="ddlutils" visibility="private" description="Provide the
necessary libraries to invoke DDLUtils schema generation"/>
<conf name="deploy-with-src-and-docs" extends="deploy"
description="Used for publishing maven artifacts to the snapshot repo"/>
<conf name="deploy-signed" extends="deploy-with-src-and-docs"
description="Used for publishing maven artifacts to the staging area repo"/>
@@ -119,10 +120,11 @@
</dependency>
<dependency org="org.mortbay.jetty" name="jsp-api-2.1" rev="6.1.3"
conf="runtime->default">
</dependency>
- <dependency org="org.apache.derby" name="derby" rev="10.4.2.0"
conf="runtime->default">
- </dependency>
<dependency org="commons-dbcp" name="commons-dbcp" rev="1.2.2"
conf="runtime->default">
</dependency>
+
+ <dependency org="org.apache.derby" name="derby" rev="10.4.2.0"
conf="database->default">
+ </dependency>
<!-- Libraries used in testing -->
<dependency org="junit" name="junit" rev="4.7" conf="test->default">
Modified:
incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/JPAPersistenceManager.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/JPAPersistenceManager.java?rev=1199782&r1=1199781&r2=1199782&view=diff
==============================================================================
---
incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/JPAPersistenceManager.java
(original)
+++
incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/JPAPersistenceManager.java
Wed Nov 9 15:02:15 2011
@@ -14,6 +14,7 @@
package org.apache.wookie.beans.jpa;
+import java.io.File;
import java.io.InputStream;
import java.lang.reflect.Array;
import java.sql.Connection;
@@ -92,6 +93,7 @@ import org.apache.wookie.beans.jpa.impl.
import org.apache.wookie.beans.jpa.impl.WidgetInstanceImpl;
import org.apache.wookie.beans.jpa.impl.WidgetServiceImpl;
import org.apache.wookie.beans.jpa.impl.WidgetTypeImpl;
+import org.apache.wookie.beans.util.DatabaseUtils;
import org.apache.wookie.beans.util.IPersistenceManager;
import org.apache.wookie.beans.util.PersistenceCommitException;
import org.slf4j.Logger;
@@ -181,6 +183,7 @@ public class JPAPersistenceManager imple
private static String dbType;
private static String dictionaryType;
private static OpenJPAEntityManagerFactory entityManagerFactory;
+ private EntityManager entityManager;
/**
* Initialize implementation with configuration.
@@ -200,6 +203,12 @@ public class JPAPersistenceManager imple
{
throw new IllegalArgumentException("Unsupported database type:
"+dbType);
}
+
+ // if we are not initializing the store and we are using derby,
then check to see if the DB files
+ // exist in the filesystem. If they do not then override and
create them.
+ if(!initializeStore && dbType.equals("derby")){
+ initializeStore = DatabaseUtils.derbyDatabaseDoesNotExist();
+ }
// initialize persistent store
if (initializeStore && (dbType != null))
@@ -301,8 +310,6 @@ public class JPAPersistenceManager imple
throw new RuntimeException("Unable to terminate: "+e, e);
}
}
-
- private EntityManager entityManager;
/* (non-Javadoc)
* @see org.apache.wookie.beans.util.IPersistenceManager#begin()
Added:
incubator/wookie/trunk/src/org/apache/wookie/beans/util/DatabaseUtils.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/util/DatabaseUtils.java?rev=1199782&view=auto
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/beans/util/DatabaseUtils.java
(added)
+++ incubator/wookie/trunk/src/org/apache/wookie/beans/util/DatabaseUtils.java
Wed Nov 9 15:02:15 2011
@@ -0,0 +1,30 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wookie.beans.util;
+
+import java.io.File;
+
+public class DatabaseUtils {
+
+ public static boolean derbyDatabaseDoesNotExist(){
+ File derbyDbFolder = new File(System.getProperty("user.dir") +
File.separator + "widgetDatabase");
+ if(derbyDbFolder.exists()){
+ return false;
+ }
+ else{
+ return true;
+ }
+ }
+
+}
Propchange:
incubator/wookie/trunk/src/org/apache/wookie/beans/util/DatabaseUtils.java
------------------------------------------------------------------------------
svn:mime-type = text/plain