You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Da...@empolis.com on 2008/04/24 17:35:59 UTC

How to use references using multiplicity="1..n" with binding.ws or binding.rmi

Hi all,

I have set up a composite, where service CrawlerControllerComponent has
one or more references to Crawlers. This runs without any problem using
binding.sca. Here is the content of the .compiste file, where 2 Crawlers
are refferenced:

<composite	xmlns="http://www.osoa.org/xmlns/sca/1.0"
		xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
		xmlns:s="http://connectivity"			
		name="connectivity">

	<component name="CrawlerControllerComponent">
		<implementation.java
class="impl.CrawlerControllerImpl"/>
		<service name="CrawlerController">
			<interface.java
interface="interfaces.CrawlerController" />
   		</service>
		<reference name="connectivity"
target="ConnectivityComponent">
			<binding.sca />
		</reference>		
		<reference name="crawlers" multiplicity="1..n"
target="CrawlerComponent SpecialCrawlerComponent">		
		</reference>

	</component>

	<component name="ConnectivityComponent">
		<implementation.java class="impl.ConnectivityImpl"/>
		<service name="Connectivity">
			<interface.java
interface="interfaces.Connectivity" />
   		</service>
	</component>
    
	<component name="CrawlerComponent">
		<implementation.java class="impl.CrawlerImpl"/>
		<service name="Crawler">
			<interface.java interface="interfaces.Crawler"
/>
   		</service>
		<property name="crawlerId">normal_crawler</property>

	</component>	
	
	<component name="SpecialCrawlerComponent">
		<implementation.java class="impl.SpecialCrawlerImpl"/>
		<service name="Crawler">
			<interface.java interface="interfaces.Crawler"
/>
   		</service>
		<property name="crawlerId">special_crawler</property>
	</component>    
</composite>


But what do I have to do, to make this sample work using binding.ws (or
binding.rmi) ???

Just adding <binding.ws ...> to CrawlerComponent and
SpecialCrawlerComponent leads to the following warning
WARNUNG: Component reference doesn't have a matching binding

I tried to configure multiple <binding> tags, but then both target
entries of reference "crawlers" use the first binding tag (in this case
http://AFA-19393:8088/CrawlerComponent). How can I have the targets use
different bindings ?

<composite	xmlns="http://www.osoa.org/xmlns/sca/1.0"
		xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
		xmlns:s="http://connectivity"			
		name="connectivity">

	<component name="CrawlerControllerComponent">
		<implementation.java
class="impl.CrawlerControllerImpl"/>
		<service name="CrawlerController">
			<interface.java
interface="interfaces.CrawlerController" />
   		</service>
		<reference name="connectivity"
target="ConnectivityComponent">
			<binding.sca />
		</reference>		
		<reference name="crawlers" multiplicity="1..n"
target="CrawlerComponent SpecialCrawlerComponent">
			<binding.ws
uri="http://AFA-19393:8088/CrawlerComponent" target="CrawlerComponent"
/>	
			<binding.ws
uri="http://AFA-19393:8088/SpecialCrawlerComponent"
target="SpecialCrawlerComponent"/>		
		</reference>

	</component>

	<component name="ConnectivityComponent">
		<implementation.java class="impl.ConnectivityImpl"/>
		<service name="Connectivity">
			<interface.java
interface="interfaces.Connectivity" />
   		</service>
	</component>
    
	<component name="CrawlerComponent">
		<implementation.java class="impl.CrawlerImpl"/>
		<service name="Crawler">
			<interface.java interface="interfaces.Crawler"
/>						
			<binding.ws
uri="http://AFA-19393:8088/CrawlerComponent" />			
   		</service>
		<property name="crawlerId">normal_crawler</property>

	</component>	
	
	<component name="SpecialCrawlerComponent">
		<implementation.java class="impl.SpecialCrawlerImpl"/>
		<service name="Crawler">
			<interface.java interface="interfaces.Crawler"
/>
			<binding.ws
uri="http://AFA-19393:8088/SpecialCrawlerComponent" />			
   		</service>
		<property name="crawlerId">special_crawler</property>
	</component>    
</composite>


Bye,
Daniel




RE: How to use references using multiplicity="1..n" with binding.ws or binding.rmi

Posted by "Marian, Radu" <ra...@bankofamerica.com>.
Simon,

I believe I am very close to what I need - thanks to you.  Here is where
I am at:
        SCANode2Factory nodeFactory = SCANode2Factory.newInstance();
        SCANode2Factory.SCAContribution[] contributions = new
SCANode2Factory.SCAContribution[0];
    	SCANode2 node =
nodeFactory.createSCANode(urlComposite.toURI().toString(),
sCompositeContents, contributions);

I am getting some output like:
Apr 28, 2008 2:49:40 PM org.apache.tuscany.sca.node.impl.NodeImpl <init>
INFO: Creating node:
http://localhost:7001/crms-domain/metadata/transformation.service/consum
er.facade/v001/ConsumerFacade.composite
Apr 28, 2008 2:49:42 PM org.apache.tuscany.sca.node.impl.NodeImpl <init>
INFO: Loading composite:
http://localhost:7001/crms-domain/metadata/transformation.service/consum
er.facade/v001/ConsumerFacade.composite

But also an exception:
org.osoa.sca.ServiceRuntimeException:
java.lang.ArrayIndexOutOfBoundsException: -1
	at
org.apache.tuscany.sca.node.impl.NodeImpl.<init>(NodeImpl.java:211)
	at
org.apache.tuscany.sca.node.impl.NodeFactoryImpl.createSCANode(NodeFacto
ryImpl.java:47)
	at DomainTestCase.setUp(DomainTestCase.java:52)
	at junit.framework.TestCase.runBare(TestCase.java:128)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:120)
	at junit.framework.TestSuite.runTest(TestSuite.java:228)
	at junit.framework.TestSuite.run(TestSuite.java:223)
	at
