User: jung
Date: 00/12/22 00:34:44
Added: src/de/infor/ce/console Console.java ConsoleException.java
ConsoleFactory.java Environment.java
SystemConsoleFactoryImpl.java
SystemConsoleImpl.java console.dfPackage
Log:
began with exception redesign (messages+embedded throwables).
added a convenient logger console abstraction.
generic Environment.java for configuring packages.
some refactoring of the http package
began move to LGPL
Revision Changes Path
1.1 zoap/src/de/infor/ce/console/Console.java
Index: Console.java
===================================================================
package de.infor.ce.console;
import java.io.InputStream;
import java.io.PrintStream;
/**
* $Id: Console.java,v 1.1 2000/12/22 08:34:42 jung Exp $
* Copyright 2000 by infor: business solutions AG
* Hauerstra�e 12, D-66299 Friedrichsthal, Germany
* All rights reserved.
*
* This software is the confidential and proprietary information
* of infor: business solutions AG ("Confidential Information"). You
* shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement
* you entered into with infor AG.
*/
import java.io.InputStream;
import java.io.PrintStream;
/**
* Console is the interface to a virtual terminal/logger. The idea is that
* we can hide a variety of different output/input mechanisms behind this
* interface in order to plugin modules into different deployment
scenarios.
*
* @see <related>
* @author $Author: jung $
* @version $Revision: 1.1 $
*/
public interface Console {
/** retrieves the inputstream of that console */
public InputStream getIn();
/** retrieves the output printstream of that console */
public PrintStream getOut();
/** retrieves the error output stream of that console */
public PrintStream getErr();
/** allows to log a message of a given type */
public void log(String type, String message);
/** allows to log a simple information message */
public void log(String message);
/** allows to log an error message */
public void error(String message);
/** allows to log a warning */
public void warning(String message);
/** allows to log a debug message */
public void debug(String message);
/** allows to log an exception */
public void exception(Throwable exception);
/** allows to track the progress of work done, a float between 0..1 */
public void reportProgress(double progress);
} // Console
1.1 zoap/src/de/infor/ce/console/ConsoleException.java
Index: ConsoleException.java
===================================================================
package de.infor.ce.console;
/**
* $Id: ConsoleException.java,v 1.1 2000/12/22 08:34:42 jung Exp $
* Copyright 2000 by infor: business solutions AG
* Hauerstra�e 12, D-66299 Friedrichsthal, Germany
* All rights reserved.
*
* This software is the confidential and proprietary information
* of infor: business solutions AG ("Confidential Information"). You
* shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement
* you entered into with infor AG.
*/
/**
* <Description>
* @see <related>
* @author $Author: jung $
* @version $Revision: 1.1 $
*/
public class ConsoleException extends Exception {
}
1.1 zoap/src/de/infor/ce/console/ConsoleFactory.java
Index: ConsoleFactory.java
===================================================================
package de.infor.ce.console;
/**
* $Id: ConsoleFactory.java,v 1.1 2000/12/22 08:34:43 jung Exp $
* Copyright 2000 by infor: business solutions AG
* Hauerstra�e 12, D-66299 Friedrichsthal, Germany
* All rights reserved.
*
* This software is the confidential and proprietary information
* of infor: business solutions AG ("Confidential Information"). You
* shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement
* you entered into with infor AG.
*/
/**
* A factory for consoles
* @see <related>
* @author $Author: jung $
* @version $Revision: 1.1 $
*/
public interface ConsoleFactory {
public Console createConsole(String moduleName) throws ConsoleException;
}
1.1 zoap/src/de/infor/ce/console/Environment.java
Index: Environment.java
===================================================================
/**
* $Id: Environment.java,v 1.1 2000/12/22 08:34:43 jung Exp $
* Copyright 2000 by infor: business solutions AG
* Hauerstra�e 12, D-66299 Friedrichsthal, Germany
* All rights reserved.
*
* This software is the confidential and proprietary information
* of infor: business solutions AG ("Confidential Information"). You
* shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement
* you entered into with infor AG.
*/
package de.infor.ce.console;
import java.util.Properties;
/**
* Environment provides a hook for all package-local configurations.
*
* @see <related>
* @author $Author: jung $
* @version $Revision: 1.1 $
*/
public abstract class Environment {
/** how this module is called */
public static final String MODULE_NAME = "console";
/** where the resources needed to configure this module are found */
public static final String RESOURCE_PATH = "";
/** where the resources needed to configure this module are found */
public static final String CONFIG_FILE_SUFFIX = ".conf";
/** whether debug messages are produced, compile-time switch */
public static final int DEBUG_LEVEL = 0;
/** runtime logging settings */
public static int LOG_LEVEL = 1;
/** the logger factory we apply */
public static ConsoleFactory CONSOLE_FACTORY=
SystemConsoleFactoryImpl.getConsoleFactory();
/** whether a config file is loaded */
public static final boolean READ_CONFIG_FILE = true;
/** the properties belonging to this module */
public static Properties PROPERTIES = System.getProperties();
/** initialisation is done at class loading time */
static {
if (READ_CONFIG_FILE) {
try {
// and add your personal configuration file
PROPERTIES.load(Environment.class.getClassLoader().
getResourceAsStream(RESOURCE_PATH + MODULE_NAME +
CONFIG_FILE_SUFFIX));
} catch (Exception e) {
}
}
if (PROPERTIES.containsKey(MODULE_NAME + ".LOG_LEVEL")) {
try {
LOG_LEVEL = new Integer(PROPERTIES.getProperty(MODULE_NAME
+ ".LOG_LEVEL")).intValue();
} catch (Exception e) {
}
}
if (PROPERTIES.containsKey(MODULE_NAME + ".CONSOLE_FACTORY")) {
try {
CONSOLE_FACTORY= (ConsoleFactory)
Class.forName(PROPERTIES.getProperty(MODULE_NAME +
".CONSOLE_FACTORY"),true,Thread.currentThread().
getContextClassLoader()).newInstance();
} catch (Exception e) {
}
}
} // static
/** set up a new logging facility */
public static Console CONSOLE;
static{
try{
CONSOLE=de.infor.ce.console.Environment.CONSOLE_FACTORY.
createConsole(MODULE_NAME);
} catch(Exception e) {
}
}
}
1.1 zoap/src/de/infor/ce/console/SystemConsoleFactoryImpl.java
Index: SystemConsoleFactoryImpl.java
===================================================================
package de.infor.ce.console;
/**
* $Id: SystemConsoleFactoryImpl.java,v 1.1 2000/12/22 08:34:43 jung Exp $
* Copyright 2000 by infor: business solutions AG
* Hauerstra�e 12, D-66299 Friedrichsthal, Germany
* All rights reserved.
*
* This software is the confidential and proprietary information
* of infor: business solutions AG ("Confidential Information"). You
* shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement
* you entered into with infor AG.
*/
/**
* Factory for system consoles
* @see <related>
* @author $Author: jung $
* @version $Revision: 1.1 $
*/
public class SystemConsoleFactoryImpl implements ConsoleFactory {
private SystemConsoleFactoryImpl() {
}
public Console createConsole(String moduleName) {
return SystemConsoleImpl.getConsole();
}
private static ConsoleFactory singleton = new SystemConsoleFactoryImpl();
public static ConsoleFactory getConsoleFactory() {
return singleton;
}
}
1.1 zoap/src/de/infor/ce/console/SystemConsoleImpl.java
Index: SystemConsoleImpl.java
===================================================================
package de.infor.ce.console;
/**
* $Id: SystemConsoleImpl.java,v 1.1 2000/12/22 08:34:43 jung Exp $
* Copyright 2000 by infor: business solutions AG
* Hauerstra�e 12, D-66299 Friedrichsthal, Germany
* All rights reserved.
*
* This software is the confidential and proprietary information
* of infor: business solutions AG ("Confidential Information"). You
* shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement
* you entered into with infor AG.
*/
import java.io.InputStream;
import java.io.PrintStream;
/**
* A simple console that is tight to System.in, System.out and System.err.
* @see <related>
* @author $Author: jung $
* @version $Revision: 1.1 $
*/
public class SystemConsoleImpl implements Console {
private InputStream in;
private PrintStream out;
private PrintStream err;
protected SystemConsoleImpl() {
in=System.in;
err=System.err;
out=System.out;
}
public InputStream getIn(){
return in;
}
public PrintStream getErr(){
return err;
}
public PrintStream getOut(){
return err;
}
public void log(String type, String message)
{
getOut().println(message);
}
public void log(String message)
{
log("Information", message);
}
public void error(String message)
{
getErr().println(message);
}
public void warning(String message)
{
getErr().println(message);
}
public void debug(String message)
{
log("Debug", message);
}
public void exception(Throwable exception)
{
exception.printStackTrace(getErr());
}
public void reportProgress(double report) {
log("Progress","progress: "+report);
}
private static Console singleton=new SystemConsoleImpl();
public static Console getConsole() {
return singleton;
}
}
1.1 zoap/src/de/infor/ce/console/console.dfPackage
Index: console.dfPackage
===================================================================
package id2zbm2ch01vrc3ch02n0gl;
/**
@version 2.0
@physicalPackage
@__modelType diagram
*/
class diagram {
}/**
@__tags
@shapeType ClassDiagram
*/
class __tags {
}/**
@__options
*/
class __options {
}/**
@__positions
*/
class __positions {
}