I've been reading the response to my questions a little closer, but I'm still 
not grasping it all.  From what you're telling me it seems that I will need to 
create my own module (as in 
tuscany-sca-1.2.1-incubating-src\modules\policy-logging\) then build it into 
tuscany.  Is that correct?

-----Original Message-----
From: Luciano Resende (JIRA) [mailto:[email protected]] 
Sent: Friday, March 06, 2009 9:51 PM
To: Sacauskis, Mike
Subject: [jira] Commented: (TUSCANY-2908) stack trace: PolicyValidation 
exception


    [ 
https://issues.apache.org/jira/browse/TUSCANY-2908?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12679831#action_12679831
 ] 

Luciano Resende commented on TUSCANY-2908:
------------------------------------------

Let me try to respond to your questions :

1. Where does the list of polices that are being loaded as described in (1) 
above come from?

It comes from modules that either you or the runtime added to the classpath of 
your application. These modules then contribute policies to the runtime.
In your case, the modules seems to be policy-security, policy-security-ws or 
binding-ws-axis2-policy, policy-logging


2. Is there a way for me to add my policy to this list or somehow get it 
resolved to my intent so that I can define my own policies?
Let's consider the policy-logging as an example here.When you provide a new 
itent (in your module definitions.xml), 

        <intent name="logging" constrains="sca:implementation.java 
sca:implementation.spring">
                <description>
                        All messages to and from this implementation must be 
logged
                </description>
        </intent>

You then use the LoggingPolicyDefinitionsProvider (registering it via 
META-INF\services\org.apache.tuscany.sca.provider.SCADefinitionsProvider)
to parse the definitions.xml and provide your intent using SCADefinitions model 
class.

Then, you still need to provide a processor to read the policySet from the app 
definitions.xml, and you do that by providing the a xxxPolicyProcessor
and registering it via 
META-INF\services\org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor.
 In this case, the processor
