You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Jim Talbut <jt...@spudsoft.co.uk> on 2012/06/22 18:14:30 UTC

OpenJPA Audit

Just want to say thanks.

Some time ago I was involved in a discussion here about doing audit 
using lifecycle listeners.
There are a whole bunch of problems with this approach and, although my 
implementation worked, it was not specified that it would work.

Yesterday I needed to add an audit facility to a system and noticed the 
new @Auditable annotation 
(http://openjpa.apache.org/builds/2.2.0/apache-openjpa/docs/ref_guide_audit.html).
Wow.
I spent some time worrying about how to write the data to the database - 
assuming I'd have to use JDBC and worrying about how to inject the data 
source.
Then I noticed that the Broker passed lets me persist a new Entity 
during the audit.

Thank you guys.

Jim

Re: OpenJPA Audit

Posted by Bengt Rodehav <be...@rodehav.com>.
Sounds like an interesting idea to me. It would allow me to import any
packages I need in order to properly configure the entity manager factory.

My original idea was that OpenJPA should use the class loader for the
bundle that contained the persistence.xml. That way I could make sure that
bundle imported anything needed. Right now, it seems like OpenJPA does not
try that class loader (although it tries a bunch of other class loaders).

/Bengt

2012/6/28 Jim Talbut <jt...@spudsoft.co.uk>

> Hi,
>
> Could the Auditor (or an AuditorFactory) be set via some property on the
> entityManagerFactory?
> If it could it would remove any need for class loading from this part of
> OpenJPA, because it puts the responsibility on the user to construct it how
> they want.
> It would also let them set it to a fully formed object, with access to any
> other objects they have - the property setting supported within
> persistence.xml is rather limited compared to what could be done with
> Spring/Blueprint.
>
> At the moment the only way I can see of passing information from the
> outside world to OpenJPA is via the jpaProperties - which is limited to
> strings.
> It may be that to provide this feature we'd need some kind of
> global/singleton/static OpenJPA world object to use for passing
> non-string-stuff into OpenJPA.
>
> Jim
>
>
> On 28/06/2012 02:10, Pinaki Poddar wrote:
>
>> Kevin,
>>   I may have done something non-kosher with openjpa.Auditor property. And
>> I
>> did not test it in OSGi environment either. Bengt had reported earlier
>> classloading issues. It may be worthwhile to try this Auditor within an
>> OSGi
>> environment, if one is set up to work with OpenJPA.
>>   First thing we need to ascertain whether it is openjpa.Auditor is loaded
>> in a non-standard way than other custom plugins. But unfortunately I do
>> not
>> have an OSGi environment to test.
>>
>> -----
>> Pinaki Poddar
>> Chair, Apache OpenJPA Project
>> --
>> View this message in context: http://openjpa.208410.n2.**
>> nabble.com/OpenJPA-Audit-**tp7580377p7580424.html<http://openjpa.208410.n2.nabble.com/OpenJPA-Audit-tp7580377p7580424.html>
>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>
>
>
>

Re: OpenJPA Audit

Posted by Jim Talbut <jt...@spudsoft.co.uk>.
Hi,

Could the Auditor (or an AuditorFactory) be set via some property on the 
entityManagerFactory?
If it could it would remove any need for class loading from this part of 
OpenJPA, because it puts the responsibility on the user to construct it 
how they want.
It would also let them set it to a fully formed object, with access to 
any other objects they have - the property setting supported within 
persistence.xml is rather limited compared to what could be done with 
Spring/Blueprint.

At the moment the only way I can see of passing information from the 
outside world to OpenJPA is via the jpaProperties - which is limited to 
strings.
It may be that to provide this feature we'd need some kind of 
global/singleton/static OpenJPA world object to use for passing 
non-string-stuff into OpenJPA.

Jim

On 28/06/2012 02:10, Pinaki Poddar wrote:
> Kevin,
>    I may have done something non-kosher with openjpa.Auditor property. And I
> did not test it in OSGi environment either. Bengt had reported earlier
> classloading issues. It may be worthwhile to try this Auditor within an OSGi
> environment, if one is set up to work with OpenJPA.
>    First thing we need to ascertain whether it is openjpa.Auditor is loaded
> in a non-standard way than other custom plugins. But unfortunately I do not
> have an OSGi environment to test.
>
> -----
> Pinaki Poddar
> Chair, Apache OpenJPA Project
> --
> View this message in context: http://openjpa.208410.n2.nabble.com/OpenJPA-Audit-tp7580377p7580424.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.



Re: OpenJPA Audit

Posted by Pinaki Poddar <pp...@apache.org>.
Kevin,
  I may have done something non-kosher with openjpa.Auditor property. And I
did not test it in OSGi environment either. Bengt had reported earlier
classloading issues. It may be worthwhile to try this Auditor within an OSGi
environment, if one is set up to work with OpenJPA.
  First thing we need to ascertain whether it is openjpa.Auditor is loaded
in a non-standard way than other custom plugins. But unfortunately I do not
have an OSGi environment to test. 

-----
Pinaki Poddar
Chair, Apache OpenJPA Project
--
View this message in context: http://openjpa.208410.n2.nabble.com/OpenJPA-Audit-tp7580377p7580424.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: OpenJPA Audit

Posted by Kevin Sutter <kw...@gmail.com>.
OpenJPA is successfully used in the WebSphere v8.5 Liberty Profile which is
an OSGi-based runtime (based on Apache Aries).  So, from a generic usage
standpoint, OpenJPA can play nice in an OSGi environment.

As far as loading the Auditing classes...  The openjpa.Auditor property is
just like any other plugin property.  I know in the past, we had some
issues with using the wrong classloader when attempting to load these
plugin classes, but I thought those were resolved.

Kevin

On Sat, Jun 23, 2012 at 6:52 AM, Jim Talbut <jt...@spudsoft.co.uk> wrote:

> On 23/06/2012 10:17, Bengt Rodehav wrote:
>
>> What is your runtime platform? Also, does anyone know whether any progress
>> is made regarding class loading within OSGI? Many people prefer OpenJPA
>> over Eclipse and Hibernate because it works better in OSGi than those
>> projects. However, the OSGi support in OpenJPA is unfortunately very
>> fragile and really needs to be improved.
>>
> Bengt,
>
> I am using OSGi (Karaf), but my Auditor class is in the same bundle as my
> entities so I don't know if my success means that the problems are resolved.
>
> Jim
>

Re: OpenJPA Audit

Posted by Jim Talbut <jt...@spudsoft.co.uk>.
On 23/06/2012 10:17, Bengt Rodehav wrote:
> What is your runtime platform? Also, does anyone know whether any progress
> is made regarding class loading within OSGI? Many people prefer OpenJPA
> over Eclipse and Hibernate because it works better in OSGi than those
> projects. However, the OSGi support in OpenJPA is unfortunately very
> fragile and really needs to be improved.
Bengt,

I am using OSGi (Karaf), but my Auditor class is in the same bundle as 
my entities so I don't know if my success means that the problems are 
resolved.

Jim

Re: OpenJPA Audit

Posted by Bengt Rodehav <be...@rodehav.com>.
Hello there Jim,

I was part of initiating that support for OpenJPA (Pinaki implemented it)
but I haven't used it myself yet. The reason is that I couldn't get the
class loading to work when running within OSGi. There is still an
outstanding issue regarding this:

https://issues.apache.org/jira/browse/OPENJPA-2052

What is your runtime platform? Also, does anyone know whether any progress
is made regarding class loading within OSGI? Many people prefer OpenJPA
over Eclipse and Hibernate because it works better in OSGi than those
projects. However, the OSGi support in OpenJPA is unfortunately very
fragile and really needs to be improved.

For me, the lack of OSGi support is very frustrating. OSGi is a requirement
for me and I really would like to use the new auditing functionality.

/Bengt

/Bengt


2012/6/22 Jim Talbut <jt...@spudsoft.co.uk>

> Just want to say thanks.
>
> Some time ago I was involved in a discussion here about doing audit using
> lifecycle listeners.
> There are a whole bunch of problems with this approach and, although my
> implementation worked, it was not specified that it would work.
>
> Yesterday I needed to add an audit facility to a system and noticed the
> new @Auditable annotation (http://openjpa.apache.org/**
> builds/2.2.0/apache-openjpa/**docs/ref_guide_audit.html<http://openjpa.apache.org/builds/2.2.0/apache-openjpa/docs/ref_guide_audit.html>
> ).
> Wow.
> I spent some time worrying about how to write the data to the database -
> assuming I'd have to use JDBC and worrying about how to inject the data
> source.
> Then I noticed that the Broker passed lets me persist a new Entity during
> the audit.
>
> Thank you guys.
>
> Jim
>

Re: OpenJPA Audit

Posted by Bengt Rodehav <be...@rodehav.com>.
Hello Pinaki,

Do you know if there is any progress on the class loading refactoring you
initiated a while back?

/Bengt

2012/6/27 Pinaki Poddar <pp...@apache.org>

> Hi,
>  > Wow.
>  Good to know that you have found this audit facility useful.
>
>  I have added a test that shows an example of recording
> insert/update/delete of persistence instances in the same database. (See my
> latest commits)
>
>
> -----
> Pinaki Poddar
> Chair, Apache OpenJPA Project
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/OpenJPA-Audit-tp7580377p7580406.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Re: OpenJPA Audit

Posted by Pinaki Poddar <pp...@apache.org>.
Hi,
 > Wow. 
  Good to know that you have found this audit facility useful.

  I have added a test that shows an example of recording
insert/update/delete of persistence instances in the same database. (See my
latest commits)


-----
Pinaki Poddar
Chair, Apache OpenJPA Project
--
View this message in context: http://openjpa.208410.n2.nabble.com/OpenJPA-Audit-tp7580377p7580406.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.