001: /*
002: * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005:
006: package com.sun.portal.instance.sra.common;
007:
008: //
009:
010: import com.sun.portal.config.context.*;
011: import com.sun.portal.config.tasks.*;
012:
013: import java.io.IOException;
014:
015: //
016:
017: public class NetletProxyInstance extends SRAInstance {
018: //
019: //
020: //
021: protected NLPTasks t = null;
022: protected static final String configFilePrefix = "NLPConfig";
023:
024: //
025: //
026: //
027: public NetletProxyInstance(String installLocation) {
028: super (installLocation, configFilePrefix
029: + SRAFileContext.DOT_PROPERTIES);
030: }
031:
032: //
033: //
034: //
035: public SRAPropertyContext getSRAPropertyContext() {
036: SRAPropertyContext result = null;
037:
038: try {
039: validate();
040: result = spc;
041: } catch (IOException ioe) {
042: DebugContext.message("Configuration file is <"
043: + workingConfigurationFile + ">");
044: ioe.printStackTrace();
045: }
046:
047: return result;
048: }
049:
050: public SRAFileContext getSRAFileContext() {
051: SRAFileContext result = null;
052:
053: try {
054: validate();
055: result = sfc;
056: } catch (IOException ioe) {
057: DebugContext.message("Configuration file is <"
058: + workingConfigurationFile + ">");
059: ioe.printStackTrace();
060: }
061:
062: return result;
063: }
064:
065: public Boolean setName(String instanceName) {
066: Boolean result = super .setName(instanceName);
067:
068: try {
069: validate();
070: workingConfigurationFile = sfc
071: .getNLPInstanceConfigurationFile(name);
072: if (workingConfigurationFile != null) {
073: gearUp();
074: }
075: } catch (IOException ioe) {
076: DebugContext.message("Configuration file is <"
077: + workingConfigurationFile + ">");
078: ioe.printStackTrace();
079: result = Boolean.FALSE;
080: }
081:
082: return result;
083: }
084:
085: public Boolean create() throws IOException {
086: return t.installNetletProxyInstance(workingConfigurationFile);
087: }
088:
089: public Boolean remove() throws IOException {
090: return t.uninstallNetletProxyInstance(workingConfigurationFile);
091: }
092:
093: public String[] list() throws IOException {
094: validate();
095: return sfc.getNLPInstanceNames();
096: }
097:
098: //
099: //
100: //
101: private void gearUp() throws IOException {
102: Tasks tasks = new TasksImpl();
103:
104: p = tasks
105: .load(tasks.replaceBackSlash(workingConfigurationFile));
106:
107: spc = new NLPPropertyContext(p);
108: sfc = SRAFileContextFactory.createNLPFileContext(spc);
109: t = SRATasksFactory.createNLPTasks(spc, sfc);
110: }
111:
112: protected void validate() throws IOException {
113: if (workingConfigurationFile != null) {
114: if (p == null) {
115: gearUp();
116: }
117: }
118: }
119:
120: //
121: //
122: //
123: public Boolean updateConfigurationFile(IdentityPropertyContext ipc,
124: SRAPropertyContext spc, String propertiesHeader) {
125: this .spc = spc; // Get modified values. CreateInstance may cause this.spc be out-of-sync.
126: workingConfigurationFile = sfc.getConfigurationDirectory()
127: + SRAFileContext.FORWARD_SLASH + configFilePrefix
128: + SRAFileContext.DASH + spc.getInstanceName()
129: + SRAFileContext.DOT_PROPERTIES;
130: return super .updateConfigurationFile(ipc, propertiesHeader);
131: }
132:
133: //
134: //
135: //
136: }
|