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.protocol;
030:
031: import javax.ejb.EJBHome;
032: import java.rmi.RemoteException;
033:
034: /**
035: * Implementation for a home handle.
036: */
037: public class HomeHandleImpl extends AbstractHomeHandle {
038: protected String serverId;
039: protected transient EJBHome home;
040:
041: /**
042: * Null arg constructor for serialization.
043: */
044: public HomeHandleImpl() {
045: }
046:
047: /**
048: * Creates a new HomeHandle.
049: *
050: * @param url the url for the bean
051: */
052: public HomeHandleImpl(String url) {
053: if (url.endsWith("/"))
054: url = url.substring(url.length() - 1);
055:
056: this .serverId = url;
057: }
058:
059: /**
060: * Creates a new HomeHandle.
061: *
062: * @param url the url for the bean
063: */
064: public HomeHandleImpl(EJBHome home, String url) {
065: this (url);
066:
067: this .home = home;
068: }
069:
070: public EJBHome getEJBHome() throws RemoteException {
071: /* XXX: webbeans
072: if (home == null)
073: home = SameJVMClientContainer.find(serverId).getEJBHome();
074: */
075:
076: return home;
077: }
078:
079: /**
080: * Return the bean's server id.
081: */
082: public String getServerId() {
083: return serverId;
084: }
085:
086: public String getURL(String protocol) {
087: return serverId;
088: }
089:
090: /**
091: * Returns the hash code for the container.
092: */
093: public int hashCode() {
094: return serverId.hashCode();
095: }
096:
097: /**
098: * Returns true if the handle equals the object.
099: */
100: public boolean equals(Object o) {
101: if (o == null || !o.getClass().equals(getClass()))
102: return false;
103:
104: HomeHandleImpl handle = (HomeHandleImpl) o;
105:
106: return serverId.equals(handle.serverId);
107: }
108: }
|