bind to already persistence layer

9 views
Skip to first unread message

fawzyj

unread,
Feb 27, 2009, 2:44:03 AM2/27/09
to AribaWeb (aribaweb.org)
Hi all
i have an application that uses spring and a custom DAO layer with
custom transaction managment and cluster wide query caching ... etc ,
and i want to plug this intoaribaweb to use it instead of its default
persistence
i think (correct me) this is done by subclassing ObjectContext class,
but then how can i tell the application to use MyObjectContext instead
of the default? i took a look at the AWApplication and friends and
seems there is no place there to hook my implementation
any thoughts?
thanks
Joe

fawzyj

unread,
Feb 27, 2009, 3:30:44 AM2/27/09
to AribaWeb (aribaweb.org)
Hi
i suppose i will implement ObjectContext.Provider and set it using
ObjectContext.setProvider at the application startup
is it correct?
does it do the job?
is the ObjectContext a sigleton in the whole application?
does the metaUI depend on the JPA annotation to know about object->
object relationship so i have to put them even if i will persist using
other echnology?
thanks
joe

Craig Federighi

unread,
Feb 27, 2009, 9:38:48 AM2/27/09
to arib...@googlegroups.com
Hi Joe,

> i suppose i will implement ObjectContext.Provider and set it using
> ObjectContext.setProvider at the application startup
> is it correct?


You're right: that's how to get your own object context used instead
of the JPA(Hibernate)Object context.

> is the ObjectContext a sigleton in the whole application?


No. Each ObjectContext is a wrapper around a single JPA EntityManager
(Hibernate Session). Each user will have their own such context for
managing the state of their current object edits. The
ObjectContext.Provider will be called upon each time such a context is
needed.

> does the metaUI depend on the JPA annotation to know about object->
> object relationship so i have to put them even if i will persist using
> other echnology?


You can create equivalent annotation listeners (or other
Meta.ValueQueriedObservers) to register metaui rules for your classes
on-demand (by consulting whatever annotations of source of persistence
metadata that you have) -- there should be no need to use any foreign
annotations in your business objects.

- craig

fawzyj

unread,
Feb 27, 2009, 3:46:39 PM2/27/09
to AribaWeb (aribaweb.org)
Hi dear
thanks again for ur reply

On Feb 27, 4:38 pm, Craig Federighi <craig.federi...@gmail.com> wrote:
> Hi Joe,
>
> > i suppose i will implement ObjectContext.Provider and set it using
> > ObjectContext.setProvider at the application startup
> > is it correct?
>
> You're right: that's how to get your own object context used instead  
> of the JPA(Hibernate)Object context.
>

i assume i put this code in the awake methode of my AWApplication
subclass right?
does the framework pick my application subclass automatically or there
is some configuration to direct it ?

> > is the ObjectContext a sigleton in the whole application?
>
> No.  Each ObjectContext is a wrapper around a single JPA EntityManager  
> (Hibernate Session).  Each user will have their own such context for  
> managing the state of their current object edits.  The  
> ObjectContext.Provider will be called upon each time such a context is  
> needed.
>
> > does the metaUI depend on the JPA annotation to know about object->
> > object relationship so i have to put them even if i will persist using
> > other echnology?
>
> You can create equivalent annotation listeners (or other  
> Meta.ValueQueriedObservers) to register metaui rules for your classes  
> on-demand (by consulting whatever annotations of source of persistence  
> metadata that you have) -- there should be no need to use any foreign  
> annotations in your business objects.
>

Oh... slowly please....
let's divide it into simple questions
first : does the metaUI depend on the JPA annotation to know about
object->object relationship (yes or no)?
second : if so and if i use other technology(by providing my
ObjectContext) can i use these annotation to just make the framework
happy (this will b a temporary work around)
third: what r annotation listeners ? like what in the framework? class
name please...
and what is Meta.ValueQueriedObservers and how it is used? the api
docs says nothing and no pointers in the api docs to any implemention

thanks

Craig Federighi

unread,
Feb 27, 2009, 4:23:11 PM2/27/09
to arib...@googlegroups.com
Joe,

