You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Juan Moreno <jw...@gmail.com> on 2012/07/17 22:22:21 UTC

Javascript Client Architecture

My Project is using Thrift and I am trying to understand the Javascript
Client Architecture.
My Question is basically this:
1. You define a .thrift file with your structures.
2. You Compile this file into Java(The Server/Service end) and
Javascript(The Client end)
3. In Java Thrift Generates a Class for each struct and service. What about
in Javascript? Is this also the same?

Can this Generated Javascript talk directly to the Java Server--that is,
can it open a TSocket or start a Transport--or must there always
be a REST Service proxy-ing between the two?

Thanks!

-- 
Juan Wellington Moreno
*Software Engineer*

Re: Javascript Client Architecture

Posted by Juan Moreno <jw...@gmail.com>.
Never mind. I simply wasn't approaching the problem right. Basically what
you want to do is subclass the TServlet and pass whatever arguments you
want via super. The documentation for TServlet should mention this. Since
it isn't am abstract class this isn't inferable.
On Aug 22, 2012 1:24 PM, "Juan Moreno" <jw...@gmail.com> wrote:

> Hey there,
> I have looked into this some more, and I now understand what you meant.
> I took a look around TServlet and thrift.js ;
> I am thinking to deploy the TServlet into TomCat or JBoss.
> However, I am not sure as to how this would work. From my understanding,
> TomCat instantiates the Servlet itself reflectively;
>
> how can you tell the TServlet what Processor to process and what Protocols
> to use?
> The TServlet has Constructor arguments. How do we pass parameters to it?
>
> http://people.apache.org/~jfarrell/thrift/0.7.0/javadoc/org/apache/thrift/server/TServlet.html
>
>
> Thank You!
>
> On Tue, Jul 17, 2012 at 4:32 PM, Jake Luciani <ja...@gmail.com> wrote:
>
>> Yes you generate a JS client,  It communicates via the JSONProtocol so you
>> must use that Protocol on the serverside.
>>
>> Also you need to use the TServlet java Server to access it from a web
>> browser.
>>
>> On Tue, Jul 17, 2012 at 4:22 PM, Juan Moreno
>> <jw...@gmail.com>wrote:
>>
>> > My Project is using Thrift and I am trying to understand the Javascript
>> > Client Architecture.
>> > My Question is basically this:
>> > 1. You define a .thrift file with your structures.
>> > 2. You Compile this file into Java(The Server/Service end) and
>> > Javascript(The Client end)
>> > 3. In Java Thrift Generates a Class for each struct and service. What
>> about
>> > in Javascript? Is this also the same?
>> >
>> > Can this Generated Javascript talk directly to the Java Server--that is,
>> > can it open a TSocket or start a Transport--or must there always
>> > be a REST Service proxy-ing between the two?
>> >
>> > Thanks!
>> >
>> > --
>> > Juan Wellington Moreno
>> > *Software Engineer*
>> >
>>
>>
>>
>> --
>> http://twitter.com/tjake
>>
>
>
>
> --
> Juan Wellington Moreno
> *Software Engineer*
> Potomac Fusion
> 7230 Lee Deforester Drive, Suite 100
> Columbia, MD 21046
> Work: (410) 794-9040 ext 317
> Work Direct: (410) 794-9017
> Main: (347) 541-9256
>
>

Re: Javascript Client Architecture

Posted by Juan Moreno <jw...@gmail.com>.
Hey there,
I have looked into this some more, and I now understand what you meant.
I took a look around TServlet and thrift.js ;
I am thinking to deploy the TServlet into TomCat or JBoss.
However, I am not sure as to how this would work. From my understanding,
TomCat instantiates the Servlet itself reflectively;

how can you tell the TServlet what Processor to process and what Protocols
to use?
The TServlet has Constructor arguments. How do we pass parameters to it?
http://people.apache.org/~jfarrell/thrift/0.7.0/javadoc/org/apache/thrift/server/TServlet.html


Thank You!

On Tue, Jul 17, 2012 at 4:32 PM, Jake Luciani <ja...@gmail.com> wrote:

> Yes you generate a JS client,  It communicates via the JSONProtocol so you
> must use that Protocol on the serverside.
>
> Also you need to use the TServlet java Server to access it from a web
> browser.
>
> On Tue, Jul 17, 2012 at 4:22 PM, Juan Moreno
> <jw...@gmail.com>wrote:
>
> > My Project is using Thrift and I am trying to understand the Javascript
> > Client Architecture.
> > My Question is basically this:
> > 1. You define a .thrift file with your structures.
> > 2. You Compile this file into Java(The Server/Service end) and
> > Javascript(The Client end)
> > 3. In Java Thrift Generates a Class for each struct and service. What
> about
> > in Javascript? Is this also the same?
> >
> > Can this Generated Javascript talk directly to the Java Server--that is,
> > can it open a TSocket or start a Transport--or must there always
> > be a REST Service proxy-ing between the two?
> >
> > Thanks!
> >
> > --
> > Juan Wellington Moreno
> > *Software Engineer*
> >
>
>
>
> --
> http://twitter.com/tjake
>



-- 
Juan Wellington Moreno
*Software Engineer*
Potomac Fusion
7230 Lee Deforester Drive, Suite 100
Columbia, MD 21046
Work: (410) 794-9040 ext 317
Work Direct: (410) 794-9017
Main: (347) 541-9256

Re: Javascript Client Architecture

Posted by Juan Moreno <jw...@gmail.com>.
Yes Web sockets are a cool idea, but currently there isn't much browser
support. We'll keep this in mind :-)
On Jul 18, 2012 3:57 PM, "Henrique Mendonça" <hm...@gmail.com> wrote:

> Hi Juan
>
> The JS client works exactly like a Java client, however, it's currently
> limited to HTTP as transport  and JSON as the protocol.
> for an example run:
> ant testserver
> under: thrift//lib/js/test/
>
> If you want to you can probably implement a WebSocket transport for the JS
> lib without much effort, patches welcome! :)
>
> Cheers,
> Henrique
>
> On 17 July 2012 22:38, Juan Moreno <jw...@gmail.com> wrote:
>
> > Ok, I am not sure which question you're answering.
> > Do you mean that yes, JS can talk directly to Java (bypassing a web-app
> > server) or that no, a Web Service must Proxy between the two.
> > Also, is there documentation for what you suggest?
> >
> >
> > On Tue, Jul 17, 2012 at 4:32 PM, Jake Luciani <ja...@gmail.com> wrote:
> >
> > > Yes you generate a JS client,  It communicates via the JSONProtocol so
> > you
> > > must use that Protocol on the serverside.
> > >
> > > Also you need to use the TServlet java Server to access it from a web
> > > browser.
> > >
> > > On Tue, Jul 17, 2012 at 4:22 PM, Juan Moreno
> > > <jw...@gmail.com>wrote:
> > >
> > > > My Project is using Thrift and I am trying to understand the
> Javascript
> > > > Client Architecture.
> > > > My Question is basically this:
> > > > 1. You define a .thrift file with your structures.
> > > > 2. You Compile this file into Java(The Server/Service end) and
> > > > Javascript(The Client end)
> > > > 3. In Java Thrift Generates a Class for each struct and service. What
> > > about
> > > > in Javascript? Is this also the same?
> > > >
> > > > Can this Generated Javascript talk directly to the Java Server--that
> > is,
> > > > can it open a TSocket or start a Transport--or must there always
> > > > be a REST Service proxy-ing between the two?
> > > >
> > > > Thanks!
> > > >
> > > > --
> > > > Juan Wellington Moreno
> > > > *Software Engineer*
> > > >
> > >
> > >
> > >
> > > --
> > > http://twitter.com/tjake
> > >
> >
> >
> >
> > --
> > Juan Wellington Moreno
> > *Software Engineer*
> > Potomac Fusion
> > 6700 Alexander Bell Drive Suite 200
> > Columbia, MD 21044
> > Work: (443) 873-1470
> > Main: (347) 541-9256
> >
>

Re: Javascript Client Architecture

Posted by Henrique Mendonça <hm...@gmail.com>.
Hi Juan

The JS client works exactly like a Java client, however, it's currently
limited to HTTP as transport  and JSON as the protocol.
for an example run:
ant testserver
under: thrift//lib/js/test/

If you want to you can probably implement a WebSocket transport for the JS
lib without much effort, patches welcome! :)

Cheers,
Henrique

On 17 July 2012 22:38, Juan Moreno <jw...@gmail.com> wrote:

