01: /*
02: * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05:
06: package com.sun.portal.desktop.deployment;
07:
08: import java.io.ByteArrayInputStream;
09: import java.io.ByteArrayOutputStream;
10: import java.io.InputStream;
11: import java.io.File;
12:
13: import java.util.Properties;
14: import java.util.zip.ZipEntry;
15:
16: /**
17: * ProviderPackageFile for encapsulating Properties objects.
18: *
19: * @author yabob
20: * @version
21: */
22: public class PropertiesPPF extends ProviderPackageFile {
23:
24: // Takes the property (for representation in the .par file), the
25: // directory that corresponds to in the current environment (so
26: // we can stream the contents), and the relative path underneath
27: // the property.
28:
29: public PropertiesPPF(Properties prop, int types, String name) {
30:
31: super (types);
32:
33: m_Prop = prop;
34: m_Name = name;
35: }
36:
37: public InputStream getStream() throws ParFileException {
38: try {
39: ByteArrayOutputStream out = new ByteArrayOutputStream();
40: m_Prop.store(out, m_Name);
41: ByteArrayInputStream in = new ByteArrayInputStream(out
42: .toByteArray());
43:
44: out.close();
45: return (InputStream) in;
46: } catch (Exception ex) {
47: throw new ParFileException("errorPropertiesFile", ex);
48: }
49: }
50:
51: // The properties entries in the Manifest entry will be added in ParFileBuilder
52: public void addManifestInclusion(ParManifest man, String name)
53: throws ParFileException {
54: throw new ParFileException("errorManifestInclusion");
55: }
56:
57: public ZipEntry getZipEntry(ParManifest man)
58: throws ParFileException {
59: return man.getPropertiesZip(m_Name);
60: }
61:
62: private Properties m_Prop;
63: private String m_Name;
64: }
|