Package org.osgi.service.event

Examples of org.osgi.service.event.EventHandler


    tracker.close();
  }


  public Object addingService(ServiceReference serviceReference) {
    EventHandler eh = (EventHandler) bc.getService(serviceReference);
    if(eh != null) {
      return TrackedEventHandler.create(this, serviceReference, eh);
    } else {
      return null;
    }
View Full Code Here


        final List<ServiceRegistration> registrations = new ArrayList<ServiceRegistration>();
        final List<Thread> threads = new ArrayList<Thread>();
        final AtomicLong finishedThreads = new AtomicLong();

        final ServiceRegistration eventHandler = this.registerEventHandler("org/apache/sling/event/notification/job/*",
                new EventHandler() {

                    @Override
                    public void handleEvent(final Event event) {
                        final String topic = (String) event.getProperty(NotificationConstants.NOTIFICATION_PROPERTY_JOB_TOPIC);
                        if ( NotificationConstants.TOPIC_JOB_FINISHED.equals(event.getTopic())) {
View Full Code Here

    @Test(timeout = DEFAULT_TEST_TIMEOUT)
    public void testSimpleJobExecutionUsingBridge() throws Exception {
        final Barrier cb = new Barrier(2);

        final ServiceRegistration reg = this.registerEventHandler(TOPIC,
                new EventHandler() {
                    @Override
                    public void handleEvent(Event event) {
                        JobUtil.acknowledgeJob(event);
                        JobUtil.finishedJob(event);
                        cb.block();
View Full Code Here

                    }

                 });
        final AtomicInteger count = new AtomicInteger(0);
        final ServiceRegistration reg2 = this.registerEventHandler(NotificationConstants.TOPIC_JOB_FINISHED,
                new EventHandler() {
                    @Override
                    public void handleEvent(Event event) {
                        count.incrementAndGet();
                    }
                 });
View Full Code Here

                        }
                        return JobResult.FAILED;
                    }
                });
        final ServiceRegistration eh1Reg = this.registerEventHandler(NotificationConstants.TOPIC_JOB_CANCELLED,
                new EventHandler() {

                    @Override
                    public void handleEvent(Event event) {
                        final String id = (String)event.getProperty("id");
                        cancelled.add(id);
                    }
                });
        final ServiceRegistration eh2Reg = this.registerEventHandler(NotificationConstants.TOPIC_JOB_FAILED,
                new EventHandler() {

                    @Override
                    public void handleEvent(Event event) {
                        final String id = (String)event.getProperty("id");
                        failed.add(id);
                    }
                });
        final ServiceRegistration eh3Reg = this.registerEventHandler(NotificationConstants.TOPIC_JOB_FINISHED,
                new EventHandler() {

                    @Override
                    public void handleEvent(Event event) {
                        final String id = (String)event.getProperty("id");
                        finished.add(id);
                    }
                });
        final ServiceRegistration eh4Reg = this.registerEventHandler(NotificationConstants.TOPIC_JOB_STARTED,
                new EventHandler() {

                    @Override
                    public void handleEvent(Event event) {
                        final String id = (String)event.getProperty("id");
                        started.add(id);
View Full Code Here

    @Test(timeout = DEFAULT_TEST_TIMEOUT)
    public void testTimedJob() throws Exception {
        final AtomicInteger counter = new AtomicInteger();

        final ServiceRegistration ehReg = this.registerEventHandler(TOPIC, new EventHandler() {

            @Override
            public void handleEvent(final Event event) {
                if ( TOPIC.equals(event.getTopic()) ) {
                    counter.incrementAndGet();
View Full Code Here

    @Test(timeout = DEFAULT_TEST_TIMEOUT)
    public void testPeriodicTimedJob() throws Exception {
        final AtomicInteger counter = new AtomicInteger();

        final ServiceRegistration ehReg = this.registerEventHandler(TOPIC, new EventHandler() {

            @Override
            public void handleEvent(final Event event) {
                if ( TOPIC.equals(event.getTopic()) ) {
                    counter.incrementAndGet();
View Full Code Here

                        processedJobsCount.incrementAndGet();
                        return JobResult.OK;
                    }
                });
        final ServiceRegistration ehReg = this.registerEventHandler(NotificationConstants.TOPIC_JOB_FINISHED,
                new EventHandler() {

                    @Override
                    public void handleEvent(Event event) {
                        finishedEvents.add(event);
                    }
View Full Code Here

                        failedJobsCount.incrementAndGet();
                        return JobResult.OK;
                    }
                });
        final ServiceRegistration ehReg = this.registerEventHandler(NotificationConstants.TOPIC_JOB_FINISHED,
                new EventHandler() {

                    @Override
                    public void handleEvent(Event event) {
                        finishedEvents.add(event);
                    }
View Full Code Here

                        parallelCount.decrementAndGet();
                        return JobResult.OK;
                    }
                });
        final ServiceRegistration ehReg = this.registerEventHandler(NotificationConstants.TOPIC_JOB_FINISHED,
                new EventHandler() {

                    @Override
                    public void handleEvent(final Event event) {
                        count.incrementAndGet();
                    }
View Full Code Here

TOP

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

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.