+ public Object newInstance(String clsName, Class type,
Configuration conf,
+ boolean fatal) {
+ if (BrokerImpl.class.getName().equals(clsName)) {
+ // This is not synchronized. If there are concurrent
invocations
+ // while _templateBroker is null, we'll just end up
with extra
+ // template brokers, which will get safely garbage
collected.
+ if (_templateBroker == null)
+ _templateBroker = (BrokerImpl) super.newInstance(
+ clsName, type, conf, fatal);
+ try {
+ return _templateBroker.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new InternalException(e);
+ }
+ } else {
+ return super.newInstance(clsName, type, conf, fatal);
+ }
+ }
+}
Don't we want FinalizingBrokerImpls to clone too? And possible
subclasses? How about:
Cloneable _templateBroker = null;
boolean _templateTried = false;
...
if (!_templateTried) {
Object broker = super.newInstance(clsName, type, conf, false);
if (broker instanceof Cloneable)
_templateBroker = (Cloneable) broker;
_templateTried = true;
}
if (_templateBroker != null) {
return _templateBroker.clone...
}
return super.newInstance...
And for completeness we should set _templateTrid to false on set/
setString.
_______________________________________________________________________
Notice: This email message, together with any attachments, may contain
information of BEA Systems, Inc., its subsidiaries and affiliated
entities, that may be confidential, proprietary, copyrighted and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.