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: JAnnotationResource.java 2067 2007-11-27 10:03:12Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.deployment.annotations.impl;
025:
026: import javax.annotation.Resource.AuthenticationType;
027:
028: import org.ow2.easybeans.deployment.api.IJAnnotationResource;
029:
030: /**
031: * Acts as an implementation of @{@link javax.annotation.Resource} annotation.
032: * @author Florent Benoit
033: */
034: public class JAnnotationResource implements IJAnnotationResource {
035:
036: /**
037: * Name.
038: */
039: private String name = null;
040:
041: /**
042: * Type (class).
043: */
044: private String type = null;
045:
046: /**
047: * Authentication type.
048: */
049: private AuthenticationType authenticationType = null;
050:
051: /**
052: * Shareable (true/false).
053: */
054: private boolean shareable;
055:
056: /**
057: * Description.
058: */
059: private String description = null;
060:
061: /**
062: * mapped name.
063: */
064: private String mappedName = null;
065:
066: /**
067: * Constructor.<br>
068: * Build object with default values.
069: */
070: public JAnnotationResource() {
071: // set default values
072: this .name = "";
073: this .type = "java/lang/Object";
074: this .authenticationType = AuthenticationType.CONTAINER;
075: shareable = true;
076: description = "";
077: }
078:
079: /**
080: * @return Name (resource to be looked up).
081: */
082: public String getName() {
083: return name;
084: }
085:
086: /**
087: * Sets Name (resource to be looked up).
088: * @param name the given name.
089: */
090: public void setName(final String name) {
091: this .name = name;
092: }
093:
094: /**
095: * @return the authentication type.
096: */
097: public AuthenticationType getAuthenticationType() {
098: return authenticationType;
099: }
100:
101: /**
102: * Sets the authentication type.
103: * @param authenticationType value to set.
104: */
105: public void setAuthenticationType(
106: final AuthenticationType authenticationType) {
107: this .authenticationType = authenticationType;
108: }
109:
110: /**
111: * @return the description.
112: */
113: public String getDescription() {
114: return description;
115: }
116:
117: /**
118: * Sets the description.
119: * @param description value to set.
120: */
121: public void setDescription(final String description) {
122: this .description = description;
123: }
124:
125: /**
126: * @return true if it is shareable.
127: */
128: public boolean isShareable() {
129: return shareable;
130: }
131:
132: /**
133: * Sets the shareable attribute (false/true).
134: * @param shareable a boolean.
135: */
136: public void setShareable(final boolean shareable) {
137: this .shareable = shareable;
138: }
139:
140: /**
141: * @return the type of resource (class).
142: */
143: public String getType() {
144: return type;
145: }
146:
147: /**
148: * Sets the class type of this object.
149: * @param type the class value (as string format).
150: */
151: public void setType(final String type) {
152: this .type = type;
153: }
154:
155: /**
156: * @return MappedName.
157: */
158: public String getMappedName() {
159: return mappedName;
160: }
161:
162: /**
163: * Sets mapped Name.
164: * @param mappedName the given mappedName.
165: */
166: public void setMappedName(final String mappedName) {
167: this .mappedName = mappedName;
168: }
169:
170: /**
171: * @return string representation
172: */
173: @Override
174: public String toString() {
175: StringBuilder sb = new StringBuilder();
176: // classname
177: sb.append(this .getClass().getName().substring(
178: this .getClass().getPackage().getName().length() + 1));
179:
180: // name
181: sb.append("[name=");
182: sb.append(name);
183:
184: // type
185: sb.append(", type=");
186: sb.append(type);
187:
188: // Authentication type
189: sb.append(", authenticationType=");
190: sb.append(authenticationType);
191:
192: // Shareable
193: sb.append(", shareable=");
194: sb.append(shareable);
195:
196: // Description
197: sb.append(", description=");
198: sb.append(description);
199:
200: // MappedName
201: sb.append(", mappedName=");
202: sb.append(mappedName);
203:
204: sb.append("]");
205: return sb.toString();
206: }
207:
208: }
|