EventConnectorFactory

View: New views
1 Messages — Rating Filter:   Alert me  

EventConnectorFactory

by Franck Routier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, and happy new year to you all

I just realised I was reinventing the wheel: I wanted to get rid of the
verbose ListenerFactory definition in each and every screen... and after
creating my own SimpleListenerFactory(Class<? extends BaseEventListener>
hanlder), I noticed this class in Barracuda :

EventConnectorFactory... it does just what I want, and is here since
2002-02-15 (!?).

So, for those that like me didn't notice it, instead of :

public ListenerFactory lf = new DefaultListenerFactory() {
                @Override
                public BaseEventListener getInstance() {
                        return new MyHandler();
                }

                @Override
                public String getListenerID() {
                        return getID(MyHandler.class);
                }
        };

public MyScreen() {
    specifyLocalEventInterests(lf, MyEvent.class);
    }

you can simply write :

public MyScreen() {
    specifyLocalEventInterests(new
EventConnectorFactory(MyHandler.class, MyEvent.class);
    }


First good resolution for 2008 : be lazy, don't reinvent the wheel :)

Franck





--
Barracuda mailing list
Barracuda@...
http://www.ow2.org/wws/lists/projects/barracuda
LightInTheBox - Buy quality products at wholesale price