You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2009/10/26 07:20:38 UTC

svn commit: r829707 - /tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java

Author: lresende
Date: Mon Oct 26 06:20:38 2009
New Revision: 829707

URL: http://svn.apache.org/viewvc?rev=829707&view=rev
Log:
Allowing multiple bindings on a service

Modified:
    tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java

Modified: tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java?rev=829707&r1=829706&r2=829707&view=diff
==============================================================================
--- tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java (original)
+++ tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java Mon Oct 26 06:20:38 2009
@@ -71,6 +71,10 @@
             Binding existed = bindingMap.put(binding.getName(), binding);
             // Check that multiple bindings do not have the same name
             if (existed != null && existed != binding) {
+                if(binding.getClass() != existed.getClass()) {
+                    // Look for a binding of the same type
+                    continue;
+                }
                 if (contract instanceof Service) {
                     Monitor.error(monitor, this, Messages.ASSEMBLY_VALIDATION, "MultipleBindingsForService", contract
                         .getName(), binding.getName());



Re: svn commit: r829707 - /tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java

Posted by Luciano Resende <lu...@gmail.com>.
On Mon, Oct 26, 2009 at 8:59 AM, Luciano Resende <lu...@gmail.com> wrote:
> On Mon, Oct 26, 2009 at 8:39 AM, Raymond Feng <en...@gmail.com> wrote:
>> Ant, you are right. Each binding under the same service/reference should
>> have a unique name, no matter if they are of the same type or not.
>>
>> BTW, we should now compare binding types using the QName
>> (binding.getType()).
>
> The scenario I have is the following :
>
>        <component name="ShoppingCartManager">
>                <implementation.java class="services.ShoppingCartManager"/>
>                <service name="ShoppingCart">
>                        <tuscany:binding.jsonrpc uri="/ShoppingCart"/>
>                </service>
>                <reference name="userService" target="UserService">
>                        <binding.sca/>
>                </reference>
>        </component>
>
>        <component name="UserService">
>                <implementation.java
> class="org.apache.tuscany.sca.cloud.user.impl.GoogleUserService"/>
>                <service name="UserService">
>                        <binding.sca/>
>                        <tuscany:binding.jsonrpc uri="/User"/>
>                </service>
>        </component>
>
> With the code we had, the binding name was being set as the contract
> name, so there was no way we could have two bindings for the same
> service... checking the 1.x code, I saw we had basically the same
> algorithm, but we were allowing different binding types... so I guess
> we should change the way we set the binding name.
>
> Thoughts ?
>
>

I guess one way to solve this would be to set the name on the binding
element on the composite. I'll make this change on my application and
revert the runtime changes.


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

Re: svn commit: r829707 - /tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java

Posted by Luciano Resende <lu...@gmail.com>.
On Mon, Oct 26, 2009 at 8:39 AM, Raymond Feng <en...@gmail.com> wrote:
> Ant, you are right. Each binding under the same service/reference should
> have a unique name, no matter if they are of the same type or not.
>
> BTW, we should now compare binding types using the QName
> (binding.getType()).

The scenario I have is the following :

	<component name="ShoppingCartManager">
		<implementation.java class="services.ShoppingCartManager"/>
		<service name="ShoppingCart">
			<tuscany:binding.jsonrpc uri="/ShoppingCart"/>
		</service>
		<reference name="userService" target="UserService">
			<binding.sca/>
		</reference>
	</component>
	
	<component name="UserService">
		<implementation.java
class="org.apache.tuscany.sca.cloud.user.impl.GoogleUserService"/>
		<service name="UserService">
			<binding.sca/>
			<tuscany:binding.jsonrpc uri="/User"/>
		</service>
	</component>	

With the code we had, the binding name was being set as the contract
name, so there was no way we could have two bindings for the same
service... checking the 1.x code, I saw we had basically the same
algorithm, but we were allowing different binding types... so I guess
we should change the way we set the binding name.

Thoughts ?


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

Re: svn commit: r829707 - /tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java

Posted by Raymond Feng <en...@gmail.com>.
Ant, you are right. Each binding under the same service/reference should 
have a unique name, no matter if they are of the same type or not.

BTW, we should now compare binding types using the QName 
(binding.getType()).

Thanks,
Raymond
--------------------------------------------------
From: "ant elder" <an...@gmail.com>
Sent: Monday, October 26, 2009 2:05 AM
To: <de...@tuscany.apache.org>
Subject: Re: svn commit: r829707 - 
/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java

> On Mon, Oct 26, 2009 at 6:20 AM,  <lr...@apache.org> wrote:
>> Author: lresende
>> Date: Mon Oct 26 06:20:38 2009
>> New Revision: 829707
>>
>> URL: http://svn.apache.org/viewvc?rev=829707&view=rev
>> Log:
>> Allowing multiple bindings on a service
>>
>> Modified:
>> 
>> tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java
>>
>> Modified: 
>> tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java
>> URL: 
>> http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java?rev=829707&r1=829706&r2=829707&view=diff
>> ==============================================================================
>> ---  
>> tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java 
>> (original)
>> +++ 
>> tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java 
>> Mon Oct 26 06:20:38 2009
>> @@ -71,6 +71,10 @@
>>             Binding existed = bindingMap.put(binding.getName(), binding);
>>             // Check that multiple bindings do not have the same name
>>             if (existed != null && existed != binding) {
>> +                if(binding.getClass() != existed.getClass()) {
>> +                    // Look for a binding of the same type
>> +                    continue;
>> +                }
>>                 if (contract instanceof Service) {
>>                     Monitor.error(monitor, this, 
>> Messages.ASSEMBLY_VALIDATION, "MultipleBindingsForService", contract
>>                         .getName(), binding.getName());
>>
>>
>>
>
> Can you explain this change a bit more? Isn't that now making it
> possible to have multiple bindings with the same name, which seems
> odd?
>
>   ...ant 


Re: svn commit: r829707 - /tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java

Posted by ant elder <an...@gmail.com>.
On Mon, Oct 26, 2009 at 6:20 AM,  <lr...@apache.org> wrote:
> Author: lresende
> Date: Mon Oct 26 06:20:38 2009
> New Revision: 829707
>
> URL: http://svn.apache.org/viewvc?rev=829707&view=rev
> Log:
> Allowing multiple bindings on a service
>
> Modified:
>    tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java
>
> Modified: tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java
> URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java?rev=829707&r1=829706&r2=829707&view=diff
> ==============================================================================
> --- tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java (original)
> +++ tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java Mon Oct 26 06:20:38 2009
> @@ -71,6 +71,10 @@
>             Binding existed = bindingMap.put(binding.getName(), binding);
>             // Check that multiple bindings do not have the same name
>             if (existed != null && existed != binding) {
> +                if(binding.getClass() != existed.getClass()) {
> +                    // Look for a binding of the same type
> +                    continue;
> +                }
>                 if (contract instanceof Service) {
>                     Monitor.error(monitor, this, Messages.ASSEMBLY_VALIDATION, "MultipleBindingsForService", contract
>                         .getName(), binding.getName());
>
>
>

Can you explain this change a bit more? Isn't that now making it
possible to have multiple bindings with the same name, which seems
odd?

   ...ant