KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > runtime > PrefetchDisabledDescriptor


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
24 package com.sun.enterprise.deployment.runtime;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.Set JavaDoc;
28 import java.util.Iterator JavaDoc;
29 import java.util.Vector JavaDoc;
30
31 import com.sun.enterprise.deployment.Descriptor;
32 import com.sun.enterprise.deployment.EjbDescriptor;
33 import com.sun.enterprise.deployment.MethodDescriptor;
34
35 public class PrefetchDisabledDescriptor extends Descriptor {
36
37     private ArrayList JavaDoc methodDescs = new ArrayList JavaDoc();
38     private ArrayList JavaDoc convertedMethodDescs = new ArrayList JavaDoc();
39     private EjbDescriptor ejbDescriptor = null;
40
41     /** Default constructor. */
42     public PrefetchDisabledDescriptor() {
43     }
44
45      /**
46       * Getter for method
47       * @return Value of MethodDescriptor list
48       */

49     public ArrayList JavaDoc getMethodDescriptors() {
50         return methodDescs;
51     }
52
53      /**
54       * Getter for converted method
55       * @return Value of style converted MethodDescriptor list
56       */

57     public ArrayList JavaDoc getConvertedMethodDescs() {
58        if (convertedMethodDescs.isEmpty()) {
59            convertStylePrefetchDisabledMethods();
60        }
61        return convertedMethodDescs;
62     }
63
64
65     /**
66       * Getter for ejbDescriptor
67       * @return Value of ejbDescriptor
68       */

69     public EjbDescriptor getEjbDescriptor() {
70         return ejbDescriptor;
71     }
72
73     /**
74      * Setter for ejbDescriptors
75      * @param ejbDescriptors New value of ejbDescriptor.
76      */

77     public void setEjbDescriptor(
78         EjbDescriptor ejbDescriptor) {
79         this.ejbDescriptor = ejbDescriptor;
80     }
81
82
83     /**
84      * Setter for method
85      * @param MethodDescriptor New value of MethodDescriptor to add.
86      */

87     public void addMethodDescriptor(MethodDescriptor methodDesc) {
88         methodDescs.add(methodDesc);
89     }
90
91     private void convertStylePrefetchDisabledMethods() {
92         Set JavaDoc allMethods = ejbDescriptor.getMethodDescriptors();
93         for (Iterator JavaDoc mdItr = methodDescs.iterator(); mdItr.hasNext();) {
94             MethodDescriptor methodDesc = (MethodDescriptor) mdItr.next();
95  
96             // the ejb-name element defined in the method element will
97
// be always ignored and overriden by the one defined in
98
// ejb element
99
methodDesc.setEjbName(ejbDescriptor.getName());
100
101             // Convert to style 3 method descriptors
102
Vector JavaDoc mds = methodDesc.doStyleConversion(ejbDescriptor, allMethods);
103             convertedMethodDescs.addAll(mds);
104         }
105     }
106
107     public boolean isPrefetchDisabledFor(MethodDescriptor methodDesc) {
108         return getConvertedMethodDescs().contains(methodDesc);
109     }
110 }
111
Popular Tags