001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.openjpa.kernel;
020:
021: import java.io.Serializable;
022: import java.util.Properties;
023:
024: import org.apache.openjpa.conf.OpenJPAConfiguration;
025: import org.apache.openjpa.lib.util.Closeable;
026:
027: /**
028: * Factory for {@link Broker} instances.
029: *
030: * @author Abe White
031: * @since 0.4.0
032: */
033: public interface BrokerFactory extends Serializable, Closeable {
034:
035: /**
036: * Return the configuration for this factory.
037: */
038: public OpenJPAConfiguration getConfiguration();
039:
040: /**
041: * Return properties describing this runtime.
042: */
043: public Properties getProperties();
044:
045: /**
046: * Put the specified key-value pair into the map of user objects.
047: */
048: public Object putUserObject(Object key, Object val);
049:
050: /**
051: * Get the value for the specified key from the map of user objects.
052: */
053: public Object getUserObject(Object key);
054:
055: /**
056: * Return a broker with default settings.
057: */
058: public Broker newBroker();
059:
060: /**
061: * Return a broker using the given credentials and in the given
062: * transaction and connection retain mode, optionally finding
063: * existing broker in the global transaction.
064: */
065: public Broker newBroker(String user, String pass, boolean managed,
066: int connRetainMode, boolean findExisting);
067:
068: /**
069: * Register a listener for lifecycle-related events on the specified
070: * classes. If the classes are null, all events will be propagated to
071: * the listener. The listener will be passed on to all new brokers.
072: *
073: * @since 0.3.3
074: */
075: public void addLifecycleListener(Object listener, Class[] classes);
076:
077: /**
078: * Remove a listener for lifecycle-related events.
079: *
080: * @since 0.3.3
081: */
082: public void removeLifecycleListener(Object listener);
083:
084: /**
085: * Register a listener for transaction-related events on the specified
086: * classes. It will be registered with all {@link Broker}s created
087: * from this instance moving forward.
088: *
089: * @since 1.0.0
090: */
091: public void addTransactionListener(Object listener);
092:
093: /**
094: * Remove a listener for transaction-related events. It will no longer
095: * be registered with new {@link Broker}s created from this instance.
096: *
097: * @since 1.0.0
098: */
099: public void removeTransactionListener(Object listener);
100:
101: /**
102: * Close the factory.
103: */
104: public void close();
105:
106: /**
107: * Returns true if this broker factory is closed.
108: */
109: public boolean isClosed();
110:
111: /**
112: * Synchronizes on an internal lock.
113: */
114: public void lock();
115:
116: /**
117: * Release the internal lock.
118: */
119: public void unlock();
120: }
|