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