Here is the java class for the asoSevice mentioned in
my how-to.
Shing
ASOService.java :
public class ASOService implements IEngineService {
@SuppressWarnings("unused")
private static Logger log =
Logger.getLogger(ASOService.class);
public static final String SERVICE_NAME =
"asoService";
private ApplicationStateManager appStateManager;
/** @since 4.0 */
private RequestExceptionReporter exceptionReporter;
/** @since 4.0 */
private LinkFactory linkFactory;
/** @since 4.0 */
private WebResponse response;
@SuppressWarnings("unchecked")
public ILink getLink(boolean post, Object parameter)
{
Map parameters = new HashMap();
return getLinkFactory().constructLink(this, false,
parameters, true);
}
public LinkFactory getLinkFactory() {
return linkFactory;
}
public void setLinkFactory(LinkFactory linkFactory) {
this.linkFactory = linkFactory;
}
public String getName() {
return SERVICE_NAME;
}
public void service(IRequestCycle cycle) throws
IOException {
WebResponse response = getResponse();
response.setHeader("Pragma", "no-cache");
response.setHeader("cache-control", "no-cache");
response.setDateHeader("Expires", 0);
OutputStream output = response.getOutputStream(new
ContentType(
"text/plain"));
HelloMessageHolder message = (HelloMessageHolder)
getAppStateManager().get("message");
String str = message.getMessage();
output.write(str.getBytes());
output.close();
}
public WebResponse getResponse() {
return response;
}
public void setResponse(WebResponse response) {
this.response = response;
}
public RequestExceptionReporter
getExceptionReporter() {
return exceptionReporter;
}
public void
setExceptionReporter(RequestExceptionReporter
exceptionReporter) {
this.exceptionReporter = exceptionReporter;
}
public ApplicationStateManager getAppStateManager() {
return appStateManager;
}
public void
setAppStateManager(ApplicationStateManager
appStateManager) {
this.appStateManager = appStateManager;
}
}
--- Joseph Hannon <[EMAIL PROTECTED]> wrote:
> Shing,
>
> Cool. I did replace <set-object with the
> <set-service and got the same
> exception. If you will notice in my original post,
> this was commented
> out, I uncommented it and commented the line with
> <set-object .
>
> Would you mind showing some code where you are
> getting your asoService
> class from a pojo? I would like to see how you are
> making the call that
> gets the service. I suspect getting my registry
> from my servlet is not
> the way to go.
>
> Thanks,
> Joseph
>
> Shing Hing Man wrote:
> >> How are you calling getAppStateManager(), from
> what
> >> class? How are you
> >> getting access to the registry from a POJO?
> >
> >
> > In my how-to, appStateManager is injected to
> > the tapestry service asoSerivce by hivemind.
> >
> >
> > The following piece of code is meant to be in the
> > .java
> > class of my asoService.
> >
> > HelloMessage message = (HelloMessage)
> > getAppStateManager().get("message");
> >
> >
> > Also, in the .java of my asoService, there is
> > getter/setter method for the property
> > appStateManager.
> >
> >
> > I have noticed that in your
> > service-point id="InjectStateWorker", you have
> > <set-object property="applicationStateManager"
> > value="infrastructure:applicationStateManager"/>
> >
> > try replacing it by
> > <set-service property="applicationStateManager"
> >
> >
>
service-id="tapestry.state.ApplicationStateManager"/>
> >
> > Shing
> >
> >
> >
> >
> > --- Joseph Hannon <[EMAIL PROTECTED]> wrote:
> >
> >> Shing,
> >>
> >> I did change the 'Visit' id to something else,
> >> 'message', as a test and
> >> still get the exception of webRequest being null.
> >>
> >> From your website: HelloMessage message =
> >> (HelloMessage)
> >> getAppStateManager().get("message");
> >> How are you calling getAppStateManager(), from
> what
> >> class? How are you
> >> getting access to the registry from a POJO?
> >>
> >> Thanks,
> >> Joseph
> >>
> >> Shing Hing Man wrote:
> >>> Sorry ! Here is the correct link.
> >>>
> >>> http://lombok.demon.co.uk/tapestry4Demo/app
> >>>
> >>>
> >>> Shing
> >>> --- Shing Hing Man <[EMAIL PROTECTED]> wrote:
> >>>
> >>>> I have noticed that in the retrieveVisit method
> >> of
> >>>> InjectStateWorker.java :
> >>>> visit = (Visit)
> >>>> _applicationStateManager.get("visit")
> >>>> ;
> >>>>
> >>>>
> >>>> But in the hivemodule.xml, the state object
> name
> >> is
> >>>> 'Visit' with a captial V.
> >>>>
> >>>> You might like to rename 'visit' to something
> >> else.
> >>>> I do not know whether it would conflict with
> the
> >>>> default visit object (the one that could be
> >>>> specified
> >>>> in
> >>>> .application.)
> >>>>
> >>>>
> >>>> I have written up an example on injecting an
> aso
> >>>> into
> >>>> a service and put it on
> >>>> http://lombok.demon.co.uk/tapestry4Demo
> >>>>
> >>>> If you like, you can take a look and see if it
> >>>> helps.
> >>>>
> >>>>
> >>>> Shing
> >>>>
> >>>>
> >>>> --- Finster Hannon <[EMAIL PROTECTED]>
> wrote:
> >>>>
> >>>>> I would like to get access to my ASO 'Visit'
> >> from
> >>>> a
> >>>>> servlet filter let's
> >>>>> say. I have used a piece I saw Howard post
> >> where
> >>>> I
> >>>>> am subclassing the
> >>>>> ApplicationServlet which will provide access
> to
> >>>> the
> >>>>> HiveMind (HM)
> >>>>> registry. I would think then calling from
> >>>> anywhere
> >>>>> in the app to the
> >>>>> servlet would give me the HM registry. Once I
> >>>> have
> >>>>> the registry, I
> >>>>> would think I can access it's services. I saw
> >> an
> >>>>> example of injecting
> >>>>> an ASO into a POJO using a service and
> >> implemented
> >>>>> that below. It is
> >>>>> not really the ASO getting injected, rather it
> >> is
> >>>>> the
> >>>>> ApplicationStateManager (ASM) getting
> injected.
> >> I
> >>>>> am getting the
> >>>>> service, getting the ASM, but when attempting
> to
> >>>> get
> >>>>> 'Visit' from the
> >>>>> ASM, an exception is thrown visible in the
> >> logging
> >>>>> below. I then moved
> >>>>> my call to a page class to see if that would
> >>>> change
> >>>>> things and it did
> >>>>> not. Debugging my servlet shows the registry
> >>>>> obtained has many services
> >>>>> including mine.
> >>>>>
> >>>>> I have seen many references to 'HiveUtils
> >>>>> ObjectBuilder' and would like
> >>>>> to get this working before attempting use of
> >> that.
> >>>>> Also saw in this
> >>>>> list: 'how to inject visit object into pojo',
> >>>> 'how
> >>>>> to inject aso in
> >>>>> service', 'injecting an aso into a hivemind
> >>>>> service', and 'injecting
> >>>>> an aso into a service' which all relate to
> this
> >>>>> post.
> >>>>>
> >>>>> Can I get the HM registry from my servlet and
> is
> >>>> it
> >>>>> valid? Is there
> >>>>> another way to get the registry? Suggestions
> on
> >>>>> getting the ASO 'Visit'
> >>>>> from a POJO? Is my code invalid?
> >>>>>
> >>>>> Thanks,
> >>>>> Joseph
> >>>>>
> >>>>> The call:
> >>>>> IInjectEnhancementWorker stateWorker =
> >>>>> (IInjectEnhancementWorker)
>
=== message truncated ===
Home page :
http://uk.geocities.com/matmsh/index.html
___________________________________________________________
Try the all-new Yahoo! Mail. "The New Version is radically easier to use" The
Wall Street Journal
http://uk.docs.yahoo.com/nowyoucan.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]