Package org.apache.felix.ipojo.util

Examples of org.apache.felix.ipojo.util.Callback


        MethodField method = m_configMap.getMethodFromName(operationName,
            signature);
        if (method != null) {
            MethodMetadata methodCall = method.getMethod();
            Callback mc = new Callback(methodCall, m_instanceManager);
            try {
                return mc.call(params);
            } catch (NoSuchMethodException e) {
                throw new ReflectionException(e);
            } catch (IllegalAccessException e) {
                throw new ReflectionException(e);
            } catch (InvocationTargetException e) {
View Full Code Here


        }

        String oncommit = elements[0].getAttribute(ONCOMMIT_ATTRIBUTE);
        if (oncommit != null) {
            m_onCommit = new Callback(oncommit, new String[] { Transaction.class.getName() }, false, getInstanceManager());
        }

        String onrollback = elements[0].getAttribute(ONROLLBACK_ATTRIBUTE);
        if (onrollback != null) {
            m_onRollback = new Callback(onrollback, new String[] { Transaction.class.getName() }, false, getInstanceManager());
        }


        Element[] sub = elements[0].getElements(TRANSACTIONAL_ELEMENT);
        if (sub == null  || sub.length == 0) {
View Full Code Here

     * @param unbind the onDeparture method
     * @param modification the onModify method
     */
    public WhiteBoardManager(WhiteBoardPatternHandler handler, Filter filter, String bind, String unbind, String modification) {
        m_handler = handler;
        m_onArrival = new Callback(bind, new Class[] {ServiceReference.class}, false, m_handler.getInstanceManager());
        m_onDeparture = new Callback(unbind, new Class[] {ServiceReference.class}, false, m_handler.getInstanceManager());
        if (modification != null) {
            m_onModification = new Callback(modification, new Class[] {ServiceReference.class}, false, m_handler.getInstanceManager());
        }
        m_filter = filter;
        m_tracker = new Tracker(handler.getInstanceManager().getContext(), m_filter, this);
    }
View Full Code Here

                // Create the specified callback and register it
                MethodMetadata methodMetadata = pojoMetadata.getMethod(
                        subscriberMetadata.getCallback(),
                        new String[] { callbackType });
                Callback callback = new Callback(methodMetadata, m_manager);
                m_callbacksByName.put(name, callback);

                // Add the subscriber list gloal map
                m_subscribersByName.put(name, subscriberMetadata);
            }
View Full Code Here

            // Stack confinement
            boolean isListening = false;

            Object callbackParam = null;
            Callback callback = null;

            synchronized (this) {
                isListening = m_isListening;
            }

            // Check if the subscriber's topic and filter match
            Filter filter = subscriberMetadata.getFilter();

            if (EventUtil.matches(topic, subscriberMetadata.getTopics())
                    && (filter == null || event.matches(filter))) {

                String name = subscriberMetadata.getName();
                callback = (Callback) m_callbacksByName.get(name);

                try {
                    // Depending on the subscriber type...
                    callbackParam = getCallbackParameter(event,
                            subscriberMetadata);
                } catch (ClassCastException e) {
                    // Ignore the data event if type doesn't match
                    warn(LOG_PREFIX + "Ignoring data event : Bad data type", e);
                } catch (NoSuchFieldException e) {
                    // Ignore events without data field for data events
                    // subscriber
                    warn(LOG_PREFIX + "Ignoring data event : No data", e);
                }
            }


            // Run the callback (final check to avoid
            // NullPointerExceptions)
            if (isListening  && callback != null  && callbackParam != null) {
                try {
                    callback.call(new Object[] { callbackParam });
                } catch (InvocationTargetException e) {
                    error(LOG_PREFIX
                            + "The callback has thrown an exception",
                            e.getTargetException());
                } catch (Exception e) {
View Full Code Here

            ProvidedService svc = new ProvidedService(this, serviceSpecifications, factory, custom, configuration);

            // Post-Registration callback
            String post = providedService.getAttribute("post-registration");
            if (post != null) {
                Callback cb = new Callback(post, new Class[]{ServiceReference.class}, false, getInstanceManager());
                svc.setPostRegistrationCallback(cb);
            }

            post = providedService.getAttribute("post-unregistration");
            if (post != null) {
                // TODO Can we really send the service reference here ?
                Callback cb = new Callback(post, new Class[]{ServiceReference.class}, false, getInstanceManager());
                svc.setPostUnregistrationCallback(cb);
            }

            Element[] props = providedService.getElements("Property");
            if (props != null) {
View Full Code Here

                    callbackMetadata        = method;
                    callbackParameterType   = method.getMethodArguments()[0];
                }
            }
           
            this.callback           = new Callback(callbackMetadata, instance);
            this.isMessageCallback  = Message.class.getCanonicalName().equals(callbackParameterType);

        }
        else {
            this.callback           = null;
View Full Code Here

            MethodMetadata method = getPojoMetadata().getMethod(upd);
            if (method == null) {
                throw new ConfigurationException("The updated method is not found in the class "
                        + getInstanceManager().getClassName());
            } else if (method.getMethodArguments().length == 0) {
                m_updated = new Callback(upd, new Class[0], false, getInstanceManager());
            } else if (method.getMethodArguments().length == 1
                    && method.getMethodArguments()[0].equals(Dictionary.class.getName())) {
                m_updated = new Callback(upd, new Class[] {Dictionary.class}, false, getInstanceManager());
            } else {
                throw new ConfigurationException("The updated method is found in the class "
                        + getInstanceManager().getClassName() + " must have either no argument or a Dictionary");
            }
        }
View Full Code Here

            ProvidedService svc = new ProvidedService(this, serviceSpecifications, factory, custom, configuration);

            // Post-Registration callback
            String post = providedServices[i].getAttribute("post-registration");
            if (post != null) {
                Callback cb = new Callback(post, new Class[] {ServiceReference.class}, false, getInstanceManager());
                svc.setPostRegistrationCallback(cb);
            }

            post = providedServices[i].getAttribute("post-unregistration");
            if (post != null) {
                // TODO Can we really send the service reference here ?
                Callback cb = new Callback(post, new Class[] {ServiceReference.class}, false, getInstanceManager());
                svc.setPostUnregistrationCallback(cb);
            }

            Element[] props = providedServices[i].getElements("Property");
            if (props != null) {
View Full Code Here

        }

        String oncommit = elements[0].getAttribute(ONCOMMIT_ATTRIBUTE);
        if (oncommit != null) {
            m_onCommit = new Callback(oncommit, new String[] { Transaction.class.getName() }, false, getInstanceManager());
        }

        String onrollback = elements[0].getAttribute(ONROLLBACK_ATTRIBUTE);
        if (onrollback != null) {
            m_onRollback = new Callback(onrollback, new String[] { Transaction.class.getName() }, false, getInstanceManager());
        }


        Element[] sub = elements[0].getElements(TRANSACTIONAL_ELEMENT);
        if (sub == null  || sub.length == 0) {
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.util.Callback

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.