001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.camel.component.smpp;
018
019 import java.net.URI;
020
021 import org.apache.camel.RuntimeCamelException;
022 import org.jsmpp.bean.NumberingPlanIndicator;
023 import org.jsmpp.bean.SMSCDeliveryReceipt;
024 import org.jsmpp.bean.TypeOfNumber;
025
026 /**
027 * Contains the SMPP component configuration properties</a>
028 *
029 * @version $Revision: 941133 $
030 * @author muellerc
031 */
032 public class SmppConfiguration implements Cloneable {
033
034 private String host = "localhost";
035 private Integer port = new Integer(2775);
036 private String systemId = "smppclient";
037 private String password = "password";
038 private String systemType = "cp";
039 private String encoding = "ISO-8859-1";
040 private Integer enquireLinkTimer = new Integer(5000);
041 private Integer transactionTimer = new Integer(10000);
042 private byte registeredDelivery = SMSCDeliveryReceipt.SUCCESS_FAILURE
043 .value();
044 private String serviceType = "CMT";
045 private String sourceAddr = "1616";
046 private String destAddr = "1717";
047 private byte sourceAddrTon = TypeOfNumber.UNKNOWN.value();
048 private byte destAddrTon = TypeOfNumber.UNKNOWN.value();
049 private byte sourceAddrNpi = NumberingPlanIndicator.UNKNOWN.value();
050 private byte destAddrNpi = NumberingPlanIndicator.UNKNOWN.value();
051 private byte protocolId = (byte) 0;
052 private byte priorityFlag = (byte) 1;
053 private byte replaceIfPresentFlag = (byte) 0;
054 private byte typeOfNumber = TypeOfNumber.UNKNOWN.value();
055 private byte numberingPlanIndicator = NumberingPlanIndicator.UNKNOWN.value();
056 private boolean usingSSL;
057
058 /**
059 * A POJO which contains all necessary configuration parameters for the SMPP connection
060 *
061 * @param uri the full URI of the endpoint
062 */
063 public void configureFromURI(URI uri) {
064 setSystemId(uri.getUserInfo());
065 setHost(uri.getHost());
066 setPort(uri.getPort());
067 if (uri.getScheme().startsWith("smpps")) {
068 setUsingSSL(true);
069 }
070 }
071
072 public SmppConfiguration copy() {
073 try {
074 return (SmppConfiguration) clone();
075 } catch (CloneNotSupportedException e) {
076 throw new RuntimeCamelException(e);
077 }
078 }
079
080 public String getHost() {
081 return host;
082 }
083
084 public void setHost(String host) {
085 this.host = host;
086 }
087
088 public Integer getPort() {
089 return port;
090 }
091
092 public void setPort(Integer port) {
093 this.port = port;
094 }
095
096 public String getSystemId() {
097 return systemId;
098 }
099
100 public void setSystemId(String systemId) {
101 this.systemId = systemId;
102 }
103
104 public String getPassword() {
105 return password;
106 }
107
108 public String getEncoding() {
109 return encoding;
110 }
111
112 public void setEncoding(String encoding) {
113 this.encoding = encoding;
114 }
115
116 public void setPassword(String password) {
117 this.password = password;
118 }
119
120 public Integer getEnquireLinkTimer() {
121 return enquireLinkTimer;
122 }
123
124 public void setEnquireLinkTimer(Integer enquireLinkTimer) {
125 this.enquireLinkTimer = enquireLinkTimer;
126 }
127
128 public Integer getTransactionTimer() {
129 return transactionTimer;
130 }
131
132 public void setTransactionTimer(Integer transactionTimer) {
133 this.transactionTimer = transactionTimer;
134 }
135
136 public String getSystemType() {
137 return systemType;
138 }
139
140 public void setSystemType(String systemType) {
141 this.systemType = systemType;
142 }
143
144 public byte getRegisteredDelivery() {
145 return registeredDelivery;
146 }
147
148 public void setRegisteredDelivery(byte registeredDelivery) {
149 this.registeredDelivery = registeredDelivery;
150 }
151
152 public String getServiceType() {
153 return serviceType;
154 }
155
156 public void setServiceType(String serviceType) {
157 this.serviceType = serviceType;
158 }
159
160 public byte getSourceAddrTon() {
161 return sourceAddrTon;
162 }
163
164 public void setSourceAddrTon(byte sourceAddrTon) {
165 this.sourceAddrTon = sourceAddrTon;
166 }
167
168 public byte getDestAddrTon() {
169 return destAddrTon;
170 }
171
172 public void setDestAddrTon(byte destAddrTon) {
173 this.destAddrTon = destAddrTon;
174 }
175
176 public byte getSourceAddrNpi() {
177 return sourceAddrNpi;
178 }
179
180 public void setSourceAddrNpi(byte sourceAddrNpi) {
181 this.sourceAddrNpi = sourceAddrNpi;
182 }
183
184 public byte getDestAddrNpi() {
185 return destAddrNpi;
186 }
187
188 public void setDestAddrNpi(byte destAddrNpi) {
189 this.destAddrNpi = destAddrNpi;
190 }
191
192 public byte getProtocolId() {
193 return protocolId;
194 }
195
196 public void setProtocolId(byte protocolId) {
197 this.protocolId = protocolId;
198 }
199
200 public byte getPriorityFlag() {
201 return priorityFlag;
202 }
203
204 public void setPriorityFlag(byte priorityFlag) {
205 this.priorityFlag = priorityFlag;
206 }
207
208 public byte getReplaceIfPresentFlag() {
209 return replaceIfPresentFlag;
210 }
211
212 public void setReplaceIfPresentFlag(byte replaceIfPresentFlag) {
213 this.replaceIfPresentFlag = replaceIfPresentFlag;
214 }
215
216 public String getSourceAddr() {
217 return sourceAddr;
218 }
219
220 public void setSourceAddr(String sourceAddr) {
221 this.sourceAddr = sourceAddr;
222 }
223
224 public String getDestAddr() {
225 return destAddr;
226 }
227
228 public void setDestAddr(String destAddr) {
229 this.destAddr = destAddr;
230 }
231
232 public byte getTypeOfNumber() {
233 return typeOfNumber;
234 }
235
236 public void setTypeOfNumber(byte typeOfNumber) {
237 this.typeOfNumber = typeOfNumber;
238 }
239
240 public byte getNumberingPlanIndicator() {
241 return numberingPlanIndicator;
242 }
243
244 public void setNumberingPlanIndicator(byte numberingPlanIndicator) {
245 this.numberingPlanIndicator = numberingPlanIndicator;
246 }
247
248 public boolean getUsingSSL() {
249 return usingSSL;
250 }
251
252 public void setUsingSSL(boolean usingSSL) {
253 this.usingSSL = usingSSL;
254 }
255
256 @Override
257 public String toString() {
258 return "SmppConfiguration[" + "enquireLinkTimer=" + enquireLinkTimer
259 + ", host=" + host + ", password=" + password + ", port="
260 + port + ", systemId=" + systemId + ", systemType="
261 + systemType + ", transactionTimer=" + transactionTimer
262 + ", registeredDelivery=" + registeredDelivery
263 + ", serviceType=" + serviceType + ", sourceAddrTon="
264 + sourceAddrTon + ", destAddrTon=" + destAddrTon
265 + ", sourceAddrNpi=" + sourceAddrNpi + ", destAddrNpi="
266 + destAddrNpi + ", protocolId=" + protocolId
267 + ", priorityFlag=" + priorityFlag + ", replaceIfPresentFlag="
268 + replaceIfPresentFlag + ", sourceAddr=" + sourceAddr
269 + ", destAddr=" + destAddr + "]";
270 }
271 }