cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r507944 - in /cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa: CayenneEntityManager.java ResourceLocalEntityManager.java
Date Thu, 15 Feb 2007 14:49:17 GMT
Author: aadamchik
Date: Thu Feb 15 06:49:16 2007
New Revision: 507944

URL: http://svn.apache.org/viewvc?view=rev&rev=507944
Log:
adding an interface that would allow access to Cayenne stack from the JPA EntityManager

Added:
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/CayenneEntityManager.java
Modified:
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/ResourceLocalEntityManager.java

Added: cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/CayenneEntityManager.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/CayenneEntityManager.java?view=auto&rev=507944
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/CayenneEntityManager.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/CayenneEntityManager.java
Thu Feb 15 06:49:16 2007
@@ -0,0 +1,41 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.jpa;
+
+import javax.persistence.EntityManager;
+
+import org.apache.cayenne.DataChannel;
+
+/**
+ * An interface that allows to access Cayenne runtime hidden behind standard JPA classes.
+ * To do that, simply cast an EntityManager returned by Cayenne provider to
+ * "CayenneEntityManager". Note that a regular JPA application shouldn't normally attempt
+ * to do that. Otherwise it will not be portable across JPA providers.
+ * 
+ * @author Andrus Adamchik
+ */
+public interface CayenneEntityManager extends EntityManager {
+
+    /**
+     * Returns a Cayenne {@link DataChannel} that is used to link EntityManager with
+     * Cayenne runtime. DataChannel can be used for instance to obtain Cayenne metadata or
+     * add listeners.
+     */
+    DataChannel getChannel();
+}

Modified: cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/ResourceLocalEntityManager.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/ResourceLocalEntityManager.java?view=diff&rev=507944&r1=507943&r2=507944
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/ResourceLocalEntityManager.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/ResourceLocalEntityManager.java
Thu Feb 15 06:49:16 2007
@@ -28,13 +28,14 @@
 import javax.persistence.Query;
 
 import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.DataChannel;
 import org.apache.cayenne.DataObjectUtils;
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.PersistenceState;
 import org.apache.cayenne.Persistent;
 import org.apache.cayenne.access.Transaction;
 
-public class ResourceLocalEntityManager implements EntityManager {
+public class ResourceLocalEntityManager implements EntityManager, CayenneEntityManager {
 
     protected EntityTransaction transaction;
     protected ResourceLocalEntityManagerFactory factory;
@@ -55,6 +56,13 @@
     }
 
     /**
+     * Returns a DataChannel of the peer ObjectContext.
+     */
+    public DataChannel getChannel() {
+        return context.getChannel();
+    }
+
+    /**
      * Returns parent EntityManagerFactory.
      */
     protected ResourceLocalEntityManagerFactory getFactory() {
@@ -150,7 +158,7 @@
      * 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
+     * expect that the instance state will be available upon detachment, unless it was
      * accessed by the application while the entity manager was open.
      * 
      * @param entityClass



Mime
View raw message