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

📄 gatewayproperties.java

📁 Logica lastest SMPP API
💻 JAVA
字号:
package com.smpp.server;

import noNamespace.SMSCType;

import com.logica.smpp.Data;
import com.logica.smpp.debug.Debug;
import com.logica.smpp.debug.Event;
import com.logica.smpp.pdu.Address;
import com.logica.smpp.pdu.AddressRange;
import com.logica.smpp.pdu.WrongLengthOfStringException;

public class GatewayProperties {

	private String ipAddress = null;

	/**
	 * The port number to bind to on the SMSC server.
	 */
	private int port = 0;

	/**
	 * The name which identifies you to SMSC.
	 */
	private String systemId = null;

	/**
	 * The password for authentication to SMSC.
	 */
	private String password = null;

	/**
	 * How you want to bind to the SMSC: transmitter (t), receiver (r) or
	 * transciever (tr). Transciever can both send messages and receive
	 * messages. Note, that if you bind as receiver you can still receive
	 * responses to you requests (submissions).
	 */
	private String bindOption = "t";

	/**
	 * The range of addresses (mobile numbers) you want to receive messages
	 * from.
	 */
	private AddressRange addressRange = new AddressRange();

	/*
	 * for information about these variables have a look in SMP 3.4
	 * specification
	 */
	private String systemType = "";

	private String serviceType = "";

	private Address sourceAddress = new Address();

	private Address destAddress = new Address();

	private String scheduleDeliveryTime = "";

	private String validityPeriod = "";

	private String shortMessage = "From gateway";

	private String numberOfDestination = "1";

	private String messageId = "";

	private byte esmClass = 0;

	private byte protocolId = 0;

	private byte priorityFlag = 0;

	private byte registeredDelivery = 0;

	private byte replaceIfPresentFlag = 0;

	private byte dataCoding = 0;

	private byte smDefaultMsgId = 0;

	/**
	 * If you attemt to receive message, how long will the application wait for
	 * data.
	 */
	private long receiveTimeout = Data.RECEIVE_BLOCKING;

	private Debug debug = null;

	/**
	 * The event object.
	 */
	private Event event = null;

	private String routes;
	
	private String processingClass; 

	/**
	 * Initialises the application, lods default values for connection to SMSC
	 * and for various PDU fields.
	 */

	private boolean propertiesLoaded = false;

	protected GatewayProperties(SMSCType prop) {

		if (!propertiesLoaded)
			loadProperties(prop);

	}

	private void loadProperties(SMSCType properties) {

		byte ton;
		byte npi;
		String addr;
		String bindMode;
		int rcvTimeout;

		ipAddress = properties.getIpAddress();
		port = properties.getPort();
		systemId = properties.getSystemId();
		password = properties.getPassword();
		routes = properties.getRoutefor();
		
		processingClass = properties.getRequestProcessorClass();

		ton = properties.getAddrTon();
		npi = properties.getAddrNpi();
		addr = properties.getAddrRange();
		addressRange.setTon(ton);
		addressRange.setNpi(npi);
		try {
			addressRange.setAddressRange(addr);
		} catch (WrongLengthOfStringException e) {
			System.out
					.println("The length of address-range parameter is wrong.");
		}

		ton = properties.getSourceTon();
		npi = properties.getSourceNpi();
		addr = properties.getSourceaddr();
		setAddressParameter("source-address", sourceAddress, ton, npi, addr);

		ton = properties.getDestTon();
		npi = properties.getDestNpi();
		addr = properties.getDestAddr();
		setAddressParameter("destination-address", destAddress, ton, npi, addr);

		serviceType = properties.getServiceType();
		systemType = properties.getSystemType();

		bindMode = properties.getBindMode();

		if (bindMode.equalsIgnoreCase("transmitter")) {
			bindMode = "t";
		} else if (bindMode.equalsIgnoreCase("receiver")) {
			bindMode = "r";
		} else if (bindMode.equalsIgnoreCase("transciever")) {
			bindMode = "tr";
		} else if (!bindMode.equalsIgnoreCase("t")
				&& !bindMode.equalsIgnoreCase("r")
				&& !bindMode.equalsIgnoreCase("tr")) {
			System.out
					.println("The value of bind-mode parameter in the configuration file is wrong");
			bindMode = "t";
		}
		bindOption = bindMode;

		// receive timeout in the cfg file is in seconds, we need milliseconds
		// also conversion from -1 which indicates infinite blocking
		// in the cfg file to Data.RECEIVE_BLOCKING which indicates infinite
		// blocking in the library is needed.
		if (receiveTimeout == Data.RECEIVE_BLOCKING) {
			rcvTimeout = -1;
		} else {
			rcvTimeout = ((int) receiveTimeout) / 1000;
		}
		rcvTimeout = properties.getRcvTimeOut();
		if (rcvTimeout == -1) {
			receiveTimeout = Data.RECEIVE_BLOCKING;
		} else {
			receiveTimeout = rcvTimeout * 1000;
		}

		/*
		 * scheduleDeliveryTime validityPeriod shortMessage numberOfDestination
		 * messageId esmClass protocolId priorityFlag registeredDelivery
		 * replaceIfPresentFlag dataCoding smDefaultMsgId
		 */
		propertiesLoaded = true;
	}

