You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by wang feng <fw...@gmail.com> on 2008/03/26 04:28:46 UTC

How to use logger policy?

Hi,all
	I do a sample to test policy with logger policy,but the logger policy don't work.
    I debug the code and find the method component.getApplicablePolicySets() in PolicyProvider Impl alway return null.
    I look for the code and not find where the  ApplicablePolicySets value on component or binding or reference was setted.
 	Can anybody help me?
                    
Config file like below

definitions.xml
<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
    xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
    xmlns:calc="http://calculator">
	
	<implementationType type="sca:implementation.java" alwaysProvides="tuscany:logging"/>
    <intent name="logging"  constrains="sca:implementation.java">
        <description>All messages to and from this implementation must be logged</description>
    </intent>
    <policySet name="JDKLoggingPolicy" provides="tuscany:logging" appliesTo="sca:implementation.java"
        xmlns="http://www.osoa.org/xmlns/sca/1.0">
        <tuscany:jdkLogger name="calculator">
            <logLevel>ALL</logLevel>
        </tuscany:jdkLogger>
    </policySet>
</definitions>	

calculator.composite
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
		   xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
           targetNamespace="http://sample"
           xmlns:sample="http://sample"
           name="Calculator"
           xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">

    <component name="CalculatorServiceComponent" policyset="tuscany:JDKLoggingPolicy">
		<implementation.java class="calculator.CalculatorServiceImpl" requires="tuscany:logging"/>
        <reference name="addService" target="AddServiceComponent" />
        <reference name="subtractService" target="SubtractServiceComponent" />
        <reference name="multiplyService" target="MultiplyServiceComponent" />
        <reference name="divideService" target="DivideServiceComponent" />
    </component>

    <component name="AddServiceComponent">
        <implementation.java class="calculator.AddServiceImpl"  requires="tuscany:logging"/>
    </component>

    <component name="SubtractServiceComponent">
        <implementation.java class="calculator.SubtractServiceImpl"/>
    </component>

    <component name="MultiplyServiceComponent">
        <implementation.java class="calculator.MultiplyServiceImpl"/>
    </component>

    <component name="DivideServiceComponent"> 
        <implementation.java class="calculator.DivideServiceImpl"/>
    </component>
</composite>		
--------------
wang feng
2008-03-26


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


Re: Re: How to use logger policy?

Posted by Venkata Krishnan <fo...@gmail.com>.
Hi Wang,

Apologies.  There is a bug in the the
JDKLoggingImplementationPolicyProvider.  We must be using
component.getPolicySets() and not getApplicablePolicySets().  I am in the
course of fixing this along with a few other things in the branch for our
1.2 release after which I will syncing up the trunk for this.  So in about
an couple of hours you should see all of this working from the trunk as
well.

There is one thing that I noted though in your definitions.xml.  It seems to
be providing the 'implementationType' definitions for the sca:
implementation.java extension.  You should not be doing this as this is
something which should be a part of implementation.java extension itself.
The trouble that this can cause is with the intents that you might specify
as 'mayProvides' and 'alwaysProvides'.  When you use the intents defined
under these, in your composite, they will never get matched with policysets
because, for these it is understood that the extension itself handles what
needs to be done.

Thanks.

- Venkat



On Wed, Mar 26, 2008 at 12:15 PM, wang feng <fw...@gmail.com> wrote:

