Source Code Cross Referenced for BeanLoader.java in  » Net » Coadunation_1.0.1 » com » rift » coad » lib » deployment » bean » 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.bean 
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:         * XMLConfigurationException.java
020:         *
021:         * BeanLoader.java
022:         *
023:         * This class is responsible for loading the coadunation beans in to memory from
024:         * the jar.
025:         */
026:
027:        package com.rift.coad.lib.deployment.bean;
028:
029:        // core java imports
030:        import java.util.Map;
031:        import java.util.HashMap;
032:        import java.util.Iterator;
033:        import java.util.List;
034:
035:        // logging import
036:        import org.apache.log4j.Logger;
037:
038:        // coad imports
039:        import com.rift.coad.lib.deployment.DeploymentLoader;
040:        import com.rift.coad.lib.deployment.BeanInfo;
041:        import com.rift.coad.lib.deployment.DeploymentThreadInfo;
042:        import com.rift.coad.lib.bean.BeanWrapper;
043:        import com.rift.coad.lib.bean.BeanThread;
044:        import com.rift.coad.lib.bean.BeanRunnable;
045:        import com.rift.coad.lib.security.ThreadsPermissionContainer;
046:        import com.rift.coad.lib.thread.CoadunationThreadGroup;
047:        import com.rift.coad.lib.thread.BasicThread;
048:
049:        /**
050:         * This class is responsible for loading the coadunation beans in to memory from
051:         * the jar file.
052:         *
053:         * @author Brett Chaldecott
054:         */
055:        public class BeanLoader extends BasicThread {
056:
057:            // the class log variable
058:            protected Logger log = Logger.getLogger(BeanLoader.class.getName());
059:
060:            // the reference to the 
061:            private DeploymentLoader deploymentLoader = null;
062:            private Map beans = null;
063:            private ThreadsPermissionContainer permissions = null;
064:            private CoadunationThreadGroup threadGroup = null;
065:            private boolean successful = true;
066:            private Exception exception = null;
067:
068:            /** 
069:             * Creates a new instance of BeanLoader.
070:             *
071:             * @param deploymentLoader The reference to the deployment loader.
072:             * @param permissions The permissions assigned to the various threads.
073:             * @param threadGroup The reference to the thread group.
074:             * @exception BeanException
075:             * @exception Exception
076:             */
077:            public BeanLoader(DeploymentLoader deploymentLoader,
078:                    ThreadsPermissionContainer permissions,
079:                    CoadunationThreadGroup threadGroup) throws BeanException,
080:                    Exception {
081:                this .deploymentLoader = deploymentLoader;
082:                this .permissions = permissions;
083:                this .threadGroup = threadGroup.createThreadGroup();
084:                beans = new HashMap();
085:            }
086:
087:            /**
088:             * This method finalizes the threads in this object.
089:             */
090:            protected void finalize() {
091:                stopThreads();
092:            }
093:
094:            /**
095:             * This method loads the beans from the deployment file.
096:             *
097:             * @exception BeanException
098:             */
099:            public void process() {
100:                try {
101:                    log.info("Load the Beans for ["
102:                            + deploymentLoader.getFile().getPath() + "]");
103:                    Map beanList = deploymentLoader.getDeploymentInfo()
104:                            .getBeans();
105:                    for (Iterator iter = beanList.keySet().iterator(); iter
106:                            .hasNext();) {
107:                        BeanInfo beanInfo = (BeanInfo) beanList
108:                                .get(iter.next());
109:                        BeanWrapper beanWrapper = new BeanWrapper(
110:                                deploymentLoader, beanInfo, permissions);
111:                        beans.put(beanInfo.getBindName(), beanWrapper);
112:                        if (beanWrapper.getSubObject() instanceof  BeanRunnable) {
113:                            BeanThread beanThread = new BeanThread(
114:                                    (BeanRunnable) beanWrapper.getSubObject());
115:                            threadGroup.addThread(beanThread, beanInfo
116:                                    .getUsername());
117:                            beanThread.start();
118:                        }
119:
120:                        // loop through the bean thread information
121:                        List threadList = beanInfo.getThreadInfoList();
122:                        for (int index = 0; index < threadList.size(); index++) {
123:                            DeploymentThreadInfo threadInfo = (DeploymentThreadInfo) threadList
124:                                    .get(index);
125:                            threadGroup.startThreads(deploymentLoader
126:                                    .getClass(threadInfo.getClassName()),
127:                                    threadInfo.getUsername(), (int) threadInfo
128:                                            .getThreadNumber());
129:                        }
130:                    }
131:                } catch (Exception ex) {
132:                    log.error("Failed to instanciate the bean : "
133:                            + ex.getMessage(), ex);
134:                    stopThreads();
135:                    successful = false;
136:                    exception = new BeanException("Failed to load the beans : "
137:                            + ex.getMessage(), ex);
138:                }
139:            }
140:
141:            /**
142:             * Terminate the processing of this object.
143:             */
144:            public void terminate() {
145:
146:            }
147:
148:            /**
149:             * This method is called to perform the unload on this bean loader object.
150:             */
151:            public void stopThreads() {
152:                try {
153:                    if (threadGroup.isTerminated() == false) {
154:                        threadGroup.terminate();
155:                    }
156:                } catch (Exception ex) {
157:                    log.error("Failed to unload the beans ["
158:                            + deploymentLoader.getFile().getPath()
159:                            + "] because : " + ex.getMessage(), ex);
160:                }
161:            }
162:
163:            /**
164:             * This method returns the loaded beans.
165:             *
166:             * @return The list of loaded beans.
167:             */
168:            public Map getBeans() {
169:                return beans;
170:            }
171:
172:            /**
173:             * This method returns true if the loading was successfull and false
174:             * otherwise.
175:             */
176:            public boolean wasSucessfull() {
177:                return successful;
178:            }
179:
180:            /**
181:             * The exception that caused the problem
182:             */
183:            public Exception getException() {
184:                return exception;
185:            }
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.