Package org.osgi.service.event

Examples of org.osgi.service.event.Event


                ResourceResolver resolver = null;
                try {
                    resolver = this.resourceResolverFactory.getAdministrativeResourceResolver(null);
                    final Resource eventResource = resolver.getResource(path);
                    if ( DistributedEventAdminImpl.RESOURCE_TYPE_EVENT.equals(eventResource.getResourceType())) {
                        final Event e = this.readEvent(eventResource);
                        if ( e != null ) {
                            // we check event admin as processing is async
                            final EventAdmin localEA = this.eventAdmin;
                            if ( localEA != null ) {
                                localEA.postEvent(e);
View Full Code Here


        final String VALUE = "some value";
        final String topic = TOPIC_PREFIX + "event/test";
        final Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put("a property", VALUE);
        final Event e = new Event(topic, props);
        this.receiver.handleEvent(e);

        while ( this.events.size() == 0 ) {
            Thread.sleep(5);
        }
        final Event receivedEvent = this.events.get(0);

        assertEquals(topic, receivedEvent.getTopic());
        assertEquals(OTHER_APP_ID, receivedEvent.getProperty(DEAConstants.PROPERTY_APPLICATION));
        assertEquals(VALUE, receivedEvent.getProperty("a property"));
        assertNull(receivedEvent.getProperty(ResourceResolver.PROPERTY_RESOURCE_TYPE));

        this.events.clear();
    }
View Full Code Here

        final Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put("a property", "some value");
        // now we check if the application id is handled correctly
        props.put(DEAConstants.PROPERTY_APPLICATION, "foo");

        final Event e = new Event(topic, props);
        this.receiver.handleEvent(e);

        while ( this.events.size() == 0 ) {
            Thread.sleep(5);
        }
        final Event receivedEvent = this.events.get(0);

        assertEquals(topic, receivedEvent.getTopic());
        assertEquals(OTHER_APP_ID, receivedEvent.getProperty(DEAConstants.PROPERTY_APPLICATION));
        assertEquals(VALUE, receivedEvent.getProperty("a property"));
        assertNull(receivedEvent.getProperty(ResourceResolver.PROPERTY_RESOURCE_TYPE));

        this.events.clear();
    }
View Full Code Here

        final String RT = "my:resourceType";

        final Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put(ResourceResolver.PROPERTY_RESOURCE_TYPE, RT);

        final Event e = new Event(topic, props);
        this.receiver.handleEvent(e);

        while ( this.events.size() == 0 ) {
            Thread.sleep(5);
        }
        final Event receivedEvent = this.events.get(0);

        assertEquals(topic, receivedEvent.getTopic());
        assertEquals(OTHER_APP_ID, receivedEvent.getProperty(DEAConstants.PROPERTY_APPLICATION));
        assertEquals(RT, receivedEvent.getProperty(ResourceResolver.PROPERTY_RESOURCE_TYPE));
        assertNull(receivedEvent.getProperty("event.dea." + ResourceResolver.PROPERTY_RESOURCE_TYPE));

        this.events.clear();
    }
View Full Code Here

    protected void addEvent(final Event e) {
        final Dictionary<String, Object> props = new Hashtable<String, Object>();
        for(final String name : e.getPropertyNames()) {
            props.put(name, e.getProperty(name));
        }
        this.events.add(new Event(e.getTopic(), props) {

            @Override
            public String toString() {
                return "Event(topic=" + e.getTopic() + ", properties=" + props + ")";
            }
View Full Code Here

    }

    private Event newEvent(final String topic, final ServiceReference reference) {
        Dictionary<Object, Object> props = new Properties();
        props.put("service.id", reference.getProperty(Constants.SERVICE_ID));
        return new Event(topic, props);
    }
View Full Code Here

        // timestamp the event
        table.put(EventConstants.TIMESTAMP,
            new Long(System.currentTimeMillis()));

        // create the event
        return new Event(topic, table);
    }
View Full Code Here

    /**
     * Send an OSGi event
     */
    private void sendChangeEvent() {
        if (this.eventAdmin != null) {
            final Event event = new Event(SlingConstants.TOPIC_RESOURCE_RESOLVER_MAPPING_CHANGED,
                            (Dictionary<?, ?>) null);
            this.eventAdmin.postEvent(event);
        }
    }
View Full Code Here

                logger.debug("bindResourceProvider: {}={} ({})", new Object[] { root, provider, debugServiceName });
                if (localEA != null) {
                    final Dictionary<String, Object> eventProps = new Hashtable<String, Object>();
                    eventProps.put(SlingConstants.PROPERTY_PATH, root);
                    localEA.postEvent(new Event(SlingConstants.TOPIC_RESOURCE_PROVIDER_ADDED, eventProps));
                }
            }
        }
        if ( !foundRoot ) {
            logger.info("Ignoring ResourceProvider(Factory) {} : no configured roots.", provider.getName());
View Full Code Here

                logger.debug("unbindResourceProvider: root={} ({})", root, debugServiceName);
                if (localEA != null) {
                    final Dictionary<String, Object> eventProps = new Hashtable<String, Object>();
                    eventProps.put(SlingConstants.PROPERTY_PATH, root);
                    localEA.postEvent(new Event(SlingConstants.TOPIC_RESOURCE_PROVIDER_REMOVED, eventProps));
                }
            }
        }

        logger.debug("unbindResourceProvider: Unbound {}, current providers={}", debugServiceName, Arrays.asList(getResourceProviders()) );
View Full Code Here

TOP

Related Classes of org.osgi.service.event.Event

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.