⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apiconfig.java

📁 短信短消息SMPP开发的JAVA API最新版本。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Java SMPP API * Copyright (C) 1998 - 2002 by Oran Kelly *  * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. *  * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. *  * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *  * A copy of the LGPL can be viewed at http://www.gnu.org/copyleft/lesser.html * Java SMPP API author: orank@users.sf.net * Java SMPP API Homepage: http://smppapi.sourceforge.net/ * $Id: APIConfig.java,v 1.7 2004/10/09 22:02:41 orank Exp $ */package ie.omk.smpp.util;import java.io.IOException;import java.io.InputStream;import java.io.PrintWriter;import java.io.StringWriter;import java.util.Properties;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;/** Internal API configuration. This singleton class holds the configuration for * the smppapi. On initialisation, it searches for a file named * "smppapi.properties". This file needs to be locatable in the classpath in one * of the following locations: /, /ie, /ie/omk, /ie/omk/smpp or the default * classloader for this class must be able to find it. * <p> Most applications can probably accept the default settings of the API. * If, however, you're trying to eke maximum performance out of your * application, tweaking these settings may help.</p> * <p>Supported API properties are: * <table cols="3" border="1" width="100%"> * <tr><th width="25%">Property name</th><th width="25%">Type</th> * <th width="50%">Description</th></tr> *  * <tr><td><code>smppapi.net.so_timeout</code></td><td>Integer</td> * <td>This property sets the SO_TIMEOUT property for the sockets used by the * {@link ie.omk.smpp.net.TcpLink} objects to connect to the SMSC. Setting this * value affects the behavour of any methods that read from the SMSC link. The * timeout is specified in milliseconds.</td> * </tr> *  * <tr><td><code>smppapi.net.buffersize_in</code></td><td>Integer</td> * <td>Sets the size of the buffer used on the incoming stream connection from * the SMSC. A plain value specified the number of bytes. A suffix of 'k' after * the number will be interpreted as kilobytes and a suffix of 'm' will be * interpreted as megabytes. For example, 4k will allocate a buffer size of 4096 * bytes.</td> * </tr> *  * <tr><td><code>smppapi.net.buffersize_out</code></td><td>Integer</td> * <td>Sets the size of the buffer used on the outgoing stream connection to * the SMSC. A plain value specified the number of bytes. A suffix of 'k' after * the number will be interpreted as kilobytes and a suffix of 'm' will be * interpreted as megabytes. For example, 4k will allocate a buffer size of 4096 * bytes.</td> * </tr> *  * <tr><td><code>smppapi.net.autoflush</code></td><td>Boolean</td> * <td>By default, the {@link ie.omk.smpp.net.SmscLink} class automatically * flushes the output stream after every packet written to the output stream. In * high-load environments, it may be better to turn this off and manually flush * the output stream only when required (after a short period of inactivity, for * example).</td> * </tr> * * <tr><td><code>smppapi.net.autoclose_snoop</code></td><td>Boolean</td> * <td>If snoop streams are set on the SMSC link object and this value is true * (the default), the snoop streams will be closed when the link is closed. If * false, the snoop streams will be flushed and left open when the link is * closed.</td> * </tr> *  * <tr><td><code>smppapi.connection.bind_timeout</code></td><td>Long</td> * <td>The length of time, in milliseconds, to wait for a bind response packet * after sending a bind request. If a packet is not received within this * time period, the network connection is closed. A negative value or zero * means wait indefinitely.</td> * </tr> *  * <tr><td><code>smppapi.connection.rcv_daemon.ioex_count</code></td><td>Integer</td> * <td>The number of I/O exceptions the receiver daemon will accept occurring * before exiting.</td> * </tr> * * <tr><td><code>smppapi.event.dispatcher</code></td><td>String</td> * <td>The name of a class which implements the * {@link ie.omk.smpp.event.EventDispatcher} which will be used as the default * event dispatcher for <code>Connection</code> objects.</td> * </tr> * * <tr><td><code>smppapi.event.threaded_dispatcher.pool_size</code></td><td>Integer</td> * <td>The size of the thread pool used by the {@link ie.omk.smpp.event.ThreadedEventDispatcher} * class.</td> * </tr> * * <tr><td><code>smppapi.event.threaded_dispatcher.queue_size</code></td><td>Integer</td> * <td>The size of the event FIFO queue used in the <code>ie.omk.smpp.event.ThreadedEventDispatcher</code> * class.</td> * </tr> * * </table> * */public class APIConfig extends Properties {    /** See class description for documentation on the properties.     * @deprecated     */    public static final String TCP_SOCKET_TIMEOUT = "smppapi.net.tcp.so_timeout";    /** See class description for documentation on the properties.     */    public static final String LINK_BUFFERSIZE_IN = "smppapi.net.buffersize_in";    /** See class description for documentation on the properties.     */    public static final String LINK_BUFFERSIZE_OUT = "smppapi.net.buffersize_out";    /** See class description for documentation on the properties.     */    public static final String LINK_AUTO_FLUSH = "smppapi.net.autoflush";    /** See class description for documentation on the properties.     */    public static final String LINK_AUTOCLOSE_SNOOP = "smppapi.net.autoclose_snoop";    /** See class description for documentation on the properties.     */    public static final String LINK_TIMEOUT = "smppapi.net.link_timeout";        /** See class description for documentation on the properties.     */    public static final String TOO_MANY_IO_EXCEPTIONS = "smppapi.connection.rcv_daemon.ioex_count";    /** See class description for documentation on the properties.     */    public static final String EVENT_DISPATCHER_CLASS = "smppapi.event.dispatcher";    /** See class description for documentation on the properties.     */    public static final String EVENT_THREAD_POOL_SIZE = "smppapi.event.threaded_dispatcher.pool_size";    /** See class description for documentation on the properties.     */    public static final String EVENT_THREAD_FIFO_QUEUE_SIZE = "smppapi.event.threaded_dispatcher.queue_size";    /** See class description for documentation on the properties.     */    public static final String BIND_TIMEOUT = "smppapi.connection.bind_timeout";    private static final Log logger = LogFactory.getLog(APIConfig.class);    /** Paths to search for the API properties file. These should always end in     * the '/' character except for the last entry which should be a blank     * string.     */    private static final String[] SEARCH_PATH = {	"/", "/ie/", "/ie/omk/", "/ie/omk/smpp/", ""    };    /** Name of the resource to load properties from.     */    private static final String PROPS_RESOURCE = "smppapi.properties";    /** The singleton instance of the API configuration.     */    private static APIConfig instance = null;    /** The file the properties got loaded from (including path info).     */    private String propsFile = PROPS_RESOURCE;    /** Construct a new APIConfig object. APIConfig follows the singleton     * pattern.     */    private APIConfig() {    }    /** Load the API properties. This method searches for the properties     * resource in a number of places and uses the     * <code>Class.getResourceAsStream</code> and the     * <code>Properties.load</code> method to load them.     */    private void loadAPIProperties() {	try {	    InputStream is = null;	    Class c = getClass();	    for (int i = 0; i < SEARCH_PATH.length && is == null; i++) {		propsFile = SEARCH_PATH[i] + PROPS_RESOURCE;		is = c.getResourceAsStream(propsFile);	    }	    if (is != null)		loadAPIPropertiesFromStream(is);	    else		logger.warn("Could not find API properties to load");	} catch (IOException x) {	    logger.warn("Could not load API properties", x);	}    }    /** Load the properties from a stream. This method actually just calls     * <code>Properties.load</code> but includes some useful debugging output     * too.     */    private void loadAPIPropertiesFromStream(InputStream stream) throws IOException {	load(stream);	if (logger.isDebugEnabled()) {	    logger.debug("Loaded API properties from " + propsFile);	    StringWriter w = new StringWriter();	    list(new PrintWriter(w));	    logger.debug("\n" + w.toString());	}    }    /** Cause the API properties to be reloaded. The properties will be read     * from the same location as they were initially loaded from. If the     * resource has disappeared or is no longer accessible, the properties will     * not be loaded and <code>false</code> will be returned to the caller.     * @return true if the properties were successfully reloaded, false     * otherwise.     */    public boolean reloadAPIConfig() {	logger.debug("Reloading API config properties.");	try {	    Class c = getClass();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -