View Javadoc

1   package org.apache.ojb.broker.accesslayer;
2   
3   /* Copyright 2003-2005 The Apache Software Foundation
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * 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  import org.apache.ojb.broker.util.factory.ConfigurableFactory;
19  import org.apache.ojb.broker.metadata.ClassDescriptor;
20  import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
21  
22  /**
23   * Factory for {@link org.apache.ojb.broker.accesslayer.StatementsForClassIF}
24   * implementations. Developers may specify the specific implementation returned by
25   * {@link #getStatementsForClass} by implementing the
26   * {@link org.apache.ojb.broker.accesslayer.StatementsForClassIF}
27   * interface and setting the <code>StatementsForClassClass</code> property in
28   * <code>OJB.properties</code>.
29   * <br/>
30   * @see org.apache.ojb.broker.accesslayer.StatementManager
31   * @see org.apache.ojb.broker.accesslayer.StatementsForClassImpl
32   * @author <a href="mailto:rburt3@mchsi.com">Randall Burt</a>
33   * @version $Id: StatementsForClassFactory.java,v 1.1 2007-08-24 22:17:30 ewestfal Exp $
34   */
35  
36  public class StatementsForClassFactory extends ConfigurableFactory
37  {
38  	private static StatementsForClassFactory singleton;
39  
40  
41  	/**
42  	 * Get the singleton instance of this class
43       * @return the singleton instance of StatementsForClassFactory
44       */
45      public static synchronized StatementsForClassFactory getInstance()
46  	{
47  		if (singleton == null)
48  		{
49  			singleton = new StatementsForClassFactory();
50  		}
51  		return singleton;
52  	}
53  
54      /*
55       * @see org.apache.ojb.broker.util.factory.ConfigurableFactory#getConfigurationKey()
56       */
57      protected String getConfigurationKey()
58      {
59          return "StatementsForClassClass";
60      }
61  
62  
63      /**
64       * Get an instance of {@link org.apache.ojb.broker.accesslayer.StatementsForClassIF}
65       * @param cds our connection descriptor
66       * @param cld the class descriptor of the persistant object
67       * @return an instance of {@link org.apache.ojb.broker.accesslayer.StatementsForClassIF}
68       */
69      public StatementsForClassIF getStatementsForClass(JdbcConnectionDescriptor cds, ClassDescriptor cld)
70      {
71  		return (StatementsForClassIF) this.createNewInstance(new Class[]{JdbcConnectionDescriptor.class, ClassDescriptor.class},
72  		                                                     new Object[]{cds, cld});
73      }
74  }