You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Raymond Feng <en...@gmail.com> on 2007/03/23 21:56:37 UTC

Do annotations on interfaces or superclasses play a role for SCA Java C&I?

Hi,

If I have component implementation class like this:

Case 1:
public class MyServiceImpl implements MyService {
    private YourService yourService;

    public void setYourService(YourService yourService) {
        this.yourService = yourService;
    }
}

public interface MyService {
    @Reference
    void setYourService(YourService yourService);
}

Q1: Should "yourService" be treated as a reference?

Case 2:
public class MyServiceImpl extends MyServiceBaseImpl {
    public void setYourService(YourService yourService) {
        super.setYourService(yourService);
        // Do addtional things here
    }
}

public class MyServiceBaseImpl {
    protected YourService yourService;

    @Reference
    public void setYourService(YourService yourService) {
        this.yourService = yourService;
    }
}

Q2: Should "yourService" be treated as a reference?

Am I crazy?

Thanks,
Raymond

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: Do annotations on interfaces or superclasses play a role for SCA Java C&I?

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

Thank you for the information. It seems to be helpful to follow the 
recommendations from JSR-250 and I agree with you that it should be 
addressed by the spec.

Raymond

----- Original Message ----- 
From: "Greg Dritschler" <gr...@gmail.com>
To: <tu...@ws.apache.org>
Sent: Tuesday, March 27, 2007 11:21 AM
Subject: Re: Do annotations on interfaces or superclasses play a role for 
SCA Java C&I?


> Regarding case 2, as far as I know the only place in the Java Common
> Annotations spec that touches on the behavior of annotations with respect 
> to
> inheritance is chapter 2 on policy annotations.  It says that the rules of
> JSR 250 apply.  According to JSR 250 annotations on hidden class members 
> are
> ignored.  So if we decided these rules also apply to @Reference, the
> @Reference annotation would not be honored.  If your derived class did not
> contain setYourService then the @Reference annotation would be honored.
>
> I think this arose in the policy section because some of the security
> annotations are similar to those in J2EE3 and the EE3 spec probably
> references JSR 250.  Perhaps it should be raised as a spec issue whether 
> the
> statements made about this in chapter 2 should be broadened to apply to 
> all
> of the annotations.  I haven't tested this extensively but my impression 
> is
> that the current tuscany code base complies with at least some of these
> rules.
>
> BTW I think the example 2a in section 2.2.1 is wrong with respect to JSR 
> 250
> because it claims annotations from hidden members should be processed.
>
> According to the javadoc java.lang.annotation.Inherited applies only to
> classes so I don't think it applies in this case.
>
> On 3/26/07, Scott Kurz <sc...@gmail.com> wrote:
>>
>> Raymond,
>>
>> I've wondered that before too.  Your case 2 would have been answered by
>> the
>> SCA spec if the @Reference annotation were defined to be, annotated 
>> itself
>> with:
>> java.lang.annotation.Inherited.    Since it's not annotated, I'm not sure
>> what to think from the SCA perspective, (though it's clear what the Java
>> lang perspective is).
>>
>>
>> On 3/23/07, Raymond Feng <en...@gmail.com> wrote:
>> >
>> > Hi,
>> >
>> > If I have component implementation class like this:
>> >
>> > Case 1:
>> > public class MyServiceImpl implements MyService {
>> >     private YourService yourService;
>> >
>> >     public void setYourService(YourService yourService) {
>> >         this.yourService = yourService;
>> >     }
>> > }
>> >
>> > public interface MyService {
>> >     @Reference
>> >     void setYourService(YourService yourService);
>> > }
>> >
>> > Q1: Should "yourService" be treated as a reference?
>> >
>> > Case 2:
>> > public class MyServiceImpl extends MyServiceBaseImpl {
>> >     public void setYourService(YourService yourService) {
>> >         super.setYourService(yourService);
>> >         // Do addtional things here
>> >     }
>> > }
>> >
>> > public class MyServiceBaseImpl {
>> >     protected YourService yourService;
>> >
>> >     @Reference
>> >     public void setYourService(YourService yourService) {
>> >         this.yourService = yourService;
>> >     }
>> > }
>> >
>> > Q2: Should "yourService" be treated as a reference?
>> >
>> > Am I crazy?
>> >
>> > Thanks,
>> > Raymond
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
>> > For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>> >
>> >
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: Do annotations on interfaces or superclasses play a role for SCA Java C&I?

