001: package org.apache.ojb.broker.core;
002:
003: /* Copyright 2003-2005 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: import org.apache.ojb.broker.PBFactoryException;
019: import org.apache.ojb.broker.PBKey;
020: import org.apache.ojb.broker.PersistenceBroker;
021: import org.apache.ojb.broker.PersistenceBrokerInternal;
022: import org.apache.ojb.broker.util.configuration.Configurable;
023:
024: /**
025: * Factory for {@link PersistenceBroker} instances.
026: * Each implementation have to provide a default constructor.
027: *
028: * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
029: * @version $Id: PersistenceBrokerFactoryIF.java,v 1.4.2.3 2005/12/21 22:25:01 tomdz Exp $
030: */
031: public interface PersistenceBrokerFactoryIF extends Configurable {
032: /**
033: * Set the {@link PBKey} used for convinience {@link PersistenceBroker}
034: * lookup method {@link #defaultPersistenceBroker}.
035: * <br/>
036: * Note: It's only allowed to set the default {@link PBKey} once.
037: * All further calls will cause an exception.
038: * If a default {@link org.apache.ojb.broker.metadata.JdbcConnectionDescriptor}
039: * was declared in configuration file, OJB will set the declared PBKey as default.
040: * <br/>
041: * This method is convenience for
042: * {@link org.apache.ojb.broker.metadata.MetadataManager#setDefaultPBKey}.
043: */
044: public void setDefaultKey(PBKey key);
045:
046: /**
047: * Get the default {@link PBKey}.
048: * This method is convenience for
049: * {@link org.apache.ojb.broker.metadata.MetadataManager#getDefaultPBKey}.
050: *
051: * @see #setDefaultKey
052: */
053: public PBKey getDefaultKey();
054:
055: /**
056: * Return {@link org.apache.ojb.broker.PersistenceBroker} instance for the given
057: * {@link org.apache.ojb.broker.PBKey}.
058: *
059: * @param key
060: */
061: public PersistenceBrokerInternal createPersistenceBroker(PBKey key)
062: throws PBFactoryException;
063:
064: /**
065: * Return a ready for action {@link org.apache.ojb.broker.PersistenceBroker} instance.
066: *
067: * @param jcdAlias An jcdAlias name specified in a <tt>jdbc-connection-descriptor</tt>
068: * @param user user name specified in a <tt>jdbc-connection-descriptor</tt>
069: * @param password valid password specified in a <tt>jdbc-connection-descriptor</tt>
070: */
071: public PersistenceBrokerInternal createPersistenceBroker(
072: String jcdAlias, String user, String password)
073: throws PBFactoryException;
074:
075: /**
076: * Return a default broker instance, specified in configuration
077: * or set using {@link #setDefaultKey}.
078: */
079: public PersistenceBrokerInternal defaultPersistenceBroker()
080: throws PBFactoryException;
081:
082: /**
083: * release all broker instances pooled by the factory.
084: * each broker instance is closed before release.
085: */
086: public void releaseAllInstances();
087:
088: /**
089: * Returns the total number of
090: * active {@link org.apache.ojb.broker.PersistenceBroker}
091: * instances.
092: */
093: public int activePersistenceBroker();
094:
095: /**
096: * Shutdown method for OJB, kills all running processes within OJB - after
097: * shutdown OJB can no longer be used.
098: * <br/>
099: * This method is introduced to solve hot/redeployment problems (memory leaks) caused by
100: * the usage of {@link ThreadLocal} instances in OJB source and the reuse of threads
101: * by the container (e.g. servlet- or ejb-container).
102: */
103: public void shutdown();
104: }
|