org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.jav
a:35)
	at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4Tes
tReference.java:38)
	at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.ja
va:38)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:460)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:673)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:386)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:196)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.ArrayList.get(ArrayList.java:324)
	at
org.apache.tuscany.sca.node.impl.NodeImpl.configureNode(NodeImpl.java:28
1)
	at
org.apache.tuscany.sca.node.impl.NodeImpl.<init>(NodeImpl.java:208)
	... 16 more



Radu Marian
CRM Services Architecture Team
Bank of America, Charlotte NC
(980) 387-6233
radu.marian@bankofamerica.com

-----Original Message-----
From: Simon Laws [mailto:simonslaws@googlemail.com] 
Sent: Monday, April 28, 2008 1:50 PM
To: tuscany-user@ws.apache.org
Subject: Re: How to use references using multiplicity="1..n" with
binding.ws or binding.rmi

On Mon, Apr 28, 2008 at 3:37 PM, <Da...@empolis.com> wrote:

> Hi all,
>
> I have another question concerning multiplicity. Given my sample 
> configuration
>
> <component name="CrawlerControllerComponent">
>    ...
>    <reference name="crawlers" multiplicity="1..n"
> target="CrawlerComponent SpecialCrawlerComponent">
>         <binding.sca />
>    </reference>
>
> </component>
>
> <component name="CrawlerComponent">
>    <implementation.java class="impl.CrawlerImpl"/>
>     <service name="Crawler">
>        <interface.java interface="interfaces.Crawler" />
>
>     </service>
> </component>
>
> <component name="SpecialCrawlerComponent">
>    <implementation.java class="impl.SpecialCrawlerImpl"/>
>     <service name="Crawler">
>        <interface.java interface="interfaces.Crawler" />
>     </service>
> </component>
>
>
> I want to create a ServiceReference to one of the Crawlers.
> Without multiplicity (assuming the reference name would be "crawler"),

> the code would look like this:
>
>        ServiceReference<Crawler> crawlerRef = 
> componentContext.getServiceReference(Crawler.class, "crawler");
>        return crawlerRef.getService();
>
>
> But How can I achieve this using multiplicity ? How can I choose for 
> what target a ServiceReference is created?
> By simply using this code
>        ServiceReference<Crawler> crawlerRef = 
> componentContext.getServiceReference(Crawler.class, "crawlers");
>        return crawlerRef.getService(); always a ServiceReference to 
> the first target (CrawlerComponent) is created.
>
>
> Bye,
> Daniel
>

Hi Daniel

