Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add serialization support (while still keeping backwards compatibility) #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/AlertNotification.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

public class AlertNotification extends Pdu {

private static final long serialVersionUID = 1L;

protected Address sourceAddress;
protected Address esmeAddress;

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/BaseBind.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
*/
public abstract class BaseBind<R extends PduResponse> extends PduRequest<R> {

private static final long serialVersionUID = 1L;

private String systemId;
private String password;
private String systemType;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/BaseBindResp.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
*/
public abstract class BaseBindResp extends PduResponse {

private static final long serialVersionUID = 1L;

private String systemId;

public BaseBindResp(int commandId, String name) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/BaseSm.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
*/
public abstract class BaseSm<R extends PduResponse> extends PduRequest<R> {

private static final long serialVersionUID = 1L;

protected String serviceType;
protected Address sourceAddress;
protected Address destAddress;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/BaseSmResp.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
*/
public abstract class BaseSmResp extends PduResponse {

private static final long serialVersionUID = 1L;

private String messageId;

public BaseSmResp(int commandId, String name) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/BindReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*/
public class BindReceiver extends BaseBind<BindReceiverResp> {

private static final long serialVersionUID = 1L;

public BindReceiver() {
super(SmppConstants.CMD_ID_BIND_RECEIVER, "bind_receiver");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/BindReceiverResp.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*/
public class BindReceiverResp extends BaseBindResp {

private static final long serialVersionUID = 1L;

public BindReceiverResp() {
super(SmppConstants.CMD_ID_BIND_RECEIVER_RESP, "bind_receiver_resp");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/BindTransceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*/
public class BindTransceiver extends BaseBind<BindTransceiverResp> {

private static final long serialVersionUID = 1L;

public BindTransceiver() {
super(SmppConstants.CMD_ID_BIND_TRANSCEIVER, "bind_transceiver");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*/
public class BindTransceiverResp extends BaseBindResp {

private static final long serialVersionUID = 1L;

public BindTransceiverResp() {
super(SmppConstants.CMD_ID_BIND_TRANSCEIVER_RESP, "bind_transceiver_resp");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/BindTransmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

public class BindTransmitter extends BaseBind<BindTransmitterResp> {

private static final long serialVersionUID = 1L;

public BindTransmitter() {
super(SmppConstants.CMD_ID_BIND_TRANSMITTER, "bind_transmitter");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

public class BindTransmitterResp extends BaseBindResp {

private static final long serialVersionUID = 1L;

public BindTransmitterResp() {
super(SmppConstants.CMD_ID_BIND_TRANSMITTER_RESP, "bind_transmitter_resp");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/CancelSm.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
*/
public class CancelSm extends PduRequest<CancelSmResp> {

private static final long serialVersionUID = 1L;

protected String serviceType;
protected String messageId;
protected Address sourceAddress;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/CancelSmResp.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
*/
public class CancelSmResp extends PduResponse {

private static final long serialVersionUID = 1L;

public CancelSmResp() {
super(SmppConstants.CMD_ID_CANCEL_SM_RESP, "cancel_sm_resp");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/DataSm.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

public class DataSm extends BaseSm<DataSmResp> {

private static final long serialVersionUID = 1L;

public DataSm() {
super(SmppConstants.CMD_ID_DATA_SM, "data_sm");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/DataSmResp.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

public class DataSmResp extends BaseSmResp {

private static final long serialVersionUID = 1L;

public DataSmResp() {
super(SmppConstants.CMD_ID_DATA_SM_RESP, "data_sm_resp");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/DeliverSm.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

public class DeliverSm extends BaseSm<DeliverSmResp> {

private static final long serialVersionUID = 1L;

public DeliverSm() {
super(SmppConstants.CMD_ID_DELIVER_SM, "deliver_sm");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/DeliverSmResp.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

public class DeliverSmResp extends BaseSmResp {

private static final long serialVersionUID = 1L;

public DeliverSmResp() {
super(SmppConstants.CMD_ID_DELIVER_SM_RESP, "deliver_sm_resp");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/EmptyBody.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

public abstract class EmptyBody<R extends PduResponse> extends PduRequest<R> {

private static final long serialVersionUID = 1L;

public EmptyBody(int commandId, String name) {
super(commandId, name);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/EmptyBodyResp.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

public abstract class EmptyBodyResp extends PduResponse {

private static final long serialVersionUID = 1L;

public EmptyBodyResp(int commandId, String name) {
super(commandId, name);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/EnquireLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

public class EnquireLink extends EmptyBody<EnquireLinkResp> {

private static final long serialVersionUID = 1L;

public EnquireLink() {
super(SmppConstants.CMD_ID_ENQUIRE_LINK, "enquire_link");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/EnquireLinkResp.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

public class EnquireLinkResp extends EmptyBodyResp {

private static final long serialVersionUID = 1L;

public EnquireLinkResp() {
super(SmppConstants.CMD_ID_ENQUIRE_LINK_RESP, "enquire_link_resp");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/GenericNack.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

public class GenericNack extends PduResponse {

private static final long serialVersionUID = 1L;

public GenericNack() {
super(SmppConstants.CMD_ID_GENERIC_NACK, "generic_nack");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/PartialPdu.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

public class PartialPdu extends EmptyBody<GenericNack> {

private static final long serialVersionUID = 1L;

public PartialPdu(int commandId) {
super(commandId, "partial_pdu");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/PartialPduResp.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

public class PartialPduResp extends EmptyBodyResp {

private static final long serialVersionUID = 1L;

public PartialPduResp(int commandId) {
super(commandId, "partial_pdu_resp");
}
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/cloudhopper/smpp/pdu/Pdu.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@
import com.cloudhopper.smpp.tlv.Tlv;
import com.cloudhopper.smpp.transcoder.PduTranscoderContext;
import com.cloudhopper.smpp.util.ChannelBufferUtil;

import java.io.Serializable;
import java.util.ArrayList;
import org.jboss.netty.buffer.ChannelBuffer;

public abstract class Pdu {
public abstract class Pdu implements Serializable {

private static final long serialVersionUID = 1L;

private final String name;
private final boolean isRequest;
Expand All @@ -52,6 +56,7 @@ public Pdu(int commandId, String name, boolean isRequest) {
this.referenceObject = null;
}

// value has to implement Serializable if serialization is used
public void setReferenceObject(Object value) {
this.referenceObject = value;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/PduRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

public abstract class PduRequest<R extends PduResponse> extends Pdu {

private static final long serialVersionUID = 1L;

public PduRequest(int commandId, String name) {
super(commandId, name, true);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/PduResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

public abstract class PduResponse extends Pdu {

private static final long serialVersionUID = 1L;

private String resultMessage;

public PduResponse(int commandId, String name) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/QuerySm.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
*/
public class QuerySm extends PduRequest<QuerySmResp> {

private static final long serialVersionUID = 1L;

private String messageId;
private Address sourceAddress;

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/QuerySmResp.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
*/
public class QuerySmResp extends PduResponse {

private static final long serialVersionUID = 1L;

private String messageId;
private String finalDate;
private byte messageState;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/ReplaceSm.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

public class ReplaceSm extends PduRequest<ReplaceSmResp> {

private static final long serialVersionUID = 1L;

private String messageId;
private Address sourceAddress;
private String scheduleDeliveryTime;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/ReplaceSmResp.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

public class ReplaceSmResp extends PduResponse {

private static final long serialVersionUID = 1L;

public ReplaceSmResp() {
super(SmppConstants.CMD_ID_REPLACE_SM_RESP, "replace_sm_resp");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/SubmitSm.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

public class SubmitSm extends BaseSm<SubmitSmResp> {

private static final long serialVersionUID = 1L;

public SubmitSm() {
super(SmppConstants.CMD_ID_SUBMIT_SM, "submit_sm");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/SubmitSmResp.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

public class SubmitSmResp extends BaseSmResp {

private static final long serialVersionUID = 1L;

public SubmitSmResp() {
super(SmppConstants.CMD_ID_SUBMIT_SM_RESP, "submit_sm_resp");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/Unbind.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

public class Unbind extends EmptyBody<UnbindResp> {

private static final long serialVersionUID = 1L;

public Unbind() {
super(SmppConstants.CMD_ID_UNBIND, "unbind");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cloudhopper/smpp/pdu/UnbindResp.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

public class UnbindResp extends EmptyBodyResp {

private static final long serialVersionUID = 1L;

public UnbindResp() {
super(SmppConstants.CMD_ID_UNBIND_RESP, "unbind_resp");
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/cloudhopper/smpp/tlv/Tlv.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import com.cloudhopper.commons.util.ByteArrayUtil;
import com.cloudhopper.commons.util.HexUtil;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;

Expand All @@ -30,7 +32,9 @@
*
* @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public class Tlv {
public class Tlv implements Serializable {

private static final long serialVersionUID = 1L;

private final short tag;
private final byte[] value; // length is stored in array
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/cloudhopper/smpp/type/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@
import com.cloudhopper.smpp.util.PduUtil;
import org.jboss.netty.buffer.ChannelBuffer;

import java.io.Serializable;

/**
* Simple representation of an Address in SMPP.
*
* @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public class Address {
public class Address implements Serializable {

private static final long serialVersionUID = 1L;

private byte ton;
private byte npi;
Expand Down