Source Code Cross Referenced for AbstractFileProvider.java in  » Library » Apache-commons-vfs-20070724-src » org » apache » commons » vfs » provider » 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 » Library » Apache commons vfs 20070724 src » org.apache.commons.vfs.provider 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
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.apache.commons.vfs.provider;
018:
019:        import org.apache.commons.vfs.FileName;
020:        import org.apache.commons.vfs.FileObject;
021:        import org.apache.commons.vfs.FileSystem;
022:        import org.apache.commons.vfs.FileSystemConfigBuilder;
023:        import org.apache.commons.vfs.FileSystemException;
024:        import org.apache.commons.vfs.FileSystemOptions;
025:        import org.apache.commons.vfs.provider.local.GenericFileNameParser;
026:
027:        import java.util.Map;
028:        import java.util.TreeMap;
029:
030:        /**
031:         * A partial {@link FileProvider} implementation.  Takes care of managing the
032:         * file systems created by the provider.
033:         *
034:         * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
035:         * @version $Revision: 480428 $ $Date: 2006-11-28 22:15:24 -0800 (Tue, 28 Nov 2006) $
036:         */
037:        public abstract class AbstractFileProvider extends AbstractVfsContainer
038:                implements  FileProvider {
039:            private FileNameParser parser;
040:
041:            public AbstractFileProvider() {
042:                parser = GenericFileNameParser.getInstance();
043:            }
044:
045:            protected FileNameParser getFileNameParser() {
046:                return parser;
047:            }
048:
049:            protected void setFileNameParser(FileNameParser parser) {
050:                this .parser = parser;
051:            }
052:
053:            /**
054:             * The cached file systems.  This is a mapping from root URI to
055:             * FileSystem object.
056:             */
057:            // private final Map fileSystems = new HashMap();
058:            private final Map fileSystems = new TreeMap();
059:
060:            /**
061:             * Closes the file systems created by this provider.
062:             */
063:            public void close() {
064:                synchronized (this ) {
065:                    fileSystems.clear();
066:                }
067:
068:                super .close();
069:            }
070:
071:            /**
072:             * Creates a layered file system.  This method throws a 'not supported' exception.
073:             */
074:            public FileObject createFileSystem(final String scheme,
075:                    final FileObject file, final FileSystemOptions properties)
076:                    throws FileSystemException {
077:                // Can't create a layered file system
078:                throw new FileSystemException(
079:                        "vfs.provider/not-layered-fs.error", scheme);
080:            }
081:
082:            /**
083:             * Adds a file system to those cached by this provider.  The file system
084:             * may implement {@link VfsComponent}, in which case it is initialised.
085:             */
086:            protected void addFileSystem(final Comparable key,
087:                    final FileSystem fs) throws FileSystemException {
088:                // Add to the cache
089:                addComponent(fs);
090:
091:                FileSystemKey treeKey = new FileSystemKey(key, fs
092:                        .getFileSystemOptions());
093:                ((AbstractFileSystem) fs).setCacheKey(treeKey);
094:
095:                synchronized (this ) {
096:                    fileSystems.put(treeKey, fs);
097:                }
098:            }
099:
100:            /**
101:             * Locates a cached file system
102:             *
103:             * @return The provider, or null if it is not cached.
104:             */
105:            protected FileSystem findFileSystem(final Comparable key,
106:                    final FileSystemOptions fileSystemProps) {
107:                FileSystemKey treeKey = new FileSystemKey(key, fileSystemProps);
108:
109:                synchronized (this ) {
110:                    return (FileSystem) fileSystems.get(treeKey);
111:                }
112:            }
113:
114:            public FileSystemConfigBuilder getConfigBuilder() {
115:                return null;
116:            }
117:
118:            public void freeUnusedResources() {
119:                Object[] item;
120:                synchronized (this ) {
121:                    item = fileSystems.values().toArray();
122:                }
123:                for (int i = 0; i < item.length; ++i) {
124:                    AbstractFileSystem fs = (AbstractFileSystem) item[i];
125:                    if (fs.isReleaseable()) {
126:                        fs.closeCommunicationLink();
127:                    }
128:                }
129:            }
130:
131:            public void closeFileSystem(final FileSystem filesystem) {
132:                AbstractFileSystem fs = (AbstractFileSystem) filesystem;
133:
134:                synchronized (this ) {
135:                    if (fs.getCacheKey() != null) {
136:                        fileSystems.remove(fs.getCacheKey());
137:                    }
138:                }
139:
140:                removeComponent(fs);
141:                fs.close();
142:            }
143:
144:            /**
145:             * Parses an absolute URI.
146:             *
147:             * @param base The base file - if null the <code>uri</code> needs to be absolute
148:             * @param uri The URI to parse.
149:             */
150:            public FileName parseUri(FileName base, String uri)
151:                    throws FileSystemException {
152:                if (getFileNameParser() != null) {
153:                    return getFileNameParser()
154:                            .parseUri(getContext(), base, uri);
155:                }
156:
157:                throw new FileSystemException(
158:                        "vfs.provider/filename-parser-missing.error");
159:                // return GenericFileName.parseUri(getFileNameParser(), uri, 0);
160:            }
161:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.