You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Wechsung, Wulf" <wu...@sap.com> on 2013/11/18 13:40:35 UTC

Interface "Request"

Hi everyone,

I want to build a service that works transparently for web request threads and system threads. If called in a web request it should utilize session storage via ASM and if called from a background thread it should just return the value of a ThreadLocal<?>.

What I can't find out is: is there a simple way to find out if a Request object exists for the thread (and therefore ASM.get() will work) or not (and therefore cause ASM methods to throw NPEs)?

Thanks in advance and kind regards,
Wulf Wechsung







Re: Interface "Request"

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 18 Nov 2013 11:39:22 -0200, Wechsung, Wulf <wu...@sap.com>  
wrote:

> Hi,

Hi!

> judging from the stack trace I think RequestGlobals actually returns a  
> non-null proxy that NPEs because it's delegate is actually null.

I don't think that's correct. You'll get an NPE if you inject Request  
directly. RequestGlobals doesn't return proxies, even because the Request  
service is based on RequestGlobals.getRequest().

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Interface "Request"

Posted by Dmitry Gusev <dm...@gmail.com>.
RequestGlobals will return the same as you store into it using
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/RequestGlobals.html#storeRequestResponse(org.apache.tapestry5.services.Request,
org.apache.tapestry5.services.Response)

As far as I can see this method is only invoked from request handlers
pipeline, which shouldn't happen for background threads, so you should get
null there.

Can you post your stacktrace?


On Mon, Nov 18, 2013 at 5:39 PM, Wechsung, Wulf <wu...@sap.com>wrote:

> Hi,
>
> judging from the stack trace I think RequestGlobals actually returns a
> non-null proxy that NPEs because it's delegate is actually null.
>
> Kind Regards,
> Wulf
> -----Original Message-----
> From: Dmitry Gusev [mailto:dmitry.gusev@gmail.com]
> Sent: Montag, 18. November 2013 13:45
> To: Tapestry users
> Subject: Re: Interface "Request"
>
> Hi,
>
> RequestGlobals.getRequest() should return null I think:
>
>
> http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/RequestGlobals.html#getRequest()
>
>
> On Mon, Nov 18, 2013 at 4:40 PM, Wechsung, Wulf <wulf.wechsung@sap.com
> >wrote:
>
> > Hi everyone,
> >
> > I want to build a service that works transparently for web request
> threads
> > and system threads. If called in a web request it should utilize session
> > storage via ASM and if called from a background thread it should just
> > return the value of a ThreadLocal<?>.
> >
> > What I can't find out is: is there a simple way to find out if a Request
> > object exists for the thread (and therefore ASM.get() will work) or not
> > (and therefore cause ASM methods to throw NPEs)?
> >
> > Thanks in advance and kind regards,
> > Wulf Wechsung
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> Dmitry Gusev
>
> AnjLab Team
> http://anjlab.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com

RE: Interface "Request"

Posted by "Wechsung, Wulf" <wu...@sap.com>.
Hi,

judging from the stack trace I think RequestGlobals actually returns a non-null proxy that NPEs because it's delegate is actually null.

Kind Regards,
Wulf
-----Original Message-----
From: Dmitry Gusev [mailto:dmitry.gusev@gmail.com] 
Sent: Montag, 18. November 2013 13:45
To: Tapestry users
Subject: Re: Interface "Request"

Hi,

RequestGlobals.getRequest() should return null I think:

http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/RequestGlobals.html#getRequest()


On Mon, Nov 18, 2013 at 4:40 PM, Wechsung, Wulf <wu...@sap.com>wrote:

> Hi everyone,
>
> I want to build a service that works transparently for web request threads
> and system threads. If called in a web request it should utilize session
> storage via ASM and if called from a background thread it should just
> return the value of a ThreadLocal<?>.
>
> What I can't find out is: is there a simple way to find out if a Request
> object exists for the thread (and therefore ASM.get() will work) or not
> (and therefore cause ASM methods to throw NPEs)?
>
> Thanks in advance and kind regards,
> Wulf Wechsung
>
>
>
>
>
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Interface "Request"

Posted by Dmitry Gusev <dm...@gmail.com>.
Hi,

RequestGlobals.getRequest() should return null I think:

http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/RequestGlobals.html#getRequest()


On Mon, Nov 18, 2013 at 4:40 PM, Wechsung, Wulf <wu...@sap.com>wrote:

> Hi everyone,
>
> I want to build a service that works transparently for web request threads
> and system threads. If called in a web request it should utilize session
> storage via ASM and if called from a background thread it should just
> return the value of a ThreadLocal<?>.
>
> What I can't find out is: is there a simple way to find out if a Request
> object exists for the thread (and therefore ASM.get() will work) or not
> (and therefore cause ASM methods to throw NPEs)?
>
> Thanks in advance and kind regards,
> Wulf Wechsung
>
>
>
>
>
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com