chirino     2005/02/13 18:43:18

  Modified:    modules/core/src/java/org/openejb EJBContextImpl.java
  Log:

  MDBs do not have a proxy factory.  NPE was being thrown due to not checking
  for proxy factory being null.
  
  Revision  Changes    Path
  1.6       +29 -18    
openejb/modules/core/src/java/org/openejb/EJBContextImpl.java
  
  Index: EJBContextImpl.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/EJBContextImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- EJBContextImpl.java       5 Oct 2004 07:04:00 -0000       1.5
  +++ EJBContextImpl.java       13 Feb 2005 23:43:18 -0000      1.6
  @@ -147,35 +147,43 @@
   
       public abstract static class EJBContextState {
           public EJBHome getEJBHome(EJBInstanceContext context) {
  -            EJBHome home = context.getProxyFactory().getEJBHome();
  -            if (home == null) {
  -                throw new IllegalStateException("getEJBHome is not allowed 
if no home interface is defined");
  +            if( context.getProxyFactory() !=null ) {
  +                EJBHome home = context.getProxyFactory().getEJBHome();
  +                if (home != null) {
  +                    return home;
  +                }
               }
  -            return home;
  +            throw new IllegalStateException("getEJBHome is not allowed if no 
home interface is defined");
           }
   
           public EJBLocalHome getEJBLocalHome(EJBInstanceContext context) {
  -            EJBLocalHome localHome = 
context.getProxyFactory().getEJBLocalHome();
  -            if (localHome == null) {
  -                throw new IllegalStateException("getEJBLocalHome is not 
allowed if no local localHome interface is defined");
  +            if( context.getProxyFactory() !=null ) {
  +                EJBLocalHome localHome = 
context.getProxyFactory().getEJBLocalHome();
  +                if (localHome != null) {
  +                    return localHome;
  +                }
               }
  -            return localHome;
  +            throw new IllegalStateException("getEJBLocalHome is not allowed 
if no local localHome interface is defined");
           }
   
           public EJBObject getEJBObject(EJBInstanceContext context) {
  -            EJBObject remote = 
context.getProxyFactory().getEJBObject(context.getId());
  -            if (remote == null) {
  -                throw new IllegalStateException("getEJBObject is not allowed 
if no remote interface is defined");
  +            if( context.getProxyFactory() !=null ) {
  +                EJBObject remote = 
context.getProxyFactory().getEJBObject(context.getId());
  +                if (remote != null) {
  +                    return remote;
  +                }
               }
  -            return remote;
  +            throw new IllegalStateException("getEJBObject is not allowed if 
no remote interface is defined");
           }
   
           public EJBLocalObject getEJBLocalObject(EJBInstanceContext context) {
  -            EJBLocalObject local = 
context.getProxyFactory().getEJBLocalObject(context.getId());
  -            if (local == null) {
  -                throw new IllegalStateException("getEJBLocalObject is not 
allowed if no local interface is defined");
  +            if( context.getProxyFactory() !=null ) {
  +                EJBLocalObject local = 
context.getProxyFactory().getEJBLocalObject(context.getId());
  +                if (local != null) {
  +                    return local;
  +                }
               }
  -            return local;
  +            throw new IllegalStateException("getEJBLocalObject is not 
allowed if no local interface is defined");
           }
   
           public Principal getCallerPrincipal() {
  @@ -183,7 +191,10 @@
           }
   
           public boolean isCallerInRole(String s, EJBInstanceContext context) {
  -            return 
ContextManager.isCallerInRole(context.getProxyFactory().getEJBName(), s);
  +            if( context.getProxyFactory() !=null ) {
  +                return 
ContextManager.isCallerInRole(context.getProxyFactory().getEJBName(), s);
  +            }
  +            throw new IllegalStateException("isCallerInRole is not allowed 
if no local or remote interface is defined");
           }
   
           public UserTransaction getUserTransaction(UserTransaction 
userTransaction) {
  
  
  

Reply via email to