Author: antelder
Date: Sun May 14 12:34:11 2006
New Revision: 406409

URL: http://svn.apache.org/viewcvs?rev=406409&view=rev
Log:
TUSCANY-365, add Srikanth's contribution of a Ruby container to the sandbox

Added:
    incubator/tuscany/sandbox/container.ruby/
    incubator/tuscany/sandbox/container.ruby/pom.xml
    incubator/tuscany/sandbox/container.ruby/src/
    incubator/tuscany/sandbox/container.ruby/src/main/
    incubator/tuscany/sandbox/container.ruby/src/main/java/
    incubator/tuscany/sandbox/container.ruby/src/main/java/org/
    incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/
    incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/config/
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/config/AbstractContextFactory.java
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/context/
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/context/AbstractComponentContext.java
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/loader/
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/loader/AbstractImplementationLoader.java
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/assembly/
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/assembly/RubyImplementation.java
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/builder/
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/builder/RubyContextFactoryBuilder.java
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/builder/RubyTargetWireBuilder.java
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/config/
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/config/RubyContextFactory.java
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/context/
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/context/RubyComponentContext.java
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/invoker/
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/invoker/RubyInvoker.java
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/invoker/RubyScript.java
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/loader/
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/loader/RubyImplementationLoader.java
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/samples/
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/samples/ruby/
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/samples/ruby/Greeting.java
    
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/samples/ruby/GreetingClient.java
    incubator/tuscany/sandbox/container.ruby/src/main/resources/
    incubator/tuscany/sandbox/container.ruby/src/main/resources/Greetings.rb
    
incubator/tuscany/sandbox/container.ruby/src/main/resources/greetings.componentType
    
incubator/tuscany/sandbox/container.ruby/src/main/resources/logging.properties
    incubator/tuscany/sandbox/container.ruby/src/main/resources/sca.module
    incubator/tuscany/sandbox/container.ruby/src/main/resources/system.fragment
    incubator/tuscany/sandbox/container.ruby/src/test/
    incubator/tuscany/sandbox/container.ruby/src/test/java/
    incubator/tuscany/sandbox/container.ruby/src/test/resources/

Added: incubator/tuscany/sandbox/container.ruby/pom.xml
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/pom.xml?rev=406409&view=auto
==============================================================================
--- incubator/tuscany/sandbox/container.ruby/pom.xml (added)
+++ incubator/tuscany/sandbox/container.ruby/pom.xml Sun May 14 12:34:11 2006
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ *  Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, 
as applicable.
+ *
+ *  Licensed 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.
+ -->
+<project>
+
+    <parent>
+        <groupId>org.apache.tuscany.sca.containers</groupId>
+        <artifactId>tuscany-sca-containers</artifactId>
+        <version>SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>tuscany-container-ruby</artifactId>
+    <name>Tuscany Ruby Container</name>
+    <description>Tuscany Ruby Container</description>
+    <version>SNAPSHOT</version>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany</groupId>
+            <artifactId>tuscany-core</artifactId>
+            <version>${pom.version}</version>
+            <scope>compile</scope>
+        </dependency>
+
+
+       <dependency>
+           <groupId>jruby</groupId>
+           <artifactId>jruby</artifactId>
+           <version>0.8.3</version>
+           <scope>provided</scope>
+       </dependency>
+
+       <dependency>
+           <groupId>bsf</groupId>
+           <artifactId>bsf</artifactId>
+           <version>2.3.0</version>
+           <scope>provided</scope>
+       </dependency>
+    </dependencies>
+
+</project>

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/config/AbstractContextFactory.java
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/config/AbstractContextFactory.java?rev=406409&view=auto
==============================================================================
--- 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/config/AbstractContextFactory.java
 (added)
+++ 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/config/AbstractContextFactory.java
 Sun May 14 12:34:11 2006
