Package org.apache.tuscany.sca.node.impl

Examples of org.apache.tuscany.sca.node.impl.NodeFactoryImpl


        this.serviceName = serviceName;
        this.serviceInterface = serviceInterface;
    }

    public void checkDomain() throws NoSuchDomainException {
        NodeFactoryImpl nodeFactory = (NodeFactoryImpl)NodeFactory.newInstance(domainURI);
        try {
            nodeFactory.init();
           
            ExtensionPointRegistry extensionsRegistry = nodeFactory.getExtensionPointRegistry();
            Properties props = extensionsRegistry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
            props.setProperty("client", "true");
            DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
           
            String registryURI = domainURI;

            // TODO: theres better ways to do this but this gets things working for now
            if (registryURI.indexOf(":") == -1) {
                registryURI = "tuscanyclient:" + registryURI;
            }
            if (registryURI.startsWith("uri:")) {
                registryURI = "tuscanyclient:" + registryURI.substring(4);
            }
            if (registryURI.startsWith("tuscany:")) {
                registryURI = "tuscanyclient:" + registryURI.substring(8);
            }
           
         
            try {
                domainRegistryFactory.getEndpointRegistry(registryURI, domainURI);
            } catch (Exception e) {
                throw new NoSuchDomainException(domainURI, e);
            }
        } finally {
            nodeFactory.destroy();
        }
    }
View Full Code Here


    }
   
  
         
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        NodeFactoryImpl nodeFactory = (NodeFactoryImpl)NodeFactory.newInstance(domainURI);
        try {
            nodeFactory.init();
           
            ExtensionPointRegistry extensionsRegistry = nodeFactory.getExtensionPointRegistry();
            Properties props = extensionsRegistry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
            props.setProperty("client", "true");
            DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
           
            String registryURI = domainURI;

            // TODO: theres better ways to do this but this gets things working for now
            if (registryURI.indexOf(":") == -1) {
                registryURI = "tuscanyclient:" + registryURI;
            }
            if (registryURI.startsWith("uri:")) {
                registryURI = "tuscanyclient:" + registryURI.substring(4);
            }
            if (registryURI.startsWith("tuscany:")) {
                registryURI = "tuscanyclient:" + registryURI.substring(8);
            }
           
            EndpointRegistry endpointRegistry;
            try {
                endpointRegistry = domainRegistryFactory.getEndpointRegistry(registryURI, domainURI);
            } catch (Exception e) {
                throw new NoSuchDomainException(domainURI, e);
            }
           
            FactoryExtensionPoint factories = extensionsRegistry.getExtensionPoint(FactoryExtensionPoint.class);
            AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
            JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
            ProxyFactory proxyFactory = new ExtensibleProxyFactory(extensionsRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class));

            String client = "sca.client." + UUID.randomUUID();
            CompositeContext compositeContext =
                new CompositeContext(extensionsRegistry, endpointRegistry, null, domainURI.toString(), client, nodeFactory.getDeployer().getSystemDefinitions());

            List<Endpoint> eps = endpointRegistry.findEndpoint(serviceName);
            if (eps == null || eps.size() < 1) {
                throw new NoSuchServiceException(serviceName);
            }
            Endpoint endpoint = eps.get(0); // TODO: what should be done with multiple endpoints?
          
            RuntimeEndpointReference epr;
            try {
                epr = createEndpointReference(javaInterfaceFactory, compositeContext, assemblyFactory, endpoint, serviceInterface);
            } catch (Exception e) {
                throw new ServiceRuntimeException(e);
            }

            InvocationHandler handler = Proxy.getInvocationHandler(proxyFactory.createProxy(serviceInterface, epr));
            return handler.invoke(proxy, method, args);
           
        } finally {
            nodeFactory.destroy();
        }
    }
View Full Code Here

    public void stop() {
        trackerTracker.close();
    }

    protected ExtensionPointRegistry getExtensionPointRegistry() {
        NodeFactoryImpl factory = (NodeFactoryImpl)NodeFactory.getInstance();
        factory.init();
        ServiceTracker tracker = new ServiceTracker(context, ExtensionPointRegistry.class.getName(), null);
        tracker.open();
        // tracker.waitForService(1000);
        registry = (ExtensionPointRegistry)tracker.getService();
        tracker.close();
View Full Code Here

        this.serviceName = serviceName;
        this.serviceInterface = serviceInterface;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        NodeFactoryImpl nodeFactory = (NodeFactoryImpl)NodeFactory.newInstance(domainURI);
        try {
            nodeFactory.init();
           
            ExtensionPointRegistry extensionsRegistry = nodeFactory.getExtensionPointRegistry();
            Properties props = extensionsRegistry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
            props.setProperty("client", "true");
            DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
           
            String registryURI = domainURI;

            // TODO: theres better ways to do this but this gets things working for now
            if (registryURI.indexOf(":") == -1) {
                registryURI = "tuscanyclient:" + registryURI;
            }
            if (registryURI.startsWith("uri:")) {
                registryURI = "tuscanyclient:" + registryURI.substring(4);
            }
            if (registryURI.startsWith("tuscany:")) {
                registryURI = "tuscanyclient:" + registryURI.substring(8);
            }
           
            EndpointRegistry endpointRegistry;
            try {
                endpointRegistry = domainRegistryFactory.getEndpointRegistry(registryURI, domainURI);
            } catch (Exception e) {
                throw new NoSuchDomainException(domainURI, e);
            }
           
            FactoryExtensionPoint factories = extensionsRegistry.getExtensionPoint(FactoryExtensionPoint.class);
            AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
            JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
            ProxyFactory proxyFactory = new ExtensibleProxyFactory(extensionsRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class));

            String client = "sca.client." + UUID.randomUUID();
            CompositeContext compositeContext =
                new CompositeContext(extensionsRegistry, endpointRegistry, null, domainURI.toString(), client, nodeFactory.getDeployer().getSystemDefinitions());

            List<Endpoint> eps = endpointRegistry.findEndpoint(serviceName);
            if (eps == null || eps.size() < 1) {
                throw new NoSuchServiceException(serviceName);
            }
            Endpoint endpoint = eps.get(0); // TODO: what should be done with multiple endpoints?
          
            RuntimeEndpointReference epr;
            try {
                epr = createEndpointReference(javaInterfaceFactory, compositeContext, assemblyFactory, endpoint, serviceInterface);
            } catch (Exception e) {
                throw new ServiceRuntimeException(e);
            }

            InvocationHandler handler = Proxy.getInvocationHandler(proxyFactory.createProxy(serviceInterface, epr));
            return handler.invoke(proxy, method, args);
           
        } finally {
            nodeFactory.destroy();
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.node.impl.NodeFactoryImpl

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.