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
[EMAIL PROTECTED]
-----Original Message-----
From: Simon Laws [mailto:[EMAIL PROTECTED]
Sent: Monday, April 28, 2008 1:50 PM
To: [email protected]
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, <[EMAIL PROTECTED]> 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