You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Dong Liu <do...@yahoo.com> on 2009/08/31 15:57:14 UTC

GetCallbackReference return NULL for pomote service

Hi,

It seems the API ComponentContext.getRequestContext().getCallbackReference() will not work if the service is pormte to composite service and used by other compsite as implementation.composite. Here are the composite files I tried:

innercomposite:
<?xml version="1.0" encoding="UTF-8"?>

<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
    targetNamespace="http://inner"  name="InnerComposite">

 <service name="Source" promote="InnerSourceComponent" 
         interface="source.Source" callbackInterface="source.SourceCallback" > 
 </service>
  
 <component name="InnerSourceComponent">
		<implementation.java class="source.SourceImpl"/>   
 </component>
    
</composite>

OuterComposite:
<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
    targetNamespace="http://outer"  xmlns:inner="http://inner"
    name="OuterComposite">
    
    <component name="InnerComponent">
        <implementation.composite name="inner:InnerComposite"/>
        <service name="Source" interface="source.Source"
                 callbackInterface="source.SourceCallback" >
        </service>
    </component>
  
    <component name="RequestComponent">
        <implementation.java class="request.RequestImpl"/>
          	<reference name="sourceReference" target="InnerComponent/Source" />
     </component> 
        
</composite>

SourceImpl.java:
@Service(Source.class)
@Scope("COMPOSITE")
public class SourceImpl implements Source{

    final static Logger logger = Logger.getLogger(SourceImpl.class);
    private SourceCallback cb;
    private ComponentContext ct; 
    @Context 
    public void setContext(ComponentContext context)
    {
    	logger.debug("Set ComponentContext ");
 	    ct = context;
    }
   
    /*
    @Callback
    public void setSourceCallback(SourceCallback sourceCallback) {
    	logger.info("Set callback ");
        cb = sourceCallback;
    }
    */
         
    public void clientMethod(String arg) {
    	logger.debug("SOurce clientMehod");
    	cb = (SourceCallback) ct.getRequestContext().getCallbackReference().getService();
        cb.receiveResult("Callbak response "+ arg);
  }
}


When method clientMethod() is invoked, the getCallbackReference only reutrns NULL.

However, the callbackReference is able to be injected by using @Callback annotation. 




Would you like to check my composites/java files to help me fimd out where the error happens.


Thanks
Dong




      

Re: GetCallbackReference return NULL for pomote service

Posted by Dong Liu <do...@yahoo.com>.
Thanks for your work. While waiting for the fix, I wil use @Callback and Stateless service to do a walk around.


Cheers

Dong


--- On Wed, 9/2/09, Simon Nash <na...@apache.org> wrote:

