Source Code Cross Referenced for TreeLoader.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » loader » 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 » EJB Server resin 3.1.5 » resin » com.caucho.loader 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003:         *
004:         * This file is part of Resin(R) Open Source
005:         *
006:         * Each copy or derived work must preserve the copyright notice and this
007:         * notice unmodified.
008:         *
009:         * Resin Open Source is free software; you can redistribute it and/or modify
010:         * it under the terms of the GNU General Public License as published by
011:         * the Free Software Foundation; either version 2 of the License, or
012:         * (at your option) any later version.
013:         *
014:         * Resin Open Source is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017:         * of NON-INFRINGEMENT.  See the GNU General Public License for more
018:         * details.
019:         *
020:         * You should have received a copy of the GNU General Public License
021:         * along with Resin Open Source; if not, write to the
022:         *   Free SoftwareFoundation, Inc.
023:         *   59 Temple Place, Suite 330
024:         *   Boston, MA 02111-1307  USA
025:         *
026:         * @author Scott Ferguson
027:         */
028:
029:        package com.caucho.loader;
030:
031:        import com.caucho.config.*;
032:        import com.caucho.make.DependencyContainer;
033:        import com.caucho.util.*;
034:        import com.caucho.vfs.Dependency;
035:        import com.caucho.vfs.JarPath;
036:        import com.caucho.vfs.Path;
037:
038:        import javax.annotation.PostConstruct;
039:        import java.io.IOException;
040:        import java.net.URL;
041:        import java.util.ArrayList;
042:        import java.util.HashSet;
043:        import java.util.Vector;
044:        import java.util.logging.Level;
045:        import java.util.logging.Logger;
046:
047:        /**
048:         * Class loader which checks for changes in class files and automatically
049:         * picks up new jars.
050:         */
051:        public class TreeLoader extends JarListLoader implements  Dependency {
052:            private static final L10N L = new L10N(TreeLoader.class);
053:
054:            private static final Logger log = Logger.getLogger(TreeLoader.class
055:                    .getName());
056:
057:            // Directory which may have jars dynamically added
058:            private Path _dir;
059:
060:            // When the directory was last modified
061:            private long _lastModified;
062:
063:            private String[] _fileNames;
064:
065:            private HashSet<Path> _files = new HashSet<Path>();
066:            private HashSet<Path> _tempFiles = new HashSet<Path>();
067:
068:            /**
069:             * Creates a new directory loader.
070:             */
071:            public TreeLoader() {
072:            }
073:
074:            /**
075:             * Creates a new directory loader.
076:             */
077:            public TreeLoader(Path dir) {
078:                _dir = dir;
079:
080:                init();
081:            }
082:
083:            /**
084:             * The directory loader's path.
085:             */
086:            public void setPath(Path path) {
087:                _dir = path;
088:            }
089:
090:            /**
091:             * The directory loader's path.
092:             */
093:            public Path getPath() {
094:                return _dir;
095:            }
096:
097:            /**
098:             * Create a new class loader
099:             *
100:             * @param parent parent class loader
101:             * @param dir directories which can handle dynamic jar addition
102:             */
103:            public static DynamicClassLoader create(ClassLoader parent, Path dir) {
104:                DynamicClassLoader loader = new DynamicClassLoader(parent);
105:
106:                TreeLoader treeLoader = new TreeLoader(dir);
107:
108:                loader.addLoader(treeLoader);
109:
110:                loader.init();
111:
112:                return loader;
113:            }
114:
115:            /**
116:             * Initialize
117:             */
118:            @PostConstruct
119:            @Override
120:            public void init() {
121:                super .init();
122:
123:                if (_dir == null)
124:                    throw new ConfigException(L
125:                            .l("<tree-loader> requires a 'path' attribute"));
126:
127:                _lastModified = _dir.getLastModified();
128:
129:                try {
130:                    _fileNames = _dir.list();
131:                } catch (IOException e) {
132:                }
133:
134:                fillJars();
135:            }
136:
137:            /**
138:             * True if the classes in the directory have changed.
139:             */
140:            public boolean logModified(Logger log) {
141:                if (isModified()) {
142:                    log.info(_dir.getNativePath() + " has modified jar files");
143:                    return true;
144:                } else
145:                    return false;
146:            }
147:
148:            /**
149:             * Sets the owning class loader.
150:             */
151:            public void setLoader(DynamicClassLoader loader) {
152:                super .setLoader(loader);
153:
154:                for (int i = 0; i < _jarList.size(); i++)
155:                    loader.addURL(_jarList.get(i).getJarPath());
156:            }
157:
158:            /**
159:             * Find all the jars in this directory and add them to jarList.
160:             */
161:            private void fillJars() {
162:                clearJars();
163:
164:                fillJars(_dir);
165:            }
166:
167:            /**
168:             * Find all the jars in this directory and add them to jarList.
169:             */
170:            private void fillJars(Path dir) {
171:                try {
172:                    String[] list = dir.list();
173:
174:                    for (int j = 0; list != null && j < list.length; j++) {
175:                        Path path = dir.lookup(list[j]);
176:
177:                        if (list[j].endsWith(".jar")
178:                                || list[j].endsWith(".zip")) {
179:                            addJar(path);
180:                        } else if (path.isDirectory()) {
181:                            fillJars(path);
182:                        }
183:                    }
184:
185:                } catch (IOException e) {
186:                }
187:            }
188:
189:            public Path getCodePath() {
190:                return _dir;
191:            }
192:
193:            /**
194:             * Destroys the loader, closing the jars.
195:             */
196:            protected void destroy() {
197:                clearJars();
198:            }
199:
200:            public String toString() {
201:                return "TreeLoader[" + _dir + "]";
202:            }
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.