summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/policy-logging/src
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-10-16 05:42:26 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-10-16 05:42:26 +0000
commit4ae4002366ded3f4b19cd96f403d8b418fcf00a1 (patch)
tree9179891f11c9add734a777713cabf7e39a980908 /java/sca/modules/policy-logging/src
parentd4cc9a0bdd43477858b8ac67b69a4cdd615ec741 (diff)
This is to change the Monitor to be request scoped for most of the cases:
Refactor the ArtifactProcessor/ModelResolver to take a ProcessorContext that holds context such as Monitor, Contribution for the contribution/artifact processing methods Refactor the Builder to take a BuilderContext that holds context such as Monitor, Definitions, Base binding mapping for the building methods Change the processor/resolver/builder implementation classes to not cache the Monitor git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@825773 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/JDKLoggingPolicyBuilder.java9
-rw-r--r--java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java10
-rw-r--r--java/sca/modules/policy-logging/src/test/java/org/apache/tuscany/sca/policy/logging/jdk/PolicyReadTestCase.java15
3 files changed, 18 insertions, 16 deletions
diff --git a/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java b/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java
index 8560b41f57..be9a05982f 100644
--- a/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java
+++ b/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java
@@ -28,9 +28,8 @@ import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
import org.apache.tuscany.sca.assembly.builder.PolicyBuilder;
-import org.apache.tuscany.sca.definitions.Definitions;
-import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.policy.PolicyExpression;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.PolicySubject;
@@ -40,17 +39,17 @@ import org.apache.tuscany.sca.policy.PolicySubject;
*/
public class JDKLoggingPolicyBuilder implements PolicyBuilder<JDKLoggingPolicy> {
- public void build(Endpoint endpoint, Definitions definitions, Monitor monitor) {
+ public void build(Endpoint endpoint, BuilderContext context) {
List<JDKLoggingPolicy> polices = getPolicies(endpoint);
System.out.println(endpoint + ": " + polices);
}
- public void build(EndpointReference endpointReference, Definitions definitions, Monitor monitor) {
+ public void build(EndpointReference endpointReference, BuilderContext context) {
List<JDKLoggingPolicy> polices = getPolicies(endpointReference);
System.out.println(endpointReference + ": " + polices);
}
- public void build(Component component, Implementation implementation, Definitions definitions, Monitor monitor) {
+ public void build(Component component, Implementation implementation, BuilderContext context) {
List<JDKLoggingPolicy> polices = getPolicies(implementation);
System.out.println(implementation + ": " + polices);
}
diff --git a/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java b/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java
index 0254da7620..6ca5732e7a 100644
--- a/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java
+++ b/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java
@@ -31,10 +31,10 @@ import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.monitor.Monitor;
/**
*
@@ -50,11 +50,11 @@ public class JDKLoggingPolicyProcessor implements StAXArtifactProcessor<JDKLoggi
return JDK_LOGGING_POLICY_QNAME;
}
- public JDKLoggingPolicyProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
+ public JDKLoggingPolicyProcessor(FactoryExtensionPoint modelFactories) {
}
- public JDKLoggingPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ public JDKLoggingPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
JDKLoggingPolicy policy = new JDKLoggingPolicy();
int event = reader.getEventType();
QName name = null;
@@ -94,7 +94,7 @@ public class JDKLoggingPolicyProcessor implements StAXArtifactProcessor<JDKLoggi
return policy;
}
- public void write(JDKLoggingPolicy policy, XMLStreamWriter writer) throws ContributionWriteException,
+ public void write(JDKLoggingPolicy policy, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
XMLStreamException {
String prefix = "tuscany";
writer.writeStartElement(prefix,
@@ -128,7 +128,7 @@ public class JDKLoggingPolicyProcessor implements StAXArtifactProcessor<JDKLoggi
return JDKLoggingPolicy.class;
}
- public void resolve(JDKLoggingPolicy arg0, ModelResolver arg1) throws ContributionResolveException {
+ public void resolve(JDKLoggingPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
}
diff --git a/java/sca/modules/policy-logging/src/test/java/org/apache/tuscany/sca/policy/logging/jdk/PolicyReadTestCase.java b/java/sca/modules/policy-logging/src/test/java/org/apache/tuscany/sca/policy/logging/jdk/PolicyReadTestCase.java
index d5b1b9eedc..0000ec8c06 100644
--- a/java/sca/modules/policy-logging/src/test/java/org/apache/tuscany/sca/policy/logging/jdk/PolicyReadTestCase.java
+++ b/java/sca/modules/policy-logging/src/test/java/org/apache/tuscany/sca/policy/logging/jdk/PolicyReadTestCase.java
@@ -32,13 +32,16 @@ import javax.xml.stream.XMLStreamWriter;
import junit.framework.TestCase;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+
/**
* Test the reading of ws config params policy.
*
* @version $Rev$ $Date$
*/
public class PolicyReadTestCase extends TestCase {
-
+ private ProcessorContext context = new ProcessorContext();
+
@Override
public void setUp() throws Exception {
}
@@ -48,7 +51,7 @@ public class PolicyReadTestCase extends TestCase {
}
public void testPolicyReading() throws Exception {
- JDKLoggingPolicyProcessor processor = new JDKLoggingPolicyProcessor(null, null);
+ JDKLoggingPolicyProcessor processor = new JDKLoggingPolicyProcessor(null);
URL url = getClass().getResource("mock_policies.xml");
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
@@ -57,14 +60,14 @@ public class PolicyReadTestCase extends TestCase {
XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
- JDKLoggingPolicy policy = processor.read(reader);
+ JDKLoggingPolicy policy = processor.read(reader, context);
assertEquals(policy.getLoggerName(), "test.logger");
assertEquals(policy.getLogLevel(), Level.INFO );
assertEquals(policy.getResourceBundleName(), "Trace_Messages.properties");
}
public void testPolicyWriting() throws Exception {
- JDKLoggingPolicyProcessor processor = new JDKLoggingPolicyProcessor(null, null);
+ JDKLoggingPolicyProcessor processor = new JDKLoggingPolicyProcessor(null);
JDKLoggingPolicy policy = new JDKLoggingPolicy();
policy.setLoggerName("test.logger");
@@ -74,14 +77,14 @@ public class PolicyReadTestCase extends TestCase {
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
StringWriter sw = new StringWriter();
XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
- processor.write(policy, writer);
+ processor.write(policy, writer, context);
writer.close();
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
StringReader sr = new StringReader(sw.toString());
XMLStreamReader reader = inputFactory.createXMLStreamReader(sr);
- policy = processor.read(reader);
+ policy = processor.read(reader, context);
assertEquals(policy.getLoggerName(), "test.logger");
assertEquals(policy.getLogLevel(), Level.INFO );
assertEquals(policy.getResourceBundleName(), "Trace_Messages.properties");