Return-Path: Delivered-To: apmail-ws-tuscany-commits-archive@locus.apache.org Received: (qmail 38483 invoked from network); 3 Jun 2007 18:10:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Jun 2007 18:10:44 -0000 Received: (qmail 67262 invoked by uid 500); 3 Jun 2007 18:10:48 -0000 Delivered-To: apmail-ws-tuscany-commits-archive@ws.apache.org Received: (qmail 67243 invoked by uid 500); 3 Jun 2007 18:10:48 -0000 Mailing-List: contact tuscany-commits-help@ws.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: tuscany-dev@ws.apache.org Delivered-To: mailing list tuscany-commits@ws.apache.org Received: (qmail 67234 invoked by uid 99); 3 Jun 2007 18:10:47 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Jun 2007 11:10:47 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Jun 2007 11:10:43 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id C46651A981D; Sun, 3 Jun 2007 11:10:22 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r543947 [2/2] - in /incubator/tuscany/java/sca/modules/extension-helper: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/tuscany/ src/main/java/org/apache/tuscany/sca/ src/main/java/org... Date: Sun, 03 Jun 2007 18:10:22 -0000 To: tuscany-commits@ws.apache.org From: antelder@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070603181022.C46651A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/DefaultPropertyValueObjectFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/DefaultPropertyValueObjectFactory.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/DynamicImplementation.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/DynamicImplementation.java?view=auto&rev=543947 ============================================================================== --- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/DynamicImplementation.java (added) +++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/DynamicImplementation.java Sun Jun 3 11:10:20 2007 @@ -0,0 +1,75 @@ +/* + * 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.sca.spi.utils; + +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.Reference; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.assembly.builder.ComponentPreProcessor; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +public class DynamicImplementation extends AbstractImplementation implements ComponentPreProcessor { + + public void preProcess(Component component) { + RuntimeComponent rtc = (RuntimeComponent) component; + + for (Service service : rtc.getServices()) { + if (getService(service.getName()) == null) { + getServices().add(createService(service)); + } + } + + Service dynamicService = getService("$dynamic$"); + if (dynamicService != null && getServices().size() > 1) { + getServices().remove(dynamicService); + dynamicService = null; + } + + for (Reference reference : rtc.getReferences()) { + if (getReference(reference.getName()) == null) { + getReferences().add(createReference(reference)); + } + } + + // TODO: support properties + } + + protected Service createService(Service service) { + Service newService; + try { + newService = (Service)service.clone(); + } catch (CloneNotSupportedException e) { + throw new AssertionError(e); // should not ever happen + } + + return newService; + } + + protected Reference createReference(Reference reference) { + Reference newReference; + try { + newReference = (Reference)reference.clone(); + } catch (CloneNotSupportedException e) { + throw new AssertionError(e); // should not ever happen + } + return newReference; + } + +} Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/DynamicImplementation.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/DynamicImplementation.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/PropertyValueObjectFactory.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/PropertyValueObjectFactory.java?view=auto&rev=543947 ============================================================================== --- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/PropertyValueObjectFactory.java (added) +++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/PropertyValueObjectFactory.java Sun Jun 3 11:10:20 2007 @@ -0,0 +1,29 @@ +/* + * 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.sca.spi.utils; + +import org.apache.tuscany.sca.assembly.Property; +import org.apache.tuscany.sca.factory.ObjectFactory; + +public interface PropertyValueObjectFactory { + + public abstract ObjectFactory createValueFactory(Property property); + +} Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/PropertyValueObjectFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/PropertyValueObjectFactory.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/ResourceHelper.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/ResourceHelper.java?view=auto&rev=543947 ============================================================================== --- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/ResourceHelper.java (added) +++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/ResourceHelper.java Sun Jun 3 11:10:20 2007 @@ -0,0 +1,70 @@ +/* + * 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.sca.spi.utils; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.URL; + +/** + * TODO: Shouldn't this be using the contrabution service? + */ +public class ResourceHelper { + + public static String readResource(String scriptName) { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL scriptSrcUrl = cl.getResource(scriptName); + if (scriptSrcUrl == null) { + throw new RuntimeException("No script: " + scriptName); + } + + InputStream is; + try { + is = scriptSrcUrl.openStream(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + try { + + Reader reader = new InputStreamReader(is, "UTF-8"); + char[] buffer = new char[1024]; + StringBuilder source = new StringBuilder(); + int count; + while ((count = reader.read(buffer)) > 0) { + source.append(buffer, 0, count); + } + + return source.toString(); + + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + is.close(); + } catch (IOException e) { + // ignore + } + } + } + +} Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/ResourceHelper.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/ResourceHelper.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator?view=auto&rev=543947 ============================================================================== --- incubator/tuscany/java/sca/modules/extension-helper/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator (added) +++ incubator/tuscany/java/sca/modules/extension-helper/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator Sun Jun 3 11:10:20 2007 @@ -0,0 +1,19 @@ +# 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. + +# Implementation class for the ExtensionActivator +org.apache.tuscany.sca.spi.impl.ImplementationsActivator --------------------------------------------------------------------- To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org For additional commands, e-mail: tuscany-commits-help@ws.apache.org