Package org.apache.tuscany.sca.extensibility

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


       
        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 = registry.getServiceDiscovery().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 =
                    registry.getServiceDiscovery().getServiceDeclaration(utilityType.getName());
                Class<?> utilityClass = null;
                if (utilityDeclaration != null) {
                    utilityClass = utilityDeclaration.loadClass();
                } else if (isConcreteClass(utilityType)) {
                    utilityClass = utilityType;
                    key = utilityType;
                }
                if (utilityClass != null) {
View Full Code Here

        Assert.assertEquals(2, 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

    @Test
    public void testTuscanyDiscovery() throws IOException {
        Collection<ServiceDeclaration> descriptors = discoverer.getServiceDeclarations("org.apache.tuscany.sca.test.TestService");
        // Only the version 2 should be found
        Assert.assertEquals(1, descriptors.size());
        ServiceDeclaration sd = descriptors.iterator().next();
        Assert.assertEquals("2", sd.getAttributes().get("version"));
    }
View Full Code Here

    private BundleContext init() throws Exception {
        if (framework != null) {
            throw new IllegalStateException("The framework is started already");
        }
        ServiceDeclaration sd = ServiceDiscovery.getInstance().getServiceDeclaration(FrameworkFactory.class.getName());
        Class<?> factoryCls = sd.loadClass();
        FrameworkFactory factory = (FrameworkFactory)factoryCls.newInstance();
        Map<Object, Object> props = new HashMap<Object, Object>();
        props.put("osgi.clean", "true");
        props.put("osgi.instance.area", new File("target/workspace").toURI().toString());
        props.put("osgi.install.area", new File("target/eclipse").toURI().toString());
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 =
                    registry.getServiceDiscovery().getServiceDeclaration(factoryInterface);
                if (factoryDeclaration != null) {
                    try {
                        // Constructor taking the extension point registry
                        factory = newInstance(registry, factoryDeclaration);
                    } catch (NoSuchMethodException e) {
                        factory = newInstance(factoryDeclaration.loadClass(), FactoryExtensionPoint.class, this);
                    }

                    // Cache the loaded factory
                    factories.put(factoryInterface, factory);
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 =
                    getServiceDiscovery().getServiceDeclaration(extensionPointType);
                if (extensionPointDeclaration != null) {
                    extensionPoint = newInstance(this, extensionPointDeclaration);
                    // Cache the loaded extension point
                    addExtensionPoint(extensionPoint, extensionPointDeclaration);
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

        List<ServiceDeclaration> list = new ArrayList<ServiceDeclaration>(modelResolverDeclarations);
       
        // Load model resolvers, add entries from lower ranking to higher ranking so that higher ranking ones override
        // the map
        for (int i = list.size() - 1; i >= 0; i--) {
            ServiceDeclaration modelResolverDeclaration = list.get(i);
            Map<String, String> attributes = modelResolverDeclaration.getAttributes();
            String model = attributes.get("model");
            // The model can be a list of interfaces so that one model resolver can be used
            // to resolve different types of models
            if (model != null) {
                StringTokenizer tokenizer = new StringTokenizer(model);
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.