KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > properties > PropertyHandler


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package test.properties;
17
18 import org.apache.axis.AxisFault;
19 import org.apache.axis.MessageContext;
20 import org.apache.axis.handlers.BasicHandler;
21
22 /**
23  * Combination of two functions for this test.
24  *
25  * 1) When invoked as a Handler, save the value of the PROP_NAME property
26  * into a field so the test can look at it later. (used to test client-
27  * side)
28  *
29  * 2) When used as a back-end service, return the value of the PROP_NAME
30  * property (used to test server-side)
31  *
32  * @author Glen Daniels (gdaniels@apache.org)
33  */

34 public class PropertyHandler extends BasicHandler {
35     private String JavaDoc propVal;
36
37     public void invoke(MessageContext msgContext) throws AxisFault {
38         // Get the "normal" property value, and save it away.
39
propVal = msgContext.getStrProp(TestScopedProperties.PROP_NAME);
40
41         // Set the "override" property directly in the MC.
42
msgContext.setProperty(TestScopedProperties.OVERRIDE_NAME,
43                                TestScopedProperties.OVERRIDE_VALUE);
44     }
45
46     public String JavaDoc getPropVal() {
47         return propVal;
48     }
49
50     public void setPropVal(String JavaDoc propVal) {
51         this.propVal = propVal;
52     }
53
54     public String JavaDoc testScopedProperty() throws Exception JavaDoc {
55         MessageContext context = MessageContext.getCurrentContext();
56         String JavaDoc propVal = context.getStrProp(TestScopedProperties.PROP_NAME);
57         return propVal;
58     }
59
60     public String JavaDoc testOverrideProperty() throws Exception JavaDoc {
61         MessageContext context = MessageContext.getCurrentContext();
62         String JavaDoc propVal = context.getStrProp(TestScopedProperties.OVERRIDE_NAME);
63         return propVal;
64     }
65 }
66
Popular Tags