RE: Adding Multiple Contributions, was:Re: Simple use case problem

2007-06-11 Thread Patrick Vanhuyse
Luciano,

Thanks. Works fine with these corrections.

 -Message d'origine-
 De : Luciano Resende [mailto:[EMAIL PROTECTED]
 Envoyé : vendredi 8 juin 2007 7:31
 À : tuscany-user@ws.apache.org; tuscany-dev
 Objet : Adding Multiple Contributions, was:Re: Simple use case problem


 Patrick

 Thanks for helping on this, looks like while trying the scenario where
 we have multiple contributions, we uncovered the following bugs :

- Class loader issue with contribution metadata loader [1]
- Wiring of multiple contributions [2]

 This scenario should now be working, after couple fixes that I
 committed under revision # 545411. Note that your sample application
 will need some small modifications, but you could use the
 EmbeddedSCADomainTestCase as an example to what needs to be changed,
 basically you will need to add a call to helper.activateDomain and
 then helper.startComponent.

 There is also a sample application exercising this scenario in my
 sandbox [3] for those interested. I'll work little more on this sample
 and probably move it to trunk under a sample or test case.

 While working on these issues, I also found the programming model to
 work with multiple contributions using EmbeddedSCADomain more complex
 then it should be. I'll take a deeper look into this area and send
 some proposals on how we could improve the programming model when
 using multiple contributions.

 [1] https://issues.apache.org/jira/browse/TUSCANY-1329
 [2] http://issues.apache.org/jira/browse/TUSCANY-1332
 [3]
 https://svn.apache.org/repos/asf/incubator/tuscany/sandbox/lresend
 e/sca/samples/

 On 6/7/07, Patrick Vanhuyse [EMAIL PROTECTED] wrote:
  Hi Luciano,
 
  I have attached the full code of my sample to the jira issue.
 
  All is in it !
 
  I now use 2 different resolvers. But it doesn't help !
 
  Regards.
 
  Patrick
 
   -Message d'origine-
   De : Luciano Resende [mailto:[EMAIL PROTECTED]
   Envoyé : mercredi 6 juin 2007 23:44
   À : tuscany-user@ws.apache.org
   Objet : Re: Simple use case problem
  
  
   Hi Patrick
  
  Thanks for finding a workaround for a bug in the code that process
   the contribution metadata side file, I have created a jira for it [1].
  
  Looking into the code you provided, I noticed you are using the
   same resolver while contributing both contributions, and you should be
   using two different ones
  
  Could you also provide us with the full stack trace and the
   composite files you are using ? In the mean time, I'll try to simulate
   what I think you are doing in a test case and made it available in
   Tuscany.
  
   [1] https://issues.apache.org/jira/browse/TUSCANY-1329
  
   On 6/6/07, Patrick Vanhuyse [EMAIL PROTECTED] wrote:
Luciano,
   
First try with url = file://.../provider.jar doesn't work
 because :
   
In ContributionServiceImpl.java, initializeContributionMetadata
   (line 134) :
   
URL[] clUrls = {sourceURL};
URLClassLoader cl = new URLClassLoader(clUrls);
   
contributionMetadataURL =
cl.getResource(Contribution.SCA_CONTRIBUTION_META);
   
sourceURL = file://.../provider.jar
contributionMetadataURL =
file://.../consumer/target/classes/META-INF/sca-contribution.xml
because of the parent class loader in cl.
   
If I put a null parent class loader in the creation of cl :
   
URL[] clUrls = {sourceURL};
URLClassLoader cl = new URLClassLoader(clUrls, null);
   
contributionMetadataURL =
cl.getResource(Contribution.SCA_CONTRIBUTION_META);
   
it finds the good sca-contribution :
contributionMetadataURL =
jar:file://.../provider.jar!/META-INF/sca-contribution.xml
   
and it loads the ProviderComposite and the ProviderComponent in it.
   
But in my test :
   
// Determine my class loader and my test SCA
 contribution location
String url =
file:///h:/it/logiciel_gi/sca/provider/target/provider.jar;
   
ContributionService contributionService =
domain.getContributionService();
DomainCompositeHelper helper =
 domain.getDomainCompositeHelper();
ModelResolver myResolver = new
ModelResolverImpl(getClass().getClassLoader());
   
// Contribute the SCA contribution
ListContribution contributions = new
 ArrayListContribution(2);
   
Contribution contribution = contributionService
.contribute(http://www.greisch.com/provider;, new URL(url),
myResolver, false);
assertNotNull(contribution);
contributions.add(contribution);
   
url = file:///h:/it/logiciel_gi/sca/consumer/target/classes/;
   
contribution = contributionService
.contribute(http://www.greisch.com/consumer;, new URL(url),
myResolver, false);
assertNotNull(contribution);
contributions.add(contribution);
   
for (Contribution contrib : contributions) {
  for (Composite composite

Adding Multiple Contributions, was:Re: Simple use case problem

2007-06-07 Thread Luciano Resende

Patrick

Thanks for helping on this, looks like while trying the scenario where
we have multiple contributions, we uncovered the following bugs :

  - Class loader issue with contribution metadata loader [1]
  - Wiring of multiple contributions [2]

This scenario should now be working, after couple fixes that I
committed under revision # 545411. Note that your sample application
will need some small modifications, but you could use the
EmbeddedSCADomainTestCase as an example to what needs to be changed,
basically you will need to add a call to helper.activateDomain and
then helper.startComponent.

There is also a sample application exercising this scenario in my
sandbox [3] for those interested. I'll work little more on this sample
and probably move it to trunk under a sample or test case.

While working on these issues, I also found the programming model to
work with multiple contributions using EmbeddedSCADomain more complex
then it should be. I'll take a deeper look into this area and send
some proposals on how we could improve the programming model when
using multiple contributions.

[1] https://issues.apache.org/jira/browse/TUSCANY-1329
[2] http://issues.apache.org/jira/browse/TUSCANY-1332
[3] 
https://svn.apache.org/repos/asf/incubator/tuscany/sandbox/lresende/sca/samples/

On 6/7/07, Patrick Vanhuyse [EMAIL PROTECTED] wrote:

Hi Luciano,

I have attached the full code of my sample to the jira issue.

All is in it !

I now use 2 different resolvers. But it doesn't help !

Regards.

Patrick

 -Message d'origine-
 De : Luciano Resende [mailto:[EMAIL PROTECTED]
 Envoyé : mercredi 6 juin 2007 23:44
 À : tuscany-user@ws.apache.org
 Objet : Re: Simple use case problem


 Hi Patrick

Thanks for finding a workaround for a bug in the code that process
 the contribution metadata side file, I have created a jira for it [1].

Looking into the code you provided, I noticed you are using the
 same resolver while contributing both contributions, and you should be
 using two different ones

Could you also provide us with the full stack trace and the
 composite files you are using ? In the mean time, I'll try to simulate
 what I think you are doing in a test case and made it available in
 Tuscany.

 [1] https://issues.apache.org/jira/browse/TUSCANY-1329

 On 6/6/07, Patrick Vanhuyse [EMAIL PROTECTED] wrote:
  Luciano,
 
  First try with url = file://.../provider.jar doesn't work because :
 
  In ContributionServiceImpl.java, initializeContributionMetadata
 (line 134) :
 
  URL[] clUrls = {sourceURL};
  URLClassLoader cl = new URLClassLoader(clUrls);
 
  contributionMetadataURL =
  cl.getResource(Contribution.SCA_CONTRIBUTION_META);
 
  sourceURL = file://.../provider.jar
  contributionMetadataURL =
  file://.../consumer/target/classes/META-INF/sca-contribution.xml
  because of the parent class loader in cl.
 
  If I put a null parent class loader in the creation of cl :
 
  URL[] clUrls = {sourceURL};
  URLClassLoader cl = new URLClassLoader(clUrls, null);
 
  contributionMetadataURL =
  cl.getResource(Contribution.SCA_CONTRIBUTION_META);
 
  it finds the good sca-contribution :
  contributionMetadataURL =
  jar:file://.../provider.jar!/META-INF/sca-contribution.xml
 
  and it loads the ProviderComposite and the ProviderComponent in it.
 
  But in my test :
 
  // Determine my class loader and my test SCA contribution location
  String url =
  file:///h:/it/logiciel_gi/sca/provider/target/provider.jar;
 
  ContributionService contributionService =
  domain.getContributionService();
  DomainCompositeHelper helper = domain.getDomainCompositeHelper();
  ModelResolver myResolver = new
  ModelResolverImpl(getClass().getClassLoader());
 
  // Contribute the SCA contribution
  ListContribution contributions = new ArrayListContribution(2);
 
  Contribution contribution = contributionService
  .contribute(http://www.greisch.com/provider;, new URL(url),
  myResolver, false);
  assertNotNull(contribution);
  contributions.add(contribution);
 
  url = file:///h:/it/logiciel_gi/sca/consumer/target/classes/;
 
  contribution = contributionService
  .contribute(http://www.greisch.com/consumer;, new URL(url),
  myResolver, false);
  assertNotNull(contribution);
  contributions.add(contribution);
 
  for (Contribution contrib : contributions) {
for (Composite composite : contrib.getDeployables()) {
  helper.addComposite(composite);
}
for (Composite composite : contrib.getDeployables()) {
  helper.startComposite(composite);
}
  }
 
 
  Consumer consumer = domain.getService(Consumer.class,
  ConsumerComponent);
  consumer.consume(Test);
 
  I get a NullPointerException when running consumer.consume(Test). It
  doesn't link consumer with my ProviderComponent as required in
  Consumer.composite.
 
  I keep going on with all this.