01: /*
02: * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05:
06: //
07: package com.sun.portal.ffj.deploy;
08:
09: //
10: import java.io.*;
11:
12: import org.openide.filesystems.*;
13:
14: import com.sun.portal.ffj.filesystems.PSFileSystem;
15: import com.sun.portal.ffj.util.ParEntry;
16: import com.sun.portal.ffj.util.PSConstants;
17:
18: //
19: public class JavaProviderDeploy extends DeployAdapter implements
20: PSConstants {
21: //
22: private static final String EXTENSION = "class";
23:
24: //
25: //
26: //
27: public boolean deploy(ParEntry pe) throws DeployException {
28: //
29: String method = "deploy: ";
30: boolean retVal = true;
31:
32: //
33: File fSrc = getSourceFile(pe);
34: File fDest = getDestinationFile(pe);
35:
36: //
37: copy(fSrc, fDest);
38:
39: //
40: return retVal;
41: }
42:
43: //
44: //
45: //
46: private File getSourceFile(ParEntry pe) {
47: //
48: String method = "getSourceFile: ";
49:
50: //
51: String providerClass = pe.getProviderClass();
52: String className = getLeafName(providerClass, PACKAGE_SEPARATOR);
53:
54: //
55: FileObject foPE = pe.getXMLDataObject().getPrimaryFile();
56: String absolutePackagePath = PSFileSystem
57: .getAbsolutePathName(foPE.getParent());
58: if (!absolutePackagePath.endsWith(File.separator))
59: absolutePackagePath += File.separator;
60: String srcPathName = absolutePackagePath + className
61: + PS_EXT_SEPARATOR + EXTENSION;
62: File fSrc = new File(srcPathName);
63:
64: return fSrc;
65: }
66:
67: private File getDestinationFile(ParEntry pe) {
68: //
69: String method = "getDestinationFile: ";
70:
71: //
72: String providerClass = pe.getProviderClass();
73: String className = getLeafName(providerClass, PACKAGE_SEPARATOR);
74: String packageName = getPackageName(providerClass,
75: PACKAGE_SEPARATOR);
76:
77: //
78: String destPath = PSFileSystem.getRootPath();
79: if (!destPath.endsWith(File.separator))
80: destPath += File.separator;
81: destPath += "WEB-INF" + File.separator + "classes";
82: if (packageName != null) {
83: destPath += File.separator
84: + packageName.replace(PACKAGE_SEPARATOR.charAt(0),
85: File.separatorChar);
86: }
87: File fDestDir = new File(destPath);
88: fDestDir.mkdirs();
89:
90: String destPathName = destPath + File.separator + className
91: + PS_EXT_SEPARATOR + EXTENSION;
92: File fDest = new File(destPathName);
93:
94: return fDest;
95: }
96: }
|