On Jan 29, 2007, at 6:50 PM, Jeremy Boynes wrote:
Instead, I think the data sent should define the configuration data needed by the JavaComponentBuilder, something like:

<java:component xmlns:java="http://tuscany.apache.org/xmlns/java/ 1.0"
                   uri="http://www.example.com/D1/Component1";
                   scope="Composite"
                   eagerInit='true'>
<implementation class="sample.Component1Impl" classLoader="MyApp"/>
     <constructor>
       <param class="sample.Component2">
<rmi:binding xmlns:rmi="http://tuscany.apache.org/xmlns/ rmi/1.0" uri="http://m2:1099/D1/Component2"/>
       </param>
     </constructor>
     <injection>
       <method name="setP1" type="java.lang.String">
          <java:simpleTypeFactory>fooValue</java:simpleTypeFactory>
       </method>
     </injection>
  </java:component>

The XML is meant to be illustrative. It's also meant to be internal to the runtime and not editable by users :-)

I was thinking about this and about the number of XML entities needed to define the input for the builder. We don't need all the flexibility here as the generator and the builder are very closely coupled (down to the version level). In light of that, we can simplify the generator and builder implementation simply by hard wiring this to bytecode. This has other advantages as well in terms of runtime simplicity and performance, it would also allow users willing to dig into the Tuscany SPIs to provide their own factory.

The basic change here would be to define an InstanceFactory that returns a fully initialized instance for the target component:
class InstanceFactory<T> {
  InstanceWrapper<T> createInstance();
}

The implementation of this can be provided by the user (which allows codegen at development time), generated during contribution, or generated during logical->physical mapping. The resulting physical component definition would be:

<java:component xmlns:java="http://tuscany.apache.org/xmlns/java/ 1.0"
                   uri="http://www.example.com/D1/Component1";
                   scope="Composite"
                   eagerInit='true'>
<instanceFactory classLoader="MyApp" class="sample.Component1Factory"/>
  </java:component>

or

<java:component xmlns:java="http://tuscany.apache.org/xmlns/java/ 1.0"
                   uri="http://www.example.com/D1/Component1";
                   scope="Composite"
                   eagerInit='true'>
<instanceFactory classLoader="MyApp">$ {base64EncodedBytecodeForTheFactory}</instanceFactory>
  </java:component>

depending on where the generation was done (i.e. is the factory already in the MyApp classloader or not).

All property and physical binding configuration can be handled by the implementation of this factory. The builder though would still need to be involved to ensure all the local wires in and out of the component were connected. It could pass the outbound reference factories to the InstanceFactory implementation during construction.

--
Jeremy


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to