Instantiating Beehive JdbcControl manually

Common usage pattern for Beehive Jdbc control is:

  • Create DB control class by extending JdbcControl
  • Declare DB control variable in page controller and use @Control annotation to have it automatically instantiated and injected
  • Use the DB control

The above works fine. But what happens if we would like to use our DB control class from within JSP page which is not part of our Beehive application and has no access to our controller?

The following text presents one possible approach.

Custom DB control class:
@JdbcControl.ConnectionDataSource(jndiName = “dataSource”)
public interface MyDBControl extends JdbcControl {
statement=”SELECT * FROM \”SCHEMA\”.\”MYTABLE\””)
public MyObject[] getAllObjects();


Classic approach, instantiate via @Control annotation in controller:
public class MyController extends PageFlowController {
private MyDBControl myControl;

//you can now use myControl…

But what if we need to instantiate the DB control class manually? One possible approach might be creating a factory like this:
public class MyDBControlFactory {
public static MyDBControl createDBControl() {
try {
ControlBeanContext ctx = new ServletBeanContext();
MyDBControlBean controlBean =
return controlBean;
} catch (ClassNotFoundException e) {
//handle it…
return null;

Comments are closed.