You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Benson Margulies <bi...@gmail.com> on 2008/03/20 19:07:51 UTC

Re: REST->JS

Arul,

CXF has a 'front end' that allows you to run Javascript on the server in
Rhino. I believe that this should work fine for REST, but I'm not the REST
expert.

Java2js generates Client javascript. It does not generate REST clients, only
SOAP clients.

Does that clarify?

-benson


On Thu, Mar 20, 2008 at 1:29 PM, Arul Dhesiaseelan <ar...@fluxcorp.com>
wrote:

> Hi,
>
> Currently CXF supports Java2JS for simple or JAX-WS front ends. Does CXF
> support JAX-RS front end (REST->JavaScript) too?
>
> Thanks!
> Arul
>
>

Re: REST->JS

Posted by Arul Dhesiaseelan <ar...@fluxcorp.com>.
I was exactly looking for something like this on the rest endpoint. I am 
using JAXRSServerFactoryBean for deploying the rest endpoint.

Thanks!
Arul

Benson Margulies wrote:
> Sergey,
>
> I implemented ?js, but it generates Soap clients, not REST clients. have a
> look at rt/javascript.
>
> --benson
>
>
> On Fri, Mar 21, 2008 at 6:44 AM, Sergey Beryozkin <se...@iona.com>
> wrote:
>
>   
>> Hi Arul, Benson
>>
>> yes, that would be a rather simple thing to do, and in fact you'd likely
>> get this JS code (or indeed code in your language of choice) generated for
>> live services, as we've introduced SystemQueryHandlers (not sure it's a good
>> name though) which are supposed to handle different types of query
>> extensions and possibly let the invocation to proceed to the actual object
>> afterwards. For example, at the moment, one can debug a live service and
>> check on what format it can produce, for example, if it's an Atom-enbaled
>> service then you can try ?_contentType=json. In this case the only thing the
>> handler does is to update the Accept headers on the message.
>>
>> Likewise, one should be able to do ?_js or ?_lang=js.
>>
>> That said, supporting extensions like _js has not been prioritized. That
>> would be a cool thing to do so if someone in the community is interested
>> then the input would be welcomed.
>>
>> Cheers, Sergey
>>
>>
>>     
>>> There is no existing code to do this, if I follow your definition of a
>>> 'resource object'. It would be only a few days of work to add to the
>>> existing Javascript generator to add this, I bet. If you post an example
>>>       
>> of
>>     
>>> what you'd like to see generated that might clarify. I for one wouldn't
>>>       
>> be
>>     
>>> in a position to tackle the job if I've understood it correctly.
>>>
>>>
>>>       
>>>> Here is my scenario. I have a JAX-RS CXF service. I have a web
>>>> application which consumes this service. Is it possible to generate the
>>>> REST resources as JavaScript so that the web app can use it directly
>>>> when doing a POST (ex: construct the resource object)?
>>>>
>>>>
>>>>
>>>>         
>> ----------------------------
>> IONA Technologies PLC (registered in Ireland)
>> Registered Number: 171387
>> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>>
>>     
>
>
> ______________________________________________________________________
> Scanned by MessageLabs
> ______________________________________________________________________
>   


-- 
Arul Dhesiaseelan, Flux Development

+1 (406) 656-7398
www.fluxcorp.com

Flux - Java Job Scheduler. File Transfer. Workflow. BPM. 



Re: REST->JS

Posted by Benson Margulies <bi...@gmail.com>.
Oh, I see, I was completely confused. I didn't appreciate that you were
talking about ? handling in the JAX-RS code. Still, you might find some code
you like in rt/javascript if/when you look at this ?js for REST.


On Fri, Mar 21, 2008 at 1:27 PM, Sergey Beryozkin <se...@iona.com>
wrote:

> Hi Benson
>
> For current CXF JAX-RS impl, the idea is to treat queries starting from
> '_' as system ones, intended for the JAX-RS runtime, such
> that such queries can be distinguished from application-specific ones.
> We've added SystemQueryHandlers which are invoked before the
> actual target object, so one of such handlers can be created to handle
> '_js' extension to avoid a clash with ?js support in
> runtime/js...
>
> Cheers, Sergey
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>