Good question. The OASIS TC has proposed a solution to this issue (
http://www.osoa.org/jira/browse/JAVA-9) but this isn't part of the API
we have implemented as we have taken the V1 API. Can you raise a JIRA
for this as I can't see one already and at least in that way we can
track it.

Is it possible for you to inject the references you need. You can
specify a reference with multiplicity as a collection, for example, from
itest/references


    @Reference(name = "dServiceReferences")
    public List<ServiceReference<DComponent>> dServiceReferences;

Which is populated by

    <component name="AComponent">
         ...
        <reference name="dServiceReferences" target="DComponent
DComponent1"
/>
    </component>

    <component name="DComponent">
        <implementation.java
class="org.apache.tuscany.sca.itest.references.DComponentImpl" />
    </component>

    <component name="DComponent1">
        <implementation.java
class="org.apache.tuscany.sca.itest.references.DComponentImpl" />
    </component>

See the test for alternatives.

Regards

Simon

Re: How to use references using multiplicity="1..n" with binding.ws or binding.rmi

Posted by Simon Laws <si...@googlemail.com>.
On Tue, May 6, 2008 at 4:18 PM, Marian, Radu <ra...@bankofamerica.com>
wrote:

>
> Simon and Daniel,
>
> Wouldn't it be easier to use a process engine such as JBPM or another
> bpel engine such as apache ode?  They are made for this type of work -
> parallel execution, wait, fork, join, etc.
>
> Another question:
> - Are there plans in tuscany project to support JBMP process executions?
> That is to link JBPM actions to sca components?  JBMP unlike unlike
> other pure bpel engines can compose it process not only out of wsdl
> based web services but out of java classes as well.
>
> Regards,
> Radu Marian
> CRM Services Architecture Team
> Bank of America, Charlotte NC
> (980) 387-6233
> radu.marian@bankofamerica.com
>
>
...snip

Hi Radu

It may be appropriate to include an engine like JBPM to orchestrate the
services in an assembly. I guess it depends on whether the complexity of the
application is such that it  warrants the inclusion of that kind of
component. On JBPM specifically I don't know of any plans to include it. I
took a quick look at the web page and it appears to be LGPL licensed which
would give us problems. However if someone was keen to do it and there were
other licensing options aside from LGPL then there's no reason why not.

Regards

Simon

RE: How to use references using multiplicity="1..n" with binding.ws or binding.rmi

Posted by "Marian, Radu" <ra...@bankofamerica.com>.
 
Simon and Daniel,

Wouldn't it be easier to use a process engine such as JBPM or another
bpel engine such as apache ode?  They are made for this type of work -
parallel execution, wait, fork, join, etc.

Another question: 
- Are there plans in tuscany project to support JBMP process executions?
That is to link JBPM actions to sca components?  JBMP unlike unlike
other pure bpel engines can compose it process not only out of wsdl
based web services but out of java classes as well.

Regards,
Radu Marian
CRM Services Architecture Team
Bank of America, Charlotte NC
(980) 387-6233
radu.marian@bankofamerica.com

-----Original Message-----
From: Simon Laws [mailto:simonslaws@googlemail.com] 
Sent: Tuesday, May 06, 2008 10:59 AM
To: tuscany-user@ws.apache.org
Subject: Re: How to use references using multiplicity="1..n" with
binding.ws or binding.rmi

Hi Daniel

A few days ago I raised the issue of fixing the API that is causing you
these problems (
http://www.mail-archive.com/tuscany-dev@ws.apache.org/msg31110.html).
I've had one positive response to it so no great raft of opposition so
I'll double check that people are OK and hope to put a fix in. Re. your
specific scenario I've made a few comments below. Thinking aloud really
so I may be slightly off target.

snip...


> Yes, this is exactly what I want to achieve. The scope of the 
> Controller is COMPOSITE.


You could split the controller into two halves.

Controller - decides what to do and is COMPOSITE scoped Dispatcher -
owns the collection of references to crawlers and is STATELESS

For each search that the Controller wants to perform it calls through to
a Dispatcher (over the local SCA binding). This fires up a new instance
of the Dispatcher, with a new set of proxies, and the Dispatcher is free
to hold a conversation with the appropriate Crawler through an injected
proxy. This removes the need to retrieve the proxy from the component
context.


> The idea is that a Controller has 1..n references to concrete 
> Crawlers, e.g. a FilesystemCrawler and a WebCrawler.
> The Controller initiates crawls of Datasources (e.g. C:\folder or
> http://someserver.org) and receives the crawled objects from the 
> Crawler and processes them. It should be possible to crawl multiple 
> Datasources with the same Crawler instance in parallel. In the 
> Controller there is a seperate thread for each crawled datasource 
> (programmed manually). On the Crawler side one needs something similar

> (either sepereate threads or multiple instances) and for simplicity I 
> wanted to make use of SCA Conversations to take care of this. Am I 
> mis-using the Conversation feature ?


Conversations would be able to do this for you but you would use
conversational semantics if you really wanted to hold a conversation
with the crawler, i.e. identify the same context over a series of
separate invocations. An example of this kind of conversation would be
if you wanted to start the crawler and then come back later and ask for
the results so far. You could employ callabacks if you wanted the
crawler to report progress back to the controlled rather than bing
polled. The same issue arises though that you need to be able to get
hold of a service reference and set an id (either conversation or
callback) on it.

You could go with a stateless crawler without conversations or
callbacks.
This would mean that the controller would have to block on the thread
for that crawler until the crawl has been completed. I can imagine that
this is not desirable if you have crawlers running in a distributed
fashion for performance reasons.


>
>
> > (the real answer of course is for us to fix the JIRA;-)
> Well, of course this would be ideal, but I need a solution (or at 
> least a workaround) for now. Implementing my own conversation handling

> seems to be lots of overhead if the Jira is fixed somtime.
>

>
>
> Bye,
> Daniel
>

Re: How to use references using multiplicity="1..n" with binding.ws or binding.rmi

Posted by Simon Laws <si...@googlemail.com>.
Hi Daniel

A few days ago I raised the issue of fixing the API that is causing you
these problems (
http://www.mail-archive.com/tuscany-dev@ws.apache.org/msg31110.html). I've
had one positive response to it so no great raft of opposition so I'll
double check that people are OK and hope to put a fix in. Re. your specific
scenario I've made a few comments below. Thinking aloud really so I may be
slightly off target.

snip...


> Yes, this is exactly what I want to achieve. The scope of the Controller
> is COMPOSITE.


You could split the controller into two halves.

Controller - decides what to do and is COMPOSITE scoped
Dispatcher - owns the collection of references to crawlers and is STATELESS

For each search that the Controller wants to perform it calls through to a
Dispatcher (over the local SCA binding). This fires up a new instance of the
Dispatcher, with a new set of proxies, and the Dispatcher is free to hold a
conversation with the appropriate Crawler through an injected proxy. This
removes the need to retrieve the proxy from the component context.


> The idea is that a Controller has 1..n references to concrete Crawlers,
> e.g. a FilesystemCrawler and a WebCrawler.
> The Controller initiates crawls of Datasources (e.g. C:\folder or
> http://someserver.org) and receives the crawled objects from the Crawler
> and processes them. It should be possible to crawl multiple Datasources
> with the same Crawler instance in parallel. In the Controller there is a
> seperate thread for each crawled datasource (programmed manually). On
> the Crawler side one needs something similar (either sepereate threads
> or multiple instances) and for simplicity I wanted to make use of SCA
> Conversations to take care of this. Am I mis-using the Conversation
> feature ?


Conversations would be able to do this for you but you would use
conversational semantics if you really wanted to hold a conversation with
the crawler, i.e. identify the same context over a series of separate
invocations. An example of this kind of conversation would be if you wanted
to start the crawler and then come back later and ask for the results so
far. You could employ callabacks if you wanted the crawler to report
progress back to the controlled rather than bing polled. The same issue
arises though that you need to be able to get hold of a service reference
and set an id (either conversation or callback) on it.

You could go with a stateless crawler without conversations or callbacks.
This would mean that the controller would have to block on the thread for
that crawler until the crawl has been completed. I can imagine that this is
not desirable if you have crawlers running in a distributed fashion for
performance reasons.


>
>
> > (the real answer of course is for us to fix the JIRA;-)
> Well, of course this would be ideal, but I need a solution (or at least
> a workaround) for now. Implementing my own conversation handling seems
> to be lots of overhead if the Jira is fixed somtime.
>

>
>
> Bye,
> Daniel
>

AW: How to use references using multiplicity="1..n" with binding.ws or binding.rmi

Posted by Da...@empolis.com.
Hi Simon,

 
> "multiple conversations in parallel on the same Service from 
> one client".
> Can I just check that this is a requirement in you scenario. 
> I'm imagining that the effect you want is to have multiple 
> ongoing crawl actions associated with a particular type of 
> crawler. Sound right?  Also what is the scope of the crawler 
> controller component. Is it composite scoped?

Yes, this is exactly what I want to achieve. The scope of the Controller
is COMPOSITE.
 
> In the factory approach you suggest, would there be a factory 
> for each type of crawler. So you would have an injected 
> reference to get the factory reference from the multiplicity 
> of factory references and then the factory would be 
> responsible for having multiple conversations with the crawler.
> This would work I think but it doesn't sounds quite right. I 
> probably don't quite understand the scenario properly. Can 
> you say a little more about the the interactions between the 
> crawler controller and the crawlers themselves.

The idea is that a Controller has 1..n references to concrete Crawlers,
e.g. a FilesystemCrawler and a WebCrawler.
The Controller initiates crawls of Datasources (e.g. C:\folder or
http://someserver.org) and receives the crawled objects from the Crawler
and processes them. It should be possible to crawl multiple Datasources
with the same Crawler instance in parallel. In the Controller there is a
seperate thread for each crawled datasource (programmed manually). On
the Crawler side one needs something similar (either sepereate threads
or multiple instances) and for simplicity I wanted to make use of SCA
Conversations to take care of this. Am I mis-using the Conversation
feature ?

 
> (the real answer of course is for us to fix the JIRA;-)
Well, of course this would be ideal, but I need a solution (or at least
a workaround) for now. Implementing my own conversation handling seems
to be lots of overhead if the Jira is fixed somtime. 


Bye,
Daniel

Re: How to use references using multiplicity="1..n" with binding.ws or binding.rmi

Posted by Simon Laws <si...@googlemail.com>.
On Wed, Apr 30, 2008 at 12:44 PM, <Da...@empolis.com> wrote:

> Hi Simon,
>
> I just created a Jira to keep track of this issue:
> https://issues.apache.org/jira/browse/TUSCANY-2281
>
> Besides using multiplicity="1..n", the interface Crawler is also
> Conversational.
> As mentioned in document "Java Common Annotations APIs", conversations
> are created when
> - a @Reference to a conversational service is injected
> - a call is made to CompositeContext.getServiceReference() and then a
> method of the service is called
>
> So the only way of having multiple conversations in parallel on the same
> Service from one client is to create multiple ServiceReferences. So if I
> use a injected reference, then I can not have multiple conversations on
> this reference. Or are there any other options to achieve this ?
>
> A workaround for my project could be
> - to use "Factory" classes for each Crawler. So in my client I could use
> a multiplicity reference to 1..n CrawlerFactories and in each
> CrawlerFactory a single 1..1 reference to a Crawler service. Then in the
> CrawlerFactory it would be possible to create ServiceReferences.
> - to simply don't use SCAs conversation mechanism but implement my own
> conversation handling.
>
> Any suggestions ?
>
> Bye,
> Daniel
>
>
> > Hi Daniel
> >
> > Good question. The OASIS TC has proposed a solution to this issue (
> > http://www.osoa.org/jira/browse/JAVA-9) but this isn't part
> > of the API we have implemented as we have taken the V1 API.
> > Can you raise a JIRA for this as I can't see one already and
> > at least in that way we can track it.
> >
> > Is it possible for you to inject the references you need. You
> > can specify a reference with multiplicity as a collection,
> > for example, from itest/references
> >
> >
> >     @Reference(name = "dServiceReferences")
> >     public List<ServiceReference<DComponent>> dServiceReferences;
> >
> > Which is populated by
> >
> >     <component name="AComponent">
> >          ...
> >         <reference name="dServiceReferences"
> > target="DComponent DComponent1"
> > />
> >     </component>
> >
> >     <component name="DComponent">
> >         <implementation.java
> > class="org.apache.tuscany.sca.itest.references.DComponentImpl" />
> >     </component>
> >
> >     <component name="DComponent1">
> >         <implementation.java
> > class="org.apache.tuscany.sca.itest.references.DComponentImpl" />
> >     </component>
> >
> > See the test for alternatives.
> >
> > Regards
> >
> > Simon
> >
>

Thanks Daniel for the JIRA.

"multiple conversations in parallel on the same Service from one client".
Can I just check that this is a requirement in you scenario. I'm imagining
that the effect you want is to have multiple ongoing crawl actions
associated with a particular type of crawler. Sound right?  Also what is the
scope of the crawler controller component. Is it composite scoped?

In the factory approach you suggest, would there be a factory for each type
of crawler. So you would have an injected reference to get the factory
reference from the multiplicity of factory references and then the factory
would be responsible for having multiple conversations with the crawler.
This would work I think but it doesn't sounds quite right. I probably don't
quite understand the scenario properly. Can you say a little more about the
the interactions between the crawler controller and the crawlers themselves.


(the real answer of course is for us to fix the JIRA;-)

Regards

Simon

Re: Are there plans to provide bindging directly to mq?

Posted by Simon Laws <si...@googlemail.com>.
On Wed, Apr 30, 2008 at 3:45 PM, Marian, Radu <ra...@bankofamerica.com>
wrote:

> In many cases it is more efficient to not rely on jms server at all.
> Instead a component can talk directly to an mq client via mq bindgings.
>
> Are there plans to have binding.mq suported in tuscany?
>
> Thanks,
> Radu
>


Hi Radu

I haven't seen anyone talking about it to date.

Simon

Are there plans to provide bindging directly to mq?

Posted by "Marian, Radu" <ra...@bankofamerica.com>.
In many cases it is more efficient to not rely on jms server at all.
Instead a component can talk directly to an mq client via mq bindgings.

Are there plans to have binding.mq suported in tuscany?

Thanks,
Radu

AW: How to use references using multiplicity="1..n" with binding.ws or binding.rmi

Posted by Da...@empolis.com.
Hi Simon,

I just created a Jira to keep track of this issue:
https://issues.apache.org/jira/browse/TUSCANY-2281

Besides using multiplicity="1..n", the interface Crawler is also
Conversational.
As mentioned in document "Java Common Annotations APIs", conversations
are created when
- a @Reference to a conversational service is injected
- a call is made to CompositeContext.getServiceReference() and then a
method of the service is called

So the only way of having multiple conversations in parallel on the same
Service from one client is to create multiple ServiceReferences. So if I
use a injected reference, then I can not have multiple conversations on
this reference. Or are there any other options to achieve this ?

A workaround for my project could be 
- to use "Factory" classes for each Crawler. So in my client I could use
a multiplicity reference to 1..n CrawlerFactories and in each
CrawlerFactory a single 1..1 reference to a Crawler service. Then in the
CrawlerFactory it would be possible to create ServiceReferences.
- to simply don't use SCAs conversation mechanism but implement my own
conversation handling.

Any suggestions ?

Bye,
Daniel


> Hi Daniel
> 
> Good question. The OASIS TC has proposed a solution to this issue (
> http://www.osoa.org/jira/browse/JAVA-9) but this isn't part 
> of the API we have implemented as we have taken the V1 API. 
> Can you raise a JIRA for this as I can't see one already and 
> at least in that way we can track it.
> 
> Is it possible for you to inject the references you need. You 
> can specify a reference with multiplicity as a collection, 
> for example, from itest/references
> 
> 
>     @Reference(name = "dServiceReferences")
>     public List<ServiceReference<DComponent>> dServiceReferences;
> 
> Which is populated by
> 
>     <component name="AComponent">
>          ...
>         <reference name="dServiceReferences" 
> target="DComponent DComponent1"
> />
>     </component>
> 
>     <component name="DComponent">
>         <implementation.java
> class="org.apache.tuscany.sca.itest.references.DComponentImpl" />
>     </component>
> 
>     <component name="DComponent1">
>         <implementation.java
> class="org.apache.tuscany.sca.itest.references.DComponentImpl" />
>     </component>
> 
> See the test for alternatives.
> 
> Regards
> 
> Simon
> 

Re: How to use references using multiplicity="1..n" with binding.ws or binding.rmi

Posted by Simon Laws <si...@googlemail.com>.
On Mon, Apr 28, 2008 at 3:37 PM, <Da...@empolis.com> wrote:

> Hi all,
>
> I have another question concerning multiplicity. Given my sample
> configuration
>
> <component name="CrawlerControllerComponent">
>    ...
>    <reference name="crawlers" multiplicity="1..n"
> target="CrawlerComponent SpecialCrawlerComponent">
>         <binding.sca />
>    </reference>
>
> </component>
>
> <component name="CrawlerComponent">
>    <implementation.java class="impl.CrawlerImpl"/>
>     <service name="Crawler">
>        <interface.java interface="interfaces.Crawler" />
>
>     </service>
> </component>
>
> <component name="SpecialCrawlerComponent">
>    <implementation.java class="impl.SpecialCrawlerImpl"/>
>     <service name="Crawler">
>        <interface.java interface="interfaces.Crawler" />
>     </service>
> </component>
>
>
> I want to create a ServiceReference to one of the Crawlers.
> Without multiplicity (assuming the reference name would be "crawler"),
> the code would look like this:
>
>        ServiceReference<Crawler> crawlerRef =
> componentContext.getServiceReference(Crawler.class, "crawler");
>        return crawlerRef.getService();
>
>
> But How can I achieve this using multiplicity ? How can I choose for
> what target a ServiceReference is created?
> By simply using this code
>        ServiceReference<Crawler> crawlerRef =
> componentContext.getServiceReference(Crawler.class, "crawlers");
>        return crawlerRef.getService();
> always a ServiceReference to the first target (CrawlerComponent) is
> created.
>
>
> Bye,
> Daniel
>

Hi Daniel

Good question. The OASIS TC has proposed a solution to this issue (
http://www.osoa.org/jira/browse/JAVA-9) but this isn't part of the API we
have implemented as we have taken the V1 API. Can you raise a JIRA for this
as I can't see one already and at least in that way we can track it.

Is it possible for you to inject the references you need. You can specify a
reference with multiplicity as a collection, for example, from
itest/references


    @Reference(name = "dServiceReferences")
    public List<ServiceReference<DComponent>> dServiceReferences;

Which is populated by

    <component name="AComponent">
         ...
        <reference name="dServiceReferences" target="DComponent DComponent1"
/>
    </component>

    <component name="DComponent">
        <implementation.java
class="org.apache.tuscany.sca.itest.references.DComponentImpl" />
    </component>

    <component name="DComponent1">
        <implementation.java
class="org.apache.tuscany.sca.itest.references.DComponentImpl" />
    </component>

See the test for alternatives.

Regards

Simon

AW: How to use references using multiplicity="1..n" with binding.ws or binding.rmi

Posted by Da...@empolis.com.
Hi all,

I have another question concerning multiplicity. Given my sample
configuration

<component name="CrawlerControllerComponent">
   ...
    <reference name="crawlers" multiplicity="1..n"
target="CrawlerComponent SpecialCrawlerComponent">
        <binding.sca />
    </reference>

</component>
 
<component name="CrawlerComponent">
    <implementation.java class="impl.CrawlerImpl"/>
    <service name="Crawler">
        <interface.java interface="interfaces.Crawler" />

    </service>
</component>	

<component name="SpecialCrawlerComponent">
    <implementation.java class="impl.SpecialCrawlerImpl"/>
    <service name="Crawler">
        <interface.java interface="interfaces.Crawler" />
    </service>
</component>


I want to create a ServiceReference to one of the Crawlers.
Without multiplicity (assuming the reference name would be "crawler"),
the code would look like this:

	ServiceReference<Crawler> crawlerRef =
componentContext.getServiceReference(Crawler.class, "crawler");
	return crawlerRef.getService();


But How can I achieve this using multiplicity ? How can I choose for
what target a ServiceReference is created?
By simply using this code
	ServiceReference<Crawler> crawlerRef =
componentContext.getServiceReference(Crawler.class, "crawlers");
	return crawlerRef.getService();
always a ServiceReference to the first target (CrawlerComponent) is
created.


Bye,
Daniel

Re: How to use references using multiplicity="1..n" with binding.ws or binding.rmi

Posted by Simon Laws <si...@googlemail.com>.
On Fri, Apr 25, 2008 at 1:22 PM, <Da...@empolis.com> wrote:

> Hi Simon,
>
> thanks for your answer. I remember you wrote a similar answer when I
> asked about load balancing and failover.
> I'll have to get my hands on this workspace stuff, soon.
>
> It would be great if you guys could provide a little more documentation
> on the website. Everything I have read so far was not self-explanatory
> (at least not to me). So this will be of interest to more people than
> me, I guess.
>
> Thanks for now.
>
> Bye,
> Daniel
>
> > Hi
> >
> > It will work when reference and service are in different
> > composites if you use the domain workspace to process the
> > composited prior to then being deployed to nodes.
> >
> > What happens is that you have the workspace-admin app running
> > and you add your contributions (containing the composites) to
> > the workspace. You also provide configuration which tells the
> > workspace where the nodes are that are going to run the
> > composites and which composites they will run. Based on this
> > information the workspace make various (2 in the case of 2
> > composite to
> > run) atom feeds available. Each can be read by a node to
> > determine which composite to run and which contributions must
> > be retrieved in order to provide the artifacts required by
> > the composite.
> >
> > As you can probably imagine the workspace processes all the
> > relationships between all composite components and provides a
> > fully configured composite to each node, i.e. all of the
> > binding URIs are filled out based on the target relationships
> > specified in the composite files. So it's basically a
> > pre-processing step. You can simulate the effect by manually
> > adding the full uri to the reference binding.ws in your case.
> >
> > The calculator-distributed sample is a simple example of the
> > use of the workspace. You can fire up the workspace and play
> > with the gui or look at the 3 xml files in the top directory
> > of that sample which the workspace relies on for configuration.
> >
> > Regards
> >
> > Simon
> >
>

Yeah, I agree. The docs in this are a already thin and haven't kept up with
the changing code. We do need to fix that.

Regards

Simon

AW: How to use references using multiplicity="1..n" with binding.ws or binding.rmi

Posted by Da...@empolis.com.
Hi Simon,

thanks for your answer. I remember you wrote a similar answer when I
asked about load balancing and failover.
I'll have to get my hands on this workspace stuff, soon.

It would be great if you guys could provide a little more documentation
on the website. Everything I have read so far was not self-explanatory
(at least not to me). So this will be of interest to more people than
me, I guess. 

Thanks for now.

Bye,
Daniel
 
> Hi
> 
> It will work when reference and service are in different 
> composites if you use the domain workspace to process the 
> composited prior to then being deployed to nodes.
> 
> What happens is that you have the workspace-admin app running 
> and you add your contributions (containing the composites) to 
> the workspace. You also provide configuration which tells the 
> workspace where the nodes are that are going to run the 
> composites and which composites they will run. Based on this 
> information the workspace make various (2 in the case of 2 
> composite to
> run) atom feeds available. Each can be read by a node to 
> determine which composite to run and which contributions must 
> be retrieved in order to provide the artifacts required by 
> the composite.
> 
> As you can probably imagine the workspace processes all the 
> relationships between all composite components and provides a 
> fully configured composite to each node, i.e. all of the 
> binding URIs are filled out based on the target relationships 
> specified in the composite files. So it's basically a 
> pre-processing step. You can simulate the effect by manually 
> adding the full uri to the reference binding.ws in your case.
> 
> The calculator-distributed sample is a simple example of the 
> use of the workspace. You can fire up the workspace and play 
> with the gui or look at the 3 xml files in the top directory 
> of that sample which the workspace relies on for configuration.
> 
> Regards
> 
> Simon
> 

Re: How to use references using multiplicity="1..n" with binding.ws or binding.rmi

Posted by Simon Laws <si...@googlemail.com>.
On Fri, Apr 25, 2008 at 9:03 AM, <Da...@empolis.com> wrote:

> Hi Simon,
>
> Yes, just using <binding.ws/> in the reference works.
>
> But, if the components are defined in seperate composites, I get the
> following warnings (as I expected):
>
> WARNUNG: Component reference target not found, it might be a remote
> service: CrawlerComponent
> WARNUNG: Component reference target not found, it might be a remote
> service: SpecialCrawlerComponent
>
> Is this a current limitation?
>
> Bye,
> Daniel
>
>
> > Hi Daniel
> >
> > Disregarding the multiple bindings angle for a moment. For a
> > single remote binding, looking at you composite I think the
> > reference side should look like....
> >
> >                <reference name="crawlers" multiplicity="1..n"
> > target="CrawlerComponent SpecialCrawlerComponent">
> >                        <binding.ws/>
> >                </reference>
> >
> > And the service side should be as you have it, e.g.
> >
> >                <service name="Crawler">
> >                        <interface.java
> > interface="interfaces.Crawler"/>
> >                        <binding.ws uri="
> > http://AFA-19393:8088/CrawlerComponent<http://afa-19393:8088/C
> > rawlerComponent>"
> > />
> >                </service>
> >
> >                etc.
> >
> > Does that work?
> >
> > Simon
> >
>
Hi

It will work when reference and service are in different composites if you
use the domain workspace to process the composited prior to then being
deployed to nodes.

What happens is that you have the workspace-admin app running and you add
your contributions (containing the composites) to the workspace. You also
provide configuration which tells the workspace where the nodes are that are
going to run the composites and which composites they will run. Based on
this information the workspace make various (2 in the case of 2 composite to
run) atom feeds available. Each can be read by a node to determine which
composite to run and which contributions must be retrieved in order to
provide the artifacts required by the composite.

As you can probably imagine the workspace processes all the relationships
between all composite components and provides a fully configured composite
to each node, i.e. all of the binding URIs are filled out based on the
target relationships specified in the composite files. So it's basically a
pre-processing step. You can simulate the effect by manually adding the full
uri to the reference binding.ws in your case.

The calculator-distributed sample is a simple example of the use of the
workspace. You can fire up the workspace and play with the gui or look at
the 3 xml files in the top directory of that sample which the workspace
relies on for configuration.

Regards

Simon

AW: How to use references using multiplicity="1..n" with binding.ws or binding.rmi

Posted by Da...@empolis.com.
Hi Simon, 

Yes, just using <binding.ws/> in the reference works.

But, if the components are defined in seperate composites, I get the
following warnings (as I expected):

WARNUNG: Component reference target not found, it might be a remote
service: CrawlerComponent
WARNUNG: Component reference target not found, it might be a remote
service: SpecialCrawlerComponent

Is this a current limitation?

Bye,
Daniel


> Hi Daniel
> 
> Disregarding the multiple bindings angle for a moment. For a 
> single remote binding, looking at you composite I think the 
> reference side should look like....
> 
>                <reference name="crawlers" multiplicity="1..n"
> target="CrawlerComponent SpecialCrawlerComponent">
>                        <binding.ws/>
>                </reference>
> 
> And the service side should be as you have it, e.g.
> 
>                <service name="Crawler">
>                        <interface.java 
> interface="interfaces.Crawler"/>
>                        <binding.ws uri="
> http://AFA-19393:8088/CrawlerComponent<http://afa-19393:8088/C
> rawlerComponent>"
> />
>                </service>
> 
>                etc.
> 
> Does that work?
> 
> Simon
> 

Re: How to use references using multiplicity="1..n" with binding.ws or binding.rmi

Posted by Simon Laws <si...@googlemail.com>.
On Thu, Apr 24, 2008 at 4:35 PM, <Da...@empolis.com> wrote:

> Hi all,
>
> I have set up a composite, where service CrawlerControllerComponent has
> one or more references to Crawlers. This runs without any problem using
> binding.sca. Here is the content of the .compiste file, where 2 Crawlers
> are refferenced:
>
> <composite      xmlns="http://www.osoa.org/xmlns/sca/1.0"
>                xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
>                xmlns:s="http://connectivity"
>                name="connectivity">
>
>        <component name="CrawlerControllerComponent">
>                <implementation.java
> class="impl.CrawlerControllerImpl"/>
>                <service name="CrawlerController">
>                        <interface.java
> interface="interfaces.CrawlerController" />
>                </service>
>                <reference name="connectivity"
> target="ConnectivityComponent">
>                        <binding.sca />
>                </reference>
>                <reference name="crawlers" multiplicity="1..n"
> target="CrawlerComponent SpecialCrawlerComponent">
>                </reference>
>
>        </component>
>
>        <component name="ConnectivityComponent">
>                <implementation.java class="impl.ConnectivityImpl"/>
>                <service name="Connectivity">
>                        <interface.java
> interface="interfaces.Connectivity" />
>                </service>
>        </component>
>
>        <component name="CrawlerComponent">
>                <implementation.java class="impl.CrawlerImpl"/>
>                <service name="Crawler">
>                        <interface.java interface="interfaces.Crawler"
> />
>                </service>
>                <property name="crawlerId">normal_crawler</property>
>
>        </component>
>
>        <component name="SpecialCrawlerComponent">
>                <implementation.java class="impl.SpecialCrawlerImpl"/>
>                <service name="Crawler">
>                        <interface.java interface="interfaces.Crawler"
> />
>                </service>
>                <property name="crawlerId">special_crawler</property>
>        </component>
> </composite>
>
>
> But what do I have to do, to make this sample work using binding.ws (or
> binding.rmi) ???
>
> Just adding <binding.ws ...> to CrawlerComponent and
> SpecialCrawlerComponent leads to the following warning
> WARNUNG: Component reference doesn't have a matching binding
>
> I tried to configure multiple <binding> tags, but then both target
> entries of reference "crawlers" use the first binding tag (in this case
> http://AFA-19393:8088/CrawlerComponent). How can I have the targets use
> different bindings ?
>
> <composite      xmlns="http://www.osoa.org/xmlns/sca/1.0"
>                xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
>                xmlns:s="http://connectivity"
>                name="connectivity">
>
>        <component name="CrawlerControllerComponent">
>                <implementation.java
> class="impl.CrawlerControllerImpl"/>
>                <service name="CrawlerController">
>                        <interface.java
> interface="interfaces.CrawlerController" />
>                </service>
>                <reference name="connectivity"
> target="ConnectivityComponent">
>                        <binding.sca />
>                </reference>
>                <reference name="crawlers" multiplicity="1..n"
> target="CrawlerComponent SpecialCrawlerComponent">
>                        <binding.ws
> uri="http://AFA-19393:8088/CrawlerComponent" target="CrawlerComponent"
> />
>                        <binding.ws
> uri="http://AFA-19393:8088/SpecialCrawlerComponent"
> target="SpecialCrawlerComponent"/>
>                </reference>
>
>        </component>
>
>        <component name="ConnectivityComponent">
>                <implementation.java class="impl.ConnectivityImpl"/>
>                <service name="Connectivity">
>                        <interface.java
> interface="interfaces.Connectivity" />
>                </service>
>        </component>
>
>        <component name="CrawlerComponent">
>                <implementation.java class="impl.CrawlerImpl"/>
>                <service name="Crawler">
>                        <interface.java interface="interfaces.Crawler"
> />
>                        <binding.ws
> uri="http://AFA-19393:8088/CrawlerComponent" />
>                </service>
>                <property name="crawlerId">normal_crawler</property>
>
>        </component>
>
>        <component name="SpecialCrawlerComponent">
>                <implementation.java class="impl.SpecialCrawlerImpl"/>
>                <service name="Crawler">
>                        <interface.java interface="interfaces.Crawler"
> />
>                        <binding.ws
> uri="http://AFA-19393:8088/SpecialCrawlerComponent" />
>                </service>
>                <property name="crawlerId">special_crawler</property>
>        </component>
> </composite>
>
>
> Bye,
> Daniel
>
>
>
Hi Daniel

Disregarding the multiple bindings angle for a moment. For a single remote
binding, looking at you composite I think the reference side should look
like....

               <reference name="crawlers" multiplicity="1..n"
target="CrawlerComponent SpecialCrawlerComponent">
                       <binding.ws/>
               </reference>

And the service side should be as you have it, e.g.

               <service name="Crawler">
                       <interface.java interface="interfaces.Crawler"/>
                       <binding.ws uri="
http://AFA-19393:8088/CrawlerComponent<http://afa-19393:8088/CrawlerComponent>"
/>
               </service>

               etc.

Does that work?

Simon

Re: How to use references using multiplicity="1..n" with binding.ws or binding.rmi

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

Check this out: 
http://cwiki.apache.org/confluence/display/TUSCANYWIKI/Multiple+bindings+and+reference+multiplicity

Thanks,
Raymond

--------------------------------------------------
From: <Da...@empolis.com>
Sent: Thursday, April 24, 2008 8:35 AM
To: <tu...@ws.apache.org>
Subject: How to use references using multiplicity="1..n" with binding.ws or 
binding.rmi

> Hi all,
>
> I have set up a composite, where service CrawlerControllerComponent has
> one or more references to Crawlers. This runs without any problem using
> binding.sca. Here is the content of the .compiste file, where 2 Crawlers
> are refferenced:
>
> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
> xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
> xmlns:s="http://connectivity"
> name="connectivity">
>
> <component name="CrawlerControllerComponent">
> <implementation.java
> class="impl.CrawlerControllerImpl"/>
> <service name="CrawlerController">
> <interface.java
> interface="interfaces.CrawlerController" />
>   </service>
> <reference name="connectivity"
> target="ConnectivityComponent">
> <binding.sca />
> </reference>
> <reference name="crawlers" multiplicity="1..n"
> target="CrawlerComponent SpecialCrawlerComponent">
> </reference>
>
> </component>
>
> <component name="ConnectivityComponent">
> <implementation.java class="impl.ConnectivityImpl"/>
> <service name="Connectivity">
> <interface.java
> interface="interfaces.Connectivity" />
>   </service>
> </component>
>
> <component name="CrawlerComponent">
> <implementation.java class="impl.CrawlerImpl"/>
> <service name="Crawler">
> <interface.java interface="interfaces.Crawler"
> />
>   </service>
> <property name="crawlerId">normal_crawler</property>
>
> </component>
>
> <component name="SpecialCrawlerComponent">
> <implementation.java class="impl.SpecialCrawlerImpl"/>
> <service name="Crawler">
> <interface.java interface="interfaces.Crawler"
> />
>   </service>
> <property name="crawlerId">special_crawler</property>
> </component>
> </composite>
>
>
> But what do I have to do, to make this sample work using binding.ws (or
> binding.rmi) ???
>
> Just adding <binding.ws ...> to CrawlerComponent and
> SpecialCrawlerComponent leads to the following warning
> WARNUNG: Component reference doesn't have a matching binding
>
> I tried to configure multiple <binding> tags, but then both target
> entries of reference "crawlers" use the first binding tag (in this case
> http://AFA-19393:8088/CrawlerComponent). How can I have the targets use
> different bindings ?
>
> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
> xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
> xmlns:s="http://connectivity"
> name="connectivity">
>
> <component name="CrawlerControllerComponent">
> <implementation.java
> class="impl.CrawlerControllerImpl"/>
> <service name="CrawlerController">
> <interface.java
> interface="interfaces.CrawlerController" />
>   </service>
> <reference name="connectivity"
> target="ConnectivityComponent">
> <binding.sca />
> </reference>
> <reference name="crawlers" multiplicity="1..n"
> target="CrawlerComponent SpecialCrawlerComponent">
> <binding.ws
> uri="http://AFA-19393:8088/CrawlerComponent" target="CrawlerComponent"
> />
> <binding.ws
> uri="http://AFA-19393:8088/SpecialCrawlerComponent"
> target="SpecialCrawlerComponent"/>
> </reference>
>
> </component>
>
> <component name="ConnectivityComponent">
> <implementation.java class="impl.ConnectivityImpl"/>
> <service name="Connectivity">
> <interface.java
> interface="interfaces.Connectivity" />
>   </service>
> </component>
>
> <component name="CrawlerComponent">
> <implementation.java class="impl.CrawlerImpl"/>
> <service name="Crawler">
> <interface.java interface="interfaces.Crawler"
> />
> <binding.ws
> uri="http://AFA-19393:8088/CrawlerComponent" />
>   </service>
> <property name="crawlerId">normal_crawler</property>
>
> </component>
>
> <component name="SpecialCrawlerComponent">
> <implementation.java class="impl.SpecialCrawlerImpl"/>
> <service name="Crawler">
> <interface.java interface="interfaces.Crawler"
> />
> <binding.ws
> uri="http://AFA-19393:8088/SpecialCrawlerComponent" />
>   </service>
> <property name="crawlerId">special_crawler</property>
> </component>
> </composite>
>
>
> Bye,
> Daniel
>
>
>