> My definitions.xml file is in the class path of
> org\apache\tuscany\sca\policy\logging and find the processor has readed the
> file.
> The PolicyProvider.createInterceptor will return null,because it can't
> find any applicable policyset for the component.
> But I copy the definitions.xml to the same dir of the composite file,it
> run fine.
> Is something wrong?
>
> Thanks,
> Wang Feng
>
>
> On 2008-03-26,Raymond Feng <en...@gmail.com> wrote:
>
> >Hi,
> >
> >Are you packaging definitions.xml in your SCA contribution to try
> >application-level configuration of the intents/policySets?
> >
> >For tuscany extensions, we have switched to SCADefinitionsProvider to
> >contribute definitions.xml model into Tuscany, not the definitions.xmlfile.
> >Can you take the policy-logging module as an example?
> >
> >Thanks,
> >Raymond
> >--------------------------------------------------
> >From: "wang feng" <fw...@gmail.com>
> >Sent: Tuesday, March 25, 2008 8:28 PM
> >To: "tuscany-dev" <tu...@ws.apache.org>
> >Subject: How to use logger policy?
> >
> >> Hi,all
> >> I do a sample to test policy with logger policy,but the logger policy
> >> don't work.
> >>    I debug the code and find the method
> >> component.getApplicablePolicySets() in PolicyProvider Impl alway return
> >> null.
> >>    I look for the code and not find where the  ApplicablePolicySets
> value
> >> on component or binding or reference was setted.
> >>  Can anybody help me?
> >>
> >> Config file like below
> >>
> >> definitions.xml
> >> <definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
> >> targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
> >>    xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
> >> xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
> >>    xmlns:calc="http://calculator">
> >>
> >> <implementationType type="sca:implementation.java"
> >> alwaysProvides="tuscany:logging"/>
> >>    <intent name="logging"  constrains="sca:implementation.java">
> >>        <description>All messages to and from this implementation must
> be
> >> logged</description>
> >>    </intent>
> >>    <policySet name="JDKLoggingPolicy" provides="tuscany:logging"
> >> appliesTo="sca:implementation.java"
> >>        xmlns="http://www.osoa.org/xmlns/sca/1.0">
> >>        <tuscany:jdkLogger name="calculator">
> >>            <logLevel>ALL</logLevel>
> >>        </tuscany:jdkLogger>
> >>    </policySet>
> >> </definitions>
> >>
> >> calculator.composite
> >> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
> >>    xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
> >>           targetNamespace="http://sample"
> >>           xmlns:sample="http://sample"
> >>           name="Calculator"
> >>           xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
> >>
> >>    <component name="CalculatorServiceComponent"
> >> policyset="tuscany:JDKLoggingPolicy">
> >> <implementation.java class="calculator.CalculatorServiceImpl"
> >> requires="tuscany:logging"/>
> >>        <reference name="addService" target="AddServiceComponent" />
> >>        <reference name="subtractService"
> target="SubtractServiceComponent"
> >> />
> >>        <reference name="multiplyService"
> target="MultiplyServiceComponent"
> >> />
> >>        <reference name="divideService" target="DivideServiceComponent"
> />
> >>    </component>
> >>
> >>    <component name="AddServiceComponent">
> >>        <implementation.java class="calculator.AddServiceImpl"
> >> requires="tuscany:logging"/>
> >>    </component>
> >>
> >>    <component name="SubtractServiceComponent">
> >>        <implementation.java class="calculator.SubtractServiceImpl"/>
> >>    </component>
> >>
> >>    <component name="MultiplyServiceComponent">
> >>        <implementation.java class="calculator.MultiplyServiceImpl"/>
> >>    </component>
> >>
> >>    <component name="DivideServiceComponent">
> >>        <implementation.java class="calculator.DivideServiceImpl"/>
> >>    </component>
> >> </composite>
> >> --------------
> >> wang feng
> >> 2008-03-26
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>

Re: Re: How to use logger policy?

Posted by wang feng <fw...@gmail.com>.
My definitions.xml file is in the class path of org\apache\tuscany\sca\policy\logging and find the processor has readed the file.
The PolicyProvider.createInterceptor will return null,because it can't find any applicable policyset for the component.
But I copy the definitions.xml to the same dir of the composite file,it run fine.
Is something wrong?

Thanks,
Wang Feng


On 2008-03-26,Raymond Feng <en...@gmail.com> wrote:

>Hi,
>
>Are you packaging definitions.xml in your SCA contribution to try 
>application-level configuration of the intents/policySets?
>
>For tuscany extensions, we have switched to SCADefinitionsProvider to 
>contribute definitions.xml model into Tuscany, not the definitions.xml file. 
>Can you take the policy-logging module as an example?
>
>Thanks,
>Raymond
>--------------------------------------------------
>From: "wang feng" <fw...@gmail.com>
>Sent: Tuesday, March 25, 2008 8:28 PM
>To: "tuscany-dev" <tu...@ws.apache.org>
>Subject: How to use logger policy?
>
>> Hi,all
>> I do a sample to test policy with logger policy,but the logger policy 
>> don't work.
>>    I debug the code and find the method 
>> component.getApplicablePolicySets() in PolicyProvider Impl alway return 
>> null.
>>    I look for the code and not find where the  ApplicablePolicySets value 
>> on component or binding or reference was setted.
>>  Can anybody help me?
>>
>> Config file like below
>>
>> definitions.xml
>> <definitions xmlns="http://www.osoa.org/xmlns/sca/1.0" 
>> targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
>>    xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" 
>> xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
>>    xmlns:calc="http://calculator">
>>
>> <implementationType type="sca:implementation.java" 
>> alwaysProvides="tuscany:logging"/>
>>    <intent name="logging"  constrains="sca:implementation.java">
>>        <description>All messages to and from this implementation must be 
>> logged</description>
>>    </intent>
>>    <policySet name="JDKLoggingPolicy" provides="tuscany:logging" 
>> appliesTo="sca:implementation.java"
>>        xmlns="http://www.osoa.org/xmlns/sca/1.0">
>>        <tuscany:jdkLogger name="calculator">
>>            <logLevel>ALL</logLevel>
>>        </tuscany:jdkLogger>
>>    </policySet>
>> </definitions>
>>
>> calculator.composite
>> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
>>    xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
>>           targetNamespace="http://sample"
>>           xmlns:sample="http://sample"
>>           name="Calculator"
>>           xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
>>
>>    <component name="CalculatorServiceComponent" 
>> policyset="tuscany:JDKLoggingPolicy">
>> <implementation.java class="calculator.CalculatorServiceImpl" 
>> requires="tuscany:logging"/>
>>        <reference name="addService" target="AddServiceComponent" />
>>        <reference name="subtractService" target="SubtractServiceComponent" 
>> />
>>        <reference name="multiplyService" target="MultiplyServiceComponent" 
>> />
>>        <reference name="divideService" target="DivideServiceComponent" />
>>    </component>
>>
>>    <component name="AddServiceComponent">
>>        <implementation.java class="calculator.AddServiceImpl" 
>> requires="tuscany:logging"/>
>>    </component>
>>
>>    <component name="SubtractServiceComponent">
>>        <implementation.java class="calculator.SubtractServiceImpl"/>
>>    </component>
>>
>>    <component name="MultiplyServiceComponent">
>>        <implementation.java class="calculator.MultiplyServiceImpl"/>
>>    </component>
>>
>>    <component name="DivideServiceComponent">
>>        <implementation.java class="calculator.DivideServiceImpl"/>
>>    </component>
>> </composite>
>> --------------
>> wang feng
>> 2008-03-26
>>
>>
>> ---------------------------------------------------------------------
>> 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
>


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


