You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Fabio Martelli <fa...@gmail.com> on 2012/08/24 17:32:52 UTC

Configuration extension

Hi All,
I'd like to extend OpenJPA configuration in order to add some custom parameters into my persistence.xml.

Could you give me the best practice to do this?

Thank you in advance.
Best regards,
F.

Re: Configuration extension

Posted by Fabio Martelli <fa...@gmail.com>.
Il giorno 29/ago/2012, alle ore 09.39, Fabio Martelli ha scritto:

> 
> Il giorno 28/ago/2012, alle ore 16.51, Kevin Sutter ha scritto:
> 
>> Hi Fabio,
>> It all depends on how extensible of a solution you are looking for.  Are
>> you looking to just extend a current OpenJPA implementation and then
>> migrating those necessary changes from release to release (as your needs
>> required)?  Or, are you looking to provide a pluggable configuration which
>> would make it easier to grow with the OpenJPA releases (but requires a bit
>> more work up-front)?  That's part of the analysis of the requirements that
>> you'll have to do.
> 
> Hi Kevin,
> you are right, I have to "contextualize" my requirement.
> 
> I have to extend OpenJPA in order to add support for SQLAzure [1].
> Please, take a look at [2] and [3].
> 
> As you can imagine, I need to specify some configuration parameters in order to achieve my goal.
> This is the purpose of my request (OpenJPA configuration extension).
> 
> Of course, the best would be to put our developments embedded into OpenJPA (more or less like done for slices - taken as reference for my development) and I hope it will happen sooner or later. Unfortunately, I need something working fine in a very short time so I had to search for a different (but clean) solution.
> 
> The idea is to develop a library of OpenJPA pluggable components and, after a short consolidation period, to submit a patch.
> 
> What do you think about? Am I on the right path?

Hi Kevin,
this is may simple solution to extend OpenJPA configuration.
http://blog.tirasa.net/blogs/index.php/wiseit/

Thank you for you support.
Best regards,
F.

> 
> Best regards,
> F.
> 
> [1] http://en.wikipedia.org/wiki/SQL_Azure
> [2] https://github.com/Tirasa/protojpasqlazure
> [3] https://github.com/Tirasa/OpenJPASQLAzure
> 
>> As you have probably noticed, OpenJPA itself has already extended the
>> OpenJPAConfigurationImpl with both the JDBCConfigurationImpl and the
>> XMLConfigurationImpl.  (As an aside, WebSphere has also extended this
>> implementation for their own extensions.)  So, the capability is there.
>> It's just a matter of how much effort you want to put into it.
> 
> 
>> 
>> Good luck,
>> Kevin
>> 
>> On Tue, Aug 28, 2012 at 6:17 AM, Fabio Martelli <fa...@gmail.com>wrote:
>> 
>>> 
>>> Il giorno 27/ago/2012, alle ore 18.44, Kevin Sutter ha scritto:
>>> 
>>>> Hi Fabio,
>>>> Unfortunately, OpenJPA doesn't have great documentation for extending the
>>>> configuration.  Although, in practice, it is quite easy to do.  What I
>>>> would suggest doing is "implement by example" and look at how other
>>>> configuration properties were incorporated.  For example, let's just take
>>>> openjpa.datacache as an example.  All of the configuration properties
>>> use a
>>>> "plugin configuration" [1].  Then, if you look at the
>>>> OpenJPAConfigurationImpl class, you'll see how this openjpa.datacache is
>>>> parsed and configured.  From there, these configuration values are used
>>>> through out the code (grep for "dataCachePlugin" as an example).
>>>> 
>>>> Hope this helps get you started.
>>> 
>>> Hi Kevin, thank you for your prompt replay.
>>> I sow that OpenJPA configuration is not pluggable.
>>> It seems that, the only way to replace the configuration impl (in order to
>>> add new parameters) it to specify a new BrokerFactory (maybe extending
>>> JDBCBrokerFactory) overriding the single static method newInstance(...).
>>> 
>>> Please, let me know what you think about this solution.
>>> 
>>> Thank you in advance.
>>> Best regards,
>>> F.
>>> 
>>>> Kevin
>>>> 
>>>> [1]
>>>> 
>>> http://openjpa.apache.org/builds/latest/docs/docbook/manual.html#ref_guide_conf_plugins
>>>> 
>>>> On Fri, Aug 24, 2012 at 10:32 AM, Fabio Martelli
>>>> <fa...@gmail.com>wrote:
>>>> 
>>>>> Hi All,
>>>>> I'd like to extend OpenJPA configuration in order to add some custom
>>>>> parameters into my persistence.xml.
>>>>> 
>>>>> Could you give me the best practice to do this?
>>>>> 
>>>>> Thank you in advance.
>>>>> Best regards,
>>>>> F.
>>> 
>>> 
> 


