Giter Site home page Giter Site logo

cdifire's Introduction

CDI Event Bus Problem

Trying to use CDI Event Bus like Guava’s EventBus:

	@Inject Event<Object> eventBus;
	
	@Schedule(second="*/3", minute="*", hour="*", dayOfWeek="*", persistent=false)
	public void sendSomething() {
		log.info("Send something!");
		eventBus.fire(new Booking(5.0));
		eventBus.fire(new Notify(new Date()));
	}

Problem is, the event handler is never called:

	public void logBooking(@Observes Booking booking) {
		log.info("Got booking " + booking);
	}

Because the EventBus implementation is Event<Object>, and Object as declared is
not assignable to Booking.

However, the object passed to fire() is a Booking, so the observer is actually able able
to handle it.

So it’s impossible to this:

@Inject Event<Document> eventBus;

and expect this to work:

eventBus.fire(new SpreadsheetDocument());

There’s no way to specialize the event? (other than explicitly typing the event, hence limiting
ability to fire events dynamically.)

Discussion: https://community.jboss.org/message/660495

cdifire's People

Contributors

ceefour avatar

Stargazers

Xavier Arias Seguí avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.