> i assume i put this code in the awake methode of my AWApplication
> subclass right?

That's one option. You'll want to make sure that your web app doesn't
include the metaui-jpa jar -- if it does that will try to assign its
provider instead of yours.

Since you'll probably build multiple apps with this support, you might
want to put it all in a separate JAR. If you look the source
directory for metaui-jpa you'll notice an "aribaweb.properties" file.
packaged-resource-extensions=awl,oss
depends-on=ariba.metaui
initializer=ariba.ui.meta.jpa.Initialization.initialize
use-namespace-from-package=ariba.ui.meta

This line "initializer" points at a static class method, "initialize",
in ariba.ui.meta.jpa.Initialization, that does the registration. This
happens because on startup AW scans for jars with aribaweb.properties
files and automatically calls their initializers (in dependency order).

> does the framework pick my application subclass automatically or there
> is some configuration to direct it ?


If it's in a package called "app" and is named "Application" we'll use
yours.

> Oh... slowly please....
> let's divide it into simple questions
> first : does the metaUI depend on the JPA annotation to know about
> object->object relationship (yes or no)?

NO.

> second : if so and if i use other technology(by providing my
> ObjectContext) can i use these annotation to just make the framework
> happy (this will b a temporary work around)

YES

> third: what r annotation listeners ? like what in the framework? class
> name please...

There's a lot behind the answer to your questions -- I'm not sure that
writing a design overview
on metaui on question at a time in an email thread is going to be
best. At this stage if you want to
write support for a whole other persistence layer you're ultimately
going to have to trace through the
code. I'm not sure that I'd want to make that my first project...

There are two types of "annotation listeners":

1) AWJarWalker.AnnotationListener
- Must be registered *early* (by the initializer in
aribaweb.properties)
- Called for all appearances of annotations on all classes appearing
in jars (that themselves have an aribaweb.properties file).
- Handler should do minimal work at this stage -- you don't want to
bog down app startup by eagerly doing processing on all of your domain
classes
- See use in ariba.ui.meta.jpa.Initialization for an example

2) ObjectMeta.AnnotationProcessor
- Called the first time an annotation is seen on a class that is
about to be used for the first time in MetaUI
- Code here can do more work, since this is only performed (lazily)
when classes are first *used*
- See use in ariba.ui.meta.jpa.Initialization for an example


> and what is Meta.ValueQueriedObservers and how it is used? the api
> docs says nothing and no pointers in the api docs to any implemention


Don't expect to find doc for these kind of internals any time soon
(i.e. load up the source in IDEA and start looking for usages).
You'll find examples like this (in ObjectMeta):

registerKeyInitObserver(KeyClass, new
IntrospectionMetaProvider());

This will cause IntrospectionMetaProvider() to have its method
void notify(Meta meta, String key, Object value)
called the first time and class name is used for the first time in a
rule. In this case, ObjectMeta uses this as a trigger to introspect
the class and register rules based on fields and actions it finds.
(This is also where it notices annotations and calls any registered
ObjectMeta.AnnotationProcessor handlers).

Again, I'd really say that unless you're really adventurous and really
willing to trace through a pretty intricate rule engine, you may want
to get a few simpler AribaWeb projects under your belt before
proceeding down this path.

Hope this helps...

- craig

fawzyj

unread,
Feb 27, 2009, 5:11:09 PM2/27/09
to AribaWeb (aribaweb.org)
Hi dear
thanks really for time and effort u spent to answer me


On Feb 27, 11:23 pm, Craig Federighi <craig.federi...@gmail.com>
wrote:
ok then the simplest solution is to include JPA annotation as a work
around to allow the metaUI to know more about the relationships even
if i will not use JPA for persistence.. RIGHT

then i have to include metaui-jpa.jar , which u recommended not to....
so?
so this seems to b a 2 phase annotation scanning strategy

