Package org.apache.tuscany.sca.extensibility

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


        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

    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

        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

        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

  
        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

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.