Posted by Greg Dritschler <gr...@gmail.com>.
Regarding case 2, as far as I know the only place in the Java Common
Annotations spec that touches on the behavior of annotations with respect to
inheritance is chapter 2 on policy annotations.  It says that the rules of
JSR 250 apply.  According to JSR 250 annotations on hidden class members are
ignored.  So if we decided these rules also apply to @Reference, the
@Reference annotation would not be honored.  If your derived class did not
contain setYourService then the @Reference annotation would be honored.

I think this arose in the policy section because some of the security
annotations are similar to those in J2EE3 and the EE3 spec probably
references JSR 250.  Perhaps it should be raised as a spec issue whether the
statements made about this in chapter 2 should be broadened to apply to all
of the annotations.  I haven't tested this extensively but my impression is
that the current tuscany code base complies with at least some of these
rules.

BTW I think the example 2a in section 2.2.1 is wrong with respect to JSR 250
because it claims annotations from hidden members should be processed.

According to the javadoc java.lang.annotation.Inherited applies only to
classes so I don't think it applies in this case.

On 3/26/07, Scott Kurz <sc...@gmail.com> wrote:
>
> Raymond,
>
> I've wondered that before too.  Your case 2 would have been answered by
> the
> SCA spec if the @Reference annotation were defined to be, annotated itself
> with:
> java.lang.annotation.Inherited.    Since it's not annotated, I'm not sure
> what to think from the SCA perspective, (though it's clear what the Java
> lang perspective is).
>
>
> On 3/23/07, Raymond Feng <en...@gmail.com> wrote:
> >
> > Hi,
> >
> > If I have component implementation class like this:
> >
> > Case 1:
> > public class MyServiceImpl implements MyService {
> >     private YourService yourService;
> >
> >     public void setYourService(YourService yourService) {
> >         this.yourService = yourService;
> >     }
> > }
> >
> > public interface MyService {
> >     @Reference
> >     void setYourService(YourService yourService);
> > }
> >
> > Q1: Should "yourService" be treated as a reference?
> >
> > Case 2:
> > public class MyServiceImpl extends MyServiceBaseImpl {
> >     public void setYourService(YourService yourService) {
> >         super.setYourService(yourService);
> >         // Do addtional things here
> >     }
> > }
> >
> > public class MyServiceBaseImpl {
> >     protected YourService yourService;
> >
> >     @Reference
> >     public void setYourService(YourService yourService) {
> >         this.yourService = yourService;
> >     }
> > }
> >
> > Q2: Should "yourService" be treated as a reference?
> >
> > Am I crazy?
> >
> > Thanks,
> > Raymond
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-dev-help@ws.apache.org
> >
> >
>

Re: Do annotations on interfaces or superclasses play a role for SCA Java C&I?

Posted by Scott Kurz <sc...@gmail.com>.
Raymond,

I've wondered that before too.  Your case 2 would have been answered by the
SCA spec if the @Reference annotation were defined to be, annotated itself
with:
java.lang.annotation.Inherited.    Since it's not annotated, I'm not sure
what to think from the SCA perspective, (though it's clear what the Java
lang perspective is).


On 3/23/07, Raymond Feng <en...@gmail.com> wrote:
>
> Hi,
>
> If I have component implementation class like this:
>
> Case 1:
> public class MyServiceImpl implements MyService {
>     private YourService yourService;
>
>     public void setYourService(YourService yourService) {
>         this.yourService = yourService;
>     }
> }
>
> public interface MyService {
>     @Reference
>     void setYourService(YourService yourService);
> }
>
> Q1: Should "yourService" be treated as a reference?
>
> Case 2:
> public class MyServiceImpl extends MyServiceBaseImpl {
>     public void setYourService(YourService yourService) {
>         super.setYourService(yourService);
>         // Do addtional things here
>     }
> }
>
> public class MyServiceBaseImpl {
>     protected YourService yourService;
>
>     @Reference
>     public void setYourService(YourService yourService) {
>         this.yourService = yourService;
>     }
> }
>
> Q2: Should "yourService" be treated as a reference?
>
> Am I crazy?
>
> Thanks,
> Raymond
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>