> > and what is Meta.ValueQueriedObservers and how it is used? the api
> > docs says nothing and no pointers in the api docs to any implemention
>
> Don't expect to find doc for these kind of internals any time soon  
> (i.e. load up the source in IDEA and start looking for usages).  
> You'll find examples like this (in ObjectMeta):
>
>          registerKeyInitObserver(KeyClass, new  
> IntrospectionMetaProvider());
>
> This will cause IntrospectionMetaProvider() to have its method
>         void notify(Meta meta, String key, Object value)
> called the first time and class name is used for the first time in a  
> rule.  In this case, ObjectMeta uses this as a trigger to introspect  
> the class and register rules based on fields and actions it finds.  
> (This is also where it notices annotations and calls any registered  
> ObjectMeta.AnnotationProcessor handlers).
>
> Again, I'd really say that unless you're really adventurous and really  
> willing to trace through a pretty intricate rule engine, you may want  
> to get a few simpler AribaWeb projects under your belt before  
> proceeding down this path.
>
> Hope this helps...
>
> - craig

it seems really a bit complicated , i'll try to get something running
first by using the JPA annotation work around then may b look at this
upon optimization

thanks a lot Craig
joe

fawzyj

unread,
Feb 28, 2009, 12:50:38 AM2/28/09
to AribaWeb (aribaweb.org)
Hi again

On Feb 27, 11:23 pm, Craig Federighi <craig.federi...@gmail.com>
wrote:
> Joe,
>
> > i assume i put this code in the awake methode of my AWApplication
> > subclass right?
>
> That's one option.  You'll want to make sure that your web app doesn't  
> include the metaui-jpa jar -- if it does that will try to assign its  
> provider instead of yours.
>

what if i have to include the metaui-jpa.jar?
can i put my provider and ObjectContext in a separate jar and specify
in aribaweb.properties" file
initializer=com.myPersister.Initialization.initialize
depends-on=ariba.metaui-jpa
in order to make the framework pick my provider as it will b
initialized after the default jpa provider

> Since you'll probably build multiple apps with this support, you might  
> want to put it all in a separate JAR.  If you look the source  
> directory for metaui-jpa you'll notice an "aribaweb.properties" file.
>         packaged-resource-extensions=awl,oss
>         depends-on=ariba.metaui
>         initializer=ariba.ui.meta.jpa.Initialization.initialize
>         use-namespace-from-package=ariba.ui.meta
>
> This line "initializer" points at a static class method, "initialize",  
> in ariba.ui.meta.jpa.Initialization, that does the registration.  This  
> happens because on startup AW scans for jars with aribaweb.properties  
> files and automatically calls their initializers (in dependency order).
>
> > does the framework pick my application subclass automatically or there
> > is some configuration to direct it ?
>
> If it's in a package called "app" and is named "Application" we'll use  
> yours.
>

what if not?
what if it in package application with the name BussinessApplication?
what configuration option should i use to force the framework to pick
it?

Craig Federighi

unread,
Feb 28, 2009, 11:05:03 AM2/28/09
to arib...@googlegroups.com

> what if i have to include the metaui-jpa.jar?
> can i put my provider and ObjectContext in a separate jar and specify
> in aribaweb.properties" file
> initializer=com.myPersister.Initialization.initialize
> depends-on=ariba.metaui-jpa
> in order to make the framework pick my provider as it will b
> initialized after the default jpa provider

Yes.

> what if not?
> what if it in package application with the name BussinessApplication?
> what configuration option should i use to force the framework to pick
> it?
>


The name of the application is currently bootstrapped in via the
AWDispatcherServlet (which, in turn, is defined in via the generated
web.xml, which is, by default, generated by the Ant build, and refers
to the "servlet.class" Ant property).

So, one way to change it is to:
- Subclass AWDispatcherServlet and override applicationName() to
return "com.me.BusinessApplication"
- In your app build.xml, set
<property name="servlet.class"
value="com.me.MyDispatcherServlet"/>

Of course, if you end up using Spring or something to wire everything
up and handle initialization, you could define the Application class
there and just make sure that
AWConcreteApplication.createApplication(
com.me.BusinessApplication.class.getName(),
com.me.BusinessApplication.class)

is called before the default AWDispatcherServlet is initialized.
(I.e. first app class created wins).

- craig

Reply all
Reply to author
Forward
0 new messages