Re: How to use logger policy?

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

Are you packaging definitions.xml in your SCA contribution to try 
application-level configuration of the intents/policySets?

For tuscany extensions, we have switched to SCADefinitionsProvider to 
contribute definitions.xml model into Tuscany, not the definitions.xml file. 
Can you take the policy-logging module as an example?

Thanks,
Raymond
--------------------------------------------------
From: "wang feng" <fw...@gmail.com>
Sent: Tuesday, March 25, 2008 8:28 PM
To: "tuscany-dev" <tu...@ws.apache.org>
Subject: How to use logger policy?

> Hi,all
> I do a sample to test policy with logger policy,but the logger policy 
> don't work.
>    I debug the code and find the method 
> component.getApplicablePolicySets() in PolicyProvider Impl alway return 
> null.
>    I look for the code and not find where the  ApplicablePolicySets value 
> on component or binding or reference was setted.
>  Can anybody help me?
>
> Config file like below
>
> definitions.xml
> <definitions xmlns="http://www.osoa.org/xmlns/sca/1.0" 
> targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
>    xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" 
> xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
>    xmlns:calc="http://calculator">
>
> <implementationType type="sca:implementation.java" 
> alwaysProvides="tuscany:logging"/>
>    <intent name="logging"  constrains="sca:implementation.java">
>        <description>All messages to and from this implementation must be 
> logged</description>
>    </intent>
>    <policySet name="JDKLoggingPolicy" provides="tuscany:logging" 
> appliesTo="sca:implementation.java"
>        xmlns="http://www.osoa.org/xmlns/sca/1.0">
>        <tuscany:jdkLogger name="calculator">
>            <logLevel>ALL</logLevel>
>        </tuscany:jdkLogger>
>    </policySet>
> </definitions>
>
> calculator.composite
> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
>    xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
>           targetNamespace="http://sample"
>           xmlns:sample="http://sample"
>           name="Calculator"
>           xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
>
>    <component name="CalculatorServiceComponent" 
> policyset="tuscany:JDKLoggingPolicy">
> <implementation.java class="calculator.CalculatorServiceImpl" 
> requires="tuscany:logging"/>
>        <reference name="addService" target="AddServiceComponent" />
>        <reference name="subtractService" target="SubtractServiceComponent" 
> />
>        <reference name="multiplyService" target="MultiplyServiceComponent" 
> />
>        <reference name="divideService" target="DivideServiceComponent" />
>    </component>
>
>    <component name="AddServiceComponent">
>        <implementation.java class="calculator.AddServiceImpl" 
> requires="tuscany:logging"/>
>    </component>
>
>    <component name="SubtractServiceComponent">
>        <implementation.java class="calculator.SubtractServiceImpl"/>
>    </component>
>
>    <component name="MultiplyServiceComponent">
>        <implementation.java class="calculator.MultiplyServiceImpl"/>
>    </component>
>
>    <component name="DivideServiceComponent">
>        <implementation.java class="calculator.DivideServiceImpl"/>
>    </component>
> </composite>
> --------------
> wang feng
> 2008-03-26
>
>
> ---------------------------------------------------------------------
> 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