is being registered for the following QName 
{http://tuscany.apache.org/xmlns/sca/1.0}jdkLogger, so when the definitions.xml 
is being parsed, 
and this qName is found, your processor is going to be invoked to provide the 
right model for the policySet.

The last piece here is to provide some functionality for this policy when the 
method get invoked, and this is what the interceptor does. 


3. Is the policy set the method of mapping a policy to an intent?
Yes

4. Is the definitions file associated with the composite app even used? 
Yes, this is where you put the policySet


BTW, I tried your sample, and it looks like you have missed the other project 
your ws app depends on.

> stack trace: PolicyValidation exception
> ---------------------------------------
>
>                 Key: TUSCANY-2908
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-2908
>             Project: Tuscany
>          Issue Type: Test
>          Components: Java SCA Policy
>         Environment: windows xp using eclipse plug-in tool 1.3.2. 
>            Reporter: Michael Sacauskis
>         Attachments: ws.zip
>
>
> (1) I've gained some insight into the issue.  It seams there are a default 
> set of policies as well as some other classes that are loaded when I Do 
> SCADomain scaDomain = SCADomain.newInstance("helloworld.composite");.  They 
> are:
>  org.apache.tuscany.sca.policy.security.SecurityPolicyDefinitionsProvider
>  org.apache.tuscany.sca.binding.ws.axis2.WSBindingDefinitionsProvider
>  org.apache.tuscany.sca.binding.sca.SCABindingDefinitionsProvider
>  org.apache.tuscany.sca.policy.logging.LoggingPolicyDefinitionsProvider
> This is done in the class 
> org.apache.tuscany.sca.definitions.imp.DefaultSCADefinitionsProviderExtensionPoint
>  and the method loadProviders.  My composite file is as follows:
> <?xml version="1.0" encoding="UTF-8"?>
> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0";
>     targetNamespace="http://helloworld";
>     xmlns:hw="http://helloworld.gdit.com.";
>     xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0";
>     name="helloworld">
>     <component name="HelloWorldServiceComponent">
>           <implementation.java class="helloworld.HelloWorldImpl">
>               <operation name="sayWorld" requires="tuscany:logging"/>
>       </implementation.java>
>     <service name="HelloWorld">
>     <interface.java interface="helloworld.HelloWorld"></interface.java>
>     <binding.ws/>
>     </service>
>         <reference name="helloService" target="HelloComponent" />
>         <reference name="worldService" target="WorldComponent" />
>     </component>
>     <component name="HelloComponent">
>         <implementation.java class="helloworld.HelloServiceImpl"/>
>     </component>
>     <component name="WorldComponent">
>         <implementation.java class="helloworld.WorldServiceImpl">
>       </implementation.java>
>     </component>
> </composite>
> (2)The Composite file specifies thet <operations name="sayWorld" 
> requires="tuscany.logging"> which specifies that it the method sayWorld needs 
> to be logged.  I have a definitions file associated with my test programs 
> which specifies the policy:
> <?xml version="1.0" encoding="UTF-8"?>
> <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:helloWorld="http://HelloWorld";>
>     <!-- PolicySets -->
>     <policySet name="JDKLoggingPolicy" provides="tuscany:logging" 
> appliesTo="sca:implementation.java"
>         xmlns="http://www.osoa.org/xmlns/sca/1.0";>
>         <!--tuscany:jdkLogger name="HelloWorld">
>             <logLevel>FINER</logLevel>
>         </tuscany:jdkLogger-->
>     </policySet>
> </definitions
> (3)My Understanding (and it may be wrong) is that the requires in the 
> composite file is supposed to map to <policySet name="JDKLoggingPolicy" 
> provides="tuscany:logging" appliesTo="sca:implementation.java" 
> xmlns="http://www.osoa.org/xmlns/sca/1.0";> line in the definitions.xml file 
> and somehow this is supposed to map to the implementation of the logger.  
> This apparently is not the case.  I ran my test program without the 
> definitions.xml file associated with it and it still runs without error. What 
> I found is that the <operation name="sayWorld" requires="tuscany:logging"/> 
> maps to the intent for the logger which is in the definitions.xml file in the 
> logger package.  The file is as follows:
> <?xml version="1.0" encoding="ASCII"?>
> <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";>
>       <!-- Policy Intents Defined by the SCA Runtime -->
>       <intent name="logging" 
>               constrains="sca:implementation.java">
>               <description>
>                       All messages to and from this implementation must be 
> logged
>               </description>
>       </intent>
> </definitions>
> If I change the intent name="logging" to something I then get the Policy 
> violation error.  So this leads me to the following questions and possible 
> issues:
> 1. Where does the list of polices that are being loaded as described in (1) 
> above come from?
> 2. Is there a way for me to add my policy to this list or somehow get it 
> resolved to my intent so that I can define my own policies?
> 3. Is the policy set the method of mapping a policy to an intent?
> 4. Is the definitions file associated with the composite app even used?
> I have my own driver and will uploaded it to the jira when the SCA Policy 
> component is created.
> -----Original Message-----
> From: Luciano Resende [mailto:[email protected]] 
> Sent: Thursday, March 05, 2009 7:32 PM
> To: [email protected]
> Subject: Re: stack trace: PolicyValidation exception
> Should your intent be                 <intent name="gdit:FooBarPolicy"
> instead of                 <intent name="FooBarPolicy" ?
> On Thu, Mar 5, 2009 at 5:23 PM, Sacauskis, Mike <[email protected]> 
> wrote:
> > <definitions xmlns="http://www.osoa.org/xmlns/sca/1.0";
> >
> >
> > targetNamespace="http://gdit.com/";
> >
> >
> > xmlns:sca="http://www.osoa.org/xmlns/sca/1.0";
> >
> >             xmlns:gdit="http://gdit.com/";>
> >
> >
> >
> >                 <!-- Policy Intents Defined by the SCA Runtime -->
> >
> >                 <intent name="FooBarPolicy"
> -- 
> Luciano Resende
> Apache Tuscany, Apache PhotArk
> http://people.apache.org/~lresende
> http://lresende.blogspot.com/

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

Reply via email to