Re: REST->JS

Posted by Sergey Beryozkin <se...@iona.com>.
Hi Jervis

I'm sorry for replying so late...
The idea behind ?_js or ?_lang=js is not to indicate to the runtime that the invocation is coming from a JS client stack but to
provide on the fly generation of the client execution code (JS in this case), similar to what Benson did for JAX-WS services. Such execution fragment can then be embedded into XHTML pages, etc. 
Perhaps a better option would be to support .js extensions, something like
GET /customer.js

Either way, CXF JAX-RS impl supports handlers which can be invoked before the invocation is made on the actual resource class. These handlers need some minor cleanup, but as far as the generation of such JS client code is concerned, it would be a matter implementing a handler capable of looking at a ClassResourceInfo (the model class you created originally) and returning a JAX-RS Response with its entity being the generated (JS) code...

Cheers, Sergey


----- Original Message ----- 
From: "Jervis Liu" <je...@gmail.com>
To: <cx...@incubator.apache.org>
Sent: Monday, March 24, 2008 3:14 AM
Subject: Re: REST->JS


> Hi Sergey, could you elaborate a bit more on the ?_js or ?_lang=js stuff
> please. I thought what Benson and Arul were talking about is a pure client
> stack that is implemented in Java script that can connect to JAX-RS
> compatible RESTful services. As far as the JAX-RS  server side is concerned,
> it does not matter the request is coming from a java script client or
> anything else, does it?
> 
> 

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Re: REST->JS

Posted by Jervis Liu <je...@gmail.com>.
Hi Sergey, could you elaborate a bit more on the ?_js or ?_lang=js stuff
please. I thought what Benson and Arul were talking about is a pure client
stack that is implemented in Java script that can connect to JAX-RS
compatible RESTful services. As far as the JAX-RS  server side is concerned,
it does not matter the request is coming from a java script client or
anything else, does it?


Cheers,
Jervis

On Sat, Mar 22, 2008 at 1:27 AM, Sergey Beryozkin <se...@iona.com>
wrote:

> Hi Benson
>
> For current CXF JAX-RS impl, the idea is to treat queries starting from
> '_' as system ones, intended for the JAX-RS runtime, such
> that such queries can be distinguished from application-specific ones.
> We've added SystemQueryHandlers which are invoked before the
> actual target object, so one of such handlers can be created to handle
> '_js' extension to avoid a clash with ?js support in
> runtime/js...
>
> Cheers, Sergey
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>

Re: REST->JS

Posted by Sergey Beryozkin <se...@iona.com>.
Hi Benson

For current CXF JAX-RS impl, the idea is to treat queries starting from '_' as system ones, intended for the JAX-RS runtime, such 
that such queries can be distinguished from application-specific ones. We've added SystemQueryHandlers which are invoked before the 
actual target object, so one of such handlers can be created to handle '_js' extension to avoid a clash with ?js support in 
runtime/js...

Cheers, Sergey 

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Re: REST->JS

Posted by Benson Margulies <bi...@gmail.com>.
Sergey,

I implemented ?js, but it generates Soap clients, not REST clients. have a
look at rt/javascript.

--benson


On Fri, Mar 21, 2008 at 6:44 AM, Sergey Beryozkin <se...@iona.com>
wrote:

> Hi Arul, Benson
>
> yes, that would be a rather simple thing to do, and in fact you'd likely
> get this JS code (or indeed code in your language of choice) generated for
> live services, as we've introduced SystemQueryHandlers (not sure it's a good
> name though) which are supposed to handle different types of query
> extensions and possibly let the invocation to proceed to the actual object
> afterwards. For example, at the moment, one can debug a live service and
> check on what format it can produce, for example, if it's an Atom-enbaled
> service then you can try ?_contentType=json. In this case the only thing the
> handler does is to update the Accept headers on the message.
>
> Likewise, one should be able to do ?_js or ?_lang=js.
>
> That said, supporting extensions like _js has not been prioritized. That
> would be a cool thing to do so if someone in the community is interested
> then the input would be welcomed.
>
> Cheers, Sergey
>
>
> > There is no existing code to do this, if I follow your definition of a
> > 'resource object'. It would be only a few days of work to add to the
> > existing Javascript generator to add this, I bet. If you post an example
> of
> > what you'd like to see generated that might clarify. I for one wouldn't
> be
> > in a position to tackle the job if I've understood it correctly.
> >
> >
> >>
> >> Here is my scenario. I have a JAX-RS CXF service. I have a web
> >> application which consumes this service. Is it possible to generate the
> >> REST resources as JavaScript so that the web app can use it directly
> >> when doing a POST (ex: construct the resource object)?
> >>
> >>
> >>
> >
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>

Re: REST->JS

Posted by Sergey Beryozkin <se...@iona.com>.
Hi Arul, Benson

yes, that would be a rather simple thing to do, and in fact you'd likely get this JS code (or indeed code in your language of choice) generated for live services, as we've introduced SystemQueryHandlers (not sure it's a good name though) which are supposed to handle different types of query extensions and possibly let the invocation to proceed to the actual object afterwards. For example, at the moment, one can debug a live service and check on what format it can produce, for example, if it's an Atom-enbaled service then you can try ?_contentType=json. In this case the only thing the handler does is to update the Accept headers on the message.

Likewise, one should be able to do ?_js or ?_lang=js.

That said, supporting extensions like _js has not been prioritized. That would be a cool thing to do so if someone in the community is interested then the input would be welcomed.

Cheers, Sergey


> There is no existing code to do this, if I follow your definition of a
> 'resource object'. It would be only a few days of work to add to the
> existing Javascript generator to add this, I bet. If you post an example of
> what you'd like to see generated that might clarify. I for one wouldn't be
> in a position to tackle the job if I've understood it correctly.
> 
> 
>>
>> Here is my scenario. I have a JAX-RS CXF service. I have a web
>> application which consumes this service. Is it possible to generate the
>> REST resources as JavaScript so that the web app can use it directly
>> when doing a POST (ex: construct the resource object)?
>>
>>
>>
>

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Re: REST->JS

Posted by Benson Margulies <bi...@gmail.com>.
There is no existing code to do this, if I follow your definition of a
'resource object'. It would be only a few days of work to add to the
existing Javascript generator to add this, I bet. If you post an example of
what you'd like to see generated that might clarify. I for one wouldn't be
in a position to tackle the job if I've understood it correctly.


>
> Here is my scenario. I have a JAX-RS CXF service. I have a web
> application which consumes this service. Is it possible to generate the
> REST resources as JavaScript so that the web app can use it directly
> when doing a POST (ex: construct the resource object)?
>
>
>

Re: REST->JS

Posted by Arul Dhesiaseelan <ar...@fluxcorp.com>.
Benson Margulies wrote:
> Arul,
>
> CXF has a 'front end' that allows you to run Javascript on the server in
> Rhino. I believe that this should work fine for REST, but I'm not the REST
> expert.
>
> Java2js generates Client javascript. It does not generate REST clients, only
> SOAP clients.
>
> Does that clarify?
>
> -benson
>
>
> On Thu, Mar 20, 2008 at 1:29 PM, Arul Dhesiaseelan <ar...@fluxcorp.com>
> wrote:
>
>   
>> Hi,
>>
>> Currently CXF supports Java2JS for simple or JAX-WS front ends. Does CXF
>> support JAX-RS front end (REST->JavaScript) too?
>>
>> Thanks!
>> Arul
>>
>>
>>     
>
>
> ______________________________________________________________________
> MessageLabs scanned this email.
> ______________________________________________________________________
>   
Thanks for the response.

Here is my scenario. I have a JAX-RS CXF service. I have a web 
application which consumes this service. Is it possible to generate the 
REST resources as JavaScript so that the web app can use it directly 
when doing a POST (ex: construct the resource object)?