From 80ccc206b5c86dbd8f4d6ba30307e8de2e4764bf Mon Sep 17 00:00:00 2001 From: slaws Date: Mon, 15 Nov 2010 14:05:17 +0000 Subject: Tag for 2.0-Beta1-RC3 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1035279 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/runtime/ActivationException.java | 37 +++++ .../sca/runtime/BaseDomainRegistryFactory.java | 115 ++++++++++++++ .../tuscany/sca/runtime/BaseEndpointRegistry.java | 141 +++++++++++++++++ .../tuscany/sca/runtime/CompositeActivator.java | 159 +++++++++++++++++++ ...DefaultDomainRegistryFactoryExtensionPoint.java | 103 +++++++++++++ .../DefaultWireProcessorExtensionPoint.java | 127 ++++++++++++++++ .../tuscany/sca/runtime/DomainRegistryFactory.java | 61 ++++++++ .../DomainRegistryFactoryExtensionPoint.java | 51 +++++++ .../tuscany/sca/runtime/DomainRegistryURI.java | 168 +++++++++++++++++++++ .../tuscany/sca/runtime/EndpointListener.java | 46 ++++++ .../sca/runtime/EndpointReferenceBinder.java | 52 +++++++ .../tuscany/sca/runtime/EndpointRegistry.java | 71 +++++++++ .../tuscany/sca/runtime/EndpointSerializer.java | 36 +++++ .../runtime/ExtensibleDomainRegistryFactory.java | 133 ++++++++++++++++ .../org/apache/tuscany/sca/runtime/Invocable.java | 137 +++++++++++++++++ .../tuscany/sca/runtime/ReferenceParameters.java | 59 ++++++++ .../tuscany/sca/runtime/RuntimeComponent.java | 84 +++++++++++ .../sca/runtime/RuntimeComponentContext.java | 70 +++++++++ .../sca/runtime/RuntimeComponentReference.java | 38 +++++ .../sca/runtime/RuntimeComponentService.java | 33 ++++ .../tuscany/sca/runtime/RuntimeEndpoint.java | 83 ++++++++++ .../sca/runtime/RuntimeEndpointReference.java | 80 ++++++++++ .../tuscany/sca/runtime/RuntimeProperties.java | 31 ++++ .../tuscany/sca/runtime/RuntimeWireProcessor.java | 39 +++++ .../RuntimeWireProcessorExtensionPoint.java | 53 +++++++ .../org/apache/tuscany/sca/runtime/Version.java | 47 ++++++ 26 files changed, 2054 insertions(+) create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseDomainRegistryFactory.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseEndpointRegistry.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultDomainRegistryFactoryExtensionPoint.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactoryExtensionPoint.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryURI.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointListener.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ExtensibleDomainRegistryFactory.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Invocable.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeProperties.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.java create mode 100644 sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java (limited to 'sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime') diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.java new file mode 100644 index 0000000000..b015891e93 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.java @@ -0,0 +1,37 @@ +/* + * 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.runtime; + + +/** + * Denotes an error starting the runtime + * + * @version $Rev$ $Date$ + */ +public class ActivationException extends Exception { + private static final long serialVersionUID = 8612661660934426123L; + + public ActivationException(String message) { + super(message); + } + + public ActivationException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseDomainRegistryFactory.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseDomainRegistryFactory.java new file mode 100644 index 0000000000..4f6a29bbcc --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseDomainRegistryFactory.java @@ -0,0 +1,115 @@ +/* + * 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.runtime; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.LifeCycleListener; + +/** + * The utility responsible for finding the endpoint regstry by the scheme and creating instances for the + * given domain + * @tuscany.spi.extension.inheritfrom + */ +public abstract class BaseDomainRegistryFactory implements DomainRegistryFactory, LifeCycleListener { + protected ExtensionPointRegistry registry; + protected Map endpointRegistries = new ConcurrentHashMap(); + protected List listeners = new ArrayList(); + + /** + * @param extensionRegistry + */ + public BaseDomainRegistryFactory(ExtensionPointRegistry registry) { + super(); + this.registry = registry; + } + + public void start() { + } + + public synchronized EndpointRegistry getEndpointRegistry(String endpointRegistryURI, String domainURI) { + if (endpointRegistryURI == null) { + endpointRegistryURI = domainURI; + } + + Object key = getKey(endpointRegistryURI, domainURI); + + EndpointRegistry endpointRegistry = endpointRegistries.get(key); + if (endpointRegistry != null) { + return endpointRegistry; + } + + endpointRegistry = createEndpointRegistry(endpointRegistryURI, domainURI); + + if (endpointRegistry instanceof LifeCycleListener) { + ((LifeCycleListener)endpointRegistry).start(); + } + + for (EndpointListener listener : listeners) { + endpointRegistry.addListener(listener); + } + endpointRegistries.put(key, endpointRegistry); + return endpointRegistry; + } + + protected Object getKey(String endpointRegistryURI, String domainURI) { + return endpointRegistryURI + "," + domainURI; + } + + protected abstract EndpointRegistry createEndpointRegistry(String endpointRegistryURI, String domainURI); + + public void stop() { + for (EndpointRegistry endpointRegistry : endpointRegistries.values()) { + if (endpointRegistry instanceof LifeCycleListener) { + ((LifeCycleListener)endpointRegistry).stop(); + } + } + endpointRegistries.clear(); + listeners.clear(); + } + + public synchronized Collection getEndpointRegistries() { + return new ArrayList(endpointRegistries.values()); + } + + public synchronized void addListener(EndpointListener listener) { + listeners.add(listener); + for (EndpointRegistry registry : endpointRegistries.values()) { + registry.addListener(listener); + } + } + + public synchronized List getListeners() { + return listeners; + } + + public synchronized void removeListener(EndpointListener listener) { + listeners.remove(listener); + for (EndpointRegistry registry : endpointRegistries.values()) { + registry.removeListener(listener); + } + } + +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseEndpointRegistry.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseEndpointRegistry.java new file mode 100644 index 0000000000..0b6b93edc0 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseEndpointRegistry.java @@ -0,0 +1,141 @@ +/* + * 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.runtime; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.logging.Logger; + +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.LifeCycleListener; + +/** + * A replicated EndpointRegistry based on Apache Tomcat Tribes + * @tuscany.spi.extension.inheritfrom + */ +public abstract class BaseEndpointRegistry implements EndpointRegistry, LifeCycleListener { + protected final static Logger logger = Logger.getLogger(BaseEndpointRegistry.class.getName()); + + protected String domainRegistryURI; + protected String domainURI; + + protected List endpointreferences = new CopyOnWriteArrayList(); + protected List listeners = new CopyOnWriteArrayList(); + protected ExtensionPointRegistry registry; + protected Map attributes; + + public BaseEndpointRegistry(ExtensionPointRegistry registry, + Map attributes, + String domainRegistryURI, + String domainURI) { + this.registry = registry; + this.domainURI = domainURI; + this.domainRegistryURI = domainRegistryURI; + this.attributes = attributes; + } + + public abstract void addEndpoint(Endpoint endpoint); + + public void addEndpointReference(EndpointReference endpointReference) { + endpointreferences.add(endpointReference); + logger.fine("Add endpoint reference - " + endpointReference); + } + + public void addListener(EndpointListener listener) { + listeners.add(listener); + } + + protected void endpointAdded(Endpoint endpoint) { + ((RuntimeEndpoint)endpoint).bind(registry, this); + for (EndpointListener listener : listeners) { + listener.endpointAdded(endpoint); + } + } + + protected void endpointRemoved(Endpoint endpoint) { + ((RuntimeEndpoint)endpoint).bind(registry, this); + for (EndpointListener listener : listeners) { + listener.endpointRemoved(endpoint); + } + } + + protected void endpointUpdated(Endpoint oldEp, Endpoint newEp) { + ((RuntimeEndpoint)newEp).bind(registry, this); + for (EndpointListener listener : listeners) { + listener.endpointUpdated(oldEp, newEp); + } + } + + public List findEndpoint(EndpointReference endpointReference) { + logger.fine("Find endpoint for reference - " + endpointReference); + + if (endpointReference.getReference() != null) { + Endpoint targetEndpoint = endpointReference.getTargetEndpoint(); + String uri = targetEndpoint.getURI(); + // [rfeng] This is a workaround to deal with the case that the endpoint URI doesn't have the + // service name to avoid confusion between structural URIs and service URIs + if (uri.indexOf('#') == -1) { + uri = uri + "#service()"; + } + return findEndpoint(uri); + } + + return new ArrayList(); + } + + public abstract List findEndpoint(String uri); + + public List findEndpointReference(Endpoint endpoint) { + return endpointreferences; + } + + public abstract Endpoint getEndpoint(String uri); + + public List getEndpointReferences() { + return endpointreferences; + } + + public abstract Collection getEndpoints(); + + public List getListeners() { + return listeners; + } + + public abstract void removeEndpoint(Endpoint endpoint); + + public void removeEndpointReference(EndpointReference endpointReference) { + endpointreferences.remove(endpointReference); + logger.fine("Remove endpoint reference - " + endpointReference); + } + + public void removeListener(EndpointListener listener) { + listeners.remove(listener); + } + + public String getDomainURI() { + return domainURI; + } + +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java new file mode 100644 index 0000000000..d9bdc2b6f6 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java @@ -0,0 +1,159 @@ +/* + * 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.runtime; + +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.context.CompositeContext; + +/** + * Start/stop a composite + * + * @version $Rev$ $Date$ + */ +public interface CompositeActivator { + /** + * Activate a composite + * @param compositeContext The context of the Node + * @param composite + */ + void activate(CompositeContext compositeContext, Composite composite) throws ActivationException; + + /** + * Activate a component reference + * @param compositeContext The context of the Node + * @param component + * @param ref + */ + void activate(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentReference ref); + + /** + * Activate a component reference + * @param compositeContext The context of the Node + * @param component + * @param ref + */ + void activate(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentService service); + + /** + * De-activate a component reference + * @param component + * @param ref + */ + void deactivate(RuntimeComponent component, RuntimeComponentReference ref); + + /** + * De-activate a component reference + * @param component + * @param ref + */ + void deactivate(RuntimeComponent component, RuntimeComponentService service); + + /** + * Stop a composite + * @param composite + */ + void deactivate(Composite composite) throws ActivationException; + + /** + * Start a component reference + * @param compositeContext The context of the Node + * @param component + * @param ref + */ + void start(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentReference ref); + + + /** + * Start a component + * @param component + */ + void start(CompositeContext compositeContext, Component component) throws ActivationException; + + /** + * Stop a component + * @param component + */ + void stop(CompositeContext compositeContext, Component component) throws ActivationException; + + /** + * Start components in a composite + * @param composite + */ + void start(CompositeContext compositeContext, Composite composite) throws ActivationException; + + /** + * Stop components in a composite + * @param composite + */ + void stop(CompositeContext compositeContext, Composite composite) throws ActivationException; + + /** + * Activate an endpoint + * @param compositeContext + * @param endpoint + */ + void activate(CompositeContext compositeContext, RuntimeEndpoint endpoint); + + /** + * Activate an endpoint reference + * @param compositeContext + * @param endpointReference + */ + void activate(CompositeContext compositeContext, RuntimeEndpointReference endpointReference); + + /** + * Deactivate an endpoint + * @param endpoint + */ + void deactivate(RuntimeEndpoint endpoint); + + /** + * Deactivate an endpoint reference + * @param endpointReference + */ + void deactivate(RuntimeEndpointReference endpointReference); + + /** + * Start an endpoint + * @param compositeContext + * @param endpoint + */ + void start(CompositeContext compositeContext, RuntimeEndpoint endpoint); + + /** + * Start an endpoint reference + * @param compositeContext + * @param endpointReference + */ + void start(CompositeContext compositeContext, RuntimeEndpointReference endpointReference); + + /** + * Stop an endpoint + * @param endpoint + */ + void stop(RuntimeEndpoint endpoint); + + /** + * Stop an endpoint reference + * @param endpointReference + */ + void stop(RuntimeEndpointReference endpointReference); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultDomainRegistryFactoryExtensionPoint.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultDomainRegistryFactoryExtensionPoint.java new file mode 100644 index 0000000000..f74d80b882 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultDomainRegistryFactoryExtensionPoint.java @@ -0,0 +1,103 @@ +/* + * 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.runtime; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.LifeCycleListener; +import org.apache.tuscany.sca.extensibility.ServiceDeclaration; +import org.apache.tuscany.sca.extensibility.ServiceHelper; +import org.oasisopen.sca.ServiceRuntimeException; + +/** + * Default implementation of DomainRegistryFactoryExtensionPoint + */ +public class DefaultDomainRegistryFactoryExtensionPoint implements DomainRegistryFactoryExtensionPoint, + LifeCycleListener { + private ExtensionPointRegistry registry; + private boolean loaded; + private List factories = new ArrayList(); + private Map domainRegistryMapping = new HashMap(); + + /** + * @param registry + */ + public DefaultDomainRegistryFactoryExtensionPoint(ExtensionPointRegistry registry, Map attributes) { + super(); + this.registry = registry; + // Populate the domainRegistryMapping + domainRegistryMapping.putAll(attributes); + domainRegistryMapping.remove("class"); + domainRegistryMapping.remove("ranking"); + } + + public void addDomainRegistryFactory(DomainRegistryFactory factory) { + ServiceHelper.start(factory); + factories.add(factory); + } + + public List getDomainRegistryFactories() { + load(); + return factories; + } + + private synchronized void load() { + if (loaded) { + return; + } + try { + Collection declarations = + registry.getServiceDiscovery().getServiceDeclarations(DomainRegistryFactory.class, true); + for (ServiceDeclaration declaration : declarations) { + DomainRegistryFactory factory = ServiceHelper.newInstance(registry, declaration); + addDomainRegistryFactory(factory); + } + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } finally { + loaded = true; + } + } + + public void removeDomainRegistryFactory(DomainRegistryFactory factory) { + if (factories.remove(factory)) { + ServiceHelper.stop(factory); + } + + } + + public void start() { + // Empty + } + + public void stop() { + ServiceHelper.stop(factories); + } + + public Map getDomainRegistryMapping() { + return domainRegistryMapping; + } + +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java new file mode 100644 index 0000000000..283d1d1a8b --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java @@ -0,0 +1,127 @@ +/* + * 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.runtime; + +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.LifeCycleListener; +import org.apache.tuscany.sca.extensibility.ServiceDeclaration; +import org.apache.tuscany.sca.extensibility.ServiceDiscovery; + +/** + * The default implementation of a WireProcessorExtensionPoint + * + * @version $Rev$ $Date$ + */ +public class DefaultWireProcessorExtensionPoint implements RuntimeWireProcessorExtensionPoint, LifeCycleListener { + private ExtensionPointRegistry registry; + private boolean loaded; + + /** + * @param registry + */ + public DefaultWireProcessorExtensionPoint(ExtensionPointRegistry registry) { + super(); + this.registry = registry; + } + + /** + * The list of WireProcessors available to the runtime + */ + private final List processors = new ArrayList(); + + /** + * Registers a wire-processor in the runtime + * + * @param processor The processor to register + */ + public void addWireProcessor(RuntimeWireProcessor processor) { + processors.add(processor); + if (processor instanceof LifeCycleListener) { + ((LifeCycleListener)processor).start(); + } + } + + /** + * De-registers a wire-processor in the runtime + * + * @param processor The processor to de-register + */ + public void removeWireProcessor(RuntimeWireProcessor processor) { + boolean found = processors.remove(processor); + if (found && (processor instanceof LifeCycleListener)) { + ((LifeCycleListener)processor).stop(); + } + } + + /** + * Returns a list of registered wire-processors. + * + * @return The list of wire processors + */ + public List getWireProcessors() { + loadWireProcessors(); + return processors; + } + + private synchronized void loadWireProcessors() { + if (loaded) { + return; + } + try { + Collection sds = + registry.getServiceDiscovery().getServiceDeclarations(RuntimeWireProcessor.class, true); + for (ServiceDeclaration sd : sds) { + Class type = sd.loadClass(); + Constructor constructor = null; + RuntimeWireProcessor processor = null; + try { + constructor = type.getConstructor(ExtensionPointRegistry.class); + processor = (RuntimeWireProcessor)constructor.newInstance(registry); + + } catch (NoSuchMethodException e) { + constructor = type.getConstructor(); + processor = (RuntimeWireProcessor)constructor.newInstance(); + } + if (processor != null) { + addWireProcessor(processor); + } + } + loaded = true; + } catch (Throwable e) { + throw new IllegalStateException(e); + } + } + + public void start() { + } + + public void stop() { + for (RuntimeWireProcessor processor : processors) { + if ((processor instanceof LifeCycleListener)) { + ((LifeCycleListener)processor).stop(); + } + } + processors.clear(); + } +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java new file mode 100644 index 0000000000..c79fab1f47 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java @@ -0,0 +1,61 @@ +/* + * 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.runtime; + +import java.util.Collection; + +/** + * A DomainRegistryFactory is responsible for creating an instance of the DomainRegistry for a given + * registry URI and domain URI + */ +public interface DomainRegistryFactory { + /** + * Get the EndpointRegistry for the given registry URI and domain URI + * @param endpointRegistryURI A URI can be used to connect to the registry, such as vm://localhost + * or multicast://200.0.100.200:50000/... + * @param domainURI The domain URI + * @return + */ + EndpointRegistry getEndpointRegistry(String endpointRegistryURI, String domainURI); + + /** + * Return all active endpoint registries + * @return + */ + Collection getEndpointRegistries(); + + /** + * Add an EndpointListener + * @param listener + */ + void addListener(EndpointListener listener); + + /** + * Remove an EndpointListener + * @param listener + */ + void removeListener(EndpointListener listener); + + /** + * Return an array of schemes that this factory supports + * @return + */ + String[] getSupportedSchemes(); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactoryExtensionPoint.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactoryExtensionPoint.java new file mode 100644 index 0000000000..f1582c3d70 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactoryExtensionPoint.java @@ -0,0 +1,51 @@ +/* + * 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.runtime; + +import java.util.List; +import java.util.Map; + +/** + * Extension point for DomainRegistryFactory + */ +public interface DomainRegistryFactoryExtensionPoint { + /** + * Return a mapping between domain URI and domain registry URI + * @return A mutable map + */ + Map getDomainRegistryMapping(); + + /** + * Add a DomainRegistryFactory + * @param factory + */ + void addDomainRegistryFactory(DomainRegistryFactory factory); + + /** + * Remove a DomainRegistryFactory + * @param factory + */ + void removeDomainRegistryFactory(DomainRegistryFactory factory); + + /** + * @return A list of DomainRegistryFactory + */ + List getDomainRegistryFactories(); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryURI.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryURI.java new file mode 100644 index 0000000000..6de0878383 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryURI.java @@ -0,0 +1,168 @@ +/* + * 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.runtime; + +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * Utility to parse the config uri string. + * + * tuscany:[domainName]?listen=[port|ip:port]]&password=abc&multicast=[off|port|ip:port]&remotes=ip:port,ip:port,... + + * listen - defines the local bind address and port, it defaults to all network interfaces on port 14820 and if that port in use it will try incrementing by one till a free port is found. + * password - is the password other nodes must use to connect to this domain. The default is 'tuscany'. + * multicast - defines if multicast discovery is used and if so what multicast ip group and port is used. + * The default is multicast is off if remotes= is specified (only for now due to a Hazelcast limitation that is planned to be fixed), + * otherwise if remotes= is not specified then multicast defaults to 224.5.12.10:51482 + * remotes - a list of ipAddress:port for remote nodes + * + * @tuscany.spi.extension.asclient + * + */ +public class DomainRegistryURI { + + private String domainName = "default"; + private String bindAddress = null; // null means all network adapters + private int listenPort = 14820; + private String password = "tuscany"; + private boolean multicastDisabled = false; + private String multicastAddress = "224.5.12.10"; + private int multicastPort = 51482; + private List remotes = new ArrayList(); + private String uri; + + public DomainRegistryURI(String uri) { + this.uri = uri; + parseURI(uri); + } + + private void parseURI(String uri) { + if (uri.startsWith("tuscanyclient:")) { + uri = uri.replace("tuscanyclient:", "tuscany:"); + } + + if (!uri.startsWith("tuscany:")) { + throw new IllegalArgumentException("Config URI must start with 'tuscany:'"); + } + + // make it a URI so java.net.URI can be used to parse it + int i = uri.indexOf(":"); + if (uri.charAt("tuscany:".length()) != '/') { + uri = uri.replaceFirst(":", ":/"); + } + if (uri.charAt("tuscany:".length()+1) != '/') { + uri = uri.replaceFirst(":/", "://"); + } + URI configURI = URI.create(uri); + + this.domainName = configURI.getHost(); + + String query = configURI.getQuery(); + if (query != null && query.length() > 0) { + String[] params = query.split("&"); + Map paramMap = new HashMap(); + for (String param : params) { + paramMap.put(param.split("=")[0], param.split("=")[1]); + } + for (String name : paramMap.keySet()) { + String value = paramMap.get(name); + if ("listen".equals(name)) { + if (value.indexOf(":") == -1) { + this.listenPort = Integer.parseInt(value); + } else { + String[] addr = value.split(":"); + this.bindAddress = addr[0]; + this.listenPort = Integer.parseInt(addr[1]); + } + } else if ("multicast".equals(name)) { + if ("off".equalsIgnoreCase(value)) { + this.multicastDisabled = true; + } else { + if (value.indexOf(":") == -1) { + this.multicastAddress = value; + } else { + String[] addr = value.split(":"); + this.multicastAddress = addr[0]; + this.multicastPort = Integer.parseInt(addr[1]); + } + } + } else if ("password".equals(name)) { + this.password = value; + } else if ("remotes".equals(name)) { + String[] ips = value.split(","); + for (String ip : ips) { + if (ip.indexOf(":") == -1) { + remotes.add(ip + ":14820"); + } else { + remotes.add(ip); + } + } + if (paramMap.containsKey("multicast")) { +// throw new IllegalArgumentException("Cannot have multicast and remotes (for now)"); + } else { + this.multicastDisabled = true; + } + } + } + } + } + + public String getDomainName() { + return domainName; + } + + public String getBindAddress() { + return bindAddress; + } + + public int getListenPort() { + return listenPort; + } + + public String getPassword() { + return password; + } + + public boolean isMulticastDisabled() { + return multicastDisabled; + } + + public String getMulticastAddress() { + return multicastAddress; + } + + public int getMulticastPort() { + return multicastPort; + } + + public List getRemotes() { + return remotes; + } + + public String toString() { + return uri; + } + +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointListener.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointListener.java new file mode 100644 index 0000000000..13d193c464 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointListener.java @@ -0,0 +1,46 @@ +/* + * 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.runtime; + +import java.util.EventListener; + +import org.apache.tuscany.sca.assembly.Endpoint; + +/** + * A listener for endpoint events + */ +public interface EndpointListener extends EventListener { + /** + * The method is invoked when a new endpoint is added to the registry + * @param endpoint + */ + void endpointAdded(Endpoint endpoint); + /** + * The method is invoked when an endpoint is removed the registry + * @param endpoint + */ + void endpointRemoved(Endpoint endpoint); + /** + * The method is invoked when an endpoint is updated in the registry + * @param oldEndpoint + * @param newEndpoint + */ + void endpointUpdated(Endpoint oldEndpoint, Endpoint newEndpoint); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java new file mode 100644 index 0000000000..b2ce3f5b7b --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java @@ -0,0 +1,52 @@ +/* + * 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.runtime; + +import org.apache.tuscany.sca.assembly.EndpointReference; + +/** + * A utility responsible for resolving the endpoint reference against a matching endpoint published + * to the EndpointRegistry + */ +public interface EndpointReferenceBinder { + + /** + * @param endpointRegistry + * @param endpointReference + * @return + */ + void bindBuildTime(EndpointRegistry endpointRegistry, EndpointReference endpointReference); + + + /** + * @param endpointRegistry + * @param endpointReference + * @return + */ + void bindRunTime(EndpointRegistry endpointRegistry, EndpointReference endpointReference); + + /** + * + * @param endpointRegistry + * @param endpointReference + * @return + */ + boolean isOutOfDate(EndpointRegistry endpointRegistry, EndpointReference endpointReference); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java new file mode 100644 index 0000000000..2c01eb115a --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java @@ -0,0 +1,71 @@ +/* + * 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.runtime; + +import java.util.Collection; +import java.util.List; + +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.EndpointReference; + +/** + * The EndpointRegistry holds the active service endpoints for the SCA domain + * @tuscany.spi.extension.inheritfrom + */ +public interface EndpointRegistry { + /** + * Add an enpoint to the registry. If the endpoint URI is the same as an existing endpoint in the registry, + * the existing one will be updated + * @param endpoint + */ + void addEndpoint(Endpoint endpoint); + + /** + * Remove an enpoint from the registry + * @param endpoint + */ + void removeEndpoint(Endpoint endpoint); + + /** + * Look up an enpoint from the registry + * @param uri The endpoint URI + * @return + */ + Endpoint getEndpoint(String uri); + + /** + * Get all endpoints in the registry + * @return + */ + Collection getEndpoints(); + + List findEndpoint(String uri); + List findEndpoint(EndpointReference endpointReference); + + void addEndpointReference(EndpointReference endpointReference); + void removeEndpointReference(EndpointReference endpointReference); + // List findEndpointReference(Endpoint endpoint); + List getEndpointReferences(); + + void addListener(EndpointListener listener); + void removeListener(EndpointListener listener); + + String getDomainURI(); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java new file mode 100644 index 0000000000..981872fdfa --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java @@ -0,0 +1,36 @@ +/* + * 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.runtime; + +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.EndpointReference; + +/** + * A utility to seralize/deserialize Endpoint/EndpointReference objects + */ +public interface EndpointSerializer { + EndpointReference readEndpointReference(String xml); + + String write(EndpointReference endpointReference); + + Endpoint readEndpoint(String xml); + + String write(Endpoint endpoint); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ExtensibleDomainRegistryFactory.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ExtensibleDomainRegistryFactory.java new file mode 100644 index 0000000000..d1d0fb2b29 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ExtensibleDomainRegistryFactory.java @@ -0,0 +1,133 @@ +/* + * 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.runtime; + +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.oasisopen.sca.ServiceRuntimeException; + +/** + * A delegating DomainRegistryFactory + */ +public class ExtensibleDomainRegistryFactory implements DomainRegistryFactory { + private final DomainRegistryFactoryExtensionPoint factories; + private String[] allSchemes; + private String defaultScheme = "tuscany"; + + public ExtensibleDomainRegistryFactory(ExtensionPointRegistry registry) { + this.factories = registry.getExtensionPoint(DomainRegistryFactoryExtensionPoint.class); + RuntimeProperties ps = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class); + if (ps.getProperties().containsKey("defaultScheme")) { + defaultScheme = ps.getProperties().getProperty("defaultScheme"); + } + + } + + public ExtensibleDomainRegistryFactory(DomainRegistryFactoryExtensionPoint factories) { + this.factories = factories; + } + + public static ExtensibleDomainRegistryFactory getInstance(ExtensionPointRegistry registry) { + UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); + return utilities.getUtility(ExtensibleDomainRegistryFactory.class); + } + + public void addListener(EndpointListener listener) { + for (DomainRegistryFactory factory : factories.getDomainRegistryFactories()) { + factory.addListener(listener); + } + } + + public Collection getEndpointRegistries() { + List registries = new ArrayList(); + for (DomainRegistryFactory factory : factories.getDomainRegistryFactories()) { + registries.addAll(factory.getEndpointRegistries()); + } + return registries; + } + + public EndpointRegistry getEndpointRegistry(String endpointRegistryURI, String domainURI) { + if (endpointRegistryURI == null) { + endpointRegistryURI = factories.getDomainRegistryMapping().get(domainURI); + if (endpointRegistryURI == null) { + endpointRegistryURI = domainURI; + } + } + + String scheme = endpointRegistryURI == null ? null : URI.create(endpointRegistryURI).getScheme(); + if (scheme == null) { + + // See if there is a previously created registry for that domain + for (DomainRegistryFactory factory : factories.getDomainRegistryFactories()) { + for (EndpointRegistry endpointRegistry : factory.getEndpointRegistries()) { + if (endpointRegistry.getDomainURI().equals(domainURI)) { + return endpointRegistry; + } + } + } + + scheme = defaultScheme; + endpointRegistryURI = scheme + ":" + endpointRegistryURI; + } else { + scheme = scheme.toLowerCase(); + } + for (DomainRegistryFactory factory : factories.getDomainRegistryFactories()) { + String[] schemes = factory.getSupportedSchemes(); + if (schemes != null && Arrays.asList(schemes).contains(scheme)) { + EndpointRegistry endpointRegistry = factory.getEndpointRegistry(endpointRegistryURI, domainURI); + if (endpointRegistry == null) { + continue; + } else { + return endpointRegistry; + } + } + } + throw new ServiceRuntimeException("No EndpointRegistry can support " + endpointRegistryURI); + } + + public void removeListener(EndpointListener listener) { + for (DomainRegistryFactory factory : factories.getDomainRegistryFactories()) { + factory.removeListener(listener); + } + } + + public synchronized String[] getSupportedSchemes() { + if (allSchemes == null) { + Set supportedSchemes = new HashSet(); + for (DomainRegistryFactory factory : factories.getDomainRegistryFactories()) { + String[] schemes = factory.getSupportedSchemes(); + if (schemes != null) { + supportedSchemes.addAll(Arrays.asList(schemes)); + } + } + allSchemes = supportedSchemes.toArray(new String[supportedSchemes.size()]); + } + return allSchemes; + } + +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Invocable.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Invocable.java new file mode 100644 index 0000000000..2df1761aec --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Invocable.java @@ -0,0 +1,137 @@ +/* + * 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.runtime; + +import java.lang.reflect.InvocationTargetException; +import java.util.List; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.Contract; +import org.apache.tuscany.sca.context.CompositeContext; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.InvocationChain; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.provider.PolicyProvider; + +/** + * The abstraction of an invocable model that contains invocation chains + * @tuscany.spi.extension.asclient + */ +public interface Invocable { + /** + * Bind the invocable to the composite context + * @param context + */ + void bind(CompositeContext context); + + /** + * Bind the invocable to the extension point registry and endpoint registry. This is typically + * called after the endpoint or endpoint reference is deserialized + * @param registry + * @param endpointRegistry + */ + void bind(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry); + + /** + * Get the associated composite context + * @return + */ + CompositeContext getCompositeContext(); + + /** + * Unbind the invocable from the composite context + */ + void unbind(); + + /** + * Get the component + * @return + */ + Component getComponent(); + + /** + * Get the service or reference (contract) + * @return + */ + Contract getContract(); + + /** + * Get the binding + * @return + */ + Binding getBinding(); + + /** + * Returns the invocation chains for service operations associated with the + * wire + * + * @return the invocation chains for service operations associated with the + * wire + */ + List getInvocationChains(); + + /** + * Lookup the invocation chain by operation + * @param operation The operation + * @return The invocation chain for the given operation + */ + InvocationChain getInvocationChain(Operation operation); + + /** + * Get the invocation chain for the binding-specific handling + * @return The binding invocation chain + */ + InvocationChain getBindingInvocationChain(); + + /** + * This invoke method assumes that the binding invocation chain is in force + * and that there will be an operation selector element there to + * determine which operation to call + * @param msg The request message + * @return The response message + */ + Message invoke(Message msg); + + /** + * Invoke an operation with given arguments + * @param operation The operation + * @param args The arguments + * @return The result + * @throws InvocationTargetException + */ + Object invoke(Operation operation, Object[] args) throws InvocationTargetException; + + /** + * Invoke an operation with a context message + * @param operation The operation + * @param msg The request message + * @return The response message + * @throws InvocationTargetException + */ + Message invoke(Operation operation, Message msg); + + /** + * Get a list of policy providers + * @return + */ + List getPolicyProviders(); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java new file mode 100644 index 0000000000..928c77fd04 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java @@ -0,0 +1,59 @@ +/* + * 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.runtime; + +import org.apache.tuscany.sca.assembly.EndpointReference; + +/** + * Parameters for the EndPointReference + * + * @version $Rev$ $Date$ + */ +public interface ReferenceParameters extends Cloneable { + /** + * Get the callback ID + * @return the callbackID + */ + Object getCallbackID(); + + /** + * Set the callback ID + * @param callbackID the callbackID to set + */ + void setCallbackID(Object callbackID); + + /** + * Get the ID for the non-ServiceReference callback object + * @return + */ + Object getCallbackObjectID(); + + /** + * Set the ID for the non-ServiceReference callback object + * @param callbackObjectID + */ + void setCallbackObjectID(Object callbackObjectID); + + EndpointReference getCallbackReference(); + + void setCallbackReference(EndpointReference callback); + + Object clone() throws CloneNotSupportedException; +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java new file mode 100644 index 0000000000..efc4b278b3 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java @@ -0,0 +1,84 @@ +/* + * 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.runtime; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.PolicyProvider; + +/** + * The runtime component interface. Provides the bridge between the + * assembly model representation of a component and its runtime + * realization. + * + * @version $Rev$ $Date$ + * @tuscany.spi.extension.asclient + */ +public interface RuntimeComponent extends Component { + /** + * Set the implementation-specific configuration for this component + * @param implementationProvider The object that manages the component implementation + */ + void setImplementationProvider(ImplementationProvider implementationProvider); + + /** + * Get the implementation-specific configuration for this component + * @return The implementation provider for this component + */ + ImplementationProvider getImplementationProvider(); + + /** + * Get the associated component context + * @return + */ + RuntimeComponentContext getComponentContext(); + + /** + * Set the associated component context + * @param context + */ + void setComponentContext(RuntimeComponentContext context); + + /** + * Tests if the RuntimeComponent is started + * @return true if the RuntimeComponent is started otherwise false + */ + boolean isStarted(); + + /** + * Sets the RuntimeComponent started state + * @param started the state to set + */ + void setStarted(boolean started); + + /** + * Add a policy provider to the component + * @param policyProvider + */ + void addPolicyProvider(PolicyProvider policyProvider); + + /** + * Get a list of policy providers configured for this component + * @return + */ + List getPolicyProviders(); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java new file mode 100644 index 0000000000..861ca2d6f9 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java @@ -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.runtime; + +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.context.CompositeContext; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.ServiceReference; + +/** + * @version $Rev$ $Date$ + */ +public interface RuntimeComponentContext extends ComponentContext { + /** + * Activate the reference (creating runtime wires) + * @param reference + */ + void start(RuntimeComponentReference reference); + + /** + * Get the CallableReference for a given component reference + * @param + * @param businessInterface The business interface + * @param endpointReference The endpointReference to be used + * @return A service reference representing the wire + */ + ServiceReference getServiceReference(Class businessInterface, + RuntimeEndpointReference endpointReference); + + + /** + * Create a CallableReference for the given component service + * @param + * @param businessInterface + * @param component + * @param service + * @return + */ + ServiceReference getServiceReference(Class businessInterface, RuntimeEndpoint endpoint); + + /** + * @param + * @param businessInterface + * @param service + * @return + */ + ServiceReference createSelfReference(Class businessInterface, ComponentService service); + + ExtensionPointRegistry getExtensionPointRegistry(); + + CompositeContext getCompositeContext(); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java new file mode 100644 index 0000000000..8abecee0bf --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java @@ -0,0 +1,38 @@ +/* + * 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.runtime; + +import org.apache.tuscany.sca.assembly.ComponentReference; + +/** + * The runtime component reference. Provides the bridge between the + * assembly model representation of a component reference and its runtime + * realization + * + * @version $Rev$ $Date$ + * @tuscany.spi.extension.asclient + */ +public interface RuntimeComponentReference extends ComponentReference { + /** + * Set the owning component + * @param component + */ + void setComponent(RuntimeComponent component); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java new file mode 100644 index 0000000000..1eefdc978e --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java @@ -0,0 +1,33 @@ +/* + * 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.runtime; + +import org.apache.tuscany.sca.assembly.ComponentService; + +/** + * The runtime component service. Provides the bridge between the + * assembly model representation of a component service and its runtime + * realization + * + * @version $Rev$ $Date$ + * @tuscany.spi.extension.asclient + */ +public interface RuntimeComponentService extends ComponentService { +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java new file mode 100644 index 0000000000..78f2d9546c --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java @@ -0,0 +1,83 @@ +/* + * 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.runtime; + +import java.io.Serializable; + +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.context.CompositeContext; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; + +/** + * The runtime representation of a service endpoint + * @tuscany.spi.extension.asclient + */ +public interface RuntimeEndpoint extends Endpoint, Invocable, Serializable { + /** + * Attach the service binding provider + * @param provider + */ + void setBindingProvider(ServiceBindingProvider provider); + + /** + * Get the service binding provider + * @return + */ + ServiceBindingProvider getBindingProvider(); + + /** + * Get the interface contract for the binding. This represents the data types that the binding + * protocol stack can process. + * @return The binding interface contract + */ + InterfaceContract getBindingInterfaceContract(); + + /** + * Get the interface contract of the service of the target component type, i.e., the + * componentType.service.interfaceContract. This represents the data types that the implementation + * code can process. + * @return The target component type service interface contract + */ + InterfaceContract getComponentTypeServiceInterfaceContract(); + + + /** + * Check that endpoint has compatible interface at the component and binding ends. + * The user can specify the interfaces at both ends so there is a danger that they won't be compatible. + */ + void validateServiceInterfaceCompatibility(); + + /** + * Get the composite context for the composite that contains this endpoint. This + * is useful for accessing various composite level objects from within the + * runtime code + */ + CompositeContext getCompositeContext(); + + /** + * Retrieve the normalized WSDL contract relating to the input WSDL contract + * + * @param interfaceContract + * @return + */ + public InterfaceContract getGeneratedWSDLContract(InterfaceContract interfaceContract); + +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java new file mode 100644 index 0000000000..42e7328c0a --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java @@ -0,0 +1,80 @@ +/* + * 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.runtime; + +import java.io.Serializable; + +import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; + +/** + * The runtime representation of an endpoint reference + * @tuscany.spi.extension.asclient + */ +public interface RuntimeEndpointReference extends EndpointReference, Invocable, Serializable { + /** + * Set the reference binding provider for the endpoint reference + * @param provider The binding provider + */ + void setBindingProvider(ReferenceBindingProvider provider); + + /** + * Get the reference binding provider for the endpoint reference + * @return The binding provider + */ + ReferenceBindingProvider getBindingProvider(); + + /** + * Get the interface contract for the binding. This represents the data types that the binding + * protocol stack can process. + * @return The binding interface contract + */ + InterfaceContract getBindingInterfaceContract(); + + + /** + * Get the interface contract of the reference of the source component type, i.e., the + * componentType.reference.interfaceContract. This represents the data types that the + * implementation code uses to make the outbound call. + * @return The source component type reference interface contract + */ + InterfaceContract getComponentTypeReferenceInterfaceContract(); + + /** + * Check that endpoint reference has compatible interface at the component and binding ends. + * The user can specify the interfaces at both ends so there is a danger that they won't be compatible. + * There is checking in the activator but of course endpoint references may not have a binding assigned + * until final resolution. + */ + public void validateReferenceInterfaceCompatibility(); + + boolean isOutOfDate(); + void rebuild(); + boolean isStarted(); + + /** + * Retrieve the normalized WSDL contract relating to the input WSDL contract + * + * @param interfaceContract + * @return + */ + public InterfaceContract getGeneratedWSDLContract(InterfaceContract interfaceContract); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeProperties.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeProperties.java new file mode 100644 index 0000000000..c413276b37 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeProperties.java @@ -0,0 +1,31 @@ +/* + * 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.runtime; + +import java.util.Properties; +/** + * + * @tuscany.spi.extension.asclient + * + */ +public interface RuntimeProperties { + Properties getProperties(); + void setProperties(Properties properties); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java new file mode 100644 index 0000000000..997e170b22 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java @@ -0,0 +1,39 @@ +/* + * 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.runtime; + +/** + * Implementations are called after wires are decorated with policy and before they are connected. + * + * @version $Rev$ $Date$ + * @tuscany.spi.extension.inheritfrom + */ +public interface RuntimeWireProcessor { + /** + * Configure the runtime endpoint + * @param endpoint + */ + void process(RuntimeEndpoint endpoint); + + /** + * Configure the runtime endpoint reference + * @param endpointReference + */ + void process(RuntimeEndpointReference endpointReference); +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.java new file mode 100644 index 0000000000..4b2c71b397 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.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.runtime; + +import java.util.List; + +/** + * Acts as a delegating WireProcessorExtensionPoint, delegating + * processing of wires after policies have been applied and source and targets + * have been connected. + * + * @version $Rev$ $Date$ + */ +public interface RuntimeWireProcessorExtensionPoint { + + /** + * Registers a wire-processor in the runtime + * + * @param processor The processor to register + */ + void addWireProcessor(RuntimeWireProcessor processor); + + /** + * De-registers a wire-processor in the runtime + * + * @param processor The processor to de-register + */ + void removeWireProcessor(RuntimeWireProcessor processor); + + /** + * Returns a list of registered wire-processors. + * + * @return The list of wire processors + */ + List getWireProcessors(); + +} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java new file mode 100644 index 0000000000..5d3ed1ce41 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta1-RC3/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java @@ -0,0 +1,47 @@ +/* + * 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.runtime; + +import java.util.ResourceBundle; + +public class Version { + + public static final String VERSION; + public static final String REVISION; + public static final String BUILDTIME; + static { + ResourceBundle rb = ResourceBundle.getBundle("org/apache/tuscany/sca/runtime/revision"); + VERSION = rb.getString("version"); + REVISION = rb.getString("revision"); + BUILDTIME = rb.getString("buildtime"); + } + + public static String getVersion() { + return VERSION; + } + + public static String getRevsion() { + return REVISION; + } + + public static String getBuildTime() { + return BUILDTIME; + } +} -- cgit v1.2.3