|
What this is
Other links
The source code
/* Copyright (c) 2001-2004, The HSQL Development Group
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of the HSQL Development Group nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.hsqldb;
import java.net.InetAddress;
import org.hsqldb.lib.HashSet;
import org.hsqldb.lib.StringUtil;
//TODO: move to here from Server and WebServer the remaining extraneous code
// dealing primarily with reading/setting properties from files, etc.
/**
* Assists with Server and WebServer configuration tasks.
*
* @author boucherb@users
* @version 1.7.2
* @since 1.7.2
*/
public final class ServerConfiguration implements ServerConstants {
private ServerConfiguration() {}
/**
* Retrieves the default port that a Server will try to use in the
* abscence of an explicitly specified one, given the specified
* value for whether or not to use secure sockets.
*
* @param protocol the protcol specifier code of the Server
* @param isTls if true, retrieve the default port when using secure
* sockets, else the default port when using plain sockets
* @return the default port used in the abscence of an explicit
* specification.
*
*/
public static int getDefaultPort(int protocol, boolean isTls) {
switch (protocol) {
case SC_PROTOCOL_HSQL : {
return isTls ? SC_DEFAULT_HSQLS_SERVER_PORT
: SC_DEFAULT_HSQL_SERVER_PORT;
}
case SC_PROTOCOL_HTTP : {
return isTls ? SC_DEFAULT_HTTPS_SERVER_PORT
: SC_DEFAULT_HTTP_SERVER_PORT;
}
default : {
return -1;
}
}
}
/**
* Retrieves a new HsqlProperties object, if possible, loaded from the
* specified file.
*
* @param path the file's path, without the .properties extention
* (which is added automatically)
* @return a new properties object loaded from the specified file
*/
public static HsqlProperties getPropertiesFromFile(String path) {
if (StringUtil.isEmpty(path)) {
return null;
}
HsqlProperties p = new HsqlProperties(path);
try {
p.load();
} catch (Exception e) {}
return p;
}
/**
* Retrieves an array of Strings naming the distinct, known to be valid local
* InetAddress names for this machine. The process is to collect and
* return the union of the following sets:
*
*
|
Copyright 1998-2008 Alvin Alexander
All Rights Reserved.
devdaily.com is based in louisville, kentucky, and this web site is hosted by godaddy.com