KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > elements > MethodPermissionMethodExists


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 in
5  * 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 or
9  * 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 by
18  * 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.tools.verifier.tests.ejb.elements;
24
25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
26 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
27 import com.sun.enterprise.tools.verifier.Result;
28 import com.sun.enterprise.deployment.*;
29
30 import java.util.Collection JavaDoc;
31 import java.util.Map JavaDoc;
32
33 /**
34  * Methods used in method permission element of the deployment descriptor
35  * must be methods defined in the enterprise bean's component and/or home
36  * interface.
37  */

38 public class MethodPermissionMethodExists extends MethodsExist implements EjbCheck {
39
40     /**
41      * Methods used in method permission element of the deployment descriptor
42      * must be methods defined in the enterprise bean's remote and/or home
43      * interface.
44      *
45      * @param descriptor the Enterprise Java Bean deployment descriptor
46      * @return <code>Result</code> the results for this assertion
47      */

48     public Result check(EjbDescriptor descriptor) {
49
50         result = getInitializedResult();
51         compName = getVerifierContext().getComponentNameConstructor();
52
53         if ((descriptor instanceof EjbSessionDescriptor) ||
54                 (descriptor instanceof EjbEntityDescriptor)) {
55             Map JavaDoc<MethodPermission,
56                     Collection JavaDoc<MethodDescriptor>> permissionedMethods = descriptor.getMethodPermissionsFromDD();
57         
58             if (permissionedMethods!=null) {
59
60                 for (MethodPermission methodPermission : permissionedMethods.keySet())
61                     for (MethodDescriptor methodDescriptor : permissionedMethods.get(methodPermission))
62                         checkMethodStyles(methodDescriptor, descriptor);
63             }
64         }
65
66         if(result.getStatus() != Result.FAILED) {
67             addGoodDetails(result, compName);
68             result.passed(smh.getLocalString
69                     (getClass().getName() + ".passed",
70                     "Valid method permission method(s) found."));
71         }
72         return result;
73     }
74 }
75
76
Popular Tags