User: user57  
  Date: 01/07/12 20:39:02

  Modified:    src/main/org/jboss/ejb MessageDrivenEnterpriseContext.java
  Log:
  cleaned up
  
  Revision  Changes    Path
  1.7       +79 -76    jboss/src/main/org/jboss/ejb/MessageDrivenEnterpriseContext.java
  
  Index: MessageDrivenEnterpriseContext.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/MessageDrivenEnterpriseContext.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MessageDrivenEnterpriseContext.java       2001/06/21 05:14:31     1.6
  +++ MessageDrivenEnterpriseContext.java       2001/07/13 03:39:02     1.7
  @@ -8,15 +8,11 @@
   
   import java.lang.reflect.Method;
   import java.lang.reflect.InvocationTargetException;
  -import java.lang.IllegalStateException;
   
   import java.security.Principal;
   
   import java.rmi.RemoteException;
  -import java.rmi.ServerException;
   
  -import javax.transaction.UserTransaction;
  -
   import javax.ejb.EJBContext;
   import javax.ejb.EJBHome;
   import javax.ejb.EJBObject;
  @@ -32,13 +28,11 @@
   /**
    * Context for message driven beans, based on Stateless.
    * FIXME - not yet verified agains spec!!!
  - *   <description> 
    *      
  - *   @see <related>
  - *   @author <a href="mailto:[EMAIL PROTECTED]";>Peter Antman</a>.
  - *   @author <a href="mailto:[EMAIL PROTECTED]";>Rickard Öberg</a>
  - *  @author <a href="[EMAIL PROTECTED]">Sebastien Alborini</a>
  - *   @version $Revision: 1.6 $
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Antman</a>.
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Rickard Öberg</a>
  + * @author <a href="[EMAIL PROTECTED]">Sebastien Alborini</a>
  + * @version $Revision: 1.7 $
    */
   public class MessageDrivenEnterpriseContext
      extends EnterpriseContext
  @@ -46,74 +40,83 @@
      // Constants -----------------------------------------------------
       
      // Attributes ----------------------------------------------------
  -    //EJBObject ejbObject;
  +
  +   //EJBObject ejbObject;
      MessageDrivenContext ctx;
      
      // Static --------------------------------------------------------
      
      // Constructors --------------------------------------------------
  +   
      public MessageDrivenEnterpriseContext(Object instance, Container con)
         throws Exception
      {
         super(instance, con);
         ctx = new MessageDrivenContextImpl();
          
  -       ((MessageDrivenBean)instance).setMessageDrivenContext(ctx);
  +      ((MessageDrivenBean)instance).setMessageDrivenContext(ctx);
         
         try
         {
  -         Method ejbCreate = instance.getClass().getMethod("ejbCreate", new 
Class[0]);
  +         Method ejbCreate = instance.getClass().getMethod("ejbCreate",
  +                                                          new Class[0]);
            ejbCreate.invoke(instance, new Object[0]);
         } catch (InvocationTargetException e) 
         {
  -          Throwable ex = e.getTargetException();
  -          if (ex instanceof EJBException)
  -             throw (Exception)ex;
  -          else if (ex instanceof RuntimeException)
  -             throw new EJBException((Exception)ex); // Transform runtime exception 
into what a bean *should* have thrown
  -          else if (ex instanceof Exception)
  -             throw (Exception)ex;
  -          else
  -             throw (Error)ex;
  +         Throwable ex = e.getTargetException();
  +         if (ex instanceof EJBException)
  +            throw (Exception)ex;
  +         else if (ex instanceof RuntimeException)
  +            // Transform runtime exception into what a bean *should*
  +            // have thrown
  +            throw new EJBException((Exception)ex); 
  +         else if (ex instanceof Exception)
  +            throw (Exception)ex;
  +         else
  +            throw (Error)ex;
         }
      }
      
      // Public --------------------------------------------------------
  -    // FIXME
  -    // Here we have some problems. If we are to use the Stateless stuff,
  -    // should we inherit from StatelessSessionEnterpriseContext or what?
  -
  -    public void setEJBObject(EJBObject eo) { 
  -      throw new Error("Not applicatable for MessageDrivenContext");
  -     //NOOP
  -     //ejbObject = eo; 
  -    }
  +
  +   // FIXME
  +   // Here we have some problems. If we are to use the Stateless stuff,
  +   // should we inherit from StatelessSessionEnterpriseContext or what?
  +
  +   public void setEJBObject(EJBObject eo) { 
  +      throw new Error("Not applicatable for MessageDrivenContext");
  +      //NOOP
  +      //ejbObject = eo; 
  +   }
  +   
      public EJBObject getEJBObject() { 
  -       throw new Error("Not applicatable for MessageDrivenContext");
  -       //return ejbObject; 
  +      throw new Error("Not applicatable for MessageDrivenContext");
  +      //return ejbObject; 
      }
  -    // This is used at least in The pool, created there even!!!
  -    // and in interceptors, ugh
  +   
  +   // This is used at least in The pool, created there even!!!
  +   // and in interceptors, ugh
      public SessionContext getSessionContext() {
  -       throw new Error("Not applicatable for MessageDrivenContext");
  -       //return ctx;
  +      throw new Error("Not applicatable for MessageDrivenContext");
  +      //return ctx;
      }
   
  -    public MessageDrivenContext getMessageDrivenContext() {
  -     
  -     return ctx;
  -    }
  +   public MessageDrivenContext getMessageDrivenContext() {
  +      return ctx;
  +   }
       
      // EnterpriseContext overrides -----------------------------------
  -   public void discard()
  -      throws RemoteException
  +   
  +   public void discard() throws RemoteException
      {
         ((MessageDrivenBean)instance).ejbRemove();
      }
  +   
      public EJBContext getEJBContext()
      {
  -       return ctx;
  +      return ctx;
      }
  +   
      // Package protected ---------------------------------------------
       
      // Protected -----------------------------------------------------
  @@ -121,50 +124,50 @@
      // Private -------------------------------------------------------
   
      // Inner classes -------------------------------------------------
  +   
      protected class MessageDrivenContextImpl
         extends EJBContextImpl
         implements MessageDrivenContext
      {
  -             public EJBHome getEJBHome() 
  +      public EJBHome getEJBHome() 
         { 
  -       Logger.log("MessageDriven bean is not allowed to call getEJBHome");
  -       throw new IllegalStateException("Not valid for MessageDriven beans");
  +         Logger.log("MessageDriven bean is not allowed to call getEJBHome");
  +         throw new IllegalStateException("Not valid for MessageDriven beans");
         }
   
  -       public boolean isCallerInRole(String id) 
  -       { 
  -        Logger.log("MessageDriven bean is not allowed to call isCallerInRole");
  -       throw new IllegalStateException("Not valid for MessageDriven beans");
  -       }
  +      public boolean isCallerInRole(String id) 
  +      { 
  +         Logger.log("MessageDriven bean is not allowed to call isCallerInRole");
  +         throw new IllegalStateException("Not valid for MessageDriven beans");
  +      }
   
   
  -       public Principal getCallerPrincipal() 
  -       { 
  -        Logger.log("MessageDriven bean is not allowed to call 
getCallerPrincipal()");
  -       throw new IllegalStateException("Not valid for MessageDriven beans");
  -       }
  +      public Principal getCallerPrincipal() 
  +      { 
  +         Logger.log("MessageDriven bean is not allowed to call 
getCallerPrincipal()");
  +         throw new IllegalStateException("Not valid for MessageDriven beans");
  +      }
   
  -       public boolean getRollbackOnly() 
  +      public boolean getRollbackOnly() 
         { 
  -       if (((MessageDrivenMetaData)con.getBeanMetaData()).getAcknowledgeMode() != 
MessageDrivenMetaData.CLIENT_ACKNOWLEDGE_MODE) {
  -           // NO transaction
  -           Logger.log("MessageDriven bean is not allowed to call getRollbackOnly 
with this transaction settings");
  -       throw new IllegalStateException("MessageDriven bean is not allowed to call 
getRollbackOnly with this transaction settings");
  -       } else {
  -           return super.getRollbackOnly();
  -       }
  +         if (((MessageDrivenMetaData)con.getBeanMetaData()).getAcknowledgeMode() != 
MessageDrivenMetaData.CLIENT_ACKNOWLEDGE_MODE) {
  +            // NO transaction
  +            Logger.log("MessageDriven bean is not allowed to call getRollbackOnly 
with this transaction settings");
  +            throw new IllegalStateException("MessageDriven bean is not allowed to 
call getRollbackOnly with this transaction settings");
  +         } else {
  +            return super.getRollbackOnly();
  +         }
         }
          
  -       public void setRollbackOnly() 
  -       { 
  -        if (((MessageDrivenMetaData)con.getBeanMetaData()).getAcknowledgeMode() != 
MessageDrivenMetaData.CLIENT_ACKNOWLEDGE_MODE) {
  -            // NO transaction
  -            Logger.log("MessageDriven bean is not allowed to call setRollbackOnly 
with this transaction settings");
  -            throw new IllegalStateException("MessageDriven bean is not allowed to 
call setRollbackOnly with this transaction settings");
  -        }else {
  -           super.setRollbackOnly();
  -           
  -        }
  -       }
  +      public void setRollbackOnly() 
  +      { 
  +         if (((MessageDrivenMetaData)con.getBeanMetaData()).getAcknowledgeMode() != 
MessageDrivenMetaData.CLIENT_ACKNOWLEDGE_MODE) {
  +            // NO transaction
  +            Logger.log("MessageDriven bean is not allowed to call setRollbackOnly 
with this transaction settings");
  +            throw new IllegalStateException("MessageDriven bean is not allowed to 
call setRollbackOnly with this transaction settings");
  +         } else {
  +            super.setRollbackOnly();
  +         }
  +      }
      }
   }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to