@@ -0,0 +1,143 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as 
applicable.
+ *
+ *  Licensed 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.container.extension.config;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.context.AtomicContext;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.wire.SourceWireFactory;
+import org.apache.tuscany.core.wire.TargetWireFactory;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Abstract context factory.
+ */
+public abstract class AbstractContextFactory<T extends AtomicContext> 
implements ContextFactory<T> {
+
+       // Context scope
+    private Scope scope;
+
+    // Context name
+    private String name;
+
+    // SOurce proxy factories
+    private List<SourceWireFactory> sourceProxyFactories = new 
ArrayList<SourceWireFactory>();
+    
+    // Target proxy factories
+    private Map<String, TargetWireFactory> targetProxyFactories = new 
HashMap<String, TargetWireFactory>();
+    
+    /**
+     * Initializes the context factory.
+     * 
+     * @param name Context name.
+     * @param scope Context scope.
+     * @param rubyScript Ruby script to run.
+     */
+    public AbstractContextFactory(String name, Scope scope) {
+        this.name = name;
+        this.scope = scope;
+    }
+
+    /**
+     * Returns the context scope.
+     * @return Context scope.
+     */
+    public final Scope getScope() {
+        return scope;
+    }
+
+    /**
+     * Returns the context name.
+     * @return Context name.
+     */
+    public final String getName() {
+        return name;
+    }
+
+    /**
+     * Adds a property.
+     * 
+     * @param propertyName Property name.
+     * @param value Property value.
+     */
+    public final void addProperty(String propertyName, Object value) {
+    }
+
+    /**
+     * Adds a target proxy factory.
+     * 
+     * @param serviceName Service name.
+     * @param factory Target proxy factory.
+     */
+    public final void addTargetWireFactory(String serviceName, 
TargetWireFactory factory) {
+        targetProxyFactories.put(serviceName, factory);
+    }
+
+    /**
+     * Gets a target proxy factory by name.
+     * 
+     * @param serviceName Service name.
+     * @return Target wire factory for the specified service.
+     */
+    public final TargetWireFactory getTargetWireFactory(String serviceName) {
+        return targetProxyFactories.get(serviceName);
+    }
+
+    /**
+     * Returns all the target wire factories.
+     * @return All the target wire factories for the context.
+     */
+    public final Map<String, TargetWireFactory> getTargetWireFactories() {
+        return targetProxyFactories;
+    }
+
+    /**
+     * Adds a source wire factory.
+     * 
+     * @param referenceName Reference name.
+     * @param factory SOurce wire factory.
+     */
+    public final void addSourceWireFactory(String referenceName, 
SourceWireFactory factory) {
+        sourceProxyFactories.add(factory);
+    }
+
+    /**
+     * Adds all source wire factories.
+     */
+    public final void addSourceWireFactories(String referenceName, Class 
referenceInterface, List<SourceWireFactory> factory, boolean multiplicity) {
+       sourceProxyFactories.addAll(factory);
+    }
+
+    /**
+     * Returns all the source wire factories.
+     */
+    public final List<SourceWireFactory> getSourceWireFactories() {
+        return sourceProxyFactories;
+    }
+
+    /**
+     * Notification that the parent factory has been activated.
+     */
+    public final void prepare(CompositeContext parent) {
+    }
+
+}

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/context/AbstractComponentContext.java
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/context/AbstractComponentContext.java?rev=406409&view=auto
==============================================================================
--- 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/context/AbstractComponentContext.java
 (added)
+++ 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/context/AbstractComponentContext.java
 Sun May 14 12:34:11 2006
