Source Code Cross Referenced for ServiceManager.java in  » Mail-Clients » columba-1.4 » org » columba » core » scripting » service » 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 » Mail Clients » columba 1.4 » org.columba.core.scripting.service 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // The contents of this file are subject to the Mozilla Public License Version
002:        // 1.1
003:        //(the "License"); you may not use this file except in compliance with the
004:        //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005:        //
006:        //Software distributed under the License is distributed on an "AS IS" basis,
007:        //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008:        //for the specific language governing rights and
009:        //limitations under the License.
010:        //
011:        //The Original Code is "The Columba Project"
012:        //
013:        //The Initial Developers of the Original Code are Frederik Dietz and Timo
014:        // Stich.
015:        //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016:        //
017:        //All Rights Reserved.
018:        package org.columba.core.scripting.service;
019:
020:        import java.util.Enumeration;
021:        import java.util.logging.Level;
022:        import java.util.logging.Logger;
023:
024:        import org.columba.api.plugin.IExtensionHandler;
025:        import org.columba.api.plugin.IExtensionHandlerKeys;
026:        import org.columba.api.plugin.IExtensionInterface;
027:        import org.columba.api.plugin.PluginException;
028:        import org.columba.api.plugin.PluginHandlerNotFoundException;
029:        import org.columba.core.logging.Logging;
030:        import org.columba.core.plugin.Extension;
031:        import org.columba.core.plugin.PluginManager;
032:        import org.columba.core.scripting.service.api.IColumbaService;
033:
034:        public class ServiceManager {
035:
036:            private static final Logger LOG = Logger
037:                    .getLogger("org.columba.core.scripting.service.ServiceManager");
038:
039:            private static ServiceManager instance = new ServiceManager();
040:
041:            private IExtensionHandler handler;
042:
043:            private ServiceManager() {
044:                try {
045:                    handler = PluginManager.getInstance().getExtensionHandler(
046:                            IExtensionHandlerKeys.ORG_COLUMBA_CORE_SERVICE);
047:                } catch (PluginHandlerNotFoundException e) {
048:                    e.printStackTrace();
049:                }
050:            }
051:
052:            public static ServiceManager getInstance() {
053:                return instance;
054:            }
055:
056:            /**
057:             * Retrieve service instance. <code>ExtensionHandler</code> automatically
058:             * handles singleton extensions. We don't need to cache instances.
059:             * 
060:             * @param extension
061:             *            extension metadata
062:             * @return instance of extension interface
063:             */
064:            private IColumbaService getServiceInstance(Extension extension) {
065:
066:                IExtensionInterface service = null;
067:                try {
068:                    service = (IExtensionInterface) extension
069:                            .instanciateExtension(new Object[] {});
070:                } catch (PluginException e1) {
071:                    LOG.severe("Failed to load service: " + e1.getMessage());
072:
073:                    if (Logging.DEBUG)
074:                        e1.printStackTrace();
075:
076:                    return null;
077:                }
078:
079:                if (!(service instanceof  IColumbaService)) {
080:                    LOG
081:                            .log(
082:                                    Level.WARNING,
083:                                    "Service plugin doesn't explicitly declare an "
084:                                            + "IColumbaService interface. Service ignored...");
085:                    return null;
086:                }
087:
088:                return (IColumbaService) service;
089:
090:            }
091:
092:            /**
093:             * Instanciate all services.
094:             * 
095:             */
096:            public void initServices() {
097:                Enumeration e = handler.getExtensionEnumeration();
098:                while (e.hasMoreElements()) {
099:                    Extension extension = (Extension) e.nextElement();
100:
101:                    // retrieving the instance for the first time
102:                    // creates an instance in ExtensionHandler subclass
103:                    // 
104:                    // instance reference is kept in hashmap automatically
105:                    IColumbaService service = getServiceInstance(extension);
106:                    service.initService();
107:
108:                }
109:
110:            }
111:
112:            public void disposeServices() {
113:                Enumeration e = handler.getExtensionEnumeration();
114:                while (e.hasMoreElements()) {
115:                    Extension extension = (Extension) e.nextElement();
116:                    IColumbaService service = getServiceInstance(extension);
117:                    service.disposeService();
118:                }
119:            }
120:
121:            public void startServices() {
122:                Enumeration e = handler.getExtensionEnumeration();
123:                while (e.hasMoreElements()) {
124:                    Extension extension = (Extension) e.nextElement();
125:                    IColumbaService service = getServiceInstance(extension);
126:                    service.startService();
127:                }
128:
129:            }
130:
131:            public void stopServices() {
132:                Enumeration e = handler.getExtensionEnumeration();
133:                while (e.hasMoreElements()) {
134:                    Extension extension = (Extension) e.nextElement();
135:                    IColumbaService service = getServiceInstance(extension);
136:                    service.stopService();
137:                }
138:            }
139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.