Added: incubator/jdo/trunk/ri11/maven.xml URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/maven.xml?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/maven.xml (added) +++ incubator/jdo/trunk/ri11/maven.xml Fri Mar 18 17:02:29 2005 @@ -0,0 +1,371 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Check existence of XML metadata for pc classes + + + + + + + + + + + Enhance persistence-capable and persistence-aware classes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: incubator/jdo/trunk/ri11/project.properties URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/project.properties?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/project.properties (added) +++ incubator/jdo/trunk/ri11/project.properties Fri Mar 18 17:02:29 2005 @@ -0,0 +1,204 @@ +# +# Copyright 2005 The Apache Software Foundation. +# +# 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. + +# Start new JVM for junit tests +maven.junit.fork = yes +maven.junit.dir = ${jdo.testdir} + +# checkstyle settings +maven.checkstyle.properties = ${basedir}/../jdo_checks.xml +maven.checkstyle.excludes = \ +org/apache/jdo/impl/jdoql/jdoqlc/*TokenTypes.java,\ +org/apache/jdo/impl/jdoql/jdoqlc/JDOQLParser.java, \ +org/apache/jdo/impl/jdoql/jdoqlc/JDOQLLexer.java, \ +org/apache/jdo/impl/jdoql/jdoqlc/Semantic.java, \ +org/apache/jdo/impl/jdoql/jdoqlc/Optimizer.java + +# dependencies +jdo.jdoapi.jarfile = ${pom.getDependencyPath('jdo:jdo-api')} +jdo.jdobtree.jarfile = ${pom.getDependencyPath('jdo:jdo-btree')} +junit.jarfile = ${pom.getDependencyPath('junit:junit')} +antlr.jarfile = ${pom.getDependencyPath('antlr:antlr')} +jta.jarfile = ${pom.getDependencyPath('geronimo-spec:geronimo-spec-jta')} +logging.jarfile = ${pom.getDependencyPath('commons-logging')} +# JNDI implementation +jndi = ${basedir}/fscontext.jar${path.separator}${basedir}/providerutil.jar +xmlparser = + +jdo.antlr.src.dir = ${basedir}/src/java/org/apache/jdo/impl/jdoql/jdoqlc +jdo.testclasses.dir = ${maven.build.dir}/test-classes +jdo.pcclasses.jarfile = ${maven.build.dir}/test-classes/pcclasses.jar +jdo.testclasses.jarfile = ${maven.build.dir}/test-classes/jdo-ri-tests.jar +jdo.fsuid.jarfile = ${maven.build.dir}/test-classes/fsuid2.jar +jdo.testlist = ${basedir}/test/conf/tests.list +jdo.testdir = ${maven.build.dir}/database +jdo.security.policy = ${basedir}/test/conf/JDO11Policy + +# enhancer +jdo.enhancer.enhanced.dir = ${maven.build.dir}/test-classes +jdo.enhancer.main = org.apache.jdo.enhancer.Main +jdo.enhancer.options = -f -d "${jdo.enhancer.enhanced.dir}" -s "${jdo.enhancer.sourcepath}" +jdo.enhancer.sourcepath = ${maven.build.dir}/test-classes${path.separator}${jdo.jdoapi.jarfile} +jdo.enhancer.classpath = ${maven.build.dest}${path.separator}${jdo.jdoapi.jarfile}${path.separator}${logging.jarfile} +jdo.annotationtest.main = org.apache.jdo.impl.enhancer.util.AnnotationTest +jdo.annotationtest.options = -s "${jdo.enhancer.enhanced.dir}${path.separator}${jdo.enhancer.sourcepath}" +jdo.augmentationtest.main = org.apache.jdo.impl.enhancer.util.AugmentationTest +jdo.augmentationtest.options = -s "${jdo.enhancer.enhanced.dir}${path.separator}${jdo.enhancer.sourcepath}" +jdo.xmlexists.main = org.apache.jdo.impl.model.jdo.xml.XMLExists +jdo.xmlexists.classpath = ${maven.build.dir}/test-classes${path.separator}${jdo.enhancer.classpath} + +jdo.pcclasses.pc.classes= \ + org.apache.jdo.pc.PCArrays \ + org.apache.jdo.pc.PCCollections \ + org.apache.jdo.pc.PCCycle \ + org.apache.jdo.pc.PCCycle2 \ + org.apache.jdo.pc.PCDepartment \ + org.apache.jdo.pc.PCDepartment1 \ + org.apache.jdo.pc.PCEmployee \ + org.apache.jdo.pc.PCEmployee1 \ + org.apache.jdo.pc.PCFullTimeEmployee1 \ + org.apache.jdo.pc.PCInsurance \ + org.apache.jdo.pc.PCInsurance1 \ + org.apache.jdo.pc.PCInterfaces \ + org.apache.jdo.pc.PCLargeObj \ + org.apache.jdo.pc.PCPoint \ + org.apache.jdo.pc.PCPoint1 \ + org.apache.jdo.pc.PCPrimitive \ + org.apache.jdo.pc.PCProject \ + org.apache.jdo.pc.PCProject1 \ + org.apache.jdo.pc.PCRect \ + org.apache.jdo.pc.PCRefArrays \ + org.apache.jdo.pc.PCSCO \ + org.apache.jdo.pc.PCStroke \ + org.apache.jdo.pc.PCBase \ + org.apache.jdo.pc.PCDerived \ + org.apache.jdo.pc.PCId \ + org.apache.jdo.pc.PCCollection + +jdo.pcclasses.pc.files= \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCArrays.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCCollections.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCCycle.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCCycle2.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCDepartment.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCDepartment1.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCEmployee.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCEmployee1.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCFullTimeEmployee1.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCInsurance.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCInsurance1.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCInterfaces.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCLargeObj.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCPoint.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCPoint1.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCPrimitive.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCProject.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCProject1.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCRect.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCRefArrays.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCSCO.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCStroke.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCBase.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCDerived.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCId.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/PCCollection.class + +jdo.pcclasses.empdept.classes= \ + org.apache.jdo.pc.empdept.PCPerson \ + org.apache.jdo.pc.empdept.PCEmployee \ + org.apache.jdo.pc.empdept.PCFullTimeEmployee \ + org.apache.jdo.pc.empdept.PCPartTimeEmployee \ + org.apache.jdo.pc.empdept.PCInsurance \ + org.apache.jdo.pc.empdept.PCDepartment \ + org.apache.jdo.pc.empdept.PCProject + +jdo.pcclasses.empdept.files= \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/empdept/PCPerson.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/empdept/PCEmployee.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/empdept/PCFullTimeEmployee.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/empdept/PCPartTimeEmployee.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/empdept/PCInsurance.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/empdept/PCDepartment.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/empdept/PCProject.class + +jdo.pcclasses.xempdept.classes= \ + org.apache.jdo.pc.xempdept.Company \ + org.apache.jdo.pc.xempdept.Department \ + org.apache.jdo.pc.xempdept.Person \ + org.apache.jdo.pc.xempdept.Employee \ + org.apache.jdo.pc.xempdept.FullTimeEmployee \ + org.apache.jdo.pc.xempdept.PartTimeEmployee \ + org.apache.jdo.pc.xempdept.Insurance \ + org.apache.jdo.pc.xempdept.Project \ + org.apache.jdo.pc.xempdept.PrimitiveTypes + +jdo.pcclasses.xempdept.files= \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/xempdept/Company.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/xempdept/Department.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/xempdept/Person.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/xempdept/Employee.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/xempdept/FullTimeEmployee.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/xempdept/PartTimeEmployee.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/xempdept/Insurance.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/xempdept/Project.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/xempdept/PrimitiveTypes.class + +jdo.pcclasses.appid.classes= \ + org.apache.jdo.pc.appid.PCPoint \ + org.apache.jdo.pc.appid.PCRect \ + org.apache.jdo.pc.appid.PCPerson \ + org.apache.jdo.pc.appid.PCEmployee \ + org.apache.jdo.pc.appid.PCFullTimeEmployee \ + org.apache.jdo.pc.appid.PCPartTimeEmployee \ + org.apache.jdo.pc.appid.PCInsurance \ + org.apache.jdo.pc.appid.PCDepartment \ + org.apache.jdo.pc.appid.PCProject \ + org.apache.jdo.pc.appid.PCObjectKey + +jdo.pcclasses.appid.files= \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/appid/PCPoint.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/appid/PCRect.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/appid/PCPerson.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/appid/PCEmployee.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/appid/PCFullTimeEmployee.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/appid/PCPartTimeEmployee.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/appid/PCInsurance.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/appid/PCDepartment.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/appid/PCProject.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/appid/PCObjectKey.class + +jdo.pcclasses.serializable.classes= \ + org.apache.jdo.pc.serializable.PCClass1 \ + org.apache.jdo.pc.serializable.PCClass2A \ + org.apache.jdo.pc.serializable.PCClass2B \ + org.apache.jdo.pc.serializable.PCSuper \ + org.apache.jdo.pc.serializable.PCSub3 \ + org.apache.jdo.pc.serializable.PCSub4A \ + org.apache.jdo.pc.serializable.PCSub4B + +jdo.pcclasses.serializable.files= \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/serializable/PCClass1.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/serializable/PCClass2A.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/serializable/PCClass2B.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/serializable/PCSuper.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/serializable/PCSub3.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/serializable/PCSub4A.class \ + ${jdo.testclasses.dir}/org/apache/jdo/pc/serializable/PCSub4B.class + +jdo.pawareclasses.test.classes= \ + org.apache.jdo.test.Test_PCDerived + +jdo.pawareclasses.test.files= \ + ${jdo.testclasses.dir}/org/apache/jdo/test/Test_PCDerived.class Added: incubator/jdo/trunk/ri11/project.xml URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/project.xml?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/project.xml (added) +++ incubator/jdo/trunk/ri11/project.xml Fri Mar 18 17:02:29 2005 @@ -0,0 +1,117 @@ + + + + + 3 + ../project.xml + + + + JDO Reference Implementation 1.1 + jdo-ri + jdo-ri + 1.1 + org.apache.jdo + Java Data Object (JDO) RI + The Java Data Objects (JDO) API is a standard interface-based +Java model abstraction of persistence, developed as Java Specification +Request 12 JSR 12 under the auspices of the Java Community Process. + + + + + + + antlr + antlr + 2.7.3 + http://www.antlr.org/download.html + + + junit + junit + 3.8.1 + + + geronimo-spec + geronimo-spec-jta + 1.0.1B-rc2 + + + commons-logging + 1.0.4 + + + jdo + jdo-api + 1.1 + + + jdo + jdo-btree + 1.1 + + + + + + + src/java + test/java + + + + org/**/Test_*.java + + + org/**/util/*.java + org/**/Test_ClassRegistration.java + org/**/Test_FSUID2.java + org/**/Test_FetchInserted.java + org/**/Test_GetObjectById2.java + org/**/Test_NonExistent.java + org/**/Test_EmpDeptAppIdInsert.java + org/**/Test_EmpDeptAppIdUpdate.java + org/**/Test_EmpDeptAppIdDelete.java + + + + ${basedir}/test/conf + + PMF.properties + jndi.properties + commons-logging.properties + simplelog.properties + logging.properties + + + + + + + + + ${basedir}/src/java + + **/*.properties + + + + + + Added: incubator/jdo/trunk/ri11/src/conf/commons-logging.properties URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/conf/commons-logging.properties?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/conf/commons-logging.properties (added) +++ incubator/jdo/trunk/ri11/src/conf/commons-logging.properties Fri Mar 18 17:02:29 2005 @@ -0,0 +1,44 @@ +# +# Copyright 2005 The Apache Software Foundation. +# +# 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. + +# +# This is a sample apache commons logging configuration file defining logging +# properties for the JDO RI sources. It defines what logging implementation +# the apache commons logging API should use by specifying the property +# org.apache.commons.logging.Log (see below). Please note, that there are +# separate property files for each logging implementation to set the log +# level of the loggers: +# - SimpleLog: simplelog.properties +# - JDK1.4 logging: logging.properties +# +# The JDO RI sources use the following logger instances: +# org.apache.jdo.impl.fostore File Object Store implementation +# org.apache.jdo.impl.jdoql JDOQL query runtime +# org.apache.jdo.impl.jdoql.jdoqlc JDOQL query compiler +# org.apache.jdo.impl.model.jdo JDOModel implementation +# org.apache.jdo.impl.model.jdo.xml XML parser for JDO metadata files +# org.apache.jdo.impl.pm PM and PMF implementation +# org.apache.jdo.impl.sco SCO implementation +# org.apache.jdo.impl.state StateManager implementation +# org.apache.jdo.store Generic StoreManager implementation +# org.apache.jdo.util Utility classes +# + +# Uncomment the next line if you want to use the apache simple logger +#org.apache.commons.logging.Log = org.apache.commons.logging.impl.SimpleLog + +# Uncomment the next two lines if you want to use JDK 1.4 logging +#org.apache.commons.logging.Log = org.apache.jdo.util.JDOJdk14Logger + Added: incubator/jdo/trunk/ri11/src/conf/logging.properties URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/conf/logging.properties?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/conf/logging.properties (added) +++ incubator/jdo/trunk/ri11/src/conf/logging.properties Fri Mar 18 17:02:29 2005 @@ -0,0 +1,62 @@ +# +# Copyright 2005 The Apache Software Foundation. +# +# 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. + +# +# This is a sample properties file to configure standard JDK 1.4 logging for +# the JDO RI sources. Below you find an entry for each of the JDO RI source +# logger instances. Please uncomment the line and adapt the log level to your +# needs, in case to want to enable a particular logger. +# +# The following describes the mapping between the log level of JDK 1.4 logging +# and apache commns logging: +# JDK 1.4 Apache +# FINEST trace +# FINE, FINER debug +# INFO, CONFIG info +# WARNING warn +# SEVERE error, fatal +# + +###################### +# JDORI sources +###################### + +# FOStore logger +#org.apache.jdo.impl.fostore.level = FINE +# JDOQL query logger +#org.apache.jdo.impl.jdoql.level = FINE +# JDOQL query compiler logger +#org.apache.jdo.impl.jdoql.jdoqlc.level = FINE +# JDOModel logger +#org.apache.jdo.impl.model.jdo.level = FINE +# XML parser logger +#org.apache.jdo.impl.model.jdo.xml.level = FINE +# PM and PMF logger +#org.apache.jdo.impl.pm.level = FINE +# SCO logger +#org.apache.jdo.impl.sco.level = FINE +# StateManager logger +#org.apache.jdo.impl.state.level = FINE +# Generic StoreManager logger +#org.apache.jdo.store.level = FINE +# Utility class logger +#org.apache.jdo.util.level = FINE + +###################### +# JDK 1.4 logging properties +###################### + +handlers = java.util.logging.ConsoleHandler +java.util.logging.ConsoleHandler.level = FINEST Added: incubator/jdo/trunk/ri11/src/conf/simplelog.properties URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/conf/simplelog.properties?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/conf/simplelog.properties (added) +++ incubator/jdo/trunk/ri11/src/conf/simplelog.properties Fri Mar 18 17:02:29 2005 @@ -0,0 +1,52 @@ +# +# Copyright 2005 The Apache Software Foundation. +# +# 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. + +# +# This is a sample properties file to configure apache commons logging SimpleLog +# implementation for the JDO RI sources. Below you find an entry for each of the +# JDO RI source logger instances. Please uncomment the line and adapt the log +# level to your needs, in case to want to enable a particular logger. +# + +###################### +# JDORI source logger +###################### + +# FOStore logger +#org.apache.commons.logging.simplelog.log.org.apache.jdo.impl.fostore = debug +# JDOQL query logger +#org.apache.commons.logging.simplelog.log.org.apache.jdo.impl.jdoql = debug +# JDOQL query compiler logger +#org.apache.commons.logging.simplelog.log.org.apache.jdo.impl.jdoql.jdoqlc = debug +# JDOModel logger +#org.apache.commons.logging.simplelog.log.org.apache.jdo.impl.model.jdo = debug +# XML parser logger +#org.apache.commons.logging.simplelog.log.org.apache.jdo.impl.model.jdo.xml = debug +# PM and PMF logger +#org.apache.commons.logging.simplelog.log.org.apache.jdo.impl.pm = debug +# SCO logger +#org.apache.commons.logging.simplelog.log.org.apache.jdo.impl.sco = debug +# StateManager logger +#org.apache.commons.logging.simplelog.log.org.apache.jdo.impl.state = debug +# Generic StoreManager logger +#org.apache.commons.logging.simplelog.log.org.apache.jdo.store = debug +# Utility class logger +#org.apache.commons.logging.simplelog.log.org.apache.jdo.util = debug + +###################### +# default logging level +###################### + +org.apache.commons.logging.simplelog.defaultlog = error Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/ejb/EJBHelper.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/ejb/EJBHelper.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/ejb/EJBHelper.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/ejb/EJBHelper.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,130 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * 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. + */ + +/* + * EJBHelper.java + * + * Created on December 15, 2000, 10:06 AM + */ + +package org.apache.jdo.ejb; + +import javax.transaction.Transaction; +import javax.transaction.UserTransaction; + +import javax.jdo.PersistenceManagerFactory; + +/** Provide a Forte for Java implementation with information about the distributed + * transaction environment. This is an interface that a helper class + * implements that is specific to a managed environment. + *

