001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.ejb.hessian;
030:
031: import com.caucho.ejb.RemoteExceptionWrapper;
032:
033: import javax.ejb.EJBHome;
034: import javax.ejb.EJBObject;
035: import javax.ejb.Handle;
036: import javax.ejb.RemoveException;
037: import java.rmi.RemoteException;
038:
039: /**
040: * Base class for generated object stubs.
041: */
042: public abstract class ObjectStub extends HessianStub implements
043: EJBObject {
044: protected transient Handle _handle;
045:
046: abstract public String getHessianType();
047:
048: /**
049: * Returns the serializable handle for the remote object
050: */
051: public Handle getHandle() throws RemoteException {
052: if (_handle == null)
053: _handle = _client.createHandle(_url);
054:
055: return _handle;
056: }
057:
058: /**
059: * Returns the EJBHome stub for the remote object.
060: */
061: public EJBHome getEJBHome() throws RemoteException {
062: try {
063: return _client.getHomeStub();
064: } catch (Exception e) {
065: throw new RemoteExceptionWrapper(e);
066: }
067: }
068:
069: /**
070: * Returns true if the test object is identical to this object.
071: *
072: * @param obj the object to test for identity
073: */
074: public boolean isIdentical(EJBObject obj) throws RemoteException {
075: return getHandle().equals(obj.getHandle())
076: || _ejb_isIdentical(obj);
077: }
078:
079: /**
080: * Remove this object from the server.
081: */
082: public void remove() throws RemoteException, RemoveException {
083: _ejb_remove();
084: }
085:
086: /**
087: * For entity beans, returns the primary key
088: */
089: public Object getPrimaryKey() throws RemoteException {
090: // XXX: the primary key could be cached
091: return _ejb_getPrimaryKey();
092: }
093:
094: protected EJBHome _ejb_getEJBHome() throws RemoteException {
095: return null;
096: }
097:
098: protected boolean _ejb_isIdentical(EJBObject obj)
099: throws RemoteException {
100: return false;
101: }
102:
103: protected void _ejb_remove() throws RemoteException,
104: RemoveException {
105: }
106:
107: protected Object _ejb_getPrimaryKey() throws RemoteException {
108: return null;
109: }
110: }
|