KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > context > ConfigurationContext


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

20
21 import org.apache.axis2.description.ServiceDescription;
22 import org.apache.axis2.engine.AxisConfiguration;
23 import org.apache.axis2.engine.AxisFault;
24 import org.apache.axis2.storage.AxisStorage;
25 import org.apache.axis2.util.threadpool.ThreadPool;
26
27 import javax.xml.namespace.QName JavaDoc;
28 import java.util.HashMap JavaDoc;
29 import java.util.Map JavaDoc;
30
31 public class ConfigurationContext extends AbstractContext{
32
33     private AxisConfiguration axisConfiguration;
34     private AxisStorage storage;
35
36     private Map JavaDoc sessionContextMap;
37     private Map JavaDoc moduleContextMap;
38     private ThreadPool threadPool;
39
40     /**
41      * Map containing <code>MessageID</code> to
42      * <code>OperationContext</code> mapping.
43      */

44     private final Map JavaDoc operationContextMap = new HashMap JavaDoc();
45
46     private final Map JavaDoc serviceContextMap;
47
48     public ConfigurationContext(AxisConfiguration registry) {
49         super(null);
50         this.axisConfiguration = registry;
51         serviceContextMap = new HashMap JavaDoc();
52         moduleContextMap = new HashMap JavaDoc();
53         sessionContextMap = new HashMap JavaDoc();
54     }
55
56     /**
57      * The method is used to do the intialization of the EngineContext, right now we know that
58      * module.init(..) is called here
59      *
60      * @throws AxisFault
61      */

62
63     public void init() throws AxisFault {
64
65     }
66
67     public synchronized void removeService(QName JavaDoc name) {
68         serviceContextMap.remove(name);
69     }
70
71     /**
72      * @return
73      */

74     public AxisConfiguration getAxisConfiguration() {
75         return axisConfiguration;
76     }
77
78     /**
79      * @param configuration
80      */

81     public void setAxisConfiguration(AxisConfiguration configuration) {
82         axisConfiguration = configuration;
83     }
84
85      public synchronized void registerOperationContext(String JavaDoc messageID, OperationContext mepContext) {
86         this.operationContextMap.put(messageID, mepContext);
87     }
88
89     public OperationContext getOperationContext(String JavaDoc messageID) {
90         return (OperationContext) this.operationContextMap.get(messageID);
91     }
92
93     public Map JavaDoc getOperationContextMap() {
94         return this.operationContextMap;
95     }
96
97     public synchronized void registerServiceContext(String JavaDoc serviceInstanceID, ServiceContext serviceContext) {
98         this.serviceContextMap.put(serviceInstanceID, serviceContext);
99     }
100
101     public ServiceContext getServiceContext(String JavaDoc serviceInstanceID) {
102         return (ServiceContext) this.serviceContextMap.get(serviceInstanceID);
103     }
104
105     public AxisStorage getStorage() {
106         return storage;
107     }
108
109     public void setStorage(AxisStorage storage) {
110         this.storage = storage;
111     }
112
113     public ServiceContext createServiceContext(QName JavaDoc serviceName) throws AxisFault {
114         ServiceDescription service = axisConfiguration.getService(serviceName);
115         if(service != null){
116             ServiceContext serviceContext = new ServiceContext(service, this);
117             return serviceContext;
118         }else{
119             throw new AxisFault("Service not found service name = "+serviceName );
120         }
121     }
122
123     /**
124      * @return
125      */

126     public ThreadPool getThreadPool() {
127         if(threadPool == null){
128             threadPool = new ThreadPool();
129         }
130         return threadPool;
131     }
132
133 }
134
Popular Tags