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: */package org.apache.geronimo.j2ee.deployment.annotation;
017:
018: import java.util.ArrayList;
019: import java.util.List;
020:
021: import org.apache.commons.logging.Log;
022: import org.apache.commons.logging.LogFactory;
023: import org.apache.geronimo.xbeans.javaee.ApplicationClientType;
024: import org.apache.geronimo.xbeans.javaee.EjbLocalRefType;
025: import org.apache.geronimo.xbeans.javaee.EjbRefType;
026: import org.apache.geronimo.xbeans.javaee.EnvEntryType;
027: import org.apache.geronimo.xbeans.javaee.LifecycleCallbackType;
028: import org.apache.geronimo.xbeans.javaee.MessageDestinationRefType;
029: import org.apache.geronimo.xbeans.javaee.PersistenceContextRefType;
030: import org.apache.geronimo.xbeans.javaee.PersistenceUnitRefType;
031: import org.apache.geronimo.xbeans.javaee.ResourceEnvRefType;
032: import org.apache.geronimo.xbeans.javaee.ResourceRefType;
033: import org.apache.geronimo.xbeans.javaee.ServiceRefType;
034:
035: /**
036: * Wrapper class to encapsulate the ApplicationClientType class with an interface that the various
037: * AnnotationHelpers can use
038: * <p/>
039: * <p/>
040: * <p><strong>Remaining ToDo(s):</strong>
041: * <ul>
042: * <li>Can AppClients have unresolved EJB references ??
043: * </ul>
044: *
045: * @version $Rev $Date
046: * @since Geronimo 2.0
047: */
048: public class AnnotatedApplicationClient implements AnnotatedApp {
049:
050: // Private instance variables
051: private static final Log log = LogFactory
052: .getLog(AnnotatedApplicationClient.class);
053: private final ApplicationClientType applicationClient;
054: private List<EjbRefType> ambiguousEjbRefs;
055: private final String componentType;
056:
057: /**
058: * ApplicationClientType-qualified constructor
059: *
060: * @param applicationClient ApplicationClientType
061: * @param applicationClientClassName
062: */
063: public AnnotatedApplicationClient(
064: ApplicationClientType applicationClient,
065: String applicationClientClassName) {
066: this .applicationClient = applicationClient;
067: this .componentType = applicationClientClassName;
068: }
069:
070: /**
071: * ApplicationClientType methods used for the @EJB, @EJBs annotations
072: */
073: public EjbLocalRefType[] getEjbLocalRefArray() {
074: return null; // Not supported by app clients
075: }
076:
077: public EjbLocalRefType addNewEjbLocalRef() {
078: return null; // Not supported by app clients
079: }
080:
081: public EjbRefType[] getEjbRefArray() {
082: return applicationClient.getEjbRefArray();
083: }
084:
085: public EjbRefType addNewEjbRef() {
086: return applicationClient.addNewEjbRef();
087: }
088:
089: /**
090: * ApplicationClientType methods used for the @Resource, @Resources annotations
091: */
092: public EnvEntryType[] getEnvEntryArray() {
093: return applicationClient.getEnvEntryArray();
094: }
095:
096: public EnvEntryType addNewEnvEntry() {
097: return applicationClient.addNewEnvEntry();
098: }
099:
100: public ServiceRefType[] getServiceRefArray() {
101: return applicationClient.getServiceRefArray();
102: }
103:
104: public ServiceRefType addNewServiceRef() {
105: return applicationClient.addNewServiceRef();
106: }
107:
108: public ResourceRefType[] getResourceRefArray() {
109: return applicationClient.getResourceRefArray();
110: }
111:
112: public ResourceRefType addNewResourceRef() {
113: return applicationClient.addNewResourceRef();
114: }
115:
116: public MessageDestinationRefType[] getMessageDestinationRefArray() {
117: return applicationClient.getMessageDestinationRefArray();
118: }
119:
120: public MessageDestinationRefType addNewMessageDestinationRef() {
121: return applicationClient.addNewMessageDestinationRef();
122: }
123:
124: public ResourceEnvRefType[] getResourceEnvRefArray() {
125: return applicationClient.getResourceEnvRefArray();
126: }
127:
128: public ResourceEnvRefType addNewResourceEnvRef() {
129: return applicationClient.addNewResourceEnvRef();
130: }
131:
132: /**
133: * applicationClient getter
134: *
135: * @return String representation of applicationClient
136: */
137: public String toString() {
138: return applicationClient.toString();
139: }
140:
141: /**
142: * applicationClient getter
143: *
144: * @return applicationClient ApplicationClientType
145: */
146: public ApplicationClientType getApplicationClient() {
147: return applicationClient;
148: }
149:
150: /**
151: * ambiguousRefs getter
152: * <p/>
153: * <p>There is no corresponding setter method. To add a new item to the list do:
154: * <pre>
155: * getAmbiguousEjbRefs().add(ejbRef);
156: * </pre>
157: *
158: * @return ambiguousRefs list
159: */
160: public List<EjbRefType> getAmbiguousEjbRefs() {
161: if (ambiguousEjbRefs == null) {
162: ambiguousEjbRefs = new ArrayList<EjbRefType>();
163: }
164: return this .ambiguousEjbRefs;
165: }
166:
167: public LifecycleCallbackType[] getPostConstructArray() {
168: return applicationClient.getPostConstructArray();
169: }
170:
171: public LifecycleCallbackType addPostConstruct() {
172: return applicationClient.addNewPostConstruct();
173: }
174:
175: public LifecycleCallbackType[] getPreDestroyArray() {
176: return applicationClient.getPreDestroyArray();
177: }
178:
179: public LifecycleCallbackType addPreDestroy() {
180: return applicationClient.addNewPreDestroy();
181: }
182:
183: public PersistenceContextRefType[] getPersistenceContextRefArray() {
184: return null; // Not supported by app clients
185: }
186:
187: public PersistenceContextRefType addNewPersistenceContextRef() {
188: return null; // Not supported by app clients
189: }
190:
191: public PersistenceUnitRefType[] getPersistenceUnitRefArray() {
192: return applicationClient.getPersistenceUnitRefArray();
193: }
194:
195: public PersistenceUnitRefType addNewPersistenceUnitRef() {
196: return applicationClient.addNewPersistenceUnitRef();
197: }
198:
199: public String getComponentType() {
200: return componentType;
201: }
202:
203: }
|