Source Code Cross Referenced for WebServiceManager.java in  » Net » Coadunation_1.0.1 » com » rift » coad » lib » deployment » webservice » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » Coadunation_1.0.1 » com.rift.coad.lib.deployment.webservice 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * CoadunationLib: The coaduntion implementation library.
003:         * Copyright (C) 2006  Rift IT Contracting
004:         * 
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         * 
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         * 
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
018:         *
019:         * WebServiceManager.java
020:         *
021:         * The web service manager. Responsible for controlling the loading and
022:         * unloading of web services.
023:         */
024:
025:        // package paths
026:        package com.rift.coad.lib.deployment.webservice;
027:
028:        // java imports
029:        import java.util.Map;
030:        import java.util.HashMap;
031:        import java.util.Set;
032:        import java.util.Iterator;
033:
034:        // logging import
035:        import org.apache.log4j.Logger;
036:
037:        // coadunation imports
038:        import com.rift.coad.lib.deployment.DeploymentLoader;
039:
040:        /**
041:         * The web service manager. Responsible for controlling the loading and
042:         * unloading of web services.
043:         *
044:         * @author Brett Chaldecott
045:         */
046:        public class WebServiceManager {
047:
048:            /**
049:             * This class wrapps the web service list and supplies thread safe access
050:             * to the references held within.
051:             */
052:            public class WebServiceList {
053:                // classes private member variables
054:                private Map services = null;
055:
056:                /**
057:                 * The constructor of the web service list object.
058:                 */
059:                public WebServiceList() {
060:                    services = new HashMap();
061:                }
062:
063:                /**
064:                 * This method return a list of all the keys that identifying all the
065:                 * services loaded by the web service manager.
066:                 *
067:                 * @return The set containing the web service information.
068:                 */
069:                public synchronized Set getServices() {
070:                    return services.keySet();
071:                }
072:
073:                /**
074:                 * This method adds the web service to the list of services.
075:                 *
076:                 * @param path The path of the object to add.
077:                 * @param obj The object reference to add.
078:                 */
079:                public synchronized void addService(String path, Object obj) {
080:                    services.put(path, obj);
081:                }
082:
083:                /**
084:                 * This method returns the reference to the web service wrapper object.
085:                 *
086:                 * @return The reference to the object.
087:                 * @param The path to retrieve.
088:                 */
089:                public synchronized Object getService(String path) {
090:                    return services.get(path);
091:                }
092:
093:                /**
094:                 * This method removes the service from the list of services.
095:                 *
096:                 * @param path The path to remove.
097:                 */
098:                public synchronized void removeService(String path) {
099:                    services.remove(path);
100:                }
101:
102:                /**
103:                 * This method return TRUE if the object is found FALSE if not.
104:                 *
105:                 * @param path The path to this object.
106:                 */
107:                public synchronized boolean contains(String path) {
108:                    return services.containsKey(path);
109:                }
110:            }
111:
112:            // the class log variable
113:            protected Logger log = Logger.getLogger(WebServiceManager.class
114:                    .getName());
115:
116:            // the private member variables
117:            private Map loaders = null;
118:            private WebServiceList serviceList = null;
119:
120:            /** 
121:             * Creates a new instance of WebServiceManager.
122:             */
123:            public WebServiceManager() {
124:                loaders = new HashMap();
125:                serviceList = new WebServiceList();
126:            }
127:
128:            /**
129:             * This method will load the specified web service using the deployment
130:             * loader.
131:             *
132:             * @param loader The reference to the loader object.
133:             * @exception WebServiceException
134:             */
135:            public void load(DeploymentLoader loader)
136:                    throws WebServiceException {
137:                if (loaders.containsKey(loader)) {
138:                    throw new WebServiceException(
139:                            "This entries has been loaded before.");
140:                }
141:                // load the web service using the a new web service loader
142:                WebServiceLoader serviceLoader = new WebServiceLoader(loader);
143:                Map services = serviceLoader.getServices();
144:                serviceClash(services);
145:
146:                // add the services to the service list
147:                for (Iterator iter = services.keySet().iterator(); iter
148:                        .hasNext();) {
149:                    String path = (String) iter.next();
150:                    log.info("Load the web service [" + path + "]");
151:                    serviceList.addService(path, services.get(path));
152:                }
153:
154:                // add the entry to the loaders list
155:                loaders.put(loader, serviceLoader);
156:
157:            }
158:
159:            /**
160:             * This method unloads the web services from the this object.
161:             *
162:             * @param loader The reference to the loader responsible for accessing this
163:             *          object.
164:             * @exception WebServiceException
165:             */
166:            public void unLoad(DeploymentLoader loader)
167:                    throws WebServiceException {
168:                if (false == loaders.containsKey(loader)) {
169:                    // do nothing there is nothing known about this entry
170:                    return;
171:                }
172:
173:                // retrieve a reference to the web service loader
174:                WebServiceLoader serviceLoader = (WebServiceLoader) loaders
175:                        .get(loader);
176:
177:                // remove the services
178:                Map services = serviceLoader.getServices();
179:                for (Iterator iter = services.keySet().iterator(); iter
180:                        .hasNext();) {
181:                    String path = (String) iter.next();
182:                    log.info("Un-load the web service [" + path + "]");
183:                    serviceList.removeService(path);
184:                }
185:
186:                // remove the loader
187:                loaders.remove(loader);
188:            }
189:
190:            /**
191:             * Retrieve the list of web servies.
192:             *
193:             * @return The list of web services managed by this object.
194:             */
195:            public Set getServices() {
196:                return serviceList.getServices();
197:            }
198:
199:            /**
200:             * This method retrieve the service identified by the path
201:             *
202:             * @return The service identified by the path.
203:             * @param path The path identifying the path.
204:             */
205:            public Object getService(String path) {
206:                return serviceList.getService(path);
207:            }
208:
209:            /**
210:             * This method checks to see if there is a clash with one of the classes
211:             * web services.
212:             *
213:             * @param services The list of services to make the check on.
214:             * @exception WebServiceException
215:             */
216:            private void serviceClash(Map services) throws WebServiceException {
217:                Set keySet = services.keySet();
218:                for (Iterator iter = keySet.iterator(); iter.hasNext();) {
219:                    String path = (String) iter.next();
220:                    if (serviceList.contains(path)) {
221:                        throw new WebServiceException(
222:                                "The service with the path [" + path
223:                                        + "] is already bound");
224:                    }
225:                }
226:            }
227:
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.