You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2007/07/09 22:32:44 UTC
svn commit: r554755 - in
/incubator/tuscany/java/sca/modules/implementation-das/src/main:
java/org/apache/tuscany/sca/implementation/das/
java/org/apache/tuscany/sca/implementation/das/impl/
java/org/apache/tuscany/sca/implementation/das/module/ resour...
Author: lresende
Date: Mon Jul 9 13:32:42 2007
New Revision: 554755
URL: http://svn.apache.org/viewvc?view=rev&rev=554755
Log:
Renaming ImplementationProcessor to ArtifactProcessor and other minor simplifications
Added:
incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASArtifactProcessor.java
incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementation.java
incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASModuleActivator.java
- copied, changed from r554533, incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/module/DASModuleActivator.java
Removed:
incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/impl/DASImplementationImpl.java
incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/impl/DASImplementationProcessor.java
incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/module/DASModuleActivator.java
Modified:
incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DefaultDASImplementationFactory.java
incubator/tuscany/java/sca/modules/implementation-das/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
Added: incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASArtifactProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASArtifactProcessor.java?view=auto&rev=554755
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASArtifactProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASArtifactProcessor.java Mon Jul 9 13:32:42 2007
@@ -0,0 +1,101 @@
+/*
+ * 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.implementation.das;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+
+
+/**
+ * Implements a STAX artifact processor for DAS implementations.
+ *
+ * The artifact processor is responsible for processing <implementation.das>
+ * elements in SCA assembly XML composite files and populating the DAS
+ * implementation model, resolving its references to other artifacts in the SCA
+ * contribution, and optionally write the model back to SCA assembly XML.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DASArtifactProcessor implements StAXArtifactProcessor<DASImplementation> {
+ private static final QName IMPLEMENTATION_DAS = new QName(Constants.SCA10_NS, "implementation.das");
+
+ private DASImplementationFactory dasFactory;
+
+ public DASArtifactProcessor(DASImplementationFactory crudFactory) {
+ this.dasFactory = crudFactory;
+ }
+
+ public QName getArtifactType() {
+ // Returns the qname of the XML element processed by this processor
+ return IMPLEMENTATION_DAS;
+ }
+
+ public Class<DASImplementation> getModelType() {
+ // Returns the type of model processed by this processor
+ return DASImplementation.class;
+ }
+
+ public DASImplementation read(XMLStreamReader reader) throws ContributionReadException {
+ assert IMPLEMENTATION_DAS.equals(reader.getName());
+
+ // Read an <implementation.crud> element
+ try {
+ // Read the das config file attribute.
+ // This is das configuration side file to use
+ String config = reader.getAttributeValue(null, "config");
+
+ // Read the data access type attribute
+ // This is the type of data store in use (e.g rdb, xml, etc)
+ String dataAccessType = reader.getAttributeValue(null, "dataAccessType");
+
+ // Create an initialize the DAS implementation model
+ DASImplementation implementation = dasFactory.createDASImplementation();
+ implementation.setConfig(config);
+ implementation.setDataAccessType(dataAccessType);
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && IMPLEMENTATION_DAS.equals(reader.getName())) {
+ break;
+ }
+ }
+
+ return implementation;
+ } catch (XMLStreamException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+ public void resolve(DASImplementation impl, ModelResolver resolver) throws ContributionResolveException {
+ }
+
+ public void write(DASImplementation model, XMLStreamWriter outputSource) throws ContributionWriteException {
+ }
+}
Added: incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementation.java?view=auto&rev=554755
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementation.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementation.java Mon Jul 9 13:32:42 2007
@@ -0,0 +1,145 @@
+/*
+ * 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.implementation.das;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceIntrospector;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+
+/**
+ * The model representing a sample DAS implementation in an SCA assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DASImplementation implements Implementation {
+
+ private Service dasService;
+ private String dasConfig;
+ private String dataAccessType;
+
+ /**
+ * Constructs a new DAS implementation.
+ */
+ public DASImplementation(AssemblyFactory assemblyFactory,
+ JavaInterfaceFactory javaFactory,
+ JavaInterfaceIntrospector introspector) {
+
+ // DAS implementation always provide a single service exposing
+ // the DAS interface, and have no references and properties
+ dasService = assemblyFactory.createService();
+ dasService.setName("DAS");
+ JavaInterface javaInterface;
+ try {
+ javaInterface = introspector.introspect(DAS.class);
+ } catch (InvalidInterfaceException e) {
+ throw new IllegalArgumentException(e);
+ }
+ JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+ interfaceContract.setInterface(javaInterface);
+ dasService.setInterfaceContract(interfaceContract);
+ }
+
+ public String getConfig() {
+ return this.dasConfig;
+ }
+
+ public void setConfig(String config) {
+ this.dasConfig = config;
+ }
+
+ public String getDataAccessType() {
+ return this.dataAccessType;
+ }
+
+ public void setDataAccessType (String dataAccessType) {
+ this.dataAccessType = dataAccessType;
+ }
+
+ public ConstrainingType getConstrainingType() {
+ // The sample DAS implementation does not support constrainingTypes
+ return null;
+ }
+
+ public List<Property> getProperties() {
+ // The sample DAS implementation does not support properties
+ return Collections.emptyList();
+ }
+
+ public List<Service> getServices() {
+ // The sample DAS implementation provides a single fixed CRUD service
+ return Collections.singletonList(dasService);
+ }
+
+ public List<Reference> getReferences() {
+ // The sample DAS implementation does not support properties
+ return Collections.emptyList();
+ }
+
+ public String getURI() {
+ // The sample DAS implementation does not have a URI
+ return null;
+ }
+
+ public void setConstrainingType(ConstrainingType constrainingType) {
+ // The sample DAS implementation does not support constrainingTypes
+ }
+
+ public void setURI(String uri) {
+ // The sample DAS implementation does not have a URI
+ }
+
+ public List<PolicySet> getPolicySets() {
+ // The sample DAS implementation does not support policy sets
+ return Collections.emptyList();
+ }
+
+ public List<Intent> getRequiredIntents() {
+ // The sample DAS implementation does not support intents
+ return Collections.emptyList();
+ }
+
+ public List<Object> getExtensions() {
+ // The sample DAS implementation does not support extensions
+ return Collections.emptyList();
+ }
+
+ public boolean isUnresolved() {
+ // The sample DAS implementation is always resolved
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The sample DAS implementation is always resolved
+ }
+
+}
Copied: incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASModuleActivator.java (from r554533, incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/module/DASModuleActivator.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASModuleActivator.java?view=diff&rev=554755&p1=incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/module/DASModuleActivator.java&r1=554533&p2=incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASModuleActivator.java&r2=554755
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/module/DASModuleActivator.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASModuleActivator.java Mon Jul 9 13:32:42 2007
@@ -17,16 +17,13 @@
* under the License.
*/
-package org.apache.tuscany.sca.implementation.das.module;
+package org.apache.tuscany.sca.implementation.das;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.core.ModuleActivator;
-import org.apache.tuscany.sca.implementation.das.DASImplementationFactory;
-import org.apache.tuscany.sca.implementation.das.DefaultDASImplementationFactory;
-import org.apache.tuscany.sca.implementation.das.impl.DASImplementationProcessor;
import org.apache.tuscany.sca.implementation.das.provider.DASImplementationProviderFactory;
import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
@@ -61,7 +58,7 @@
// Add the CRUD implementation extension to the StAXArtifactProcessor
// extension point
StAXArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
- DASImplementationProcessor implementationArtifactProcessor = new DASImplementationProcessor(crudFactory);
+ DASArtifactProcessor implementationArtifactProcessor = new DASArtifactProcessor(crudFactory);
processors.addArtifactProcessor(implementationArtifactProcessor);
// Add the CRUD provider factory to the ProviderFactory extension point
Modified: incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DefaultDASImplementationFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DefaultDASImplementationFactory.java?view=diff&rev=554755&r1=554754&r2=554755
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DefaultDASImplementationFactory.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DefaultDASImplementationFactory.java Mon Jul 9 13:32:42 2007
@@ -20,7 +20,6 @@
package org.apache.tuscany.sca.implementation.das;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.implementation.das.impl.DASImplementationImpl;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceIntrospector;
@@ -45,7 +44,7 @@
}
public DASImplementation createDASImplementation() {
- return new DASImplementationImpl(assemblyFactory, javaFactory, introspector);
+ return new DASImplementation(assemblyFactory, javaFactory, introspector);
}
}
Modified: incubator/tuscany/java/sca/modules/implementation-das/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-das/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator?view=diff&rev=554755&r1=554754&r2=554755
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-das/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator (original)
+++ incubator/tuscany/java/sca/modules/implementation-das/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator Mon Jul 9 13:32:42 2007
@@ -17,4 +17,4 @@
#
# Implementation class for the ExtensionActivator
#
-org.apache.tuscany.sca.implementation.das.module.DASModuleActivator
+org.apache.tuscany.sca.implementation.das.DASModuleActivator
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org