JEntityRemote.java

00001 
00026 package org.objectweb.jonas_ejb.container;
00027 
00028 import java.rmi.Remote;
00029 import java.rmi.RemoteException;
00030 
00031 import javax.ejb.EJBException;
00032 import javax.ejb.EJBHome;
00033 import javax.ejb.EJBObject;
00034 
00035 import org.objectweb.carol.rmi.exception.RmiUtility;
00036 
00037 import org.objectweb.jonas_ejb.lib.EJBInvocation;
00038 
00039 import org.objectweb.util.monolog.api.BasicLevel;
00040 
00046 public abstract class JEntityRemote extends JRemote implements Remote {
00047 
00048     protected JEntityFactory ebf;
00049 
00050     protected JEntitySwitch bs;
00051 
00056     public JEntityRemote(JEntityFactory bf) throws RemoteException {
00057         super(bf);
00058         TraceEjb.interp.log(BasicLevel.DEBUG, "");
00059         this.ebf = bf;
00060     }
00061 
00066     public void setEntitySwitch(JEntitySwitch bs) {
00067         TraceEjb.interp.log(BasicLevel.DEBUG, "");
00068         this.bs = bs;
00069     }
00070 
00071     // --------------------------------------------------------------------------
00072     // EJBObject implementation
00073     // remove() is implemented in the generated part.
00074     // --------------------------------------------------------------------------
00075 
00079     public EJBHome getEJBHome() {
00080         TraceEjb.interp.log(BasicLevel.DEBUG, "");
00081 
00082         /*
00083          * try/catch block is commented because the encapsulated code don't
00084          * throw a RemoteException for the moment
00085          * If the code changes and throws a such exception, let's think
00086          * to uncomment it
00087          *
00088          * try {
00089          */
00090 
00091         return ebf.getHome();
00092 
00093         /*
00094          * } catch (RemoteException e) {
00095          * // check if rmi exception mapping is needed - if yes the method  rethrows it
00096          * RmiUtility.rethrowRmiException(e);
00097          * // if not, throws the exception just as it is
00098          * throw e;
00099          * }
00100          */
00101 
00102     }
00103 
00108     public Object getPrimaryKey() {
00109         TraceEjb.interp.log(BasicLevel.DEBUG, "");
00110         /*
00111          * try/catch block is commented because the encapsulated code don't
00112          * throw a RemoteException for the moment
00113          * If the code changes and throws a such exception, let's think
00114          * to uncomment it
00115          *
00116          * try {
00117          */
00118 
00119         if (bs == null) {
00120             throw new EJBException("No Primary Key yet");
00121         }
00122         return bs.getPrimaryKey();
00123 
00124         /*
00125          * } catch (RemoteException e) {
00126          * // check if rmi exception mapping is needed - if yes the method  rethrows it
00127          * RmiUtility.rethrowRmiException(e);
00128          * // if not, throws the exception just as it is
00129          * throw e;
00130          * }
00131          */
00132 
00133     }
00134 
00142     public boolean isIdentical(EJBObject obj) throws RemoteException {
00143         TraceEjb.interp.log(BasicLevel.DEBUG, "");
00144 
00145         try {
00146 
00147             boolean ret = false;
00148 
00149             if (obj != null) { // Get the home class name
00150                 String homeClassName = getEJBHome().getEJBMetaData().getHomeInterfaceClass().getName();
00151                 String objHomeClassName = obj.getEJBHome().getEJBMetaData().getHomeInterfaceClass().getName();
00152 
00153                 // Tests the home equality and the primary key equality
00154                 ret = ((obj.equals(this)) || ((objHomeClassName.equals(homeClassName)) && (obj.getPrimaryKey()
00155                         .equals(getPrimaryKey()))));
00156             }
00157 
00158             return ret;
00159 
00160         } catch (RemoteException e) {
00161          // check if rmi exception mapping is needed - if yes the method rethrows it
00162          RmiUtility.rethrowRmiException(e);
00163          // if not, throws the exception just as it is
00164          throw e;
00165          }
00166 
00167     }
00168 
00169     // ---------------------------------------------------------------
00170     // other public methods, for internal use.
00171     // ---------------------------------------------------------------
00172 
00179     public RequestCtx preInvoke(int txa) throws RemoteException {
00180         TraceEjb.interp.log(BasicLevel.DEBUG, "");
00181         return bf.preInvokeRemote(txa);
00182     }
00183 
00189      public void checkSecurity(EJBInvocation ejbInv) {
00190          TraceEjb.interp.log(BasicLevel.DEBUG, "");
00191          bf.checkSecurity(ejbInv);
00192      }
00193 
00199     public void postInvoke(RequestCtx rctx) throws RemoteException {
00200         TraceEjb.interp.log(BasicLevel.DEBUG, "");
00201         try {
00202             bf.postInvokeRemote(rctx);
00203         } finally {
00204             if (rctx.sysExc != null) {
00205                 bs.discardICtx(rctx.currTx);
00206             } else {
00207                 bs.releaseICtx(rctx.currTx);
00208             }
00209         }
00210     }
00211 
00212 }

Generated on Tue Feb 15 15:05:37 2005 for JOnAS by  doxygen 1.3.9.1