You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by mb...@apache.org on 2005/05/22 20:01:48 UTC

svn commit: r171352 [1/11] - in /incubator/jdo/trunk/runtime20: ./ src/ src/conf/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/jdo/ src/java/org/apache/jdo/ejb/ src/java/org/apache/jdo/impl/ src/java/org/apache/jdo/impl/model/ src/java/org/apache/jdo/impl/model/java/ src/java/org/apache/jdo/impl/model/java/runtime/ src/java/org/apache/jdo/impl/model/jdo/ src/java/org/apache/jdo/impl/model/jdo/xml/ src/java/org/apache/jdo/impl/pm/ src/java/org/apache/jdo/impl/sco/ src/java/org/apache/jdo/impl/state/ src/java/org/apache/jdo/pm/ src/java/org/apache/jdo/query/ src/java/org/apache/jdo/sco/ src/java/org/apache/jdo/state/ src/java/org/apache/jdo/store/

Author: mbo
Date: Sun May 22 11:01:45 2005
New Revision: 171352

URL: http://svn.apache.org/viewcvs?rev=171352&view=rev
Log:
First version of JDO2 implementation (Runtime). It includes implementation for the components pm, pmf, state manager, life cycle states, sco, store manager interface and runtime meta data support.

Added:
    incubator/jdo/trunk/runtime20/
    incubator/jdo/trunk/runtime20/maven.xml
    incubator/jdo/trunk/runtime20/project.properties
    incubator/jdo/trunk/runtime20/project.xml
    incubator/jdo/trunk/runtime20/src/
    incubator/jdo/trunk/runtime20/src/conf/
    incubator/jdo/trunk/runtime20/src/conf/commons-logging.properties
    incubator/jdo/trunk/runtime20/src/conf/logging.properties
    incubator/jdo/trunk/runtime20/src/conf/simplelog.properties
    incubator/jdo/trunk/runtime20/src/java/
    incubator/jdo/trunk/runtime20/src/java/org/
    incubator/jdo/trunk/runtime20/src/java/org/apache/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/ejb/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/ejb/EJBHelper.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/ejb/EJBImplHelper.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/ejb/package.html
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/Bundle.properties
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RegisterClassListener.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaModel.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaModelFactory.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaType.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/package.html
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/jdo/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/jdo/xml/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/jdo/xml/XMLExists.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/pm/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/pm/Bundle.properties
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/pm/CacheManagerImpl.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/pm/PersistenceManagerFactoryImpl.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/pm/PersistenceManagerImpl.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/pm/PersistenceManagerWrapper.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/pm/TransactionImpl.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/pm/TransactionSynchronization.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/pm/package.html
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/ArrayList.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/Bundle.properties
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/Date.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/Freezer.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/HashMap.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/HashSet.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/Hashtable.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/LinkedList.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/SCOHelper.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/SqlDate.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/SqlTime.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/SqlTimestamp.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/TreeMap.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/TreeSet.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/Vector.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/sco/package.html
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/AutoPersistentNew.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/AutoPersistentNewFlushed.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/AutoPersistentNewFlushedDirty.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/AutoPersistentPending.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/Bundle.properties
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/Hollow.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/LifeCycleState.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/PersistentClean.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/PersistentCleanTransactional.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/PersistentDeleted.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/PersistentDeletedFlushed.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/PersistentDirty.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/PersistentDirtyFlushed.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/PersistentNew.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/PersistentNewDeleted.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/PersistentNewFlushed.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/PersistentNewFlushedDeleted.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/PersistentNewFlushedDirty.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/PersistentNonTransactional.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/ReachabilityHandler.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/SCOProcessor.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/SimpleFieldManager.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/StateFieldManager.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/StateManagerFactory.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/StateManagerImpl.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/TransientClean.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/TransientDirty.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/Accessor.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/PersistenceManagerFactoryInternal.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/PersistenceManagerInternal.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/package.html
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/BasicQueryResult.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/Bundle.properties
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/QueryResult.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/QueryResultHelper.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/QueryResultIterator.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCO.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCOCollection.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCODate.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCOMap.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/package.html
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/FieldManager.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/StateManagerInternal.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/package.html
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/Bundle.properties
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/Connector.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/StoreManager.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/StoreManagerImpl.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/Transcriber.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/TranscriberFactory.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/package.html

Added: incubator/jdo/trunk/runtime20/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/maven.xml?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/maven.xml (added)
+++ incubator/jdo/trunk/runtime20/maven.xml Sun May 22 11:01:45 2005
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<project default="default"
+    xmlns:j="jelly:core"
+    xmlns:ant="jelly:ant"
+    xmlns:maven="jelly:maven"
+    >
+
+    <!-- ==================== -->
+    <!-- Default Global Goals -->
+    <!-- ==================== -->
+
+    <goal name="default">
+        <attainGoal name="jar:install-snapshot"/>
+    </goal>
+
+    <goal name="build">
+        <attainGoal name="default"/>
+    </goal>
+
+    <goal name="rebuild">
+        <attainGoal name="clean"/>
+        <attainGoal name="build"/>
+    </goal>
+
+    <goal name="clobber" prereqs="clean">
+        <delete>
+            <fileset dir="." defaultexcludes="no" includes="**/*~"/>
+        </delete>
+    </goal>
+
+</project>

Added: incubator/jdo/trunk/runtime20/project.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/project.properties?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/project.properties (added)
+++ incubator/jdo/trunk/runtime20/project.properties Sun May 22 11:01:45 2005
@@ -0,0 +1,18 @@
+#
+# 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.
+
+# checkstyle settings
+maven.checkstyle.properties = ${basedir}/../jdo_checks.xml
+

Added: incubator/jdo/trunk/runtime20/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/project.xml?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/project.xml (added)
+++ incubator/jdo/trunk/runtime20/project.xml Sun May 22 11:01:45 2005
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+-->
+
+<project>
+    <pomVersion>3</pomVersion>
+    <extend>../project.xml</extend>
+    <!-- ============== -->
+    <!-- Identification -->
+    <!-- ============== -->
+    <name>JDO2 Implementation (Runtime)</name>
+    <artifactId>jdo2-runtime</artifactId>
+    <currentVersion>2.0</currentVersion>
+    <package>org.apache.jdo</package>
+    <shortDescription>Java Data Object 2.0 (JDO) Runtime</shortDescription>
+    <description>The Java Data Objects 2.0 (JDO) API is a standard interface-based 
+Java model abstraction of persistence, developed as Java Specification 
+Request JSR 243 under the auspices of the Java Community Process.</description>
+    <repository />
+    <!-- ============ -->
+    <!-- Dependencies -->
+    <!-- ============ -->
+    <dependencies>
+        <dependency>
+            <groupId>apache-jdo</groupId>
+            <artifactId>jdo1-api</artifactId>
+            <version>SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>apache-jdo</groupId>
+            <artifactId>jdo2-core</artifactId>
+            <version>SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <id>commons-logging</id>
+            <version>1.0.4</version>
+        </dependency>
+        <dependency>
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-jta</artifactId>
+            <version>1.0.1B-rc2</version>
+        </dependency>
+    </dependencies>
+    <!-- =================== -->
+    <!-- Build Specification -->
+    <!-- =================== -->
+    <build>
+        <sourceDirectory>src/java</sourceDirectory>
+        <!-- J A R  R E S O U R C E S -->
+        <!-- Resources that are packaged up inside the JAR file -->
+        <resources>
+            <resource>
+                <directory>${basedir}/src/java</directory>
+                <includes>
+                    <include>**/*.properties</include>
+                </includes>
+            </resource>
+        </resources>
+    </build>
+</project>
+

Added: incubator/jdo/trunk/runtime20/src/conf/commons-logging.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/conf/commons-logging.properties?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/conf/commons-logging.properties (added)
+++ incubator/jdo/trunk/runtime20/src/conf/commons-logging.properties Sun May 22 11:01:45 2005
@@ -0,0 +1,42 @@
+#
+# 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 JDO2 Implementation (Runtime) 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 JDO2 Implementation (Runtime) sources use the following logger instances:
+# 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
+# Dependent projects:
+# org.apache.jdo.util                 Utility classes
+# org.apache.jdo.impl.model.jdo       JDOModel implementation
+# org.apache.jdo.impl.model.jdo.xml   XML parser for JDO metadata files
+#
+
+# 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/runtime20/src/conf/logging.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/conf/logging.properties?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/conf/logging.properties (added)
+++ incubator/jdo/trunk/runtime20/src/conf/logging.properties Sun May 22 11:01:45 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 JDO2 Implementation (Runtime) sources. 
+# Below you find an entry for each of the 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
+#
+
+######################
+# Runtime source logger
+######################
+
+# 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
+
+######################
+# Dependent projects
+######################
+
+# Utility class logger
+#org.apache.jdo.util.level = FINE
+# JDOModel logger
+#org.apache.jdo.impl.model.jdo.level = FINE
+# XML parser logger
+#org.apache.jdo.impl.model.jdo.xml.level = FINE
+
+######################
+# JDK 1.4 logging properties
+######################
+
+handlers = java.util.logging.ConsoleHandler
+java.util.logging.ConsoleHandler.level = FINEST

Added: incubator/jdo/trunk/runtime20/src/conf/simplelog.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/conf/simplelog.properties?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/conf/simplelog.properties (added)
+++ incubator/jdo/trunk/runtime20/src/conf/simplelog.properties Sun May 22 11:01:45 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 JDO2 Implementation (Runtime) sources.
+# Below you find an entry for each of the source logger instances. 
+# Please uncomment the line and adapt the log level to your needs, 
+# in case to want to enable a particular logger.
+#
+
+######################
+# Runtime source logger
+######################
+
+# 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
+
+######################
+# Dependent projects
+######################
+
+# Utility class logger
+#org.apache.commons.logging.simplelog.log.org.apache.jdo.util = 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
+
+######################
+# Default logging level
+######################
+
+org.apache.commons.logging.simplelog.defaultlog = error

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/ejb/EJBHelper.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/ejb/EJBHelper.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/ejb/EJBHelper.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/ejb/EJBHelper.java Sun May 22 11:01:45 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.
+ * <P><B>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.</B></P>
+ * The class that implements this interface must register itself
+ * by a static method at class initialization time.  For example,
+ * <blockquote><pre>
+ * import org.apache.jdo.*;
+ * class blackHerringEJBImplHelper implements EJBHelper {
+ *    static EJBHelper.register(new blackHerringEJBImplHelper());
+ *    ...
+ * }
+ * </pre></blockquote>
+ *
+ * @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
+     * <code>equals()</code> and <code>hashCode()</code> based on the global transaction id.
+     * <P>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.
+     * <P>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:
+     * <code>javax.transaction.Status.STATUS_COMMITTED</code> or
+     * <code>javax.transaction.Status.STATUS_ROLLED_BACK</code>.
+     * @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/runtime20/src/java/org/apache/jdo/ejb/EJBImplHelper.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/ejb/EJBImplHelper.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/ejb/EJBImplHelper.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/ejb/EJBImplHelper.java Sun May 22 11:01:45 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/runtime20/src/java/org/apache/jdo/ejb/package.html
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/ejb/package.html?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/ejb/package.html (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/ejb/package.html Sun May 22 11:01:45 2005
@@ -0,0 +1,26 @@
+<!--
+ 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.
+-->
+
+<html>
+<head>
+<title>Package org.apache.jdo.ejb</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
+</head>
+
+<body bgcolor="#FFFFFF">
+<p>This package contains classes and interfaces for EJB support.</p>
+</body>
+</html>

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/Bundle.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/Bundle.properties?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/Bundle.properties (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/Bundle.properties Sun May 22 11:01:45 2005
@@ -0,0 +1,73 @@
+#
+# 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.
+
+#
+# Generic messages
+#
+
+# {0} - location (class.method)
+#NOI18N
+ERR_InvalidNullFieldInstance={0}: specified Field instance is null.
+
+
+# {0} - class name
+# {1} - detailed message of the cause
+EXC_ClassLoadingError=Error during loading of class ''{0}'': {1}.
+
+#
+# RuntimeJavaModelFactory
+#
+
+EXC_CannotGetJDOImplHelper=A SecurityException was thrown when trying to get \
+the singleton JDOImplHelper instance. In order to get runtime metadata, you \
+must grant javax.jdo.spi.JDOPermission("getMetadata") to the codeBases \
+containing the JDO Reference Implementation (jdo.jar and jdori.jar).
+
+EXC_CannotGetRuntimeJavaModelFactory=A SecurityException was thrown when trying \
+to get the singleton RuntimeJavaModelFactory instance. In order to get runtime \
+metadata, you must grant javax.jdo.spi.JDOPermission("getMetadata") to the \
+codeBases containing the JDO Reference Implementation (jdo.jar and jdori.jar).
+
+# {0} - class instance
+EXC_CannotGetClassLoader=A SecurityException was thrown when trying to get the \
+class loader of class instance ''{0}''. In order to get runtime metadata, you \
+must grant ReflectPermission("getClassLoader") to the codeBase containing the \
+JDO Reference Implementation (jdori.jar).
+
+# {0} - key instance
+EXC_InvalidJavaModelKey=Invalid key for runtime JavaModel lookup: \
+expected ''java.lang.ClassLoader'' instance, found ''{0}'' instance.
+
+# {0} - type description instance
+EXC_InvalidTypeDesc=Invalid type description for runtime JavaType lookup: \
+expected ''java.lang.Class'' instance, found ''{0}'' instance.
+
+# {0} - JavaType instance
+EXC_InvalidJavaType=Invalid JavaType instance for getJavaClass method: \
+expected ''org.apache.jdo.impl.model.java.ReflectionJavaType'' instance, \
+found ''{0}'' instance.
+
+#NOI18N
+ERR_CannotSetJDOModel=Cannot set JDOModel for JavaModel instance.
+
+#
+# RuntimeJavaType
+#
+
+# {0} - error location (class.method)
+# {1} - implementation method name
+# {2} - field name
+#NOI18N
+ERR_MultipleJavaField={0}: multiple JavaField ''{1}'' for class '{2}''.

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RegisterClassListener.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RegisterClassListener.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RegisterClassListener.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RegisterClassListener.java Sun May 22 11:01:45 2005
@@ -0,0 +1,178 @@
+/*
+ * 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.impl.model.java.runtime;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import javax.jdo.spi.RegisterClassEvent;
+import javax.jdo.spi.JDOImplHelper;
+import javax.jdo.spi.PersistenceCapable;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.jdo.model.ModelException;
+import org.apache.jdo.model.java.JavaField;
+import org.apache.jdo.model.java.JavaModel;
+import org.apache.jdo.model.java.JavaType;
+import org.apache.jdo.model.jdo.JDOClass;
+import org.apache.jdo.model.jdo.JDOField;
+import org.apache.jdo.model.jdo.JDOModel;
+import org.apache.jdo.model.jdo.PersistenceModifier;
+
+/**
+ * The Model listener gets notified whenever a persistence-capable class gets 
+ * registered with the JDOImplHelper at runtime.
+ *
+ * @author Michael Bouschen
+ */
+public class RegisterClassListener
+    implements javax.jdo.spi.RegisterClassListener
+{
+    /** The corresponding JDOImplHelper instance. */
+    JDOImplHelper helper;
+
+    /** The JavaModel factory. */
+    RuntimeJavaModelFactory javaModelFactory;
+
+    /** Logger. */
+    private static Log logger =
+        LogFactory.getFactory().getInstance("org.apache.jdo.impl.model.jdo"); // NOI18N
+
+    /** 
+     * Constructor. 
+     * @param helper the JDOImplHelper instance.
+     * @param javaModelFactory the JavaModel factory.
+     */
+    public RegisterClassListener(JDOImplHelper helper, 
+                                 RuntimeJavaModelFactory javaModelFactory)
+    {
+        this.helper = helper;
+        this.javaModelFactory = javaModelFactory;
+    }
+
+    /**
+     * This method gets called when a persistence-capable class is registered.
+     * @param event a RegisterClassEvent instance describing the registered 
+     * class plus metatdata.
+     */
+    public void registerClass(RegisterClassEvent event)
+    {
+        if (logger.isDebugEnabled())
+            logger.debug("RegisterClassListener.registerClass " + //NOI18N
+                         event.getRegisteredClass());
+        try {
+            updateJDOClass(createJDOClass(event.getRegisteredClass()),
+                           event.getFieldNames(), 
+                           event.getFieldTypes(),
+                           event.getFieldFlags(),
+                           event.getPersistenceCapableSuperclass());
+        }
+        catch (ModelException ex) {
+            // ignore error message
+            logger.error("Problems updating JDOModel", ex); //NOI18N
+            System.out.println("caught " + ex); //NOI18N
+        }
+    }
+    
+    /** 
+     * Internal method to update the corresponding JDOClass instance with the 
+     * runtime meta data.
+     * @param pcClass the class object of the persistence-capable class
+     */
+    private JDOClass createJDOClass(Class pcClass)
+        throws ModelException
+    {
+        String pcClassName = pcClass.getName();
+        ClassLoader classLoader = 
+            javaModelFactory.getClassLoaderPrivileged(pcClass);
+        JavaModel javaModel = javaModelFactory.getJavaModel(classLoader);
+        JDOModel jdoModel = javaModel.getJDOModel();
+        // do not load XML here, this will be done on first request
+        JDOClass jdoClass = jdoModel.createJDOClass(pcClassName, false);
+        JavaType javaType = javaModel.getJavaType(pcClass);
+        jdoClass.setJavaType(javaType);
+        return jdoClass;
+    }
+
+    /** 
+     * Internal method to update the specified JDOClass instance with the 
+     * runtime meta data.
+     * @param jdoClass the jdoClass instance to be updated
+     * @param fieldNames the names of the managed fields
+     * @param fieldTypes the types of the managed fields
+     * @param fieldFlags the jdo field flags of the managed fields
+     * @param pcSuperclass the class object of the persistence-capable 
+     * superclass
+     */
+    private void updateJDOClass(JDOClass jdoClass,
+                                String[] fieldNames, 
+                                Class[] fieldTypes,
+                                byte[] fieldFlags,
+                                Class pcSuperclass)
+        throws ModelException
+    {
+        // handle superclass
+        if (pcSuperclass != null) {
+            ClassLoader classLoader = 
+                javaModelFactory.getClassLoaderPrivileged(pcSuperclass);
+            JavaModel superJavaModel = 
+                javaModelFactory.getJavaModel(classLoader);
+            JDOModel superJDOModel = superJavaModel.getJDOModel();
+            // do not load XML => last arg should be false
+            JDOClass superJDOClass = 
+                superJDOModel.getJDOClass(pcSuperclass.getName(), false);
+            jdoClass.setPersistenceCapableSuperclass(superJDOClass);
+        }
+        
+        // Iterate the field names and set the corresponding field type
+        RuntimeJavaType declaringClass = (RuntimeJavaType)jdoClass.getJavaType();
+        for (int i = 0; i < fieldNames.length; i++) {
+            JDOField jdoField = jdoClass.createJDOField(fieldNames[i]);
+            updateJDOField(jdoField, fieldTypes[i], fieldFlags[i],
+                           declaringClass);
+        }
+    }
+
+    /** 
+     * Internal method to update the specified JDOField instance with the 
+     * runtime meta data.
+     * @param jdoField the jdoField instance to be updated
+     * @param fieldType the type of the field
+     * @param fieldFlags the jdo field flags
+     */
+    private void updateJDOField(JDOField jdoField,
+                                Class fieldType,
+                                byte fieldFlags,
+                                RuntimeJavaType declaringClass)
+        throws ModelException
+    {
+        // handle JavaField
+        JavaField javaField = declaringClass.createJavaField(jdoField, 
+            javaModelFactory.getJavaType(fieldType));
+        jdoField.setJavaField(javaField);
+        
+        // handle field flags
+        jdoField.setSerializable(
+            (fieldFlags & PersistenceCapable.SERIALIZABLE) > 0);
+    }
+}
+

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaModel.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaModel.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaModel.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaModel.java Sun May 22 11:01:45 2005
@@ -0,0 +1,71 @@
+/*
+ * 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.impl.model.java.runtime;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.io.InputStream;
+
+import org.apache.jdo.impl.model.java.reflection.ReflectionJavaModel;
+import org.apache.jdo.model.ModelFatalException;
+import org.apache.jdo.model.java.JavaType;
+import org.apache.jdo.model.jdo.JDOModel;
+import org.apache.jdo.util.I18NHelper;
+
+/**
+ * A reflection based JavaModel implementation used at runtime.  
+ * The implementation takes <code>java.lang.Class</code> and
+ * <code>java.lang.reflect.Field</code> instances to get Java related
+ * metadata about types and fields. 
+ * <p>
+ * The RuntimeJavaModelFactory caches JavaModel instances per ClassLoader.
+ * The RuntimeJavaModel implementation will use this ClassLoader to lookup
+ * any type by name. This makes sure that the type name is unique.
+ *
+ * @author Michael Bouschen
+ * @since JDO 1.0.1
+ */
+public class RuntimeJavaModel
+    extends ReflectionJavaModel
+{
+    /** Constructor taking the ClassLoader. */
+    public RuntimeJavaModel(ClassLoader classLoader) 
+    {
+        super(classLoader, true);
+    }
+    
+    /** */
+    protected RuntimeJavaModel(ClassLoader classLoader, boolean initialize)
+    {
+        super(classLoader, initialize);
+    }
+
+    /** 
+     * Creates a new JavaType instance for the specified Class object.
+     * This method provides a hook such that RuntimeJavaModel subclasses
+     * can create instances of a different JavaType implementation. 
+     * <p>
+     * This implementation returns a RuntimeJavaType instance.
+     * @param clazz the Class instance representing the type
+     * @return a new JavaType instance
+     */
+    protected JavaType createJavaType(Class clazz)
+    {
+        return new RuntimeJavaType(clazz, getJDOModel());
+    }
+    
+}

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaModelFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaModelFactory.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaModelFactory.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaModelFactory.java Sun May 22 11:01:45 2005
@@ -0,0 +1,290 @@
+/*
+ * 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.impl.model.java.runtime;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.lang.reflect.Field;
+
+import javax.jdo.spi.JDOImplHelper;
+import javax.jdo.spi.JDOPermission;
+
+import org.apache.jdo.model.ModelException;
+import org.apache.jdo.model.ModelFatalException;
+import org.apache.jdo.model.java.JavaModel;
+import org.apache.jdo.model.java.JavaModelFactory;
+import org.apache.jdo.model.java.JavaType;
+import org.apache.jdo.model.jdo.JDOModelFactory;
+import org.apache.jdo.model.jdo.JDOModel;
+import org.apache.jdo.impl.model.java.AbstractJavaModelFactory;
+import org.apache.jdo.impl.model.java.BaseReflectionJavaType;
+import org.apache.jdo.impl.model.jdo.caching.JDOModelFactoryImplCaching;
+import org.apache.jdo.util.I18NHelper;
+
+/**
+ * A reflection based JavaModelFactory implementation used at runtime. 
+ * The implementation takes <code>java.lang.Class</code> and
+ * <code>java.lang.reflect.Field</code> instances to get Java related
+ * metadata about types and fields. This implementation caches JavaModel
+ * instance sper ClassLoader.
+ * <p>
+ * RuntimeJavaModelFactory implements the singleton pattern; method 
+ * {@link #getInstance()} provides access to the singleton factory
+ * instance. This method also registers a model listener at the
+ * JDOImplHelper to handle the runtime metadata as generated by the
+ * enhancer. 
+ * 
+ * @author Michael Bouschen
+ * @since JDO 1.0.1
+ */
+public class RuntimeJavaModelFactory
+    extends AbstractJavaModelFactory
+{    
+    /** The singleton RuntimeJavaModelFactory instance. */    
+    private static final RuntimeJavaModelFactory runtimeJavaModelFactory = 
+        new RuntimeJavaModelFactory();
+
+    /** I18N support */
+    private final static I18NHelper msg =  
+        I18NHelper.getInstance("org.apache.jdo.impl.model.java.runtime.Bundle"); //NOI18N
+
+    /** */
+    static
+    {
+        // initialize RuntimeJavaModelFactory singleton instance
+        try {
+            JDOImplHelper helper = 
+                (JDOImplHelper) AccessController.doPrivileged(
+                    new PrivilegedAction () {
+                        public Object run () {
+                            return JDOImplHelper.getInstance();
+                        }
+                    }
+                    );
+            // register listener to JDOImplHelpers class registration
+            RegisterClassListener crl = new RegisterClassListener(
+                helper, runtimeJavaModelFactory);
+            helper.addRegisterClassListener(crl);
+        }
+        catch (SecurityException ex) {
+            throw new ModelFatalException(
+                msg.msg("EXC_CannotGetJDOImplHelper"), ex); // NOI18N
+        }
+    }
+
+    /**
+     * Creates a new RuntimeJavaModelFactory. This constructor should not
+     * be called directly; instead, the singleton access method 
+     * {@link #getInstance()} should be used.
+     */
+    protected RuntimeJavaModelFactory() {}
+
+    /** 
+     * Returns the singleton instance of RuntimeJavaModelFactory. On first
+     * call it registers  a model listener at the JDOImplHelper.
+     * This method checks that the caller is authorized for 
+     * <code>JDOPermission("getMetadata")</code>, and if not, throws
+     * <code>ModelFatalException</code> wrapping the SecurityException.
+     * @return RuntimeJavaModelFactory instance
+     * @exception ModelFatalException if the caller does not have the
+     * getMetadata permission.
+     */    
+    public static RuntimeJavaModelFactory getInstance()
+        throws ModelFatalException
+    {
+        // first check whether caller has the getMetadata permission
+        SecurityManager sec = System.getSecurityManager();
+        if (sec != null) { 
+            try {
+                // throws exception if caller is not authorized
+                sec.checkPermission(JDOPermission.GET_METADATA);
+            }
+            catch (SecurityException ex) {
+                throw new ModelFatalException(
+                    msg.msg("EXC_CannotGetRuntimeJavaModelFactory"), ex); // NOI18N
+            }
+        }
+
+        return runtimeJavaModelFactory;
+    }
+    
+    /**
+     * Creates a new empty JavaModel instance. A factory implementation may
+     * use the specified key when caching the new JavaModel instance. 
+     * <p>
+     * This implementation only accepts <code>java.lang.ClassLoader</code>
+     * instances as key and does not support <code>null</code> keys. A
+     * ModelException indicates an invalid key.
+     * <p>
+     * The method automatically sets the parent/child relationship for the
+     * created JavaModel according to the parent/child relationship of the 
+     * ClassLoader passed as key. 
+     * @param key the key that may be used to cache the returned JavaModel
+     * instance. 
+     * @return a new JavaModel instance.
+     * @exception ModelException if impossible; the key is of an
+     * inappropriate type or the key is <code>null</code> and this
+     * JavaModelFactory does not support <code>null</code> keys.
+     */
+    public JavaModel createJavaModel(Object key)
+        throws ModelException
+    {
+        if ((key == null) || (!(key instanceof ClassLoader)))
+            throw new ModelException(msg.msg("EXC_InvalidJavaModelKey", //NOI18N
+                (key==null?"null":key.getClass().getName())));
+        
+        ClassLoader classLoader = (ClassLoader)key;
+        JavaModel javaModel = new RuntimeJavaModel(classLoader);
+
+        // check parent <-> child relationship
+        if (classLoader != ClassLoader.getSystemClassLoader()) {
+            // if the specified classLoader is not the system class loader
+            // try to get the parent class loader and update the parent property
+            try {
+                ClassLoader parentClassLoader = classLoader.getParent();
+                if (parentClassLoader != null) {
+                    javaModel.setParent(getJavaModel(parentClassLoader));
+                }
+            }
+            catch (SecurityException ex) {
+                // ignore => parentClassLoader and parent JavaModel are null
+            }
+        }
+
+        // set the JDOModel property in JavaModel
+        setJDOModelInternal(javaModel);
+
+        return javaModel;
+    }
+
+    /**
+     * Returns the JavaModel instance for the specified key.
+     * @param key the key used to cache the returned JavaModel instance
+     */
+    public JavaModel getJavaModel(Object key)
+    {
+        if (key == null) {
+            // null classLoader might happen for classes loaded by the
+            // bootstrap class loder
+            key = ClassLoader.getSystemClassLoader();
+        }
+        return super.getJavaModel(key);
+    }
+    
+    /**
+     * Returns a JavaType instance for the specified type description
+     * (optional operation). This method is a convenience method and a
+     * short cut for <code>getJavaModel(key).getJavaType(typeName)</code>.
+     * <p>
+     * The RuntimeJavaModelFactory supports this short cut and accepts
+     * <code>java.lang.Class</code> instances as valid arguments for this
+     * method. The method throws a 
+     * {@link org.apache.jdo.model.ModelFatalException}, if the specified
+     * type descriptor is not a <code>java.lang.Class</code> instance. 
+     * @param typeDesc the type description
+     * @return a JavaType instance for the specified type.
+     * @exception ModelFatalException the specified type description is not
+     * a <code>java.lang.Class</code> instance.
+     */
+    public JavaType getJavaType(Object typeDesc)
+    {
+        if (typeDesc == null)
+            return null;
+
+        try {
+            Class clazz = (Class)typeDesc;
+            ClassLoader classLoader = getClassLoaderPrivileged(clazz);
+            return getJavaModel(classLoader).getJavaType(clazz);
+        }
+        catch (ClassCastException ex) {
+            throw new ModelFatalException(msg.msg("EXC_InvalidTypeDesc", //NOI18N
+                typeDesc.getClass().getName()));
+        }
+    }
+
+    // ===== Methods not defined in JavaModelFactory =====
+
+    /**
+     * Calls getClassLoader on the specified class instance in a
+     * doPrivileged block. Any SecurityException is wrapped into a
+     * ModelFatalException. 
+     * @return the class loader that loaded the specified class instance.
+     * @exception ModelFatalException wraps the SecurityException thrown by
+     * getClassLoader.
+     */
+    public ClassLoader getClassLoaderPrivileged(final Class clazz)
+    {
+        if (clazz == null)
+            return null;
+
+        try { 
+            return (ClassLoader) AccessController.doPrivileged(
+                new PrivilegedAction () {
+                    public Object run () {
+                        return clazz.getClassLoader();
+                    }
+                }
+                );
+        }
+        catch (SecurityException ex) {
+            throw new ModelFatalException(
+                msg.msg("EXC_CannotGetClassLoader", clazz), ex); //NOI18N
+        }
+    }
+
+    /**
+     * Returns the <code>java.lang.Class</code> wrapped in the specified 
+     * JavaType. 
+     * @return the <code>java.lang.Class</code> for the specified
+     * JavaType. 
+     * @exception ModelFatalException the specified JavaType does
+     * not wrap a <code>java.lang.Class</code> instance.
+     */
+    public Class getJavaClass(JavaType javaType) 
+    {
+        if (javaType == null)
+            return null;
+        
+        try {
+            return ((BaseReflectionJavaType)javaType).getJavaClass();
+        }
+        catch (ClassCastException ex) {
+            throw new ModelFatalException(msg.msg(
+                "EXC_InvalidJavaType", javaType.getClass())); //NOI18N
+        }
+    }
+
+    //========= Internal helper methods ==========
+    
+    /**
+     * Sets the JDOModel instance for the specified JavaModel.
+     * @param javaModel the JavaModel
+     */
+    protected void setJDOModelInternal(JavaModel javaModel)
+    {
+        JDOModelFactory factory = JDOModelFactoryImplCaching.getInstance();
+        JDOModel jdoModel = factory.getJDOModel(javaModel);
+        // update the JDOModel property of the JavaModel
+        try {
+            javaModel.setJDOModel(jdoModel);
+        }
+        catch (ModelException ex) {
+            throw new ModelFatalException("ERR_CannotSetJDOModel", ex); //NOI18N
+        }
+    }
+}
+

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaType.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaType.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaType.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/RuntimeJavaType.java Sun May 22 11:01:45 2005
@@ -0,0 +1,78 @@
+/*
+ * 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.impl.model.java.runtime;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.apache.jdo.impl.model.java.reflection.ReflectionJavaType;
+import org.apache.jdo.model.java.JavaField;
+import org.apache.jdo.model.java.JavaModel;
+import org.apache.jdo.model.java.JavaModelFactory;
+import org.apache.jdo.model.java.JavaType;
+import org.apache.jdo.model.jdo.JDOClass;
+import org.apache.jdo.model.jdo.JDOField;
+import org.apache.jdo.model.jdo.JDOModel;
+import org.apache.jdo.util.I18NHelper;
+
+
+
+/**
+/**
+ * A reflection based JavaType implementation used at runtime.  
+ * The implementation takes <code>java.lang.Class</code> and
+ * <code>java.lang.reflect.Field</code> instances to get Java related
+ * metadata about types and fields. 
+ *
+ * @author Michael Bouschen
+ * @since JDO 1.0.1
+ */
+public class RuntimeJavaType
+    extends ReflectionJavaType
+{
+    /** JavaModelFactory */
+    private static final RuntimeJavaModelFactory javaModelFactory =
+        (RuntimeJavaModelFactory) AccessController.doPrivileged(
+            new PrivilegedAction () {
+                public Object run () {
+                    return RuntimeJavaModelFactory.getInstance();
+                }
+            }
+        );
+
+    /** Constructor. */
+    public RuntimeJavaType(Class clazz, JDOModel jdoModel)
+    {
+        super(clazz, jdoModel);
+    }
+
+    /** 
+     * Returns a JavaType instance for the specified Class object. 
+     * This method provides a hook such that RuntimeJavaType subclasses can
+     * implement their own mapping of Class objects to JavaType instances. 
+     * <p>
+     * This implementation delegates the call to the javaModelFactory. 
+     * @param clazz the Class instance representing the type
+     * @return a JavaType instance for the name of the specified class
+     * object or <code>null</code> if not present in this model instance.
+     */
+    protected JavaType getJavaTypeInternal(Class clazz)
+    {
+        return javaModelFactory.getJavaType(clazz);
+    }
+    
+}

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/package.html
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/package.html?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/package.html (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/java/runtime/package.html Sun May 22 11:01:45 2005
@@ -0,0 +1,27 @@
+<!--
+ 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.
+-->
+
+<html>
+<head>
+<title>Runtime JavaModel implementation package.</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+</head>
+
+<body bgcolor="#FFFFFF">
+<p>This package contains a runtime specific JavaModel implementation 
+based on reflection.
+</body>
+</html>

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/jdo/xml/XMLExists.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/jdo/xml/XMLExists.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/jdo/xml/XMLExists.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/model/jdo/xml/XMLExists.java Sun May 22 11:01:45 2005
@@ -0,0 +1,307 @@
+/*
+ * 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.impl.model.jdo.xml;
+
+import java.util.*;
+
+import org.apache.jdo.impl.model.java.AbstractJavaModelFactory;
+import org.apache.jdo.impl.model.java.runtime.RuntimeJavaModel;
+import org.apache.jdo.impl.model.jdo.caching.JDOModelFactoryImplCaching;
+import org.apache.jdo.impl.model.jdo.util.PrintSupport;
+import org.apache.jdo.model.ModelException;
+import org.apache.jdo.model.ModelFatalException;
+import org.apache.jdo.model.java.JavaModel;
+import org.apache.jdo.model.jdo.JDOClass;
+import org.apache.jdo.model.jdo.JDOModel;
+import org.apache.jdo.model.jdo.JDOModelFactory;
+
+/**
+ * This class allows to check whether there is JDO metadata for a class with 
+ * a given class name. There must be a class file (enhanced or not enhanced)
+ * available in the classpath of the caller.
+ * <p>
+ * Usage: XMLExists &lt;options&gt; &lt;arguments&gt;...
+ * <br>
+ * Options:
+ * <br>
+ * <code>&nbsp;&nbsp;-h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>
+ * print usage message
+ * <br>
+ * <code>&nbsp;&nbsp;-v&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>
+ * print verbose messages and JDO metadata
+ * <br>
+ * <code>&nbsp;&nbsp;-q&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>
+ * do not print any output; just set the exit code
+ * <br>
+ * <code>&nbsp;&nbsp;-xml&nbsp;&nbsp;&nbsp;&nbsp;</code>
+ * expected to find JDO XML metadata for the specified class(es)
+ * <br>
+ * <code>&nbsp;&nbsp;-noxml&nbsp;&nbsp;</code>
+ * expected to find no JDO XML metadata for the specified class(es)
+ * <br>
+ * Arguments:
+ * <br>
+ * <code>&nbsp;&nbsp;&lt;classname&gt;&nbsp;</code>
+ * the fully qualified name of a class to be checked
+ * <p>
+ * The following sample call checks whether there is JDO XML metadata for the 
+ * classes Emplyoe and Department from the com.xyz.hr package and dumps the 
+ * JDOClass instances:
+ * <br>
+ * <code>&nbsp;&nbsp;java org.apache.jdo.impl.model.jdo.util.XMLExists -v 
+ * com.xyz.hr.Employee com.xyz.hr.Department</code>
+ * <p>
+ * Method main will exit the JVM with an exit code 1 if the test fails for 
+ * at least one class. Please note, the class dumps the JDOClass if the 
+ * outputLevel is set to VERBOSE (e.g. by setting the -v option). This JDOClass 
+ * info does NOT include runtime metadata, even if the class file is enhanced.
+ * 
+ * @author Michael Bouschen
+ */
+public class XMLExists
+{
+    /** 
+     * Flag indicating whether the classes to be checked is expected to have 
+     * JDO XML metadata or not.
+     */
+    private boolean xmlExpected;
+    
+    /** Print verbose messages. */
+    public static final int VERBOSE = 1;
+
+    /** Normal output. */
+    public static final int NORMAL = 0;
+
+    /** No messages, just set the exit code. */
+    public static final int QUIET = -1;
+       
+    /** Output level.*/
+    private int outputLevel = NORMAL;
+
+    /** 
+     * The main method checks all classes specified as argument.
+     * It will exit the JVM with an exit code 1 if the test fails for 
+     * at least one class. 
+     * @param args arguments which are options followed by class names.
+     */
+    public static void main(String[] args)
+    {
+        final XMLExists test = new XMLExists();
+        final List classNames = test.processArgs(args);
+        if (!test.run(classNames))
+            System.exit(1);
+    }
+
+    /** 
+     * No arg constructor. The flags default to
+     * <ul>
+     * <li> <code>xmlExpected == true</code>
+     * <li> <code>outputLevel == NORMAL</code>
+     * </ul>
+     */
+    public XMLExists()
+    {
+        this(true, NORMAL);
+    }
+
+    /** Constructor taking checkXMLExists and outputLevel. */
+    public XMLExists(boolean xmlExpected, int outputLevel)
+    {
+        this.xmlExpected = xmlExpected;
+        this.outputLevel = outputLevel;
+    }
+
+    /**
+     * This method checks all classes from the specified list of class names.
+     * It uses the current classLoader to load the classes. The method returns 
+     * <code>false</code> if there is at least one class that fails on checking.
+     * @param classNames list of classes to be checked
+     * @return <code>true</code> if all classes are ok;
+     * <code>false</code> otherwise.
+     */
+    public boolean run(List classNames)
+    {
+        ClassLoader classLoader = getClass().getClassLoader();
+        XMLExistsJDOModelFactory factory = new XMLExistsJDOModelFactory();
+        JavaModel javaModel = factory.getJavaModel(classLoader);
+        JDOModel jdoModel = javaModel.getJDOModel();
+        boolean ok = true;
+        for (Iterator i = classNames.iterator(); i.hasNext(); ) {
+            final String className = (String)i.next();
+            try {
+                checkClass(className, classLoader, jdoModel, xmlExpected);
+                if ((outputLevel == NORMAL) && xmlExpected)
+                    System.out.println(
+                        "Found XML metadata for class " + className); //NOI18N
+                                       
+                else if ((outputLevel == NORMAL) && !xmlExpected)
+                    System.out.println(
+                        "No MXL metadata for class " + className); //NOI18N
+            }
+            catch (Exception ex) {
+                if (outputLevel > QUIET) {
+                    System.err.println(ex);
+                    ex.printStackTrace();
+                }
+                ok = false;
+            }
+        }
+        return ok;
+    }
+    
+    /** 
+     * The method checks the class with the specified class name.
+     * It first loads the class using the specified class loader.
+     * If the flag xmlExpected is <code>true</code> it expects to get a non-null
+     * JDOClass instance. If the flag xmlExpected is <code>false</code> it 
+     * expects to get a null JDOClass instance. 
+     * <p>
+     * The method indicates any failure by throwing an exception. 
+     * It dumps the JDOClass if the output level is VERBOSE.
+     * @param className the name of the class to be checked
+     * @param classLoader the class loader to be used to load the class
+     * @param jdoModel JDOModel for type info
+     * @param xmlExpected flag whether the class to be checked is expected to 
+     * have JDO XML metadata or not.
+     */
+    public void checkClass(String className, 
+                           ClassLoader classLoader,
+                           JDOModel jdoModel, 
+                           boolean xmlExpected)
+        throws Exception
+    {
+        Class clazz = Class.forName(className, true, classLoader);
+        if (outputLevel == VERBOSE)
+            System.out.println("Found " + clazz); //NOI18N
+        JDOClass jdoClass = jdoModel.getJDOClass(className);
+        if (xmlExpected && (jdoClass == null)) {
+            throw new Exception(
+                "Missing JDO XML metadata for class " + //NOI18N
+                className);
+        }
+        if (!xmlExpected && (jdoClass != null)) {
+            throw new Exception(
+                "Found JDO XML metadata for class " + className); //NOI18N
+        }
+        if ((outputLevel == VERBOSE) && (jdoClass != null)) {
+            PrintSupport.printJDOClass(jdoClass);
+        }
+    }
+    
+    // ==== Comand line processing helper method =====
+    
+    /**
+     * Helper method to do command line argument processing.
+     * @param args the arguments passed to main.
+     * @return the list of classes to be checked.
+     */
+    protected List processArgs(String[] args)
+    { 
+        List classNames = new ArrayList();
+        for (int i = 0; i < args.length; i++) {
+            final String arg = args[i];
+            if (arg.equals("-h")) { //NOI18N
+                usage();
+            }
+            else if (arg.equals("-v")) { //NOI18N
+                outputLevel = VERBOSE;
+            }
+            else if (arg.equals("-q")) { //NOI18N
+                outputLevel = QUIET;
+            }
+            else if (arg.equals("-xml")) { //NOI18N
+                xmlExpected = true;
+            }
+            else if (arg.equals("-noxml")) { //NOI18N
+                xmlExpected = false;
+            }
+            else if (arg.length() > 0 && arg.charAt(0) == '-') {
+                System.err.println("Unrecognized option:" + arg); //NOI18N
+                usage();
+            }
+            else if (arg.length() == 0) {
+                System.err.println("Ignoring empty command line argument."); //NOI18N
+            }
+            else {
+                classNames.add(arg);
+            }
+        }
+        return classNames;
+    }
+    
+    /**
+     * Print a usage message to System.err.
+     */
+    public void usage() 
+    {
+        System.err.println("Usage: main <options> <arguments>..."); //NOI18N
+        System.err.println("Options:"); //NOI18N
+        System.err.println("  -h      print usage message"); //NOI18N
+        System.err.println("  -v      print verbose messages and JDO metadata"); //NOI18N
+        System.err.println("  -q      do not print any messages; just set the exit code"); //NOI18N
+        System.err.println("  -xml    expected to find JDO XML metadata for the specified class(es)"); //NOI18N
+        System.err.println("  -noxml  expected to find no JDO XML metadata for the specified class(es)"); //NOI18N
+        System.err.println("Arguments:"); //NOI18N
+        System.err.println("  <classname>   the fully qualified name of a class to be checked"); //NOI18N
+    }
+    
+    /**
+     * JavaModelFactory implementation. 
+     * We cannot use the RuntimeJavaModelFactory, because it registers
+     * a JDOImplHelper event listener to populate enhancer generated
+     * metadata into the model. Since XMLExists checks whether JDO
+     * metadata is present from a .jdo we do not want to the enhancer
+     * generated metadata.
+     */
+    private static class XMLExistsJDOModelFactory 
+        extends AbstractJavaModelFactory {
+
+        /** */
+        protected XMLExistsJDOModelFactory() {}
+
+        /** */
+        public JavaModel createJavaModel(Object key) throws ModelException {
+            if ((key == null) || (!(key instanceof ClassLoader)))
+                throw new ModelException("Invalid key " + key + 
+                                         " expected ClassLoader");
+            ClassLoader classLoader = (ClassLoader)key;
+            JavaModel javaModel = new RuntimeJavaModel(classLoader); 
+
+            // set the JDOModel property in JavaModel
+            setJDOModelInternal(javaModel);
+
+            return javaModel;
+        }
+        
+        /**
+         * Sets the JDOModel instance for the specified JavaModel.
+         * @param javaModel the JavaModel
+         */
+        protected void setJDOModelInternal(JavaModel javaModel) {
+            JDOModelFactory factory = JDOModelFactoryImplCaching.getInstance();
+            JDOModel jdoModel = factory.getJDOModel(javaModel);
+            // update the JDOModel property of the JavaModel
+            try {
+                javaModel.setJDOModel(jdoModel);
+            }
+            catch (ModelException ex) {
+                throw new ModelFatalException("Cannot set JDOModel", ex); //NOI18N
+            }
+        }
+    }
+    
+}

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/pm/Bundle.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/pm/Bundle.properties?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/pm/Bundle.properties (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/pm/Bundle.properties Sun May 22 11:01:45 2005
@@ -0,0 +1,102 @@
+#
+# 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 file should conform to netbeans standards
+# (http://www.netbeans.org/i18n)
+
+# resource bundle for the messages
+# key consists of: <PREFIX_><description>
+# <PREFIX_> - any valid prefix like MSG_, EXC_, etc.
+# <description> - short description started with the upper case letter and used
+# upper case to represent each next word.
+
+# XXX TBD: this message is not used:
+notsupported=Operation is not supported in this release.
+
+
+#
+# CacheManagerImpl
+#
+EXC_MetaDataNotAvailable=Metadata for the owning Class is not available.
+EXC_NonTransactional=Instance is not transactional.
+EXC_ObjectExistsInCache=Object exists. Instance with the same primary key is already in the PersistenceManager cache.
+EXC_NotOID=Given object is not a valid OID.
+# NOI18N
+EXC_ObjectIdExistsInCache=ObjectId {0} already exists in this PersistenceManager cache.
+# NOI18N
+EXC_ObjectIdNotExistsInCache=ObjectId {0} does not exist in this PersistenceManager cache.
+
+#
+# PersistenceManagerFactoryImpl
+#
+EXC_NotConfigurable=This instance of PersistenceManagerFactory is not configurable.
+EXC_IntegerInInvalidFormat=Integer found in invalid format: should not happen!
+EXC_IncompleteConfiguration=One of ConnectionURL, ConnectionFactory, or ConnectionFactoryName must be set before using this PersistenceManagerFactory.
+EXC_WrongUsernamePassword=Cannot use multiple combinations of username/password in the same transaction.
+# NOI18N
+EXC_WrongJTATransaction=This instance of javax.transaction.Transaction is registered with another PersistenceManager.
+EXC_PersistenceManagerFactoryClosed=This operation cannot be performed because this PersistenceManagerFactory is closed.
+EXC_ActivePersistenceManager=This PersistenceManagerFactory cannot be closed while a PersistenceManager has an active transaction.
+EXC_CannotAddShutdownHook=A SecurityException was thrown when trying \
+to add a JVM shudown hook. In order to register a shutdown hook, \
+you must grant java.lang.RuntimePermission("shutdownHooks") to the \
+codeBases containing the JDO Reference Implementation (jdo-ri.jar).
+
+#
+# PersistenceManagerImpl
+#
+EXC_CannotGetRuntimeJavaModelFactory=A SecurityException was thrown when trying \
+to get the singleton RuntimeJavaModelFactory instance. In order to get runtime \
+metadata, you must grant javax.jdo.spi.JDOPermission("getMetadata") to the \
+codeBases containing the JDO Reference Implementation (jdo.jar and jdo-ri.jar).
+EXC_ActiveTransaction=Cannot close PersistenceManager while transaction is still active.
+EXC_WrongSCOType=Tracked SCO instances of type {0} are not supported.
+EXC_CannotConstructSCO=Exception during construction of type {0}.
+EXC_IllegalArguments=Wrong arguments for construction of type {0}.
+EXC_PersistenceManagerClosed=PersistenceManager was closed.
+EXC_TransactionNotActive=Transaction is not active.
+EXC_NotPersistenceCapable=Class {0} not PersistenceCapable. The class of the instance does not implement PersistenceCapable. Check to see that the class has been enhanced and that the class path is correct (the unenhanced version of the class should not be in the class path).
+EXC_CollectionType=Parameter is of a Collection type; use method {0}All(Collection).
+EXC_ArrayType=Parameter is of an array type; use method {0}All(Object[]).
+EXC_TransientInstance=Instance of class {0} is not persistent.
+EXC_AnotherPersistenceManager=Object owned by another PersistenceManager.
+EXC_ClassNotPersistenceCapable=Class given to getExtent, {0},  does not implement javax.jdo.spi.PersistenceCapable
+EXC_FailedToProcessAll=Failed to process all objects.
+EXC_CannotFindSM=Could not find a StateManager for the given PersistenceCapable of class {0}.
+# NOI18N
+EXC_NotNullJTATransaction=Attempt to replace not null javax.transaction.Transaction.
+EXC_UnsupportedQueryLanguage=Unsupported query language ''{0}''
+EXC_CannotFindPCClassForObjectIdClass=Cannot find persistence-capable class for ObjectId class ''{0}''
+
+#
+# TransactionImpl
+#
+EXC_CannotChangeType=Cannot change transaction type during an active transaction.
+EXC_CannotSetFlag=Cannot change flag value during commit or rollback processing.
+EXC_CannotSetFlagIfActive=Cannot change flag value if transaction is active.
+EXC_SynchronizationNotNull=A Synchronization object has already been set for this transaction.
+EXC_ErrorBegin=Transaction has already begun.
+EXC_TransactionRolledback=Transaction already rolled back or rollback in progress.
+EXC_TransactionCommitting=Transaction has already started to commit.
+EXC_MarkedRolledback=This transaction was marked rollback-only.
+EXC_WrongStateCommit=Transaction in wrong state to commit.
+EXC_WrongStateRollback=Transaction in wrong state to rollback.
+EXC_InvalidStatus=Invalid Transaction.{0}(). This transaction status is not {1} (status = {2}).
+EXC_WrongMgdOperation=Operation {0} is not allowed in managed environment.
+EXC_WrongNonMgdOperation=Operation {0} is not allowed in non-managed environment.
+EXC_NontransactionalRead=This operation requires that a transaction be active or the NontransactionalRead flag be true.
+# NOI18N
+EXC_ErrorRegister=Cannot register this instance with JTA Synchronization.
+