Actually, what id doe is risk trying to release a null broker. I always
find finally blocks to be clearer, and less redundant.
Thomas Mahler wrote:
> you are right!
>
> David Corbin wrote:
>
>>
>>
>> The following method is take from the Advanced OR tutorial. Doesn't
>> this risk losing a PersistanceBroker? Shouldn't there be a finally
>> clause to release the broker?
>>
>> Thanks.
>> David.
>>
>> protected ClassDescriptor selectClassDescriptor(
>> Map row,
>> ClassDescriptor cld)
>> throws PersistenceBrokerException
>> {
>> // check if there is an attribute which tells us which
>> concrete class // is to be instantiated
>> FieldDescriptor concreteClassFD =
>>
>> cld.getFieldDescriptorByName(ClassDescriptor.OJB_CONCRETE_CLASS);
>>
>> if (concreteClassFD == null)
>> return cld;
>> else
>> {
>> PersistenceBroker broker = null;
>> try
>> {
>> String concreteClass =
>> (String) row.get(concreteClassFD.getColumnName());
>> broker =
>> PersistenceBrokerFactory.createPersistenceBroker();
>> ClassDescriptor result =
>> broker.getClassDescriptor(
>> Class.forName(
>> concreteClass,
>> true,
>>
>> Thread.currentThread().getContextClassLoader()));
>> PersistenceBrokerFactory.releaseInstance(broker);
>> if (result == null)
>> result = cld;
>> return result;
>> }
>> catch (PersistenceBrokerException e)
>> {
>> PersistenceBrokerFactory.releaseInstance(broker);
>> throw e;
>> }
>> catch (ClassNotFoundException e)
>> {
>> PersistenceBrokerFactory.releaseInstance(broker);
>> throw new PersistenceBrokerException(e);
>> }
>> }
>> }
>>
>>
>>
>> --
>> To unsubscribe, e-mail:
>> <mailto:[EMAIL PROTECTED]>
>> For additional commands, e-mail:
>> <mailto:[EMAIL PROTECTED]>
>>
>>
>>
>>
>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>