Examples of EventAdmin


Examples of org.osgi.service.event.EventAdmin

     * @param bundle The bundle hosting the web application.
     * @param contextPath
     *               The contextPath information from the bundle.
     */
    private void dispatch(String topic, Bundle bundle, String contextPath) {
        EventAdmin eventAdmin = getEventAdmin();
        if (eventAdmin == null) {
            return;
        }
        Dictionary<String, Object> props = createDefaultProperties(bundle, contextPath);
        eventAdmin.postEvent(new Event(topic, props));
    }
View Full Code Here

Examples of org.osgi.service.event.EventAdmin

            tracker.open();
        }

        @SuppressWarnings({"ThrowableResultOfMethodCallIgnored"})
        public void blueprintEvent(BlueprintEvent event) {
            EventAdmin eventAdmin = (EventAdmin) tracker.getService();
            if (eventAdmin == null) {
                return;
            }

            Dictionary<String, Object> props = new Hashtable<String, Object>();
            props.put(EventConstants.TYPE, event.getType());
            props.put(EventConstants.EVENT, event);
            props.put(EventConstants.TIMESTAMP, event.getTimestamp());
            props.put(EventConstants.BUNDLE, event.getBundle());
            props.put(EventConstants.BUNDLE_SYMBOLICNAME, event.getBundle().getSymbolicName());
            props.put(EventConstants.BUNDLE_ID, event.getBundle().getBundleId());
            props.put(EventConstants.BUNDLE_VERSION, JavaUtils.getBundleVersion(event.getBundle()));
            props.put(EventConstants.EXTENDER_BUNDLE, event.getExtenderBundle());
            props.put(EventConstants.EXTENDER_BUNDLE_ID, event.getExtenderBundle().getBundleId());
            props.put(EventConstants.EXTENDER_BUNDLE_SYMBOLICNAME, event.getExtenderBundle().getSymbolicName());
            props.put(EventConstants.EXTENDER_BUNDLE_VERSION, JavaUtils.getBundleVersion(event.getExtenderBundle()));

            if (event.getCause() != null) {
                props.put(EventConstants.CAUSE, event.getCause());
            }
            if (event.getDependencies() != null) {
                props.put(EventConstants.DEPENDENCIES, event.getDependencies());
            }
            String topic;
            switch (event.getType()) {
                case BlueprintEvent.CREATING:
                    topic = EventConstants.TOPIC_CREATING;
                    break;
                case BlueprintEvent.CREATED:
                    topic = EventConstants.TOPIC_CREATED;
                    break;
                case BlueprintEvent.DESTROYING:
                    topic = EventConstants.TOPIC_DESTROYING;
                    break;
                case BlueprintEvent.DESTROYED:
                    topic = EventConstants.TOPIC_DESTROYED;
                    break;
                case BlueprintEvent.FAILURE:
                    topic = EventConstants.TOPIC_FAILURE;
                    break;
                case BlueprintEvent.GRACE_PERIOD:
                    topic = EventConstants.TOPIC_GRACE_PERIOD;
                    break;
                case BlueprintEvent.WAITING:
                    topic = EventConstants.TOPIC_WAITING;
                    break;
                default:
                    throw new IllegalStateException("Unknown blueprint event type: " + event.getType());
            }
            eventAdmin.postEvent(new Event(topic, props));
        }
View Full Code Here

Examples of org.osgi.service.event.EventAdmin

            params.put(CIShellEventConstants.EVENT_TYPE, "algorithmFinished");
           
            if (params.get(CIShellEventConstants.EVENT_ID) == null)
                params.put(CIShellEventConstants.EVENT_ID, idGen.newID());
           
            EventAdmin eventAdmin = (EventAdmin) eventReg.getService();
            eventAdmin.postEvent(new Event(CIShellEventConstants.BASE_TOPIC, params));
        }
    }
View Full Code Here

