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 org.apache.jdo.model.jdo;
19  
20  import org.apache.jdo.model.ModelException;
21  import org.apache.jdo.model.java.JavaModel;
22  
23  
24  /***
25   * Factory for JDOModel instances. The factory provides a mechanism to cache 
26   * JDOModel instances per user defined keys.
27   * 
28   * @author Michael Bouschen
29   * @version 2.0
30   */
31  public interface JDOModelFactory 
32  {
33      /***
34       * Creates a new empty JDOModel instance. 
35       * The returned JDOModel instance uses the specified flag
36       * <code>loadXMLMetadataDefault</code> to set the default behavior 
37       * for the creation of new JDOClass instances  using methods 
38       * {@link JDOModel#createJDOClass(String)} and 
39       * {@link JDOModel#getJDOClass(String)} for which the caller doesn't 
40       * explicitly specify whether to read XML metatdata or not.
41       * @param loadXMLMetadataDefault the default setting for whether to 
42       * read XML metatdata in JDOModel's methods for JDOClass creation.
43       * @exception ModelException if impossible
44       */
45      public JDOModel createJDOModel(JavaModel javaModel,
46                                     boolean loadXMLMetadataDefault)
47          throws ModelException;
48      
49      /***
50       * Returns the JDOModel instance for the specified javaModel.
51       * @param javaModel the javaModel used to cache the returned JDOModel
52       * instance.
53       */
54      public JDOModel getJDOModel(JavaModel javaModel);
55      
56      /***
57       * Returns the JDOModel instance for the specified javaModel.  
58       * The returned JDOModel instance uses the specified flag
59       * <code>loadXMLMetadataDefault</code> to set the default behavior 
60       * for the creation of new JDOClass instances  using methods 
61       * {@link JDOModel#createJDOClass(String)} and 
62       * {@link JDOModel#getJDOClass(String)} for which the caller doesn't 
63       * explicitly specify whether to read XML metatdata or not.
64       * @param loadXMLMetadataDefault the default setting for whether to 
65       * read XML metatdata in JDOModel's methods for JDOClass creation.
66       */
67      public JDOModel getJDOModel(JavaModel javaModel, 
68                                  boolean loadXMLMetadataDefault);
69  
70      /***
71       * Removes the specified jdoModel from the JDOModel cache. Note, if
72       * there are multiple entries in the cache with the specified jdoModel
73       * as value, then all of them get removed. The method does not have an
74       * effect, if this factory does not have the specified jdoModel.
75       * @param jdoModel the JDOModel to be removed.
76       * @since 2.0
77       */
78      public void removeJDOModel(JDOModel jdoModel)
79          throws ModelException;
80  
81      /***
82       * Removes the JDOModel for the specified javaModel from the JDOModel
83       * cache. The method does not have an effect, if this factory does not
84       * have a JDOModel for the the specified javaModel.
85       * @param javaModel the javaModel used to find the JDOModel instance to be
86       * removed.
87       * @since 2.0
88       */
89      public void removeJDOModel(JavaModel javaModel)
90          throws ModelException;
91  
92  }