KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > rift > coad > lib > deployment > webservice > WebServiceLoader


1 /*
2  * CoadunationLib: The coaduntion implementation library.
3  * Copyright (C) 2006 Rift IT Contracting
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * WebServiceLoader.java
20  *
21  * The web service loader. Responsible for loading web services from the
22  * coadunation jar files.
23  */

24
25 // package that the web service can be found in
26
package com.rift.coad.lib.deployment.webservice;
27
28 // java utils
29
import java.util.Map JavaDoc;
30 import java.util.HashMap JavaDoc;
31 import java.util.Iterator JavaDoc;
32
33 // logging import
34
import org.apache.log4j.Logger;
35
36 // coadunation imports
37
import com.rift.coad.lib.deployment.DeploymentLoader;
38 import com.rift.coad.lib.webservice.WebServiceWrapper;
39
40 /**
41  * The web service loader responsible for loading web services from the
42  * coadunation jar files.
43  *
44  * @author Brett Chaldecott
45  */

46 public class WebServiceLoader {
47     
48     // the class log variable
49
protected Logger log =
50         Logger.getLogger(WebServiceLoader.class.getName());
51     
52     // The classes private member variables
53
private Map JavaDoc services = null;
54     private DeploymentLoader deploymentLoader = null;
55     
56     /**
57      * Creates a new instance of WebServiceLoader
58      *
59      * @param deploymentLoader The reference to the deployment loader.
60      */

61     public WebServiceLoader(DeploymentLoader deploymentLoader)
62             throws WebServiceException {
63         this.deploymentLoader = deploymentLoader;
64         services = new HashMap JavaDoc();
65         loadServices();
66     }
67     
68     
69     /**
70      * This method loads the web service information retrieve from the
71      * deployment loader into web service wrappers.
72      *
73      * @exception WebServiceException
74      */

75     private void loadServices() throws WebServiceException {
76         try {
77             log.info("Load the Web Services for [" +
78                     deploymentLoader.getFile().getPath() + "]");
79             Map JavaDoc mapList = deploymentLoader.getDeploymentInfo().getWebServices();
80             for (Iterator JavaDoc iter = mapList.keySet().iterator(); iter.hasNext();) {
81                 com.rift.coad.lib.deployment.WebServiceInfo webServiceInfo =
82                         (com.rift.coad.lib.deployment.WebServiceInfo)mapList.
83                         get(iter.next());
84                 services.put(webServiceInfo.getPath(),new WebServiceWrapper(
85                         webServiceInfo,deploymentLoader));
86             }
87         } catch (Exception JavaDoc ex) {
88             throw new WebServiceException(
89                     "Failed to load the web services :" +ex.getMessage(),ex);
90         }
91     }
92     
93     
94     /**
95      * This method returns the list of web services loaded by this object.
96      *
97      * @return The list of services.
98      */

99     public Map JavaDoc getServices() {
100         return services;
101     }
102     
103 }
104
Popular Tags