openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <plins...@gmail.com>
Subject Re: How to wire up a StoreManager
Date Sat, 15 Mar 2008 16:55:44 GMT
So the AbstractStoreManager framework is designed around making it
"easy" to write a custom StoreManager, or at least to get started
writing one. It's designed around putting helper methods in place to
shield you from some of the complexities of the Broker / StoreManager
contract. Some of these complexities are just because of the way we
did things; some of them are there to allow for important performance
/ scalability characteristics in the product.

In terms of using Spring to assemble your StoreManager implementation:

1. The OpenJPA Way is to put EMF-related state into an
OpenJPAConfiguration object (or possibly a subclass). Our
configuration framework should be able to then handle lifecycle issues
and provide non-static EMF-wide singleton services. If you wire up
stateful things directly from your Spring application context to your
StoreManager instances, you'll be coupling your StoreManager to the
particular Spring deployment pattern that you're using. Obviously,
this might be acceptable / desirable for you; I just wanted to point
it out for completeness.

2. To take control of the instantiation of StoreManager instances,
you'll basically want to jettison the AbstractStoreBrokerFactory and
replace it with your own GigaspacesBrokerFactory implementation. Your
implementation should have static getInstance(ConfigurationProvider)
and newInstance(ConfigurationProvider) methods. Set the
'openjpa.BrokerFactory' property to the full class name of your
implementation, and the configuration system will invoke one of those
static methods to get an implementation of your
GigaspacesBrokerFactory. You'll need to implement the abstract
'newStoreManager()' method; this is where you can plug in your Spring
application context.

Does that make sense?

-Patrick

On Wed, Mar 12, 2008 at 12:36 PM, jcarreira <jcarreira@gmail.com> wrote:
>
>
>  Any ideas for me? Anyone?
>
>
>
>
>  jcarreira wrote:
>  >
>  >
>  > Okay, but that's just moved the problem one level higher. At some point
>  > I'd like to be able to have Spring build my instance and be able to pass
>  > it in to OpenJPA to use, whether it be a BrokerFactory or the StoreManager
>  > itself.
>  >
>  > Does anyone else wire OpenJPA up with Spring and pass in anything like the
>  > DataSource to be used by OpenJPA? I want to be able to use the same
>  > objects I'm using in my Spring configuration inside OpenJPA. Outside of a
>  > Servlet context, I don't know how to look up the ApplicationContext to
>  > directly look up the beans.
>  >
>  >
>  > Pinaki Poddar wrote:
>  >>
>  >> Hi,
>  >>   You can plug-in your store manager by the following:
>  >>    1. Extend AbstractBrokerFactory by overwriting the method
>  >>               protected abstract StoreManager newStoreManager();
>  >>
>  >>       Let us call this extended BrokerFactory
>  >> com.gigaspaces.BrokerFactory
>  >>
>  >>    2. Let this method return an instance of your specialized StoreManager
>  >>        For example, here is the implementation of JDBCBrokerFactory:
>  >>
>  >>        protected StoreManager newStoreManager() {
>  >>           return new JDBCStoreManager();
>  >>        }
>  >>
>  >>
>  >>    3. Then at runtime specify
>  >>         <property name="openjpa.BrokerFactory"
>  >> value="com.gigaspaces.BrokerFactory"/>
>  >>
>  >>
>  >>
>  >>
>  >> jcarreira wrote:
>  >>>
>  >>> I'm trying to implement a StoreManager that stores into and retrieves
>  >>> from GigaSpaces. What I need, though, is to be able to dependency-
>  >>> inject the StoreManager instance with its dependencies (for example
>  >>> the GigaSpace instance). As far as I can tell, OpenJPA uses the
>  >>> constructor via reflection to create the instance of the configured
>  >>> class for the StoreManager. This gives me no opportunity to wire it
>  >>> up with the stuff it needs to do its work, unfortunately.
>  >>>
>  >>> Any suggestions?
>  >>>
>  >>> Thanks,
>  >>>
>  >>> Jason Carreira
>  >>>
>  >>>
>  >>
>  >>
>  >
>  >
>
>  --
>  View this message in context: http://www.nabble.com/How-to-wire-up-a-StoreManager-tp15991272p16012528.html
>
>
> Sent from the OpenJPA Developers mailing list archive at Nabble.com.
>
>



-- 
Patrick Linskey
202 669 5907

Mime
View raw message