Source Code Cross Referenced for BaseResourceLoader.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » rice » resourceloader » 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 » ERP CRM Financial » Kuali Financial System » org.kuali.rice.resourceloader 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2006 The Kuali Foundation.
003:         *
004:         *
005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         *
009:         * http://www.opensource.org/licenses/ecl1.php
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.kuali.rice.resourceloader;
018:
019:        import javax.xml.namespace.QName;
020:
021:        import org.kuali.rice.core.Core;
022:        import org.kuali.rice.definition.ObjectDefinition;
023:        import org.kuali.rice.lifecycle.Lifecycle;
024:        import org.kuali.rice.util.ClassLoaderUtils;
025:
026:        /**
027:         * A simple ResourceLoader implementation which will load objects from the
028:         * specified classloader and also locate services in an optional ServiceLocator.
029:         *
030:         * @author Kuali Rice Team (kuali-rice@googlegroups.com)
031:         */
032:        public class BaseResourceLoader extends ResourceLoaderContainer
033:                implements  ResourceLoader {
034:
035:            static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
036:                    .getLogger(BaseResourceLoader.class);
037:
038:            private ServiceLocator serviceLocator;
039:
040:            private ClassLoader classLoader;
041:
042:            private boolean postProcessContainer = true;
043:
044:            public BaseResourceLoader(QName name, ClassLoader classLoader) {
045:                this (name, classLoader, null);
046:            }
047:
048:            public BaseResourceLoader(QName name) {
049:                this (name, ClassLoaderUtils.getDefaultClassLoader());
050:            }
051:
052:            public BaseResourceLoader(QName name, ServiceLocator serviceLocator) {
053:                this (name, ClassLoaderUtils.getDefaultClassLoader(),
054:                        serviceLocator);
055:            }
056:
057:            public BaseResourceLoader(QName name, ClassLoader classLoader,
058:                    ServiceLocator serviceLocator) {
059:                super (name);
060:                this .classLoader = classLoader;
061:                this .serviceLocator = serviceLocator;
062:            }
063:
064:            public Object getObject(ObjectDefinition objectDefinition) {
065:                // if this resource locator has no NameSpaceURI(M.E.) or the
066:                // objectDefinition has no M.E. just try to find the class here
067:                // or if the M.E. of the object is the same as the M.E. of the locator
068:                if (getName().getNamespaceURI() == null
069:                        || getName().getNamespaceURI().equals(
070:                                objectDefinition.getMessageEntity())
071:                        || objectDefinition.getMessageEntity() == null ||
072:                        // TODO did we really want to check for the KEW_MESSAGING_ENTITY here???
073:                        //(EdenConstants.KEW_MESSAGING_ENTITY.equals(objectDefinition.getMessageEntity()) && Core.getCurrentContextConfig().getRunningEmbeddedServerMode())) {
074:                        Core.getCurrentContextConfig()
075:                                .getRunningEmbeddedServerMode()) {
076:                    Object object = ObjectDefinitionResolver.createObject(
077:                            objectDefinition, this .classLoader, true);
078:                    if (object != null) {
079:                        return postProcessObject(objectDefinition, object);
080:                    }
081:                }
082:                Object super Object = super .getObject(objectDefinition);
083:                return (isPostProcessContainer() ? postProcessObject(
084:                        objectDefinition, super Object) : super Object);
085:            }
086:
087:            public Object getService(QName serviceName) {
088:                if (LOG.isDebugEnabled()) {
089:                    LOG.debug("ResourceLoader " + getName()
090:                            + " fetching service " + serviceName
091:                            + getMemStatus());
092:                }
093:                if (this .serviceLocator != null) {
094:                    if (LOG.isDebugEnabled()) {
095:                        LOG
096:                                .debug("Using internal service locator to fetch service "
097:                                        + serviceName);
098:                    }
099:                    Object service = this .serviceLocator
100:                            .getService(serviceName);
101:                    if (service != null) {
102:                        return postProcessService(serviceName, service);
103:                    }
104:                }
105:                if (LOG.isDebugEnabled()) {
106:                    LOG
107:                            .debug("ResourceLoader "
108:                                    + getName()
109:                                    + " didn't find service differing to child resource loaders ");
110:                }
111:                Object super Service = super .getService(serviceName);
112:                return (isPostProcessContainer() ? postProcessService(
113:                        serviceName, super Service) : super Service);
114:            }
115:
116:            public void start() throws Exception {
117:                if (this .classLoader instanceof  Lifecycle) {
118:                    ((Lifecycle) this .classLoader).start();
119:                }
120:                if (this .serviceLocator != null) {
121:                    LOG.info("Starting ResourceLoader " + this .getName());
122:                    this .serviceLocator.start();
123:                }
124:                super .start();
125:            }
126:
127:            public void stop() throws Exception {
128:                super .stop();
129:                if (this .serviceLocator != null) {
130:                    LOG.info("Stopping ResourceLoader " + this .getName());
131:                    this .serviceLocator.stop();
132:                }
133:                if (this .classLoader instanceof  Lifecycle) {
134:                    ((Lifecycle) this .classLoader).stop();
135:                }
136:                this .classLoader = null;
137:                this .serviceLocator = null;
138:            }
139:
140:            public ClassLoader getClassLoader() {
141:                return this .classLoader;
142:            }
143:
144:            public void setClassLoader(ClassLoader classLoader) {
145:                this .classLoader = classLoader;
146:            }
147:
148:            protected Object postProcessObject(ObjectDefinition definition,
149:                    Object object) {
150:                return object;
151:            }
152:
153:            protected Object postProcessService(QName serviceName,
154:                    Object service) {
155:                return service;
156:            }
157:
158:            public boolean isPostProcessContainer() {
159:                return postProcessContainer;
160:            }
161:
162:            public void setPostProcessContainer(boolean postProcessContainer) {
163:                this .postProcessContainer = postProcessContainer;
164:            }
165:
166:            /**
167:             * @deprecated use {@link #postProcessService(QName, Object)} instead
168:             */
169:            protected Object wrap(QName serviceName, Object service) {
170:                return postProcessService(serviceName, service);
171:            }
172:
173:            public String getContents(String indent, boolean servicePerLine) {
174:                String contents = indent + this  + "\n";
175:
176:                if (this .serviceLocator != null) {
177:                    contents += this .serviceLocator.getContents(indent + "+++",
178:                            servicePerLine);
179:                }
180:
181:                for (ResourceLoader resourceLoader : this .getResourceLoaders()) {
182:                    contents += resourceLoader.getContents(indent + "+++",
183:                            servicePerLine);
184:                }
185:
186:                return contents;
187:            }
188:
189:            private String getMemStatus() {
190:                return "\n############################################################## \n"
191:                        + "# "
192:                        + dumpMemory()
193:                        + "\n##############################################################\n";
194:            }
195:
196:            private String dumpMemory() {
197:                long total = Runtime.getRuntime().totalMemory() / 1024;
198:                long free = Runtime.getRuntime().freeMemory() / 1024;
199:                long max = Runtime.getRuntime().maxMemory() / 1024;
200:                return "[Memory] max: " + max + "K, total: " + total
201:                        + "K, free: " + free + "K, used: " + (total - free)
202:                        + "K";
203:            }
204:
205:            public ServiceLocator getServiceLocator() {
206:                return this.serviceLocator;
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.