From 6a3ca6736c808c1647854e405ef379b609f276db Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:07:45 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835126 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tuscany/sca/domain/DomainException.java | 53 ++++++ .../org/apache/tuscany/sca/domain/SCADomain.java | 207 +++++++++++++++++++++ .../tuscany/sca/domain/SCADomainFactory.java | 77 ++++++++ 3 files changed, 337 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-1.2.1/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/DomainException.java create mode 100644 sca-java-1.x/branches/sca-java-1.2.1/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/SCADomain.java create mode 100644 sca-java-1.x/branches/sca-java-1.2.1/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/SCADomainFactory.java (limited to 'sca-java-1.x/branches/sca-java-1.2.1/modules/domain-api/src/main/java/org/apache/tuscany') diff --git a/sca-java-1.x/branches/sca-java-1.2.1/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/DomainException.java b/sca-java-1.x/branches/sca-java-1.2.1/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/DomainException.java new file mode 100644 index 0000000000..1a62801b1b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.2.1/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/DomainException.java @@ -0,0 +1,53 @@ +/* + * 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.domain; + + +/** + * Denotes an error starting the runtime + * + * @version $Rev: 568826 $ $Date: 2007-08-23 06:27:34 +0100 (Thu, 23 Aug 2007) $ + */ +public class DomainException extends Exception { + + static final long serialVersionUID = 2096658015909178325L; + + private String message; + + public DomainException() { + } + + public DomainException(String message) { + super(message); + setMessage(message); + } + + public DomainException(Throwable cause) { + super(cause); + setMessage(cause.getMessage()); + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.2.1/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/SCADomain.java b/sca-java-1.x/branches/sca-java-1.2.1/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/SCADomain.java new file mode 100644 index 0000000000..e88a18a534 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.2.1/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/SCADomain.java @@ -0,0 +1,207 @@ +/* + * 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.domain; + +import java.net.URL; + +import javax.xml.namespace.QName; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.ServiceReference; + + +/** + * Represents an SCA domain. + * + * @version $Rev: 580520 $ $Date: 2007-09-29 00:50:25 +0100 (Sat, 29 Sep 2007) $ + */ +public interface SCADomain { + + /** + * Start all of the services in the domain. + */ + public void start() + throws DomainException; + + /** + * Stop all of the services in the domain. + */ + public void stop() + throws DomainException; + + /** + * Destroy the SCA domain. + */ + public void destroy() + throws DomainException; + + /** + * Returns the URI of the SCA Domain. That URI is the endpoint of the + * SCA domain administration service. + * + * @return the URI of the SCA Domain + */ + public String getURI(); + + /** + * Add an SCA contribution to the domain. + * + * @param contributionURI the URI of the contribution + * @param contributionURL the URL of the contribution + * @throws DomainException + */ + public void addContribution(String contributionURI, URL contributionURL) + throws DomainException; + + /** + * Update an SCA contribution that has previousle been added to the domain. + * + * @param contributionURI the URI of the contribution + * @param contributionURL the URL of the contribution + * @throws DomainException + */ + public void updateContribution(String contributionURI, URL contributionURL) + throws DomainException; + + /** + * Remove a contribution from the domain. + * + * @param contributionURI the URI of the contribution + * @throws DomainException + */ + public void removeContribution(String contributionURI) + throws DomainException; + + /** + * Add the supplied composite XML to the identified contribution + * + * @param contributionURI the URI of the contribution + * @param compositeXML the XML string of the composite + * @throws DomainException + */ + public void addDeploymentComposite(String contributionURI, String compositeXML) + throws DomainException; + + /** + * Use the supplied composite XML to update the identified contribution + * + * @param contributionURI the URI of the contribution + * @param compositeXML the XML string of the composite + * @throws DomainException + */ + public void updateDeploymentComposite(String contributionURI, String compositeXML) + throws DomainException; + + /** + * Add a deployable composite to the domain. + * + * @param compositeQName the QName of the composite + * @throws DomainException + */ + public void addToDomainLevelComposite(QName compositeQName) + throws DomainException; + + /** + * Remove a deployable composite from the domain. + * + * @param compositeQName the QName of the composite + * @throws DomainException + */ + public void removeFromDomainLevelComposite(QName compositeQName) + throws DomainException; + + /** + * Returns an XML string representation of the domain level composite + * + * @return xml representing the domain level composite + */ + public String getDomainLevelComposite() + throws DomainException; + + /** + * Returns an XML String representation of a artifact from within the + * domain namespace formed by the domain level composite + * + * @return xml representing the specified artifact + */ + public String getQNameDefinition(QName artifact) + throws DomainException; + + /** + * Start a composite. The domain is responsible for starting all the + * components in the composite. It may decompose the composite into + * one or more smaller composites and load these composites into + * an appropriate SCA node for execution. + * + * @param compositeQName The QName of the composite + * @throws DomainException + */ + public void startComposite(QName compositeQName) + throws DomainException; + + /** + * Stop a composite. The domain will stop all the components from the + * specified composite. + * + * @param compositeQName The QName of the composite + * @throws DomainException + */ + public void stopComposite(QName compositeQName) + throws DomainException; + + /** + * Cast a type-safe reference to a CallahbleReference. Converts a type-safe + * reference to an equivalent CallableReference; if the target refers to a + * service then a ServiceReference will be returned, if the target refers to + * a callback then a CallableReference will be returned. + * + * @param target a reference proxy provided by the SCA runtime + * @param the Java type of the business interface for the reference + * @param the type of reference to be returned + * @return a CallableReference equivalent for the proxy + * @throws IllegalArgumentException if the supplied instance is not a + * reference supplied by the SCA runtime + */ + public > R cast(B target) throws IllegalArgumentException; + + /** + * Returns a proxy for a service provided by a component in the SCA domain. + * + * @param businessInterface the interface that will be used to invoke the + * service + * @param serviceName the name of the service + * @param the Java type of the business interface for the service + * @return an object that implements the business interface + */ + public B getService(Class businessInterface, String serviceName); + + /** + * Returns a ServiceReference for a service provided by a component in the + * SCA domain. + * + * @param businessInterface the interface that will be used to invoke the + * service + * @param serviceName the name of the service + * @param the Java type of the business interface for the service + * @return a ServiceReference for the designated service + */ + public ServiceReference getServiceReference(Class businessInterface, String referenceName); + +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-1.2.1/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/SCADomainFactory.java b/sca-java-1.x/branches/sca-java-1.2.1/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/SCADomainFactory.java new file mode 100644 index 0000000000..860ab0171b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.2.1/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/SCADomainFactory.java @@ -0,0 +1,77 @@ +/* + * 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.domain; + +import java.lang.reflect.Constructor; + +import org.osoa.sca.ServiceRuntimeException; + +/** + * A factory for SCA domains. + * + * @version $Rev: 580520 $ $Date: 2007-09-29 00:50:25 +0100 (Sat, 29 Sep 2007) $ + */ +public abstract class SCADomainFactory { + + + /** + * Returns a new SCA domain factory instance. + * + * @return a new SCA domain factory + */ + public static SCADomainFactory newInstance() { + + SCADomainFactory scaDomainFactory = null; + + try { + final ClassLoader classLoader = SCADomainFactory.class.getClassLoader(); + String className = "org.apache.tuscany.sca.domain.impl.SCADomainFactoryImpl"; + + Class cls = Class.forName(className, true, classLoader); + + Constructor constructor = null; + + try { + constructor = cls.getConstructor(); + } catch (NoSuchMethodException e) { + // ignore + } + + if (constructor != null) { + scaDomainFactory = (SCADomainFactory)constructor.newInstance(); + } + + return scaDomainFactory; + + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } + } + + /** + * Creates a new SCA domain. + * + * @param domainURI the URI of the domain, this is the endpoint + * URI of the domain administration service + * @return a new SCA domain + */ + public abstract SCADomain createSCADomain(String domainURI) throws DomainException; + +} -- cgit v1.2.3