| Method from org.jboss.ejb.MessageDrivenContainer Detail: |
public void addInterceptor(Interceptor in) {
if (interceptor == null)
{
interceptor = in;
}
else
{
Interceptor current = interceptor;
while (current.getNext() != null)
{
current = current.getNext();
}
current.setNext(in);
}
}
|
Interceptor createContainerInterceptor() {
return new ContainerInterceptor();
}
|
public EJBObject createHome() throws CreateException, RemoteException {
throw new Error("createHome not valid for MessageDriven beans");
}
|
protected void createService() throws Exception {
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
pushENC();
try
{
// Call default init
super.createService();
// Map the bean methods
Map map = new HashMap();
MessageDrivenMetaData mdMetaData = (MessageDrivenMetaData)metaData;
String type = mdMetaData.getMessagingType();
if(type == null || type.length() == 0)
type = MessageDrivenMetaData.DEFAULT_MESSAGING_TYPE;
Class clazz = getClassLoader().loadClass(type);
Method[] methods = clazz.getDeclaredMethods();
for (int i = 0; i < methods.length; i++)
{
Method m = methods[i];
map.put(m, beanClass.getMethod(m.getName(), m.getParameterTypes()));
log.debug("Mapped " + m.getName() + " " + m.hashCode() + " to " + map.get(m));
}
if( TimedObject.class.isAssignableFrom( beanClass ) ) {
// Map ejbTimeout
map.put(
TimedObject.class.getMethod( "ejbTimeout", new Class[] { Timer.class } ),
beanClass.getMethod( "ejbTimeout", new Class[] { Timer.class } )
);
}
beanMapping = map;
// Try to register the instance pool as an MBean
try
{
ObjectName containerName = super.getJmxName();
Hashtable props = containerName.getKeyPropertyList();
props.put("plugin", "pool");
ObjectName poolName = new ObjectName(containerName.getDomain(), props);
server.registerMBean(instancePool, poolName);
}
catch(Throwable t)
{
log.debug("Failed to register pool as mbean", t);
}
// Initialize pool
instancePool.create();
for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();)
{
String invokerBinding = (String) it.next();
EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding);
// Try to register the container invoker as an MBean
try
{
ObjectName containerName = super.getJmxName();
Hashtable props = containerName.getKeyPropertyList();
props.put("plugin", "invoker");
props.put("binding", invokerBinding);
ObjectName invokerName = new ObjectName(containerName.getDomain(), props);
server.registerMBean(ci, invokerName);
}
catch(Throwable t)
{
log.debug("Failed to register invoker binding as mbean", t);
}
ci.create();
}
// Initialize the interceptor by calling the chain
Interceptor in = interceptor;
while (in != null)
{
in.setContainer(this);
in.create();
in = in.getNext();
}
}
finally
{
popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
}
|
protected void destroyService() throws Exception {
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
pushENC();
try
{
// Destroy container invoker
for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();)
{
String invokerBinding = (String) it.next();
EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding);
ci.destroy();
ci.setContainer(null);
try
{
ObjectName containerName = super.getJmxName();
Hashtable props = containerName.getKeyPropertyList();
props.put("plugin", "invoker");
props.put("binding", invokerBinding);
ObjectName invokerName = new ObjectName(containerName.getDomain(), props);
server.unregisterMBean(invokerName);
}
catch(Throwable ignore)
{
}
}
// Destroy the pool
instancePool.destroy();
instancePool.setContainer(null);
try
{
ObjectName containerName = super.getJmxName();
Hashtable props = containerName.getKeyPropertyList();
props.put("plugin", "pool");
ObjectName poolName = new ObjectName(containerName.getDomain(), props);
server.unregisterMBean(poolName);
}
catch(Throwable ignore)
{
}
// Destroy all the interceptors in the chain
Interceptor in = interceptor;
while (in != null)
{
in.destroy();
in.setContainer(null);
in = in.getNext();
}
// Call default destroy
super.destroyService();
}
finally
{
popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
}
|
public EJBMetaData getEJBMetaDataHome() throws RemoteException {
// TODO
//return null;
throw new Error("getEJBMetaDataHome not valid for MessageDriven beans");
}
|
public Class getHomeClass() {
//throw new Error("HomeClass not valid for MessageDriven beans");
return null;
}
EJBProxyFactoryContainer - not needed, should we skip inherit this
or just throw Error?? |
public HomeHandle getHomeHandleHome() throws RemoteException {
// TODO
//return null;
throw new Error("getHomeHandleHome not valid for MessageDriven beans");
}
|
public InstancePool getInstancePool() {
return instancePool;
}
|
public Interceptor getInterceptor() {
return interceptor;
}
|
public Class getLocalClass() {
return null;
}
|
public Class getLocalHomeClass() {
//throw new Error("LocalHomeClass not valid for MessageDriven beans");
return null;
}
|
public LocalProxyFactory getLocalProxyFactory() {
return localProxyFactory;
}
|
public long getMessageCount() {
return messageCount;
}
|
public Class getRemoteClass() {
//throw new Error("RemoteClass not valid for MessageDriven beans");
return null;
}
|
public Object internalInvoke(Invocation mi) throws Exception {
// Invoke through interceptors
return getInterceptor().invoke(mi);
}
This method does invocation interpositioning of tx and security,
retrieves the instance from an object table, and invokes the method
on the particular instance |
public Object internalInvokeHome(Invocation mi) throws Exception {
throw new Error("invokeHome not valid for MessageDriven beans");
}
|
public void removeHome(Handle handle) throws RemoteException, RemoveException {
throw new Error("removeHome not valid for MessageDriven beans");
// TODO
}
|
public void removeHome(Object primaryKey) throws RemoteException, RemoveException {
throw new Error("removeHome not valid for MessageDriven beans");
// TODO
}
|
public void setInstancePool(InstancePool instancePool) {
if (instancePool == null)
throw new NullArgumentException("instancePool");
this.instancePool = instancePool;
this.instancePool.setContainer(this);
}
|
protected void startService() throws Exception {
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
pushENC();
try
{
// Call default start
super.startService();
// Start the instance pool
instancePool.start();
// Start all interceptors in the chain
Interceptor in = interceptor;
while (in != null)
{
in.start();
in = in.getNext();
}
// Start container invoker
for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();)
{
String invokerBinding = (String) it.next();
EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding);
ci.start();
}
// Restore persisted ejb timers
restoreTimers();
}
finally
{
popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
}
|
protected void stopService() throws Exception {
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
pushENC();
try
{
// Call default stop
super.stopService();
// Stop container invoker
for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();)
{
String invokerBinding = (String) it.next();
EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding);
ci.stop();
}
// Stop the instance pool
instancePool.stop();
// Stop all interceptors in the chain
Interceptor in = interceptor;
while (in != null)
{
in.stop();
in = in.getNext();
}
}
finally
{
popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
}
|