Re: Configuration extension

Posted by Fabio Martelli <fa...@gmail.com>.
Il giorno 28/ago/2012, alle ore 16.51, Kevin Sutter ha scritto:

> Hi Fabio,
> It all depends on how extensible of a solution you are looking for.  Are
> you looking to just extend a current OpenJPA implementation and then
> migrating those necessary changes from release to release (as your needs
> required)?  Or, are you looking to provide a pluggable configuration which
> would make it easier to grow with the OpenJPA releases (but requires a bit
> more work up-front)?  That's part of the analysis of the requirements that
> you'll have to do.

Hi Kevin,
you are right, I have to "contextualize" my requirement.

I have to extend OpenJPA in order to add support for SQLAzure [1].
Please, take a look at [2] and [3].

As you can imagine, I need to specify some configuration parameters in order to achieve my goal.
This is the purpose of my request (OpenJPA configuration extension).

Of course, the best would be to put our developments embedded into OpenJPA (more or less like done for slices - taken as reference for my development) and I hope it will happen sooner or later. Unfortunately, I need something working fine in a very short time so I had to search for a different (but clean) solution.

The idea is to develop a library of OpenJPA pluggable components and, after a short consolidation period, to submit a patch.

What do you think about? Am I on the right path?

Best regards,
F.

[1] http://en.wikipedia.org/wiki/SQL_Azure
[2] https://github.com/Tirasa/protojpasqlazure
[3] https://github.com/Tirasa/OpenJPASQLAzure

> As you have probably noticed, OpenJPA itself has already extended the
> OpenJPAConfigurationImpl with both the JDBCConfigurationImpl and the
> XMLConfigurationImpl.  (As an aside, WebSphere has also extended this
> implementation for their own extensions.)  So, the capability is there.
> It's just a matter of how much effort you want to put into it.


> 
> Good luck,
> Kevin
> 
> On Tue, Aug 28, 2012 at 6:17 AM, Fabio Martelli <fa...@gmail.com>wrote:
> 
>> 
>> Il giorno 27/ago/2012, alle ore 18.44, Kevin Sutter ha scritto:
>> 
>>> Hi Fabio,
>>> Unfortunately, OpenJPA doesn't have great documentation for extending the
>>> configuration.  Although, in practice, it is quite easy to do.  What I
>>> would suggest doing is "implement by example" and look at how other
>>> configuration properties were incorporated.  For example, let's just take
>>> openjpa.datacache as an example.  All of the configuration properties
>> use a
>>> "plugin configuration" [1].  Then, if you look at the
>>> OpenJPAConfigurationImpl class, you'll see how this openjpa.datacache is
>>> parsed and configured.  From there, these configuration values are used
>>> through out the code (grep for "dataCachePlugin" as an example).
>>> 
>>> Hope this helps get you started.
>> 
>> Hi Kevin, thank you for your prompt replay.
>> I sow that OpenJPA configuration is not pluggable.
>> It seems that, the only way to replace the configuration impl (in order to
>> add new parameters) it to specify a new BrokerFactory (maybe extending
>> JDBCBrokerFactory) overriding the single static method newInstance(...).
>> 
>> Please, let me know what you think about this solution.
>> 
>> Thank you in advance.
>> Best regards,
>> F.
>> 
>>> Kevin
>>> 
>>> [1]
>>> 
>> http://openjpa.apache.org/builds/latest/docs/docbook/manual.html#ref_guide_conf_plugins
>>> 
>>> On Fri, Aug 24, 2012 at 10:32 AM, Fabio Martelli
>>> <fa...@gmail.com>wrote:
>>> 
>>>> Hi All,
>>>> I'd like to extend OpenJPA configuration in order to add some custom
>>>> parameters into my persistence.xml.
>>>> 
>>>> Could you give me the best practice to do this?
>>>> 
>>>> Thank you in advance.
>>>> Best regards,
>>>> F.
>> 
>> 


Re: Configuration extension

Posted by Kevin Sutter <kw...@gmail.com>.
Hi Fabio,
It all depends on how extensible of a solution you are looking for.  Are
you looking to just extend a current OpenJPA implementation and then
migrating those necessary changes from release to release (as your needs
required)?  Or, are you looking to provide a pluggable configuration which
would make it easier to grow with the OpenJPA releases (but requires a bit
more work up-front)?  That's part of the analysis of the requirements that
you'll have to do.

As you have probably noticed, OpenJPA itself has already extended the
OpenJPAConfigurationImpl with both the JDBCConfigurationImpl and the
XMLConfigurationImpl.  (As an aside, WebSphere has also extended this
implementation for their own extensions.)  So, the capability is there.
It's just a matter of how much effort you want to put into it.

