001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: JCommonBean.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.deployment.annotations.impl;
025:
026: import java.util.ArrayList;
027: import java.util.List;
028:
029: /**
030: * Defines common methods used by Session Bean and Message Driven beans.
031: * @author Florent Benoit
032: */
033: public class JCommonBean {
034:
035: /**
036: * Name of the bean.
037: */
038: private String name = null;
039:
040: /**
041: * Default name ? (annotation)
042: */
043: private boolean defaultName = true;
044:
045: /**
046: * Mapped name (could be used as JNDI name).
047: */
048: private String mappedName = null;
049:
050: /**
051: * Description.
052: */
053: private String description = null;
054:
055: /**
056: * List of alias (for the different ejb-name).
057: * FIXME: maybe chaneg this to a different way
058: */
059: private List<String> aliases = null;
060:
061: /**
062: * Build an object that will be shared by EJB (Session + MDB).
063: */
064: public JCommonBean() {
065:
066: }
067:
068: /**
069: * @return the description.
070: */
071: public String getDescription() {
072: return description;
073: }
074:
075: /**
076: * Sets the description.
077: * @param description value of description
078: */
079: public void setDescription(final String description) {
080: this .description = description;
081: }
082:
083: /**
084: * @return the mapped name (JNDI ?)
085: */
086: public String getMappedName() {
087: return mappedName;
088: }
089:
090: /**
091: * Sets the mapped name.
092: * @param mappedName the value to set
093: */
094: public void setMappedName(final String mappedName) {
095: this .mappedName = mappedName;
096: }
097:
098: /**
099: * @return name of the bean.
100: */
101: public String getName() {
102: return name;
103: }
104:
105: /**
106: * Sets the bean name.
107: * @param name the bean's name
108: */
109: public void setName(final String name) {
110: this .name = name;
111: }
112:
113: /**
114: * @return true if the bean is the default name (set with annotation)
115: */
116: public boolean isDefaultName() {
117: return defaultName;
118: }
119:
120: /**
121: * Is that this name is a default name ?
122: * @param defaultName boolean true/false
123: */
124: public void setDefaultName(final boolean defaultName) {
125: this .defaultName = defaultName;
126: }
127:
128: /**
129: * @return a list of aliases (ejb-names)
130: */
131: public List<String> getAliases() {
132: return aliases;
133: }
134:
135: /**
136: * Adds an alias to the list of the names.
137: * @param ejbName the name of the ejb
138: */
139: public void addAlias(final String ejbName) {
140: if (aliases == null) {
141: aliases = new ArrayList<String>();
142: }
143: aliases.add(ejbName);
144: }
145:
146: /**
147: * @return string representation
148: */
149: @Override
150: public String toString() {
151: StringBuilder sb = new StringBuilder();
152: // classname
153: sb.append(this .getClass().getName().substring(
154: this .getClass().getPackage().getName().length() + 1));
155:
156: // defaultName
157: sb.append("[isDefaultName=");
158: sb.append(defaultName);
159:
160: // name
161: sb.append(",name=");
162: sb.append(name);
163:
164: // mappedName
165: sb.append(",mappedName=");
166: sb.append(mappedName);
167:
168: // description
169: sb.append(",description=");
170: sb.append(description);
171:
172: // ejb-name aliases
173: if (aliases != null && aliases.size() > 0) {
174: sb.append(",aliases=");
175: sb.append(aliases);
176: }
177:
178: sb.append("]");
179: return sb.toString();
180: }
181: }
|