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.session;
030:
031: import com.caucho.ejb.AbstractEJBObject;
032: import com.caucho.ejb.AbstractServer;
033: import com.caucho.ejb.protocol.ObjectSkeletonWrapper;
034:
035: import javax.ejb.Handle;
036: import javax.ejb.SessionBean;
037: import java.io.ObjectStreamException;
038: import java.io.Serializable;
039:
040: /**
041: * Abstract base class for a 3.0 session object
042: */
043: abstract public class AbstractSessionObject extends AbstractEJBObject
044: implements Serializable {
045: // ejb/0ff0
046: protected Class _businessInterface;
047:
048: public SessionBean _getObject() {
049: throw new UnsupportedOperationException(
050: "_getObject is not implemented");
051: }
052:
053: /**
054: * Returns the server.
055: */
056: abstract public AbstractServer getServer();
057:
058: /**
059: * Returns the handle.
060: */
061: public Handle getHandle() {
062: return getServer().getHandleEncoder().createHandle(
063: __caucho_getId());
064: }
065:
066: public Object getPrimaryKey() {
067: throw new UnsupportedOperationException();
068: }
069:
070: /**
071: * Returns the server.
072: */
073: public AbstractServer __caucho_getServer() {
074: return getServer();
075: }
076:
077: /**
078: * The home id is null.
079: */
080: public String __caucho_getId() {
081: return getServer().encodeId(getPrimaryKey());
082: }
083:
084: /**
085: * Returns the business interface.
086: */
087: public Class __caucho_getBusinessInterface() {
088: return _businessInterface;
089: }
090:
091: /**
092: * Sets the business interface.
093: */
094: public void __caucho_setBusinessInterface(Class businessInterface) {
095: _businessInterface = businessInterface;
096: }
097:
098: /**
099: * Serialize the HomeSkeletonWrapper in place of this object.
100: *
101: * @return the matching skeleton wrapper.
102: */
103: public Object writeReplace() throws ObjectStreamException {
104: return new ObjectSkeletonWrapper(getHandle());
105: }
106: }
|