Hi all, I'm new to Wicket and developing my first Wicket website.
I have some temporary objects created inside a users' session but needed by
a parallel process which uses them
outside the user session and I would like to avoid temporarily persisting
them into a database.

I'm looking at using application scope objects but I'm not sure how to do it
best
in Wicket.

I guess I should override the get() method of WebApplication
mimicking the pattern used for custom Session objects.

public class WicketApplication extends MyWebApplication
{
 private Object applicationScopeObject;

public WicketApplication() {
setApplicationScopeObject( <init value> );
}
 @Override
public static WicketApplication get() {
return (WicketApplication) WebApplication.get();
}
 public Object getApplicationScopeObject(){
return this.applicationScopeObject;
}
 public void setApplicationScopeObject( Object applicationScopeObject ){
this.applicationScopeObject = applicationScopeObject;
}
 [...]
}

public class PageInsideUserSession
{
public PageInsideUserSession(){
 [...]
// object has already been initialized
WicketApplication.get().setApplicationScopeObject( object );
}
}

public class PageOutsideUserSession
{
public PageOutsideUserSession(){
Object object = WicketApplication.get().getApplicationScopeObject();
[...]
}
}

In my case synchronizing the access to the application scope object should
not be needed.

Is this approach correct (and efficient) or is there a better solution ?
Should I maybe use a separate parent class (parent of WicketApplication and
child of WebApplication) for
overriding the get() method (in case the override interferes with something
else in the framework) ?

Cheers,

Marvan

-- 
Reza Marvan Spagnolo
SW Engineer - Freelancer

Reply via email to