This interface is specific to Forte for Java, version 3.0, + * and is subject to change without notice. In particular, as additional + * experience is gained with specific application servers, this interface + * may have methods added and removed, even with patch releases. + * Therefore, this interface should be considered very volatile, and + * any class that implements it might have to be reimplemented whenever + * an upgrade to either the application server or Forte for Java occurs.

+ * The class that implements this interface must register itself + * by a static method at class initialization time. For example, + *
+ * import org.apache.jdo.*;
+ * class blackHerringEJBImplHelper implements EJBHelper {
+ *    static EJBHelper.register(new blackHerringEJBImplHelper());
+ *    ...
+ * }
+ * 
+ * + * @author Marina Vatkina + */ +public interface EJBHelper { + + /** Returns the UserTransaction associated with the calling thread. If there + * is no transaction currently in progress, this method returns null. + * @return the UserTransaction instance for the calling thread + */ + UserTransaction getUserTransaction(); + + /** Identify the Transaction context for the calling thread, and return a + * Transaction instance that can be used to register synchronizations, + * and used as the key for HashMaps. The returned Transaction must implement + * equals() and hashCode() based on the global transaction id. + *

All Transaction instances returned by this method called in the same + * Transaction context must compare equal and return the same hashCode. + * The Transaction instance returned will be held as the key to an + * internal HashMap until the Transaction completes. If there is no transaction + * associated with the current thread, this method returns null. + * @return the Transaction instance for the calling thread + */ + Transaction getTransaction(); + + /** Translate local representation of the Transaction Status to + * javax.transaction.Status value if necessary. Otherwise this method + * should return the value passed to it as an argument. + *

This method is used during afterCompletion callbacks to translate + * the parameter value passed by the application server to the + * afterCompletion method. The return value must be one of: + * javax.transaction.Status.STATUS_COMMITTED or + * javax.transaction.Status.STATUS_ROLLED_BACK. + * @param st local Status value + * @return the javax.transaction.Status value of the status + */ + int translateStatus(int st); + + /** Replace newly created instance of internal PersistenceManagerFactory + * with the hashed one if it exists. The replacement is necessary only if + * the JNDI lookup always returns a new instance. Otherwise this method + * returns the object passed to it as an argument. + * + * PersistenceManagerFactory is uniquely identified by + * ConnectionFactory.hashCode() if ConnectionFactory is + * not null; otherwise by ConnectionFactoryName.hashCode() if + * ConnectionFactoryName is not null; otherwise + * by the combination of URL.hashCode() + userName.hashCode() + + * password.hashCode() + driverName.hashCode(); + * + * @param pmf PersistenceManagerFactory instance to be replaced + * @return the PersistenceManagerFactory known to the runtime + */ + PersistenceManagerFactory replacePersistenceManagerFactory( + PersistenceManagerFactory pmf) ; + + /** Called at the beginning of the Transaction.beforeCompletion() to + * register the component with the app server if necessary. + * The component argument is an array of Objects. + * The first element is javax.jdo.Transaction object responsible for + * transaction completion. + * The second element is javax.jdo.PersistenceManager object that has + * been associated with the Transaction context for the calling thread. + * The third element is javax.transaction.Transaction object that has been + * associated with the given instance of PersistenceManager. + * The return value is passed unchanged to the postInvoke method. + * + * @param component an array of Objects + * @return implementation-specific Object + */ + Object enlistBeforeCompletion(Object component) ; + + /** Called at the end of the Transaction.beforeCompletion() to + * de-register the component with the app server if necessary. + * The parameter is the return value from preInvoke, and can be any + * Object. + * + * @param im implementation-specific Object + */ + void delistBeforeCompletion(Object im) ; + +} + Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/ejb/EJBImplHelper.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/ejb/EJBImplHelper.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/ejb/EJBImplHelper.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/ejb/EJBImplHelper.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,138 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * 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. + */ + +/* + * EJBImplHelper.java + * + * Created on December 15, 2000, 10:15 AM + */ +package org.apache.jdo.ejb; + +import javax.transaction.*; + +import javax.jdo.PersistenceManagerFactory; + +/** Provides helper methods for a Forte for Java implementation with the + * application server specific information in the distributed transaction + * environment. Calls corresponding methods on the registered class which + * implements EJBHelper interface. + * + * @author Marina Vatkina + */ +public class EJBImplHelper { + + /** Reference to a class that implements EJBHelper interface for this + * particular application server + */ + static EJBHelper myHelper; + + /** Register class that implements EJBHelper interface + * Should be called by a static method at class initialization time. + * + * @param h application server specific implemetation of the + * EJBHelper interface. + */ + public static void registerEJBHelper (EJBHelper h) { + myHelper = h; + } + + /** Returns Transaction instance that can be used to register + * synchronizations. In a non-managed environment or if there is no + * transaction associated with the current thread, this method + * returns null. + * + * @see EJBHelper#getTransaction() + * @return the Transaction instance for the calling thread + */ + public static Transaction getTransaction() { + return myHelper == null ? null : myHelper.getTransaction(); + } + + /** Returns the UserTransaction associated with the calling thread. + * In a non-managed environment or if there is no transaction + * currently in progress, this method returns null. + * + * @see EJBHelper#getUserTransaction() + * @return the UserTransaction instance for the calling thread + */ + public static UserTransaction getUserTransaction() { + return myHelper == null ? null : myHelper.getUserTransaction(); + } + + /** Identifies the managed environment behavior. + * @return true if there is a helper class registered. + */ + public static boolean isManaged() { + return myHelper != null; + } + + /** Translates local representation of the Transaction Status to + * javax.transaction.Status value. In a non-managed environment + * returns the value passed to it as an argument. + * + * @see EJBHelper#translateStatus(int st) + * @param st Status value + * @return the javax.transaction.Status value of the status + */ + public static int translateStatus(int st) { + return myHelper == null ? st : myHelper.translateStatus(st); + } + + /** Returns the hashed instance of internal PersistenceManagerFactory + * that compares equal to the newly created instance or the instance + * itself if it is not found. In a non-managed environment returns + * the value passed to it as an argument. + * + * @see EJBHelper#replacePersistenceManagerFactory( + * PersistenceManagerFactory pmf) + * @param pmf PersistenceManagerFactory instance to be replaced + * @return the PersistenceManagerFactory known to the runtime + */ + public static PersistenceManagerFactory replacePersistenceManagerFactory( + PersistenceManagerFactory pmf) { + return myHelper == null ? pmf : + myHelper.replacePersistenceManagerFactory(pmf); + } + + /** Called at the beginning of the Transaction.beforeCompletion() + * to register the component with the app server if necessary. In a + * non-managed environment or if the delistBeforeCompletion method + * does not use the value, this method returns null. + * + * @see EJBHelper#enlistBeforeCompletion(Object component) + * @param component an array of Objects + * @return implementation-specific Object + */ + public static Object enlistBeforeCompletion(Object component) { + return myHelper == null ? null : + myHelper.enlistBeforeCompletion(component); + } + + /** Called a non-managed environment at the end of the + * Transaction.beforeCompletion() to de-register the component with + * the app server if necessary. + * + * @see EJBHelper#delistBeforeCompletion(Object im) + * @param im implementation-specific Object + */ + public static void delistBeforeCompletion(Object im) { + if (myHelper != null) { + myHelper.delistBeforeCompletion(im); + } + } + +} + Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/ejb/package.html URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/ejb/package.html?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/ejb/package.html (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/ejb/package.html Fri Mar 18 17:02:29 2005 @@ -0,0 +1,26 @@ + + + + +Package org.apache.jdo.ejb + + + + +

This package contains classes and interfaces for EJB support.

+ + Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/enhancer/EnhancerMain.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/enhancer/EnhancerMain.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/enhancer/EnhancerMain.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/enhancer/EnhancerMain.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,387 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * 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.jdo.enhancer; + +import java.io.IOException; +import java.io.File; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.PrintWriter; + +import java.util.List; +import java.util.Iterator; +import java.util.Properties; + +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; + +import org.apache.jdo.impl.enhancer.ClassFileEnhancer; +import org.apache.jdo.impl.enhancer.ClassFileEnhancerHelper; +import org.apache.jdo.impl.enhancer.ClassFileEnhancerTimer; +import org.apache.jdo.impl.enhancer.EnhancerFatalError; +import org.apache.jdo.impl.enhancer.EnhancerOptions; +import org.apache.jdo.impl.enhancer.EnhancerUserException; +import org.apache.jdo.impl.enhancer.JdoMetaMain; +import org.apache.jdo.impl.enhancer.OutputStreamWrapper; +import org.apache.jdo.impl.enhancer.core.EnhancerFilter; + + + +/** + * JDO command line enhancer. + * + * @author Martin Zaun + */ +public class EnhancerMain + extends JdoMetaMain +{ + /** + * The options and arguments. + */ + protected EnhancerOptions options; + + /** + * The byte code enhancer. + */ + protected ClassFileEnhancer enhancer; + + /** + * Creates an instance. + */ + public EnhancerMain(PrintWriter out, + PrintWriter err) + { + this(out, err, new EnhancerOptions(out, err)); + } + + /** + * Creates an instance. + */ + public EnhancerMain(PrintWriter out, + PrintWriter err, + EnhancerOptions options) + { + super(out, err, options); + this.options = options; + } + + // ---------------------------------------------------------------------- + + /** + * Enhances all files entered in the command line. + * + * @param classNames List of class names. + * @param classFileNames List of class file names. + * @param archiveFileNames List of archive file names. + */ + private int enhanceInputFiles(List classNames, + List classFileNames, + List archiveFileNames) + { + int res = 0; + try { + String name = null; + for (Iterator i = archiveFileNames.iterator(); i.hasNext();) { + try { + name = (String)i.next(); + enhanceArchiveFile(name); + } catch (EnhancerUserException ex) { + printlnErr("Error while enhancing " + name, ex, + options.verbose.value); + res++; + continue; + } + } + for (Iterator i = classFileNames.iterator(); i.hasNext();) { + try { + name = (String)i.next(); + enhanceClassFile(openFileInputStream(name)); + } catch (EnhancerUserException ex) { + printlnErr("Error while enhancing " + name, ex, + options.verbose.value); + res++; + continue; + } + } + for (Iterator i = classNames.iterator(); i.hasNext();) { + try { + name = (String)i.next(); + enhanceClassFile(openClassInputStream(name)); + } catch (EnhancerUserException ex) { + printlnErr("Error while enhancing " + name, ex, + options.verbose.value); + res++; + continue; + } + } + } catch (IOException ex) { + printlnErr("IO Error while enhancing", ex, options.verbose.value); + return ++res; + } catch (EnhancerFatalError ex) { + // enhancer is not anymore guaranteed to be consistent + printlnErr("Fatal error while enhancing", ex, options.verbose.value); + enhancer = null; + return ++res; + } + return res; + } + + /** + * Enhances a classfile. + * + * @param in The input stream of the classfile. + */ + private void enhanceClassFile(InputStream in) + throws IOException, EnhancerUserException, EnhancerFatalError + { + OutputStream out = null; + try { + final File temp = File.createTempFile("enhancer", ".class"); + out = new BufferedOutputStream(new FileOutputStream(temp)); + + //enhance + final OutputStreamWrapper wrapper = new OutputStreamWrapper(out); + final boolean enhanced = enhancer.enhanceClassFile(in, wrapper); + + closeOutputStream(out); + out = null; + createOutputFile(enhanced, + getClassFileName(wrapper.getClassName()), temp); + } finally { + closeInputStream(in); + closeOutputStream(out); + } + } + + /** + * Enhances a archive file. + * + * @param fileName The filename of the archive file. + */ + private void enhanceArchiveFile(String fileName) + throws IOException, EnhancerUserException, EnhancerFatalError + { + ZipInputStream in = null; + ZipOutputStream out = null; + try { + final File temp = File.createTempFile("enhancer", ".zip"); + in = new ZipInputStream(new BufferedInputStream( + new FileInputStream(new File(fileName)))); + out = new ZipOutputStream(new BufferedOutputStream( + new FileOutputStream(temp))); + + // enhance the archive file + final boolean enhanced + = ClassFileEnhancerHelper.enhanceZipFile(enhancer, in, out); + + // create the output file + closeOutputStream(out); + out = null; + createOutputFile(enhanced, new File(fileName).getName(), temp); + } finally { + closeOutputStream(out); + closeInputStream(in); + } + } + + /** + * Creates a file object that represents the output archive file for + * a given archive file to enhance. + * + * @param archiveFileName the input archive file name + * @return the output archive file + */ + private File createArchiveOutputFile(String archiveFileName) + { + return new File(options.destDir.value, + new File(archiveFileName).getName()); + } + + /** + * Creates the output file for an enhanced class- or archive file. If the + * enhanced file is written back depends on the command line options. + * + * @param enhanced Has the input file been enhanced? + * @param fileName The name of the output file. + * @param temp The temp file, the output is written to. + * @exception IOException If the file could not be created. + */ + private void createOutputFile(boolean enhanced, + String fileName, + File temp) + throws IOException + { + //noWrite or (not enhanced and not forceWrite) + if (options.noWrite.value + || (!enhanced && !options.forceWrite.value)) { + temp.deleteOnExit(); + return; + } + + // create file and its parent directory + final File file = new File(options.destDir.value, fileName); + final File dir = file.getAbsoluteFile().getParentFile(); + if (!dir.exists() && !dir.mkdirs()) { + throw new IOException("Error creating directory '" + + dir.getAbsolutePath() + "'."); + } + + file.delete(); //delete old file if exists + boolean renamed = temp.renameTo(file); + if (!renamed) { + //@dave: empirical evidence shows that renameTo does not allow for + // crossing filesystem boundaries. If it fails, try "by hand". + InputStream in = null; + OutputStream out = null; + try { + in = new FileInputStream(temp); + out = new FileOutputStream(file); + int PAGESIZE = 4096; // Suggest a better size? + byte data[] = new byte[PAGESIZE]; + while (in.available() > 0) { + int numRead = in.read(data, 0, PAGESIZE); + out.write(data, 0, numRead); + } + renamed = true; + } catch (IOException ex) { + throw new IOException("Could not rename temp file '" + + temp.getAbsolutePath() + + "' to '" + file.getAbsolutePath() + + "': " + ex); + } finally { + closeInputStream(in); + closeOutputStream(out); + } + if (renamed) { + temp.delete(); //delete temporary file + } + else { + throw new IOException("Could not rename temp file '" + + temp.getAbsolutePath() + + "' to '" + file.getAbsolutePath() + "'."); + } + } + } + + /** + * Closes an output stream. + * + * @param out the output stream + */ + private void closeOutputStream(OutputStream out) + { + if (out != null) { + try { + out.close(); + } catch (IOException ex) { + printlnErr("", ex, options.verbose.value); + } + } + } + + // ---------------------------------------------------------------------- + + /** + * Initializes all components. + */ + protected void init() + throws EnhancerFatalError, EnhancerUserException + { + super.init(); + + final Properties props = new Properties(); + if (options.verbose.value) { + props.put(EnhancerFilter.VERBOSE_LEVEL, + EnhancerFilter.VERBOSE_LEVEL_VERBOSE); + } + + if (options.doTiming.value) { + props.put(EnhancerFilter.DO_TIMING_STATISTICS, + Boolean.TRUE.toString()); + } + + if (options.dumpClass.value) { + props.put(EnhancerFilter.DUMP_CLASS, + Boolean.TRUE.toString()); + } + + if (options.noAugment.value) { + props.put(EnhancerFilter.NO_AUGMENT, + Boolean.TRUE.toString()); + } + + if (options.noAnnotate.value) { + props.put(EnhancerFilter.NO_ANNOTATE, + Boolean.TRUE.toString()); + } + + try { + enhancer = new EnhancerFilter(jdoMeta, props, out, err); + if (options.doTiming.value) { + // wrap with timing byte-code enhancer + enhancer = new ClassFileEnhancerTimer(enhancer); + } + } catch (EnhancerUserException ex) { + printlnErr("Error while creating the enhancer", ex, + options.verbose.value); + throw ex; + } catch (EnhancerFatalError ex) { + // enhancer is not anymore guaranteed to be consistent + printlnErr("Fatal error while creating the enhancer", ex, + options.verbose.value); + enhancer = null; + throw ex; + } catch (RuntimeException ex) { + // enhancer is not anymore guaranteed to be consistent + printlnErr("Internal error while creating the enhancer", ex, + options.verbose.value); + enhancer = null; + throw new EnhancerFatalError(ex); + } + } + + /** + * Run the enhancer. + */ + protected int process() + { + return enhanceInputFiles(options.classNames, + options.classFileNames, + options.archiveFileNames); + } + + // ---------------------------------------------------------------------- + + /** + * Runs this class + */ + static public void main(String[] args) + { + final PrintWriter out = new PrintWriter(System.out, true); + out.println("--> EnhancerMain.main()"); + //out.println("JDO RI Class-File Enhancer"); + final EnhancerMain main = new EnhancerMain(out, out); + int res = main.run(args); + //out.println("done."); + out.println("<-- EnhancerMain.main(): exit = " + res); + System.exit(res); + } +}