Author: rfeng
Date: Wed Jul 8 22:50:59 2009
New Revision: 792346
URL: http://svn.apache.org/viewvc?rev=792346&view=rev
Log:
Add the policy-logging back to trunk
Added:
tuscany/java/sca/modules/policy-logging/
- copied from r792319, tuscany/java/sca-contrib/modules/policy-logging/
tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/definitions.xml
tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
Removed:
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/LoggingPolicyDefinitionsProvider.java
tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.DefinitionsProvider
Modified:
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java
Modified:
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java?rev=792346&r1=792319&r2=792346&view=diff
==============================================================================
---
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java
(original)
+++
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java
Wed Jul 8 22:50:59 2009
@@ -19,72 +19,29 @@
package org.apache.tuscany.sca.policy.logging.jdk;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
-import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
/**
* @version $Rev$ $Date$
*/
-public class JDKLoggingImplementationPolicyProvider implements PolicyProvider {
- private RuntimeComponent component;
- private Implementation implementation;
-
- public JDKLoggingImplementationPolicyProvider(RuntimeComponent component,
Implementation implementation) {
- super();
- this.component = component;
- this.implementation = implementation;
- }
-
- private String getContext() {
- return "component.implementation: " + component.getURI() + "(" +
implementation.getClass().getName() + ")";
- }
+public class JDKLoggingImplementationPolicyProvider extends
BasePolicyProvider<JDKLoggingPolicy> {
- private PolicySet findPolicySet(Operation operation) {
- for (PolicySet ps : component.getPolicySets()) {
- for (Object p : ps.getPolicies()) {
- if (JDKLoggingPolicy.class.isInstance(p)) {
- return ps;
- }
- }
- }
-
- if ( component instanceof OperationsConfigurator ) {
- for ( ConfiguredOperation confOp :
((OperationsConfigurator)component).getConfiguredOperations() ) {
- if ( confOp.getName().equals(operation.getName())) {
- for (PolicySet ps : confOp.getPolicySets()) {
- for (Object p : ps.getPolicies()) {
- if (JDKLoggingPolicy.class.isInstance(p)) {
- return ps;
- }
- }
- }
- }
- }
- }
-
- return null;
+ public JDKLoggingImplementationPolicyProvider(RuntimeComponent component) {
+ super(JDKLoggingPolicy.class, component);
}
/**
* @see
org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation)
*/
- public Interceptor createInterceptor(Operation operation) {
- PolicySet ps = findPolicySet(operation);
- return ps == null ? null : new
JDKLoggingPolicyInterceptor(getContext(), operation, ps);
- }
-
- /**
- * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase()
- */
- public String getPhase() {
- return Phase.IMPLEMENTATION_POLICY;
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ PolicySet ps = findPolicySet();
+ return ps == null ? null : new
JDKLoggingPolicyInterceptor(getContext(), operation, ps,
+
Phase.IMPLEMENTATION_POLICY);
}
}
Modified:
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java?rev=792346&r1=792319&r2=792346&view=diff
==============================================================================
---
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java
(original)
+++
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java
Wed Jul 8 22:50:59 2009
@@ -22,15 +22,13 @@
import javax.xml.namespace.QName;
-import org.apache.tuscany.sca.policy.Policy;
-
/**
* Implementation for policies that could be injected as parameter
* into the axis2config.
*
* @version $Rev$ $Date$
*/
-public class JDKLoggingPolicy implements Policy {
+public class JDKLoggingPolicy {
static final String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
static final String SCA10_TUSCANY_NS =
"http://tuscany.apache.org/xmlns/sca/1.0";
private static final QName JDK_LOGGING_POLICY_QNAME = new
QName(SCA10_TUSCANY_NS, "jdkLogger");
Modified:
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java?rev=792346&r1=792319&r2=792346&view=diff
==============================================================================
---
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java
(original)
+++
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java
Wed Jul 8 22:50:59 2009
@@ -26,9 +26,9 @@
import javax.xml.namespace.QName;
import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -37,7 +37,7 @@
*
* @version $Rev$ $Date$
*/
-public class JDKLoggingPolicyInterceptor implements Interceptor {
+public class JDKLoggingPolicyInterceptor implements PhasedInterceptor {
public static final String loggingPolicy = "JDKLoggingPolicy";
public static final QName policySetQName = new
QName(JDKLoggingPolicy.SCA10_TUSCANY_NS, loggingPolicy);
private Logger logger = null;
@@ -46,12 +46,14 @@
private Operation operation;
private PolicySet policySet = null;
private String context;
+ private String phase;
- public JDKLoggingPolicyInterceptor(String context, Operation operation,
PolicySet policySet) {
+ public JDKLoggingPolicyInterceptor(String context, Operation operation,
PolicySet policySet, String phase) {
super();
this.operation = operation;
this.policySet = policySet;
this.context = context;
+ this.phase = phase;
init();
}
@@ -126,4 +128,9 @@
public void setNext(Invoker next) {
this.next = next;
}
+
+ public String getPhase() {
+ return phase;
+ }
+
}
Modified:
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java?rev=792346&r1=792319&r2=792346&view=diff
==============================================================================
---
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java
(original)
+++
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java
Wed Jul 8 22:50:59 2009
@@ -19,14 +19,12 @@
package org.apache.tuscany.sca.policy.logging.jdk;
-import org.apache.tuscany.sca.assembly.Binding;
-import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.provider.PolicyProvider;
import org.apache.tuscany.sca.provider.PolicyProviderFactory;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-import org.apache.tuscany.sca.runtime.RuntimeComponentService;
/**
* @version $Rev$ $Date$
@@ -42,26 +40,22 @@
/**
* @see
org.apache.tuscany.sca.provider.PolicyProviderFactory#createImplementationPolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent,
org.apache.tuscany.sca.assembly.Implementation)
*/
- public PolicyProvider createImplementationPolicyProvider(RuntimeComponent
component, Implementation implementation) {
- return new JDKLoggingImplementationPolicyProvider(component,
implementation);
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent
component) {
+ return new JDKLoggingImplementationPolicyProvider(component);
}
/**
* @see
org.apache.tuscany.sca.provider.PolicyProviderFactory#createReferencePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent,
org.apache.tuscany.sca.runtime.RuntimeComponentReference,
org.apache.tuscany.sca.assembly.Binding)
*/
- public PolicyProvider createReferencePolicyProvider(RuntimeComponent
component,
-
RuntimeComponentReference reference,
- Binding binding) {
- return new JDKLoggingReferencePolicyProvider(component, reference,
binding);
+ public PolicyProvider createReferencePolicyProvider(EndpointReference
endpointReference) {
+ return new JDKLoggingReferencePolicyProvider(endpointReference);
}
/**
* @see
org.apache.tuscany.sca.provider.PolicyProviderFactory#createServicePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent,
org.apache.tuscany.sca.runtime.RuntimeComponentService,
org.apache.tuscany.sca.assembly.Binding)
*/
- public PolicyProvider createServicePolicyProvider(RuntimeComponent
component,
- RuntimeComponentService
service,
- Binding binding) {
- return new JDKLoggingServicePolicyProvider(component, service,
binding);
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return new JDKLoggingServicePolicyProvider(endpoint);
}
/**
Modified:
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java?rev=792346&r1=792319&r2=792346&view=diff
==============================================================================
---
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java
(original)
+++
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java
Wed Jul 8 22:50:59 2009
@@ -19,71 +19,22 @@
package org.apache.tuscany.sca.policy.logging.jdk;
-import java.util.List;
-
import org.apache.tuscany.sca.assembly.Binding;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Interceptor;
-import org.apache.tuscany.sca.invocation.Phase;
-import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
-import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
/**
* @version $Rev$ $Date$
*/
-public class JDKLoggingReferencePolicyProvider implements PolicyProvider {
+public class JDKLoggingReferencePolicyProvider extends
BasePolicyProvider<JDKLoggingPolicy> {
private RuntimeComponent component;
private RuntimeComponentReference reference;
private Binding binding;
- public JDKLoggingReferencePolicyProvider(RuntimeComponent component,
- RuntimeComponentReference
reference,
- Binding binding) {
- super();
- this.component = component;
- this.reference = reference;
- this.binding = binding;
- }
-
- private PolicySet findPolicySet() {
- if (binding instanceof PolicySetAttachPoint) {
- List<PolicySet> policySets =
((PolicySetAttachPoint)binding).getApplicablePolicySets();
- for (PolicySet ps : policySets) {
- for (Object p : ps.getPolicies()) {
- if (JDKLoggingPolicy.class.isInstance(p)) {
- return ps;
- }
- }
- }
- }
- return null;
- }
-
- private String getContext() {
- return "component.reference: " + component.getURI()
- + "#"
- + reference.getName()
- + "("
- + binding.getClass().getName()
- + ")";
- }
-
- /**
- * @see
org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation)
- */
- public Interceptor createInterceptor(Operation operation) {
- PolicySet ps = findPolicySet();
- return ps == null ? null : new
JDKLoggingPolicyInterceptor(getContext(), operation, ps);
- }
-
- /**
- * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase()
- */
- public String getPhase() {
- return Phase.REFERENCE_POLICY;
+ public JDKLoggingReferencePolicyProvider(EndpointReference
endpointReference) {
+ super(JDKLoggingPolicy.class, endpointReference);
}
}
Modified:
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java?rev=792346&r1=792319&r2=792346&view=diff
==============================================================================
---
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java
(original)
+++
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java
Wed Jul 8 22:50:59 2009
@@ -19,69 +19,25 @@
package org.apache.tuscany.sca.policy.logging.jdk;
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
-import org.apache.tuscany.sca.provider.PolicyProvider;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
/**
* @version $Rev$ $Date$
*/
-public class JDKLoggingServicePolicyProvider implements PolicyProvider {
- private RuntimeComponent component;
- private RuntimeComponentService service;
- private Binding binding;
-
- public JDKLoggingServicePolicyProvider(RuntimeComponent component,
RuntimeComponentService service, Binding binding) {
- super();
- this.component = component;
- this.service = service;
- this.binding = binding;
- }
-
- private PolicySet findPolicySet() {
- if (binding instanceof PolicySetAttachPoint) {
- List<PolicySet> policySets =
((PolicySetAttachPoint)binding).getApplicablePolicySets();
- for (PolicySet ps : policySets) {
- for (Object p : ps.getPolicies()) {
- if (JDKLoggingPolicy.class.isInstance(p)) {
- return ps;
- }
- }
- }
- }
- return null;
- }
+public class JDKLoggingServicePolicyProvider extends
BasePolicyProvider<JDKLoggingPolicy> {
- private String getContext() {
- return "component.service: " + component.getURI()
- + "#"
- + service.getName()
- + "("
- + binding.getClass().getName()
- + ")";
+ public JDKLoggingServicePolicyProvider(Endpoint endpoint) {
+ super(JDKLoggingPolicy.class, endpoint);
}
- /**
- * @see
org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation)
- */
- public Interceptor createInterceptor(Operation operation) {
+ public PhasedInterceptor createInterceptor(Operation operation) {
PolicySet ps = findPolicySet();
- return ps == null ? null : new
JDKLoggingPolicyInterceptor(getContext(), operation, ps);
- }
-
- /**
- * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase()
- */
- public String getPhase() {
- return Phase.SERVICE_POLICY;
+ return ps == null ? null : new
JDKLoggingPolicyInterceptor(getContext(), operation, ps, Phase.SERVICE_POLICY);
}
}
Added:
tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/definitions.xml
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/definitions.xml?rev=792346&view=auto
==============================================================================
---
tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/definitions.xml
(added)
+++
tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/definitions.xml
Wed Jul 8 22:50:59 2009
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <!-- Policy Intents Defined by the SCA Runtime -->
+ <intent name="logging" constrains="sca:implementation sca:binding">
+ <description>
+ All messages to and from this implementation must be
logged
+ </description>
+ </intent>
+</definitions>
\ No newline at end of file
Added:
tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions?rev=792346&view=auto
==============================================================================
---
tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
(added)
+++
tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
Wed Jul 8 22:50:59 2009
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+org/apache/tuscany/sca/policy/logging/definitions.xml
\ No newline at end of file