Examples of org.osgi.service.event.EventAdmin

            return null;
        }
    }

    public void postEvent(Event event) {
        EventAdmin eventAdmin = (EventAdmin) eventAdminTracker.getService();
        if (eventAdmin != null) {
            eventAdmin.postEvent(event);
        } else {
            warning("EventAdmin is unavailable", null);
        }
    }
View Full Code Here

Examples of org.osgi.service.event.EventAdmin

    }

    // Javadoc inherited
    public void report(Map metrics) {

        EventAdmin sa = (EventAdmin) tracker.getService();
        if (null != sa) {
            Hashtable dict = new Hashtable();

            // process the input metrics map and copy appropriate content to the
            // dictionary we will use for event signalling
            Iterator it = metrics.entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry entry = (Map.Entry) it.next();
                Object key = entry.getKey();
                Object value = entry.getValue();
                if (null != value) {
                    if (key instanceof String) {
                        //noinspection StringContatenationInLoop
                        dict.put(DefaultMetrics.REPORT_PROPERTIES_PREFIX + key,
                                 value);
                    } else if (key instanceof Class) {
                        dict.put(DefaultMetrics.REPORT_CLASS,
                                 ((Class) value).getName());
                    } else if (key instanceof DynamicReport) {
                        // subtypes exist only for DynamicReport instances.
                        dict.put(DefaultMetrics.REPORT_SUBTYPE, value);
                    } else {
                        LOGGER.warn("unknown-event-property", key);
                    }
                }
            }
            // post the event (asynchronous)
            sa.postEvent(new Event(DefaultMetrics.TOPIC, dict));
        }
    }
View Full Code Here

Examples of org.osgi.service.event.EventAdmin

        tracker = new ServiceTracker<EventAdmin, EventAdmin>(context, EventAdmin.class.getName(), null);
        tracker.open();
    }

    public void featureEvent(FeatureEvent event) {
        EventAdmin eventAdmin = tracker.getService();
        if (eventAdmin == null) {
            return;
        }
        Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put(EventConstants.TYPE, event.getType());
        props.put(EventConstants.EVENT, event);
        props.put(EventConstants.TIMESTAMP, System.currentTimeMillis());
        props.put(EventConstants.FEATURE_NAME, event.getFeature().getName());
        props.put(EventConstants.FEATURE_VERSION, event.getFeature().getVersion());
        String topic;
        switch (event.getType()) {
            case FeatureInstalled:
                topic = EventConstants.TOPIC_FEATURES_INSTALLED;
                break;
            case FeatureUninstalled:
                topic = EventConstants.TOPIC_FEATURES_UNINSTALLED;
                break;
            default:
                throw new IllegalStateException("Unknown features event type: " + event.getType());
        }
        eventAdmin.postEvent(new Event(topic, props));
    }
View Full Code Here

Examples of org.osgi.service.event.EventAdmin

        }
        eventAdmin.postEvent(new Event(topic, props));
    }

    public void repositoryEvent(RepositoryEvent event) {
        EventAdmin eventAdmin = tracker.getService();
        if (eventAdmin == null) {
            return;
        }
        Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put(EventConstants.TYPE, event.getType());
        props.put(EventConstants.EVENT, event);
        props.put(EventConstants.TIMESTAMP, System.currentTimeMillis());
        props.put(EventConstants.REPOSITORY_NAME, event.getRepository().getName());
        props.put(EventConstants.REPOSITORY_URI, event.getRepository().getURI().toString());
        String topic;
        switch (event.getType()) {
            case RepositoryAdded:
                topic = EventConstants.TOPIC_REPOSITORY_ADDED;
                break;
            case RepositoryRemoved:
                topic = EventConstants.TOPIC_REPOSITORY_REMOVED;
                break;
            default:
                throw new IllegalStateException("Unknown repository event type: " + event.getType());
        }
        eventAdmin.postEvent(new Event(topic, props));
    }
View Full Code Here