	/**
	 * @return Returns the addressRange.
	 */
	public AddressRange getAddressRange() {
		return addressRange;
	}

	/**
	 * @return Returns the bindOption.
	 */
	public String getBindOption() {
		return bindOption;
	}

	/**
	 * @return Returns the dataCoding.
	 */
	public byte getDataCoding() {
		return dataCoding;
	}

	/**
	 * @return Returns the destAddress.
	 */
	public Address getDestAddress() {
		return destAddress;
	}

	/**
	 * @return Returns the esmClass.
	 */
	public byte getEsmClass() {
		return esmClass;
	}

	/**
	 * @return Returns the ipAddress.
	 */
	public String getIpAddress() {
		return ipAddress;
	}

	/**
	 * @return Returns the messageId.
	 */
	public String getMessageId() {
		return messageId;
	}

	/**
	 * @return Returns the numberOfDestination.
	 */
	public String getNumberOfDestination() {
		return numberOfDestination;
	}

	/**
	 * @return Returns the password.
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @return Returns the port.
	 */
	public int getPort() {
		return port;
	}

	/**
	 * @return Returns the priorityFlag.
	 */
	public byte getPriorityFlag() {
		return priorityFlag;
	}

	/**
	 * @return Returns the protocolId.
	 */
	public byte getProtocolId() {
		return protocolId;
	}

	/**
	 * @return Returns the receiveTimeout.
	 */
	public long getReceiveTimeout() {
		return receiveTimeout;
	}

	/**
	 * @return Returns the registeredDelivery.
	 */
	public byte getRegisteredDelivery() {
		return registeredDelivery;
	}

	/**
	 * @return Returns the replaceIfPresentFlag.
	 */
	public byte getReplaceIfPresentFlag() {
		return replaceIfPresentFlag;
	}

	/**
	 * @return Returns the scheduleDeliveryTime.
	 */
	public String getScheduleDeliveryTime() {
		return scheduleDeliveryTime;
	}

	/**
	 * @return Returns the serviceType.
	 */
	public String getServiceType() {
		return serviceType;
	}

	/**
	 * @return Returns the shortMessage.
	 */
	public String getShortMessage() {
		return shortMessage;
	}

	/**
	 * @return Returns the smDefaultMsgId.
	 */
	public byte getSmDefaultMsgId() {
		return smDefaultMsgId;
	}

	/**
	 * @return Returns the sourceAddress.
	 */
	public Address getSourceAddress() {
		return sourceAddress;
	}

	/**
	 * @return Returns the systemId.
	 */
	public String getSystemId() {
		return systemId;
	}

	/**
	 * @return Returns the systemType.
	 */
	public String getSystemType() {
		return systemType;
	}

	/**
	 * @return Returns the validityPeriod.
	 */
	public String getValidityPeriod() {
		return validityPeriod;
	}

	/**
	 * Gets a property and converts it into byte.
	 */

	/**
	 * Gets a property and converts it into integer.
	 */

	private void setAddressParameter(String descr, Address address, byte ton,
			byte npi, String addr) {
		address.setTon(ton);
		address.setNpi(npi);
		try {
			address.setAddress(addr);
		} catch (WrongLengthOfStringException e) {
			//System.out.println("The length of " + descr+ " parameter is wrong.");
			e.printStackTrace();
		}
	}

	/**
	 * @return Returns the debug.
	 */
	public Debug getDebug() {
		return debug;
	}

	/**
	 * @param debug
	 *            The debug to set.
	 */
	public void setDebug(Debug debug) {
		this.debug = debug;
	}

	/**
	 * @return Returns the event.
	 */
	public Event getEvent() {
		return event;
	}

	/**
	 * @param event
	 *            The event to set.
	 */
	public void setEvent(Event event) {
		this.event = event;
	}

	/**
	 * @return Returns the routes.
	 */
	public String getRoutes() {
		return routes;
	}

	public String getProcessingClass() {
		return processingClass;
	}

}

⌨️ 快捷键说明

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