cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r396882 [2/11] - in /incubator/cayenne: branches/ tags/ trunk/ trunk/cayenne-jpa-tck/ trunk/cayenne-jpa-tck/.settings/ trunk/cayenne-jpa-tck/src/ trunk/cayenne-jpa-tck/src/main/ trunk/cayenne-jpa-tck/src/main/java/ trunk/cayenne-jpa-tck/src...
Date Wed, 26 Apr 2006 20:58:50 GMT
Added: incubator/cayenne/trunk/cayenne-jpa/.settings/org.eclipse.jdt.ui.prefs
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/.settings/org.eclipse.jdt.ui.prefs?rev=396882&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/.settings/org.eclipse.jdt.ui.prefs (added)
+++ incubator/cayenne/trunk/cayenne-jpa/.settings/org.eclipse.jdt.ui.prefs Tue Apr 25 06:43:00 2006
@@ -0,0 +1,8 @@
+#Mon Apr 17 17:09:21 MSD 2006
+eclipse.preferences.version=1
+formatter_settings_version=8
+internal.default.compliance=default
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=java;javax;org;com;
+org.eclipse.jdt.ui.ondemandthreshold=99
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?>\n<templates><template id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment" description\="Comment for getter method" context\="gettercomment_context" enabled\="true" deleted\="false" autoinsert\="true"/><template id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment" description\="Comment for setter method" context\="settercomment_context" enabled\="true" deleted\="false" autoinsert\="true"/><template id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment" description\="Comment for created constructors" context\="constructorcomment_context" enabled\="true" deleted\="false" autoinsert\="true"/><template id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment" description\="Comment for created Java files" context\="filecomment_context" enabled\="true" deleted\="false" autoinsert\="true">/*
 *\n * \n */</template><template id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment" description\="Comment for created types" context\="typecomment_context" enabled\="true" deleted\="false" autoinsert\="true">/**\n * @author \n */</template><template id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment" description\="Comment for fields" context\="fieldcomment_context" enabled\="true" deleted\="false" autoinsert\="true"/><template id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment" description\="Comment for non-overriding methods" context\="methodcomment_context" enabled\="true" deleted\="false" autoinsert\="true"/><template id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment" description\="Comment for overriding methods" context\="overridecomment_context" enabled\="true" deleted\="false" autoinsert\="true"/><template id\="org.eclipse.jdt.ui.text.codetemplates.newtype" na
 me\="newtype" description\="Newly created files" context\="newtype_context" enabled\="true" deleted\="false" autoinsert\="false">/* \=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\n * \n * The ObjectStyle Group Software License, version 1.1\n * ObjectStyle Group - http\://objectstyle.org/\n * \n * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors\n * of the software. All rights reserved.\n * \n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met\:\n * \n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * \n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or 
 other materials provided with the\n *    distribution.\n * \n * 3. The end-user documentation included with the redistribution, if any,\n *    must include the following acknowlegement\:\n *    "This product includes software developed by independent contributors\n *    and hosted on ObjectStyle Group web site (http\://objectstyle.org/)."\n *    Alternately, this acknowlegement may appear in the software itself,\n *    if and wherever such third-party acknowlegements normally appear.\n * \n * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse\n *    or promote products derived from this software without prior written\n *    permission. For written permission, email\n *    "andrus at objectstyle dot org".\n * \n * 5. Products derived from this software may not be called "ObjectStyle"\n *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their\n *    names without prior written permission.\n * \n * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY
  EXPRESSED OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\n * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\n * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n * \=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\n * \n * This software consists of voluntary contributions made by many\n * individuals and hosted on ObjectStyle Group web
  site.  For more\n * information on the ObjectStyle Group, please see\n * &lt;http\://objectstyle.org/&gt;.\n */\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock" description\="Code in new catch blocks" context\="catchblock_context" enabled\="true" deleted\="false" autoinsert\="true">${exception_var}.printStackTrace();</template><template id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody" description\="Code in created method stubs" context\="methodbody_context" enabled\="true" deleted\="false" autoinsert\="true">${body_statement}</template><template id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody" description\="Code in created constructor stubs" context\="constructorbody_context" enabled\="true" deleted\="false" autoinsert\="true">${body_statement}</template><template id\="org.eclipse.jdt.ui.text.codetemplates.ge
 tterbody" name\="getterbody" description\="Code in created getters" context\="getterbody_context" enabled\="true" deleted\="false" autoinsert\="true">return ${field};</template><template id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody" description\="Code in created setters" context\="setterbody_context" enabled\="true" deleted\="false" autoinsert\="true">${field} \= ${param};</template></templates>

