Part 3 : Create the SampleStartupBeanEJB module
Now we will create the SampleStartupBeanEJB module, which hosts the startup bean,
then we will create the messaging task and register it with the scheduler. This, then, would in turn post the trigger messages on the SI bus, periodically.
First, create a new EJB module called "SampleStartupBeanEJB" and attach it to the TimerMediationModule’s EAR known as "TimerMediationModuleapp", as shown in Figure 15.
Figure 15. Creating SampleStartupBeanEJB
Disable the creation of the EJB Client module as shown in the following figure.
Figure 16. Creating SampleStartupBeanEJB
Once the EJB module is created, right-click and go to Properties > Java Build Path > Libraries. Extend the variable ECLIPSE_HOME and point to the startup.jar under ECLIPSE_HOME/runtimes/bi_v6/lib. Once the variable is added, the libraries pane should look like the following figure.
Figure 17. Creating SampleStartupBeanEJB
Right click the SampleStartupBeanEJB project and choose New > EnterpriseBean. Now
let's create the startup bean. Give the Bean Name as SampleStartupBean and accept the defaults as shown in Figure 18.
Figure 18. Creating SampleStartupBeanEJB
Click Next. Title the Remote home interface, "com.ibm.websphere.startupservice.AppStartUpHome", and the remote interface as "com.ibm.websphere.startupservice.AppStartUp", like we see in the following figure :
Figure 19. Creating SampleStartupBeanEJB
Click on Finish. Two warning messages display in the Problems pane that point out that the start() and the stop() methods need to be implemented by the SampleStartupBean class.
Any application startup bean, should implement two functions called "start()" and "stop()". Note that we had added this EJB module to the TimerMediationModule. Whenever the mediation module EAR is installed and started, the start() function of the SampleStartupBean would automatically be invoked. Whenever the TimerMediationModule is stopped or uninstalled, the stop() function of the SampleStartupBean would be invoked.
Here we use the start() function to implement the logic of getting a handle to the scheduler, implement a messaging task and register it with the scheduler.
Similarly, we use the stop() function to unregister the task with the scheduler or kill any tasks that were previously spawned by the start() function.
Now, before we implement these two functions, we would first create and configure
the necessary resources on WESB, which would be used by the scheduler, the
messaging task and the timer mediation module. We will complete this in section 4.
|