RE: RIAP Client from within my J2EE application (jboss)

2009-08-16 Thread Jerome Louvel
Hi Andew,

The pseudo RIAP protocol is supported internally by the Restlet engine and
doesn't require you to declare any client and server connector. That means
that in order to issue a RIAP call, you need to have a hold on your parent
Context instance.

In your case, it seems that Application.getCurrent() returns null because
the calling thread isn't the one that was initially processing the call, but
a Quartz worker thread instead. 

You would be stuck, but in Restlet 2.0 M4, we added RIAP client and server
connectors to support riap://component dispatching even when you have no
hold on the current context. This works using a RiapServerHelper singleton.

I suggest that you try again with Restlet 2.0 M4, looking at the attached
test case for guidance.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com




-Message d'origine-
De : Andrew Moore [mailto:rp.andrew.mo...@gmail.com] 
Envoyé : jeudi 30 juillet 2009 19:29
À : discuss@restlet.tigris.org
Objet : Re: RIAP Client from within my J2EE application (jboss)

I'm definitely still having issues... 

A little more background: we have a quartz job that calls a class which is
trying to make these requests. The Job class I created really has no context
for the my restlet application.  I'm not sure I'm creating my client
correctly... when I create it like this (which seems my only option since I
don't have access to a Context object):

Client riapClient = new Client(Protocol.RIAP);
riapClient.start();

I get a warning message:
WARNING: No available client connector supports the required protocols:
'RIAP' . Please add the JAR of a matching connector to your classpath.

I haven't seen a jar to add (and shouldn't this be part of the basic restlet
jar anyway?). When I try and start my client, a NullPointerException gets
thrown from somewhere inside the start() method. I'm assuming this is
probably due to not having a Context specified. But, I am having a hard time
trying to understand how I can get a Context object from my application. 

I haven't found any example code for instantiating and using an RIAP based
Client. I've seen (and used) RIAP requests from within a ServerResource to
another ServerResource, but not an RIAP request from a Client to the
ServerResource. 

I'm pretty sure I'm missing some sort of concept or using the Client in a
way it wasn't intended perhaps. 

Any help explaining what I'm missing or pointing me to some example code of
an RIAP Client that is sitting on the server-side would be greatly
appreciated! 

Regards,

Andrew
-- 
View this message in context:
http://n2.nabble.com/RIAP-Client-from-within-my-J2EE-application-%28jboss%29
-tp3353312p3357728.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=23770
64

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2384073

RiapConnectorsTestCase.java
Description: Binary data


Re: RIAP Client from within my J2EE application (jboss)

2009-08-16 Thread Tim Peierls
On Sun, Aug 16, 2009 at 11:32 AM, Jerome Louvel
jerome.lou...@noelios.comwrote:

 In your case, it seems that Application.getCurrent() returns null because
 the calling thread isn't the one that was initially processing the call,
 but
 a Quartz worker thread instead.


I don't know enough about Quartz to give details, but after a quick scan at
the Quartz javadocs, I bet that a technique similar to that used in
Restlet's TaskService class could be used to wrap a Quartz Scheduler to make
sure that all Jobs execute with a current Application.

--tim

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2384083

Re: RIAP Client from within my J2EE application (jboss)

2009-07-30 Thread Andrew Moore
Thanks, I'll give that a shot and let you know if it works or what I'm still
stuck on.

Regards,

Andrew
-- 
View this message in context: 
http://n2.nabble.com/RIAP-Client-from-within-my-J2EE-application-%28jboss%29-tp3353312p3356788.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2376983


Re: RIAP Client from within my J2EE application (jboss)

2009-07-30 Thread Andrew Moore
I'm definitely still having issues... 

A little more background: we have a quartz job that calls a class which is
trying to make these requests. The Job class I created really has no context
for the my restlet application.  I'm not sure I'm creating my client
correctly... when I create it like this (which seems my only option since I
don't have access to a Context object):

Client riapClient = new Client(Protocol.RIAP);
riapClient.start();

I get a warning message:
WARNING: No available client connector supports the required protocols:
'RIAP' . Please add the JAR of a matching connector to your classpath.

I haven't seen a jar to add (and shouldn't this be part of the basic restlet
jar anyway?). When I try and start my client, a NullPointerException gets
thrown from somewhere inside the start() method. I'm assuming this is
probably due to not having a Context specified. But, I am having a hard time
trying to understand how I can get a Context object from my application. 

I haven't found any example code for instantiating and using an RIAP based
Client. I've seen (and used) RIAP requests from within a ServerResource to
another ServerResource, but not an RIAP request from a Client to the
ServerResource. 

I'm pretty sure I'm missing some sort of concept or using the Client in a
way it wasn't intended perhaps. 

Any help explaining what I'm missing or pointing me to some example code of
an RIAP Client that is sitting on the server-side would be greatly
appreciated! 

Regards,

Andrew
-- 
View this message in context: 
http://n2.nabble.com/RIAP-Client-from-within-my-J2EE-application-%28jboss%29-tp3353312p3357728.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2377064


RIAP Client from within my J2EE application (jboss)

2009-07-29 Thread Andrew Moore
Hi, 

We're running a J2EE app on JBOSS, but we've started integrating Restlet so
that hopefully we can ditch our legacy app and move on with RESTful
services.

The short story is hopefully some other folks will be able to use our new
Restlet service to get the resources they need, but if they can't (due to a
deadline crunch) then we need to do the leg work for them: request from our
own service and give them the returned resource through a legacy mechanism
they know already works. 

I'm wanting to write a server-side client (oxymoron?) that uses RIAP so I
can bypass the HTTP overhead and keep request internal. I'd also like to do
it without having to specify any configuration information related to the
host we've installed our application on. I figured my best shot was to write
a client on the server-side (within our application on the same jvm) using
the RIAP protocol. I know I have my restlet application routing internal
RIAP requests correctly as I previously dabbled with some server resources
that called each other... 

I feel like I've tried a number of things... but I think my general problem
is I don't seem to have access to Context of my restlet Application. 

I thought at one point I could call the static method getCurrent() on my
Application (i.e. MyRestletApplication.getCurrent()) and then make my riap
request through there:

MyRestletApplication.getCurrent().getContext().getClientDispatcher().get(riap://component/path-to-my-resource)

That didn't seem to work... the MyRestletApplication.getCurrent() only
returns null. Is that something I need to set in the
MyRestletApplication.createRoot() method? 

I also tried just creating a Client with the RIAP protocol:

Client myclient = new Client(Protocol.RIAP);

...but that doesn't seem to work as I don't have a Context for
MyRestletApplication. 

I appreciate any help, direction and insight as to how I can accomplish
this.

Thanks in advance!

Regards,

Andrew




-- 
View this message in context: 
http://n2.nabble.com/RIAP-Client-from-within-my-J2EE-application-%28jboss%29-tp3353312p3353312.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2376769


Re: RIAP Client from within my J2EE application (jboss)

2009-07-29 Thread Rob Heittman
Can you try riap://host instead of riap://component and see if that works
for you?  This is kind of cargo cult advice but we have mainly changed to
that, and it works.  Untested hypothesis: component/application context
visibility issues (added for security reasons around 1.2M2 IIRC) prevent you
from using riap://component from an Application context.

On Wed, Jul 29, 2009 at 7:44 PM, Andrew Moore rp.andrew.mo...@gmail.comwrote:

 I thought at one point I could call the static method getCurrent() on my
 Application (i.e. MyRestletApplication.getCurrent()) and then make my riap
 request through there:


 MyRestletApplication.getCurrent().getContext().getClientDispatcher().get(riap://component/path-to-my-resource)



--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2376774