Added: incubator/cayenne/trunk/cayenne-jpa/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/pom.xml?rev=396882&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/pom.xml (added)
+++ incubator/cayenne/trunk/cayenne-jpa/pom.xml Tue Apr 25 06:43:00 2006
@@ -0,0 +1,205 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.objectstyle.cayenne</groupId>
+  <artifactId>cayenne-jpa</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>Cayenne JPA Implementation</name>
+  <url>http://www.objectstyle.org/cayenne</url>
+  <organization>
+	  <name>Apache Software Foundation (incubating)</name>
+  </organization>
+	
+  <description>
+This project is dedicated to making Cayenne a JPA provider.
+  </description>
+  <mailingLists>
+    <mailingList>
+      <name>Development List</name>
+      <subscribe>cayenne-devel-subscribe@objectstyle.org</subscribe>
+      <unsubscribe>cayenne-devel-unsubscribe@objectstyle.org</unsubscribe>
+      <post>cayenne-devel@objectstyle.org</post>
+      <archive>http://objectstyle.org/cayenne/lists/cayenne-user</archive>
+    </mailingList>
+    <mailingList>
+      <name>User List</name>
+      <subscribe>cayenne-user-subscribe@objectstyle.org</subscribe>
+      <unsubscribe>cayenne-user-unsubscribe@objectstyle.org</unsubscribe>
+      <post>cayenne-user@objectstyle.org</post>
+      <archive>http://objectstyle.org/cayenne/lists/cayenne-user</archive>
+    </mailingList>
+    <mailingList>
+      <name>Commits List</name>
+      <subscribe>cayenne-cvs-subscribe@objectstyle.org</subscribe>
+      <unsubscribe>cayenne-cvs-subscribe@objectstyle.org</unsubscribe>
+    </mailingList>
+  </mailingLists>
+  <developers>
+    <developer>
+      <id>andrus</id>
+      <name>Andrus Adamchik</name>
+      <email>andrus@objectstyle.org</email>
+      <organizationUrl>http://adamchik.org</organizationUrl>
+    </developer>
+    <developer>
+      <name>Cris Daniluk</name>
+    </developer>
+    <developer>
+      <name>Michael Gentry</name>
+    </developer>
+    <developer>
+      <name>Tore Halset</name>
+    </developer>
+    <developer>
+      <name>Mike Kienenberger</name>
+    </developer>
+    <developer>
+      <name>Kevin Menard</name>
+    </developer>
+    <developer>
+      <name>Eric Schneider</name>
+      <email>eric@centralparksoftware.com</email>
+      <organizationUrl>http://www.centralparksoftware.com</organizationUrl>
+    </developer>
+  </developers>
+  <issueManagement>
+    <system>JIRA</system>
+    <url>http://objectstyle.org/jira/secure/BrowseProject.jspa?id=10000</url>
+  </issueManagement>
+  <scm>
+    <connection>scm:cvs:pserver:anonymous:@cvs.sourceforge.net:/cvsroot/cayenne</connection>
+    <developerConnection>scm:cvs:ext:DEVELOPER_NAME@cvs.sourceforge.net:/cvsroot/cayenne</developerConnection>
+    <url>http://cvs.sourceforge.net/viewcvs.py/cayenne/</url>
+  </scm>
+	<repositories>
+		<repository>
+			<id>objectstyle</id>
+			<name>ObjectStyle Public Maven2 repo</name>
+			<url>http://objectstyle.org/maven2</url>
+		</repository>
+	</repositories>
+
+  <dependencies>
+	<dependency>
+		<groupId>junit</groupId>
+		<artifactId>junit</artifactId>
+		<version>3.8.1</version>
+		<scope>test</scope>
+	</dependency>
+    <dependency>
+		<groupId>org.apache.geronimo.specs</groupId>
+		<artifactId>geronimo-jpa_3.0_spec</artifactId>
+		<version>1.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.objectstyle.cayenne</groupId>
+      <artifactId>cayenne-nodeps</artifactId>
+      <version>1.2-SNAPSHOT</version>
+    </dependency>
+	<dependency>
+      <groupId>asm</groupId>
+      <artifactId>asm-all</artifactId>
+      <version>2.2</version>
+    </dependency>
+  </dependencies>
+	
+	
+  <distributionManagement>
+    <site>
+      <id>cayenne-website</id>
+      <name>Cayenne</name>
+      <url>file://${java.io.tmpdir}/foo</url>
+    </site>
+    <repository>
+      <id>local-maven2-repo</id>
+      <name>Local Maven 2 Cayenne Repository</name>
+      <url>file://${java.io.tmpdir}/cayenne-mvn-repo</url>
+    </repository>
+    <snapshotRepository>
+      <id>local-maven2-snapshot-repo</id>
+      <name>Local Maven 2 Snapshot Cayenne Repository</name>
+      <url>file://${java.io.tmpdir}/cayenne-mvn-snapshot-repo</url>
+    </snapshotRepository>
+  </distributionManagement>
+	
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+	  <plugin>
+          <groupId>org.codehaus.mojo</groupId>
+          <artifactId>surefire-report-maven-plugin</artifactId>
+      </plugin>
+		<plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-javadoc-plugin</artifactId>
+			<configuration>
+			    <showProtected>true</showProtected>
+				<showPackage>false</showPackage>
+			</configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-project-info-reports-plugin</artifactId>
+        <reportSets>
+           <reportSet>
+              <reports>
+                <report>project-team</report>
+                <report>mailing-list</report>
+                <report>cim</report>
+                <report>issue-tracking</report>
+                <report>license</report>
+                <report>scm</report>
+                <report>javadoc</report>
+              </reports>
+            </reportSet>
+          </reportSets>
+        </plugin>
+      </plugins>
+  </reporting>
+
+  <profiles>
+    <profile>
+      <id>generate-assembly</id>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-javadoc-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>attach-javadoc</id>
+                <goals>
+                  <goal>jar</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+          <plugin>
+            <artifactId>maven-source-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>attach-source</id>
+                <goals>
+                  <goal>jar</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+
+</project>

