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.connector.deployment;
019    
020    import java.lang.reflect.Field;
021    import java.lang.reflect.Method;
022    import java.util.HashMap;
023    import java.util.List;
024    import java.util.Map;
025    
026    import javax.annotation.Resource;
027    import javax.naming.Reference;
028    import javax.xml.namespace.QName;
029    
030    import org.apache.commons.logging.Log;
031    import org.apache.commons.logging.LogFactory;
032    import org.apache.geronimo.common.DeploymentException;
033    import org.apache.geronimo.common.UnresolvedReferenceException;
034    import org.apache.geronimo.gbean.AbstractNameQuery;
035    import org.apache.geronimo.gbean.GBeanInfo;
036    import org.apache.geronimo.gbean.GBeanInfoBuilder;
037    import org.apache.geronimo.j2ee.deployment.EARContext;
038    import org.apache.geronimo.j2ee.deployment.Module;
039    import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedApp;
040    import org.apache.geronimo.j2ee.deployment.annotation.ResourceAnnotationHelper;
041    import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
042    import org.apache.geronimo.kernel.GBeanNotFoundException;
043    import org.apache.geronimo.kernel.config.Configuration;
044    import org.apache.geronimo.kernel.repository.Environment;
045    import org.apache.geronimo.naming.deployment.AbstractNamingBuilder;
046    import org.apache.geronimo.naming.reference.ResourceReferenceFactory;
047    import org.apache.geronimo.naming.reference.UserTransactionReference;
048    import org.apache.geronimo.xbeans.geronimo.naming.GerMessageDestinationDocument;
049    import org.apache.geronimo.xbeans.geronimo.naming.GerMessageDestinationType;
050    import org.apache.geronimo.xbeans.geronimo.naming.GerPatternType;
051    import org.apache.geronimo.xbeans.geronimo.naming.GerResourceEnvRefDocument;
052    import org.apache.geronimo.xbeans.geronimo.naming.GerResourceEnvRefType;
053    import org.apache.geronimo.xbeans.javaee.DescriptionType;
054    import org.apache.geronimo.xbeans.javaee.FullyQualifiedClassType;
055    import org.apache.geronimo.xbeans.javaee.InjectionTargetType;
056    import org.apache.geronimo.xbeans.javaee.JndiNameType;
057    import org.apache.geronimo.xbeans.javaee.MessageDestinationRefType;
058    import org.apache.geronimo.xbeans.javaee.MessageDestinationType;
059    import org.apache.geronimo.xbeans.javaee.MessageDestinationTypeType;
060    import org.apache.geronimo.xbeans.javaee.ResourceEnvRefType;
061    import org.apache.geronimo.xbeans.javaee.XsdStringType;
062    import org.apache.xmlbeans.QNameSet;
063    import org.apache.xmlbeans.XmlObject;
064    
065    /**
066     * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $
067     */
068    public class AdminObjectRefBuilder extends AbstractNamingBuilder {
069        private final static Log log = LogFactory.getLog(AdminObjectRefBuilder.class);
070        private final QNameSet adminOjbectRefQNameSet;
071        private final QNameSet messageDestinationQNameSet;
072        private final QNameSet messageDestinationRefQNameSet;
073    
074        private static final QName GER_ADMIN_OBJECT_REF_QNAME = GerResourceEnvRefDocument.type.getDocumentElementName();
075        private static final QNameSet GER_ADMIN_OBJECT_REF_QNAME_SET = QNameSet.singleton(GER_ADMIN_OBJECT_REF_QNAME);
076        private static final QName GER_MESSAGE_DESTINATION_QNAME = GerMessageDestinationDocument.type.getDocumentElementName();
077        private static final QNameSet GER_MESSAGE_DESTINATION_QNAME_SET = QNameSet.singleton(GER_MESSAGE_DESTINATION_QNAME);
078    
079        public AdminObjectRefBuilder(Environment defaultEnvironment, String[] eeNamespaces) {
080            super(defaultEnvironment);
081            adminOjbectRefQNameSet = buildQNameSet(eeNamespaces, "resource-env-ref");
082            messageDestinationQNameSet = buildQNameSet(eeNamespaces, "message-destination");
083            messageDestinationRefQNameSet = buildQNameSet(eeNamespaces, "message-destination-ref");
084        }
085    
086        protected boolean willMergeEnvironment(XmlObject specDD, XmlObject plan) {
087            return specDD.selectChildren(adminOjbectRefQNameSet).length > 0 || specDD.selectChildren(messageDestinationRefQNameSet).length > 0;
088        }
089    
090        public void initContext(XmlObject specDD, XmlObject plan, Module module) throws DeploymentException {
091            List<MessageDestinationType> specDestinations = convert(specDD.selectChildren(messageDestinationQNameSet), JEE_CONVERTER, MessageDestinationType.class, MessageDestinationType.type);
092            XmlObject[] gerDestinations = plan.selectChildren(GER_MESSAGE_DESTINATION_QNAME_SET);
093            Map<String, GerMessageDestinationType> nameMap = new HashMap<String, GerMessageDestinationType>();
094            for (XmlObject gerDestination : gerDestinations) {
095                GerMessageDestinationType destination = (GerMessageDestinationType) gerDestination.copy().changeType(GerMessageDestinationType.type);
096                String name = destination.getMessageDestinationName().trim();
097                nameMap.put(name, destination);
098                boolean found = false;
099                for (MessageDestinationType specDestination : specDestinations) {
100                    if (specDestination.getMessageDestinationName().getStringValue().trim().equals(name)) {
101                        found = true;
102                        break;
103                    }
104                }
105                if (!found) {
106                    throw new DeploymentException("No spec DD message-destination for " + name);
107                }
108            }
109            module.getRootEarContext().registerMessageDestionations(module.getName(), nameMap);
110        }
111    
112    
113        public void buildNaming(XmlObject specDD, XmlObject plan, Module module, Map componentContext) throws DeploymentException {
114            XmlObject[] gerResourceEnvRefsUntyped = plan == null ? NO_REFS : plan.selectChildren(GER_ADMIN_OBJECT_REF_QNAME_SET);
115            Map<String, GerResourceEnvRefType> refMap = mapResourceEnvRefs(gerResourceEnvRefsUntyped);
116            int initialGerRefSize = refMap.size();
117            Map<String, Map<String, GerMessageDestinationType>> messageDestinations = module.getRootEarContext().getMessageDestinations();
118    
119            // Discover and process any @Resource annotations (if !metadata-complete)
120            if (module.getClassFinder() != null) {
121    
122                // Process all the annotations for this naming builder type
123                try {
124                    ResourceAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder(), new AdminObjectRefProcessor(refMap, messageDestinations, module.getEarContext()));
125                }
126                catch (Exception e) {
127                    log.warn("Unable to process @Resource annotations for module" + module.getName(), e);
128                }
129            }
130    
131            List<ResourceEnvRefType> resourceEnvRefsUntyped = convert(specDD.selectChildren(adminOjbectRefQNameSet), JEE_CONVERTER, ResourceEnvRefType.class, ResourceEnvRefType.type);
132            int unresolvedRefSize = resourceEnvRefsUntyped.size();
133            ClassLoader cl = module.getEarContext().getClassLoader();
134            for (ResourceEnvRefType resourceEnvRef : resourceEnvRefsUntyped) {
135                String name = resourceEnvRef.getResourceEnvRefName().getStringValue().trim();
136                addInjections(name, resourceEnvRef.getInjectionTargetArray(), componentContext);
137                String type = resourceEnvRef.getResourceEnvRefType().getStringValue().trim();
138                Class iface;
139                try {
140                    iface = cl.loadClass(type);
141                } catch (ClassNotFoundException e) {
142                    throw new DeploymentException("could not load class " + type, e);
143                }
144                GerResourceEnvRefType gerResourceEnvRef = refMap.get(name);
145                refMap.remove(name);
146                try {
147                    String refType = getStringValue(resourceEnvRef.getResourceEnvRefType());
148                    if (refType.equals("javax.transaction.UserTransaction")) {
149                        Reference ref = new UserTransactionReference();
150                        getJndiContextMap(componentContext).put(ENV + name, ref);
151                    } else {
152                        AbstractNameQuery containerId = getAdminObjectContainerId(name, gerResourceEnvRef);
153                        ResourceReferenceFactory<RuntimeException> ref = buildAdminObjectReference(module, containerId, iface);
154                        getJndiContextMap(componentContext).put(ENV + name, ref);
155                    }
156                } catch (UnresolvedReferenceException e) {
157                    throw new DeploymentException("Unable to resolve resource env reference '" + name + "' (" + (e.isMultiple() ? "found multiple matching resources" : "no matching resources found") + ")", e);
158                }
159            }
160            
161            if (refMap.size() > 0 && ((initialGerRefSize - unresolvedRefSize) != refMap.size())) {
162                log.warn("Failed to build reference to Admin object reference "+refMap.keySet()+" defined in plan file, reason - corresponding entry in deployment descriptor missing.");
163            }
164            
165            //message-destination-refs
166            List<MessageDestinationRefType> messageDestinationRefsUntyped = convert(specDD.selectChildren(messageDestinationRefQNameSet), JEE_CONVERTER, MessageDestinationRefType.class, MessageDestinationRefType.type);
167    
168            for (MessageDestinationRefType messageDestinationRef : messageDestinationRefsUntyped) {
169                String name = getStringValue(messageDestinationRef.getMessageDestinationRefName());
170                addInjections(name, messageDestinationRef.getInjectionTargetArray(), componentContext);
171                String linkName = getStringValue(messageDestinationRef.getMessageDestinationLink());
172                //TODO figure out something better to do here!
173                if (linkName == null) {
174                    linkName = name;
175                }
176                String type = getStringValue(messageDestinationRef.getMessageDestinationType());
177                if (type == null) {
178                    //must have an injection target to determine type EE5.8.1.3
179                    InjectionTargetType[] targets = messageDestinationRef.getInjectionTargetArray();
180                    if (targets.length == 0) {
181                        throw new DeploymentException("No type for message-destination-ref can be determined from explicit specification or injection target: " + messageDestinationRef);
182                    }
183                    type = getStringValue(targets[0].getInjectionTargetClass());
184                    if (type == null) {
185                        throw new DeploymentException("no type for message destination ref in injection target: " + targets[0]);
186                    }
187                }
188                Class iface;
189                try {
190                    iface = cl.loadClass(type);
191                } catch (ClassNotFoundException e) {
192                    throw new DeploymentException("could not load class " + type, e);
193                }
194                String moduleURI = null;
195                GerMessageDestinationType destination = getMessageDestination(linkName, messageDestinations);
196                if (destination != null) {
197                    if (destination.isSetAdminObjectLink()) {
198                        if (destination.isSetAdminObjectModule()) {
199                            moduleURI = destination.getAdminObjectModule().trim();
200                        }
201                        linkName = destination.getAdminObjectLink().trim();
202                    }
203                } else {
204                    //well, we know for sure an admin object is not going to be defined in a modules that can have a message-destination
205                    int pos = linkName.indexOf('#');
206                    if (pos > -1) {
207                        //AMM -- the following line causes blowups; e.g. to look in DayTrader EJB module for a RA -- why is that?!?
208                        //moduleURI = linkName.substring(0, pos);
209                        linkName = linkName.substring(pos + 1);
210                    }
211                }
212    
213                //try to resolve ref based only matching resource-ref-name
214                //throws exception if it can't locate ref.
215                AbstractNameQuery containerId = buildAbstractNameQuery(null, moduleURI, linkName, NameFactory.JCA_ADMIN_OBJECT, NameFactory.RESOURCE_ADAPTER_MODULE);
216                ResourceReferenceFactory<RuntimeException> ref = buildAdminObjectReference(module, containerId, iface);
217                getJndiContextMap(componentContext).put(ENV + name, ref);
218    
219            }
220    
221        }
222    
223        public static GerMessageDestinationType getMessageDestination(String messageDestinationLink, Map<String, Map<String, GerMessageDestinationType>> messageDestinations) throws DeploymentException {
224            GerMessageDestinationType destination = null;
225            int pos = messageDestinationLink.indexOf('#');
226            if (pos > -1) {
227                String targetModule = messageDestinationLink.substring(0, pos);
228                Map<String, GerMessageDestinationType> destinations = messageDestinations.get(targetModule);
229                // Hmmm...if we don't find the module then something is wrong in the deployment.
230                if (destinations == null) {
231                    StringBuffer sb = new StringBuffer();
232                    for (Object o : messageDestinations.keySet()) {
233                        sb.append(o).append("\n");
234                    }
235                    throw new DeploymentException("Unknown module " + targetModule + " when processing message destination " + messageDestinationLink +
236                            "\nKnown modules in deployable unit are:\n" + sb.toString());
237                }
238                messageDestinationLink = messageDestinationLink.substring(pos + 1);
239                destination = destinations.get(messageDestinationLink);
240            } else {
241                for (Map<String, GerMessageDestinationType> destinations : messageDestinations.values()) {
242                    GerMessageDestinationType destinationTest = destinations.get(messageDestinationLink);
243                    if (destinationTest != null) {
244                        if (destination != null) {
245                            throw new DeploymentException("Duplicate message destination " + messageDestinationLink + " accessed from a message-destination-link without a module");
246                        }
247                        destination = destinationTest;
248                    }
249                }
250            }
251            return destination;
252        }
253    
254    
255        private ResourceReferenceFactory<RuntimeException> buildAdminObjectReference(Module module, AbstractNameQuery containerId, Class iface) throws DeploymentException {
256            Configuration localConfiguration = module.getEarContext().getConfiguration();
257            try {
258                localConfiguration.findGBean(containerId);
259            } catch (GBeanNotFoundException e) {
260                throw new DeploymentException("Can not resolve admin object ref " + containerId + " in configuration " + localConfiguration.getId(), e);
261            }
262            return new ResourceReferenceFactory<RuntimeException>(module.getConfigId(), containerId, iface);
263        }
264    
265        private static AbstractNameQuery getAdminObjectContainerId(String name, GerResourceEnvRefType gerResourceEnvRef) {
266            AbstractNameQuery containerId;
267            if (gerResourceEnvRef == null) {
268                containerId = buildAbstractNameQuery(null, null, name, NameFactory.JCA_ADMIN_OBJECT, NameFactory.RESOURCE_ADAPTER_MODULE);
269            } else if (gerResourceEnvRef.isSetMessageDestinationLink()) {
270                containerId = buildAbstractNameQuery(null, null, gerResourceEnvRef.getMessageDestinationLink().trim(), NameFactory.JCA_ADMIN_OBJECT, NameFactory.RESOURCE_ADAPTER_MODULE);
271            } else if (gerResourceEnvRef.isSetAdminObjectLink()) {
272                String moduleURI = null;
273                if (gerResourceEnvRef.isSetAdminObjectModule()) {
274                    moduleURI = gerResourceEnvRef.getAdminObjectModule().trim();
275                }
276                containerId = buildAbstractNameQuery(null, moduleURI, gerResourceEnvRef.getAdminObjectLink().trim(), NameFactory.JCA_ADMIN_OBJECT, NameFactory.RESOURCE_ADAPTER_MODULE);
277            } else {
278                //construct name from components
279                GerPatternType patternType = gerResourceEnvRef.getPattern();
280                containerId = buildAbstractNameQuery(patternType, NameFactory.JCA_ADMIN_OBJECT, NameFactory.RESOURCE_ADAPTER_MODULE, null);
281            }
282            return containerId;
283        }
284    
285        private static Map<String, GerResourceEnvRefType> mapResourceEnvRefs(XmlObject[] refs) {
286            Map<String, GerResourceEnvRefType> refMap = new HashMap<String, GerResourceEnvRefType>();
287            if (refs != null) {
288                for (XmlObject ref1 : refs) {
289                    GerResourceEnvRefType ref = (GerResourceEnvRefType) ref1.copy().changeType(GerResourceEnvRefType.type);
290                    refMap.put(ref.getRefName().trim(), ref);
291                }
292            }
293            return refMap;
294        }
295    
296        public QNameSet getSpecQNameSet() {
297            return adminOjbectRefQNameSet;
298        }
299    
300        public QNameSet getPlanQNameSet() {
301            return GER_ADMIN_OBJECT_REF_QNAME_SET;
302        }
303    
304        public static class AdminObjectRefProcessor extends ResourceAnnotationHelper.ResourceProcessor {
305            public static final AdminObjectRefProcessor INSTANCE = new AdminObjectRefProcessor(null, null, null);
306    
307            private final EARContext earContext;
308            private final Map<String, GerResourceEnvRefType> refMap;
309            private final Map<String, Map<String, GerMessageDestinationType>> messageDestinations;
310    
311            public AdminObjectRefProcessor(Map<String, GerResourceEnvRefType> refMap, Map<String, Map<String, GerMessageDestinationType>> messageDestinations, EARContext earContext) {
312                this.refMap = refMap;
313                this.messageDestinations = messageDestinations;
314                this.earContext = earContext;
315            }
316    
317            public boolean processResource(AnnotatedApp annotatedApp, Resource annotation, Class cls, Method method, Field field) throws DeploymentException {
318                String resourceName = getResourceName(annotation, method, field);
319                String resourceType = getResourceType(annotation, method, field);
320    
321                if (resourceType.equals("javax.ejb.SessionContext")) return true;
322                if (resourceType.equals("javax.ejb.MessageDrivenContext")) return true;
323                if (resourceType.equals("javax.ejb.EntityContext")) return true;
324                if (resourceType.equals("javax.ejb.TimerService")) return true;
325    
326                //If it already exists in xml as a message-destination-ref or resource-env-ref, we are done.
327                MessageDestinationRefType[] messageDestinationRefs = annotatedApp.getMessageDestinationRefArray();
328                for (MessageDestinationRefType messageDestinationRef : messageDestinationRefs) {
329                    if (messageDestinationRef.getMessageDestinationRefName().getStringValue().trim().equals(resourceName)) {
330                        if (method != null || field != null) {
331                            InjectionTargetType[] targets = messageDestinationRef.getInjectionTargetArray();
332                            if (!hasTarget(method, field, targets)) {
333                                configureInjectionTarget(messageDestinationRef.addNewInjectionTarget(), method, field);
334                            }
335                        }
336                        return true;
337                    }
338                }
339                ResourceEnvRefType[] ResourceEnvRefs = annotatedApp.getResourceEnvRefArray();
340                for (ResourceEnvRefType resourceEnvRefType : ResourceEnvRefs) {
341                    if (resourceEnvRefType.getResourceEnvRefName().getStringValue().trim().equals(resourceName)) {
342                        if (method != null || field != null) {
343                            InjectionTargetType[] targets = resourceEnvRefType.getInjectionTargetArray();
344                            if (!hasTarget(method, field, targets)) {
345                                configureInjectionTarget(resourceEnvRefType.addNewInjectionTarget(), method, field);
346                            }
347                        }
348                        return true;
349                    }
350                }
351    
352                //if it maps to a message-destination in the geronimo plan, it's a message-destination.
353                GerMessageDestinationType gerMessageDestinationType = null;
354                if (messageDestinations != null) {
355                    gerMessageDestinationType = getMessageDestination(resourceName, messageDestinations);
356                }
357                if (gerMessageDestinationType != null) {
358                    addMethodDestinationRef(annotatedApp, resourceName, resourceType, method, field, annotation);
359                    return true;
360                } else {
361                    //if it maps to a resource-env-ref in the geronimo plan, it's a resource-ref
362                    GerResourceEnvRefType resourceEnvRefType = null;
363                    if (refMap != null) {
364                        resourceEnvRefType = refMap.get(resourceName);
365                    }
366                    if (resourceEnvRefType != null || resourceType.equals("javax.transaction.UserTransaction")) {
367                        //mapped resource-env-ref
368                        addResourceEnvRef(annotatedApp, resourceName, resourceType, method, field, annotation);
369                        return true;
370                    } else {
371                        if (earContext != null) {
372                            // look for an JCAAdminObject gbean with the right name
373                            AbstractNameQuery containerId = buildAbstractNameQuery(null, null, resourceName,
374                                    NameFactory.JCA_ADMIN_OBJECT, NameFactory.RESOURCE_ADAPTER_MODULE);
375                            try {
376                                earContext.findGBean(containerId);
377                            } catch (GBeanNotFoundException e) {
378                                // not identifiable as an admin object ref
379                                return false;
380                            }
381                        } else {
382                            if (!("javax.jms.Queue".equals(resourceType) || "javax.jms.Topic".equals(resourceType) 
383                                    || "javax.jms.Destination".equals(resourceType))) {
384                                // not identifiable as an admin object ref
385                                return false;
386                            }
387                        }
388                        addResourceEnvRef(annotatedApp, resourceName, resourceType, method, field, annotation);
389                        return true;
390                    }
391                }
392            }
393    
394            private void addResourceEnvRef(AnnotatedApp annotatedApp, String resourceName, String resourceType, Method method, Field field, Resource annotation) {
395                ResourceEnvRefType resourceEnvRef = annotatedApp.addNewResourceEnvRef();
396    
397                //------------------------------------------------------------------------------
398                // <resource-env-ref> required elements:
399                //------------------------------------------------------------------------------
400    
401                // resource-env-ref-name
402                JndiNameType resourceEnvRefName = resourceEnvRef.addNewResourceEnvRefName();
403                resourceEnvRefName.setStringValue(resourceName);
404                resourceEnvRef.setResourceEnvRefName(resourceEnvRefName);
405    
406                if (!resourceType.equals("")) {
407                    // resource-env-ref-type
408                    FullyQualifiedClassType qualifiedClass = resourceEnvRef.addNewResourceEnvRefType();
409                    qualifiedClass.setStringValue(resourceType);
410                    resourceEnvRef.setResourceEnvRefType(qualifiedClass);
411                }
412                if (method != null || field != null) {
413                    // injectionTarget
414                    InjectionTargetType injectionTarget = resourceEnvRef.addNewInjectionTarget();
415                    configureInjectionTarget(injectionTarget, method, field);
416                }
417    
418                //------------------------------------------------------------------------------
419                // <resource-env-ref> optional elements:
420                //------------------------------------------------------------------------------
421    
422                // description
423                String descriptionAnnotation = annotation.description();
424                if (!descriptionAnnotation.equals("")) {
425                    DescriptionType description = resourceEnvRef.addNewDescription();
426                    description.setStringValue(descriptionAnnotation);
427                }
428    
429                // mappedName
430                String mappdedNameAnnotation = annotation.mappedName();
431                if (!mappdedNameAnnotation.equals("")) {
432                    XsdStringType mappedName = resourceEnvRef.addNewMappedName();
433                    mappedName.setStringValue(mappdedNameAnnotation);
434                    resourceEnvRef.setMappedName(mappedName);
435                }
436            }
437    
438            private void addMethodDestinationRef(AnnotatedApp annotatedApp, String resourceName, String resourceType, Method method, Field field, Resource annotation) {
439                MessageDestinationRefType messageDestinationRef = annotatedApp.addNewMessageDestinationRef();
440    
441                //------------------------------------------------------------------------------
442                // <message-destination-ref> required elements:
443                //------------------------------------------------------------------------------
444    
445                // message-destination-ref-name
446                JndiNameType messageDestinationRefName = messageDestinationRef.addNewMessageDestinationRefName();
447                messageDestinationRefName.setStringValue(resourceName);
448                messageDestinationRef.setMessageDestinationRefName(messageDestinationRefName);
449    
450                if (!resourceType.equals("")) {
451                    // message-destination-ref-type
452                    MessageDestinationTypeType msgDestType = messageDestinationRef.addNewMessageDestinationType();
453                    msgDestType.setStringValue(resourceType);
454                    messageDestinationRef.setMessageDestinationType(msgDestType);
455                }
456                if (method != null || field != null) {
457                    // injectionTarget
458                    InjectionTargetType injectionTarget = messageDestinationRef.addNewInjectionTarget();
459                    configureInjectionTarget(injectionTarget, method, field);
460                }
461    
462                //------------------------------------------------------------------------------
463                // <message-destination-ref> optional elements:
464                //------------------------------------------------------------------------------
465    
466                // description
467                String descriptionAnnotation = annotation.description();
468                if (!descriptionAnnotation.equals("")) {
469                    DescriptionType description = messageDestinationRef.addNewDescription();
470                    description.setStringValue(descriptionAnnotation);
471                }
472    
473                // mappedName
474                String mappdedNameAnnotation = annotation.mappedName();
475                if (!mappdedNameAnnotation.equals("")) {
476                    XsdStringType mappedName = messageDestinationRef.addNewMappedName();
477                    mappedName.setStringValue(mappdedNameAnnotation);
478                    messageDestinationRef.setMappedName(mappedName);
479                }
480            }
481        }
482    
483        public static final GBeanInfo GBEAN_INFO;
484    
485        static {
486            GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(AdminObjectRefBuilder.class, NameFactory.MODULE_BUILDER);
487            infoBuilder.addAttribute("eeNamespaces", String[].class, true, true);
488            infoBuilder.addAttribute("defaultEnvironment", Environment.class, true, true);
489    
490            infoBuilder.setConstructor(new String[]{"defaultEnvironment", "eeNamespaces"});
491    
492            GBEAN_INFO = infoBuilder.getBeanInfo();
493        }
494    
495        public static GBeanInfo getGBeanInfo
496                () {
497            return GBEAN_INFO;
498        }
499    
500    }