public class HandlerContainerImpl extends Object implements HandlerContainer
HandlerContainer. Inherit from this class if you want subclasses that can contain handlers. Classes inheriting from
HandlerContainerImpland that participate in dependency injection with Guice/GIN can use the automatic binding mechanism. See
HandlerContainerImpl(boolean)for more details.
|Constructor and Description|
Creates a handler container class with automatic binding, unless
Creates a handler container class with or without automatic binding.
|Modifier and Type||Method and Description|
Call this method after the object is constructed in order to bind all its handlers.
Returns true if the
Lifecycle method called when binding the object.
Lifecycle method called when unbinding the object.
Registers a handler so that it is automatically removed when
Call this method when you want to release the object and its handlers are not needed anymore.
@Inject public HandlerContainerImpl()
AutobindDisableis used to globally disable automatic binding. Autobinding requires the class to be instantiated by Guice/GIN. If you are instantiating
new, autobinding will not work. It is recommended you document it by using #HandlerContainerImpl(boolean) with
falseas a parameter.
public HandlerContainerImpl(boolean autoBind)
bind()method will be called automatically after the class is instantiated through Guice/GIN dependency injection mechanism, unless
AutobindDisableis used to globally disable automatic binding. Otherwise, the user is responsible for calling
bind(). Autobinding requires the class to be instantiated by Guice/GIN. If you are instantiating
new, autobinding will not work. It is recommended you document it by passing
trueto request automatic binding,
public void bind()
HandlerContainer.bind()from the constructor of a non-leaf class since it is meant to be called after the object has been entirely constructed. When automatic binding is used (see
HandlerContainerImpl), this will be called immediately after the object is constructed through Guice/GIN dependency injection mechanism. If you are not using automatic binding, or if you later call
HandlerContainer.unbind()on this object, you will have to call
HandlerContainer.bind()manually. Multiple call to bind will not fail, the class will be bound once.
public final boolean isBound()
HandlerContaineris currently bound. That is, the
HandlerContainer.bind()method has completed and
HandlerContainer.unbind()has not been called.
public void unbind()
HandlerContainer.bind()again manually if you ever want to reuse the object.
protected void onBind()
onBind(). Also, do not call directly, call
bind()instead. Any event handler should be initialised here rather than in the constructor. Also, it is good practice to perform any costly initialisation here. Handlers registered by calling
registerHandler(HandlerRegistration)will be removed when unbinding. Any other initialisation that takes place here (or as a side-effect of what is done here) should be taken down in
onUnbind(). This method will never be invoked more then once, or if it is, the second time will necessarily be preceded by an invocation of
protected void onUnbind()
onUnbind(). Also, do not call directly, call
unbind()instead. Any handler registration recorded with
(HandlerRegistration)will have already been removed at this point. You should override this method to take down any other initialisation that took place in
onBind(). This method will never be invoked more then once, or if it is, the second time will necessarily be preceded by an invocation of
protected void registerHandler(HandlerRegistration handlerRegistration)
unbind()is called. This provides an easy way to track event handler registrations.
handlerRegistration- The registration of handler to track.
Copyright © 2010–2014 Arcbees. All rights reserved.