01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.test.server.appserver.deployment;
05:
06: import java.io.File;
07: import java.io.FilenameFilter;
08:
09: public class ClassPathBuilder {
10:
11: StringBuffer sb = new StringBuffer();
12:
13: public void addDir(String dir) {
14: FileSystemPath dirPath = FileSystemPath.existingDir(dir);
15: addFileOrDir(dirPath);
16: }
17:
18: private void addFileOrDir(FileSystemPath dirPath) {
19: if (sb.length() > 0)
20: sb.append(";");
21: sb.append(dirPath);
22: }
23:
24: public String makeClassPath() {
25: return sb.toString();
26: }
27:
28: public void addJARsInDir(String dirContainingJARS) {
29: FileSystemPath dirPath = FileSystemPath
30: .existingDir(dirContainingJARS);
31: String[] jars = dirPath.getFile().list(new FilenameFilter() {
32:
33: public boolean accept(File dir, String name) {
34: return name.endsWith(".jar");
35: }
36: });
37: for (int i = 0; i < jars.length; i++) {
38: String jar = jars[i];
39: addFileOrDir(dirPath.existingFile(jar));
40: }
41:
42: }
43:
44: }
|