You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Luciano Resende <lu...@gmail.com> on 2007/10/29 20:03:23 UTC

SCA in Web 2.0 applications...

I have created a new implementation type (implementation.widget) that
starts to extend the SCA programming model to web 2.0 client
applications. This is similar to what was proposed on this thread [1],
we can now turn a html into a SCA component, declare references using
JavaScript, and get them wired using SCA.

Considering the store composite [1],

<component name="store">
   <tuscany:implementation.widget location="content/store.html"/>
   <service name="Widget">
      <tuscany:binding.http/>
   </service>
   <reference name="Catalog" target="Catalog">
      <tuscany:binding.jsonrpc/>
   </reference>
   <reference name="ShoppingCart" target="ShoppingCart">
      <tuscany:binding.atom uri="/ShoppingCart"/>
    </reference>
</component>

<component name="Catalog">
   <implementation.java class="store.CatalogImpl"/>
   <service name="Catalog">
      <tuscany:binding.jsonrpc uri="/Catalog"/>
   </service>
</component>
	
<component name="ShoppingCart">
   <implementation.java class="store.ShoppingCartImpl"/>
   <service name="Collection">
      <tuscany:binding.atom/>
   </service>    	
</component>

Declaring SCA references using JavaScript can be done with the syntax
below. This references will get properly introspected by the
implementation.widget and wired.

//@Reference
var catalog = new Reference("Catalog");
	
//@Reference
var shoppingCart = new Reference("ShoppingCart");

The client application would need to include a generated js, that has
the same name as the  component being used.

<!-- one js include per sca component -->
<script type="text/javascript" src="store.js"></script>


Right now there is support for JSONRPC and Atom, and you can see all
of this in in action in sca/samples/store.

Please, provide your feedback, and let me know if you have more
scenarios that would enhance and simplify the programming model in a
web 2.0 application scenario.


[1] http://www.mail-archive.com/tuscany-dev@ws.apache.org/msg23094.html
[2] https://svn.apache.org/repos/asf/incubator/tuscany/java/sca/samples/store/src/main/resources/store.composite

-- 
Luciano Resende
Apache Tuscany Committer
http://people.apache.org/~lresende
http://lresende.blogspot.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: SCA in Web 2.0 applications...

Posted by Luciano Resende <lu...@gmail.com>.
On 10/29/07, Raymond Feng <en...@gmail.com> wrote:
> Hi,
>
> I think it is a nice and clean way to use SCA with Web 2.0. I have a few
> comments.
>
> 1) To reference the generated JavaScript for a given component, say foo,
> should we use a naming convention to avoid conflict? For example,
> sca/foo.js?
>

Good point, let me look into that...

> 2) Why do I have to use the following syntax to declare the references as
> they are already in the composite file?
> //@Reference
> var catalog = new Reference("Catalog");
>
> //@Reference
> var shoppingCart = new Reference("ShoppingCart");
>
> With the component definition, we already know "Catalog" and "ShoppingCart"
> are two references. Cannot we just generate these variables in the store.js?
>

The store widget component have references to other components, and
the composite define how they are wired together to the proper
targets, right ? So, making making the analogy to a java component
where we have the java class and the getters and setters for the
references properly annotated, in implementation.widget we introspect
the html to find the properly annotated references, and then use the
information on the composite file to properly wire them. One of the
benefits I see right away is that i start getting validation and
warnings when proper reference target is  not found, etc I Does this
sounds ok ?

BTW, in a sense, the variable does get generated in store.js, and
Reference("xxx") just give you access to that.


