summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/policy-logging/src
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-07-09 18:14:18 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-07-09 18:14:18 +0000
commit274c7b6bba7c87e78318f980c84ac5741054817b (patch)
tree7aa59ca537420cb9c2b615adcf9cea0d6a947489 /java/sca/modules/policy-logging/src
parente4a17acd7ffa7c65c1ec1b4f23d1b39c93086f17 (diff)
Use the list of policies instead of policySet to drive the logging
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@792622 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/policy-logging/src')
-rw-r--r--java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java9
-rw-r--r--java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java49
-rw-r--r--java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java5
-rw-r--r--java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java17
-rw-r--r--java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java7
5 files changed, 49 insertions, 38 deletions
diff --git a/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java b/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java
index 863d80a17c..85ce106048 100644
--- a/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java
+++ b/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java
@@ -19,10 +19,11 @@
package org.apache.tuscany.sca.policy.logging.jdk;
+import java.util.List;
+
import org.apache.tuscany.sca.interfacedef.Operation;
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.BasePolicyProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -39,9 +40,9 @@ public class JDKLoggingImplementationPolicyProvider extends BasePolicyProvider<J
* @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation)
*/
public PhasedInterceptor createInterceptor(Operation operation) {
- PolicySet ps = findPolicySet();
- return ps == null ? null : new JDKLoggingPolicyInterceptor(getContext(), operation, ps,
- Phase.IMPLEMENTATION_POLICY);
+ List<JDKLoggingPolicy> policies = findPolicies();
+ return policies.isEmpty() ? null : new JDKLoggingPolicyInterceptor(getContext(), operation, policies,
+ Phase.IMPLEMENTATION_POLICY);
}
}
diff --git a/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java b/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java
index fbcb293513..9200bfdd70 100644
--- a/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java
+++ b/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java
@@ -18,6 +18,7 @@
*/
package org.apache.tuscany.sca.policy.logging.jdk;
+import java.util.List;
import java.util.logging.ConsoleHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
@@ -29,7 +30,6 @@ import org.apache.tuscany.sca.interfacedef.Operation;
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;
/**
* Policy handler to handle PolicySet related to Logging with the QName
@@ -44,39 +44,44 @@ public class JDKLoggingPolicyInterceptor implements PhasedInterceptor {
private Invoker next;
private Operation operation;
- private PolicySet policySet = null;
+ private List<JDKLoggingPolicy> policies;
private String context;
private String phase;
- public JDKLoggingPolicyInterceptor(String context, Operation operation, PolicySet policySet, String phase) {
+ public JDKLoggingPolicyInterceptor(String context,
+ Operation operation,
+ List<JDKLoggingPolicy> policies,
+ String phase) {
super();
this.operation = operation;
- this.policySet = policySet;
+ this.policies = policies;
this.context = context;
this.phase = phase;
init();
}
+ public void start() {
+ init();
+ }
+
private void init() {
- if (policySet != null) {
- JDKLoggingPolicy policy = (JDKLoggingPolicy)policySet.getPolicies().get(0);
- logger = Logger.getLogger(policy.getLoggerName());
- logger.setLevel(policy.getLogLevel());
- logger.setUseParentHandlers(policy.isUseParentHandlers());
-
- boolean found = false;
- for (Handler handler : logger.getHandlers()) {
- if (handler instanceof ConsoleHandler) {
- found = true;
- break;
- }
+ JDKLoggingPolicy policy = policies.get(0);
+ logger = Logger.getLogger(policy.getLoggerName());
+ logger.setLevel(policy.getLogLevel());
+ logger.setUseParentHandlers(policy.isUseParentHandlers());
+
+ boolean found = false;
+ for (Handler handler : logger.getHandlers()) {
+ if (handler instanceof ConsoleHandler) {
+ found = true;
+ break;
}
+ }
- if (!found) {
- ConsoleHandler consoleHandler = new ConsoleHandler();
- consoleHandler.setLevel(Level.ALL);
- logger.addHandler(consoleHandler);
- }
+ if (!found) {
+ ConsoleHandler consoleHandler = new ConsoleHandler();
+ consoleHandler.setLevel(Level.ALL);
+ logger.addHandler(consoleHandler);
}
}
@@ -132,5 +137,5 @@ public class JDKLoggingPolicyInterceptor implements PhasedInterceptor {
public String getPhase() {
return phase;
}
-
+
}
diff --git a/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java b/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java
index 80d70fed63..62bf06475b 100644
--- a/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java
+++ b/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java
@@ -61,9 +61,8 @@ public class JDKLoggingPolicyProviderFactory implements PolicyProviderFactory<JD
/**
* @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
*/
- public Class getModelType() {
- // TODO Auto-generated method stub
- return null;
+ public Class<JDKLoggingPolicy> getModelType() {
+ return JDKLoggingPolicy.class;
}
}
diff --git a/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java b/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java
index a02668f309..b10fd7345a 100644
--- a/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java
+++ b/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java
@@ -19,22 +19,27 @@
package org.apache.tuscany.sca.policy.logging.jdk;
-import org.apache.tuscany.sca.assembly.Binding;
+import java.util.List;
+
import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
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 extends BasePolicyProvider<JDKLoggingPolicy> {
- private RuntimeComponent component;
- private RuntimeComponentReference reference;
- private Binding binding;
public JDKLoggingReferencePolicyProvider(EndpointReference endpointReference) {
super(JDKLoggingPolicy.class, endpointReference);
}
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ List<JDKLoggingPolicy> policies = findPolicies();
+ return policies.isEmpty() ? null : new JDKLoggingPolicyInterceptor(getContext(), operation, policies,
+ Phase.REFERENCE_POLICY);
+ }
+
}
diff --git a/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java b/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java
index c500f8e281..1af1d05fe8 100644
--- a/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java
+++ b/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java
@@ -19,11 +19,12 @@
package org.apache.tuscany.sca.policy.logging.jdk;
+import java.util.List;
+
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.interfacedef.Operation;
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.BasePolicyProvider;
/**
@@ -36,8 +37,8 @@ public class JDKLoggingServicePolicyProvider extends BasePolicyProvider<JDKLoggi
}
public PhasedInterceptor createInterceptor(Operation operation) {
- PolicySet ps = findPolicySet();
- return ps == null ? null : new JDKLoggingPolicyInterceptor(getContext(), operation, ps, Phase.SERVICE_POLICY);
+ List<JDKLoggingPolicy> policies = findPolicies();
+ return policies.isEmpty() ? null : new JDKLoggingPolicyInterceptor(getContext(), operation, policies, Phase.SERVICE_POLICY);
}
}