Package org.osgi.service.event

Examples of org.osgi.service.event.Event


        // Flush event list of the event tracker
        m_eventTracker.clearEvents();

        // Send donuts and check the sender instance name
        Event receivedEvent;
        for (int i = 0; i < NUMBER_OF_EAH_PROVIDERS; i++) {
            m_eahProviders[i].sellDonut();
            receivedEvent = m_eventTracker.waitForEvent();
            assertEquals(
                    "The instance name property of the received message must be the same as the sender instance name.",
                    m_eahProvidersInstances[i].getInstanceName(), receivedEvent
                    .getProperty("publisher.instance.name"));
        }
    }
View Full Code Here


        // Add instance information in the event
        content.put(INSTANCE_NAME_PROPERTY, m_instanceName);
        // We sent the event on each topic
        for (int i = 0; i < m_topics.length; i++) {
            // Create an event with the given topic and content
            Event e = new Event(m_topics[i], content);
            // Send the event, depending on the sending mode
            if (!m_synchronous) {
                m_handler.getEventAdminService().postEvent(e); // Asynchronous
            } else {
                m_handler.getEventAdminService().sendEvent(e); // Synchronous
View Full Code Here

    public Donut sellDonut() {
        Dictionary rawEvent = new Hashtable();
        Donut donut = new Donut(m_serial++, m_name, Donut.FLAVOURS[m_random
                .nextInt(Donut.FLAVOURS.length)]);
        rawEvent.put("food", donut);
        m_ea.postEvent(new Event("food/donuts", rawEvent));
        return donut;
    }
View Full Code Here

     */
    private void sendCompleteEvent(AbstractDeploymentPackage source, AbstractDeploymentPackage target, boolean success) {
        Dictionary props = createEventProperties(source, target);
        props.put(EVENTPROPERTY_SUCCESSFUL, Boolean.valueOf(success));

        m_eventAdmin.postEvent(new Event(EVENTTOPIC_COMPLETE, props));
    }
View Full Code Here

     * @param target the current installed package (can be new).
     */
    private void sendStartedEvent(AbstractDeploymentPackage source, AbstractDeploymentPackage target) {
        Dictionary props = createEventProperties(source, target);

        m_eventAdmin.postEvent(new Event(EVENTTOPIC_INSTALL, props));
    }
View Full Code Here

     * @param target the current installed package (can be new).
     */
    private void sendUninstallEvent(AbstractDeploymentPackage source, AbstractDeploymentPackage target) {
        Dictionary props = createEventProperties(source, target);

        m_eventAdmin.postEvent(new Event(EVENTTOPIC_UNINSTALL, props));
    }
View Full Code Here

   
    private static final Event newEvent(HttpServletRequest request)
    {
        String topic = request.getParameter("topic"); //$NON-NLS-1$

        return new Event(topic, (Dictionary)PropertiesEditorSupport.convertProperties(request));
    }
View Full Code Here

    protected void doPost( HttpServletRequest req, HttpServletResponse resp )
    throws ServletException, IOException
    {
        final String action = req.getParameter( PARAMETER_ACTION );
        if ( ACTION_POST.equals(action) ) {
            final Event event = newEvent(req);
            eventAdmin.postEvent(event);
        } else if (ACTION_SEND.equals(action)) {
            final Event event = newEvent(req);
            eventAdmin.sendEvent(event);
        } else if ( ACTION_CLEAR.equals( action ) ) {
            this.collector.clear();
        }
        // we always send back the json data
View Full Code Here

            d.setTime(System.currentTimeMillis() + 2000); // run in 2 seconds
            // send timed event
            final Dictionary<String, Object> props = new Hashtable<String, Object>();
            props.put(EventUtil.PROPERTY_TIMED_EVENT_TOPIC, TOPIC);
            props.put(EventUtil.PROPERTY_TIMED_EVENT_DATE, d);
            this.eventAdmin.sendEvent(new Event(EventUtil.TOPIC_TIMED_EVENT, props));

            while ( counter.get() == 0 ) {
                this.sleep(1000);
            }
        } finally {
View Full Code Here

            // send timed event
            final Dictionary<String, Object> props = new Hashtable<String, Object>();
            props.put(EventUtil.PROPERTY_TIMED_EVENT_TOPIC, TOPIC);
            props.put(EventUtil.PROPERTY_TIMED_EVENT_PERIOD, 1L);
            props.put(EventUtil.PROPERTY_TIMED_EVENT_ID, "id");
            this.eventAdmin.sendEvent(new Event(EventUtil.TOPIC_TIMED_EVENT, props));

            while ( counter.get() < 5 ) {
                this.sleep(1000);
            }
            final Dictionary<String, Object> props2 = new Hashtable<String, Object>();
            props2.put(EventUtil.PROPERTY_TIMED_EVENT_TOPIC, TOPIC);
            props2.put(EventUtil.PROPERTY_TIMED_EVENT_ID, "id");

            this.eventAdmin.sendEvent(new Event(EventUtil.TOPIC_TIMED_EVENT, props2));
            int current = counter.get();
            this.sleep(2000);
            if ( counter.get() != current && counter.get() != current + 1 ) {
                fail("Events are still sent");
            }
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.