KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > vfs > ConfigPath


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.vfs;
30
31 import com.caucho.loader.EnvironmentLocal;
32
33 import java.util.Map JavaDoc;
34
35 /**
36  * ConfigPath implements remote configuration scheme.
37  */

38 public class ConfigPath extends Path {
39   private static final EnvironmentLocal<RemotePwd> _remotePath
40     = new EnvironmentLocal<RemotePwd>();
41
42   /**
43    * Creates the path (for the scheme)
44    */

45   ConfigPath()
46   {
47     super(null);
48   }
49
50   /**
51    * Sets the remote.
52    */

53   public static void setRemote(Path remotePath)
54   {
55     _remotePath.set(new RemotePwd(remotePath, Vfs.lookup()));
56   }
57
58   /**
59    * Path-specific lookup. Path implementations will override this.
60    *
61    * @param userPath the user's lookup() path.
62    * @param newAttributes the attributes for the new path.
63    * @param newPath the lookup() path
64    * @param offset offset into newPath to start lookup.
65    *
66    * @return the found path
67    */

68   protected Path schemeWalk(String JavaDoc userPath,
69                 Map JavaDoc<String JavaDoc,Object JavaDoc> newAttributes,
70                 String JavaDoc newPath, int offset)
71   {
72     throw new UnsupportedOperationException JavaDoc();
73     /*
74     Path path = Vfs.lookup();
75
76     path = path.schemeWalk(userPath, newAttributes, newPath, offset);
77
78     RemotePwd remotePwd = _remotePath.get();
79
80     if (remotePwd == null)
81       return path;
82
83     Path configPwd = remotePwd.getPwd();
84     Path remotePath = remotePwd.getRemote();
85
86     String pathName = path.getFullPath();
87     String configName = configPwd.getFullPath();
88
89     if (pathName.startsWith(configName))
90       pathName = pathName.substring(configName.length());
91
92     return remotePath.schemeWalk(userPath, newAttributes, pathName, 0);
93     */

94   }
95
96   /**
97    * Returns the scheme.
98    */

99   public String JavaDoc getScheme()
100   {
101     Path path = Vfs.lookup();
102
103     return path.getScheme();
104   }
105
106   /**
107    * Returns the path.
108    */

109   public String JavaDoc getPath()
110   {
111     Path path = Vfs.lookup();
112
113     return path.getPath();
114   }
115
116   static class RemotePwd {
117     Path _remote;
118     Path _pwd;
119
120     RemotePwd(Path remote, Path pwd)
121     {
122       _remote = remote;
123       _pwd = pwd;
124     }
125
126     Path getRemote()
127     {
128       return _remote;
129     }
130
131     Path getPwd()
132     {
133       return _pwd;
134     }
135   }
136 }
137
Popular Tags