Good luck,
Kevin

On Tue, Aug 28, 2012 at 6:17 AM, Fabio Martelli <fa...@gmail.com>wrote:

>
> Il giorno 27/ago/2012, alle ore 18.44, Kevin Sutter ha scritto:
>
> > Hi Fabio,
> > Unfortunately, OpenJPA doesn't have great documentation for extending the
> > configuration.  Although, in practice, it is quite easy to do.  What I
> > would suggest doing is "implement by example" and look at how other
> > configuration properties were incorporated.  For example, let's just take
> > openjpa.datacache as an example.  All of the configuration properties
> use a
> > "plugin configuration" [1].  Then, if you look at the
> > OpenJPAConfigurationImpl class, you'll see how this openjpa.datacache is
> > parsed and configured.  From there, these configuration values are used
> > through out the code (grep for "dataCachePlugin" as an example).
> >
> > Hope this helps get you started.
>
> Hi Kevin, thank you for your prompt replay.
> I sow that OpenJPA configuration is not pluggable.
> It seems that, the only way to replace the configuration impl (in order to
> add new parameters) it to specify a new BrokerFactory (maybe extending
> JDBCBrokerFactory) overriding the single static method newInstance(...).
>
> Please, let me know what you think about this solution.
>
> Thank you in advance.
> Best regards,
> F.
>
> > Kevin
> >
> > [1]
> >
> http://openjpa.apache.org/builds/latest/docs/docbook/manual.html#ref_guide_conf_plugins
> >
> > On Fri, Aug 24, 2012 at 10:32 AM, Fabio Martelli
> > <fa...@gmail.com>wrote:
> >
> >> Hi All,
> >> I'd like to extend OpenJPA configuration in order to add some custom
> >> parameters into my persistence.xml.
> >>
> >> Could you give me the best practice to do this?
> >>
> >> Thank you in advance.
> >> Best regards,
> >> F.
>
>

Re: Configuration extension

Posted by Fabio Martelli <fa...@gmail.com>.
Il giorno 27/ago/2012, alle ore 18.44, Kevin Sutter ha scritto:

> Hi Fabio,
> Unfortunately, OpenJPA doesn't have great documentation for extending the
> configuration.  Although, in practice, it is quite easy to do.  What I
> would suggest doing is "implement by example" and look at how other
> configuration properties were incorporated.  For example, let's just take
> openjpa.datacache as an example.  All of the configuration properties use a
> "plugin configuration" [1].  Then, if you look at the
> OpenJPAConfigurationImpl class, you'll see how this openjpa.datacache is
> parsed and configured.  From there, these configuration values are used
> through out the code (grep for "dataCachePlugin" as an example).
> 
> Hope this helps get you started.

Hi Kevin, thank you for your prompt replay.
I sow that OpenJPA configuration is not pluggable.
It seems that, the only way to replace the configuration impl (in order to add new parameters) it to specify a new BrokerFactory (maybe extending JDBCBrokerFactory) overriding the single static method newInstance(...).

Please, let me know what you think about this solution.

Thank you in advance.
Best regards,
F.

> Kevin
> 
> [1]
> http://openjpa.apache.org/builds/latest/docs/docbook/manual.html#ref_guide_conf_plugins
> 
> On Fri, Aug 24, 2012 at 10:32 AM, Fabio Martelli
> <fa...@gmail.com>wrote:
> 
>> Hi All,
>> I'd like to extend OpenJPA configuration in order to add some custom
>> parameters into my persistence.xml.
>> 
>> Could you give me the best practice to do this?
>> 
>> Thank you in advance.
>> Best regards,
>> F.


Re: Configuration extension

Posted by Kevin Sutter <kw...@gmail.com>.
Hi Fabio,
Unfortunately, OpenJPA doesn't have great documentation for extending the
configuration.  Although, in practice, it is quite easy to do.  What I
would suggest doing is "implement by example" and look at how other
configuration properties were incorporated.  For example, let's just take
openjpa.datacache as an example.  All of the configuration properties use a
"plugin configuration" [1].  Then, if you look at the
OpenJPAConfigurationImpl class, you'll see how this openjpa.datacache is
parsed and configured.  From there, these configuration values are used
through out the code (grep for "dataCachePlugin" as an example).

Hope this helps get you started.

Kevin

[1]
http://openjpa.apache.org/builds/latest/docs/docbook/manual.html#ref_guide_conf_plugins

On Fri, Aug 24, 2012 at 10:32 AM, Fabio Martelli
<fa...@gmail.com>wrote:

> Hi All,
> I'd like to extend OpenJPA configuration in order to add some custom
> parameters into my persistence.xml.
>
> Could you give me the best practice to do this?
>
> Thank you in advance.
> Best regards,
> F.