org.apache.beehive.controls.system.ejb.EJBControlImplInitializer Maven / Gradle / Ivy
package org.apache.beehive.controls.system.ejb;
import java.lang.reflect.Field;
import org.apache.beehive.controls.api.ControlException;
import org.apache.beehive.controls.api.context.ControlBeanContext;
import org.apache.beehive.controls.runtime.bean.ControlBean;
@SuppressWarnings("all")
public class EJBControlImplInitializer
extends org.apache.beehive.controls.runtime.bean.ImplInitializer
{
protected static class ContextLifeCycleEventAdaptor implements org.apache.beehive.controls.api.context.ControlBeanContext.LifeCycle, java.io.Serializable
{
private static final long serialVersionUID = 1L;
org.apache.beehive.controls.system.ejb.EJBControlImpl __bc_impl;
ContextLifeCycleEventAdaptor(org.apache.beehive.controls.system.ejb.EJBControlImpl impl) { __bc_impl = impl; }
public void onCreate()
{
__bc_impl.onCreate();
}
public void onVetoableChange(java.beans.PropertyChangeEvent arg0) throws java.beans.PropertyVetoException
{
}
public void onPropertyChange(java.beans.PropertyChangeEvent arg0)
{
}
}
protected static class ResourceContextResourceEventsEventAdaptor implements org.apache.beehive.controls.api.context.ResourceContext.ResourceEvents, java.io.Serializable
{
private static final long serialVersionUID = 1L;
org.apache.beehive.controls.system.ejb.EJBControlImpl __bc_impl;
ResourceContextResourceEventsEventAdaptor(org.apache.beehive.controls.system.ejb.EJBControlImpl impl) { __bc_impl = impl; }
public void onRelease()
{
__bc_impl.onRelease();
}
public void onAcquire()
{
__bc_impl.onAcquire();
}
}
/**
* Initializes the nested contextual services required by the implementation
*/
public void initServices(ControlBean bean, Object target)
{
org.apache.beehive.controls.system.ejb.EJBControlImpl __bc_impl = (org.apache.beehive.controls.system.ejb.EJBControlImpl)target;
super.initServices(bean, __bc_impl);
ControlBeanContext __bc_beanContext = bean.getControlBeanContext();
try
{
org.apache.beehive.controls.api.context.ControlBeanContext _context = __bc_beanContext;
if (_context == null)
throw new ControlException("Contextual service org.apache.beehive.controls.api.context.ControlBeanContext is not available");
_context.addLifeCycleListener(new ContextLifeCycleEventAdaptor(__bc_impl));
__bc_impl.context = _context;
org.apache.beehive.controls.api.context.ResourceContext _resourceContext = (org.apache.beehive.controls.api.context.ResourceContext)__bc_beanContext.getService(org.apache.beehive.controls.api.context.ResourceContext.class, null);
if (_resourceContext == null)
throw new ControlException("Contextual service org.apache.beehive.controls.api.context.ResourceContext is not available");
_resourceContext.addResourceEventsListener(new ResourceContextResourceEventsEventAdaptor(__bc_impl));
__bc_impl.resourceContext = _resourceContext;
}
catch (RuntimeException __bc_re) { throw __bc_re; }
catch (Exception __bc_e)
{
throw new ControlException("Contextual service initialization failure", __bc_e);
}
}
/**
* Resets all nested contextual services instances to null
*/
public void resetServices(ControlBean bean, Object target)
{
org.apache.beehive.controls.system.ejb.EJBControlImpl __bc_impl = (org.apache.beehive.controls.system.ejb.EJBControlImpl)target;
super.resetServices(bean, __bc_impl);
try
{
__bc_impl.context = null;
__bc_impl.resourceContext = null;
}
catch (RuntimeException __bc_re) { throw __bc_re; }
catch (Exception __bc_e)
{
throw new ControlException("Contextual service reset failure", __bc_e);
}
}
}