Package org.apache.tuscany.spi.wire

Examples of org.apache.tuscany.spi.wire.InboundWire


    }

    public Object createProxy(RuntimeWire wire) throws ProxyCreationException {
        assert wire != null : "Wire was null";
        if (wire instanceof InboundWire) {
            InboundWire inbound = (InboundWire) wire;
            Class<?> interfaze = wire.getServiceContract().getInterfaceClass();
            Method[] methods = interfaze.getMethods();
            Map<Method, InboundInvocationChain> chains = createInboundMapping(inbound, methods);
            JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(chains, context);
            ClassLoader cl = interfaze.getClassLoader();
View Full Code Here


    }

    public WireInvocationHandler createHandler(RuntimeWire wire) {
        assert wire != null : "Wire was null";
        if (wire instanceof InboundWire) {
            InboundWire inbound = (InboundWire) wire;
            Method[] methods = inbound.getServiceContract().getInterfaceClass().getMethods();
            Map<Method, InboundInvocationChain> chains = createInboundMapping(inbound, methods);
            return new JDKInboundInvocationHandler(chains, context);
        } else if (wire instanceof OutboundWire) {
            OutboundWire outbound = (OutboundWire) wire;
            return new JDKOutboundInvocationHandler(outbound, context);
View Full Code Here

    public void createWires(Component component, ComponentDefinition<?> definition) {
        Implementation<?> implementation = definition.getImplementation();
        ComponentType<?, ?, ?> componentType = implementation.getComponentType();
        for (ServiceDefinition service : componentType.getServices().values()) {
            InboundWire inboundWire = createWire(service);
            inboundWire.setContainer(component);
            if (componentType instanceof CompositeComponentType<?, ?, ?>) {
                // If this is the case, then it means that component has already been returned
                // by CompositeBuilder and thus its children, in particular composite services,
                // have been registered
                CompositeComponent compositeComponent = (CompositeComponent) component;
                Service serviceChild = (Service) compositeComponent.getChild(service.getName());
                assert serviceChild != null;
                if (serviceChild instanceof CompositeService) {
                    serviceChild.setInboundWire(inboundWire);
                    // Notice that now the more immediate container of the wire is the composite service
                    inboundWire.setContainer(serviceChild);
                }
            }
            component.addInboundWire(inboundWire);
        }
View Full Code Here

            }
        }
    }

    public void createWires(Reference reference, ServiceContract<?> contract) {
        InboundWire inboundWire = new InboundWireImpl();
        inboundWire.setServiceContract(contract);
        inboundWire.setContainer(reference);
        for (Operation<?> operation : contract.getOperations().values()) {
            InboundInvocationChain chain = createInboundChain(operation);
            inboundWire.addInvocationChain(operation, chain);
        }
        OutboundWire outboundWire = new OutboundWireImpl();

        // [rfeng] Check if the Reference has the binding contract
        ServiceContract<?> bindingContract = reference.getBindingServiceContract();
View Full Code Here

        }
        return wire;
    }

    public InboundWire createWire(ServiceDefinition service) {
        InboundWire wire = new InboundWireImpl();
        ServiceContract<?> contract = service.getServiceContract();
        wire.setServiceContract(contract);
        wire.setServiceName(service.getName());
        for (Operation<?> operation : contract.getOperations().values()) {
            InboundInvocationChain chain = createInboundChain(operation);
            // TODO handle policy
            //TODO statement below could be cleaner
            chain.addInterceptor(new InvokerInterceptor());
            wire.addInvocationChain(operation, chain);
        }
        if (contract.getCallbackName() != null) {
            wire.setCallbackReferenceName(service.getCallbackReferenceName());
        }
        return wire;
    }
View Full Code Here

        }
        return wire;
    }

    public void createWires(Service service, String targetName, ServiceContract<?> contract) {
        InboundWire inboundWire = new InboundWireImpl();

        // [rfeng] Check if the Reference has the binding contract
        ServiceContract<?> bindingContract = service.getBindingServiceContract();
        if (bindingContract == null) {
            bindingContract = contract;
        }
        inboundWire.setServiceContract(bindingContract);
        inboundWire.setContainer(service);
        for (Operation<?> operation : bindingContract.getOperations().values()) {
            InboundInvocationChain inboundChain = createInboundChain(operation);
            inboundWire.addInvocationChain(operation, inboundChain);
        }

        OutboundWire outboundWire = new OutboundWireImpl();
        outboundWire.setServiceContract(contract);
        outboundWire.setTargetName(new QualifiedName(targetName));
View Full Code Here

                                                                      scope,
                                                                      ArtifactFactory.createWireService(),
                                                                      null);
        scope.register(context);

        InboundWire wire = ArtifactFactory.createInboundWire("Greeting",
                                                                Greeting.class);
        ArtifactFactory.terminateWire(wire);
        for (InboundInvocationChain chain : wire.getInvocationChains().values()) {
            chain.setTargetInvoker(context.createTargetInvoker(null,
                                                               chain.getOperation()));
        }
        context.addInboundWire(wire);
        Greeting greeting = (Greeting) context.getServiceInstance("Greeting");
View Full Code Here

        this.scope = configuration.getScopeContainer().getScope();
        this.monitor = monitor;
    }

    public Object getServiceInstance(String name) throws TargetException {
        InboundWire wire = serviceWires.get(name);
        if (wire == null) {
            TargetNotFoundException e = new TargetNotFoundException(name);
            e.addContextName(getName());
            throw e;
        }
View Full Code Here

        wireService.createProxy(EasyMock.isA(InboundWire.class));
        EasyMock.expectLastCall().andReturn(null);
        EasyMock.replay(wireService);

        //Create a mocked InboundWire, make the call of ServiceExtension.getInterface() returns a Class
        InboundWire inboundWire = EasyMock.createNiceMock(InboundWire.class);
        JavaServiceContract contract = new JavaServiceContract(Greeter.class);
        Map<String, Operation<Type>> opMap = new HashMap<String, Operation<Type>>();
        for(Method m: Greeter.class.getMethods()) {
            opMap.put(m.getName(), new Operation<Type>(m.getName(), null, null, null));
        }
        contract.setOperations(opMap);
        EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
        if (callback) {
            contract.setCallbackName("");
        }
        EasyMock.replay(inboundWire);
View Full Code Here

    }

    public void testAsyncTargetInvoker() throws Exception {
        Axis2Reference axis2Reference = createAxis2Reference("testWebAppName", "testServiceName");
        //Create a mocked InboundWire, make the call of ServiceExtension.getInterface() returns a Class
        InboundWire inboundWire = EasyMock.createNiceMock(InboundWire.class);
        JavaServiceContract contract = new JavaServiceContract(Greeter.class);
        contract.setCallbackClass(GreetingCallback.class);
        Operation<Type> callbackOp = new Operation<Type>("sayHiCallback", null, null, null, true, null);
        HashMap<String,Operation<Type>> callbackOps = new HashMap<String,Operation<Type>>();
        callbackOps.put("sayHiCallback", callbackOp);
        contract.setCallbackOperations(callbackOps);
        EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
        EasyMock.replay(inboundWire);

        axis2Reference.setInboundWire(inboundWire);
        Operation operation = new Operation<Type>("sayHi", null, null, null, true, null);
        TargetInvoker asyncTargetInvoker = axis2Reference.createAsyncTargetInvoker(null, operation);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.spi.wire.InboundWire

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.