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