Package org.apache.tuscany.model.assembly

Examples of org.apache.tuscany.model.assembly.Service


    public static ExternalService createAutowirableExternalService(String name, Class type) {
        ExternalService es = systemFactory.createExternalService();
        es.setName(name);
        JavaServiceContract inter = systemFactory.createJavaServiceContract();
        inter.setInterface(type);
        Service service = systemFactory.createService();
        service.setServiceContract(inter);
        ConfiguredService cService = systemFactory.createConfiguredService();
        cService.setPort(service);
        cService.initialize(assemblyContext);
        es.setConfiguredService(cService);
        es.getBindings().add(systemFactory.createSystemBinding());
View Full Code Here


    public <T> Component createSystemComponent(String name, Class<T> service, Class<? extends T> impl, Scope scope) {
        JavaServiceContract jsc = createJavaServiceContract();
        jsc.setInterface(service);
        jsc.setScope(scope);
        Service s = createService();
        s.setServiceContract(jsc);

        ComponentType componentType = createComponentType();
        componentType.getServices().add(s);

        SystemImplementation sysImpl = createSystemImplementation();
View Full Code Here

        Callback callback = serviceClass.getAnnotation(Callback.class);
        if (callback != null && !Void.class.equals(callback.value())) {
            javaInterface.setCallbackInterface(callback.value());
        }
        String name = JavaIntrospectionHelper.getBaseName(serviceClass);
        Service service = factory.createService();
        service.setName(name);
        service.setServiceContract(javaInterface);
        services.add(service);
    }
View Full Code Here

                    public void setName(String name) {

                    }

                    public Service getPort() {
                        return new Service() {

                            public ServiceContract getServiceContract() {
                                return new ServiceContract() {

                                    public Class getInterface() {
View Full Code Here

    public static ModuleComponent createSystemCompositeComponent(String name) {
        ModuleComponent sc = systemFactory.createModuleComponent();
        SystemModule impl = systemFactory.createSystemModule();
        impl.setImplementationClass(SystemCompositeContextImpl.class);
        sc.setImplementation(impl);
        Service s = systemFactory.createService();
        JavaServiceContract ji = systemFactory.createJavaServiceContract();
        s.setServiceContract(ji);
        ji.setScope(Scope.AGGREGATE);
        impl.setComponentType(systemFactory.createComponentType());
        impl.getComponentType().getServices().add(s);
        sc.setName(name);
        sc.setImplementation(impl);
View Full Code Here

        systemChild.registerModelObject(MockFactory.createSystemChildModule());

        // register a top-level system entry point that exposes the child entry point
        EntryPoint ep = MockFactory.createEPSystemBinding("TestService2EP", ModuleScopeSystemComponent.class, "ref");
        ep.getBindings().add(systemFactory.createSystemBinding());
        Service service = systemFactory.createService();
        service.setName("system.child/TestService2EP");
        ep.getConfiguredReference().getTargetConfiguredServices().get(0).setPort(service);
        JavaServiceContract inter = systemFactory.createJavaServiceContract();
        inter.setInterface(ModuleScopeSystemComponentImpl.class);
        service.setServiceContract(inter);
        system.registerModelObject(ep);
        system.publish(new ModuleStart(this));
        Assert.assertNotNull(system.getContext("TestService1").getInstance(null));
        Assert.assertNotNull(system.getContext("TestService2EP").getInstance(null));
View Full Code Here

        CompositeContext systemModule2 = (CompositeContext) system.getContext("module2");
        systemModule2.registerModelObject(MockFactory.createSystemChildModule());

        EntryPoint ep = MockFactory.createEPSystemBinding("TestService2EP", ModuleScopeSystemComponent.class, "ref");
        ep.getBindings().add(factory.createSystemBinding());
        Service service = factory.createService();
        service.setName("module2/TestService2EP");
        JavaServiceContract inter = factory.createJavaServiceContract();
        inter.setInterface(ModuleScopeSystemComponentImpl.class);
        service.setServiceContract(inter);
        ep.getConfiguredReference().getTargetConfiguredServices().get(0).setPort(service);
        system.registerModelObject(ep);
        system.publish(new ModuleStart(this));
        Assert.assertNotNull(system.getContext("TestService1").getInstance(null));
        Assert.assertNotNull(system.getContext("TestService2EP").getInstance(null));
View Full Code Here

        assert ENTRY_POINT.equals(reader.getName());
        EntryPoint entryPoint = factory.createEntryPoint();
        String name = reader.getAttributeValue(null, "name");
        entryPoint.setName(name);

        Service service = factory.createService();
        service.setName(name);
        ConfiguredService configuredService = factory.createConfiguredService();
        configuredService.setPort(service);
        entryPoint.setConfiguredService(configuredService);

        Reference reference = factory.createReference();
        reference.setMultiplicity(StAXUtil.multiplicity(reader.getAttributeValue(null, "multiplicity"), Multiplicity.ONE_ONE));
        ConfiguredReference configuredReference = factory.createConfiguredReference();
        configuredReference.setPort(reference);
        entryPoint.setConfiguredReference(configuredReference);

        while (true) {
            switch (reader.next()) {
            case START_ELEMENT:
                QName qname = reader.getName();
                if (AssemblyConstants.REFERENCE.equals(qname)) {
                    String uri = reader.getElementText();
                    configuredReference.getTargets().add(uri);
                } else {
                    AssemblyObject o = registry.load(reader, loaderContext);
                    if (o instanceof Binding) {
                        entryPoint.getBindings().add((Binding) o);
                    } else if (o instanceof ServiceContract) {
                        service.setServiceContract((ServiceContract) o);
                        reference.setServiceContract((ServiceContract) o);
                    }
                }
                reader.next();
                break;
View Full Code Here

        return SERVICE;
    }

    public Service load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException {
        assert SERVICE.equals(reader.getName());
        Service service = factory.createService();
        service.setName(reader.getAttributeValue(null, "name"));

        while (true) {
            switch (reader.next()) {
            case START_ELEMENT:
                AssemblyObject o = registry.load(reader, loaderContext);
                if (o instanceof ServiceContract) {
                    service.setServiceContract((ServiceContract) o);
                }
                reader.next();
                break;
            case END_ELEMENT:
                return service;
View Full Code Here

        ExternalJbiServiceClient externalJbiServiceClient = new ExternalJbiServiceClient(externalService);
        ExternalJbiServiceContextFactory config = new ExternalJbiServiceContextFactory(externalService.getName(), new SingletonObjectFactory<ExternalJbiServiceClient>(externalJbiServiceClient));

        ConfiguredService configuredService = externalService.getConfiguredService();
        Service service = configuredService.getService();
        ServiceContract serviceContract = service.getServiceContract();
        Map<Method, InvocationConfiguration> iConfigMap = new MethodHashMap();
        ProxyFactory proxyFactory = proxyFactoryFactory.createProxyFactory();
        Set<Method> javaMethods = JavaIntrospectionHelper.getAllUniqueMethods(serviceContract.getInterface());
        for (Method method : javaMethods) {
            InvocationConfiguration iConfig = new InvocationConfiguration(method);
            iConfigMap.put(method, iConfig);
        }
        QualifiedName qName = new QualifiedName(externalService.getName() + "/" + service.getName());
        ProxyConfiguration pConfiguration = new ProxyConfiguration(qName, iConfigMap, serviceContract.getInterface().getClassLoader(), messageFactory);
        proxyFactory.setBusinessInterface(serviceContract.getInterface());
        proxyFactory.setProxyConfiguration(pConfiguration);
        config.addTargetProxyFactory(service.getName(), proxyFactory);
        configuredService.setProxyFactory(proxyFactory);
        if (policyBuilder != null) {
            // invoke the reference builder to handle additional policy metadata
            policyBuilder.build(configuredService);
        }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.model.assembly.Service

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.