[ 
https://issues.apache.org/jira/browse/TUSCANY-1539?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12526711
 ] 

Amita Vadhavkar commented on TUSCANY-1539:
------------------------------------------

Seems that the Intents from .composite and javaImpl.java do add under certain 
conditions - one 
example below. Also I have some questions about implementation intents, at the 
bottom of the note.
_________________________________________________________________________________________________

e.g. impl.java

@Requires( {"transaction.global"})
public class CalculatorServiceImpl implements CalculatorService {

    private AddService addService;
    private SubtractService subtractService;
    private MultiplyService multiplyService;
    private DivideService divideService;

    @Reference
    @Requires( {"transaction.local"})
    public void setAddService(AddService addService) {
        this.addService = addService;
    }

......
    @Requires( {"transaction.local"})
    public double add(double n1, double n2) {
        return addService.add(n1, n2);
    }


}
_________________________________________________________________________________________________
e.g. .composite

<composite xmlns="http://www.osoa.org/xmlns/sca/1.0";
           targetNamespace="http://sample";
           xmlns:sample="http://sample";
           xmlns:cns="http://test"; 
           xmlns:sns="http://test";
           name="Calculator" >
   
    <component name="CalculatorServiceComponent" >
        <service name="CalculatorService">
            <interface.java interface="calculator.CalculatorService"  />
        </service>
                
        <implementation.java class="calculator.CalculatorServiceImpl"  
requires="cns:confidentiality"/>
        .....
</component>

