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.impl.model.jdo.caching;
19  
20  import org.apache.jdo.model.java.JavaModel;
21  import org.apache.jdo.model.jdo.JDOModel;
22  import org.apache.jdo.model.jdo.JDOModelFactory;
23  
24  import org.apache.jdo.impl.model.jdo.JDOModelFactoryImplDynamic;
25  
26  /***
27   * Factory for caching JDOModel instances.
28   *
29   * @author Michael Bouschen
30   * @since 1.1
31   * @version 1.1
32   */
33  public class JDOModelFactoryImplCaching extends JDOModelFactoryImplDynamic {
34  
35      /*** The singleton JDOModelFactory instance. */    
36      private static JDOModelFactory jdoModelFactory = 
37          new JDOModelFactoryImplCaching();
38  
39      /***
40       * Creates new JDOModelFactoryImplCaching. This constructor
41       * should not be called directly; instead, the singleton access
42       * method  {@link #getInstance} should be used.
43       */
44      protected JDOModelFactoryImplCaching() {}
45  
46      /*** 
47       * Get an instance of JDOModelFactoryImpl.
48       * @return an instance of JDOModelFactoryImpl
49       */    
50      public static JDOModelFactory getInstance() {
51          return jdoModelFactory;
52      }
53      
54      /***
55       * Creates a new empty JDOModel instance. 
56       * The returned JDOModel instance uses the specified flag
57       * <code>loadXMLMetadataDefault</code> to set the default behavior 
58       * for the creation of new JDOClass instances  using methods 
59       * {@link JDOModel#createJDOClass(String)} and 
60       * {@link JDOModel#getJDOClass(String)} for which the caller doesn't 
61       * explicitly specify whether to read XML metatdata or not.
62       * @param loadXMLMetadataDefault the default setting for whether to 
63       * read XML metatdata in JDOModel's methods for JDOClass creation.
64       */
65      public JDOModel createJDOModel(JavaModel javaModel,
66                                     boolean loadXMLMetadataDefault) {
67          return new JDOModelImplCaching(javaModel, loadXMLMetadataDefault);
68      }
69  
70  }