You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by me...@apache.org on 2007/02/09 10:07:15 UTC
svn commit: r505222 - in /incubator/tuscany/java/sca/kernel:
core/src/main/java/org/apache/tuscany/core/component/
core/src/main/java/org/apache/tuscany/core/marshaller/
core/src/test/java/org/apache/tuscany/core/marshaller/
spi/src/main/java/org/apach...
Author: meerajk
Date: Fri Feb 9 01:07:14 2007
New Revision: 505222
URL: http://svn.apache.org/viewvc?view=rev&rev=505222
Log:
added wire and interceptor definitions to physical component definition
Added:
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/InterceptorDefinition.java (with props)
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/WireDefinition.java (with props)
Modified:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/JavaPhysicalComponentDefinition.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/marshaller/JavaPhysicalComponentDefinitionMarshaller.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/marshaller/JavaPhysicalComponentDefinitionMarshallerTestCase.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/PhysicalComponentDefinition.java
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/JavaPhysicalComponentDefinition.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/JavaPhysicalComponentDefinition.java?view=diff&rev=505222&r1=505221&r2=505222
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/JavaPhysicalComponentDefinition.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/JavaPhysicalComponentDefinition.java Fri Feb 9 01:07:14 2007
@@ -18,6 +18,8 @@
*/
package org.apache.tuscany.core.component;
+import java.net.URI;
+
import org.apache.tuscany.spi.model.physical.PhysicalComponentDefinition;
/**
@@ -30,6 +32,14 @@
// The byte code for the instance factory
private byte[] instanceFactoryByteCode;
+
+ /**
+ * Initializes the component id.
+ * @param componentId The component id.
+ */
+ public JavaPhysicalComponentDefinition(final URI componentId) {
+ super(componentId);
+ }
/**
* Gets the byte code for the instance factory.
@@ -44,7 +54,12 @@
* @param instanceFactoryByteCode Byte code for the instance factory.
*/
public void setInstanceFactoryByteCode(byte[] instanceFactoryByteCode) {
+
+ if(instanceFactoryByteCode == null) {
+ throw new IllegalArgumentException("Instance factory byte code is null");
+ }
this.instanceFactoryByteCode = instanceFactoryByteCode;
+
}
}
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/marshaller/JavaPhysicalComponentDefinitionMarshaller.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/marshaller/JavaPhysicalComponentDefinitionMarshaller.java?view=diff&rev=505222&r1=505221&r2=505222
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/marshaller/JavaPhysicalComponentDefinitionMarshaller.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/marshaller/JavaPhysicalComponentDefinitionMarshaller.java Fri Feb 9 01:07:14 2007
@@ -104,12 +104,15 @@
public JavaPhysicalComponentDefinition unmarshall(XMLStreamReader reader) throws MarshalException {
try {
- JavaPhysicalComponentDefinition definition = new JavaPhysicalComponentDefinition();
+
+ JavaPhysicalComponentDefinition definition = null;
+
for (int i = reader.next(); i != END_DOCUMENT; i = reader.next()) {
switch (i) {
case START_ELEMENT:
if (reader.getName().equals(MESSAGE_TYPE)) {
- setComponentId(reader, definition);
+ final URI componentId = getComponentId(reader);
+ definition = new JavaPhysicalComponentDefinition(componentId);
} else if (reader.getName().equals(INSTANCE_FACTORY_BYTE_CODE)) {
setInstanceFactoryByteCode(reader, definition);
}
@@ -117,7 +120,7 @@
}
}
- if (definition.getComponentId() == null || definition.getInstanceFactoryByteCode() == null) {
+ if (definition == null || definition.getInstanceFactoryByteCode() == null) {
throw new MarshalException("Invalid component definition");
}
@@ -142,12 +145,12 @@
}
/*
- * Sets the component id.
+ * Gets the component id.
*/
- private void setComponentId(XMLStreamReader reader, JavaPhysicalComponentDefinition definition)
+ private URI getComponentId(XMLStreamReader reader)
throws URISyntaxException {
final String uri = reader.getAttributeValue(null, COMPONENT_ID);
- definition.setComponentId(new URI(uri));
+ return new URI(uri);
}
}
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/marshaller/JavaPhysicalComponentDefinitionMarshallerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/marshaller/JavaPhysicalComponentDefinitionMarshallerTestCase.java?view=diff&rev=505222&r1=505221&r2=505222
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/marshaller/JavaPhysicalComponentDefinitionMarshallerTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/marshaller/JavaPhysicalComponentDefinitionMarshallerTestCase.java Fri Feb 9 01:07:14 2007
@@ -69,8 +69,7 @@
ByteArrayOutputStream out = new ByteArrayOutputStream();
- JavaPhysicalComponentDefinition definition = new JavaPhysicalComponentDefinition();
- definition.setComponentId(new URI("uri"));
+ JavaPhysicalComponentDefinition definition = new JavaPhysicalComponentDefinition(new URI("uri"));
definition.setInstanceFactoryByteCode("TEST".getBytes());
XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(out, "UTF-8");
Added: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/InterceptorDefinition.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/InterceptorDefinition.java?view=auto&rev=505222
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/InterceptorDefinition.java (added)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/InterceptorDefinition.java Fri Feb 9 01:07:14 2007
@@ -0,0 +1,31 @@
+/*
+ * 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.spi.model.physical;
+
+/**
+ * Model class representing the portable definition of an interceptor. This class
+ * is used to describe the interceptors around inbound and outbound wires on a
+ * physical component definition.
+ *
+ * @version $Rev$ $Date$
+ *
+ */
+public class InterceptorDefinition {
+
+}
Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/InterceptorDefinition.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/InterceptorDefinition.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/PhysicalComponentDefinition.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/PhysicalComponentDefinition.java?view=diff&rev=505222&r1=505221&r2=505222
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/PhysicalComponentDefinition.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/PhysicalComponentDefinition.java Fri Feb 9 01:07:14 2007
@@ -19,6 +19,9 @@
package org.apache.tuscany.spi.model.physical;
import java.net.URI;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
import org.apache.tuscany.spi.model.ModelObject;
@@ -29,7 +32,28 @@
*
*/
public abstract class PhysicalComponentDefinition extends ModelObject {
- private URI componentId;
+
+ // Component Id.
+ private final URI componentId;
+
+ // Inbound wires
+ private final Set<WireDefinition> inboundWires = new HashSet<WireDefinition>();
+
+ // Outbound wires
+ private final Set<WireDefinition> outboundWires = new HashSet<WireDefinition>();
+
+ /**
+ * Initializes the component id.
+ * @param componentId The component id.
+ */
+ public PhysicalComponentDefinition(final URI componentId) {
+
+ if(componentId == null) {
+ throw new IllegalArgumentException("Component id is null");
+ }
+ this.componentId = componentId;
+
+ }
/**
* Returns the absolute id for the phyiscal component.
@@ -38,12 +62,47 @@
public URI getComponentId() {
return componentId;
}
-
+
/**
- * Sets the absolute id for the phyiscal component.
- * @param componentId the absolute id for the phyiscal component
+ * Returns a read-only view of the inbound wires.
+ * @return List of inbound wires available on the component.
*/
- public void setComponentId(URI componentId) {
- this.componentId = componentId;
+ public Set<WireDefinition> getInboundWires() {
+ return Collections.unmodifiableSet(inboundWires);
+ }
+
+ /**
+ * Adds an inbound wire.
+ * @param inboundWire Inbound wire to add to the component.
+ */
+ public void addInboundWire(WireDefinition inboundWire) {
+
+ if(inboundWire == null) {
+ throw new IllegalArgumentException("Inbound wire is null");
+ }
+ inboundWires.add(inboundWire);
+
+ }
+
+ /**
+ * Returns a read-only view of the outbound wires.
+ * @return List of outbound wires available on the component.
+ */
+ public Set<WireDefinition> getOutboundWires() {
+ return Collections.unmodifiableSet(outboundWires);
+ }
+
+ /**
+ * Adds an outbound wire.
+ * @param outboundWire Outbound wire to add to the component.
+ */
+ public void addOutboundWire(WireDefinition outboundWire) {
+
+ if(outboundWire == null) {
+ throw new IllegalArgumentException("Outbound wire is null");
+ }
+ outboundWires.add(outboundWire);
+
}
+
}
Added: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/WireDefinition.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/WireDefinition.java?view=auto&rev=505222
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/WireDefinition.java (added)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/WireDefinition.java Fri Feb 9 01:07:14 2007
@@ -0,0 +1,84 @@
+/*
+ * 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.spi.model.physical;
+
+import java.net.URI;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Model class representing the portable definition of a wire. This class
+ * is used to describe the inbound and outbound wires on a physical
+ * component definition.
+ *
+ * @version $Rev$ $Date$
+ *
+ */
+public class WireDefinition {
+
+ // The resolved URI of the wire
+ private final URI wireUri;
+
+ // Interceptors defined against the wire
+ private final Set<InterceptorDefinition> interceptors = new HashSet<InterceptorDefinition>();
+
+ /**
+ * Initializes the wire URI.
+ * @param wireUri The resolved URI of the wire.
+ */
+ public WireDefinition(final URI wireUri) {
+
+ if(wireUri == null) {
+ throw new IllegalArgumentException("Wire uri is null");
+ }
+ this.wireUri = wireUri;
+
+ }
+
+ /**
+ * Returns a read-only view of the available interceptors.
+ * @return List of interceptors available on the wire.
+ */
+ public Set<InterceptorDefinition> getInterceptors() {
+ return Collections.unmodifiableSet(interceptors);
+ }
+
+ /**
+ * Adds an interceptor definition.
+ * @param interceptorDefinition Interceptor definition to add to the wire.
+ */
+ public void addInterceptor(InterceptorDefinition interceptorDefinition) {
+
+ if(interceptorDefinition == null) {
+ throw new IllegalArgumentException("Interceptor definition is null");
+ }
+ interceptors.add(interceptorDefinition);
+
+ }
+
+ /**
+ * Returns the wire URI.
+ * @return The resolved URI of the wire.
+ */
+ public URI getWireUri() {
+ return wireUri;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/WireDefinition.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/physical/WireDefinition.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org