......
</composite>
_________________________________________________________________________________________________
e.g. client code

    protected void setUp() throws Exception {
        //Create a test embedded SCA domain
        cl = getClass().getClassLoader();
        domain = new EmbeddedSCADomain(cl, "http://localhost";);
        //Start the domain
        domain.start();
        // Contribute the SCA contribution
        contributionService = domain.getContributionService();
        File javaContribLocation = new File("./target/classes");
        URL javaContribURL = javaContribLocation.toURL();
        javaContribution = 
contributionService.contribute("http://import-export/export-java";, 
javaContribURL, false);
    }

    public void testIntents() throws IOException {
        Composite composite =null; 
        
        for (DeployedArtifact artifact : 
contributionService.getContribution("http://import-export/export-java";).getArtifacts())
 {
                if(artifact != null && artifact.getModel() != null)
                System.out.println("current 
artifact:"+artifact.getModel().getClass().getName());
            if (artifact.getModel() instanceof Composite) {
                System.out.println("URI:"+artifact.getURI().toString());
                if 
(artifact.getURI().toString().endsWith("Calculator.composite"))
                {
                    composite = ((Composite)artifact.getModel());
                    break;
                }
            }
        }
                
        if (composite!=null)
        {
            System.out.println("component 
name:"+composite.getComponents().get(0).getName()+" services 
size:"+composite.getComponents().get(0).getServices().size());
            System.out.println("service 
:"+composite.getComponents().get(0).getServices().get(0).getName());
            System.out.println("service operations size:"+
                        
composite.getComponents().get(0).getServices().get(0).getInterfaceContract().getInterface().getOperations().size());
            
            List<Operation> ops = 
composite.getComponents().get(0).getServices().get(0).getInterfaceContract().getInterface().getOperations();
            System.out.println("service operation 0:"+ops.get(0).getName());
            System.out.println("service intents 
size:"+composite.getComponents().get(0).getServices().get(0).getRequiredIntents().size());
            if(composite.getComponents().get(0).getImplementation() instanceof 
JavaImplementation){
                JavaImplementation javaImpl = 
(JavaImplementation)composite.getComponents().get(0).getImplementation();
                if(javaImpl instanceof IntentAttachPoint){
                        IntentAttachPoint javaImplIntentAttachPoint = 
(IntentAttachPoint)javaImpl;
                        List<Intent> intents = 
javaImplIntentAttachPoint.getRequiredIntents();
                        System.out.println("Impl Intents SIZE:"+intents.size());
                        if(intents.size() == 4){
                        System.out.println("RESULT intent 
0:"+intents.get(0).getName());
                        System.out.println("RESULT intent 
1:"+intents.get(1).getName());
                        System.out.println("RESULT intent 
2:"+intents.get(2).getName());
                        System.out.println("RESULT intent 
3:"+intents.get(3).getName());
                    }
                }
            }
        }
    }
    
Result: addition from .composite and impl.java
_________________________________________________________________________________________________
current artifact:org.apache.tuscany.sca.assembly.impl.CompositeImpl
URI:Calculator.composite
component name:CalculatorServiceComponent services size:1
service :CalculatorService
service operations size:4
service operation 0:add
service intents size:0
Impl Intents SIZE:4
RESULT intent 0:{http://test}confidentiality
RESULT intent 1:transaction.global
RESULT intent 2:transaction.local
RESULT intent 3:transaction.local
-------------------------------------------------------------------------------------------------------------------------------------
Questions:
PolicyProcessor-
1) what is the relation in operation and intent?
why is this commented? //intent.getOperations().add(operation); in private void 
readIntents(Method method, List<Intent> requiredIntents) 

Same in PolicyAttachPointProcessor
Does this mean any method level intents are always treated as Class Impl level 
intent?

same with service callback

2) tuscany-implementation-java->JavaClassIntrospectorImpl has a comment -
The interfaces implemented by a class never contribute annotations
to the class itself or any of its members.

This is followed by tuscany-implementation-java->JavaImplementationProcessor
and thus any @Requires on Java Service Interface is ignored, only
the ones from implementation class are read (in read(reader)).
So effectively, @Requires is processed when it is defined in 
1> Java Implementation, 2> methods in Java Implementation

3) Also in PolicyProcessor
type.getServices() return no service for a .composite like above for 
CalculatorServiceImpl.
So any @Requires on java service iface is not considered, in the above client 
code.

The test case PolicyProcessorTestCase is explicitly invoking iface.java classes 
in visitClass()
method and so it sees @Requires in iface.java. But for a general client code, 
how this is achieved?

4) No duplicate checks etc. - see above result. Also, no check on 
restrictiveness of intent,
i.e. the list elements just keep adding, there is no check if the one from say 
.composite
is less restrictive than impl.java etc.

5) JIRA-1204 states that
a>@Requires on the implementation class are added to the assembly 
Implementation model object.
b>@Requires on service interfaces are added to the corresponding service model 
object.
c>@Requires on callback interfaces are added to the corresponding callback 
model object.
d>@Requires on operations are turned into Intents containing a corresponding 
Operation object.

But only a> seems to be working.

6) SCA_JavaAnnotationsAndAPIs spec mentions
If an annotation is specified at both the class/interface level and the method 
or field level, then 
the method or field level annotation completely overrides the class level 
annotation of the same type.

But looking at the above result transaction.global is not overriden by 
transaction.local.

Also where is support for Field level annotations?

7) When in the above .composite, added  requires="cns:authentication" at 
<component name="CalculatorServiceComponent" requires="cns:authentication" >, 
based on PolicyFramework
specs, 
A list of required implementation intents may also be specified by any ancestor
element of the <sca:implementation> element. The effective list of required 
implementation intents
is the union of intents specified on the implementation element and all its 
ancestors.

But RESULT does not show "authentication" added to serviceImpl.java


> The assembly model does not contain the annotated intent information
> --------------------------------------------------------------------
>
>                 Key: TUSCANY-1539
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1539
>             Project: Tuscany
>          Issue Type: Improvement
>          Components: Java SCA Assembly Model
>         Environment: r558780
>            Reporter: Yang Lei
>            Assignee: Venkatakrishnan
>             Fix For: Java-SCA-1.0
>
>
> I am following JavaAnnotationsAndAPIs section 2.3.1 and 2.4 to create an 
> sample with both intent annotation and SCDL file. I realize no matter I 
> define intents or not in SCDL, it is alreays the SCDL version get picked up.  
> I use the following code to load the composite model:
>                  EmbeddedSCADomain domain= new 
> EmbeddedSCADomain(this.getClass().getClassLoader(),"http://"+name);
>                 domain.start();
>                 ModelResolver resolver = new ModelResolverImpl(cl);
>                 ContributionService service= 
> util.getDomain(null).getContributionService();
>                 service.contribute(contributionId, contributionLocation, 
> resolver, false);
>         r       service.getContribution(contributionId);
> I use the following code to display the composite :
>          Composite composite =null;
>          for (DeployedArtifact artifact : contribution.getArtifacts()) {
>              if (artifact.getModel() instanceof Composite) {
>                  if 
> (artifact.getURI().toString().endsWith("default.composite"))
>                  {
>                      composite = ((Composite)artifact.getModel());
>                      break;
>                  }
>              }
>          }
>          if (composite!=null)
>          {
>              System.out.println("this is the artifact");
>              display(composite);
>              System.out.println("this is the added composite");
>              domain.getDomainCompositeHelper().addComposite(composite);
>              display(composite);
>              System.out.println("this is the started composite");
>              domain.getDomainCompositeHelper().startComposite(composite);
>              display(composite);
>          }
> Under all 3 cases, the composite does not contain the annotated intent setting

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to