001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.naming;
019:
020: import javax.naming.Context;
021: import javax.naming.Reference;
022: import javax.naming.StringRefAddr;
023:
024: /**
025: * Represents a reference address to an EJB.
026: *
027: * @author Remy Maucherat
028: * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
029: */
030:
031: public class EjbRef extends Reference {
032:
033: // -------------------------------------------------------------- Constants
034:
035: /**
036: * Default factory for this reference.
037: */
038: public static final String DEFAULT_FACTORY = org.apache.naming.factory.Constants.DEFAULT_EJB_FACTORY;
039:
040: /**
041: * EJB type address type.
042: */
043: public static final String TYPE = "type";
044:
045: /**
046: * Remote interface classname address type.
047: */
048: public static final String REMOTE = "remote";
049:
050: /**
051: * Link address type.
052: */
053: public static final String LINK = "link";
054:
055: // ----------------------------------------------------------- Constructors
056:
057: /**
058: * EJB Reference.
059: *
060: * @param ejbType EJB type
061: * @param home Home interface classname
062: * @param remote Remote interface classname
063: * @param link EJB link
064: */
065: public EjbRef(String ejbType, String home, String remote,
066: String link) {
067: this (ejbType, home, remote, link, null, null);
068: }
069:
070: /**
071: * EJB Reference.
072: *
073: * @param ejbType EJB type
074: * @param home Home interface classname
075: * @param remote Remote interface classname
076: * @param link EJB link
077: */
078: public EjbRef(String ejbType, String home, String remote,
079: String link, String factory, String factoryLocation) {
080: super (home, factory, factoryLocation);
081: StringRefAddr refAddr = null;
082: if (ejbType != null) {
083: refAddr = new StringRefAddr(TYPE, ejbType);
084: add(refAddr);
085: }
086: if (remote != null) {
087: refAddr = new StringRefAddr(REMOTE, remote);
088: add(refAddr);
089: }
090: if (link != null) {
091: refAddr = new StringRefAddr(LINK, link);
092: add(refAddr);
093: }
094: }
095:
096: // ----------------------------------------------------- Instance Variables
097:
098: // -------------------------------------------------------- RefAddr Methods
099:
100: // ------------------------------------------------------ Reference Methods
101:
102: /**
103: * Retrieves the class name of the factory of the object to which this
104: * reference refers.
105: */
106: public String getFactoryClassName() {
107: String factory = super .getFactoryClassName();
108: if (factory != null) {
109: return factory;
110: } else {
111: factory = System.getProperty(Context.OBJECT_FACTORIES);
112: if (factory != null) {
113: return null;
114: } else {
115: return DEFAULT_FACTORY;
116: }
117: }
118: }
119:
120: // ------------------------------------------------------------- Properties
121:
122: }
|