Skip to content

Commit

Permalink
Added SessionBeanComponent.invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfc committed Apr 1, 2011
1 parent 3ee7bd2 commit ae0e8e5
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 10 deletions.
Expand Up @@ -21,32 +21,33 @@
*/
package org.jboss.as.ejb3.component.session;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Set;
import java.util.concurrent.Executor;
import org.jboss.as.ee.component.ComponentView;
import org.jboss.as.ejb3.component.AsyncFutureInterceptor;
import org.jboss.as.ejb3.component.AsyncVoidInterceptor;
import org.jboss.as.ee.component.ComponentView;
import org.jboss.as.ejb3.component.EJBComponent;
import org.jboss.as.threads.ThreadsServices;
import org.jboss.ejb3.context.CurrentInvocationContext;
import org.jboss.ejb3.context.base.BaseSessionContext;
import org.jboss.ejb3.context.base.BaseSessionInvocationContext;
import org.jboss.ejb3.context.spi.SessionContext;
import org.jboss.invocation.Interceptor;
import org.jboss.invocation.InterceptorContext;
import org.jboss.msc.service.ServiceName;

import javax.ejb.AccessTimeout;
import javax.ejb.EJBLocalObject;
import javax.ejb.EJBObject;
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;

import static java.util.concurrent.TimeUnit.MINUTES;
import org.jboss.invocation.InterceptorContext;
import org.jboss.msc.service.ServiceName;

/**
* @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
Expand Down Expand Up @@ -168,6 +169,8 @@ protected boolean isAsynchronous(final Method method) {
return false;
}

public abstract Object invoke(Serializable sessionId, Map<String,Object> contextData, Class<?> invokedBusinessInterface, Method implMethod, Object[] args) throws Exception;

protected Object invokeAsynchronous(final Method method, final InterceptorContext context) throws Exception {
if (Void.TYPE.isAssignableFrom(method.getReturnType())) {
return new AsyncVoidInterceptor(getAsynchronousExecutor()).processInvocation(context);
Expand Down
Expand Up @@ -197,5 +197,17 @@ private synchronized void destroySingletonInstance() {
}
}


@Override
public Object invoke(Serializable sessionId, Map<String, Object> contextData, Class<?> invokedBusinessInterface, Method beanMethod, Object[] args) throws Exception {
if (sessionId != null)
throw new IllegalArgumentException("Singleton " + this + " does not support sessions");
if (invokedBusinessInterface != null)
throw new UnsupportedOperationException("invokedBusinessInterface != null");
InterceptorContext context = new InterceptorContext();
context.putPrivateData(Component.class, this);
context.setContextData(contextData);
context.setMethod(beanMethod);
context.setParameters(args);
return getComponentInterceptor().processInvocation(context);
}
}
Expand Up @@ -21,7 +21,6 @@
*/
package org.jboss.as.ejb3.component.stateful;

import java.lang.reflect.Method;
import org.jboss.as.ee.component.AbstractComponentInstance;
import org.jboss.as.ee.component.Component;
import org.jboss.as.ejb3.component.session.SessionBeanComponent;
Expand All @@ -33,7 +32,9 @@
import org.jboss.invocation.InterceptorFactoryContext;

import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;

/**
* Stateful Session Bean
Expand Down Expand Up @@ -109,4 +110,19 @@ protected AbstractComponentInstance constructComponentInstance(Object instance,
return new StatefulSessionComponentInstance(this, instance, preDestroyInterceptors, context);
}

@Override
public Object invoke(Serializable sessionId, Map<String, Object> contextData, Class<?> invokedBusinessInterface, Method beanMethod, Object[] args) throws Exception {
if (sessionId == null)
throw new IllegalArgumentException("Session is mandatory on Stateful " + this);
if (invokedBusinessInterface != null)
throw new UnsupportedOperationException("invokedBusinessInterface != null");
InterceptorContext context = new InterceptorContext();
context.putPrivateData(Component.class, this);
// TODO: attaching as Serializable.class is a bit wicked
context.putPrivateData(Serializable.class, sessionId);
context.setContextData(contextData);
context.setMethod(beanMethod);
context.setParameters(args);
return getComponentInterceptor().processInvocation(context);
}
}
Expand Up @@ -22,7 +22,6 @@

package org.jboss.as.ejb3.component.stateless;

import java.lang.reflect.Method;
import org.jboss.as.ee.component.AbstractComponentInstance;
import org.jboss.as.ee.component.Component;
import org.jboss.as.ee.component.ComponentInstance;
Expand All @@ -36,7 +35,9 @@
import org.jboss.invocation.InterceptorFactoryContext;

import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
Expand Down Expand Up @@ -115,4 +116,18 @@ protected AbstractComponentInstance constructComponentInstance(Object instance,
public Pool<StatelessSessionComponentInstance> getPool() {
return pool;
}

@Override
public Object invoke(Serializable sessionId, Map<String, Object> contextData, Class<?> invokedBusinessInterface, Method beanMethod, Object[] args) throws Exception {
if (sessionId != null)
throw new IllegalArgumentException("Stateless " + this + " does not support sessions");
if (invokedBusinessInterface != null)
throw new UnsupportedOperationException("invokedBusinessInterface != null");
InterceptorContext context = new InterceptorContext();
context.putPrivateData(Component.class, this);
context.setContextData(contextData);
context.setMethod(beanMethod);
context.setParameters(args);
return getComponentInterceptor().processInvocation(context);
}
}

0 comments on commit ae0e8e5

Please sign in to comment.