@@ -0,0 +1,114 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as 
applicable.
+ *
+ *  Licensed 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.container.extension.context;
+
+import java.util.Map;
+
+import org.apache.tuscany.core.context.AtomicContext;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.context.event.InstanceCreated;
+import org.apache.tuscany.core.context.impl.AbstractContext;
+import org.apache.tuscany.core.wire.ProxyCreationException;
+import org.apache.tuscany.core.wire.TargetWireFactory;
+import org.apache.tuscany.core.wire.WireFactory;
+
+/**
+ * Abstract component context.
+ *
+ */
+public abstract class AbstractComponentContext extends AbstractContext 
implements AtomicContext {
+
+    private Map<String, TargetWireFactory> targetProxyFactories;
+
+    public AbstractComponentContext(String name, Map<String, 
TargetWireFactory> targetProxyFactories) {
+        super(name);
+        this.targetProxyFactories = targetProxyFactories;
+    }
+
+    public Object getInstance(QualifiedName qName) throws TargetException {
+        return getInstance(qName, true);
+    }
+
+    /**
+     * Init method.
+     */
+    public void init() throws TargetException {
+    }
+
+    /**
+     * Detsroy method.
+     */
+    public void destroy() throws TargetException {
+    }
+
+    private synchronized Object getInstance(QualifiedName qName, boolean 
notify) throws TargetException {
+        String portName = qName.getPortName();
+        WireFactory targetFactory;
+        if (portName != null) {
+            targetFactory = targetProxyFactories.get(portName);
+        } else {
+            targetFactory = targetProxyFactories.values().iterator().next();
+        }
+        if (targetFactory == null) {
+            TargetException e = new TargetException("Target service not 
found");
+            e.setIdentifier(qName.getPortName());
+            e.addContextName(getName());
+            throw e;
+        }
+        try {
+            Object proxy = targetFactory.createProxy();
+            if (notify) {
+                publish(new InstanceCreated(this));
+            }
+            return proxy;
+        } catch (ProxyCreationException e) {
+            TargetException te = new TargetException("Error returning target", 
e);
+            e.setIdentifier(qName.getPortName());
+            e.addContextName(getName());
+            throw te;
+        }
+    }
+
+    /**
+     * Whether this context supports eager init.
+     */
+    public boolean isEagerInit() {
+        return false;
+    }
+
+    /**
+     * Whether this context is destroyable.
+     */
+    public boolean isDestroyable() {
+        return false;
+    }
+
+    /**
+     * Starts the context.
+     */
+    public void start() throws CoreRuntimeException {
+    }
+
+    /**
+     * Stops the context.
+     */
+    public void stop() throws CoreRuntimeException {
+    }
+
+}

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/loader/AbstractImplementationLoader.java
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/loader/AbstractImplementationLoader.java?rev=406409&view=auto
==============================================================================
--- 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/loader/AbstractImplementationLoader.java
 (added)
+++ 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/extension/loader/AbstractImplementationLoader.java
 Sun May 14 12:34:11 2006
@@ -0,0 +1,160 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as 
applicable.
+ *
+ *  Licensed 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.container.extension.loader;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.core.config.InvalidRootElementException;
+import org.apache.tuscany.core.config.MissingResourceException;
+import org.apache.tuscany.core.config.SidefileLoadException;
+import org.apache.tuscany.core.loader.LoaderContext;
+import org.apache.tuscany.core.loader.StAXElementLoader;
+import org.apache.tuscany.core.loader.StAXLoaderRegistry;
+import org.apache.tuscany.core.loader.assembly.AssemblyConstants;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Implementation;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * Abstract implementation loader.
+ *
+ */
[EMAIL PROTECTED]("MODULE")
+public abstract class AbstractImplementationLoader<T extends Implementation> 
implements StAXElementLoader<T> {
+
+       // Injected Stax loader registry.
+    protected StAXLoaderRegistry registry;
+
+    // XML input factory.
+    protected XMLInputFactory xmlFactory;
+
+    /**
+     * Initializes the XML input factory.
+     *
+     */
+    public AbstractImplementationLoader() {
+        xmlFactory = XMLInputFactory.newInstance();
+    }
+
+    /**
+     * Injection method for Stax loader registry.
+     * @param registry Stax loader registry.
+     */
+    @Autowire
+    public void setRegistry(StAXLoaderRegistry registry) {
+        this.registry = registry;
+    }
+
+    /**
+     * Loads the Ruby implementation.
+     *
+     * @param Stax XML stream reader.
+     * @param loaderContext Loader context.
+     * @return Ruby implementation.
+     */
+       public T load(XMLStreamReader reader, LoaderContext loaderContext) 
throws XMLStreamException, ConfigurationLoadException {
+
+               T assemblyObject = getAssemblyObject(reader, loaderContext);
+               
+               URL componentTypeFile = getSideFile(reader, loaderContext);
+        ComponentType componentType = loadComponentType(componentTypeFile, 
loaderContext);
+
+               assemblyObject.setComponentType(componentType);
+
+               return assemblyObject;
+
+       }
+       
+       /**
+        * Required to be implemented by the concrete classes.
+        * @return Implementation object.
+        */
+       protected abstract T getAssemblyObject(XMLStreamReader reader, 
LoaderContext loaderContext);
+
+    /**
+     * Gets the side file.
+     * 
+     * @param reader Reader for the module file.
+     * @param loaderContext Loader context.
+     * @return Side file Url.
+     * @throws MissingResourceException
+     */
+       protected abstract URL getSideFile(XMLStreamReader reader, 
LoaderContext loaderContext) throws MissingResourceException;
+
+       /**
+        * Loads the SIDE file to get the component information.
+        *
+        * @param scriptFile SCript file name.
+        * @param loaderContext Loader context.
+        * @return Component information.
+        * @throws SidefileLoadException
+        * @throws MissingResourceException
+        */
+    private ComponentType loadComponentType(URL componentTypeFile, 
LoaderContext loaderContext) throws SidefileLoadException, 
MissingResourceException{
+       
+       XMLStreamReader reader = null;
+       InputStream is = null;
+
+        try {
+            is = componentTypeFile.openStream();
+            reader = xmlFactory.createXMLStreamReader(is);
+            reader.nextTag();
+            if (!AssemblyConstants.COMPONENT_TYPE.equals(reader.getName())) {
+                InvalidRootElementException e = new 
InvalidRootElementException(AssemblyConstants.COMPONENT_TYPE, reader.getName());
+                e.setResourceURI(componentTypeFile.toString());
+                throw e;
+            }
+            return (ComponentType) registry.load(reader, loaderContext);
+        } catch (IOException e) {
+            SidefileLoadException sfe = new 
SidefileLoadException(e.getMessage());
+            sfe.setResourceURI(componentTypeFile.toString());
+            throw sfe;
+        } catch (XMLStreamException e) {
+            SidefileLoadException sfe = new 
SidefileLoadException(e.getMessage());
+            sfe.setResourceURI(componentTypeFile.toString());
+            throw sfe;
+        } catch (ConfigurationLoadException e) {
+            SidefileLoadException sfe = new 
SidefileLoadException(e.getMessage());
+            sfe.setResourceURI(componentTypeFile.toString());
+            throw sfe;
+        } finally {
+            try {
+               if(reader != null) {
+                       reader.close();
+               }
+            } catch (XMLStreamException e) {
+                // ignore
+            }
+            try {
+               if(is != null) {
+                       is.close();
+               }
+            } catch (IOException e) {
+                // ignore
+            }
+        }
+    }
+
+}

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/assembly/RubyImplementation.java
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/assembly/RubyImplementation.java?rev=406409&view=auto
==============================================================================
--- 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/assembly/RubyImplementation.java
 (added)
+++ 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/assembly/RubyImplementation.java
 Sun May 14 12:34:11 2006
@@ -0,0 +1,64 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as 
applicable.
+ *
+ *  Licensed 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.container.ruby.assembly;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.model.assembly.impl.AtomicImplementationImpl;
+
+/**
+ * Meta-information for the Ruby implementation.
+ *
+ */
+public class RubyImplementation extends AtomicImplementationImpl {
+       
+       // Full path of the script file to be executed
+       private String script;
+       
+       // Resource loader for accessing classpath resources
+       private ResourceLoader resourceLoader;
+       
+       /**
+        * Gets the full path of the script file to be executed.
+        * @return Full path of the script file to be executed.
+        */
+       public String getScript() { 
+               return script; 
+       }
+       
+       /**
+        * Sets the full path of the script file to be executed.
+        * @param script Full path of the script file to be executed.
+        */
+       public void setScript(String script) { 
+               this.script = script; 
+       }
+       
+       /**
+        * Gets the resource loader for accessing classpath resources.
+        * @return Resource loader.
+        */
+       public ResourceLoader getResourceLoader() { return resourceLoader; }
+
+       /**
+        * Sets the resource loader for accessing classpath resources.
+        * @param resourceLoader Resource loader.
+        */
+       public void setResourceLoader(ResourceLoader resourceLoader) { 
+               this.resourceLoader = resourceLoader; 
+       }
+
+}

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/builder/RubyContextFactoryBuilder.java
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/builder/RubyContextFactoryBuilder.java?rev=406409&view=auto
==============================================================================
--- 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/builder/RubyContextFactoryBuilder.java
 (added)
+++ 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/builder/RubyContextFactoryBuilder.java
 Sun May 14 12:34:11 2006
@@ -0,0 +1,39 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as 
applicable.
+ *
+ *  Licensed 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.container.ruby.builder;
+
+import org.apache.tuscany.container.ruby.assembly.RubyImplementation;
+import org.apache.tuscany.container.ruby.config.RubyContextFactory;
+import org.apache.tuscany.container.ruby.invoker.RubyScript;
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.extension.ContextFactoryBuilderSupport;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Ruby context factory builder.
+ *
+ */
[EMAIL PROTECTED]("MODULE")
+public class RubyContextFactoryBuilder extends 
ContextFactoryBuilderSupport<RubyImplementation> {
+
+    @Override
+    protected ContextFactory createContextFactory(String componentName, 
RubyImplementation implementation, Scope scope) {
+        RubyScript rubyScript = new RubyScript(implementation.getScript());
+        return new RubyContextFactory(componentName, scope, rubyScript);
+    }
+
+}

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/builder/RubyTargetWireBuilder.java
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/builder/RubyTargetWireBuilder.java?rev=406409&view=auto
==============================================================================
--- 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/builder/RubyTargetWireBuilder.java
 (added)
+++ 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/builder/RubyTargetWireBuilder.java
 Sun May 14 12:34:11 2006
@@ -0,0 +1,47 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as 
applicable.
+ *
+ *  Licensed 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.container.ruby.builder;
+
+import org.apache.tuscany.container.ruby.config.RubyContextFactory;
+import org.apache.tuscany.container.ruby.invoker.RubyInvoker;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.extension.WireBuilderSupport;
+import org.apache.tuscany.core.wire.TargetInvoker;
+import org.osoa.sca.annotations.Scope;
+
+import java.lang.reflect.Method;
+
+/**
+ * Ruby target wire builder.
+ */
[EMAIL PROTECTED]("MODULE")
+public class RubyTargetWireBuilder extends 
WireBuilderSupport<RubyContextFactory> {
+
+       /**
+        * Created the invoker for Ruby.
+        * 
+        * @param targetName Target component name.
+        * @param  method Method invoked on the proxy.
+        * @param context Scope context.
+        * @param downScope Flag for down scope.
+        */
+    protected TargetInvoker createInvoker(QualifiedName targetName, Method 
method, ScopeContext context, boolean downScope) {
+        String serviceName = targetName.getPartName();
+        return new RubyInvoker(context, serviceName, method.getName());
+    }
+}

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/config/RubyContextFactory.java
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/config/RubyContextFactory.java?rev=406409&view=auto
==============================================================================
--- 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/config/RubyContextFactory.java
 (added)
+++ 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/config/RubyContextFactory.java
 Sun May 14 12:34:11 2006
@@ -0,0 +1,55 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as 
applicable.
+ *
+ *  Licensed 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.container.ruby.config;
+
+import org.apache.tuscany.container.extension.config.AbstractContextFactory;
+import org.apache.tuscany.container.ruby.context.RubyComponentContext;
+import org.apache.tuscany.container.ruby.invoker.RubyScript;
+import org.apache.tuscany.core.builder.ContextCreationException;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Ruby context factory.
+ */
+public class RubyContextFactory extends 
AbstractContextFactory<RubyComponentContext> {
+    
+    // Ruby script to run
+    private RubyScript rubyScript;
+    
+    /**
+     * Initializes the context factory.
+     * 
+     * @param name Context name.
+     * @param scope Context scope.
+     * @param rubyScript Ruby script to run.
+     */
+    public RubyContextFactory(String name, Scope scope, RubyScript rubyScript) 
{
+        super(name, scope);
+        this.rubyScript = rubyScript;
+    }
+
+    /**
+     * Creates the Ruby component context.
+     */
+    public RubyComponentContext createContext() throws 
ContextCreationException {
+        return new RubyComponentContext(
+                getName(), 
+                       getTargetWireFactories(), 
+                rubyScript);
+    }
+
+}

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/context/RubyComponentContext.java
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/context/RubyComponentContext.java?rev=406409&view=auto
==============================================================================
--- 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/context/RubyComponentContext.java
 (added)
+++ 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/context/RubyComponentContext.java
 Sun May 14 12:34:11 2006
@@ -0,0 +1,56 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as 
applicable.
+ *
+ *  Licensed 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.container.ruby.context;
+
+import java.util.Map;
+
+import org.apache.tuscany.container.extension.context.AbstractComponentContext;
+import org.apache.tuscany.container.ruby.invoker.RubyScript;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.wire.TargetWireFactory;
+
+/**
+ * Ruby component context.
+ *
+ */
+public class RubyComponentContext extends AbstractComponentContext {
+    
+    // Ruby script.
+    private RubyScript rubyScript;
+
+    /**
+     * Initializes the context.
+     * 
+     * @param name Component name.
+     * @param targetProxyFactories Target wire factories.
+     * @param rubyScript Ruby script.
+     */
+    public RubyComponentContext(String name, 
+               Map<String, TargetWireFactory> targetProxyFactories, 
+               RubyScript rubyScript) {
+        super(name, targetProxyFactories);
+        this.rubyScript = rubyScript;
+    }
+
+    /**
+     * Gets the target invocation instance.
+     */
+    public Object getTargetInstance() throws TargetException {
+        return rubyScript;
+    }
+
+}

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/invoker/RubyInvoker.java
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/invoker/RubyInvoker.java?rev=406409&view=auto
==============================================================================
--- 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/invoker/RubyInvoker.java
 (added)
+++ 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/invoker/RubyInvoker.java
 Sun May 14 12:34:11 2006
@@ -0,0 +1,108 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as 
applicable.
+ *
+ *  Licensed 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.container.ruby.invoker;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.core.context.AtomicContext;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.wire.Interceptor;
+import org.apache.tuscany.core.wire.TargetInvoker;
+
+/**
+ * Ruby target invoker.
+ *
+ */
+public class RubyInvoker implements TargetInvoker, Cloneable {
+       
+       // SCope context
+       private ScopeContext scopeContext;      
+       
+       // Srevice name
+       private String serviceName;
+       
+       // Method name
+       private String methodName;
+       
+       /**
+        * Initializes the invoker.
+        * 
+        * @param scopeContext SCope context.
+        * @param serviceName Service name.
+        * @param methodName Method name.
+        */
+       public RubyInvoker(ScopeContext scopeContext, String serviceName, 
String methodName) {
+               this.scopeContext = scopeContext;
+               this.serviceName = serviceName;
+               this.methodName = methodName;
+       }
+
+       /**
+        * Invokes the target.
+        */
+       public Object invokeTarget(Object payload) throws 
InvocationTargetException {
+               
+               AtomicContext atomicContext = 
(AtomicContext)scopeContext.getContext(serviceName);
+        RubyScript rubyScript = (RubyScript)atomicContext.getTargetInstance();
+        
+               Object[] args = (Object[])payload;
+               
+               try {
+                       return rubyScript.runScript(methodName, args);
+               } catch(Exception ex) {
+                       throw new InvocationTargetException(ex);
+               }
+               
+       }
+
+       /**
+        * Whether the invoker is cacheable.
+        */
+       public boolean isCacheable() {
+               return false;
+       }
+
+       /**
+        * Invokes the servce.
+        */
+       public Message invoke(Message msg) {
+        try {
+            Object resp = invokeTarget(msg.getBody());
+            msg.setBody(resp);
+        } catch (InvocationTargetException e) {
+            msg.setBody(e.getCause());
+        } catch (Throwable e) {
+            msg.setBody(e);
+        }
+        return msg;
+       }
+
+       /**
+        * Sets interceptor.
+        */
+       public void setNext(Interceptor next) {
+       }
+
+    /**
+     * Implementations must support deep cloning
+     */
+    public Object clone() {
+       return new RubyInvoker(scopeContext, serviceName, methodName);
+    }
+
+}

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/invoker/RubyScript.java
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/invoker/RubyScript.java?rev=406409&view=auto
==============================================================================
--- 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/invoker/RubyScript.java
 (added)
+++ 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/invoker/RubyScript.java
 Sun May 14 12:34:11 2006
@@ -0,0 +1,101 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as 
applicable.
+ *
+ *  Licensed 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.container.ruby.invoker;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Method;
+import org.eclipse.emf.common.util.URI;
+
+import org.apache.bsf.BSFManager;
+import org.apache.bsf.util.IOUtils;
+import org.jruby.RubyObject;
+
+
+/**
+ * Models a Ruby script.
+ */
+public class RubyScript {
+       
+       // Script to run.
+       private String script;
+       private BSFManager bsfManager;
+       
+       /**
+        * Initializes the script name.
+        * @param script Full path to the script.
+        */
+       public RubyScript(String script) {
+               this.script = script;
+               
+               // Register the BSF Engine
+        BSFManager.registerScriptingEngine("ruby", 
"org.jruby.javasupport.bsf.JRubyEngine", 
+                       new String[] { "rb" });
+        bsfManager = new BSFManager();
+       }
+       
+       /**
+        * Executes the script.
+        * @param methodName Name of the method to be executed.
+        * @param args Arguments to the method.
+        * @return Result of invocation.
+        * @throws CompilationFailedException
+        * @throws InstantiationException
+        * @throws IllegalAccessException
+        */
+       public Object runScript(String methodName, Object[] args) throws 
InstantiationException, IllegalAccessException {
+               
+               ClassLoader classLoader = getClass().getClassLoader();
+               
+               try {
+                       // Get the Ruby Class
+                       Object rubyClass = getRubyClass(classLoader, script);   
                
+                       Method rubyMethod = findFunction(rubyClass, methodName);
+                       Object result = null;
+                       if(rubyMethod != null) {
+                               result = rubyMethod.invoke(rubyClass, args);
+                       }
+                       return result;
+               } catch(Exception ex) {
+                       ex.printStackTrace();                   
+               }
+               
+               return null;
+               
+       }
+
+       // Gives the Ruby class for the corresponding script
+       // Can optimize in future by caching the instance
+       private Object getRubyClass(ClassLoader classLoader, String 
rubyScriptName) throws Exception {          
+               // Load the ruby script         
+               InputStream inputStream = 
classLoader.getResourceAsStream(rubyScriptName);
+               String script = IOUtils.getStringFromReader(new 
InputStreamReader(inputStream));
+               bsfManager.exec("ruby", "(java)", 1, 1, script);        
+               
+               // Get the Ruby class
+               String 
rubyClassName=URI.createURI(rubyScriptName).trimFileExtension().lastSegment();  
                 
+               Object rubyClass = bsfManager.eval("ruby", "(java)", 1, 1, 
rubyClassName+".new");               
+               return rubyClass;
+       }
+       
+       // Find whether a particular method exists
+       private Method findFunction(Object rubyClass, String functionName) 
throws Exception {
+               Class[] parameterTypes = new Class[]{String.class};
+               Method method = rubyClass.getClass().getMethod(functionName, 
parameterTypes);
+               return method;
+       }
+}

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/loader/RubyImplementationLoader.java
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/loader/RubyImplementationLoader.java?rev=406409&view=auto
==============================================================================
--- 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/loader/RubyImplementationLoader.java
 (added)
+++ 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/container/ruby/loader/RubyImplementationLoader.java
 Sun May 14 12:34:11 2006
@@ -0,0 +1,97 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as 
applicable.
+ *
+ *  Licensed 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.container.ruby.loader;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import 
org.apache.tuscany.container.extension.loader.AbstractImplementationLoader;
+import org.apache.tuscany.container.ruby.assembly.RubyImplementation;
+import org.apache.tuscany.core.config.MissingResourceException;
+import org.apache.tuscany.core.loader.LoaderContext;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * Ruby implementation loader.
+ *
+ */
[EMAIL PROTECTED]("MODULE")
+public class RubyImplementationLoader extends 
AbstractImplementationLoader<RubyImplementation> {
+
+       // Qualified name for the Ruby implementation.
+       public static final QName NAME = new 
QName("http://org.apache.tuscany/xmlns/ruby/0.9";, "implementation.ruby");
+
+    /**
+     * Lifecycle method registers the implementation loader.
+     *
+     */
+    @Init(eager = true)
+    public void start() {
+        registry.registerLoader(NAME, this);
+    }
+
+    /**
+     * Lifecycle method deregisters the implementation loader.
+     *
+     */
+    @Destroy
+    public void stop() {
+        registry.unregisterLoader(NAME, this);
+    }
+       
+       /**
+        * Required to be implemented by the concrete classes.
+        * @return Implementation object.
+        */
+       protected RubyImplementation getAssemblyObject(XMLStreamReader reader, 
LoaderContext loaderContext) {
+               
+               RubyImplementation rubyImplementation = new 
RubyImplementation();
+               String script = reader.getAttributeValue(null, "script");
+               
+               rubyImplementation.setScript(script);
+               
rubyImplementation.setResourceLoader(loaderContext.getResourceLoader());
+
+               return rubyImplementation;
+               
+       }
+
+    /**
+     * Gets the side file.
+     * 
+     * @param reader Reader for the module file.
+     * @param loaderContext Loader context.
+     * @return Side file Url.
+     * @throws MissingResourceException
+     */
+       protected URL getSideFile(XMLStreamReader reader, LoaderContext 
loaderContext) 
+       throws MissingResourceException {
+               
+               String script = reader.getAttributeValue(null, "script");
+               String sidefile = script.substring(0, script.lastIndexOf('.')) 
+ ".componentType";
+        URL componentTypeFile = 
loaderContext.getResourceLoader().getResource(sidefile);
+        if (componentTypeFile == null) {
+            throw new MissingResourceException(sidefile);
+        }
+               return componentTypeFile;
+               
+       }
+
+}

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/samples/ruby/Greeting.java
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/samples/ruby/Greeting.java?rev=406409&view=auto
==============================================================================
--- 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/samples/ruby/Greeting.java
 (added)
+++ 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/samples/ruby/Greeting.java
 Sun May 14 12:34:11 2006
@@ -0,0 +1,6 @@
+package org.apache.tuscany.samples.ruby;
+
+public interface Greeting {
+
+       void greet(String name);
+}

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/samples/ruby/GreetingClient.java
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/samples/ruby/GreetingClient.java?rev=406409&view=auto
==============================================================================
--- 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/samples/ruby/GreetingClient.java
 (added)
+++ 
incubator/tuscany/sandbox/container.ruby/src/main/java/org/apache/tuscany/samples/ruby/GreetingClient.java
 Sun May 14 12:34:11 2006
@@ -0,0 +1,63 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as 
applicable.
+ *
+ *  Licensed 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.samples.ruby;
+
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.Properties;
+
+import org.osoa.sca.CurrentModuleContext;
+import org.osoa.sca.ModuleContext;
+
+import org.apache.tuscany.core.client.TuscanyRuntime;
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.common.monitor.impl.JavaLoggingMonitorFactory;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * locate a simple ruby service component and invoke it.
+ */
+public class GreetingClient {
+
+    public static final void main(String[] args) throws Exception {
+       
+        // Setup Tuscany monitoring to use java.util.logging
+        
LogManager.getLogManager().readConfiguration(GreetingClient.class.getResourceAsStream("/logging.properties"));
+        Properties levels = new Properties();
+        MonitorFactory monitorFactory = new JavaLoggingMonitorFactory(levels, 
Level.FINEST, "MonitorMessages");
+
+        // Obtain Tuscany runtime
+        TuscanyRuntime tuscany = new TuscanyRuntime("greeting", null, 
monitorFactory);
+
+        // Associate the application module component with this thread
+        tuscany.start();
+
+        // Obtain SCA module context.
+        ModuleContext moduleContext = CurrentModuleContext.getContext();
+
+        Greeting greeting = (Greeting) 
moduleContext.locateService("GreetingComponent");
+        greeting.greet("World");
+        
+        System.err.flush();
+
+        // Disassociate the application module component
+        tuscany.stop();
+
+        // Shut down the runtime
+        tuscany.shutdown();
+    }
+}

Added: incubator/tuscany/sandbox/container.ruby/src/main/resources/Greetings.rb
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/resources/Greetings.rb?rev=406409&view=auto
==============================================================================
--- incubator/tuscany/sandbox/container.ruby/src/main/resources/Greetings.rb 
(added)
+++ incubator/tuscany/sandbox/container.ruby/src/main/resources/Greetings.rb 
Sun May 14 12:34:11 2006
@@ -0,0 +1,9 @@
+require 'java'
+
+include_class 'org.apache.tuscany.samples.ruby.Greeting'
+
+class Greetings < Greeting
+  def greet(name)
+    puts "RUBY : Hello " + name.to_s
+  end
+end
\ No newline at end of file

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/resources/greetings.componentType
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/resources/greetings.componentType?rev=406409&view=auto
==============================================================================
--- 
incubator/tuscany/sandbox/container.ruby/src/main/resources/greetings.componentType
 (added)
+++ 
incubator/tuscany/sandbox/container.ruby/src/main/resources/greetings.componentType
 Sun May 14 12:34:11 2006
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
+
+    <service name="GreetingService">
+        <interface.java interface="org.apache.tuscany.samples.ruby.Greeting"/>
+    </service>
+
+</componentType>
\ No newline at end of file

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/resources/logging.properties
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/resources/logging.properties?rev=406409&view=auto
==============================================================================
--- 
incubator/tuscany/sandbox/container.ruby/src/main/resources/logging.properties 
(added)
+++ 
incubator/tuscany/sandbox/container.ruby/src/main/resources/logging.properties 
Sun May 14 12:34:11 2006
@@ -0,0 +1,27 @@
+#  Copyright (c) 2006 The Apache Software Foundation or its licensors, as 
applicable.
+#
+#  Licensed 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.
+#
+#  $Rev$ $Date$
+#
+
+# Custom logging configuration for Tuscany samples
+# By default, only INFO level logging is enabled and ALL messages get sent to 
the console
+# For more messages from the runtime, uncomment specific settings at the end 
of this file
+handlers = java.util.logging.ConsoleHandler
+java.util.logging.ConsoleHandler.level = ALL
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+.level=INFO
+
+# Uncomment the next setting to get all Tuscany messages (this will be a lot)
+#org.apache.tuscany.level=FINEST
\ No newline at end of file

Added: incubator/tuscany/sandbox/container.ruby/src/main/resources/sca.module
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/resources/sca.module?rev=406409&view=auto
==============================================================================
--- incubator/tuscany/sandbox/container.ruby/src/main/resources/sca.module 
(added)
+++ incubator/tuscany/sandbox/container.ruby/src/main/resources/sca.module Sun 
May 14 12:34:11 2006
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright (c) 2005 BEA Sytems Inc.
+  Copyright (c) 2005 International Business Machines
+
+  Licensed 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.
+ -->
+<!--module xmlns="http://www.osoa.org/xmlns/sca/0.9"; 
+xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9";
+        name="sampleHelloworld"-->
+<module 
+       xmlns="http://www.osoa.org/xmlns/sca/0.9"; 
+       xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9";
+       xmlns:ruby="http://org.apache.tuscany/xmlns/ruby/0.9";
+    name="RubySample">
+
+    <component name="GreetingComponent">
+        <ruby:implementation.ruby script="Greetings.rb"/>
+    </component>
+    
+</module>

Added: 
incubator/tuscany/sandbox/container.ruby/src/main/resources/system.fragment
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/container.ruby/src/main/resources/system.fragment?rev=406409&view=auto
==============================================================================
--- incubator/tuscany/sandbox/container.ruby/src/main/resources/system.fragment 
(added)
+++ incubator/tuscany/sandbox/container.ruby/src/main/resources/system.fragment 
Sun May 14 12:34:11 2006
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+  Copyright (c) 2005 The Apache Software Foundation or its licensors, as 
applicable.
+
+  Licensed 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.
+ -->
+<moduleFragment xmlns="http://www.osoa.org/xmlns/sca/0.9"; 
xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9";
+        xmlns:system="http://org.apache.tuscany/xmlns/system/0.9";
+               name="org.apache.tuscany.container.ruby">
+
+    <component 
name="org.apache.tuscany.container.ruby.builder.rubyContextFactoryBuilder">
+        <system:implementation.system 
class="org.apache.tuscany.container.ruby.builder.RubyContextFactoryBuilder"/>
+    </component>
+
+    <component 
name="org.apache.tuscany.container.ruby.builder.rubyTargetWireBuilder">
+        <system:implementation.system 
class="org.apache.tuscany.container.ruby.builder.RubyTargetWireBuilder"/>
+    </component>
+
+    <component 
name="org.apache.tuscany.container.ruby.loader.rubyImplementationLoader">
+        <system:implementation.system 
class="org.apache.tuscany.container.ruby.loader.RubyImplementationLoader"/>
+    </component>
+</moduleFragment>


Reply via email to