Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
SCA4J Copyright (c) 2009 - 2099 Service Symphony Ltd Licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. A copy of the license is included in this distrubtion or you may obtain a copy at http://www.opensource.org/licenses/apache2.0.php 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. This project contains code licensed from the Apache Software Foundation under the Apache License, Version 2.0 and original code from project contributors. Original Codehaus Header Copyright (c) 2007 - 2008 fabric3 project contributors Licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. A copy of the license is included in this distrubtion or you may obtain a copy at http://www.opensource.org/licenses/apache2.0.php 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. This project contains code licensed from the Apache Software Foundation under the Apache License, Version 2.0 and original code from project contributors. Original Apache Header Copyright (c) 2005 - 2006 The Apache Software Foundation Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF. This product includes software developed by The Apache Software Foundation (http://www.apache.org/).
 
 package org.sca4j.groovy.runtime;
 
 import java.net.URI;
 import java.util.List;
 import java.util.Map;
 
 
The component builder for Java implementation types. Responsible for creating the Component runtime artifact from a physical component definition

Version:
$Rev: 5244 $ $Date: 2008-08-20 22:21:13 +0100 (Wed, 20 Aug 2008) $
 
     private final ComponentManager manager;
 
     public GroovyTargetWireAttacher(@Reference ComponentManager manager) {
         this. = manager;
     }
 
     public void attachToTarget(PhysicalWireSourceDefinition sourceDefinition,
                                GroovyWireTargetDefinition targetDefinition,
                                Wire wirethrows WireAttachException {
         URI targetName = UriHelper.getDefragmentedName(targetDefinition.getUri());
         Component component = .getComponent(targetName);
         assert component instanceof GroovyComponent;
         GroovyComponent<?> target = (GroovyComponentcomponent;
 
         ScopeContainer<?> scopeContainer = target.getScopeContainer();
        Class<?> implementationClass = target.getImplementationClass();
        ClassLoader loader = implementationClass.getClassLoader();
        // attach the invoker interceptor to forward invocation chains
        for (Map.Entry<PhysicalOperationDefinitionInvocationChainentry : wire.getInvocationChains().entrySet()) {
            PhysicalOperationDefinition operation = entry.getKey();
            InvocationChain chain = entry.getValue();
            List<Stringparams = operation.getParameters();
            Class<?>[] paramTypes = new Class<?>[params.size()];
            assert loader != null;
            for (int i = 0; i < params.size(); i++) {
                String param = params.get(i);
                try {
                    paramTypes[i] = loader.loadClass(param);
                } catch (ClassNotFoundException e) {
                    URI sourceUri = sourceDefinition.getUri();
                    URI targetUri = targetDefinition.getUri();
                    throw new WireAttachException("Implementation class not found"sourceUritargetUrie);
                }
            }
            Method method;
            try {
                method = implementationClass.getMethod(operation.getName(), paramTypes);
            } catch (NoSuchMethodException e) {
                URI sourceUri = sourceDefinition.getUri();
                URI targetUri = targetDefinition.getUri();
                throw new WireAttachException("No matching method found"sourceUritargetUrie);
            }
            boolean endsConversation = operation.isEndsConversation();
            boolean callback = targetDefinition.isCallback();
            if (callback) {
                // callbacks do not expire the client (i.e. the callback target); they expire the forward implementation instance
                endsConversation = false;
            }
            InvokerInterceptor<?, ?> interceptor = createInterceptor(methodcallbackendsConversationtargetscopeContainer);
            chain.addInterceptor(interceptor);
        }
        // TODO handle callbacks
    }
    <T, CONTEXT> InvokerInterceptor<T, CONTEXT> createInterceptor(Method method,
                                                                  boolean callback,
                                                                  boolean endsConvesation,
                                                                  AtomicComponent<T> component,
                                                                  ScopeContainer<CONTEXT> scopeContainer) {
        return new InvokerInterceptor<T, CONTEXT>(methodcallbackendsConvesationcomponentscopeContainer);
    }
        URI targetId = UriHelper.getDefragmentedName(target.getUri());
        PojoComponent<?> targetComponent = (PojoComponent<?>) .getComponent(targetId);
        return targetComponent.createObjectFactory();
    }
New to GrepCode? Check out our FAQ X