> From: Simon Nash <na...@apache.org>
> Subject: Re: GetCallbackReference return NULL for pomote service
> To: user@tuscany.apache.org
> Date: Wednesday, September 2, 2009, 6:23 PM
> Simon Nash wrote:
> > Dong Liu wrote:
> >> Hi,
> >> 
> >> It seems the API
> ComponentContext.getRequestContext().getCallbackReference()
> will not work if the service is pormte to composite service
> and used by other compsite as implementation.composite. Here
> are the composite files I tried:
> >> 
> >> innercomposite:
> >> <?xml version="1.0" encoding="UTF-8"?>
> >> 
> >> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
> >>     targetNamespace="http://inner" 
> name="InnerComposite">
> >> 
> >>  <service name="Source"
> promote="InnerSourceComponent"       
>   interface="source.Source"
> callbackInterface="source.SourceCallback" > 
> </service>
> >>    <component
> name="InnerSourceComponent">
> >>     
>    <implementation.java
> class="source.SourceImpl"/>   
> </component>
> >>     </composite>
> >> 
> >> OuterComposite:
> >> <?xml version="1.0" encoding="UTF-8"?>
> >> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
> >>     targetNamespace="http://outer" 
> xmlns:inner="http://inner"
> >>     name="OuterComposite">
> >>     
>    <component name="InnerComponent">
> >>     
>    <implementation.composite
> name="inner:InnerComposite"/>
> >>         <service
> name="Source" interface="source.Source"
> >>             
>     callbackInterface="source.SourceCallback"
> >
> >>     
>    </service>
> >>     </component>
> >>       <component
> name="RequestComponent">
> >>     
>    <implementation.java
> class="request.RequestImpl"/>
> >>           
>    <reference name="sourceReference"
> target="InnerComponent/Source" />
> >>      </component> 
>        </composite>
> >> 
> >> SourceImpl.java:
> >> @Service(Source.class)
> >> @Scope("COMPOSITE")
> >> public class SourceImpl implements Source{
> >> 
> >>     final static Logger logger
> = Logger.getLogger(SourceImpl.class);
> >>     private SourceCallback
> cb;
> >>     private ComponentContext
> ct;     @Context 
>    public void setContext(ComponentContext
> context)
> >>     {
> >>     
>    logger.debug("Set ComponentContext ");
> >>          ct = context;
> >>     }
> >>        /*
> >>     @Callback
> >>     public void
> setSourceCallback(SourceCallback sourceCallback) {
> >>     
>    logger.info("Set callback ");
> >>         cb =
> sourceCallback;
> >>     }
> >>     */
> >>             
> public void clientMethod(String arg) {
> >>     
>    logger.debug("SOurce clientMehod");
> >>         cb =
> (SourceCallback)
> ct.getRequestContext().getCallbackReference().getService();
> >>     
>    cb.receiveResult("Callbak response "+
> arg);
> >>   }
> >> }
> >> 
> >> 
> >> When method clientMethod() is invoked, the
> getCallbackReference only reutrns NULL.
> >> 
> >> However, the callbackReference is able to be
> injected by using @Callback annotation.
> >> 
> >> 
> >> 
> >> Would you like to check my composites/java files
> to help me fimd out where the error happens.
> >> 
> >> 
> >> Thanks
> >> Dong
> >> 
> >> 
> > Hi Dong,
> > Thans for reporting this problem.  Your
> composites and Java files are
> > fine, and this is a bug in the Tuscany runtime. 
> I don't yet know what
> > is causing it, but while debugging it I have found 3
> other problems
> > so far:
> > 
> >  1. When using a local callback interface
> together with reference or
> >     service promotion, the Tuscany
> runtime produces a warning message for
> >     interface incompatibility even
> though the interface is compatible.
> >     I have created TUSCANY-3251 to
> track this.
> > 
> >  2. The warning messages for incompatible
> references and services are
> >     worded incorrectly.  They
> include the name of the component reference
> >     or service but the message
> wordings refer to this as a composite
> >     reference or service.  I
> have created TUSCANY-3252 to track this.
> > 
> >  3. The implementation-composite sample and the
> itest/recursive test case
> >     don't verify that the
> callbacks were received.  If the callbacks are
> >     not received because of null
> pointer exceptions, the tests appear to
> >     pass even though they have
> failed.  I have created TUSCANY-3253 to
> >     track this.
> > 
> > I am still looking into the cause of the null return
> value from
> > getCallbackReference().  I will post more
> information when I have it.
> > 
> >   Simon
> > 
> > 
> > 
> I have found the cause of the problem with null being
> returned by
> getCallbackReference() for composite implementations. 
> Some code needs
> to be added to ComponentServicePromotionBuilderImpl.java
> and
> CompositeServicePromotionBuilderImpl.java.  I have
> created TUSCANY-3254
> to track this.
> 
>   Simon
> 
> 


      

Re: GetCallbackReference return NULL for pomote service

Posted by Simon Nash <na...@apache.org>.
Simon Nash wrote:
> Dong Liu wrote:
>> Hi,
>>
>> It seems the API 
>> ComponentContext.getRequestContext().getCallbackReference() will not 
>> work if the service is pormte to composite service and used by other 
>> compsite as implementation.composite. Here are the composite files I 
>> tried:
>>
>> innercomposite:
>> <?xml version="1.0" encoding="UTF-8"?>
>>
>> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
>>     targetNamespace="http://inner"  name="InnerComposite">
>>
>>  <service name="Source" promote="InnerSourceComponent"          
>> interface="source.Source" callbackInterface="source.SourceCallback" > 
>>  </service>
>>    <component name="InnerSourceComponent">
>>         <implementation.java class="source.SourceImpl"/>    </component>
>>     </composite>
>>
>> OuterComposite:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
>>     targetNamespace="http://outer"  xmlns:inner="http://inner"
>>     name="OuterComposite">
>>         <component name="InnerComponent">
>>         <implementation.composite name="inner:InnerComposite"/>
>>         <service name="Source" interface="source.Source"
>>                  callbackInterface="source.SourceCallback" >
>>         </service>
>>     </component>
>>       <component name="RequestComponent">
>>         <implementation.java class="request.RequestImpl"/>
>>               <reference name="sourceReference" 
>> target="InnerComponent/Source" />
>>      </component>         </composite>
>>
>> SourceImpl.java:
>> @Service(Source.class)
>> @Scope("COMPOSITE")
>> public class SourceImpl implements Source{
>>
>>     final static Logger logger = Logger.getLogger(SourceImpl.class);
>>     private SourceCallback cb;
>>     private ComponentContext ct;     @Context     public void 
>> setContext(ComponentContext context)
>>     {
>>         logger.debug("Set ComponentContext ");
>>          ct = context;
>>     }
>>        /*
>>     @Callback
>>     public void setSourceCallback(SourceCallback sourceCallback) {
>>         logger.info("Set callback ");
>>         cb = sourceCallback;
>>     }
>>     */
>>              public void clientMethod(String arg) {
>>         logger.debug("SOurce clientMehod");
>>         cb = (SourceCallback) 
>> ct.getRequestContext().getCallbackReference().getService();
>>         cb.receiveResult("Callbak response "+ arg);
>>   }
>> }
>>
>>
>> When method clientMethod() is invoked, the getCallbackReference only 
>> reutrns NULL.
>>
>> However, the callbackReference is able to be injected by using 
>> @Callback annotation.
>>
>>
>>
>> Would you like to check my composites/java files to help me fimd out 
>> where the error happens.
>>
>>
>> Thanks
>> Dong
>>
>>
> Hi Dong,
> Thans for reporting this problem.  Your composites and Java files are
> fine, and this is a bug in the Tuscany runtime.  I don't yet know what
> is causing it, but while debugging it I have found 3 other problems
> so far:
> 
>  1. When using a local callback interface together with reference or
>     service promotion, the Tuscany runtime produces a warning message for
>     interface incompatibility even though the interface is compatible.
>     I have created TUSCANY-3251 to track this.
> 
>  2. The warning messages for incompatible references and services are
>     worded incorrectly.  They include the name of the component reference
>     or service but the message wordings refer to this as a composite
>     reference or service.  I have created TUSCANY-3252 to track this.
> 
>  3. The implementation-composite sample and the itest/recursive test case
>     don't verify that the callbacks were received.  If the callbacks are
>     not received because of null pointer exceptions, the tests appear to
>     pass even though they have failed.  I have created TUSCANY-3253 to
>     track this.
> 
> I am still looking into the cause of the null return value from
> getCallbackReference().  I will post more information when I have it.
> 
>   Simon
> 
> 
> 
I have found the cause of the problem with null being returned by
getCallbackReference() for composite implementations.  Some code needs
to be added to ComponentServicePromotionBuilderImpl.java and
CompositeServicePromotionBuilderImpl.java.  I have created TUSCANY-3254
to track this.

   Simon