> Thanks,
> Raymond
>
>
> ----- Original Message -----
> From: "Luciano Resende" <lu...@gmail.com>
> To: "tuscany-dev" <tu...@ws.apache.org>
> Cc: "tuscany user" <tu...@ws.apache.org>
> Sent: Monday, October 29, 2007 12:03 PM
> Subject: SCA in Web 2.0 applications...
>
>
> >I have created a new implementation type (implementation.widget) that
> > starts to extend the SCA programming model to web 2.0 client
> > applications. This is similar to what was proposed on this thread [1],
> > we can now turn a html into a SCA component, declare references using
> > JavaScript, and get them wired using SCA.
> >
> > Considering the store composite [1],
> >
> > <component name="store">
> >   <tuscany:implementation.widget location="content/store.html"/>
> >   <service name="Widget">
> >      <tuscany:binding.http/>
> >   </service>
> >   <reference name="Catalog" target="Catalog">
> >      <tuscany:binding.jsonrpc/>
> >   </reference>
> >   <reference name="ShoppingCart" target="ShoppingCart">
> >      <tuscany:binding.atom uri="/ShoppingCart"/>
> >    </reference>
> > </component>
> >
> > <component name="Catalog">
> >   <implementation.java class="store.CatalogImpl"/>
> >   <service name="Catalog">
> >      <tuscany:binding.jsonrpc uri="/Catalog"/>
> >   </service>
> > </component>
> >
> > <component name="ShoppingCart">
> >   <implementation.java class="store.ShoppingCartImpl"/>
> >   <service name="Collection">
> >      <tuscany:binding.atom/>
> >   </service>
> > </component>
> >
> > Declaring SCA references using JavaScript can be done with the syntax
> > below. This references will get properly introspected by the
> > implementation.widget and wired.
> >
> > //@Reference
> > var catalog = new Reference("Catalog");
> >
> > //@Reference
> > var shoppingCart = new Reference("ShoppingCart");
> >
> > The client application would need to include a generated js, that has
> > the same name as the  component being used.
> >
> > <!-- one js include per sca component -->
> > <script type="text/javascript" src="store.js"></script>
> >
> >
> > Right now there is support for JSONRPC and Atom, and you can see all
> > of this in in action in sca/samples/store.
> >
> > Please, provide your feedback, and let me know if you have more
> > scenarios that would enhance and simplify the programming model in a
> > web 2.0 application scenario.
> >
> >
> > [1] http://www.mail-archive.com/tuscany-dev@ws.apache.org/msg23094.html
> > [2]
> > https://svn.apache.org/repos/asf/incubator/tuscany/java/sca/samples/store/src/main/resources/store.composite
> >
> > --
> > Luciano Resende
> > Apache Tuscany Committer
> > http://people.apache.org/~lresende
> > http://lresende.blogspot.com/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
>
>


-- 
Luciano Resende
Apache Tuscany Committer
http://people.apache.org/~lresende
http://lresende.blogspot.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: SCA in Web 2.0 applications...

Posted by Jean-Sebastien Delfino <js...@apache.org>.
[snip]
Raymond Feng wrote:
> Hi,
>
> I think it is a nice and clean way to use SCA with Web 2.0. I have a 
> few comments.

I like it too, with this implementation type we can model in an SCA 
composition client side components and their wires to server-side 
components.

I started to use <implementation.widget> in the store tutorial that I'm 
working on and found it very easy to use.

>
> 1) To reference the generated JavaScript for a given component, say 
> foo, should we use a naming convention to avoid conflict? For example, 
> sca/foo.js?

Initially the widget Javascript was mapped to the component URI. I ran 
into some minor issues with that:
- different components could not reuse the same HTML (as the HTML needed 
to change to include the different generated script files)
- the HTML had to use a convoluted path to the script if its URI was not 
the same as the component URI

I changed it to be <widget artifact uri>.js, i.e. for cool/ui/store.html 
it's cool/ui/store.js, allowing store.html to simply do <script 
src="store.js"/> to include the script. I'm not sure that requiring an 
sca/ prefix is really useful.

>
> 2) Why do I have to use the following syntax to declare the references 
> as they are already in the composite file?
> //@Reference
> var catalog = new Reference("Catalog");
>
> //@Reference
> var shoppingCart = new Reference("ShoppingCart");

