summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/policy-transaction/src
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-03-04 01:19:55 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-03-04 01:19:55 +0000
commitea934f27ae0c4de4ca7cfa8771b220b315684b3c (patch)
tree24a74e62025081080217546bdd48ce233865f5d5 /sca-java-2.x/trunk/modules/policy-transaction/src
parentbfbb439e09596671c3019e3f53da16792e9b8c95 (diff)
Providing TransactionPolicyFactory and avoiding direct access to TransactionPolicyImpl following pattern used in other tuscany modules
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@918808 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/policy-transaction/src')
-rw-r--r--sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyFactory.java34
-rw-r--r--sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyProcessor.java17
-rw-r--r--sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/impl/TransactionPolicyFactoryImpl.java36
-rw-r--r--sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/impl/TransactionPolicyImpl.java (renamed from sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyImpl.java)5
-rw-r--r--sca-java-2.x/trunk/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.transaction.TransactionPolicyFactory19
-rw-r--r--sca-java-2.x/trunk/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/PolicyReadTestCase.java6
6 files changed, 108 insertions, 9 deletions
diff --git a/sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyFactory.java b/sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyFactory.java
new file mode 100644
index 0000000000..f0567f47e0
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyFactory.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+package org.apache.tuscany.sca.policy.transaction;
+
+/**
+ * Factory for Policy Transaction
+ *
+ * @version $Rev$ $Date$
+ */
+public interface TransactionPolicyFactory {
+
+ /**
+ * Creates a new Transaction Policy
+ * @return the new Transaction policy
+ */
+ TransactionPolicy createTransactionPolicy();
+}
diff --git a/sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyProcessor.java b/sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyProcessor.java
index 341cfc0016..d6818c9b98 100644
--- a/sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyProcessor.java
+++ b/sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyProcessor.java
@@ -32,6 +32,7 @@ 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.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
@@ -42,15 +43,23 @@ public class TransactionPolicyProcessor implements StAXArtifactProcessor<Transac
public static final String TIMEOUT = "transactionTimeout";
public static final String ACTION = "action";
+ TransactionPolicyFactory transactionPolicyFactory;
+
public QName getArtifactType() {
return TransactionPolicy.NAME;
}
- public TransactionPolicyProcessor(FactoryExtensionPoint modelFactories) {
+ public Class<TransactionPolicy> getModelType() {
+ return TransactionPolicy.class;
+ }
+
+ public TransactionPolicyProcessor(ExtensionPointRegistry extensions) {
+ FactoryExtensionPoint factories = extensions.getExtensionPoint(FactoryExtensionPoint.class);
+ transactionPolicyFactory = factories.getFactory(TransactionPolicyFactory.class);
}
public TransactionPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
- TransactionPolicy txPolicy = new TransactionPolicyImpl();
+ TransactionPolicy txPolicy = transactionPolicyFactory.createTransactionPolicy();
int event = reader.getEventType();
while (reader.hasNext()) {
event = reader.getEventType();
@@ -88,10 +97,6 @@ public class TransactionPolicyProcessor implements StAXArtifactProcessor<Transac
// TODO
}
- public Class<TransactionPolicy> getModelType() {
- return TransactionPolicy.class;
- }
-
public void resolve(TransactionPolicy policy, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
// TODO
}
diff --git a/sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/impl/TransactionPolicyFactoryImpl.java b/sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/impl/TransactionPolicyFactoryImpl.java
new file mode 100644
index 0000000000..6a4325fa4d
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/impl/TransactionPolicyFactoryImpl.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+package org.apache.tuscany.sca.policy.transaction.impl;
+
+import org.apache.tuscany.sca.policy.transaction.TransactionPolicy;
+import org.apache.tuscany.sca.policy.transaction.TransactionPolicyFactory;
+
+/**
+ * Implementation for Transaction Policy factory
+ *
+ * @version $Rev$ $Date$
+ */
+public class TransactionPolicyFactoryImpl implements TransactionPolicyFactory {
+
+ public TransactionPolicy createTransactionPolicy() {
+ return new TransactionPolicyImpl();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyImpl.java b/sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/impl/TransactionPolicyImpl.java
index f178876a72..1101790a6a 100644
--- a/sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyImpl.java
+++ b/sca-java-2.x/trunk/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/impl/TransactionPolicyImpl.java
@@ -17,10 +17,13 @@
* under the License.
*/
-package org.apache.tuscany.sca.policy.transaction;
+package org.apache.tuscany.sca.policy.transaction.impl;
import javax.xml.namespace.QName;
+import org.apache.tuscany.sca.policy.transaction.TransactionPolicy;
+import org.apache.tuscany.sca.policy.transaction.TransactionPolicy.Action;
+
/**
* @version $Rev$ $Date$
*/
diff --git a/sca-java-2.x/trunk/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.transaction.TransactionPolicyFactory b/sca-java-2.x/trunk/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.transaction.TransactionPolicyFactory
new file mode 100644
index 0000000000..5b37ba4171
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.transaction.TransactionPolicyFactory
@@ -0,0 +1,19 @@
+# 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.
+
+# Implementation class for the model factory
+org.apache.tuscany.sca.policy.transaction.impl.TransactionPolicyFactoryImpl
diff --git a/sca-java-2.x/trunk/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/PolicyReadTestCase.java b/sca-java-2.x/trunk/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/PolicyReadTestCase.java
index 345dbaef8e..fd3e0a7968 100644
--- a/sca-java-2.x/trunk/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/PolicyReadTestCase.java
+++ b/sca-java-2.x/trunk/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/PolicyReadTestCase.java
@@ -25,6 +25,8 @@ import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import junit.framework.TestCase;
@@ -40,8 +42,8 @@ public class PolicyReadTestCase extends TestCase {
}
public void testPolicyReading() throws Exception {
-
- TransactionPolicyProcessor processor = new TransactionPolicyProcessor(null);
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ TransactionPolicyProcessor processor = new TransactionPolicyProcessor(extensionPoints);
URL url = getClass().getResource("/org/apache/tuscany/sca/policy/transaction/definitions.xml");
XMLInputFactory inputFactory = XMLInputFactory.newInstance();