Added: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/JpaEntityManager.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/JpaEntityManager.java?rev=396882&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/JpaEntityManager.java (added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/JpaEntityManager.java Tue Apr 25 06:43:00 2006
@@ -0,0 +1,343 @@
+package org.objectstyle.cayenne.jpa;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityNotFoundException;
+import javax.persistence.EntityTransaction;
+import javax.persistence.FlushModeType;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.PersistenceException;
+import javax.persistence.Query;
+import javax.persistence.TransactionRequiredException;
+
+/**
+ * Base implementation of a non-JTA EntityManager.
+ * 
+ * @author Andrus Adamchik
+ */
+public abstract class JpaEntityManager implements EntityManager {
+
+    protected FlushModeType flushMode;
+    protected EntityManagerFactory factory;
+    protected EntityTransaction transaction;
+    protected boolean open;
+    protected PersistenceContextType contextType;
+
+    public JpaEntityManager(EntityManagerFactory factory,
+            PersistenceContextType contextType) {
+        this.factory = factory;
+        this.open = true;
+        this.contextType = contextType;
+    }
+
+    /**
+     * Close an application-managed EntityManager. After an EntityManager has been closed,
+     * all methods on the EntityManager instance will throw the IllegalStateException
+     * except for isOpen, which will return false. This method can only be called when the
+     * EntityManager is not associated with an active transaction.
+     * 
+     * @throws IllegalStateException if the EntityManager is associated with an active
+     *             transaction or if the EntityManager is container-managed.
+     */
+    public void close() {
+        checkClosed();
+
+        if (transaction != null && transaction.isActive()) {
+            throw new IllegalStateException("Active transaction in progress");
+        }
+
+        open = false;
+    }
+
+    /**
+     * Determine whether the EntityManager is open.
+     * 
+     * @return true until the EntityManager has been closed.
+     */
+    public boolean isOpen() {
+        return open && (factory == null || factory.isOpen());
+    }
+
+    /**
+     * Make an instance managed and persistent.
+     * 
+     * @param entity
+     * @throws IllegalArgumentException if not an entity or entity is detached
+     * @throws TransactionRequiredException if there is no transaction and the persistence
+     *             context is of type PersistenceContextType.TRANSACTION
+     */
+    public void persist(Object entity) {
+        checkClosed();
+        checkTransaction();
+
+        persistInternal(entity);
+    }
+
+    protected abstract void persistInternal(Object entity);
+
+    /**
+     * Merge the state of the given entity into the current persistence context. Cayenne:
+     * Is this like localObject(s)?
+     * 
+     * @param entity
+     * @return the instance that the state was merged to
+     * @throws IllegalArgumentException if instance is not an entity or is a removed
+     *             entity
+     * @throws TransactionRequiredException if there is no transaction and the persistence
+     *             context is of type PersistenceContextType.TRANSACTION
+     */
+    public <T> T merge(T entity) {
+        checkClosed();
+        checkTransaction();
+        return mergeInternal(entity);
+    }
+
+    protected abstract <T> T mergeInternal(T entity);
+
+    /**
+     * Remove the entity instance.
+     * 
+     * @param entity
+     * @throws IllegalArgumentException if not an entity or if a detached entity
+     * @throws TransactionRequiredException if there is no transaction and the persistence
+     *             context is of type PersistenceContextType.TRANSACTION
+     */
+    public void remove(Object entity) {
+        checkClosed();
+        checkTransaction();
+
+        removeInternal(entity);
+    }
+
+    protected abstract void removeInternal(Object entity);
+
+    /**
+     * Find by primary key.
+     * 
+     * @param entityClass
+     * @param primaryKey
+     * @return the found entity instance or null if the entity does not exist
+     * @throws IllegalArgumentException if the first argument does not denote an entity
+     *             type or the second argument is not a valid type for that
+     */
+    public <T> T find(Class<T> entityClass, Object primaryKey) {
+        checkClosed();
+        return findInternal(entityClass, primaryKey);
+    }
+
+    protected abstract <T> T findInternal(Class<T> entityClass, Object primaryKey);
+
+    /**
+     * Get an instance, whose state may be lazily fetched. If the requested instance does
+     * not exist in the database, throws EntityNotFoundException when the instance state
+     * is first accessed. (The persistence provider runtime is permitted to throw the
+     * EntityNotFoundException when getReference is called.) The application should not
+     * expect that theinstance state will be available upon detachment, unless it was
+     * accessed by the application while the entity manager was open.
+     * 
+     * @param entityClass
+     * @param primaryKey
+     * @return the found entity instance
+     * @throws IllegalArgumentException if the first argument does not denote an entity
+     *             type or the second argument is not a valid type for that entityƕs
+     *             primary key
+     * @throws EntityNotFoundException if the entity state cannot be accessed
+     */
+    public <T> T getReference(Class<T> entityClass, Object primaryKey) {
+        checkClosed();
+
+        // TODO: force refresh?
+        T ref = find(entityClass, primaryKey);
+
+        if (ref == null) {
+            throw new EntityNotFoundException("Could not find "
+                    + entityClass.toString()
+                    + " with primary key value "
+                    + primaryKey.toString());
+        }
+
+        return ref;
+    }
+
+    /**
+     * Synchronize the persistence context to the underlying database.
+     * 
+     * @throws TransactionRequiredException if there is no transaction
+     * @throws PersistenceException if the flush fails
+     */
+    public void flush() {
+        checkClosed();
+        checkTransaction();
+
+        flushInternal();
+    }
+
+    protected abstract void flushInternal();
+
+    /**
+     * Set the flush mode that applies to all objects contained in the persistence
+     * context.
+     * 
+     * @param flushMode
+     */
+    public void setFlushMode(FlushModeType flushMode) {
+        checkClosed();
+
+        this.flushMode = flushMode;
+    }
+
+    /**
+     * Get the flush mode that applies to all objects contained in the persistence
+     * context.
+     * 
+     * @return flushMode
+     */
+    public FlushModeType getFlushMode() {
+        checkClosed();
+
+        return flushMode;
+    }
+
+    /**
+     * Refresh the state of the instance from the database, overwriting changes made to
+     * the entity, if any.
+     * 
+     * @param entity
+     * @throws IllegalArgumentException if not an entity or entity is not managed
+     * @throws TransactionRequiredException if there is no transaction and the persistence
+     *             context is of type PersistenceContextType.TRANSACTION
+     * @throws EntityNotFoundException if the entity no longer exists in the database
+     */
+    public void refresh(Object entity) {
+        checkClosed();
+        refreshInternal(entity);
+    }
+
+    protected abstract void refreshInternal(Object entity);
+
+    /**
+     * Clear the persistence context, causing all managed entities to become detached.
+     * Changes made to entities that have not been flushed to the database will not be
+     * persisted.
+     */
+    public void clear() {
+        checkClosed();
+        // TODO: Andrus, 2/10/2006 - implement
+        throw new UnsupportedOperationException("TODO");
+    }
+
+    /**
+     * Check if the instance belongs to the current persistence context.
+     * 
+     * @param entity
+     * @return
+     * @throws IllegalArgumentException if not an entity
+     */
+    public boolean contains(Object entity) {
+        checkClosed();
+        return containsInternal(entity);
+    }
+
+    protected abstract boolean containsInternal(Object entity);
+
+    /**
+     * Create an instance of Query for executing an EJB QL statement.
+     * 
+     * @param ejbqlString an EJB QL query string
+     * @return the new query instance
+     * @throws IllegalArgumentException if query string is not valid
+     */
+    public Query createQuery(String ejbqlString) {
+        checkClosed();
+
+        // TODO: Andrus, 2/10/2006 - implement
+        throw new UnsupportedOperationException("TODO");
+    }
+
+    /**
+     * Create an instance of Query for executing a named query (in EJB QL or native SQL).
+     * 
+     * @param name the name of a query defined in metadata
+     * @return the new query instance
+     * @throws IllegalArgumentException if a query has not been defined with the given name
+     */
+    public abstract Query createNamedQuery(String name);
+
+    /**
+     * Create an instance of Query for executing a native SQL statement, e.g., for update
+     * or delete.
+     * 
+     * @param sqlString a native SQL query string
+     * @return the new query instance
+     */
+    public Query createNativeQuery(String sqlString) {
+        checkClosed();
+
+        // TODO: Andrus, 2/10/2006 - implement
+        throw new UnsupportedOperationException("TODO");
+    }
+
+    /**
+     * Create an instance of Query for executing a native SQL query.
+     * 
+     * @param sqlString a native SQL query string
+     * @param resultClass the class of the resulting instance(s)
+     * @return the new query instance
+     */
+    public abstract Query createNativeQuery(String sqlString, Class resultClass);
+
+    /**
+     * Create an instance of Query for executing a native SQL query.
+     * 
+     * @param sqlString a native SQL query string
+     * @param resultSetMapping the name of the result set mapping
+     * @return the new query instance
+     */
+    public Query createNativeQuery(String sqlString, String resultSetMapping) {
+        checkClosed();
+
+        // TODO: Andrus, 2/10/2006 - implement
+        throw new UnsupportedOperationException("TODO");
+    }
+
+    /**
+     * Return the resource-level transaction object. The EntityTransaction instance may be
+     * used serially to begin and commit multiple transactions.
+     * 
+     * @return EntityTransaction instance
+     * @throws IllegalStateException if invoked on a JTA EntityManager or an EntityManager
+     *             that has been closed.
+     */
+    public EntityTransaction getTransaction() {
+        checkClosed();
+
+        return transaction;
+    }
+
+    public void setTransaction(EntityTransaction transaction) {
+        checkClosed();
+
+        this.transaction = transaction;
+    }
+
+    /*
+     * Throws an exception if called on closed factory.
+     */
+    protected void checkClosed() throws IllegalStateException {
+        if (!isOpen()) {
+            throw new IllegalStateException(
+                    "An attempt to access closed EntityManagerFactory.");
+        }
+    }
+
+    /**
+     * @throws TransactionRequiredException if there is no transaction and the persistence
+     *             context is of type PersistenceContextType.TRANSACTION
+     */
+    protected void checkTransaction() throws TransactionRequiredException {
+        if ((transaction == null) && (contextType == PersistenceContextType.TRANSACTION)) {
+            throw new TransactionRequiredException();
+        }
+    }
+
+}

Added: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/JpaEntityManagerFactory.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/JpaEntityManagerFactory.java?rev=396882&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/JpaEntityManagerFactory.java (added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/JpaEntityManagerFactory.java Tue Apr 25 06:43:00 2006
@@ -0,0 +1,92 @@
+package org.objectstyle.cayenne.jpa;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.spi.PersistenceUnitInfo;
+
+/**
+ * A base implementation of a non-JTA EntityManagerFactory.
+ * 
+ * @author Andrus Adamchik
+ */
+public abstract class JpaEntityManagerFactory implements EntityManagerFactory {
+
+    protected boolean open;
+    protected PersistenceUnitInfo unitInfo;
+
+    public JpaEntityManagerFactory(PersistenceUnitInfo unitInfo) {
+        this.unitInfo = unitInfo;
+        this.open = true;
+    }
+
+    /**
+     * Indicates whether the factory is open. Returns true until the factory has been
+     * closed.
+     */
+    public boolean isOpen() {
+        return open;
+    }
+
+    /**
+     * Close the factory, releasing any resources that it holds. After a factory instance
+     * is closed, all methods invoked on it will throw an IllegalStateException, except
+     * for isOpen, which will return false.
+     */
+    public void close() {
+        checkClosed();
+        this.open = false;
+    }
+
+    /**
+     * Creates a new EntityManager of of type PersistenceContextType.TRANSACTION. This
+     * method returns a new application-managed EntityManager instance (with a new
+     * stand-alone persistence context) each time it is invoked. The {@link #isOpen()}
+     * method will return true on the returned instance.
+     */
+    public EntityManager createEntityManager() {
+        return createEntityManager(PersistenceContextType.TRANSACTION);
+    }
+
+    /**
+     * Create a new EntityManager of the specified persistence context type. This method
+     * returns a new application-managed EntityManager instance (with a new stand-alone
+     * persistence context) each time it is invoked. The {@link #isOpen()} method will
+     * return true on the returned instance.
+     */
+    public EntityManager createEntityManager(PersistenceContextType type) {
+        checkClosed();
+        return createEntityManagerInternal(type);
+    }
+
+    protected abstract EntityManager createEntityManagerInternal(
+            PersistenceContextType type);
+
+    /**
+     * Getan EntityManager instance whose persistence context is propagated with the
+     * current JTA transaction. If there is no persistence context bound to the current
+     * JTA transaction, a new transaction-scoped persistence context is created and
+     * associated with the transaction and the entity manager instance that is created and
+     * returned. If no JTA transaction is in progress, an EntityManager instance is
+     * created for which the persistence context will bepropagated with subsequent JTA
+     * transactions.
+     * 
+     * @throws IllegalStateException if called on an EntityManagerFactory that does not
+     *             provide JTA EntityManagers.
+     */
+    public EntityManager getEntityManager() {
+        checkClosed();
+        throw new IllegalStateException(
+                "JTA EntityManagers are not supported by this factory.");
+    }
+
+    /*
+     * Throws an exception if called on closed factory.
+     */
+    void checkClosed() throws IllegalStateException {
+        if (!isOpen()) {
+            throw new IllegalStateException(
+                    "An attempt to access closed EntityManagerFactory.");
+        }
+    }
+}

Added: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/JpaProviderException.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/JpaProviderException.java?rev=396882&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/JpaProviderException.java (added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/JpaProviderException.java Tue Apr 25 06:43:00 2006
@@ -0,0 +1,82 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.objectstyle.cayenne.jpa;
+
+import org.objectstyle.cayenne.CayenneRuntimeException;
+
+/**
+ * A runtime exception thrown on various problems in the provider code.
+ * 
+ * @author Andrus Adamchik
+ */
+public class JpaProviderException extends CayenneRuntimeException {
+
+    public JpaProviderException() {
+        super();
+    }
+
+    public JpaProviderException(String message) {
+        super(message);
+    }
+
+    public JpaProviderException(Throwable cause) {
+        super(cause);
+    }
+
+    public JpaProviderException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Added: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/CayenneQueryHints.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/CayenneQueryHints.java?rev=396882&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/CayenneQueryHints.java (added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/CayenneQueryHints.java Tue Apr 25 06:43:00 2006
@@ -0,0 +1,69 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.objectstyle.cayenne.jpa.bridge;
+
+import org.objectstyle.cayenne.query.ProcedureQuery;
+import org.objectstyle.cayenne.query.SQLTemplate;
+import org.objectstyle.cayenne.query.SelectQuery;
+
+public interface CayenneQueryHints {
+
+    public static final String QUERY_TYPE_HINT = "cayenne.query.type";
+
+    public static final String QUERY_TYPE_HINT_SELECT_QUERY = SelectQuery.class.getName();
+    public static final String QUERY_TYPE_HINT_PROCEDURE_QUERY = ProcedureQuery.class.getName();
+    public static final String QUERY_TYPE_HINT_SQL_TEMPLATE_QUERY = SQLTemplate.class.getName();
+}

Added: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/DataMapConverter.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/DataMapConverter.java?rev=396882&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/DataMapConverter.java (added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/DataMapConverter.java Tue Apr 25 06:43:00 2006
@@ -0,0 +1,221 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.objectstyle.cayenne.jpa.bridge;
+
+import org.objectstyle.cayenne.jpa.map.JpaAttribute;
+import org.objectstyle.cayenne.jpa.map.JpaEntity;
+import org.objectstyle.cayenne.jpa.map.JpaEntityMap;
+import org.objectstyle.cayenne.jpa.map.JpaNamedQuery;
+import org.objectstyle.cayenne.jpa.map.JpaQueryHint;
+import org.objectstyle.cayenne.map.DataMap;
+import org.objectstyle.cayenne.map.ObjEntity;
+import org.objectstyle.cayenne.project.ProjectPath;
+import org.objectstyle.cayenne.util.BaseTreeVisitor;
+import org.objectstyle.cayenne.util.HierarchicalTreeVisitor;
+import org.objectstyle.cayenne.util.TraversalUtil;
+import org.objectstyle.cayenne.util.Util;
+import org.objectstyle.cayenne.validation.SimpleValidationFailure;
+import org.objectstyle.cayenne.validation.ValidationResult;
+
+/**
+ * A converter between {@link org.objectstyle.cayenne.jpa.map.JpaEntityMap} and Cayenne
+ * {@link org.objectstyle.cayenne.map.DataMap}.
+ * 
+ * @author Andrus Adamchik
+ */
+public class DataMapConverter {
+
+    protected ValidationResult conflicts;
+
+    protected ProjectPath targetPath;
+    protected HierarchicalTreeVisitor visitor;
+
+    public DataMapConverter(ValidationResult conflicts) {
+        this.conflicts = conflicts;
+    }
+
+    public ValidationResult getConflicts() {
+        return conflicts;
+    }
+
+    public synchronized DataMap toDataMap(String name, JpaEntityMap info) {
+
+        // reset
+        DataMap dataMap = new DataMap(name);
+        dataMap.setDefaultPackage(info.getPackageName());
+        dataMap.setDefaultSchema(info.getSchema());
+
+        this.targetPath = new ProjectPath(dataMap);
+
+        if (visitor == null) {
+            visitor = createVisitor();
+        }
+
+        TraversalUtil.traverse(info, visitor);
+        return dataMap;
+    }
+
+    protected void recordConflict(ProjectPath path, String message) {
+        conflicts.addFailure(new SimpleValidationFailure(path.getObject(), message));
+    }
+
+    protected HierarchicalTreeVisitor createVisitor() {
+        BaseTreeVisitor visitor = new BaseTreeVisitor();
+        visitor.addChildVisitor(JpaEntity.class, new EntityVisitor());
+        visitor.addChildVisitor(JpaNamedQuery.class, new NamedQueryVisitor());
+
+        return visitor;
+    }
+
+    class EntityVisitor extends NestedVisitor {
+
+        public EntityVisitor() {
+            addChildVisitor(JpaAttribute.class, new AttributeVisitor());
+        }
+
+        @Override
+        Object createObject(ProjectPath path) {
+            JpaEntity jpaEntity = (JpaEntity) path.getObject();
+            ObjEntity cayenneEntity = new ObjEntity(jpaEntity.getName());
+            cayenneEntity.setClassName(jpaEntity.getClassName());
+
+            ((DataMap) targetPath.getObject()).addObjEntity(cayenneEntity);
+
+            return cayenneEntity;
+        }
+    }
+
+    class AttributeVisitor extends NestedVisitor {
+
+        @Override
+        Object createObject(ProjectPath path) {
+            return null;
+        }
+    }
+
+    class NamedQueryVisitor extends NestedVisitor {
+
+        @Override
+        Object createObject(ProjectPath path) {
+            JpaNamedQuery jpaQuery = (JpaNamedQuery) path.getObject();
+            JpaIndirectQuery cayenneQuery;
+
+            JpaQueryHint hint = jpaQuery.getHint(CayenneQueryHints.QUERY_TYPE_HINT);
+            if (hint != null && !Util.isEmptyString(hint.getValue())) {
+                try {
+                    Object cayenneQueryObject = Class.forName(
+                            hint.getValue(),
+                            true,
+                            Thread.currentThread().getContextClassLoader());
+
+                    if (!(cayenneQueryObject instanceof JpaIndirectQuery)) {
+                        recordConflict(path, "Unknown type for Cayenne query '"
+                                + jpaQuery.getName()
+                                + "': "
+                                + cayenneQueryObject.getClass().getName());
+                        return null;
+                    }
+
+                    cayenneQuery = (JpaIndirectQuery) cayenneQueryObject;
+
+                }
+                catch (Exception e) {
+                    recordConflict(path, "Problem while creating Cayenne query '"
+                            + jpaQuery.getName()
+                            + "', exception"
+                            + e.getMessage());
+                    return null;
+                }
+            }
+            else {
+                // by default use EJBQL query...
+                cayenneQuery = new JpaEjbQLQuery();
+            }
+
+            cayenneQuery.setName(jpaQuery.getName());
+            cayenneQuery.setJpaQuery(jpaQuery);
+            ((DataMap) targetPath.firstInstanceOf(DataMap.class)).addQuery(cayenneQuery);
+
+            return cayenneQuery;
+        }
+    }
+
+    /**
+     * A superclass of visitors that need to push/pop processed object from the stack.
+     */
+    abstract class NestedVisitor extends BaseTreeVisitor {
+
+        abstract Object createObject(ProjectPath path);
+
+        @Override
+        public boolean onStartNode(ProjectPath path) {
+            Object object = createObject(path);
+
+            if (object != null) {
+                targetPath = targetPath.appendToPath(object);
+                return true;
+            }
+            else {
+                return false;
+            }
+        }
+
+        @Override
+        public void onFinishNode(ProjectPath path) {
+            targetPath = targetPath.subpathWithSize(targetPath.getPath().length - 1);
+        }
+    }
+}

Added: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaEjbQLQuery.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaEjbQLQuery.java?rev=396882&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaEjbQLQuery.java (added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaEjbQLQuery.java Tue Apr 25 06:43:00 2006
@@ -0,0 +1,67 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.objectstyle.cayenne.jpa.bridge;
+
+import org.objectstyle.cayenne.map.EntityResolver;
+import org.objectstyle.cayenne.query.Query;
+
+public class JpaEjbQLQuery extends JpaIndirectQuery {
+
+    @Override
+    protected Query createReplacementQuery(EntityResolver resolver) {
+        throw new UnsupportedOperationException("TODO");
+    }
+}

Added: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaIndirectQuery.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaIndirectQuery.java?rev=396882&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaIndirectQuery.java (added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaIndirectQuery.java Tue Apr 25 06:43:00 2006
@@ -0,0 +1,77 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.objectstyle.cayenne.jpa.bridge;
+
+import org.objectstyle.cayenne.jpa.map.JpaNamedQuery;
+import org.objectstyle.cayenne.query.IndirectQuery;
+
+/**
+ * A superclass of indirect queries that map JPA to Cayenne queries.
+ * 
+ * @author Andrus Adamchik
+ */
+public abstract class JpaIndirectQuery extends IndirectQuery {
+
+    protected JpaNamedQuery jpaQuery;
+
+    public JpaNamedQuery getJpaQuery() {
+        return jpaQuery;
+    }
+
+    public void setJpaQuery(JpaNamedQuery query) {
+        this.jpaQuery = query;
+    }
+}

Added: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaProcedureQuery.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaProcedureQuery.java?rev=396882&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaProcedureQuery.java (added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaProcedureQuery.java Tue Apr 25 06:43:00 2006
@@ -0,0 +1,73 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.objectstyle.cayenne.jpa.bridge;
+
+import org.objectstyle.cayenne.map.EntityResolver;
+import org.objectstyle.cayenne.query.Query;
+
+/**
+ * An indirect query that resolves to Cayenne ProcedureQuery using information from JPA
+ * query hints.
+ * 
+ * @author Andrus Adamchik
+ */
+public class JpaProcedureQuery extends JpaIndirectQuery {
+
+    @Override
+    protected Query createReplacementQuery(EntityResolver resolver) {
+        throw new UnsupportedOperationException("TODO");
+    }
+}

Added: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaSQLTemplate.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaSQLTemplate.java?rev=396882&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaSQLTemplate.java (added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaSQLTemplate.java Tue Apr 25 06:43:00 2006
@@ -0,0 +1,74 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.objectstyle.cayenne.jpa.bridge;
+
+import org.objectstyle.cayenne.map.EntityResolver;
+import org.objectstyle.cayenne.query.Query;
+
+/**
+ * An indirect query that resolves to Cayenne SQLTemplate using information from JPA query
+ * hints.
+ * 
+ * @author Andrus Adamchik
+ */
+public class JpaSQLTemplate extends JpaIndirectQuery {
+
+    @Override
+    protected Query createReplacementQuery(EntityResolver resolver) {
+        throw new UnsupportedOperationException("TODO");
+    }
+
+}

Added: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaSelectQuery.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaSelectQuery.java?rev=396882&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaSelectQuery.java (added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/bridge/JpaSelectQuery.java Tue Apr 25 06:43:00 2006
@@ -0,0 +1,73 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.objectstyle.cayenne.jpa.bridge;
+
+import org.objectstyle.cayenne.map.EntityResolver;
+import org.objectstyle.cayenne.query.Query;
+
+/**
+ * An indirect query that resolves to Cayenne SelectQuery using information from JPA query
+ * hints.
+ * 
+ * @author Andrus Adamchik
+ */
+public class JpaSelectQuery extends JpaIndirectQuery {
+
+    @Override
+    protected Query createReplacementQuery(EntityResolver resolver) {
+        throw new UnsupportedOperationException("TODO");
+    }
+}

Added: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/conf/AnnotationProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/conf/AnnotationProcessor.java?rev=396882&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/conf/AnnotationProcessor.java (added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/conf/AnnotationProcessor.java Tue Apr 25 06:43:00 2006
@@ -0,0 +1,78 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.objectstyle.cayenne.jpa.conf;
+
+import java.lang.reflect.AnnotatedElement;
+
+/**
+ * An abstract JPA annotation processor.
+ * 
+ * @author Andrus Adamchik
+ */
+public interface AnnotationProcessor {
+
+    /**
+     * Invoked in the beginning of the annotation tree traversal, which is done in a
+     * depth-first manner.
+     */
+    void onStartElement(AnnotatedElement element, AnnotationProcessorContext context);
+
+    /**
+     * Invoked at the end of the annotation tree traversal, which is done in a depth-first
+     * manner.
+     */
+    void onFinishElement(AnnotatedElement element, AnnotationProcessorContext context);
+}

Added: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/conf/AnnotationProcessorContext.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/conf/AnnotationProcessorContext.java?rev=396882&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/conf/AnnotationProcessorContext.java (added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/conf/AnnotationProcessorContext.java Tue Apr 25 06:43:00 2006
@@ -0,0 +1,75 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.objectstyle.cayenne.jpa.conf;
+
+import java.lang.reflect.AnnotatedElement;
+
+/**
+ * A context for the annotation processor with methods to inspect and modify the processor
+ * stack and record conflicts.
+ * 
+ * @author Andrus Adamchik
+ */
+public interface AnnotationProcessorContext {
+
+    void push(Object object);
+
+    Object pop();
+
+    Object peek();
+
+    void recordConflict(AnnotatedElement element, Class annotatedType, String message);
+}

Added: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/conf/AnnotationProcessorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/conf/AnnotationProcessorFactory.java?rev=396882&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/conf/AnnotationProcessorFactory.java (added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/objectstyle/cayenne/jpa/conf/AnnotationProcessorFactory.java Tue Apr 25 06:43:00 2006
@@ -0,0 +1,198 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.objectstyle.cayenne.jpa.conf;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A factory for annotation processors. Concrete subclasses can simply define inner
+ * classes for the each type of annotation processors they support.
+ * {@link #createProcessor(String)} method will use naming conventions to determine the
+ * type of the processor.
+ * 
+ * @author Andrus Adamchik
+ */
+public abstract class AnnotationProcessorFactory {
+
+    static final String ANNOTATIONS_PACKAGE = "javax.persistence.";
+    static final String PROCESSOR_NAME_SUFFIX = "Processor";
+    static final AnnotationProcessor NOOP_PROCESSOR = new AnnotationProcessor() {
+
+        public void onFinishElement(
+                AnnotatedElement element,
+                AnnotationProcessorContext context) {
+        }
+
+        public void onStartElement(
+                AnnotatedElement element,
+                AnnotationProcessorContext context) {
+        }
+    };
+
+    /**
+     * Dervies processor inner class name, applying naming conventions.
+     */
+    static Class processorClass(Class factoryClass, String annotationFQN) {
+        if (annotationFQN.startsWith(ANNOTATIONS_PACKAGE)) {
+
+            // derive the processor name from the annotation unqualified name, so that we
+            // do not have to configure the processors manually
+
+            // assume that the processor class is an inner class of a concrete factory...
+
+            String processorName = factoryClass.getName()
+                    + "$"
+                    + annotationFQN.substring(ANNOTATIONS_PACKAGE.length())
+                    + PROCESSOR_NAME_SUFFIX;
+
+            try {
+                return Class.forName(processorName, true, Thread
+                        .currentThread()
+                        .getContextClassLoader());
+
+            }
+            catch (Exception e) {
+                // there are a few unsupported annotations in the JPA package related
+                // to Java EE conatiners
+                return null;
+            }
+        }
+        else {
+            return null;
+        }
+
+    }
+
+    /**
+     * Returns an annotation class handled by the processor, applying naming conventions.
+     */
+    static Class annotationClass(Class processorClass) {
+        String name = processorClass.getName();
+        if (!name.endsWith(PROCESSOR_NAME_SUFFIX)) {
+            return null;
+        }
+
+        int split = name.lastIndexOf('$');
+        if (split <= 0) {
+            return null;
+        }
+
+        String className = name.substring(split + 1);
+        String annotationFQN = ANNOTATIONS_PACKAGE
+                + className.substring(0, className.length()
+                        - PROCESSOR_NAME_SUFFIX.length());
+
+        try {
+            return Class.forName(annotationFQN, true, Thread
+                    .currentThread()
+                    .getContextClassLoader());
+
+        }
+        catch (Exception e) {
+            // there are a few unsupported annotations in the JPA package related
+            // to Java EE conatiners
+            return null;
+        }
+    }
+
+    final Map<String, AnnotationProcessor> processors;
+
+    AnnotationProcessorFactory() {
+        this.processors = new HashMap<String, AnnotationProcessor>();
+    }
+
+    /**
+     * Returns processor for a given annotation, caching it ofr future use. Returns null
+     * if an annotation is not a JPA annotation.
+     */
+    AnnotationProcessor getProcessor(Annotation annotation) {
+
+        String annotationName = annotation.annotationType().getName();
+        AnnotationProcessor processor = processors.get(annotationName);
+
+        if (processor == null) {
+            processor = createProcessor(annotationName);
+            processors.put(annotationName, processor);
+        }
+
+        return processor == NOOP_PROCESSOR ? null : processor;
+    }
+
+    /**
+     * Creates a new processor for the annotation full class name.
+     */
+    AnnotationProcessor createProcessor(String annotationFQN) {
+
+        Class processorClass = processorClass(getClass(), annotationFQN);
+
+        if (processorClass != null) {
+
+            try {
+                return (AnnotationProcessor) processorClass.newInstance();
+
+            }
+            catch (Exception e) {
+                return NOOP_PROCESSOR;
+            }
+        }
+
+        // not a JPA annotation...
+        return NOOP_PROCESSOR;
+    }
+}



Mime
View raw message