To tell the world that this HTML widget component requires these 
references. This is similar to all other component implementations (e.g. 
Java components with annotations, BPEL components with partnerLinkTypes 
etc).

>
> With the component definition, we already know "Catalog" and 
> "ShoppingCart" are two references. Cannot we just generate these 
> variables in the store.js?

It's the other way around. The business logic in the widget 
implementation is coded to use specific references. The implementation 
needs to make a statement about what references it requires to work. 
Then an assembler comes, looks at the implementation to find what 
references it needs, creates a <component> from the implementation and 
wires the required references.

In other words, without "Reference" definitions in the implementation 
nobody knows what references the implementation requires, so nobody can 
write the correct <component> declaration :).

-- 
Jean-Sebastien


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: SCA in Web 2.0 applications...

Posted by Luciano Resende <lu...@gmail.com>.
On 10/29/07, Raymond Feng <en...@gmail.com> wrote:
> Hi,
>
> I think it is a nice and clean way to use SCA with Web 2.0. I have a few
> comments.
>
> 1) To reference the generated JavaScript for a given component, say foo,
> should we use a naming convention to avoid conflict? For example,
> sca/foo.js?
>

Good point, let me look into that...

> 2) Why do I have to use the following syntax to declare the references as
> they are already in the composite file?
> //@Reference
> var catalog = new Reference("Catalog");
>
> //@Reference
> var shoppingCart = new Reference("ShoppingCart");
>
> With the component definition, we already know "Catalog" and "ShoppingCart"
> are two references. Cannot we just generate these variables in the store.js?
>

The store widget component have references to other components, and
the composite define how they are wired together to the proper
targets, right ? So, making making the analogy to a java component
where we have the java class and the getters and setters for the
references properly annotated, in implementation.widget we introspect
the html to find the properly annotated references, and then use the
information on the composite file to properly wire them. One of the
benefits I see right away is that i start getting validation and
warnings when proper reference target is  not found, etc I Does this
sounds ok ?

BTW, in a sense, the variable does get generated in store.js, and
Reference("xxx") just give you access to that.


> Thanks,
> Raymond
>
>
> ----- Original Message -----
> From: "Luciano Resende" <lu...@gmail.com>
> To: "tuscany-dev" <tu...@ws.apache.org>
> Cc: "tuscany user" <tu...@ws.apache.org>
> Sent: Monday, October 29, 2007 12:03 PM
> Subject: SCA in Web 2.0 applications...
>
>
> >I have created a new implementation type (implementation.widget) that
> > starts to extend the SCA programming model to web 2.0 client
> > applications. This is similar to what was proposed on this thread [1],
> > we can now turn a html into a SCA component, declare references using
> > JavaScript, and get them wired using SCA.
> >
> > Considering the store composite [1],
> >
> > <component name="store">
> >   <tuscany:implementation.widget location="content/store.html"/>
> >   <service name="Widget">
> >      <tuscany:binding.http/>
> >   </service>
> >   <reference name="Catalog" target="Catalog">
> >      <tuscany:binding.jsonrpc/>
> >   </reference>
> >   <reference name="ShoppingCart" target="ShoppingCart">
> >      <tuscany:binding.atom uri="/ShoppingCart"/>
> >    </reference>
> > </component>
> >
> > <component name="Catalog">
> >   <implementation.java class="store.CatalogImpl"/>
> >   <service name="Catalog">
> >      <tuscany:binding.jsonrpc uri="/Catalog"/>
> >   </service>
> > </component>
> >
> > <component name="ShoppingCart">
> >   <implementation.java class="store.ShoppingCartImpl"/>
> >   <service name="Collection">
> >      <tuscany:binding.atom/>
> >   </service>
> > </component>
> >
> > Declaring SCA references using JavaScript can be done with the syntax
> > below. This references will get properly introspected by the
> > implementation.widget and wired.
> >
> > //@Reference
> > var catalog = new Reference("Catalog");
> >
> > //@Reference
> > var shoppingCart = new Reference("ShoppingCart");
> >
> > The client application would need to include a generated js, that has
> > the same name as the  component being used.
> >
> > <!-- one js include per sca component -->
> > <script type="text/javascript" src="store.js"></script>
> >
> >
> > Right now there is support for JSONRPC and Atom, and you can see all
> > of this in in action in sca/samples/store.
> >
> > Please, provide your feedback, and let me know if you have more
> > scenarios that would enhance and simplify the programming model in a
> > web 2.0 application scenario.
> >
> >
> > [1] http://www.mail-archive.com/tuscany-dev@ws.apache.org/msg23094.html
> > [2]
> > https://svn.apache.org/repos/asf/incubator/tuscany/java/sca/samples/store/src/main/resources/store.composite
> >
> > --
> > Luciano Resende
> > Apache Tuscany Committer
> > http://people.apache.org/~lresende
> > http://lresende.blogspot.com/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
>
>


