KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > core > PersistenceBrokerFactoryIF


1 package org.apache.ojb.broker.core;
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.PBFactoryException;
19 import org.apache.ojb.broker.PBKey;
20 import org.apache.ojb.broker.PersistenceBroker;
21 import org.apache.ojb.broker.PersistenceBrokerInternal;
22 import org.apache.ojb.broker.util.configuration.Configurable;
23
24 /**
25  * Factory for {@link PersistenceBroker} instances.
26  * Each implementation have to provide a default constructor.
27  *
28  * @author <a HREF="mailto:thma@apache.org">Thomas Mahler<a>
29  * @version $Id: PersistenceBrokerFactoryIF.java,v 1.4.2.3 2005/12/21 22:25:01 tomdz Exp $
30  */

31 public interface PersistenceBrokerFactoryIF extends Configurable
32 {
33     /**
34      * Set the {@link PBKey} used for convinience {@link PersistenceBroker}
35      * lookup method {@link #defaultPersistenceBroker}.
36      * <br/>
37      * Note: It's only allowed to set the default {@link PBKey} once.
38      * All further calls will cause an exception.
39      * If a default {@link org.apache.ojb.broker.metadata.JdbcConnectionDescriptor}
40      * was declared in configuration file, OJB will set the declared PBKey as default.
41      * <br/>
42      * This method is convenience for
43      * {@link org.apache.ojb.broker.metadata.MetadataManager#setDefaultPBKey}.
44      */

45     public void setDefaultKey(PBKey key);
46
47     /**
48      * Get the default {@link PBKey}.
49      * This method is convenience for
50      * {@link org.apache.ojb.broker.metadata.MetadataManager#getDefaultPBKey}.
51      *
52      * @see #setDefaultKey
53      */

54     public PBKey getDefaultKey();
55
56     /**
57      * Return {@link org.apache.ojb.broker.PersistenceBroker} instance for the given
58      * {@link org.apache.ojb.broker.PBKey}.
59      *
60      * @param key
61      */

62     public PersistenceBrokerInternal createPersistenceBroker(PBKey key) throws PBFactoryException;
63
64     /**
65      * Return a ready for action {@link org.apache.ojb.broker.PersistenceBroker} instance.
66      *
67      * @param jcdAlias An jcdAlias name specified in a <tt>jdbc-connection-descriptor</tt>
68      * @param user user name specified in a <tt>jdbc-connection-descriptor</tt>
69      * @param password valid password specified in a <tt>jdbc-connection-descriptor</tt>
70      */

71     public PersistenceBrokerInternal createPersistenceBroker(String JavaDoc jcdAlias, String JavaDoc user, String JavaDoc password)
72             throws PBFactoryException;
73
74     /**
75      * Return a default broker instance, specified in configuration
76      * or set using {@link #setDefaultKey}.
77      */

78     public PersistenceBrokerInternal defaultPersistenceBroker() throws PBFactoryException;
79
80     /**
81      * release all broker instances pooled by the factory.
82      * each broker instance is closed before release.
83      */

84     public void releaseAllInstances();
85
86     /**
87      * Returns the total number of
88      * active {@link org.apache.ojb.broker.PersistenceBroker}
89      * instances.
90      */

91     public int activePersistenceBroker();
92
93     /**
94      * Shutdown method for OJB, kills all running processes within OJB - after
95      * shutdown OJB can no longer be used.
96      * <br/>
97      * This method is introduced to solve hot/redeployment problems (memory leaks) caused by
98      * the usage of {@link ThreadLocal} instances in OJB source and the reuse of threads
99      * by the container (e.g. servlet- or ejb-container).
100      */

101     public void shutdown();
102 }
103
Popular Tags