package org.jfox.ejb;
import java.util.Properties;
import java.security.Identity;
import java.security.Principal;
import java.lang.reflect.Proxy;
import javax.ejb.EJBContext;
import javax.ejb.EJBHome;
import javax.ejb.EJBLocalHome;
import javax.ejb.EJBException;
import org.jfox.ejb.invoker.local.LOCALContainerInvoker;
import org.jfox.ejb.invoker.local.LOCALContainerService;
import org.huihoo.jfox.logging.Logger;
public abstract class EJBContextSupport implements EJBContext {
protected Logger logger = Logger.getLogger(getClass().getName());
protected ObjectId objectId = null;
protected BulkMetaData bulkMeta = null;
public EJBContextSupport(ObjectId objectId, BulkMetaData bulkMeta) {
this.objectId = objectId;
this.bulkMeta = bulkMeta;
}
public EJBHome getEJBHome() {
ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
String ejbHomeInterfaceName = objectId.getHomeInterfName();
try {
Class remoteInterface = ctxLoader.loadClass(ejbHomeInterfaceName);
return (EJBHome)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
new Class[]{remoteInterface},
new LOCALContainerInvoker(objectId,LOCALContainerService.getInstance()));
}
catch(Exception e){
throw new EJBException(e);
}
}
public EJBLocalHome getEJBLocalHome() {
throw new IllegalStateException("current not support local ejb");
}
public Properties getEnvironment() {
throw new EJBException("Deprecated");
}
public Identity getCallerIdentity() {
throw new EJBException("Deprecated");
}
public Principal getCallerPrincipal() {
throw new IllegalStateException("current not support security context");
}
public boolean isCallerInRole(Identity identity) {
throw new EJBException("Deprecated");
}
public boolean isCallerInRole(String string) {
throw new IllegalStateException("current not support security context");
}
}