View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package javax.jdo;
19  
20  import javax.persistence.EntityManagerFactory;
21  
22  /*
23   * JDOEntityManagerFactory.java
24   *
25   * @since 2.1
26   *
27   */
28  public interface JDOEntityManagerFactory 
29      extends EntityManagerFactory, PersistenceManagerFactory {
30  
31      /** Get an instance of <code>JDOEntityManager</code> from this factory.  
32       * The instance has default values for options. This method overrides
33       * the getPersistenceManager method from PersistenceManagerFactory.
34       *
35       * <P>After the first use of <code>getPersistenceManager</code>, no "set" 
36       * methods will succeed.
37       *
38       * @return a <code>JDOEntityManager</code> instance with default options.
39       */
40      JDOEntityManager getPersistenceManager();
41  
42      /** Get a thread-safe instance of a proxy that dynamically binds 
43       * on each method call to an instance of <code>JDOEntityManager</code>.
44       * <P>When used with a <code>JDOEntityManagerFactory</code>
45       * that uses TransactionType JTA,
46       * the proxy can be used in a server to dynamically bind to an instance 
47       * from this factory associated with the thread's current transaction.
48       * In this case, the close method is ignored, as the 
49       * <code>PersistenceManager</code> is automatically closed when the
50       * transaction completes.
51       * <P>When used with a <code>JDOEntityManagerFactory</code>
52       * that uses TransactionType RESOURCE_LOCAL, the proxy uses an inheritable
53       * ThreadLocal to bind to an instance of <code>JDOEntityManager</code>
54       * associated with the thread. In this case, the close method executed
55       * on the proxy closes the <code>JDOEntityManager</code> and then
56       * clears the ThreadLocal.
57       * Use of this method does not affect the configurability of the
58       * <code>JDOEntityManagerFactory</code>.
59       *
60       * @since 2.1
61       * @return a <code>PersistenceManager</code> proxy.
62       */
63      JDOEntityManager getPersistenceManagerProxy();
64  
65      /** Get an instance of <code>JDOEntityManager</code> from this factory.  
66       * The instance has default values for options.  
67       * The parameters <code>userid</code> and <code>password</code> are used 
68       * when obtaining datastore connections from the connection pool.
69       *
70       * <P>After the first use of <code>getPersistenceManager</code>, no "set" 
71       * methods will succeed.
72       *
73       * @return a <code>JDOEntityManager</code> instance with default options.
74       * @param userid the userid for the connection
75       * @param password the password for the connection
76       */
77      JDOEntityManager getPersistenceManager(String userid, String password);
78  
79  }