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: 888296 $
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    
057        /**
058         * A POJO which contains all necessary configuration parameters for the SMPP connection
059         * 
060         * @param uri the full URI of the endpoint
061         */
062        public void configureFromURI(URI uri) {
063            setSystemId(uri.getUserInfo());
064            setHost(uri.getHost());
065            setPort(uri.getPort());
066        }
067    
068        public SmppConfiguration copy() {
069            try {
070                return (SmppConfiguration) clone();
071            } catch (CloneNotSupportedException e) {
072                throw new RuntimeCamelException(e);
073            }
074        }
075    
076        public String getHost() {
077            return host;
078        }
079    
080        public void setHost(String host) {
081            this.host = host;
082        }
083    
084        public Integer getPort() {
085            return port;
086        }
087    
088        public void setPort(Integer port) {
089            this.port = port;
090        }
091    
092        public String getSystemId() {
093            return systemId;
094        }
095    
096        public void setSystemId(String systemId) {
097            this.systemId = systemId;
098        }
099    
100        public String getPassword() {
101            return password;
102        }
103        
104        public String getEncoding() {
105            return encoding;
106        }
107    
108        public void setEncoding(String encoding) {
109            this.encoding = encoding;
110        }
111    
112        public void setPassword(String password) {
113            this.password = password;
114        }
115    
116        public Integer getEnquireLinkTimer() {
117            return enquireLinkTimer;
118        }
119    
120        public void setEnquireLinkTimer(Integer enquireLinkTimer) {
121            this.enquireLinkTimer = enquireLinkTimer;
122        }
123    
124        public Integer getTransactionTimer() {
125            return transactionTimer;
126        }
127    
128        public void setTransactionTimer(Integer transactionTimer) {
129            this.transactionTimer = transactionTimer;
130        }
131    
132        public String getSystemType() {
133            return systemType;
134        }
135    
136        public void setSystemType(String systemType) {
137            this.systemType = systemType;
138        }
139    
140        public byte getRegisteredDelivery() {
141            return registeredDelivery;
142        }
143    
144        public void setRegisteredDelivery(byte registeredDelivery) {
145            this.registeredDelivery = registeredDelivery;
146        }
147    
148        public String getServiceType() {
149            return serviceType;
150        }
151    
152        public void setServiceType(String serviceType) {
153            this.serviceType = serviceType;
154        }
155    
156        public byte getSourceAddrTon() {
157            return sourceAddrTon;
158        }
159    
160        public void setSourceAddrTon(byte sourceAddrTon) {
161            this.sourceAddrTon = sourceAddrTon;
162        }
163    
164        public byte getDestAddrTon() {
165            return destAddrTon;
166        }
167    
168        public void setDestAddrTon(byte destAddrTon) {
169            this.destAddrTon = destAddrTon;
170        }
171    
172        public byte getSourceAddrNpi() {
173            return sourceAddrNpi;
174        }
175    
176        public void setSourceAddrNpi(byte sourceAddrNpi) {
177            this.sourceAddrNpi = sourceAddrNpi;
178        }
179    
180        public byte getDestAddrNpi() {
181            return destAddrNpi;
182        }
183    
184        public void setDestAddrNpi(byte destAddrNpi) {
185            this.destAddrNpi = destAddrNpi;
186        }
187    
188        public byte getProtocolId() {
189            return protocolId;
190        }
191    
192        public void setProtocolId(byte protocolId) {
193            this.protocolId = protocolId;
194        }
195    
196        public byte getPriorityFlag() {
197            return priorityFlag;
198        }
199    
200        public void setPriorityFlag(byte priorityFlag) {
201            this.priorityFlag = priorityFlag;
202        }
203    
204        public byte getReplaceIfPresentFlag() {
205            return replaceIfPresentFlag;
206        }
207    
208        public void setReplaceIfPresentFlag(byte replaceIfPresentFlag) {
209            this.replaceIfPresentFlag = replaceIfPresentFlag;
210        }
211    
212        public String getSourceAddr() {
213            return sourceAddr;
214        }
215    
216        public void setSourceAddr(String sourceAddr) {
217            this.sourceAddr = sourceAddr;
218        }
219    
220        public String getDestAddr() {
221            return destAddr;
222        }
223    
224        public void setDestAddr(String destAddr) {
225            this.destAddr = destAddr;
226        }
227        
228        public byte getTypeOfNumber() {
229            return typeOfNumber;
230        }
231    
232        public void setTypeOfNumber(byte typeOfNumber) {
233            this.typeOfNumber = typeOfNumber;
234        }
235    
236        public byte getNumberingPlanIndicator() {
237            return numberingPlanIndicator;
238        }
239    
240        public void setNumberingPlanIndicator(byte numberingPlanIndicator) {
241            this.numberingPlanIndicator = numberingPlanIndicator;
242        }
243    
244        @Override
245        public String toString() {
246            return "SmppConfiguration[" + "enquireLinkTimer=" + enquireLinkTimer
247                    + ", host=" + host + ", password=" + password + ", port="
248                    + port + ", systemId=" + systemId + ", systemType="
249                    + systemType + ", transactionTimer=" + transactionTimer
250                    + ", registeredDelivery=" + registeredDelivery
251                    + ", serviceType=" + serviceType + ", sourceAddrTon="
252                    + sourceAddrTon + ", destAddrTon=" + destAddrTon
253                    + ", sourceAddrNpi=" + sourceAddrNpi + ", destAddrNpi="
254                    + destAddrNpi + ", protocolId=" + protocolId
255                    + ", priorityFlag=" + priorityFlag + ", replaceIfPresentFlag="
256                    + replaceIfPresentFlag + ", sourceAddr=" + sourceAddr 
257                    + ", destAddr=" + destAddr + "]";
258        }
259    }