diff options
Diffstat (limited to 'tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly')
4 files changed, 0 insertions, 211 deletions
diff --git a/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/JavaScriptAssemblyFactory.java b/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/JavaScriptAssemblyFactory.java deleted file mode 100644 index 0072bcdaa1..0000000000 --- a/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/JavaScriptAssemblyFactory.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * - * 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.js.assembly; - -import org.apache.tuscany.model.assembly.AssemblyFactory; - -public interface JavaScriptAssemblyFactory extends AssemblyFactory { - - /** - * Returns a new object of class '<em>JavaScript Implementation</em>'. - */ - JavaScriptImplementation createJavaScriptImplementation(); - -} diff --git a/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/JavaScriptImplementation.java b/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/JavaScriptImplementation.java deleted file mode 100644 index 6edaf2b60a..0000000000 --- a/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/JavaScriptImplementation.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * - * 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.js.assembly; - -import org.apache.tuscany.common.resource.ResourceLoader; -import org.apache.tuscany.model.assembly.ComponentImplementation; - -/** - * A representation of a JavaScript component implementation type - * - * @version $Rev$ $Date$ - */ -public interface JavaScriptImplementation extends ComponentImplementation { - - public ResourceLoader getResourceLoader(); - - public String getScriptFile(); - - public void setScriptFile(String fn); -} diff --git a/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptAssemblyFactoryImpl.java b/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptAssemblyFactoryImpl.java deleted file mode 100644 index 21930d22ec..0000000000 --- a/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptAssemblyFactoryImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * - * 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.js.assembly.impl; - -import org.apache.tuscany.container.js.assembly.JavaScriptAssemblyFactory; -import org.apache.tuscany.container.js.assembly.JavaScriptImplementation; -import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl; - -public class JavaScriptAssemblyFactoryImpl extends AssemblyFactoryImpl implements JavaScriptAssemblyFactory { - - public JavaScriptAssemblyFactoryImpl() { - super(); - } - - public JavaScriptImplementation createJavaScriptImplementation() { - return new JavaScriptImplementationImpl(); - } - -} diff --git a/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptImplementationImpl.java b/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptImplementationImpl.java deleted file mode 100644 index c6b58a25c6..0000000000 --- a/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptImplementationImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.apache.tuscany.container.js.assembly.impl; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - -import org.apache.tuscany.common.resource.ResourceLoader; -import org.apache.tuscany.container.js.assembly.JavaScriptImplementation; -import org.apache.tuscany.model.assembly.AssemblyModelContext; -import org.apache.tuscany.model.assembly.ComponentType; -import org.apache.tuscany.model.assembly.ModelInitException; -import org.apache.tuscany.model.assembly.impl.ComponentImplementationImpl; - -/** - * Default implementation of a JavScript component implementation type - * - * @version $Rev$ $Date$ - */ -public class JavaScriptImplementationImpl extends ComponentImplementationImpl implements JavaScriptImplementation { - - private ResourceLoader resourceLoader; - - public JavaScriptImplementationImpl() { - super(); - } - - public ResourceLoader getResourceLoader() { - return null; - } - - public void initialize(AssemblyModelContext modelContext) throws ModelInitException { - if (isInitialized()) { - return; - } - this.resourceLoader = modelContext.getApplicationResourceLoader(); - if(resourceLoader == null){ - throw new ModelInitException("No resource loader set on model context"); - } - getScriptFile(); - - // Initialize the component type - ComponentType componentType = getComponentType(); - if (componentType == null) { - try { - componentType = createComponentType(modelContext); - } catch (IOException e) { - throw new ModelInitException("Error retrieving component type file",e); - } - setComponentType(componentType); - } - - super.initialize(modelContext); - - } - - String script; - - public String getScriptFile() { - return script; - } - - public void setScriptFile(String fn) { - script = fn; - } - - private String scriptCode; - - public String getScript() throws ModelInitException { - if (scriptCode != null) { - return scriptCode; - } - try { - URL url = resourceLoader.getResource(getScriptFile()); - if (url == null) { - ModelInitException ce = new ModelInitException("Script not found"); - ce.setIdentifier(getScriptFile()); - throw ce; - } - InputStream inputStream = url.openStream(); - try { - StringBuffer sb = new StringBuffer(); - int n = 0; - while ((n = inputStream.read()) != -1) { - sb.append((char) n); - } - scriptCode = sb.toString(); - return scriptCode; - } finally { - inputStream.close(); - } - } catch (IOException e) { - ModelInitException ce = new ModelInitException("Error reading script file",e); - ce.setIdentifier(getScriptFile()); - throw ce; - } - } - - /** - * Create the component type - * - * @param modelContext - * @param implementationClass - */ - private ComponentType createComponentType(AssemblyModelContext modelContext) throws IOException{ - String prefix = script.substring(0,script.lastIndexOf('.')); - URL componentTypeFile = resourceLoader.getResource(prefix + ".componentType"); - if (componentTypeFile != null) { - return modelContext.getAssemblyLoader().loadComponentType(componentTypeFile.toString()); - } else { - // TODO we could introspect the JavaScript source - return modelContext.getAssemblyFactory().createComponentType(); - } - } - - -} |