Package org.apache.tuscany.sca.extensibility

Examples of org.apache.tuscany.sca.extensibility.ServiceDeclaration


    private synchronized void loadHosts() {
        if (loaded) {
            return;
        }
        try {
            ServiceDeclaration sd = registry.getServiceDiscovery().getServiceDeclaration(CorbaHost.class);
            CorbaHost host = ServiceHelper.newInstance(registry, sd);
            ServiceHelper.start(host);
            corbaHosts.add(host);
        } catch (Throwable e) {
            throw new ServiceRuntimeException(e);
View Full Code Here


        Assert.assertEquals(0, descriptors.size());
    }

    @Test
    public void testDiscoveryFirst() throws IOException {
        ServiceDeclaration descriptor = discoverer.getFirstServiceDeclaration("test.TestService");
        Assert.assertNotNull(descriptor);
        descriptor = discoverer.getFirstServiceDeclaration("notthere");
        Assert.assertNull(descriptor);
    }
View Full Code Here

       
        Class<?>[] classes = modelType.getInterfaces();
        for (Class<?> c : classes) {
            Class<? extends ModelResolver> resolver = resolvers.get(c);
            if (resolver == null) {
                ServiceDeclaration resolverClass = loadedResolvers.get(c.getName());
                if (resolverClass != null) {
                    try {
                        return (Class<? extends ModelResolver>)resolverClass.loadClass();
                    } catch (ClassNotFoundException e) {
                        throw new IllegalArgumentException(e);
                    }
                }
            } else {
                return resolver;
            }
        }

        Class<? extends ModelResolver > resolver = resolvers.get(modelType);
        if (resolver == null) {
            ServiceDeclaration resolverClass = loadedResolvers.get(modelType.getName());
            if (resolverClass != null) {
                try {
                    return (Class<? extends ModelResolver>)resolverClass.loadClass();
                } catch (ClassNotFoundException e) {
                    throw new IllegalArgumentException(e);
                }
            }
        }
View Full Code Here

        Object factory = factories.get(factoryInterface);
        if (factory == null) {

            // Dynamically load a factory class declared under META-INF/services
            try {
                ServiceDeclaration factoryDeclaration = ServiceDiscovery.getInstance().getServiceDeclaration(factoryInterface.getName());
                if (factoryDeclaration != null) {
                    Class<?> factoryClass = factoryDeclaration.loadClass();
           
                    // Default empty constructor
                    Constructor<?> constructor = factoryClass.getConstructor(ExtensionPointRegistry.class);
                    factory = constructor.newInstance(registry);
           
View Full Code Here

        }
        if (utility == null) {

            // Dynamically load a utility class declared under META-INF/services/"utilityType"
            try {
                ServiceDeclaration utilityDeclaration =
                    ServiceDiscovery.getInstance().getServiceDeclaration(utilityType.getName());
                if (utilityDeclaration != null) {
                    Class<?> utilityClass = utilityDeclaration.loadClass();

                    // Construct the utility
                    Constructor<?>[] constructors = utilityClass.getConstructors();
                    Constructor<?> constructor = getConstructor(constructors, ExtensionPointRegistry.class, Map.class);
                    if (constructor != null) {
                        utility = constructor.newInstance(extensionPoints, utilityDeclaration.getAttributes());
                    } else {
                        constructor = getConstructor(constructors, ExtensionPointRegistry.class);
                        if (constructor != null) {
                            utility = constructor.newInstance(extensionPoints);
                        } else {
View Full Code Here

        Object factory = factories.get(factoryInterface);
        if (factory == null) {

            // Dynamically load a factory class declared under META-INF/services
            try {
                ServiceDeclaration factoryDeclaration =
                    ServiceDiscovery.getInstance().getServiceDeclaration(factoryInterface.getName());
                if (factoryDeclaration != null) {
                    Class<?> factoryClass = factoryDeclaration.loadClass();
                    try {
                       
                        // Default empty constructor
                        Constructor<?> constructor = factoryClass.getConstructor();
                        factory = constructor.newInstance();
View Full Code Here

        Object extensionPoint = findExtensionPoint(extensionPointType);
        if (extensionPoint == null) {

            // Dynamically load an extension point class declared under META-INF/services
            try {
                ServiceDeclaration extensionPointDeclaration =
                    ServiceDiscovery.getInstance().getServiceDeclaration(extensionPointType.getName());
                if (extensionPointDeclaration != null) {
                    Class<?> extensionPointClass = extensionPointDeclaration.loadClass();

                    // Construct the extension point
                    Constructor<?>[] constructors = extensionPointClass.getConstructors();
                    Constructor<?> constructor =
                        getConstructor(constructors, new Class<?>[] {ExtensionPointRegistry.class});
View Full Code Here

        Assert.assertEquals(0, descriptors.size());
    }

    @Test
    public void testDiscoveryFirst() throws IOException {
        ServiceDeclaration descriptor = discoverer.getServiceDeclaration("test.TestService");
        Assert.assertNotNull(descriptor);
        descriptor = discoverer.getServiceDeclaration("notthere");
        Assert.assertNull(descriptor);
    }
View Full Code Here

     * @param factory
     * @return
     * @throws Exception
     */
    private <T> T getFactory(Class<T> factory) throws Exception {
        ServiceDeclaration sd = ServiceDiscovery.getInstance().getServiceDeclaration(factory.getName());
        if (sd != null) {
            return factory.cast(sd.loadClass().newInstance());
        } else {
            return factory.cast(factory.getMethod("newInstance").invoke(null));
        }
    }
View Full Code Here

       
        Class<?>[] classes = modelType.getInterfaces();
        for (Class<?> c : classes) {
            Class<? extends ModelResolver> resolver = resolvers.get(c);
            if (resolver == null) {
                ServiceDeclaration resolverClass = loadedResolvers.get(c.getName());
                if (resolverClass != null) {
                    try {
                        return (Class<? extends ModelResolver>)resolverClass.loadClass();
                    } catch (ClassNotFoundException e) {
                        throw new IllegalArgumentException(e);
                    }
                }
            } else {
                return resolver;
            }
        }

        Class<? extends ModelResolver > resolver = resolvers.get(modelType);
        if (resolver == null) {
            ServiceDeclaration resolverClass = loadedResolvers.get(modelType.getName());
            if (resolverClass != null) {
                try {
                    return (Class<? extends ModelResolver>)resolverClass.loadClass();
                } catch (ClassNotFoundException e) {
                    throw new IllegalArgumentException(e);
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.extensibility.ServiceDeclaration

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.