Examples of org.osgi.service.event.EventAdmin

     * @param bundle The bundle hosting the web application.
     * @param contextPath
     *               The contextPath information from the bundle.
     */
    private void dispatch(String topic, Dictionary<String, Object> props) {
        EventAdmin eventAdmin = getEventAdmin();
        if (eventAdmin == null) {
            return;
        }
        eventAdmin.postEvent(new Event(topic, props));
    }
View Full Code Here

Examples of org.osgi.service.event.EventAdmin

    static class EventAdminAuditor {
        public static void audit(BundleContext bundleContext, String topic, String username, Subject subject) {
            ServiceReference<EventAdmin> ref = bundleContext.getServiceReference(EventAdmin.class);
            if (ref != null) {
                EventAdmin eventAdmin = bundleContext.getService(ref);
                try {
                    Map<String, Object> props = new HashMap<String, Object>();
                    Event event = new Event(topic, props);
                    props.put("type", topic.substring(topic.lastIndexOf("/") + 1).toLowerCase());
                    props.put("timestamp", System.currentTimeMillis());
                    props.put("username", username);
                    props.put("subject", subject);
                    eventAdmin.postEvent(event);
                } finally {
                    bundleContext.ungetService(ref);
                }
            }
        }
View Full Code Here

Examples of org.osgi.service.event.EventAdmin

            tracker.open();
        }

        @SuppressWarnings({"ThrowableResultOfMethodCallIgnored"})
        public void blueprintEvent(BlueprintEvent event) {
            EventAdmin eventAdmin = (EventAdmin) tracker.getService();
            if (eventAdmin == null) {
                return;
            }

            Dictionary<String, Object> props = new Hashtable<String, Object>();
            props.put(EventConstants.TYPE, event.getType());
            props.put(EventConstants.EVENT, event);
            props.put(EventConstants.TIMESTAMP, event.getTimestamp());
            props.put(EventConstants.BUNDLE, event.getBundle());
            props.put(EventConstants.BUNDLE_SYMBOLICNAME, event.getBundle().getSymbolicName());
            props.put(EventConstants.BUNDLE_ID, event.getBundle().getBundleId());
            props.put(EventConstants.BUNDLE_VERSION, JavaUtils.getBundleVersion(event.getBundle()));
            props.put(EventConstants.EXTENDER_BUNDLE, event.getExtenderBundle());
            props.put(EventConstants.EXTENDER_BUNDLE_ID, event.getExtenderBundle().getBundleId());
            props.put(EventConstants.EXTENDER_BUNDLE_SYMBOLICNAME, event.getExtenderBundle().getSymbolicName());
            props.put(EventConstants.EXTENDER_BUNDLE_VERSION, JavaUtils.getBundleVersion(event.getExtenderBundle()));

            if (event.getCause() != null) {
                props.put(EventConstants.CAUSE, event.getCause());
            }
            if (event.getDependencies() != null) {
                props.put(EventConstants.DEPENDENCIES, event.getDependencies());
            }
            String topic;
            switch (event.getType()) {
                case BlueprintEvent.CREATING:
                    topic = EventConstants.TOPIC_CREATING;
                    break;
                case BlueprintEvent.CREATED:
                    topic = EventConstants.TOPIC_CREATED;
                    break;
                case BlueprintEvent.DESTROYING:
                    topic = EventConstants.TOPIC_DESTROYING;
                    break;
                case BlueprintEvent.DESTROYED:
                    topic = EventConstants.TOPIC_DESTROYED;
                    break;
                case BlueprintEvent.FAILURE:
                    topic = EventConstants.TOPIC_FAILURE;
                    break;
                case BlueprintEvent.GRACE_PERIOD:
                    topic = EventConstants.TOPIC_GRACE_PERIOD;
                    break;
                case BlueprintEvent.WAITING:
                    topic = EventConstants.TOPIC_WAITING;
                    break;
                default:
                    throw new IllegalStateException("Unknown blueprint event type: " + event.getType());
            }
            eventAdmin.postEvent(new Event(topic, props));
        }
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.