View Javadoc

1   /*
2    * Copyright 2005 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at 
7    * 
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software 
11   * distributed under the License is distributed on an "AS IS" BASIS, 
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License.
15   */
16  
17  package org.apache.jdo.impl.model.jdo.caching;
18  
19  import org.apache.jdo.model.java.JavaModel;
20  import org.apache.jdo.model.jdo.JDOModel;
21  import org.apache.jdo.model.jdo.JDOModelFactory;
22  
23  import org.apache.jdo.impl.model.jdo.JDOModelFactoryImplDynamic;
24  
25  /***
26   * Factory for caching JDOModel instances.
27   *
28   * @author Michael Bouschen
29   * @since 1.1
30   * @version 1.1
31   */
32  public class JDOModelFactoryImplCaching extends JDOModelFactoryImplDynamic {
33  
34      /*** The singleton JDOModelFactory instance. */    
35      private static JDOModelFactory jdoModelFactory = 
36          new JDOModelFactoryImplCaching();
37  
38      /***
39       * Creates new JDOModelFactoryImplCaching. This constructor
40       * should not be called directly; instead, the singleton access
41       * method  {@link #getInstance} should be used.
42       */
43      protected JDOModelFactoryImplCaching() {}
44  
45      /*** 
46       * Get an instance of JDOModelFactoryImpl.
47       * @return an instance of JDOModelFactoryImpl
48       */    
49      public static JDOModelFactory getInstance() {
50          return jdoModelFactory;
51      }
52      
53      /***
54       * Creates a new empty JDOModel instance. 
55       * The returned JDOModel instance uses the specified flag
56       * <code>loadXMLMetadataDefault</code> to set the default behavior 
57       * for the creation of new JDOClass instances  using methods 
58       * {@link JDOModel#createJDOClass(String)} and 
59       * {@link JDOModel#getJDOClass(String)} for which the caller doesn't 
60       * explicitly specify whether to read XML metatdata or not.
61       * @param loadXMLMetadataDefault the default setting for whether to 
62       * read XML metatdata in JDOModel's methods for JDOClass creation.
63       */
64      public JDOModel createJDOModel(JavaModel javaModel,
65                                     boolean loadXMLMetadataDefault) {
66          return new JDOModelImplCaching(javaModel, loadXMLMetadataDefault);
67      }
68  
69  }