01: /**
02: * Library name : Primrose - A Java Database Connection Pool.
03: * Published by Ben Keeping, http://primrose.org.uk .
04: * Copyright (C) 2004 Ben Keeping, primrose.org.uk
05: * Email: Use "Contact Us Form" on website
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this library; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: */package uk.org.primrose.console;
21:
22: import uk.org.primrose.*;
23: import java.io.*;
24:
25: public class GenericWebConsoleFactory {
26: private int port = -1;
27: private String logFile = null;
28: private Logger logger = null;
29: private static WebConsole wc = null;
30: private String logLevel = "";
31: private String username = null;
32: private String password = null;
33:
34: public void setLogLevel(String logLevel) {
35: this .logLevel = logLevel;
36: }
37:
38: public String getLogLevel() {
39: return logger.getLogLevel();
40: }
41:
42: public void setPort(String port) throws IOException {
43: this .port = Integer.parseInt(port);
44: start();
45: }
46:
47: public void setLogFile(String logFile) throws IOException {
48: this .logFile = logFile;
49: this .logger = new Logger();
50: this .logger.setLogWriter(logFile);
51: this .logger.setLogLevel(this .logLevel);
52: start();
53: }
54:
55: public String getLogFile() {
56: return logFile;
57: }
58:
59: public String getPort() {
60: return port + "";
61: }
62:
63: public void start() throws IOException {
64: if (port > 0 && logger != null) {
65: wc = new WebConsole(username, password, port, logger);
66: wc.start();
67: }
68: }
69:
70: public void stop() throws IOException {
71: WebConsole.shutdown();
72: }
73:
74: public void setUsername(String username) {
75: this .username = username;
76: if (wc != null)
77: wc.setUsername(username);
78: }
79:
80: public void setPassword(String password) {
81: this .password = password;
82: if (wc != null)
83: wc.setPassword(password);
84: }
85:
86: public String getPassword() {
87: if (wc != null)
88: return wc.getPassword();
89: return null;
90: }
91:
92: public String getUsername() {
93: if (wc != null)
94: return wc.getUsername();
95: return null;
96: }
97: }
|