Re: GetCallbackReference return NULL for pomote service

Posted by Simon Nash <na...@apache.org>.
Dong Liu wrote:
> Hi,
> 
> It seems the API ComponentContext.getRequestContext().getCallbackReference() will not work if the service is pormte to composite service and used by other compsite as implementation.composite. Here are the composite files I tried:
> 
> innercomposite:
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
>     targetNamespace="http://inner"  name="InnerComposite">
> 
>  <service name="Source" promote="InnerSourceComponent" 
>          interface="source.Source" callbackInterface="source.SourceCallback" > 
>  </service>
>   
>  <component name="InnerSourceComponent">
> 		<implementation.java class="source.SourceImpl"/>   
>  </component>
>     
> </composite>
> 
> OuterComposite:
> <?xml version="1.0" encoding="UTF-8"?>
> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
>     targetNamespace="http://outer"  xmlns:inner="http://inner"
>     name="OuterComposite">
>     
>     <component name="InnerComponent">
>         <implementation.composite name="inner:InnerComposite"/>
>         <service name="Source" interface="source.Source"
>                  callbackInterface="source.SourceCallback" >
>         </service>
>     </component>
>   
>     <component name="RequestComponent">
>         <implementation.java class="request.RequestImpl"/>
>           	<reference name="sourceReference" target="InnerComponent/Source" />
>      </component> 
>         
> </composite>
> 
> SourceImpl.java:
> @Service(Source.class)
> @Scope("COMPOSITE")
> public class SourceImpl implements Source{
> 
>     final static Logger logger = Logger.getLogger(SourceImpl.class);
>     private SourceCallback cb;
>     private ComponentContext ct; 
>     @Context 
>     public void setContext(ComponentContext context)
>     {
>     	logger.debug("Set ComponentContext ");
>  	    ct = context;
>     }
>    
>     /*
>     @Callback
>     public void setSourceCallback(SourceCallback sourceCallback) {
>     	logger.info("Set callback ");
>         cb = sourceCallback;
>     }
>     */
>          
>     public void clientMethod(String arg) {
>     	logger.debug("SOurce clientMehod");
>     	cb = (SourceCallback) ct.getRequestContext().getCallbackReference().getService();
>         cb.receiveResult("Callbak response "+ arg);
>   }
> }
> 
> 
> When method clientMethod() is invoked, the getCallbackReference only reutrns NULL.
> 
> However, the callbackReference is able to be injected by using @Callback annotation. 
> 
> 
> 
> 
> Would you like to check my composites/java files to help me fimd out where the error happens.
> 
> 
> Thanks
> Dong
> 
> 
Hi Dong,
Thans for reporting this problem.  Your composites and Java files are
fine, and this is a bug in the Tuscany runtime.  I don't yet know what
is causing it, but while debugging it I have found 3 other problems
so far:

  1. When using a local callback interface together with reference or
     service promotion, the Tuscany runtime produces a warning message for
     interface incompatibility even though the interface is compatible.
     I have created TUSCANY-3251 to track this.

  2. The warning messages for incompatible references and services are
     worded incorrectly.  They include the name of the component reference
     or service but the message wordings refer to this as a composite
     reference or service.  I have created TUSCANY-3252 to track this.

  3. The implementation-composite sample and the itest/recursive test case
     don't verify that the callbacks were received.  If the callbacks are
     not received because of null pointer exceptions, the tests appear to
     pass even though they have failed.  I have created TUSCANY-3253 to
     track this.

I am still looking into the cause of the null return value from
getCallbackReference().  I will post more information when I have it.

   Simon