You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by Leandro Rodrigo Saad Cruz <le...@ibnetwork.com.br> on 2004/11/16 15:07:13 UTC
ObjectFactory problem - Pico caching
Hi all. I'm having some problems with ojb-HEAD b/c the ObjectFactory
instance is not a singleton (IMHO it should), is there any place I can
tell pico to cache isnatnces of ObjectFactory.
--
Leandro Rodrigo Saad Cruz
InterBusiness Tecnologia e Serviços
IB - www.ibnetwork.com.br
DB - www.digitalbrand.com.br
OJB - db.apache.org/ojb
XINGU - xingu.sf.net
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: ObjectFactory problem - Pico caching
Posted by Leandro Rodrigo Saad Cruz <le...@ibnetwork.com.br>.
On Tue, 2004-11-16 at 15:48 +0100, Thomas Dudziak wrote:
> >
> I didn't touch the PersistenceBrokerFactory stuff yet, but I will so in
> the next days - which will ultimatively result in the removal of the PBF
> - so perhaps you should migrate to direct usage of the OJB class:
>
> OJB ojb = new OJB();
>
> ojb.getConfiguration().registerCreator(...);
> broker = ojb.lookupBroker(key);
>
> Also, the creator registration probably doesn't work the way that you
> think. If you want to register one creator instance that handles *all*
> your classes, you should inherit from the ObjectFactoryDefaultImpl and
> register your instance like this:
>
> OJB ojb = new OJB();
>
> ojb.getComponentContainer().setSingletonInstance(ObjectFactory.class,
> myFactory);
> broker = ojb.lookupBroker(key);
>
> but note that you have to do so before the configuration object is
> created (i.e. before using this key).
>
> Btw, the use-factory flag in the class descriptor is no longer
> necessary, I just haven't removed it yet.
Ok.. thanks. I changed (will not commit) ObjectFactoryDefaultImpl to
handle the case on my example (using '*' as a type name). So. if you
call registerCreator(creator,"*"); this creator instance is considered
the default way to create objects
--
Leandro Rodrigo Saad Cruz
InterBusiness Tecnologia e Serviços
IB - www.ibnetwork.com.br
DB - www.digitalbrand.com.br
OJB - db.apache.org/ojb
XINGU - xingu.sf.net
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: ObjectFactory problem - Pico caching
Posted by Thomas Dudziak <to...@first.fhg.de>.
Leandro Rodrigo Saad Cruz wrote:
>I changed my code to :
>
>PBKey key = new PBKey(alias);
>PersistenceBroker broker =
>PersistenceBrokerFactory.createPersistenceBroker(key);
>broker.getConfiguration().getObjectFactory().registerCreator(creator,"*");
>return broker;
>
>Now it works.. Thanks !
>
>
I didn't touch the PersistenceBrokerFactory stuff yet, but I will so in
the next days - which will ultimatively result in the removal of the PBF
- so perhaps you should migrate to direct usage of the OJB class:
OJB ojb = new OJB();
ojb.getConfiguration().registerCreator(...);
broker = ojb.lookupBroker(key);
Also, the creator registration probably doesn't work the way that you
think. If you want to register one creator instance that handles *all*
your classes, you should inherit from the ObjectFactoryDefaultImpl and
register your instance like this:
OJB ojb = new OJB();
ojb.getComponentContainer().setSingletonInstance(ObjectFactory.class,
myFactory);
broker = ojb.lookupBroker(key);
but note that you have to do so before the configuration object is
created (i.e. before using this key).
Btw, the use-factory flag in the class descriptor is no longer
necessary, I just haven't removed it yet.
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: ObjectFactory problem - Pico caching
Posted by Leandro Rodrigo Saad Cruz <le...@ibnetwork.com.br>.
I changed my code to :
PBKey key = new PBKey(alias);
PersistenceBroker broker =
PersistenceBrokerFactory.createPersistenceBroker(key);
broker.getConfiguration().getObjectFactory().registerCreator(creator,"*");
return broker;
Now it works.. Thanks !
On Tue, 2004-11-16 at 15:08 +0100, Thomas Dudziak wrote:
> Leandro Rodrigo Saad Cruz wrote:
>
> >Hi all. I'm having some problems with ojb-HEAD b/c the ObjectFactory
> >instance is not a singleton (IMHO it should), is there any place I can
> >tell pico to cache isnatnces of ObjectFactory.
> >
> >
> Its a singleton per PersistenceConfiguration.
> What is your exact problem ?
>
> Tom
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: ObjectFactory problem - Pico caching
Posted by Leandro Rodrigo Saad Cruz <le...@ibnetwork.com.br>.
<java>
PBKey key = new PBKey(alias);
PersistenceBrokerFactory.getOjb().getConfiguration(key).getObjectFactory().registerCreator(creator,"*");
PersistenceBrokerFactory.createPersistenceBroker(key);
</java>
An instance of ObjectFactoryDefaultImpl is created on lines 2 and 3 from
the snippet above. Do you know why ?!
On Tue, 2004-11-16 at 15:08 +0100, Thomas Dudziak wrote:
> Leandro Rodrigo Saad Cruz wrote:
>
> >Hi all. I'm having some problems with ojb-HEAD b/c the ObjectFactory
> >instance is not a singleton (IMHO it should), is there any place I can
> >tell pico to cache isnatnces of ObjectFactory.
> >
> >
> Its a singleton per PersistenceConfiguration.
> What is your exact problem ?
>
> Tom
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: ObjectFactory problem - Pico caching
Posted by Thomas Dudziak <to...@first.fhg.de>.
Leandro Rodrigo Saad Cruz wrote:
>Hi all. I'm having some problems with ojb-HEAD b/c the ObjectFactory
>instance is not a singleton (IMHO it should), is there any place I can
>tell pico to cache isnatnces of ObjectFactory.
>
>
Its a singleton per PersistenceConfiguration.
What is your exact problem ?
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org