-- 
Luciano Resende
Apache Tuscany Committer
http://people.apache.org/~lresende
http://lresende.blogspot.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: SCA in Web 2.0 applications...

Posted by Raymond Feng <en...@gmail.com>.
Hi,

I think it is a nice and clean way to use SCA with Web 2.0. I have a few 
comments.

1) To reference the generated JavaScript for a given component, say foo, 
should we use a naming convention to avoid conflict? For example, 
sca/foo.js?

2) Why do I have to use the following syntax to declare the references as 
they are already in the composite file?
//@Reference
var catalog = new Reference("Catalog");

//@Reference
var shoppingCart = new Reference("ShoppingCart");

With the component definition, we already know "Catalog" and "ShoppingCart" 
are two references. Cannot we just generate these variables in the store.js?

Thanks,
Raymond


----- Original Message ----- 
From: "Luciano Resende" <lu...@gmail.com>
To: "tuscany-dev" <tu...@ws.apache.org>
Cc: "tuscany user" <tu...@ws.apache.org>
Sent: Monday, October 29, 2007 12:03 PM
Subject: SCA in Web 2.0 applications...


>I have created a new implementation type (implementation.widget) that
> starts to extend the SCA programming model to web 2.0 client
> applications. This is similar to what was proposed on this thread [1],
> we can now turn a html into a SCA component, declare references using
> JavaScript, and get them wired using SCA.
>
> Considering the store composite [1],
>
> <component name="store">
>   <tuscany:implementation.widget location="content/store.html"/>
>   <service name="Widget">
>      <tuscany:binding.http/>
>   </service>
>   <reference name="Catalog" target="Catalog">
>      <tuscany:binding.jsonrpc/>
>   </reference>
>   <reference name="ShoppingCart" target="ShoppingCart">
>      <tuscany:binding.atom uri="/ShoppingCart"/>
>    </reference>
> </component>
>
> <component name="Catalog">
>   <implementation.java class="store.CatalogImpl"/>
>   <service name="Catalog">
>      <tuscany:binding.jsonrpc uri="/Catalog"/>
>   </service>
> </component>
>
> <component name="ShoppingCart">
>   <implementation.java class="store.ShoppingCartImpl"/>
>   <service name="Collection">
>      <tuscany:binding.atom/>
>   </service>
> </component>
>
> Declaring SCA references using JavaScript can be done with the syntax
> below. This references will get properly introspected by the
> implementation.widget and wired.
>
> //@Reference
> var catalog = new Reference("Catalog");
>
> //@Reference
> var shoppingCart = new Reference("ShoppingCart");
>
> The client application would need to include a generated js, that has
> the same name as the  component being used.
>
> <!-- one js include per sca component -->
> <script type="text/javascript" src="store.js"></script>
>
>
> Right now there is support for JSONRPC and Atom, and you can see all
> of this in in action in sca/samples/store.
>
> Please, provide your feedback, and let me know if you have more
> scenarios that would enhance and simplify the programming model in a
> web 2.0 application scenario.
>
>
> [1] http://www.mail-archive.com/tuscany-dev@ws.apache.org/msg23094.html
> [2] 
> https://svn.apache.org/repos/asf/incubator/tuscany/java/sca/samples/store/src/main/resources/store.composite
>
> -- 
> Luciano Resende
> Apache Tuscany Committer
> http://people.apache.org/~lresende
> http://lresende.blogspot.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: SCA in Web 2.0 applications...

