You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by jr...@apache.org on 2010/05/25 23:12:10 UTC
svn commit: r948207 - in /openjpa/trunk/openjpa-examples/openbooks:
build.jee.was.xml build.jee.xml build.xml scripts/ scripts/was/
scripts/was/ds_config.py src/main/resources/META-INF/persistence.jee.was.xml
Author: jrbauer
Date: Tue May 25 21:12:08 2010
New Revision: 948207
URL: http://svn.apache.org/viewvc?rev=948207&view=rev
Log:
Added basic build, install, and config support for WebSphere Application Server to OpenBooks
Added:
openjpa/trunk/openjpa-examples/openbooks/build.jee.was.xml (with props)
openjpa/trunk/openjpa-examples/openbooks/scripts/
openjpa/trunk/openjpa-examples/openbooks/scripts/was/
openjpa/trunk/openjpa-examples/openbooks/scripts/was/ds_config.py (with props)
openjpa/trunk/openjpa-examples/openbooks/src/main/resources/META-INF/persistence.jee.was.xml (with props)
Modified:
openjpa/trunk/openjpa-examples/openbooks/build.jee.xml
openjpa/trunk/openjpa-examples/openbooks/build.xml
Added: openjpa/trunk/openjpa-examples/openbooks/build.jee.was.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/build.jee.was.xml?rev=948207&view=auto
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/build.jee.was.xml (added)
+++ openjpa/trunk/openjpa-examples/openbooks/build.jee.was.xml Tue May 25 21:12:08 2010
@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+<!-- ====================================================================== -->
+<!-- -->
+<!-- Ant build script for JEE version of OpenBooks for -->
+<!-- WebSphere Application Server with OpenJPA 2.0/JPA 2.0 functionality -->
+<!-- -->
+<!-- NOTE: The main build script (build.xml) must be run with ws_ant -->
+<!-- located in the was.home/bin directory. Otherwise, WebSphere -->
+<!-- provided ant tools will not be included on the classpath and build -->
+<!-- errors will result. -->
+<!-- ====================================================================== -->
+
+<project name="OpenBooks.JEE.WAS" default="package">
+
+ <!-- WebSphere Application Server task definitions -->
+ <taskdef name="wsUninstallApp" classname="com.ibm.websphere.ant.tasks.UninstallApplication"/>
+ <taskdef name="wsInstallApp" classname="com.ibm.websphere.ant.tasks.InstallApplication"/>
+ <taskdef name="wsUninstallApp" classname="com.ibm.websphere.ant.tasks.UninstallApplication"/>
+ <taskdef name="wsStartApplication" classname="com.ibm.websphere.ant.tasks.StartApplication"/>
+ <taskdef name="wsadmin" classname="com.ibm.websphere.ant.tasks.WsAdmin"/>
+
+ <!-- Location of WebSphere Application Server home/install dir -->
+ <property name="was.home" value="/opt/IBM/WebSphere/AppServer"/>
+
+ <!-- WebSphere Server name (IP name or address) -->
+ <property name="was.server" value=""/>
+
+ <!-- WebSphere Admin port -->
+ <property name="was.port" value=""/>
+
+ <!-- WebSphere admin connection type. SOAP, RMI, JMS, or NONE. -->
+ <property name="was.conntype" value=""/>
+
+ <!-- WebSphere User name (required if security is enabled) -->
+ <property name="was.user" value=""/>
+
+ <!-- WebSphere Password (required if security enabled) -->
+ <property name="was.password" value=""/>
+
+ <target name="pre-package">
+ <echo message="In WAS pre-package"/>
+ <copy file="${rsrc.dir}/META-INF/persistence.jee.was.xml" tofile="${classes.dir}/META-INF/persistence.xml"/>
+ </target>
+
+ <target name="install"
+ description="Deploy OpenBooks as a WAR application in WebSphere Application Server">
+ <condition property="default.deploy">
+ <length string="${was.server}" length="0"/>
+ </condition>
+ <antcall target="was.deploy"/>
+ <antcall target="was.deploy.secure"/>
+ </target>
+
+ <target name="uninstall"
+ description="Uninstall OpenBooks from the Application Server">
+ <condition property="default.uninstall">
+ <length string="${was.server}" length="0"/>
+ </condition>
+ <antcall target="was.uninstall"/>
+ <antcall target="was.secure.uninstall"/>
+ </target>
+
+ <!-- Default app uninstall -->
+ <target name="was.uninstall" if="default.uninstall">
+ <echo>
+ ---------------------------------------
+ Uninstalling OpenBooks demo application
+ WAS Home: ${was.home}
+ </echo>
+ <wsUninstallApp wasHome="${was.home}"
+ application="OpenBooks"/>
+ </target>
+
+ <!-- App uninstall when security is enabled -->
+ <target name="was.secure.uninstall" unless="default.uninstall">
+ <echo>
+ ---------------------------------------
+ Uninstalling OpenBooks demo application
+ </echo>
+ <wsUninstallApp wasHome="${was.home}"
+ application="OpenBooks"
+ conntype="${was.conntype}"
+ host="${was.server}"
+ port="${was.port}"
+ user="${was.user}"
+ password="${was.password}"/>
+
+ </target>
+
+ <!-- Default simple deployment if WAS security is disabled -->
+ <target name="was.deploy" if="default.deploy">
+ <echo>
+ --------------------------------------------
+ Creating Derby JDBC provider and data source
+ WAS Home: ${was.home}
+ </echo>
+ <wsadmin wasHome="${was.home}"
+ script="scripts/was/ds_config.py"
+ lang="jython"/>
+
+ <echo>
+ -------------------------------------
+ Deploying OpenBooks demo application
+ </echo>
+ <wsInstallApp wasHome="${was.home}"
+ ear="openbooks.war"
+ options="-usedefaultbindings -contextroot OpenBooks -appname OpenBooks"/>
+
+ <echo>
+ -------------------------------------
+ Starting OpenBooks demo application
+ </echo>
+ <wsStartApplication wasHome="${was.home}"
+ application="OpenBooks"/>
+
+ </target>
+
+ <!-- Target for installation and deployment of the application when a -->
+ <!-- server IP name or address is provided. This type of deployment -->
+ <!-- requires server IP name was.home, was.server, was.conntype, -->
+ <!-- was.port, was.user, and was.password to be provided. -->
+
+ <target name="was.deploy.secure" unless="default.deploy">
+ <echo>
+ -------------------------------------------
+ Creating Derby JDBC Provider and DataSource
+ WAS Home: ${was.home}
+ WAS Server: ${was.server}
+ ConnType: ${was.conntype}
+ Port: ${was.port}
+ User: ${was.user}
+ Password: Not shown
+ </echo>
+ <wsadmin wasHome="${was.home}"
+ script="scripts/was/ds_config.py"
+ lang="jython"
+ conntype="${was.conntype}"
+ host="${was.server}"
+ port="${was.port}"
+ user="${was.user}"
+ password="${was.password}"/>
+
+ <echo>
+ -------------------------------------
+ Deploying OpenBooks demo application
+ </echo>
+
+ <wsInstallApp wasHome="${was.home}"
+ ear="openbooks.war"
+ conntype="${was.conntype}"
+ host="${was.server}"
+ port="${was.port}"
+ user="${was.user}"
+ password="${was.password}"
+ options="-usedefaultbindings -appname OpenBooks"/>
+ <echo>
+ -------------------------------------
+ Starting OpenBooks demo application
+ Start OpenBooks via http://server:port/OpenBooks
+ </echo>
+ <wsStartApplication wasHome="${was.home}"
+ application="OpenBooks"
+ conntype="${was.conntype}"
+ host="${was.server}"
+ port="${was.port}"
+ user="${was.user}"
+ password="${was.password}"/>
+ </target>
+</project>
Propchange: openjpa/trunk/openjpa-examples/openbooks/build.jee.was.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/trunk/openjpa-examples/openbooks/build.jee.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/build.jee.xml?rev=948207&r1=948206&r2=948207&view=diff
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/build.jee.xml (original)
+++ openjpa/trunk/openjpa-examples/openbooks/build.jee.xml Tue May 25 21:12:08 2010
@@ -27,15 +27,20 @@
<target name="package"
description="Build, package and deploy OpenBooks as a WAR application in an Application Server">
- <delete file="${deploy.dir}/openbook.war" failonerror="false"/>
+
+ <condition property="app.server" value="" else=".${appserver}">
+ <equals arg1="${appserver}" arg2="" casesensitive="true" trim="true"/>
+ </condition>
+ <antcall target="jee.uninstall"/>
<mkdir dir="${classes.dir}/META-INF"/>
- <copy file="${rsrc.dir}/META-INF/persistence.xml" todir="${classes.dir}/META-INF"/>
+ <antcall target="jee.pre-package"/>
<war destfile="openbooks.war" webxml="${rsrc.dir}/META-INF/web.xml" filesonly="true">
<fileset dir="${web.dir}"/>
<classes dir="${classes.dir}">
<include name="openbook/domain/**"/>
<include name="openbook/server/**"/>
<include name="openbook/util/**"/>
+ <include name="META-INF/persistence.xml"/>
</classes>
<fileset dir="${rsrc.dir}">
<include name="images/Add2Cart.jpg"/>
@@ -45,6 +50,48 @@
<include name="generated-html/**"/>
</fileset>
</war>
+ <antcall target="jee.install"/>
+ </target>
+
+ <target name="jee.uninstall"
+ description="AppServer specific installation">
+ <subant antfile="build.${build.mode}${app.server}.xml"
+ target="uninstall"
+ inheritrefs="true"
+ inheritall="true"
+ buildpath="${basedir}"/>
+ </target>
+
+ <target name="uninstall"
+ description="Default app uninstall">
+ <delete file="${deploy.dir}/openbook.war" failonerror="false"/>
+ </target>
+
+ <target name="jee.pre-package"
+ description="AppServer specific pre-packaging. Occurs before war packaging.">
+ <subant antfile="build.${build.mode}${app.server}.xml"
+ target="pre-package"
+ inheritrefs="true"
+ inheritall="true"
+ buildpath="${basedir}"/>
+ </target>
+
+ <target name="pre-package"
+ description="Default application pre-packaging">
+ <copy file="${rsrc.dir}/META-INF/persistence.xml" todir="${classes.dir}/META-INF"/>
+ </target>
+
+ <target name="jee.install"
+ description="AppServer selective installation.">
+ <subant antfile="build.${build.mode}${app.server}.xml"
+ target="install"
+ inheritrefs="true"
+ inheritall="true"
+ buildpath="${basedir}"/>
+ </target>
+
+ <target name="install"
+ description="Default application installation">
<move file="openbooks.war" todir="${deploy.dir}" overwrite="true"/>
</target>
Modified: openjpa/trunk/openjpa-examples/openbooks/build.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/build.xml?rev=948207&r1=948206&r2=948207&view=diff
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/build.xml (original)
+++ openjpa/trunk/openjpa-examples/openbooks/build.xml Tue May 25 21:12:08 2010
@@ -44,9 +44,9 @@
<!-- JPA configuration file anchored by the persistence unit name -->
<property name="jpa.properties" value="META-INF/persistence.xml#OpenBooks"/>
<!-- ================================================================== -->
-
-
-
+ <!-- Application/Web Server type: -->
+ <!-- geronimo, was, tomcat, glassfish, or empty string for default -->
+ <property name="appserver" value=""/>
<!-- ================================================================== -->
<!-- Root directory of all derived artifacts -->
<property name="target.dir" value="${basedir}/target"/>
Added: openjpa/trunk/openjpa-examples/openbooks/scripts/was/ds_config.py
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/scripts/was/ds_config.py?rev=948207&view=auto
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/scripts/was/ds_config.py (added)
+++ openjpa/trunk/openjpa-examples/openbooks/scripts/was/ds_config.py Tue May 25 21:12:08 2010
@@ -0,0 +1,111 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
+import sys
+import os
+global AdminConfig
+global AdminTask
+
+#-----------------------------------------------------------------
+# getName - Returns the base name of the config object.
+#-----------------------------------------------------------------
+def getName (objectId):
+ endIndex = (objectId.find("(c") - 1)
+ stIndex = 0
+ if (objectId.find("\"") == 0):
+ stIndex = 1
+ #endIf
+ return objectId[stIndex:endIndex+1]
+#endDef
+
+#-----------------------------------------------------------------
+# getNodeId - Return the node id of the existing node. If in an
+# ND environment, returns the first node in the list.
+#-----------------------------------------------------------------
+def getNodeId ():
+ nodeList = AdminConfig.list("Node").split("\n")
+
+ node=""
+ if (len(nodeList) == 1):
+ node = nodeList[0]
+ #endIf
+
+ return node
+#endDef
+
+#-----------------------------------------------------------------
+# getServerId - Return the server id of the existing server. If
+# more than one server exists, returns the first server
+# in the list.
+#-----------------------------------------------------------------
+def getServerId ():
+ serverList = AdminConfig.list("Server").split("\n")
+
+ server = serverList[0]
+ return server
+#endDef
+
+def addDatasourceProperty (datasourceId, name, value):
+ parms = ["-propertyName", name, "-propertyValue", value]
+ AdminTask.setResourceProperty(datasourceId, parms)
+#endDef
+
+# Set the default database provider to Derby
+DefaultProviderType="Derby"
+DefaultProviderName="Derby JDBC Provider"
+DefaultPathName="${DERBY_JDBC_DRIVER_PATH}/derby.jar"
+DefaultNativePathName= ""
+
+# If in an ND environment with multiple nodes or servers
+# specify the target node and server name
+TargetNodeName = ""
+TargetServerName = ""
+
+if (TargetNodeName == ""):
+ TargetNodeName = getName(getNodeId())
+#endIf
+
+if (TargetServerName == ""):
+ TargetServerName = getName(getServerId())
+#endIf
+
+print "TargetNodeName: " + TargetNodeName
+print "TargetServerName: " + TargetServerName
+
+# Build the scope for the Derby provider
+scope = AdminConfig.getid("/Node:"+TargetNodeName+"/Server:"+TargetServerName+"/")
+
+scopeName = getName(scope)
+print "Scope: " + scopeName
+
+providerId = AdminConfig.getid("/Server:"+scopeName+"/JDBCProvider:\""+DefaultProviderName+"\"/" )
+
+if (providerId == ""):
+ print "Creating new JDBC provider"
+ providerId = AdminTask.createJDBCProvider('[-scope Node='+TargetNodeName+',Server='+TargetServerName+' -databaseType Derby -providerType "Derby JDBC Provider" -implementationType "Connection pool data source" -name "Derby JDBC Provider" -description "Derby embedded non-XA JDBC Provider." -classpath [${DERBY_JDBC_DRIVER_PATH}/derby.jar ] -nativePath "" ]')
+#endIf
+
+print "Creating new JDBC data sources"
+dataSourceId = AdminTask.createDatasource(providerId, '[-name "OpenBooks Data Source" -jndiName jdbc/OpenBooks -dataStoreHelperClassName com.ibm.websphere.rsadapter.DerbyDataStoreHelper -containerManagedPersistence false -componentManagedAuthenticationAlias -configureResourceProperties [[databaseName java.lang.String OpenBooks]]')
+addDatasourceProperty(dataSourceId, "createDatabase", "create")
+nonTxDataSourceId = AdminTask.createDatasource(providerId, '[-name "OpenBooks Non-transactional Data Source" -jndiName jdbc/NonTxOpenBooks -dataStoreHelperClassName com.ibm.websphere.rsadapter.DerbyDataStoreHelper -containerManagedPersistence false -componentManagedAuthenticationAlias -configureResourceProperties [[databaseName java.lang.String OpenBooks]]')
+addDatasourceProperty(nonTxDataSourceId, "nonTransactionalDataSource", "true")
+
+print "Saving configuration"
+AdminConfig.save( )
+print "Done"
\ No newline at end of file
Propchange: openjpa/trunk/openjpa-examples/openbooks/scripts/was/ds_config.py
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-examples/openbooks/src/main/resources/META-INF/persistence.jee.was.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/src/main/resources/META-INF/persistence.jee.was.xml?rev=948207&view=auto
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/src/main/resources/META-INF/persistence.jee.was.xml (added)
+++ openjpa/trunk/openjpa-examples/openbooks/src/main/resources/META-INF/persistence.jee.was.xml Tue May 25 21:12:08 2010
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ version="1.0">
+ <persistence-unit name="OpenBooks">
+ <jta-data-source>jdbc/OpenBooks</jta-data-source>
+ <non-jta-data-source>jdbc/NonTxOpenBooks</non-jta-data-source>
+
+ <class>openbook.domain.Book</class>
+ <class>openbook.domain.Inventory</class>
+ <class>openbook.domain.PurchaseOrder</class>
+ <class>openbook.domain.LineItem</class>
+ <class>openbook.domain.Customer</class>
+ <class>openbook.domain.Author</class>
+
+ <properties>
+ <property name="openjpa.DataCache" value="true"/>
+ <property name="openjpa.RemoteCommitProvider" value="sjvm"/>
+ <property name="openjpa.DynamicEnhancementAgent" value="false"/>
+ <property name="openjpa.RuntimeUnenhancedClasses" value="unsupported"/>
+
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ <property name="openjpa.jdbc.QuerySQLCache" value="true(EnableStatistics=true)"/>
+
+ </properties>
+ </persistence-unit>
+
+</persistence>
Propchange: openjpa/trunk/openjpa-examples/openbooks/src/main/resources/META-INF/persistence.jee.was.xml
------------------------------------------------------------------------------
svn:eol-style = native