KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > wsmgmt > config > impl > WebServiceConfigImpl


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.admin.wsmgmt.config.impl;
24
25 import com.sun.enterprise.admin.wsmgmt.config.spi.WebServiceConfig;
26 import com.sun.enterprise.config.serverbeans.WebServiceEndpoint;
27 import com.sun.enterprise.admin.wsmgmt.config.spi.TransformationRule;
28 import com.sun.enterprise.admin.wsmgmt.config.spi.RegistryLocation;
29 import com.sun.enterprise.admin.wsmgmt.config.spi.Constants;
30
31 import java.util.StringTokenizer JavaDoc;
32 import java.util.List JavaDoc;
33 import java.util.ArrayList JavaDoc;
34
35 /**
36  * This represents management configuration for a web service end point.
37  */

38 public class WebServiceConfigImpl implements WebServiceConfig {
39
40     public WebServiceConfigImpl( String JavaDoc n, String JavaDoc level, int size, boolean
41         jbi ) {
42         name = n;
43         monitoringLevel = level;
44         maxHistorySize = size;
45         jbiEnabled = jbi;
46     }
47
48     public WebServiceConfigImpl(WebServiceEndpoint wsEp ) {
49
50         if (wsEp == null) {
51             return;
52         }
53
54         name = wsEp.getName();
55         monitoringLevel = wsEp.getMonitoring();
56         maxHistorySize = Integer.parseInt(wsEp.getMaxHistorySize());
57         jbiEnabled = wsEp.isJbiEnabled();
58         tRules = wsEp.getTransformationRule();
59     }
60
61     /**
62      * Returns the name of the web service endpoint
63      *
64      * @return the name of the web service endpoint
65      */

66     public String JavaDoc getName() {
67         return name;
68     }
69
70     /**
71      * Returns the relative name of the web service endpoint
72      *
73      * @return the relative name of the web service endpoint
74      */

75     public String JavaDoc getEndpointName() {
76         StringTokenizer JavaDoc strTok = new StringTokenizer JavaDoc(name, "#");
77         String JavaDoc relId = null;
78         while (strTok.hasMoreElements()) {
79             relId = (String JavaDoc) strTok.nextElement();
80         }
81         return relId;
82     }
83
84     /**
85      * Returns the monitoring level OFF, LOW or HIGH
86      *
87      * @return the monitoring level OFF, LOW or HIGH
88      */

89     public String JavaDoc getMonitoringLevel() {
90         return monitoringLevel;
91     }
92
93     /**
94      * Returns the max history size (size of stored monitoring stats)
95      *
96      * @return the max history size (size of stored monitoring stats)
97      */

98     public int getMaxHistorySize() {
99         return maxHistorySize;
100     }
101
102     /**
103      * Returns true, if this web service endpoint JBI enabled
104      *
105      * @return true, if this web service endpoint JBI enabled
106      */

107     public boolean getJbiEnabled() {
108         return jbiEnabled;
109     }
110     
111     /**
112      * Returns the transformation rules defined for this endpoint
113      *
114      * @return the transformation rules defined for this endpoint
115      */

116     public TransformationRule[] getTransformationRule() {
117         if ( tRules != null) {
118             TransformationRule[] transformRules = new
119                         TransformationRuleImpl[tRules.length];
120             for (int index =0; index < tRules.length; index++) {
121                transformRules[index]= new TransformationRuleImpl(tRules[index]);
122             }
123             return transformRules;
124         } else {
125             return null;
126         }
127     }
128
129     /**
130      * Returns the transformation rules defined for this endpoint
131      * during request phase
132      *
133      * @return the transformation rules defined for this endpoint
134      */

135     public TransformationRule[] getRequestTransformationRule() {
136         if ( tRules != null) {
137             List JavaDoc tList = new ArrayList JavaDoc();
138             for (int index =0; index < tRules.length; index++) {
139                 String JavaDoc phase = tRules[index].getApplyTo();
140                 if ( (phase.equals(Constants.REQUEST) ) ||
141                         (phase.equals(Constants.BOTH)) ) {
142                    if ( tRules[index].isEnabled() == true) {
143                        tList.add(new TransformationRuleImpl(tRules[index]));
144                    }
145                }
146             }
147             if ( tList.size() > 0 ) {
148                 TransformationRule[] transformRules = new
149                         TransformationRuleImpl[tList.size()];
150                 return (TransformationRule[]) tList.toArray(transformRules);
151             } else {
152                 return null;
153             }
154         } else {
155             return null;
156         }
157     }
158
159     /**
160      * Returns the transformation rules defined for this endpoint
161      * during response phase
162      *
163      * @return the transformation rules defined for this endpoint
164      */

165     public TransformationRule[] getResponseTransformationRule() {
166         if ( tRules != null) {
167             List JavaDoc tList = new ArrayList JavaDoc();
168             for (int index =0; index < tRules.length; index++) {
169                 String JavaDoc phase = tRules[index].getApplyTo();
170                 if ( (phase.equals(Constants.RESPONSE) ) ||
171                         (phase.equals(Constants.BOTH)) ) {
172                    if ( tRules[index].isEnabled() == true) {
173                        tList.add(new TransformationRuleImpl(tRules[index]));
174                    }
175                }
176             }
177             if ( tList.size() > 0 ) {
178                 TransformationRule[] transformRules = new
179                         TransformationRuleImpl[tList.size()];
180                 return (TransformationRule[]) tList.toArray(transformRules);
181             } else {
182                 return null;
183             }
184         } else {
185             return null;
186         }
187     }
188
189     /**
190      * Returns the registries where the web service end point artifacts are
191      * published.
192      *
193      * @return the registries where the web service end point artifacts are
194      * published.
195      */

196     public RegistryLocation[] getRegistryLocation() {
197         return null;
198     }
199
200     // PRIVATE VARS
201
String JavaDoc name = null;
202     String JavaDoc monitoringLevel = null;
203     boolean jbiEnabled = false;
204     int maxHistorySize = 0;
205     com.sun.enterprise.config.serverbeans.TransformationRule[] tRules = null;
206 }
207
Popular Tags