> Ok, I am not sure which question you're answering.
> Do you mean that yes, JS can talk directly to Java (bypassing a web-app
> server) or that no, a Web Service must Proxy between the two.
> Also, is there documentation for what you suggest?
>
>
> On Tue, Jul 17, 2012 at 4:32 PM, Jake Luciani <ja...@gmail.com> wrote:
>
> > Yes you generate a JS client,  It communicates via the JSONProtocol so
> you
> > must use that Protocol on the serverside.
> >
> > Also you need to use the TServlet java Server to access it from a web
> > browser.
> >
> > On Tue, Jul 17, 2012 at 4:22 PM, Juan Moreno
> > <jw...@gmail.com>wrote:
> >
> > > My Project is using Thrift and I am trying to understand the Javascript
> > > Client Architecture.
> > > My Question is basically this:
> > > 1. You define a .thrift file with your structures.
> > > 2. You Compile this file into Java(The Server/Service end) and
> > > Javascript(The Client end)
> > > 3. In Java Thrift Generates a Class for each struct and service. What
> > about
> > > in Javascript? Is this also the same?
> > >
> > > Can this Generated Javascript talk directly to the Java Server--that
> is,
> > > can it open a TSocket or start a Transport--or must there always
> > > be a REST Service proxy-ing between the two?
> > >
> > > Thanks!
> > >
> > > --
> > > Juan Wellington Moreno
> > > *Software Engineer*
> > >
> >
> >
> >
> > --
> > http://twitter.com/tjake
> >
>
>
>
> --
> Juan Wellington Moreno
> *Software Engineer*
> Potomac Fusion
> 6700 Alexander Bell Drive Suite 200
> Columbia, MD 21044
> Work: (443) 873-1470
> Main: (347) 541-9256
>

Re: Javascript Client Architecture

Posted by Juan Moreno <jw...@gmail.com>.
Ok, I am not sure which question you're answering.
Do you mean that yes, JS can talk directly to Java (bypassing a web-app
server) or that no, a Web Service must Proxy between the two.
Also, is there documentation for what you suggest?


On Tue, Jul 17, 2012 at 4:32 PM, Jake Luciani <ja...@gmail.com> wrote:

> Yes you generate a JS client,  It communicates via the JSONProtocol so you
> must use that Protocol on the serverside.
>
> Also you need to use the TServlet java Server to access it from a web
> browser.
>
> On Tue, Jul 17, 2012 at 4:22 PM, Juan Moreno
> <jw...@gmail.com>wrote:
>
> > My Project is using Thrift and I am trying to understand the Javascript
> > Client Architecture.
> > My Question is basically this:
> > 1. You define a .thrift file with your structures.
> > 2. You Compile this file into Java(The Server/Service end) and
> > Javascript(The Client end)
> > 3. In Java Thrift Generates a Class for each struct and service. What
> about
> > in Javascript? Is this also the same?
> >
> > Can this Generated Javascript talk directly to the Java Server--that is,
> > can it open a TSocket or start a Transport--or must there always
> > be a REST Service proxy-ing between the two?
> >
> > Thanks!
> >
> > --
> > Juan Wellington Moreno
> > *Software Engineer*
> >
>
>
>
> --
> http://twitter.com/tjake
>



-- 
Juan Wellington Moreno
*Software Engineer*
Potomac Fusion
6700 Alexander Bell Drive Suite 200
Columbia, MD 21044
Work: (443) 873-1470
Main: (347) 541-9256

Re: Javascript Client Architecture

Posted by Jake Luciani <ja...@gmail.com>.
Yes you generate a JS client,  It communicates via the JSONProtocol so you
must use that Protocol on the serverside.

Also you need to use the TServlet java Server to access it from a web
browser.

On Tue, Jul 17, 2012 at 4:22 PM, Juan Moreno
<jw...@gmail.com>wrote:

> My Project is using Thrift and I am trying to understand the Javascript
> Client Architecture.
> My Question is basically this:
> 1. You define a .thrift file with your structures.
> 2. You Compile this file into Java(The Server/Service end) and
> Javascript(The Client end)
> 3. In Java Thrift Generates a Class for each struct and service. What about
> in Javascript? Is this also the same?
>
> Can this Generated Javascript talk directly to the Java Server--that is,
> can it open a TSocket or start a Transport--or must there always
> be a REST Service proxy-ing between the two?
>
> Thanks!
>
> --
> Juan Wellington Moreno
> *Software Engineer*
>



-- 
http://twitter.com/tjake