Posted by Raymond Feng <en...@gmail.com>.
Hi,

I think it is a nice and clean way to use SCA with Web 2.0. I have a few 
comments.

1) To reference the generated JavaScript for a given component, say foo, 
should we use a naming convention to avoid conflict? For example, 
sca/foo.js?

2) Why do I have to use the following syntax to declare the references as 
they are already in the composite file?
//@Reference
var catalog = new Reference("Catalog");

//@Reference
var shoppingCart = new Reference("ShoppingCart");

With the component definition, we already know "Catalog" and "ShoppingCart" 
are two references. Cannot we just generate these variables in the store.js?

Thanks,
Raymond


----- Original Message ----- 
From: "Luciano Resende" <lu...@gmail.com>
To: "tuscany-dev" <tu...@ws.apache.org>
Cc: "tuscany user" <tu...@ws.apache.org>
Sent: Monday, October 29, 2007 12:03 PM
Subject: SCA in Web 2.0 applications...


>I have created a new implementation type (implementation.widget) that
> starts to extend the SCA programming model to web 2.0 client
> applications. This is similar to what was proposed on this thread [1],
> we can now turn a html into a SCA component, declare references using
> JavaScript, and get them wired using SCA.
>
> Considering the store composite [1],
>
> <component name="store">
>   <tuscany:implementation.widget location="content/store.html"/>
>   <service name="Widget">
>      <tuscany:binding.http/>
>   </service>
>   <reference name="Catalog" target="Catalog">
>      <tuscany:binding.jsonrpc/>
>   </reference>
>   <reference name="ShoppingCart" target="ShoppingCart">
>      <tuscany:binding.atom uri="/ShoppingCart"/>
>    </reference>
> </component>
>
> <component name="Catalog">
>   <implementation.java class="store.CatalogImpl"/>
>   <service name="Catalog">
>      <tuscany:binding.jsonrpc uri="/Catalog"/>
>   </service>
> </component>
>
> <component name="ShoppingCart">
>   <implementation.java class="store.ShoppingCartImpl"/>
>   <service name="Collection">
>      <tuscany:binding.atom/>
>   </service>
> </component>
>
> Declaring SCA references using JavaScript can be done with the syntax
> below. This references will get properly introspected by the
> implementation.widget and wired.
>
> //@Reference
> var catalog = new Reference("Catalog");
>
> //@Reference
> var shoppingCart = new Reference("ShoppingCart");
>
> The client application would need to include a generated js, that has
> the same name as the  component being used.
>
> <!-- one js include per sca component -->
> <script type="text/javascript" src="store.js"></script>
>
>
> Right now there is support for JSONRPC and Atom, and you can see all
> of this in in action in sca/samples/store.
>
> Please, provide your feedback, and let me know if you have more
> scenarios that would enhance and simplify the programming model in a
> web 2.0 application scenario.
>
>
> [1] http://www.mail-archive.com/tuscany-dev@ws.apache.org/msg23094.html
> [2] 
> https://svn.apache.org/repos/asf/incubator/tuscany/java/sca/samples/store/src/main/resources/store.composite
>
> -- 
> Luciano Resende
> Apache Tuscany Committer
> http://people.apache.org/~lresende
> http://lresende.blogspot.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org