Examples of SingletonObjectFactory


Examples of org.apache.tuscany.core.injection.SingletonObjectFactory

        boolean eagerInit = false;
        EventInvoker destroyInvoker = null;
        for (Field field : fields) {
            ComponentName compName = field.getAnnotation(ComponentName.class);
            if (compName != null) {
                Injector injector = new FieldInjector(field, new SingletonObjectFactory(name));
                injectors.add(injector);
            }
            org.osoa.sca.annotations.Context context = field.getAnnotation(org.osoa.sca.annotations.Context.class);
            if (context != null) {
                Injector injector = new FieldInjector(field, new SingletonObjectFactory(moduleComponentContext));
                injectors.add(injector);
            }
        }
        for (Method method : methods) {
            // FIXME Java5
            Init init = method.getAnnotation(Init.class);
            if (init != null && initInvoker == null) {
                initInvoker = new MethodEventInvoker(method);
                eagerInit = init.eager();
                continue;
            }
            Destroy destroy = method.getAnnotation(Destroy.class);
            if (destroy != null && destroyInvoker == null) {
                destroyInvoker = new MethodEventInvoker(method);
                continue;
            }
            ComponentName compName = method.getAnnotation(ComponentName.class);
            if (compName != null) {
                Injector injector = new MethodInjector(method, new SingletonObjectFactory(name));
                injectors.add(injector);
            }
            org.osoa.sca.annotations.Context context = method.getAnnotation(org.osoa.sca.annotations.Context.class);
            if (context != null) {
                Injector injector = new MethodInjector(method, new SingletonObjectFactory(moduleComponentContext));
                injectors.add(injector);
            }
        }
        boolean stateless = (scope == Scope.INSTANCE);
        return new JavaAtomicContext("foo", new PojoObjectFactory(JavaIntrospectionHelper
View Full Code Here

Examples of org.apache.tuscany.core.injection.SingletonObjectFactory

        assert type != null : "property type is null";
        String text = reader.getElementText();

        // degenerate case where we are returning a String
        if (String.class.equals(type)) {
            return new SingletonObjectFactory(text);
        }

        // special handler to convert hexBinary to a byte[]
        if (byte[].class.equals(type)) {
            byte[] instance = new byte[text.length() >> 1];
            for (int i = 0; i < instance.length; i++) {
                instance[i] = (byte) (Character.digit(text.charAt(i << 1), 16) << 4 | Character.digit(text.charAt((i << 1) + 1), 16));
            }
            return new SingletonObjectFactory(instance);
        }

        // does this type have a static valueOf(String) method?
        try {
            Method valueOf = type.getMethod("valueOf", String.class);
            if (Modifier.isStatic(valueOf.getModifiers())) {
                try {
                    return new SingletonObjectFactory(valueOf.invoke(null, text));
                } catch (IllegalAccessException e) {
                    throw new AssertionError("getMethod returned an inaccessible method");
                } catch (InvocationTargetException e) {
                    // FIXME we should throw something better
                    throw new ConfigurationLoadException(e.getCause());
                }
            }
        } catch (NoSuchMethodException e) {
            // try something else
        }

        // does this type have a constructor that takes a String?
        try {
            Constructor<?> ctr = type.getConstructor(String.class);
            return new SingletonObjectFactory(ctr.newInstance(text));
        } catch (NoSuchMethodException e) {
            // try something else
        } catch (IllegalAccessException e) {
            throw new AssertionError("getConstructor returned an inaccessible method");
        } catch (InstantiationException e) {
            throw new ConfigurationLoadException("Property type cannot be instantiated: " + type.getName());
        } catch (InvocationTargetException e) {
            // FIXME we should throw something better
            throw new ConfigurationLoadException(e.getCause());
        }

        // do we have a property editor for it?
        PropertyEditor editor = PropertyEditorManager.findEditor(type);
        if (editor != null) {
            try {
                editor.setAsText(text);
                return new SingletonObjectFactory(editor.getValue());
            } catch (IllegalArgumentException e) {
                // FIXME we should throw something better
                throw new ConfigurationLoadException(e);

            }
View Full Code Here

Examples of org.mule.object.SingletonObjectFactory

            QueueProfile queueProfile = QueueProfile.newInstancePersistingToDefaultMemoryQueueStore(muleContext);
            s.setQueueProfile(queueProfile);
           
            ((CompositeMessageSource) s.getMessageSource()).addSource(
                muleContext.getEndpointFactory().getInboundEndpoint(newEndpoint));
            final DefaultJavaComponent component = new DefaultJavaComponent(new SingletonObjectFactory(listener));
            component.setMuleContext(muleContext);
            s.setComponent(component);
            muleContext.getRegistry().registerService(s);
            return true;
        }
View Full Code Here

Examples of org.mule.object.SingletonObjectFactory

                InboundEndpoint endpoint = endpointFactory.getInboundEndpoint(endpointBuilder);

                messageRouter.addSource(endpoint);
            }
        }
        DefaultJavaComponent component = new DefaultJavaComponent(new SingletonObjectFactory(this));
        component.setMuleContext(muleContext);
        service.setComponent(component);
        return service;
    }
View Full Code Here

Examples of org.mule.object.SingletonObjectFactory

    {
        this.muleContext = muleContext;
        AbstractObjectFactory factory;
        if (scope == Scope.Singleton)
        {
            factory = new SingletonObjectFactory(clazz);
        }
        else
        {
            factory = new PrototypeObjectFactory(clazz);
        }
View Full Code Here

Examples of org.mule.object.SingletonObjectFactory

    }

    ComponentBuilder(Object instance, MuleContext muleContext)
    {
        this.muleContext = muleContext;
        ObjectFactory  factory = new SingletonObjectFactory(instance);
        component = new DefaultJavaComponent(factory);
    }
View Full Code Here

Examples of org.mule.object.SingletonObjectFactory

            service.setName(AXIS_SERVICE_PROPERTY + getName());
            service.setModel(muleContext.getRegistry().lookupSystemModel());

            Map props = new HashMap();
            props.put(AXIS, axis);
            SingletonObjectFactory of = new SingletonObjectFactory(AxisServiceComponent.class, props);
            final DefaultJavaComponent component = new DefaultJavaComponent(of);
            component.setMuleContext(muleContext);
            service.setComponent(component);
        }
        return service;
View Full Code Here

Examples of org.mule.object.SingletonObjectFactory

    public AbderaServiceComponent()
    {
        super();

        setObjectFactory(new SingletonObjectFactory(new AbderaCallable(this)));
    }
View Full Code Here

Examples of org.mule.object.SingletonObjectFactory

    {
        final String domainOriginal = "TEST_DOMAIN_1";

        final SedaService service = new SedaService(muleContext);
        service.setName("TEST_SERVICE");
        SingletonObjectFactory factory = new SingletonObjectFactory(Object.class);
        final DefaultJavaComponent component = new DefaultJavaComponent(factory);
        component.setMuleContext(muleContext);
        service.setComponent(component);

        service.setThreadingProfile(ThreadingProfile.DEFAULT_THREADING_PROFILE);
View Full Code Here

Examples of org.mule.object.SingletonObjectFactory

     *
     * @param callable
     */
    public SimpleCallableJavaComponent(Callable callable)
    {
        objectFactory = new SingletonObjectFactory(callable);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.