Lines 64-69
Link Here
|
64 |
|
64 |
|
65 |
private static final Logger LOG = Logger.getLogger(WebModuleProviderImpl.class.getName()); |
65 |
private static final Logger LOG = Logger.getLogger(WebModuleProviderImpl.class.getName()); |
66 |
private static final Map<Project,Map<FileObject, WebModule>> webModules = new WeakHashMap<Project,Map<FileObject, WebModule>>(); |
66 |
private static final Map<Project,Map<FileObject, WebModule>> webModules = new WeakHashMap<Project,Map<FileObject, WebModule>>(); |
|
|
67 |
private static final Map<Project, WebModule> webModulesWithoutDocRoot = new WeakHashMap<Project, WebModule>(); |
67 |
|
68 |
|
68 |
private Project p; |
69 |
private Project p; |
69 |
private String root; |
70 |
private String root; |
Lines 81-110
Link Here
|
81 |
assert p.equals(FileOwnerQuery.getOwner(file)); |
82 |
assert p.equals(FileOwnerQuery.getOwner(file)); |
82 |
|
83 |
|
83 |
String docBaseFolders = Cache.get(root + WebCacheConstants.DOCROOT); |
84 |
String docBaseFolders = Cache.get(root + WebCacheConstants.DOCROOT); |
84 |
if (docBaseFolders == null) { |
|
|
85 |
return null; |
86 |
} |
87 |
FileObject docRoot = null; |
85 |
FileObject docRoot = null; |
88 |
for (String piece : docBaseFolders.split("[:;]")) { |
86 |
if (docBaseFolders != null) { |
89 |
FileObject aRoot = FileUtil.toFileObject(new File(piece)); |
87 |
for (String piece : docBaseFolders.split("[:;]")) { |
90 |
if (aRoot != null && (FileUtil.isParentOf(aRoot, file) || aRoot == file)) { |
88 |
FileObject aRoot = FileUtil.toFileObject(new File(piece)); |
91 |
docRoot = aRoot; |
89 |
if (aRoot != null && (FileUtil.isParentOf(aRoot, file) || aRoot == file)) { |
92 |
break; |
90 |
docRoot = aRoot; |
|
|
91 |
break; |
92 |
} |
93 |
} |
93 |
} |
94 |
} |
94 |
} |
95 |
if (docRoot == null) { |
95 |
if (docRoot == null) { |
96 |
LOG.log(Level.FINE, "Found no docroot for {0} in {1}", new Object[] {file, p.getProjectDirectory()}); |
96 |
LOG.log(Level.FINE, "Found no docroot for {0} in {1}", new Object[] {file, p.getProjectDirectory()}); |
97 |
return null; |
|
|
98 |
} |
97 |
} |
99 |
Map<FileObject, WebModule> projectWebModules = webModules.get(p); |
98 |
Map<FileObject, WebModule> projectWebModules = webModules.get(p); |
100 |
if (projectWebModules == null) { |
99 |
if (projectWebModules == null) { |
101 |
projectWebModules = new HashMap<FileObject, WebModule>(); |
100 |
projectWebModules = new HashMap<FileObject, WebModule>(); |
102 |
webModules.put(p, projectWebModules); |
101 |
webModules.put(p, projectWebModules); |
103 |
} |
102 |
} |
104 |
WebModule wm = projectWebModules.get(docRoot); |
103 |
WebModule wm = docRoot != null ? projectWebModules.get(docRoot) : webModulesWithoutDocRoot.get(p); |
105 |
if (wm == null) { |
104 |
if (wm == null) { |
106 |
wm = WebModuleFactory.createWebModule(new WebModuleImpl(docRoot, root, cpp, this)); |
105 |
wm = WebModuleFactory.createWebModule(new WebModuleImpl(docRoot, root, cpp, this)); |
107 |
projectWebModules.put(docRoot, wm); |
106 |
if (docRoot != null) { |
|
|
107 |
projectWebModules.put(docRoot, wm); |
108 |
} else { |
109 |
webModulesWithoutDocRoot.put(p, wm); |
110 |
} |
108 |
} |
111 |
} |
109 |
return wm; |
112 |
return wm; |
110 |
} |
113 |
} |
Lines 113-132
Link Here
|
113 |
public J2eeModule getJ2eeModule() { |
116 |
public J2eeModule getJ2eeModule() { |
114 |
if (j2eeModule == null) { |
117 |
if (j2eeModule == null) { |
115 |
String docBaseFolders = Cache.get(root + WebCacheConstants.DOCROOT); |
118 |
String docBaseFolders = Cache.get(root + WebCacheConstants.DOCROOT); |
116 |
if (docBaseFolders == null) { |
|
|
117 |
return null; |
118 |
} |
119 |
FileObject docRoot = null; |
119 |
FileObject docRoot = null; |
120 |
for (String piece : docBaseFolders.split("[:;]")) { |
120 |
if (docBaseFolders != null) { |
121 |
FileObject aRoot = FileUtil.toFileObject(new File(piece)); |
121 |
for (String piece : docBaseFolders.split("[:;]")) { |
122 |
if (aRoot != null) { |
122 |
FileObject aRoot = FileUtil.toFileObject(new File(piece)); |
123 |
docRoot = aRoot; |
123 |
if (aRoot != null) { |
124 |
break; |
124 |
docRoot = aRoot; |
|
|
125 |
break; |
126 |
} |
125 |
} |
127 |
} |
126 |
} |
128 |
} |
127 |
if (docRoot != null) { |
129 |
j2eeModule = J2eeModuleFactory.createJ2eeModule(new WebModuleImpl(docRoot, root, cpp, this)); |
128 |
j2eeModule = J2eeModuleFactory.createJ2eeModule(new WebModuleImpl(docRoot, root, cpp, this)); |
|
|
129 |
} |
130 |
} |
130 |
} |
131 |
return j2eeModule; |
131 |
return j2eeModule; |
132 |
} |
132 |
} |