From 75c4045c9663debea932437ed12954e74e7e27bd Mon Sep 17 00:00:00 2001 From: rfeng Date: Mon, 23 Jun 2008 21:21:18 +0000 Subject: Delete obsolete contents git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@670762 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/core/builder/BuilderRegistryImpl.java | 185 ---------- .../core/builder/ComponentNotFoundException.java | 36 -- .../apache/tuscany/core/builder/ConnectorImpl.java | 385 --------------------- .../core/builder/IllegalCallbackException.java | 36 -- .../builder/IncompatibleInterfacesException.java | 40 --- .../core/builder/InvalidSourceTypeException.java | 35 -- .../core/builder/InvalidTargetTypeException.java | 35 -- .../tuscany/core/builder/NoBindingException.java | 35 -- .../builder/NoCompatibleBindingsException.java | 34 -- .../builder/NoConversationalContractException.java | 37 -- .../core/builder/NoRegisteredBuilderException.java | 38 -- .../builder/SourceServiceNotFoundException.java | 36 -- .../builder/TargetServiceNotFoundException.java | 36 -- .../core/builder/WireCreationException.java | 39 --- .../builder/WirePostProcessorRegistryImpl.java | 50 --- .../core/builder/WiringExceptionFormatter.java | 67 ---- 16 files changed, 1124 deletions(-) delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ComponentNotFoundException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidSourceTypeException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidTargetTypeException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoBindingException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoCompatibleBindingsException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoConversationalContractException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoRegisteredBuilderException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/SourceServiceNotFoundException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/TargetServiceNotFoundException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WireCreationException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WiringExceptionFormatter.java (limited to 'sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder') diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java deleted file mode 100644 index 33dd2175f9..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * 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.core.builder; - -import java.net.URI; -import java.util.HashMap; -import java.util.Map; - -import org.osoa.sca.annotations.EagerInit; - -import org.apache.tuscany.spi.builder.BindingBuilder; -import org.apache.tuscany.spi.builder.BuilderException; -import org.apache.tuscany.spi.builder.BuilderRegistry; -import org.apache.tuscany.spi.builder.ComponentBuilder; -import org.apache.tuscany.spi.builder.ScopeNotFoundException; -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.Reference; -import org.apache.tuscany.spi.component.ReferenceBinding; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.ScopeRegistry; -import org.apache.tuscany.spi.component.Service; -import org.apache.tuscany.spi.component.ServiceBinding; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.model.BindingDefinition; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.ComponentType; -import org.apache.tuscany.spi.model.Implementation; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.model.ServiceDefinition; - -import org.apache.tuscany.core.binding.local.LocalBindingDefinition; -import org.apache.tuscany.core.implementation.composite.ReferenceImpl; -import org.apache.tuscany.core.implementation.composite.ServiceImpl; - -/** - * The default builder registry in the runtime - * - * @version $Rev$ $Date$ - */ -@EagerInit -public class BuilderRegistryImpl implements BuilderRegistry { - private ScopeRegistry scopeRegistry; - - private final Map>, ComponentBuilder>> componentBuilders = - new HashMap>, ComponentBuilder>>(); - private final Map, BindingBuilder> bindingBuilders = - new HashMap, BindingBuilder>(); - - public BuilderRegistryImpl(@org.osoa.sca.annotations.Reference ScopeRegistry scopeRegistry) { - this.scopeRegistry = scopeRegistry; - } - - public > void register(Class implClass, ComponentBuilder builder) { - componentBuilders.put(implClass, builder); - } - - public > void unregister(Class implClass) { - componentBuilders.remove(implClass); - } - - public void register(Class implClass, BindingBuilder builder) { - bindingBuilders.put(implClass, builder); - } - - @SuppressWarnings("unchecked") - public > Component build( - ComponentDefinition componentDefinition, - DeploymentContext context) throws BuilderException { - Class implClass = componentDefinition.getImplementation().getClass(); - // noinspection SuspiciousMethodCalls - ComponentBuilder componentBuilder = (ComponentBuilder) componentBuilders.get(implClass); - if (componentBuilder == null) { - String name = implClass.getName(); - throw new NoRegisteredBuilderException("No builder registered for implementation", name); - } - Component component = componentBuilder.build(componentDefinition, context); - assert component != null; - component.setDefaultPropertyValues(componentDefinition.getPropertyValues()); - Scope scope = componentDefinition.getImplementation().getComponentType().getImplementationScope(); - if (scope == Scope.SYSTEM || scope == Scope.COMPOSITE) { - component.setScopeContainer(context.getCompositeScope()); - } else { - // Check for conversational contract if conversational scope - if (scope == Scope.CONVERSATION) { - boolean hasConversationalContract = false; - ComponentType componentType = - componentDefinition.getImplementation().getComponentType(); - Map services = componentType.getServices(); - for (ServiceDefinition serviceDef : services.values()) { - ServiceContract contract = serviceDef.getServiceContract(); - if (contract.isConversational()) { - hasConversationalContract = true; - break; - } - } - if (!hasConversationalContract) { - String name = implClass.getName(); - throw new NoConversationalContractException( - "No conversational contract for conversational implementation", name); - } - } - // Now it's ok to set the scope container - ScopeContainer scopeContainer = scopeRegistry.getScopeContainer(scope); - if (scopeContainer == null) { - throw new ScopeNotFoundException(scope.toString()); - } - component.setScopeContainer(scopeContainer); - } - context.getComponents().put(component.getUri(), component); - ComponentType componentType = componentDefinition.getImplementation().getComponentType(); - assert componentType != null : "Component type must be set"; - return component; - } - - @SuppressWarnings({"unchecked"}) - public Service build(ServiceDefinition serviceDefinition, DeploymentContext context) throws BuilderException { - URI uri = serviceDefinition.getUri(); - ServiceContract serviceContract = serviceDefinition.getServiceContract(); - if (serviceDefinition.getBindings().isEmpty()) { - // if no bindings are configured, default to the local binding. - // this should be changed to allow runtime selection - if (serviceDefinition.getBindings().isEmpty()) { - // TODO JFM implement capability for the runtime to choose a binding - serviceDefinition.addBinding(new LocalBindingDefinition()); - } - } - URI targetUri = serviceDefinition.getTarget(); - Service service = new ServiceImpl(uri, serviceContract, targetUri); - for (BindingDefinition definition : serviceDefinition.getBindings()) { - Class bindingClass = definition.getClass(); - // noinspection SuspiciousMethodCalls - BindingBuilder bindingBuilder = bindingBuilders.get(bindingClass); - if (bindingBuilder == null) { - throw new NoRegisteredBuilderException("No builder registered for type", bindingClass.getName()); - } - ServiceBinding binding = bindingBuilder.build(serviceDefinition, definition, context); - service.addServiceBinding(binding); - } - return service; - } - - @SuppressWarnings("unchecked") - public Reference build(ReferenceDefinition referenceDefinition, DeploymentContext context) throws BuilderException { - URI uri = referenceDefinition.getUri(); - ServiceContract contract = referenceDefinition.getServiceContract(); - if (referenceDefinition.getBindings().isEmpty()) { - // if no bindings are configured, default to the local binding. - // this should be changed to allow runtime selection - if (referenceDefinition.getBindings().isEmpty()) { - // TODO JFM implement capability for the runtime to choose a binding - referenceDefinition.addBinding(new LocalBindingDefinition()); - } - } - - Reference reference = new ReferenceImpl(uri, contract); - for (BindingDefinition bindingDefinition : referenceDefinition.getBindings()) { - Class bindingClass = bindingDefinition.getClass(); - // noinspection SuspiciousMethodCalls - BindingBuilder bindingBuilder = bindingBuilders.get(bindingClass); - ReferenceBinding binding = bindingBuilder.build(referenceDefinition, bindingDefinition, context); - reference.addReferenceBinding(binding); - - } - return reference; - } - -} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ComponentNotFoundException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ComponentNotFoundException.java deleted file mode 100644 index a46e038cb9..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ComponentNotFoundException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.core.builder; - -import java.net.URI; - -import org.apache.tuscany.spi.builder.WiringException; - -/** - * Indicates a component was not found during wiring - * - * @version $Rev$ $Date$ - */ -public class ComponentNotFoundException extends WiringException { - - public ComponentNotFoundException(String message, URI name) { - super(message, name, name); - } - -} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java deleted file mode 100644 index 6923fb6837..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java +++ /dev/null @@ -1,385 +0,0 @@ -/* - * 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.core.builder; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import javax.xml.namespace.QName; - -import org.osoa.sca.annotations.Constructor; - -import org.apache.tuscany.spi.builder.BuilderException; -import org.apache.tuscany.spi.builder.Connector; -import org.apache.tuscany.spi.builder.WiringException; -import org.apache.tuscany.spi.builder.interceptor.InterceptorBuilderRegistry; -import org.apache.tuscany.spi.builder.physical.WireAttacherRegistry; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.ComponentManager; -import org.apache.tuscany.spi.component.Invocable; -import org.apache.tuscany.spi.component.Reference; -import org.apache.tuscany.spi.component.ReferenceBinding; -import org.apache.tuscany.spi.component.Service; -import org.apache.tuscany.spi.component.ServiceBinding; -import org.apache.tuscany.spi.component.TargetInvokerCreationException; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.ComponentType; -import org.apache.tuscany.spi.model.CompositeComponentType; -import org.apache.tuscany.spi.model.Implementation; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.model.ReferenceTarget; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.model.ServiceDefinition; -import org.apache.tuscany.spi.model.physical.PhysicalInterceptorDefinition; -import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition; -import org.apache.tuscany.spi.model.physical.PhysicalWireDefinition; -import org.apache.tuscany.spi.model.physical.PhysicalWireSourceDefinition; -import org.apache.tuscany.spi.model.physical.PhysicalWireTargetDefinition; -import org.apache.tuscany.spi.services.work.WorkScheduler; -import org.apache.tuscany.spi.util.UriHelper; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.InvocationChain; -import org.apache.tuscany.spi.wire.Wire; -import org.apache.tuscany.spi.wire.WirePostProcessorRegistry; - -import org.apache.tuscany.core.wire.InvocationChainImpl; -import org.apache.tuscany.core.wire.InvokerInterceptor; -import org.apache.tuscany.core.wire.NonBlockingInterceptor; -import org.apache.tuscany.core.wire.WireImpl; -import org.apache.tuscany.core.wire.WireUtils; - -/** - * The default connector implmentation - * - * @version $$Rev$$ $$Date$$ - */ -public class ConnectorImpl implements Connector { - private WirePostProcessorRegistry postProcessorRegistry; - private ComponentManager componentManager; - private WorkContext workContext; - private WorkScheduler scheduler; - private InterceptorBuilderRegistry interceptorBuilderRegistry; - private WireAttacherRegistry attacherRegistry; - - public ConnectorImpl(ComponentManager componentManager) { - this.componentManager = componentManager; - } - - @Constructor - public ConnectorImpl( - @org.osoa.sca.annotations.Reference InterceptorBuilderRegistry interceptorBuilderRegistry, - @org.osoa.sca.annotations.Reference WireAttacherRegistry attacherRegistry, - @org.osoa.sca.annotations.Reference WirePostProcessorRegistry processorRegistry, - @org.osoa.sca.annotations.Reference ComponentManager componentManager, - @org.osoa.sca.annotations.Reference WorkScheduler scheduler, - @org.osoa.sca.annotations.Reference WorkContext workContext) { - this.attacherRegistry = attacherRegistry; - this.interceptorBuilderRegistry = interceptorBuilderRegistry; - this.postProcessorRegistry = processorRegistry; - this.componentManager = componentManager; - this.scheduler = scheduler; - this.workContext = workContext; - } - - /** - * Note this method will not work yet - *

- * Wires a source and target component based on a wire defintion - * - * @param definition the wire definition - * @throws WiringException - */ - public void connect(PhysicalWireDefinition definition) throws BuilderException { - URI sourceUri = definition.getSourceUri(); - assert sourceUri != null; - URI targetUri = definition.getTargetUri(); - assert targetUri != null; - URI baseSourceUri = UriHelper.getDefragmentedName(sourceUri); - URI baseTargetUri = UriHelper.getDefragmentedName(targetUri); - Component source = componentManager.getComponent(baseSourceUri); - if (source == null) { - throw new ComponentNotFoundException("Wire source component not found", baseSourceUri); - } - Wire wire = createWire(definition); - - PhysicalWireSourceDefinition sourceDefinition = definition.getSource(); - PhysicalWireTargetDefinition targetDefinition = definition.getTarget(); - Component target; - if (baseTargetUri != null) { - target = componentManager.getComponent(baseTargetUri); - if (target == null) { - throw new ComponentNotFoundException("Wire target component not found", baseTargetUri); - } - } else { - target = null; - } - attacherRegistry.attachToSource(source, sourceDefinition, target, targetDefinition, wire); - attacherRegistry.attachToTarget(source, sourceDefinition, target, targetDefinition, wire); - } - - public void connect(ComponentDefinition> definition) throws WiringException { - URI sourceUri = definition.getUri(); - Component source = componentManager.getComponent(sourceUri); - if (source == null) { - throw new ComponentNotFoundException("Source not found", sourceUri); - } - ComponentType type = definition.getImplementation().getComponentType(); - if (type instanceof CompositeComponentType) { - CompositeComponentType compositeType = (CompositeComponentType) type; - for (ComponentDefinition> child : compositeType.getComponents().values()) { - connect(child); - } - for (ServiceDefinition child : compositeType.getServices().values()) { - connect(child); - } - for (ReferenceDefinition child : compositeType.getReferences().values()) { - connect(child); - } - } - Map targets = definition.getReferenceTargets(); - for (ReferenceTarget referenceTarget : targets.values()) { - List wires = new ArrayList(); - String refName = referenceTarget.getReferenceName().getFragment(); - ReferenceDefinition refDefinition = type.getReferences().get(refName); - assert refDefinition != null; - List uris = referenceTarget.getTargets(); - for (URI uri : uris) { - URI targetUri = UriHelper.getDefragmentedName(uri); - Component target = componentManager.getComponent(targetUri); - if (target == null && !refDefinition.isRequired()) { - // a non-required reference, just skip - continue; - } - if (target == null) { - throw new ComponentNotFoundException("Target not found", targetUri); - } - String fragment = uri.getFragment(); - URI sourceURI = refDefinition.getUri(); - Wire wire = createWire(sourceURI, uri, refDefinition.getServiceContract(), Wire.LOCAL_BINDING); - try { - attachInvokers(fragment, wire, source, target); - } catch (TargetInvokerCreationException e) { - throw new WireCreationException("Error creating invoker", sourceUri, targetUri, e); - } - if (postProcessorRegistry != null) { - postProcessorRegistry.process(wire); - } - optimize(source, target, wire); - wires.add(wire); - if (!wire.getCallbackInvocationChains().isEmpty()) { - target.attachCallbackWire(wire); - } - } - if (wires.size() > 1) { - // attach as a multiplicity - source.attachWires(wires); - } else if (wires.size() == 1) { - // attach as a single wire - Wire wire = wires.get(0); - source.attachWire(wire); - } - } - } - - /** - * @deprecated - */ - protected void connect(ServiceDefinition definition) throws WiringException { - URI uri = definition.getUri(); - URI sourceUri = UriHelper.getDefragmentedName(uri); - URI targetUri = definition.getTarget(); - URI baseTargetUri = UriHelper.getDefragmentedName(targetUri); - Component source = componentManager.getComponent(sourceUri); - if (source == null) { - throw new ComponentNotFoundException("Source not found", sourceUri); - } - Service service = source.getService(uri.getFragment()); - if (service == null) { - throw new SourceServiceNotFoundException("Service not found on composite", uri); - } - Component target = componentManager.getComponent(baseTargetUri); - if (target == null) { - throw new ComponentNotFoundException("Target not found", sourceUri); - } - ServiceContract contract = definition.getServiceContract(); - // TODO if no binding, do local - for (ServiceBinding binding : service.getServiceBindings()) { - Wire wire = createWire(uri, targetUri, contract, binding.getBindingType()); - binding.setWire(wire); - if (postProcessorRegistry != null) { - postProcessorRegistry.process(wire); - } - try { - attachInvokers(definition.getTarget().getFragment(), wire, binding, target); - } catch (TargetInvokerCreationException e) { - throw new WireCreationException("Error creating invoker", sourceUri, baseTargetUri, e); - } - } - } - - /** - * @deprecated - */ - protected void connect(ReferenceDefinition definition) throws WiringException { - URI uri = definition.getUri(); - URI sourceUri = UriHelper.getDefragmentedName(uri); - Component source = componentManager.getComponent(sourceUri); - if (source == null) { - throw new ComponentNotFoundException("Source not found", sourceUri); - } - Reference reference = source.getReference(uri.getFragment()); - if (reference == null) { - throw new SourceServiceNotFoundException("Reference not found on composite", uri); - } - - for (ReferenceBinding binding : reference.getReferenceBindings()) { - // create wire - if (Wire.LOCAL_BINDING.equals(binding.getBindingType())) { - URI targetUri = binding.getTargetUri(); - ServiceContract contract = binding.getBindingServiceContract(); - QName type = binding.getBindingType(); - Wire wire = createWire(sourceUri, targetUri, contract, type); - binding.setWire(wire); - // wire local bindings to their targets - Component target = componentManager.getComponent(UriHelper.getDefragmentedName(targetUri)); - if (target == null) { - throw new ComponentNotFoundException("Target not found", sourceUri); - } - try { - attachInvokers(targetUri.getFragment(), wire, binding, target); - } catch (TargetInvokerCreationException e) { - throw new WireCreationException("Error creating invoker", sourceUri, targetUri, e); - } - } else { - Wire wire = createWire(sourceUri, null, binding.getBindingServiceContract(), binding.getBindingType()); - if (postProcessorRegistry != null) { - postProcessorRegistry.process(wire); - } - binding.setWire(wire); - } - } - } - - protected Wire createWire(PhysicalWireDefinition definition) throws BuilderException { - URI sourceURI = definition.getSourceUri(); - URI targetUri = definition.getTargetUri(); - Wire wire = new WireImpl(); - wire.setSourceUri(sourceURI); - wire.setTargetUri(targetUri); - for (PhysicalOperationDefinition operation : definition.getOperations()) { - InvocationChain chain = new InvocationChainImpl(operation); - for (PhysicalInterceptorDefinition interceptorDefinition : operation.getInterceptors()) { - Interceptor interceptor = interceptorBuilderRegistry.build(interceptorDefinition); - chain.addInterceptor(interceptor); - } - wire.addInvocationChain(operation, chain); - } - return wire; - } - - protected Wire createWire(URI sourceURI, URI targetUri, ServiceContract contract, QName bindingType) { - Wire wire = new WireImpl(bindingType); - wire.setSourceContract(contract); - wire.setTargetContract(contract); - wire.setSourceUri(sourceURI); - wire.setTargetUri(targetUri); - for (Operation operation : contract.getOperations().values()) { - InvocationChain chain = new InvocationChainImpl(operation); - if (operation.isNonBlocking()) { - chain.addInterceptor(new NonBlockingInterceptor(scheduler, workContext)); - } - chain.addInterceptor(new InvokerInterceptor()); - wire.addInvocationChain(operation, chain); - - } - for (Operation operation : contract.getCallbackOperations().values()) { - InvocationChain chain = new InvocationChainImpl(operation); - if (operation.isNonBlocking()) { - chain.addInterceptor(new NonBlockingInterceptor(scheduler, workContext)); - } - chain.addInterceptor(new InvokerInterceptor()); - wire.addCallbackInvocationChain(operation, chain); - } - return wire; - } - - /** - * @Deprecated - */ - private void attachInvokers(String name, Wire wire, Invocable source, Invocable target) - throws TargetInvokerCreationException { - // TODO section will deleted be replaced when we cut-over to the physical marshallers - for (InvocationChain chain : wire.getInvocationChains().values()) { - chain.setTargetInvoker(target.createTargetInvoker(name, chain.getOperation())); - } - for (InvocationChain chain : wire.getCallbackInvocationChains().values()) { - chain.setTargetInvoker(source.createTargetInvoker(null, chain.getOperation())); - } - } - - /** - * @Deprecated - */ - protected void optimize(Component source, Component target, Wire wire) { - boolean optimizableScopes = isOptimizable(source.getScope(), target.getScope()); - if (optimizableScopes && target.isOptimizable() && WireUtils.isOptimizable(wire)) { - wire.setOptimizable(true); - wire.setTarget((AtomicComponent) target); - } else { - wire.setOptimizable(false); - } - } - - protected boolean isOptimizable(Scope pReferrer, Scope pReferee) { - if (pReferrer == Scope.UNDEFINED - || pReferee == Scope.UNDEFINED - || pReferrer == Scope.CONVERSATION - || pReferee == Scope.CONVERSATION) { - return false; - } - if (pReferee == pReferrer) { - return true; - } else if (pReferrer == Scope.STATELESS) { - return true; - } else if (pReferee == Scope.STATELESS) { - return false; - } else if (pReferrer == Scope.REQUEST && pReferee == Scope.SESSION) { - return true; - } else if (pReferrer == Scope.REQUEST && pReferee == Scope.COMPOSITE) { - return true; - } else if (pReferrer == Scope.REQUEST && pReferee == Scope.SYSTEM) { - return true; - } else if (pReferrer == Scope.SESSION && pReferee == Scope.COMPOSITE) { - return true; - } else if (pReferrer == Scope.SESSION && pReferee == Scope.SYSTEM) { - return true; - } else //noinspection SimplifiableIfStatement - if (pReferrer == Scope.SYSTEM && pReferee == Scope.COMPOSITE) { - // case where a service context points to a composite scoped component - return true; - } else { - return pReferrer == Scope.COMPOSITE && pReferee == Scope.SYSTEM; - } - } -} \ No newline at end of file diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java deleted file mode 100644 index 183ccea1b8..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.core.builder; - -import java.net.URI; - -import org.apache.tuscany.spi.builder.WiringException; - -/** - * Denotes an illegal callback - * - * @version $Rev$ $Date$ - */ -public class IllegalCallbackException extends WiringException { - - public IllegalCallbackException(String message, String identifier, URI sourceUri, URI targetUri) { - super(message, identifier, sourceUri, targetUri); - } - -} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java deleted file mode 100644 index 1a9c74aa3b..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.core.builder; - -import java.net.URI; - -import org.apache.tuscany.spi.builder.WiringException; - -/** - * Denotes an attempt to wire incompatible interfaces - * - * @version $Rev$ $Date$ - */ -public class IncompatibleInterfacesException extends WiringException { - - public IncompatibleInterfacesException(URI source, URI target) { - super("Incompatible source and target interfaces", source, target); - } - - public IncompatibleInterfacesException(URI source, URI target, Throwable throwable) { - super("Incompatible source and target interfaces", source, target, throwable); - } - -} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidSourceTypeException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidSourceTypeException.java deleted file mode 100644 index d9df445530..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidSourceTypeException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.core.builder; - -import java.net.URI; - -import org.apache.tuscany.spi.builder.WiringException; - -/** - * Denotes an invalid source type for a wire - * - * @version $Rev$ $Date$ - */ -public class InvalidSourceTypeException extends WiringException { - - public InvalidSourceTypeException(String message, URI sourceUri, URI targetUri) { - super(message, sourceUri, targetUri); - } -} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidTargetTypeException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidTargetTypeException.java deleted file mode 100644 index e3c26c75d2..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidTargetTypeException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.core.builder; - -import java.net.URI; - -import org.apache.tuscany.spi.builder.WiringException; - -/** - * Denotes an invalid target service for a wire - * - * @version $Rev$ $Date$ - */ -public class InvalidTargetTypeException extends WiringException { - - public InvalidTargetTypeException(String message, URI sourceUri, URI targetUri) { - super(message, sourceUri, targetUri); - } -} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoBindingException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoBindingException.java deleted file mode 100644 index c351013297..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoBindingException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.core.builder; - -import java.net.URI; - -import org.apache.tuscany.spi.builder.WiringException; - -/** - * Denotes no binding was specified for a wire - * - * @version $Rev$ $Date$ - */ -public class NoBindingException extends WiringException { - - public NoBindingException(String message, URI sourceUri, URI targetUri) { - super(message, sourceUri, targetUri); - } -} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoCompatibleBindingsException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoCompatibleBindingsException.java deleted file mode 100644 index 3c49767333..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoCompatibleBindingsException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.core.builder; - -import java.net.URI; - -import org.apache.tuscany.spi.builder.WiringException; - -/** - * @version $Rev$ $Date$ - */ -public class NoCompatibleBindingsException extends WiringException { - - public NoCompatibleBindingsException(URI sourceName, URI targetName) { - super("No compatible bindings for source and target", sourceName, targetName); - } - -} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoConversationalContractException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoConversationalContractException.java deleted file mode 100644 index 71eb9ebd26..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoConversationalContractException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.core.builder; - -import org.apache.tuscany.spi.builder.BuilderException; - -/** - * Raised when a component has conversational scope but no conversational contract - * - * @version $Rev: 487877 $ $Date: 2006-12-16 15:32:16 -0500 (Sat, 16 Dec 2006) $ - */ -public class NoConversationalContractException extends BuilderException { - - public NoConversationalContractException(String message, String identifier) { - super(message, identifier); - } - - public NoConversationalContractException(String message) { - super(message); - } -} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoRegisteredBuilderException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoRegisteredBuilderException.java deleted file mode 100644 index 340a20f239..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoRegisteredBuilderException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.core.builder; - -import org.apache.tuscany.spi.builder.BuilderException; - -/** - * Raised when a builder cannot be found for a SCDL entry type - * - * @version $Rev$ $Date$ - */ -public class NoRegisteredBuilderException extends BuilderException { - - public NoRegisteredBuilderException(String message, String identifier) { - super(message, identifier); - } - - public NoRegisteredBuilderException(String message) { - super(message); - } - -} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/SourceServiceNotFoundException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/SourceServiceNotFoundException.java deleted file mode 100644 index 7d3d49b937..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/SourceServiceNotFoundException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.core.builder; - -import java.net.URI; - -import org.apache.tuscany.spi.builder.WiringException; - -/** - * Indicates the source service of a wire was not found - * - * @version $Rev$ $Date$ - */ -public class SourceServiceNotFoundException extends WiringException { - - public SourceServiceNotFoundException(String message, URI sourceName) { - super(message, sourceName, null); - } - -} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/TargetServiceNotFoundException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/TargetServiceNotFoundException.java deleted file mode 100644 index f22b421aa7..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/TargetServiceNotFoundException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.core.builder; - -import java.net.URI; - -import org.apache.tuscany.spi.builder.WiringException; - -/** - * Indicates the target service of a reference was not found - * - * @version $Rev$ $Date$ - */ -public class TargetServiceNotFoundException extends WiringException { - - public TargetServiceNotFoundException(String message, URI sourceName, URI targetName) { - super(message, sourceName, targetName); - } - -} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WireCreationException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WireCreationException.java deleted file mode 100644 index 117bb23180..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WireCreationException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.core.builder; - -import java.net.URI; - -import org.apache.tuscany.spi.builder.WiringException; - -/** - * Denotes an error creating a wire - * - * @version $Rev$ $Date$ - */ -public class WireCreationException extends WiringException { - - public WireCreationException(String message, URI sourceUri, Throwable e) { - super(message, sourceUri, null, e); - } - - public WireCreationException(String message, URI sourceUri, URI targetUri, Throwable e) { - super(message, sourceUri, targetUri, e); - } -} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java deleted file mode 100644 index 6f611956be..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.core.builder; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.spi.wire.Wire; -import org.apache.tuscany.spi.wire.WirePostProcessor; -import org.apache.tuscany.spi.wire.WirePostProcessorRegistry; - -/** - * The default implementation of a WirePostProcessor - * - * @version $Rev$ $Date$ - */ -public class WirePostProcessorRegistryImpl implements WirePostProcessorRegistry { - - private final List processors = new ArrayList(); - - public void process(Wire wire) { - for (WirePostProcessor processor : processors) { - processor.process(wire); - } - } - - public void register(WirePostProcessor processor) { - processors.add(processor); - } - - public void unregister(WirePostProcessor processor) { - processors.remove(processor); - } -} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WiringExceptionFormatter.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WiringExceptionFormatter.java deleted file mode 100644 index 661dc8bfea..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WiringExceptionFormatter.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.core.builder; - -import java.io.PrintWriter; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.EagerInit; -import org.osoa.sca.annotations.Reference; - -import org.apache.tuscany.spi.builder.WiringException; - -import org.apache.tuscany.host.monitor.ExceptionFormatter; -import org.apache.tuscany.host.monitor.FormatterRegistry; - -/** - * Formats {@link WiringException}s - * - * @version $Rev$ $Date$ - */ -@EagerInit -public class WiringExceptionFormatter implements ExceptionFormatter { - private FormatterRegistry factory; - - public WiringExceptionFormatter(@Reference FormatterRegistry factory) { - this.factory = factory; - factory.register(this); - } - - public boolean canFormat(Class type) { - return WiringException.class.isAssignableFrom(type); - } - - @Destroy - public void destroy() { - factory.unregister(this); - } - - public PrintWriter write(PrintWriter writer, Throwable exception) { - assert exception instanceof WiringException; - WiringException e = (WiringException) exception; - e.appendBaseMessage(writer); - if (e.getSourceUri() != null) { - writer.write("\nSource : " + e.getSourceUri()); - } - if (e.getTargetUri() != null) { - writer.write("\nTarget : " + e.getTargetUri()); - } - return writer; - } -} -- cgit v1.2.3