You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2007/03/12 06:29:53 UTC
svn commit: r517102 - in
/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core:
implementation/java/ marshaller/extensions/java/ model/physical/java/
Author: jboynes
Date: Sun Mar 11 22:29:52 2007
New Revision: 517102
URL: http://svn.apache.org/viewvc?view=rev&rev=517102
Log:
replace bytecode in JavaPCD with a provider
comment out marshalling code for now
Modified:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaPhysicalComponentBuilder.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/marshaller/extensions/java/JavaPhysicalComponentDefinitionMarshaller.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/model/physical/java/JavaPhysicalComponentDefinition.java
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaPhysicalComponentBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaPhysicalComponentBuilder.java?view=diff&rev=517102&r1=517101&r2=517102
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaPhysicalComponentBuilder.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaPhysicalComponentBuilder.java Sun Mar 11 22:29:52 2007
@@ -20,6 +20,8 @@
import java.net.URI;
+import org.osoa.sca.annotations.Reference;
+
import org.apache.tuscany.core.builder.physical.AbstractPhysicalComponentBuilder;
import org.apache.tuscany.core.component.InstanceFactory;
import org.apache.tuscany.core.model.physical.java.JavaPhysicalComponentDefinition;
@@ -31,26 +33,25 @@
import org.apache.tuscany.spi.model.Scope;
import org.apache.tuscany.spi.services.classloading.ClassLoaderRegistry;
import org.apache.tuscany.spi.wire.physical.WireAttacher;
-import org.osoa.sca.annotations.Reference;
/**
* Java physical component builder.
- *
- * @version $Rev$ $Date$
*
+ * @version $Rev$ $Date$
*/
public class JavaPhysicalComponentBuilder extends
AbstractPhysicalComponentBuilder<JavaPhysicalComponentDefinition, JavaComponent>
- implements WireAttacher<JavaComponent, JavaPhysicalWireSourceDefinition, JavaPhysicalWireTargetDefinition>{
-
+ implements WireAttacher<JavaComponent, JavaPhysicalWireSourceDefinition, JavaPhysicalWireTargetDefinition> {
+
// Classloader registry
private ClassLoaderRegistry classLoaderRegistry;
-
+
// SCope registry
private ScopeRegistry scopeRegistry;
-
+
/**
* Gets the physical component definition this builder expects.
+ *
* @return Physical component definition class.
*/
protected Class<JavaPhysicalComponentDefinition> getComponentType() {
@@ -59,25 +60,26 @@
/**
* Builds a component from its physical component definition.
- *
+ *
* @param componentDefinition Physical component definition of the component
- * to be built.
+ * to be built.
* @return A component instance that is ready to go live.
* @throws BuilderException If unable to build the component.
*/
public JavaComponent build(JavaPhysicalComponentDefinition componentDefinition) throws BuilderException {
-
+
JavaComponent component = new JavaComponent();
-
+
setScopeContainer(componentDefinition, component);
setInstanceFactoryClass(componentDefinition, component);
-
+
return component;
}
/**
* Injects classloader registry.
+ *
* @param classLoaderRegistry Class loader registry.
*/
@Reference
@@ -87,6 +89,7 @@
/**
* Injects scope registry.
+ *
* @param scopeRegistry Scope registry.
*/
@Reference
@@ -100,11 +103,13 @@
private void setInstanceFactoryClass(JavaPhysicalComponentDefinition componentDefinition, JavaComponent component) {
// TODO use MPCL to load IF class
URI classLoaderId = componentDefinition.getClassLoaderId();
+/*
byte[] instanceFactoryByteCode = componentDefinition.getInstanceFactoryByteCode(); //NOPMD
+*/
ClassLoader appCl = classLoaderRegistry.getClassLoader(classLoaderId); //NOPMD
ClassLoader systemCl = getClass().getClassLoader(); //NOPMD
ClassLoader mpcl = null; //NOPMD
- Class<InstanceFactory<?>> instanceFactoryClass = null;
+ Class<InstanceFactory<?>> instanceFactoryClass = null;
component.setInstanceFactoryClass(instanceFactoryClass);
}
@@ -119,20 +124,20 @@
/**
* Attaches the source to the component.
- *
+ *
* @param component Component.
- * @param source Source.
+ * @param source Source.
*/
public void attach(JavaComponent component, JavaPhysicalWireSourceDefinition source) {
}
/**
* Attaches the target to the component.
- *
+ *
* @param component Component.
- * @param target Target.
+ * @param target Target.
*/
public void attach(JavaComponent component, JavaPhysicalWireTargetDefinition target) {
- }
+ }
}
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/marshaller/extensions/java/JavaPhysicalComponentDefinitionMarshaller.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/marshaller/extensions/java/JavaPhysicalComponentDefinitionMarshaller.java?view=diff&rev=517102&r1=517101&r2=517102
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/marshaller/extensions/java/JavaPhysicalComponentDefinitionMarshaller.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/marshaller/extensions/java/JavaPhysicalComponentDefinitionMarshaller.java Sun Mar 11 22:29:52 2007
@@ -20,13 +20,11 @@
import java.net.URI;
import java.net.URISyntaxException;
-
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
-import org.apache.commons.codec.binary.Base64;
import org.apache.tuscany.core.marshaller.PhysicalChangeSetMarshaller;
import org.apache.tuscany.core.marshaller.extensions.AbstractPhysicalComponentDefinitionMarshaller;
import org.apache.tuscany.core.model.physical.java.JavaPhysicalComponentDefinition;
@@ -35,7 +33,7 @@
/**
* Marshaller for Java physical component definitions.
- *
+ *
* @version $Revision$ $Date: 2007-03-03 16:41:22 +0000 (Sat, 03 Mar
* 2007) $
*/
@@ -44,12 +42,14 @@
// Core marshaller namespace
public static final String JAVA_NS = "http://tuscany.apache.org/xmlns/marshaller/java/1.0-SNAPSHOT";
-
+
// Core marshaller prefix
public static final String JAVA_PREFIX = "java";
-
+
+/*
// Instance factory
private static final String INSTANCE_FACTORY = "instanceFactory";
+*/
// Scope
private static final String SCOPE = "scope";
@@ -64,7 +64,7 @@
/**
* Gets the qualified name of the XML fragment for the marshalled model
* object.
- *
+ *
* @return {"http://tuscany.apache.org/xmlns/marshaller/component/java/1.0-SNAPSHOT",
* "component"}
*/
@@ -75,7 +75,7 @@
/**
* Retursn the type of the model object.
- *
+ *
* @return <code>JavaPhysicalComponentDefinition.class</code>.
*/
@Override
@@ -85,7 +85,7 @@
/**
* Create the concrete PCD.
- *
+ *
* @return An instance of<code>JavaPhysicalComponentDefinition</code>.
*/
@Override
@@ -96,9 +96,9 @@
/**
* Handles extensions for unmarshalling Java physical component definitions
* including the marshalling of base64 encoded instance factory byte code.
- *
+ *
* @param componentDefinition Physical component definition.
- * @param reader Reader from which marshalled data is read.
+ * @param reader Reader from which marshalled data is read.
*/
@Override
protected void handleExtension(JavaPhysicalComponentDefinition componentDefinition, XMLStreamReader reader)
@@ -107,11 +107,13 @@
try {
String name = reader.getName().getLocalPart();
reader.next();
- if (INSTANCE_FACTORY.equals(name)) {
+/* if (INSTANCE_FACTORY.equals(name)) {
byte[] base64ByteCode = reader.getText().getBytes();
byte[] byteCode = Base64.decodeBase64(base64ByteCode);
componentDefinition.setInstanceFactoryByteCode(byteCode);
- } else if (SCOPE.equals(name)) {
+ } else
+*/
+ if (SCOPE.equals(name)) {
componentDefinition.setScope(new Scope(reader.getText()));
} else if (CLASSLOADER_ID.equals(name)) {
componentDefinition.setClassLoaderId(new URI(reader.getText()));
@@ -127,29 +129,31 @@
/**
* Handles extensions for marshalling Java physical component definitions
* including the marshalling of base64 encoded instance factory byte code.
- *
+ *
* @param componentDefinition Physical component definition.
- * @param reader Writer to which marshalled data is written.
+ * @param writer Writer to which marshalled data is written.
*/
@Override
protected void handleExtension(JavaPhysicalComponentDefinition componentDefinition, XMLStreamWriter writer)
throws MarshalException {
try {
-
+
+/*
writer.writeStartElement(QNAME.getPrefix(), INSTANCE_FACTORY, QNAME.getNamespaceURI());
writer.writeCharacters(new String(Base64.encodeBase64(componentDefinition.getInstanceFactoryByteCode())));
writer.writeEndElement();
+*/
writer.writeStartElement(QNAME.getPrefix(), SCOPE, QNAME.getNamespaceURI());
writer.writeCharacters(componentDefinition.getScope().toString());
writer.writeEndElement();
writer.writeStartElement(QNAME.getPrefix(), CLASSLOADER_ID, QNAME.getNamespaceURI());
writer.writeCharacters(componentDefinition.getClassLoaderId().toASCIIString());
writer.writeEndElement();
-
+
} catch (XMLStreamException ex) {
throw new MarshalException(ex);
}
-
+
}
}
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/model/physical/java/JavaPhysicalComponentDefinition.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/model/physical/java/JavaPhysicalComponentDefinition.java?view=diff&rev=517102&r1=517101&r2=517102
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/model/physical/java/JavaPhysicalComponentDefinition.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/model/physical/java/JavaPhysicalComponentDefinition.java Sun Mar 11 22:29:52 2007
@@ -20,6 +20,7 @@
import java.net.URI;
+import org.apache.tuscany.core.component.InstanceFactoryProvider;
import org.apache.tuscany.spi.model.Scope;
import org.apache.tuscany.spi.model.physical.PhysicalComponentDefinition;
@@ -27,11 +28,11 @@
* Represents the physical component definition for a Java implementation.
*
* @version $Rev$ $Date$
+ * @param <T> the implementation class (if known)
*/
-public class JavaPhysicalComponentDefinition extends PhysicalComponentDefinition {
+public class JavaPhysicalComponentDefinition<T> extends PhysicalComponentDefinition {
- // The byte code for the instance factory
- private byte[] instanceFactoryByteCode;
+ private InstanceFactoryProvider<T> provider;
// Scope
private Scope scope;
@@ -41,6 +42,7 @@
/**
* Gets the classloader id.
+ *
* @return Classloader id.
*/
public URI getClassLoaderId() {
@@ -49,6 +51,7 @@
/**
* Set the classloader id.
+ *
* @param classLoaderId Classloader id.
*/
public void setClassLoaderId(URI classLoaderId) {
@@ -57,6 +60,7 @@
/**
* Gets the scope for the component.
+ *
* @return The scope for the component.
*/
public Scope getScope() {
@@ -65,6 +69,7 @@
/**
* Sets the scope for the component.
+ *
* @param scope The scope for the component.
*/
public void setScope(Scope scope) {
@@ -72,21 +77,20 @@
}
/**
- * Gets the byte code for the instance factory.
+ * Return the provider for the component's instance factory.
*
- * @return Byte code for the instance factory.
+ * @return the provider for the component's instance factory
*/
- public byte[] getInstanceFactoryByteCode() {
- return instanceFactoryByteCode;
+ public InstanceFactoryProvider<T> getProvider() {
+ return provider;
}
/**
- * Sets the byte code for the instance factory.
+ * Sets the provider for the component's instance factory.
*
- * @param instanceFactoryByteCode Byte code for the instance factory.
+ * @param provider the provider for the component's instance factory
*/
- public void setInstanceFactoryByteCode(byte[] instanceFactoryByteCode) {
- this.instanceFactoryByteCode = instanceFactoryByteCode;
+ public void setProvider(InstanceFactoryProvider<T> provider) {
+ this.provider = provider;
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org