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;
030:
031: import com.caucho.util.CharBuffer;
032:
033: import javax.ejb.EJBHome;
034: import javax.ejb.EJBMetaData;
035: import java.io.Serializable;
036:
037: public class EJBMetaDataImpl implements EJBMetaData, Serializable {
038: // ejb/0230
039: private EJBHome home;
040:
041: private Class homeInterfaceClass;
042: private Class remoteInterfaceClass;
043: private Class primaryKeyClass;
044:
045: private boolean isSession;
046: private boolean isStatelessSession;
047:
048: /**
049: * Null constructor for serialization.
050: */
051: public EJBMetaDataImpl() {
052: }
053:
054: /**
055: * Create a new meta data.
056: */
057: EJBMetaDataImpl(EJBHome home, Class homeInterfaceClass,
058: Class remoteInterfaceClass, Class primaryKeyClass) {
059: this .home = home;
060: this .homeInterfaceClass = homeInterfaceClass;
061: this .remoteInterfaceClass = remoteInterfaceClass;
062: this .primaryKeyClass = primaryKeyClass;
063: }
064:
065: public EJBHome getEJBHome() {
066: return this .home;
067: }
068:
069: public void setEJBHome(EJBHome home) {
070: this .home = home;
071: }
072:
073: public Class getHomeInterfaceClass() {
074: return this .homeInterfaceClass;
075: }
076:
077: public Class getRemoteInterfaceClass() {
078: return this .remoteInterfaceClass;
079: }
080:
081: public Class getPrimaryKeyClass() {
082: return this .primaryKeyClass;
083: }
084:
085: void setSession(boolean isSession) {
086: this .isSession = isSession;
087: }
088:
089: public boolean isSession() {
090: return this .isSession;
091: }
092:
093: void setStatelessSession(boolean isStatelessSession) {
094: this .isStatelessSession = isStatelessSession;
095: }
096:
097: public boolean isStatelessSession() {
098: return this .isStatelessSession;
099: }
100:
101: public String toString() {
102: CharBuffer cb = new CharBuffer();
103:
104: cb.append(getClass().getSimpleName());
105: cb.append("[");
106: if (isSession() && isStatelessSession())
107: cb.append("stateless-session");
108: else if (isSession())
109: cb.append("session");
110: else
111: cb.append("entity");
112:
113: if (homeInterfaceClass != null)
114: cb.append(" home:" + homeInterfaceClass.getName());
115: if (remoteInterfaceClass != null)
116: cb.append(" remote:" + remoteInterfaceClass.getName());
117: if (primaryKeyClass != null)
118: cb.append(" key:" + primaryKeyClass.getName());
119:
120: cb.append("]");
121:
122: return cb.toString();
123: }
124: }
|