]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | GlobalData class. \r | |
3 | \r | |
4 | GlobalData provide initializing, instoring, querying and update global data.\r | |
5 | It is a bridge to intercommunicate between multiple component, such as AutoGen,\r | |
6 | PCD and so on. \r | |
7 | \r | |
8 | Copyright (c) 2006, Intel Corporation\r | |
9 | All rights reserved. This program and the accompanying materials\r | |
10 | are licensed and made available under the terms and conditions of the BSD License\r | |
11 | which accompanies this distribution. The full text of the license may be found at\r | |
12 | http://opensource.org/licenses/bsd-license.php\r | |
13 | \r | |
14 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
15 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
16 | **/\r | |
17 | package org.tianocore.build.global;\r | |
18 | \r | |
19 | import java.io.File;\r | |
20 | import java.util.HashMap;\r | |
21 | import java.util.HashSet;\r | |
22 | import java.util.Iterator;\r | |
23 | import java.util.List;\r | |
24 | import java.util.Map;\r | |
25 | import java.util.Set;\r | |
26 | \r | |
27 | import org.apache.tools.ant.BuildException;\r | |
28 | import org.apache.xmlbeans.XmlObject;\r | |
29 | import org.tianocore.FrameworkDatabaseDocument;\r | |
30 | import org.tianocore.MsaFilesDocument;\r | |
31 | import org.tianocore.PackageListDocument;\r | |
32 | import org.tianocore.PackageSurfaceAreaDocument;\r | |
33 | import org.tianocore.MsaHeaderDocument.MsaHeader;\r | |
34 | import org.tianocore.MsaLibHeaderDocument.MsaLibHeader;\r | |
35 | import org.tianocore.build.pcd.entity.MemoryDatabaseManager;\r | |
36 | import org.tianocore.build.autogen.CommonDefinition;\r | |
37 | import org.tianocore.build.fpd.FpdParserTask;\r | |
38 | \r | |
39 | /**\r | |
40 | GlobalData provide initializing, instoring, querying and update global data.\r | |
41 | It is a bridge to intercommunicate between multiple component, such as AutoGen,\r | |
42 | PCD and so on. \r | |
43 | \r | |
44 | <p>Note that all global information are initialized incrementally. All data will \r | |
45 | parse and record only it is necessary during build time. </p>\r | |
46 | \r | |
47 | @since GenBuild 1.0\r | |
48 | **/\r | |
49 | public class GlobalData {\r | |
50 | \r | |
51 | ///\r | |
52 | /// means no surface area information for module\r | |
53 | ///\r | |
54 | public static final int NO_SA = 0;\r | |
55 | \r | |
56 | ///\r | |
57 | /// means only MSA\r | |
58 | ///\r | |
59 | public static final int ONLY_MSA = 1;\r | |
60 | \r | |
61 | ///\r | |
62 | /// means only Library MSA\r | |
63 | ///\r | |
64 | public static final int ONLY_LIBMSA = 2;\r | |
65 | \r | |
66 | ///\r | |
67 | /// means both MSA and MBD\r | |
68 | ///\r | |
69 | public static final int MSA_AND_MBD = 3;\r | |
70 | \r | |
71 | ///\r | |
72 | /// means both Library MSA and Library MBD\r | |
73 | ///\r | |
74 | public static final int LIBMSA_AND_LIBMBD = 4;\r | |
75 | \r | |
76 | ///\r | |
77 | /// Be used to ensure Global data will be initialized only once.\r | |
78 | ///\r | |
79 | public static boolean globalFlag = false;\r | |
80 | \r | |
81 | ///\r | |
82 | /// Record current WORKSPACE Directory\r | |
83 | ///\r | |
84 | private static String workspaceDir = "";\r | |
85 | \r | |
86 | ///\r | |
87 | /// Two columns: Package Name (Key), Package Path(ralative to WORKSPACE)\r | |
88 | ///\r | |
89 | private static final Map<String, String> packageInfo = new HashMap<String, String>();\r | |
90 | \r | |
91 | ///\r | |
92 | /// spdTable\r | |
93 | /// Key: Package Name, Value: SPD detail info\r | |
94 | ///\r | |
95 | private static final Map<String, Spd> spdTable = new HashMap<String, Spd>();\r | |
96 | \r | |
97 | ///\r | |
98 | /// Three columns:\r | |
99 | /// 1. Module Name | BaseName (Key)\r | |
100 | /// 2. Module Path + Msa file name (relative to Package)\r | |
101 | /// 3. Package Name (This module belong to which package)\r | |
102 | ///\r | |
103 | private static final Map<String, String[]> moduleInfo = new HashMap<String, String[]>();\r | |
104 | \r | |
105 | ///\r | |
106 | /// List all libraries for current build module\r | |
107 | /// Key: Library BaseName, Value: output library path+name\r | |
108 | ///\r | |
109 | private static final Map<String, String> libraries = new HashMap<String, String>();\r | |
110 | \r | |
111 | ///\r | |
112 | /// Store every module's relative library instances BaseName\r | |
113 | /// Key: Module BaseName, Value: All library instances module depends on.\r | |
114 | ///\r | |
115 | private static final Map<String, Set<String> > moduleLibraryMap = new HashMap<String, Set<String> >();\r | |
116 | \r | |
117 | ///\r | |
118 | /// Key: Module BaseName, Value: original MSA info\r | |
119 | ///\r | |
120 | private static final Map<String, Map<String, XmlObject> > nativeMsa = new HashMap<String, Map<String, XmlObject> >();\r | |
121 | \r | |
122 | ///\r | |
123 | /// Key: Module BaseName, Value: original MBD info\r | |
124 | ///\r | |
125 | private static final Map<String, Map<String, XmlObject> > nativeMbd = new HashMap<String, Map<String, XmlObject> >();\r | |
126 | \r | |
127 | ///\r | |
128 | /// Two columns: Module Name or Base Name as Key\r | |
129 | /// Value is a HashMap with overridden data from MSA/MBD or/and Platform\r | |
130 | ///\r | |
131 | private static final Map<String, Map<String, XmlObject> > parsedModules = new HashMap<String, Map<String, XmlObject> >();\r | |
132 | \r | |
133 | ///\r | |
134 | /// List all built Module; Value is Module BaseName + Arch. TBD\r | |
135 | ///\r | |
136 | private static final Set<String> builtModules = new HashSet<String>();\r | |
137 | \r | |
138 | ///\r | |
139 | /// Library instance information table which recored the library and it's\r | |
140 | /// constructor and distructor function\r | |
141 | ///\r | |
142 | private static final Map<String, String[]> libInstanceInfo = new HashMap<String, String[]>();\r | |
143 | \r | |
144 | ///\r | |
145 | /// PCD memory database stored all PCD information which collected from FPD,MSA and SPD.\r | |
146 | ///\r | |
147 | private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager();\r | |
148 | \r | |
149 | /**\r | |
150 | Query the module's absolute path with module base name. \r | |
151 | \r | |
152 | @param moduleName the base name of the module\r | |
153 | @return the absolute module path\r | |
154 | **/\r | |
155 | public synchronized static String getModulePath(String moduleName) {\r | |
156 | String[] info = moduleInfo.get(moduleName);\r | |
157 | String packagePath = (String) packageInfo.get(info[1]);\r | |
158 | File convertFile = new File(workspaceDir + File.separatorChar + packagePath + File.separatorChar + info[0]);\r | |
159 | return convertFile.getParent();\r | |
160 | }\r | |
161 | \r | |
162 | /**\r | |
163 | Query the module's absolute MSA file path with module base name. \r | |
164 | \r | |
165 | @param moduleName the base name of the module\r | |
166 | @return the absolute MSA file name\r | |
167 | @throws BuildException\r | |
168 | Base name is not registered in any SPD files\r | |
169 | **/\r | |
170 | private synchronized static String getMsaFilename(String moduleName) throws BuildException {\r | |
171 | String[] info = moduleInfo.get(moduleName);\r | |
172 | if (info == null) {\r | |
173 | throw new BuildException("Module base name [" + moduleName + "] can't found in all SPD.");\r | |
174 | }\r | |
175 | String packagePath = (String) packageInfo.get(info[1]);\r | |
176 | File convertFile = new File(workspaceDir + File.separatorChar + packagePath + File.separatorChar + info[0]);\r | |
177 | return convertFile.getPath();\r | |
178 | }\r | |
179 | \r | |
180 | /**\r | |
181 | Query the module's absolute MBD file path with module base name. \r | |
182 | \r | |
183 | @param moduleName the base name of the module\r | |
184 | @return the absolute MBD file name\r | |
185 | @throws BuildException\r | |
186 | Base name is not registered in any SPD files\r | |
187 | **/\r | |
188 | private synchronized static String getMbdFilename(String moduleName) throws BuildException {\r | |
189 | String[] info = moduleInfo.get(moduleName);\r | |
190 | if (info == null) {\r | |
191 | throw new BuildException("Info: Module base name [" + moduleName + "] can't found in all SPD.");\r | |
192 | }\r | |
193 | String packagePath = (String) packageInfo.get(info[1]);\r | |
194 | File convertFile = new File(workspaceDir + File.separatorChar + packagePath + File.separatorChar + info[0]);\r | |
195 | return convertFile.getPath().substring(0, convertFile.getPath().length() - 4) + ".mbd";\r | |
196 | }\r | |
197 | \r | |
198 | /**\r | |
199 | Get the current WORKSPACE Directory. \r | |
200 | @return current workspace directory\r | |
201 | **/\r | |
202 | public synchronized static String getWorkspacePath() {\r | |
203 | return workspaceDir;\r | |
204 | }\r | |
205 | \r | |
206 | /**\r | |
207 | Query package relative path to WORKSPACE_DIR with package name. \r | |
208 | \r | |
209 | @param packageName the name of the package\r | |
210 | @return the path relative to WORKSPACE_DIR \r | |
211 | **/\r | |
212 | public synchronized static String getPackagePath(String packageName) {\r | |
213 | return (String) packageInfo.get(packageName);\r | |
214 | }\r | |
215 | \r | |
216 | /**\r | |
217 | Query package (which the module belongs to) relative path to WORSPACE_DIR. \r | |
218 | \r | |
219 | @param moduleName the base name of the module\r | |
220 | @return the relative path to WORKSPACE_DIR of the package which the module belongs to\r | |
221 | **/\r | |
222 | public synchronized static String getPackagePathForModule(String moduleName) {\r | |
223 | String[] info = moduleInfo.get(moduleName);\r | |
224 | String packagePath = (String) packageInfo.get(info[1]);\r | |
225 | return packagePath;\r | |
226 | }\r | |
227 | \r | |
228 | /**\r | |
229 | Query the package name which the module belongs to with the module's base name.\r | |
230 | \r | |
231 | @param moduleName the base name of the module\r | |
232 | @return the package name which the module belongs to\r | |
233 | **/\r | |
234 | public synchronized static String getPackageNameForModule(String moduleName) {\r | |
235 | return moduleInfo.get(moduleName)[1];\r | |
236 | }\r | |
237 | \r | |
238 | /**\r | |
239 | Parse framework database (DB) and all SPD files listed in DB to initialize\r | |
240 | the environment for next build. This method will only be executed only once\r | |
241 | in the whole build process. \r | |
242 | \r | |
243 | @param workspaceDatabaseFile the file name of framework database\r | |
244 | @param workspaceDir current workspace directory path\r | |
245 | @throws BuildException\r | |
246 | Framework Dababase or SPD or MSA file is not valid\r | |
247 | **/\r | |
248 | public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir) throws BuildException {\r | |
249 | if (globalFlag) {\r | |
250 | return;\r | |
251 | }\r | |
252 | globalFlag = true;\r | |
253 | GlobalData.workspaceDir = workspaceDir;\r | |
254 | File dbFile = new File(workspaceDir + File.separatorChar + workspaceDatabaseFile);\r | |
255 | try {\r | |
256 | FrameworkDatabaseDocument db = (FrameworkDatabaseDocument) XmlObject.Factory.parse(dbFile);\r | |
257 | List<PackageListDocument.PackageList.Package> packages = db.getFrameworkDatabase().getPackageList()\r | |
258 | .getPackageList();\r | |
259 | Iterator iter = packages.iterator();\r | |
260 | while (iter.hasNext()) {\r | |
261 | PackageListDocument.PackageList.Package packageItem = (PackageListDocument.PackageList.Package) iter\r | |
262 | .next();\r | |
263 | String name = packageItem.getPackageNameArray(0).getStringValue();\r | |
264 | String path = packageItem.getPathArray(0).getStringValue();\r | |
265 | packageInfo.put(name, path);\r | |
266 | File spdFile = new File(workspaceDir + File.separatorChar + path + File.separatorChar + name + ".spd");\r | |
267 | initPackageInfo(spdFile.getPath(), name);\r | |
268 | // \r | |
269 | // SPD Parse.\r | |
270 | //\r | |
271 | PackageSurfaceAreaDocument spdDoc = (PackageSurfaceAreaDocument) XmlObject.Factory.parse(spdFile);\r | |
272 | Spd spd = new Spd(spdDoc, path);\r | |
273 | spdTable.put(name, spd);\r | |
274 | \r | |
275 | }\r | |
276 | } catch (Exception e) {\r | |
277 | throw new BuildException("Parse workspace Database [" + dbFile.getPath() + "] Error.\n" + e.getMessage());\r | |
278 | }\r | |
279 | }\r | |
280 | \r | |
281 | /**\r | |
282 | Parse every MSA files, get base name from MSA Header. And record those\r | |
283 | values to ModuleInfo.\r | |
284 | \r | |
285 | @param packageFilename the file name of the package\r | |
286 | @param packageName the name of the package\r | |
287 | @throws BuildException\r | |
288 | SPD or MSA file is not valid\r | |
289 | **/\r | |
290 | private synchronized static void initPackageInfo(String packageFilename, String packageName) throws BuildException {\r | |
291 | File packageFile = new File(packageFilename);\r | |
292 | try {\r | |
293 | PackageSurfaceAreaDocument spd = (PackageSurfaceAreaDocument) XmlObject.Factory.parse(packageFile);\r | |
294 | List<MsaFilesDocument.MsaFiles.MsaFile> msasList = spd.getPackageSurfaceArea().getMsaFiles()\r | |
295 | .getMsaFileList();\r | |
296 | Iterator msasIter = msasList.iterator();\r | |
297 | while (msasIter.hasNext()) {\r | |
298 | MsaFilesDocument.MsaFiles.MsaFile msas = (MsaFilesDocument.MsaFiles.MsaFile) msasIter.next();\r | |
299 | String msaFilename = msas.getFilename().getStringValue();\r | |
300 | File msaFile = new File(workspaceDir + File.separatorChar + GlobalData.getPackagePath(packageName)\r | |
301 | + File.separatorChar + msaFilename);\r | |
302 | SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();\r | |
303 | Map<String, XmlObject> map = surfaceAreaParser.parseFile(msaFile);\r | |
304 | String baseName = "";\r | |
305 | XmlObject header = null;\r | |
306 | if ((header = map.get("MsaHeader")) != null) {\r | |
307 | baseName = ((MsaHeader) header).getBaseName().getStringValue();\r | |
308 | } else if ((header = map.get("MsaLibHeader")) != null) {\r | |
309 | baseName = ((MsaLibHeader) header).getBaseName().getStringValue();\r | |
310 | } else {\r | |
311 | continue;\r | |
312 | }\r | |
313 | nativeMsa.put(baseName, map);\r | |
314 | String[] info = { msaFilename, packageName };\r | |
315 | moduleInfo.put(baseName, info);\r | |
316 | }\r | |
317 | } catch (Exception e) {\r | |
318 | throw new BuildException("Parse package description file [" + packageFile.getPath() + "] Error.\n"\r | |
319 | + e.getMessage());\r | |
320 | }\r | |
321 | }\r | |
322 | \r | |
323 | /**\r | |
324 | Query the libraries which the module depends on.\r | |
325 | \r | |
326 | @param moduleName the base name of the module\r | |
327 | @return the libraries which the module depends on\r | |
328 | **/\r | |
61746a87 | 329 | public synchronized static String[] getModuleLibrary(String moduleName, String arch) {\r |
330 | Set<String> set = moduleLibraryMap.get(moduleName + "-" + arch);\r | |
878ddf1f | 331 | return set.toArray(new String[set.size()]);\r |
332 | }\r | |
333 | \r | |
334 | /**\r | |
335 | Register module's library list which it depends on for later use. \r | |
336 | \r | |
337 | @param moduleName the base name of the module\r | |
338 | @param libraryList the libraries which the module depends on\r | |
339 | **/\r | |
61746a87 | 340 | public synchronized static void addModuleLibrary(String moduleName, String arch, Set<String> libraryList) {\r |
341 | moduleLibraryMap.put(moduleName + "-" + arch, libraryList);\r | |
878ddf1f | 342 | }\r |
343 | \r | |
344 | /**\r | |
345 | Query the library absolute file name with library name. \r | |
346 | \r | |
347 | @param library the base name of the library\r | |
348 | @return the library absolute file name\r | |
349 | **/\r | |
61746a87 | 350 | public synchronized static String getLibrary(String library, String arch) {\r |
351 | return libraries.get(library + "-" + arch);\r | |
878ddf1f | 352 | }\r |
353 | \r | |
354 | /**\r | |
355 | Register library absolute file name for later use.\r | |
356 | \r | |
357 | @param library the base name of the library\r | |
358 | @param resultPath the library absolute file name\r | |
359 | **/\r | |
61746a87 | 360 | public synchronized static void addLibrary(String library, String arch, String resultPath) {\r |
361 | libraries.put(library + "-" + arch, resultPath);\r | |
878ddf1f | 362 | }\r |
363 | \r | |
364 | /**\r | |
365 | Whether the module with ARCH has built in the previous build. \r | |
366 | \r | |
367 | @param moduleName the base name of the module\r | |
368 | @param arch current build ARCH\r | |
369 | @return true if the module has built in previous, otherwise return false\r | |
370 | **/\r | |
371 | public synchronized static boolean isModuleBuilt(String moduleName, String arch) {\r | |
372 | return builtModules.contains(moduleName + "-" + arch);\r | |
373 | }\r | |
374 | \r | |
375 | /**\r | |
376 | Register the module with ARCH has built. \r | |
377 | \r | |
378 | @param moduleName the base name of the module\r | |
379 | @param arch current build ARCH\r | |
380 | **/\r | |
381 | public synchronized static void registerBuiltModule(String moduleName, String arch) {\r | |
382 | builtModules.add(moduleName + "-" + arch);\r | |
383 | }\r | |
384 | \r | |
385 | /**\r | |
386 | Whether the module's surface area has parsed in the previous build.\r | |
387 | \r | |
388 | @param moduleName the base name of the module\r | |
389 | @return true if the module's surface area has parsed in previous, otherwise\r | |
390 | return false\r | |
391 | **/\r | |
392 | public synchronized static boolean isModuleParsed(String moduleName) {\r | |
393 | return parsedModules.containsKey(moduleName);\r | |
394 | }\r | |
395 | \r | |
396 | /**\r | |
397 | Query overrided module surface area information. If current is Package\r | |
398 | or Platform build, also include the information from FPD file. \r | |
399 | \r | |
400 | <p>Note that surface area parsing is incremental. That means the method will \r | |
401 | only to parse the MSA and MBD files when never parsed before. </p>\r | |
402 | \r | |
403 | @param moduleName the base name of the module\r | |
404 | @return the overrided module surface area information\r | |
405 | @throws BuildException\r | |
406 | MSA or MBD is not valid\r | |
407 | **/\r | |
408 | public synchronized static Map<String, XmlObject> getDoc(String moduleName) throws BuildException {\r | |
409 | if (parsedModules.containsKey(moduleName)) {\r | |
410 | return parsedModules.get(moduleName);\r | |
411 | }\r | |
412 | Map<String, XmlObject> msaMap = getNativeMsa(moduleName);\r | |
413 | Map<String, XmlObject> mbdMap = getNativeMbd(moduleName);\r | |
414 | OverrideProcess op = new OverrideProcess();\r | |
415 | Map<String, XmlObject> map = op.override(mbdMap, msaMap);\r | |
416 | //\r | |
417 | // IF IT IS A PALTFORM BUILD, OVERRIDE FROM PLATFORM\r | |
418 | //\r | |
419 | if (FpdParserTask.platformBuildOptions != null) {\r | |
420 | Map<String, XmlObject> platformMap = new HashMap<String, XmlObject>();\r | |
421 | platformMap.put("BuildOptions", FpdParserTask.platformBuildOptions);\r | |
422 | Map<String, XmlObject> overrideMap = op.override(platformMap, OverrideProcess.deal(map));\r | |
423 | GlobalData.registerModule(moduleName, overrideMap);\r | |
424 | return overrideMap;\r | |
425 | } else {\r | |
426 | parsedModules.put(moduleName, map);\r | |
427 | return map;\r | |
428 | }\r | |
429 | }\r | |
430 | \r | |
431 | /**\r | |
432 | Query the native MSA information with module base name. \r | |
433 | \r | |
434 | <p>Note that MSA parsing is incremental. That means the method will \r | |
435 | only to parse the MSA files when never parsed before. </p>\r | |
436 | \r | |
437 | @param moduleName the base name of the module\r | |
438 | @return the native MSA information\r | |
439 | @throws BuildException\r | |
440 | MSA file is not valid\r | |
441 | **/\r | |
442 | public synchronized static Map<String, XmlObject> getNativeMsa(String moduleName) throws BuildException {\r | |
443 | if (nativeMsa.containsKey(moduleName)) {\r | |
444 | return nativeMsa.get(moduleName);\r | |
445 | }\r | |
446 | String msaFilename = getMsaFilename(moduleName);\r | |
447 | File msaFile = new File(msaFilename);\r | |
448 | if (!msaFile.exists()) {\r | |
449 | throw new BuildException("Info: Surface Area file [" + msaFile.getPath() + "] can't found.");\r | |
450 | }\r | |
451 | SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();\r | |
452 | Map<String, XmlObject> map = surfaceAreaParser.parseFile(msaFile);\r | |
453 | nativeMsa.put(moduleName, map);\r | |
454 | return map;\r | |
455 | }\r | |
456 | \r | |
457 | /**\r | |
458 | Query the native MBD information with module base name. \r | |
459 | \r | |
460 | <p>Note that MBD parsing is incremental. That means the method will \r | |
461 | only to parse the MBD files when never parsed before. </p>\r | |
462 | \r | |
463 | @param moduleName the base name of the module\r | |
464 | @return the native MBD information\r | |
465 | @throws BuildException\r | |
466 | MBD file is not valid\r | |
467 | **/\r | |
468 | public synchronized static Map<String, XmlObject> getNativeMbd(String moduleName) throws BuildException {\r | |
469 | if (nativeMbd.containsKey(moduleName)) {\r | |
470 | return nativeMbd.get(moduleName);\r | |
471 | }\r | |
472 | String mbdFilename = getMbdFilename(moduleName);\r | |
473 | File mbdFile = new File(mbdFilename);\r | |
474 | if (!mbdFile.exists()) {\r | |
475 | throw new BuildException("Info: Surface Area file [" + mbdFile.getPath() + "] can't found.");\r | |
476 | }\r | |
477 | SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();\r | |
478 | Map<String, XmlObject> map = surfaceAreaParser.parseFile(mbdFile);\r | |
479 | nativeMbd.put(moduleName, map);\r | |
480 | return map;\r | |
481 | }\r | |
482 | \r | |
483 | /**\r | |
484 | Register module overrided surface area information. If has existed, then update.\r | |
485 | \r | |
486 | @param moduleName the base name of the module\r | |
487 | @param map the overrided surface area information\r | |
488 | **/\r | |
489 | public synchronized static void registerModule(String moduleName, Map<String, XmlObject> map) {\r | |
490 | parsedModules.put(moduleName, map);\r | |
491 | }\r | |
492 | \r | |
493 | /**\r | |
494 | * \r | |
495 | * @param protocolName\r | |
496 | * @return\r | |
497 | */\r | |
498 | public synchronized static String[] getProtocolInfoGuid(String protocolName) {\r | |
499 | Set set = spdTable.keySet();\r | |
500 | Iterator iter = set.iterator();\r | |
501 | String[] cNameGuid = null;\r | |
502 | \r | |
503 | while (iter.hasNext()) {\r | |
504 | Spd spd = (Spd) spdTable.get(iter.next());\r | |
505 | cNameGuid = spd.getProtocolNameGuidArray(protocolName);\r | |
506 | if (cNameGuid != null) {\r | |
507 | break;\r | |
508 | }\r | |
509 | }\r | |
510 | return cNameGuid;\r | |
511 | }\r | |
512 | \r | |
513 | public synchronized static String[] getPpiInfoGuid(String ppiName) {\r | |
514 | Set set = spdTable.keySet();\r | |
515 | Iterator iter = set.iterator();\r | |
516 | String[] cNameGuid = null;\r | |
517 | \r | |
518 | while (iter.hasNext()) {\r | |
519 | Spd spd = (Spd) spdTable.get(iter.next());\r | |
520 | cNameGuid = spd.getPpiCnameGuidArray(ppiName);\r | |
521 | \r | |
522 | if (cNameGuid != null) {\r | |
523 | break;\r | |
524 | }\r | |
525 | }\r | |
526 | return cNameGuid;\r | |
527 | }\r | |
528 | \r | |
529 | /**\r | |
530 | * \r | |
531 | * @param guidName\r | |
532 | * @return\r | |
533 | */\r | |
534 | public synchronized static String[] getGuidInfoGuid(String guidName) {\r | |
535 | String[] cNameGuid = null;\r | |
536 | Set set = spdTable.keySet();\r | |
537 | Iterator iter = set.iterator();\r | |
538 | \r | |
539 | while (iter.hasNext()) {\r | |
540 | Spd spd = (Spd) spdTable.get(iter.next());\r | |
541 | cNameGuid = spd.getGuidNameArray(guidName);\r | |
542 | if (cNameGuid != null) {\r | |
543 | break;\r | |
544 | }\r | |
545 | }\r | |
546 | return cNameGuid;\r | |
547 | }\r | |
548 | \r | |
549 | public synchronized static String getLibClassIncluder(String libName) {\r | |
550 | String libIncluder = null;\r | |
551 | Set set = spdTable.keySet();\r | |
552 | Iterator iter = set.iterator();\r | |
553 | \r | |
554 | while (iter.hasNext()) {\r | |
555 | String packageName = (String) iter.next();\r | |
556 | Spd spd = (Spd) spdTable.get(packageName);\r | |
557 | libIncluder = spd.getLibClassIncluder(libName);\r | |
558 | String packagePath = spd.packagePath;\r | |
559 | if (packagePath != null) {\r | |
560 | packagePath = packagePath.replace('\\', File.separatorChar);\r | |
561 | packagePath = packagePath.replace('/', File.separatorChar);\r | |
562 | } else {\r | |
563 | packagePath = packageName;\r | |
564 | }\r | |
565 | if (libIncluder != null) {\r | |
566 | libIncluder = libIncluder.replace('\\', File.separatorChar);\r | |
567 | libIncluder = libIncluder.replace('/', File.separatorChar);\r | |
568 | libIncluder = packageName + File.separatorChar + libIncluder;\r | |
569 | break;\r | |
570 | }\r | |
571 | }\r | |
572 | return libIncluder;\r | |
573 | }\r | |
574 | \r | |
575 | public synchronized static String getModuleInfoByPackageName(String packageName, String moduleType) {\r | |
576 | Spd spd;\r | |
577 | String includeFile = null;\r | |
578 | String includeStr = "";\r | |
579 | String cleanPath = "";\r | |
580 | \r | |
581 | spd = (Spd) spdTable.get(packageName);\r | |
582 | includeFile = spd.getModuleTypeIncluder(moduleType);\r | |
583 | if (includeFile != null) {\r | |
584 | includeFile = includeFile.replace('\\', File.separatorChar);\r | |
585 | includeFile = includeFile.replace('/', File.separatorChar);\r | |
586 | includeStr = CommonDefinition.include + " <" + includeStr;\r | |
587 | cleanPath = spd.packagePath;\r | |
588 | cleanPath = cleanPath.replace('\\', File.separatorChar);\r | |
589 | cleanPath = cleanPath.replace('/', File.separatorChar);\r | |
590 | \r | |
591 | if (cleanPath.charAt(spd.packagePath.length() - 1) != File.separatorChar) {\r | |
592 | cleanPath = cleanPath + File.separatorChar;\r | |
593 | }\r | |
594 | includeStr = includeStr + cleanPath;\r | |
595 | includeStr = includeStr + includeFile;\r | |
596 | includeStr = includeStr + ">\r\n";\r | |
597 | }\r | |
598 | \r | |
599 | return includeStr;\r | |
600 | }\r | |
601 | \r | |
602 | public synchronized static void setLibInstanceInfo(String libName, String libConstructor, String libDesturctor) {\r | |
603 | String[] libConsDes = new String[2];\r | |
604 | libConsDes[0] = libConstructor;\r | |
605 | libConsDes[1] = libDesturctor;\r | |
606 | \r | |
607 | libInstanceInfo.put(libName, libConsDes);\r | |
608 | }\r | |
609 | \r | |
610 | public synchronized static boolean isHaveLibInstance(String libName) {\r | |
611 | return libInstanceInfo.containsKey(libName);\r | |
612 | }\r | |
613 | \r | |
614 | public synchronized static String getLibInstanceConstructor(String libName) {\r | |
615 | String[] libInstanceValue;\r | |
616 | libInstanceValue = libInstanceInfo.get(libName);\r | |
617 | if (libInstanceValue != null) {\r | |
618 | return libInstanceValue[0];\r | |
619 | } else {\r | |
620 | return null;\r | |
621 | }\r | |
622 | }\r | |
623 | \r | |
624 | public synchronized static String getLibInstanceDestructor(String libName) {\r | |
625 | String[] libInstanceValue;\r | |
626 | libInstanceValue = libInstanceInfo.get(libName);\r | |
627 | if (libInstanceValue != null) {\r | |
628 | return libInstanceValue[1];\r | |
629 | } else {\r | |
630 | return null;\r | |
631 | }\r | |
632 | }\r | |
633 | \r | |
634 | public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() {\r | |
635 | return pcdDbManager;\r | |
636 | }\r | |
637 | }\r |