![]() |
![]() |
![]() |
![]() |
Custom controls consist of two Java source files: an interface class file and an implementation class file.
The interface class contains the control's publicly accessible methods. Clients of the control call the methods in the implementation class.
The implementation class contains the control's behind the scenes implementation code.
There is also a third class associated with each custom control: the generated JavaBean class. This is a build artifact created from the interface and implementation source files. The generated JavaBean class provides supplemental programmatic access to the control, especially the ability to override default annotation values in the control. For more information about this class see Overriding Control Annotation Values Through the Control JavaBean
A custom control interface class must be decorated with the @ControlInterface annotation.
package controls.hello; import org.apache.beehive.controls.api.bean.ControlInterface; @ControlInterface public interface Hello { ... }
The @ControlInterface annotation informs the compiler to treat this class as a part of the Beehive Control framework.
The interface class also lists the control's publicly available methods. The following example shows a control with one publicly available method.
package controls.hello; import org.apache.beehive.controls.api.bean.ControlInterface; @ControlInterface public interface Hello { public String hello(); }
A custom control implementation class contains the control's logic - the code that defines what the control does. In this file you define what each of the control's methods do.
The minimum requirements for a custom control implementation class are listed below.
import org.apache.beehive.controls.api.bean.ControlImplementation; @ControlImplementation public class HelloImpl
import org.apache.beehive.controls.api.bean.ControlImplementation; @ControlImplementation public class HelloImpl implements Hello
(a) implement java.io.Serializable
import java.io.Serializable; @ControlImplementation public class HelloImpl implements Hello, Serializable
@ControlImplementation(isTransient=true) public class HelloImpl implements Hello { }
![]() ![]() |