Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 78048 invoked from network); 5 Sep 2005 10:59:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 5 Sep 2005 10:59:34 -0000 Received: (qmail 54137 invoked by uid 500); 5 Sep 2005 10:59:33 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 53964 invoked by uid 500); 5 Sep 2005 10:59:31 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 53951 invoked by uid 500); 5 Sep 2005 10:59:31 -0000 Received: (qmail 53948 invoked by uid 99); 5 Sep 2005 10:59:31 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 05 Sep 2005 03:59:31 -0700 Received: (qmail 78033 invoked by uid 1797); 5 Sep 2005 10:59:30 -0000 Date: 5 Sep 2005 10:59:30 -0000 Message-ID: <20050905105930.78032.qmail@minotaur.apache.org> From: tomdz@apache.org To: db-ojb-cvs@apache.org Subject: cvs commit: db-ojb/src/java/org/apache/ojb/broker/core/proxy ProxyHelper.java X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N tomdz 2005/09/05 03:59:30 Modified: src/java/org/apache/ojb/broker/core/proxy Tag: OJB_1_0_RELEASE ProxyHelper.java Log: Fix that allows to use the metadata facilities without a configured broker Revision Changes Path No revision No revision 1.2.2.5 +19 -9 db-ojb/src/java/org/apache/ojb/broker/core/proxy/Attic/ProxyHelper.java Index: ProxyHelper.java =================================================================== RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/proxy/Attic/ProxyHelper.java,v retrieving revision 1.2.2.4 retrieving revision 1.2.2.5 diff -u -r1.2.2.4 -r1.2.2.5 --- ProxyHelper.java 12 Aug 2005 13:49:21 -0000 1.2.2.4 +++ ProxyHelper.java 5 Sep 2005 10:59:30 -0000 1.2.2.5 @@ -15,10 +15,12 @@ * limitations under the License. */ +import org.apache.ojb.broker.PBFactoryException; import org.apache.ojb.broker.PersistenceBrokerFactory; import org.apache.ojb.broker.PersistenceBrokerInternal; import java.lang.ref.SoftReference; + /** * ProxyHelper used to get the real thing behind a proxy * @@ -28,19 +30,27 @@ public class ProxyHelper { private static SoftReference proxyFactoryRef; - static { - proxyFactoryRef = new SoftReference(getBroker().getProxyFactory()); - } - - public static ProxyFactory getProxyFactory() { - if (proxyFactoryRef.get() == null) { - proxyFactoryRef = new SoftReference(getBroker().getProxyFactory()); + public synchronized static ProxyFactory getProxyFactory() + { + if ((proxyFactoryRef == null) || (proxyFactoryRef.get() == null)) + { + try + { + proxyFactoryRef = new SoftReference(getBroker().getProxyFactory()); + } + catch (PBFactoryException ex) + { + // seems we cannot get a broker; in that case we're defaulting to the CGLib proxy factory + // (which also works for older JDKs) ie. for broker-less mode (only metadata) + return new ProxyFactoryCGLIBImpl(); + } } return (ProxyFactory)proxyFactoryRef.get(); } - private static PersistenceBrokerInternal getBroker(){ + private static PersistenceBrokerInternal getBroker() + { return (PersistenceBrokerInternal)PersistenceBrokerFactory.defaultPersistenceBroker(); } --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org