1 /*2 * The contents of this file are subject to the terms 3 * of the Common Development and Distribution License 4 * (the License). You may not use this file except in5 * compliance with the License.6 * 7 * You can obtain a copy of the license at 8 * https://glassfish.dev.java.net/public/CDDLv1.0.html or9 * glassfish/bootstrap/legal/CDDLv1.0.txt.10 * See the License for the specific language governing 11 * permissions and limitations under the License.12 * 13 * When distributing Covered Code, include this CDDL 14 * Header Notice in each file and include the License file 15 * at glassfish/bootstrap/legal/CDDLv1.0.txt. 16 * If applicable, add the following below the CDDL Header, 17 * with the fields enclosed by brackets [] replaced by18 * you own identifying information: 19 * "Portions Copyrighted [year] [name of copyright owner]"20 * 21 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.22 */23 package com.sun.enterprise.deployment.annotation.handlers;24 25 import java.lang.annotation.Annotation ;26 import java.lang.annotation.ElementType ;27 import java.lang.reflect.AnnotatedElement ;28 import java.util.ArrayList ;29 import java.util.List ;30 31 import javax.annotation.Resource;32 import javax.annotation.Resources;33 34 import com.sun.enterprise.deployment.annotation.AnnotatedElementHandler;35 import com.sun.enterprise.deployment.annotation.AnnotationInfo;36 import com.sun.enterprise.deployment.annotation.AnnotationProcessorException;37 import com.sun.enterprise.deployment.annotation.HandlerProcessingResult;38 import com.sun.enterprise.deployment.annotation.context.ResourceContainerContext;39 import com.sun.enterprise.deployment.annotation.impl.AnnotationUtils;40 41 /**42 * This handler is responsible for handling javax.annotation.Resources43 *44 */45 public class ResourcesHandler extends ResourceHandler {46 47 public ResourcesHandler() {48 }49 50 /**51 * @return the annoation type this annotation handler is handling52 */53 public Class <? extends Annotation > getAnnotationType() {54 return Resources.class;55 }56 57 /**58 * This entry point is used both for a single @EJB and iteratively59 * from a compound @EJBs processor.60 */61 protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo,62 ResourceContainerContext[] rcContexts)63 throws AnnotationProcessorException {64 65 Resources resourcesAn = (Resources)ainfo.getAnnotation();66 67 Resource[] resourceAns = resourcesAn.value();68 List <HandlerProcessingResult> results = new ArrayList <HandlerProcessingResult>();69 70 for(Resource res : resourceAns) {71 results.add(processResource(ainfo, rcContexts, res));72 }73 74 return getOverallProcessingResult(results);75 }76 77 }78