Permalink
Browse files

Large cleanup of javadocs and comments; added full apache license

  • Loading branch information...
jjlauer committed May 4, 2011
1 parent 04a9622 commit eabd7234bd1e922279b81f4ff82a599792f5d529
Showing with 494 additions and 266 deletions.
  1. +1 −1 src/main/java/com/cloudhopper/smpp/PduAsyncResponse.java
  2. +1 −1 src/main/java/com/cloudhopper/smpp/SmppBindType.java
  3. +16 −7 src/main/java/com/cloudhopper/smpp/SmppClient.java
  4. +5 −2 src/main/java/com/cloudhopper/smpp/SmppConstants.java
  5. +1 −1 src/main/java/com/cloudhopper/smpp/SmppServer.java
  6. +45 −4 src/main/java/com/cloudhopper/smpp/SmppServerConfiguration.java
  7. +1 −1 src/main/java/com/cloudhopper/smpp/SmppServerHandler.java
  8. +1 −1 src/main/java/com/cloudhopper/smpp/SmppServerSession.java
  9. +13 −4 src/main/java/com/cloudhopper/smpp/SmppSession.java
  10. +2 −2 src/main/java/com/cloudhopper/smpp/SmppSessionConfiguration.java
  11. +1 −1 src/main/java/com/cloudhopper/smpp/SmppSessionHandler.java
  12. +1 −1 src/main/java/com/cloudhopper/smpp/channel/ChannelUtil.java
  13. +1 −1 src/main/java/com/cloudhopper/smpp/channel/SmppChannelConstants.java
  14. +1 −1 src/main/java/com/cloudhopper/smpp/channel/SmppClientConnector.java
  15. +2 −0 src/main/java/com/cloudhopper/smpp/channel/SmppServerConnector.java
  16. +1 −1 src/main/java/com/cloudhopper/smpp/channel/SmppSessionLogger.java
  17. +1 −1 src/main/java/com/cloudhopper/smpp/channel/SmppSessionPduDecoder.java
  18. +1 −1 src/main/java/com/cloudhopper/smpp/channel/SmppSessionThreadRenamer.java
  19. +1 −1 src/main/java/com/cloudhopper/smpp/channel/SmppSessionWrapper.java
  20. +1 −1 src/main/java/com/cloudhopper/smpp/impl/DefaultPduAsyncResponse.java
  21. +48 −24 src/main/java/com/cloudhopper/smpp/impl/DefaultSmppClient.java
  22. +37 −5 src/main/java/com/cloudhopper/smpp/impl/DefaultSmppServer.java
  23. +13 −41 src/main/java/com/cloudhopper/smpp/impl/DefaultSmppSession.java
  24. +1 −1 src/main/java/com/cloudhopper/smpp/impl/DefaultSmppSessionHandler.java
  25. +12 −2 src/main/java/com/cloudhopper/smpp/impl/PollableSmppSessionHandler.java
  26. +1 −1 src/main/java/com/cloudhopper/smpp/impl/SmppSessionChannelListener.java
  27. +12 −3 src/main/java/com/cloudhopper/smpp/impl/UnboundSmppSession.java
  28. +4 −1 src/main/java/com/cloudhopper/smpp/pdu/BaseBind.java
  29. +4 −1 src/main/java/com/cloudhopper/smpp/pdu/BaseBindResp.java
  30. +4 −0 src/main/java/com/cloudhopper/smpp/pdu/BaseSm.java
  31. +4 −1 src/main/java/com/cloudhopper/smpp/pdu/BaseSmResp.java
  32. +4 −0 src/main/java/com/cloudhopper/smpp/pdu/BindReceiver.java
  33. +4 −0 src/main/java/com/cloudhopper/smpp/pdu/BindReceiverResp.java
  34. +4 −0 src/main/java/com/cloudhopper/smpp/pdu/BindTransceiver.java
  35. +4 −0 src/main/java/com/cloudhopper/smpp/pdu/BindTransceiverResp.java
  36. +1 −1 src/main/java/com/cloudhopper/smpp/simulator/SmppSimulatorBindProcessor.java
  37. +1 −1 src/main/java/com/cloudhopper/smpp/simulator/SmppSimulatorPduProcessor.java
  38. +1 −1 src/main/java/com/cloudhopper/smpp/simulator/SmppSimulatorServer.java
  39. +1 −1 src/main/java/com/cloudhopper/smpp/simulator/SmppSimulatorServerHandler.java
  40. +1 −1 src/main/java/com/cloudhopper/smpp/simulator/SmppSimulatorSessionHandler.java
  41. +5 −0 src/main/java/com/cloudhopper/smpp/tlv/Tlv.java
  42. +1 −2 src/main/java/com/cloudhopper/smpp/tlv/TlvConvertException.java
  43. +6 −0 src/main/java/com/cloudhopper/smpp/transcoder/DefaultPduTranscoder.java
  44. +3 −1 src/main/java/com/cloudhopper/smpp/transcoder/DefaultPduTranscoderContext.java
  45. +1 −1 src/main/java/com/cloudhopper/smpp/transcoder/PduTranscoder.java
  46. +1 −1 src/main/java/com/cloudhopper/smpp/transcoder/PduTranscoderContext.java
  47. +1 −1 src/main/java/com/cloudhopper/smpp/type/Address.java
  48. +1 −1 src/main/java/com/cloudhopper/smpp/type/GenericNackException.java
  49. +1 −0 src/main/java/com/cloudhopper/smpp/type/LoggingOptions.java
  50. +1 −1 src/main/java/com/cloudhopper/smpp/type/NotEnoughDataInBufferException.java
  51. +1 −1 src/main/java/com/cloudhopper/smpp/type/RecoverablePduException.java
  52. +1 −1 src/main/java/com/cloudhopper/smpp/type/SmppBindException.java
  53. +1 −1 src/main/java/com/cloudhopper/smpp/type/SmppChannelConnectException.java
  54. +1 −1 src/main/java/com/cloudhopper/smpp/type/SmppChannelConnectTimeoutException.java
  55. +1 −1 src/main/java/com/cloudhopper/smpp/type/SmppChannelException.java
  56. +1 −1 src/main/java/com/cloudhopper/smpp/type/SmppConnectionConfiguration.java
  57. +1 −1 src/main/java/com/cloudhopper/smpp/type/SmppProcessingException.java
  58. +1 −1 src/main/java/com/cloudhopper/smpp/type/SmppTimeoutException.java
  59. +1 −1 src/main/java/com/cloudhopper/smpp/type/TerminatingNullByteNotFoundException.java
  60. +1 −1 src/main/java/com/cloudhopper/smpp/type/UnexpectedPduResponseException.java
  61. +1 −1 src/main/java/com/cloudhopper/smpp/type/UnknownCommandIdException.java
  62. +1 −1 src/main/java/com/cloudhopper/smpp/type/UnrecoverablePduException.java
  63. +1 −1 src/main/java/com/cloudhopper/smpp/util/ChannelBufferUtil.java
  64. +1 −1 src/main/java/com/cloudhopper/smpp/util/DaemonExecutors.java
  65. +1 −1 src/main/java/com/cloudhopper/smpp/util/DeliveryReceipt.java
  66. +1 −1 src/main/java/com/cloudhopper/smpp/util/DeliveryReceiptException.java
  67. +1 −1 src/main/java/com/cloudhopper/smpp/util/InvalidSequenceNumberException.java
  68. +1 −1 src/main/java/com/cloudhopper/smpp/util/PduUtil.java
  69. +1 −1 src/main/java/com/cloudhopper/smpp/util/SequenceNumber.java
  70. +1 −1 src/main/java/com/cloudhopper/smpp/util/SmppSessionUtil.java
  71. +1 −1 src/main/java/com/cloudhopper/smpp/util/SmppUtil.java
  72. +1 −1 src/main/java/com/cloudhopper/smpp/util/TlvUtil.java
  73. +106 −66 src/test/java/com/cloudhopper/smpp/demo/ClientMain.java
  74. +1 −1 src/test/java/com/cloudhopper/smpp/demo/DeliveryReceiptMain.java
  75. +1 −1 src/test/java/com/cloudhopper/smpp/demo/ParserMain.java
  76. +1 −1 src/test/java/com/cloudhopper/smpp/demo/RebindMain.java
  77. +40 −4 src/test/java/com/cloudhopper/smpp/demo/ServerMain.java
  78. +2 −12 src/test/java/com/cloudhopper/smpp/demo/SimulatorMain.java
  79. +3 −2 src/test/java/com/cloudhopper/smpp/demo/SlowServerMain.java
  80. +1 −1 src/test/java/com/cloudhopper/smpp/impl/DefaultSmppServerTest.java
  81. +26 −18 src/test/java/com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java
  82. +1 −1 src/test/java/com/cloudhopper/smpp/pdu/BufferHelper.java
  83. +1 −1 src/test/java/com/cloudhopper/smpp/pdu/PduTest.java
  84. +2 −2 src/test/java/com/cloudhopper/smpp/tlv/TlvTest.java
  85. +1 −1 src/test/java/com/cloudhopper/smpp/transcoder/PduDecoderTest.java
  86. +1 −1 src/test/java/com/cloudhopper/smpp/transcoder/PduEncoderTest.java
  87. +1 −1 src/test/java/com/cloudhopper/smpp/util/ChannelBufferUtilTest.java
  88. +1 −1 src/test/java/com/cloudhopper/smpp/util/DeliveryReceiptTest.java
  89. +1 −1 src/test/java/com/cloudhopper/smpp/util/PduUtilTest.java
  90. +1 −1 src/test/java/com/cloudhopper/smpp/util/SequenceNumberTest.java
  91. +1 −1 src/test/java/com/cloudhopper/smpp/util/SmppUtilTest.java
  92. +1 −1 src/test/java/com/cloudhopper/smpp/util/TlvUtilTest.java
@@ -22,7 +22,7 @@
* internally by an SmppSession. For example, an instance of this class will
* contain the original request, the response, and the processing time.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public interface PduAsyncResponse {
@@ -17,7 +17,7 @@
/**
* Enumeration of all SMPP session types.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public enum SmppBindType {
@@ -22,17 +22,18 @@
/**
* Interface representing an SmppClient.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public interface SmppClient {
/**
- *
- * @param config
- * @param sessionHandler
- * @return
+ * Binds a client to a remote SMPP endpoint by opening the socket, sending
+ * a bind request, and waiting for a bind response.
+ * @param config The client session configuration
+ * @param sessionHandler The session handler
+ * @return If the bind is successful will be the new session
* @throws SmppTimeoutException Thrown if either the underlying TCP/IP connection
- * cannot connect within the "connectTimeout" or we can connect, but don't
+ * cannot connect within the "connectTimeout" or we can connect but don't
* receive a response back to the bind request within the "bindTimeout".
* @throws SmppChannelException Thrown if there is an error with the underlying
* TCP/IP connection such as a bad host name or the remote server's port
@@ -42,12 +43,20 @@
* a "bind" response that rejected the bind attempt.
* @throws UnrecoverablePduException Thrown in the case where we were able
* to connect and send our "bind" request, but we got back data that
- * was not parseable to a valid PDU.
+ * was not failed parsing into a PDU.
* @throws InterruptedException Thrown if the calling thread is interrupted
* while we are attempting the bind.
*/
SmppSession bind(SmppSessionConfiguration config, SmppSessionHandler sessionHandler) throws SmppTimeoutException, SmppChannelException, SmppBindException, UnrecoverablePduException, InterruptedException;
+ /**
+ * Shutdown a client by ensuring that all session sockets are closed and all
+ * resources are cleaned up. This method should the <b>last</b> method called
+ * before discarding or losing a reference to a client. Since this method
+ * cleans up all resources, make sure that any data you need to access is
+ * accessed <b>before</b> calling this method. After calling this method
+ * it is not guaranteed that <b>any</b> other method will correctly work.
+ */
void shutdown();
}
@@ -21,7 +21,7 @@
/**
* All constants defined for the SMPP protocol.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public class SmppConstants {
@@ -46,7 +46,10 @@
public static final long DEFAULT_CONNECT_TIMEOUT = 10000;
public static final long DEFAULT_BIND_TIMEOUT = 5000;
public static final long DEFAULT_REQUEST_EXPIRY_TIMEOUT = -1; // disabled
-
+ public static final long DEFAULT_WINDOW_MONITOR_INTERVAL = -1; // disabled
+ public static final int DEFAULT_SERVER_MAX_CONNECTIONS = 100;
+ public static final boolean DEFAULT_SERVER_NON_BLOCKING_SOCKETS_ENABLED = true;
+ public static final boolean DEFAULT_SERVER_REUSE_ADDRESS = true;
//
// SUBMIT_MULTI destination type flags
@@ -19,7 +19,7 @@
/**
* Interface representing an SmppServer.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public interface SmppServer {
@@ -17,7 +17,7 @@
/**
* Configuration of an SMPP server.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public class SmppServerConfiguration {
@@ -38,6 +38,11 @@
private int maxConnections;
private boolean nonBlockingSocketsEnabled;
private boolean reuseAddress;
+ // default request expiry timeout on server sessions
+ private int defaultWindowSize = SmppConstants.DEFAULT_WINDOW_SIZE;
+ private long defaultWindowWaitTimeout = SmppConstants.DEFAULT_WINDOW_WAIT_TIMEOUT;
+ private long defaultRequestExpiryTimeout = SmppConstants.DEFAULT_REQUEST_EXPIRY_TIMEOUT;
+ private long defaultWindowMonitorInterval = SmppConstants.DEFAULT_WINDOW_MONITOR_INTERVAL;
public SmppServerConfiguration() {
this.name = "SmppServer";
@@ -46,9 +51,13 @@ public SmppServerConfiguration() {
this.systemId = "cloudhopper";
this.autoNegotiateInterfaceVersion = true;
this.interfaceVersion = SmppConstants.VERSION_3_4;
- this.maxConnections = 100;
- this.nonBlockingSocketsEnabled = true;
- this.reuseAddress = true;
+ this.maxConnections = SmppConstants.DEFAULT_SERVER_MAX_CONNECTIONS;
+ this.nonBlockingSocketsEnabled = SmppConstants.DEFAULT_SERVER_NON_BLOCKING_SOCKETS_ENABLED;
+ this.reuseAddress = SmppConstants.DEFAULT_SERVER_REUSE_ADDRESS;
+ this.defaultWindowSize = SmppConstants.DEFAULT_WINDOW_SIZE;
+ this.defaultWindowWaitTimeout = SmppConstants.DEFAULT_WINDOW_WAIT_TIMEOUT;
+ this.defaultRequestExpiryTimeout = SmppConstants.DEFAULT_REQUEST_EXPIRY_TIMEOUT;
+ this.defaultWindowMonitorInterval = SmppConstants.DEFAULT_WINDOW_MONITOR_INTERVAL;
}
public boolean isReuseAddress() {
@@ -158,5 +167,37 @@ public byte getInterfaceVersion() {
public void setInterfaceVersion(byte interfaceVersion) {
this.interfaceVersion = interfaceVersion;
}
+
+ public long getDefaultRequestExpiryTimeout() {
+ return defaultRequestExpiryTimeout;
+ }
+
+ public void setDefaultRequestExpiryTimeout(long defaultRequestExpiryTimeout) {
+ this.defaultRequestExpiryTimeout = defaultRequestExpiryTimeout;
+ }
+
+ public long getDefaultWindowMonitorInterval() {
+ return defaultWindowMonitorInterval;
+ }
+
+ public void setDefaultWindowMonitorInterval(long defaultWindowMonitorInterval) {
+ this.defaultWindowMonitorInterval = defaultWindowMonitorInterval;
+ }
+
+ public int getDefaultWindowSize() {
+ return defaultWindowSize;
+ }
+
+ public void setDefaultWindowSize(int defaultWindowSize) {
+ this.defaultWindowSize = defaultWindowSize;
+ }
+
+ public long getDefaultWindowWaitTimeout() {
+ return defaultWindowWaitTimeout;
+ }
+
+ public void setDefaultWindowWaitTimeout(long defaultWindowWaitTimeout) {
+ this.defaultWindowWaitTimeout = defaultWindowWaitTimeout;
+ }
}
@@ -28,7 +28,7 @@
* 3) If sessionBindRequested is ok, creates a new session, and calls sessionCreated
* 4) When socket/channel is closed, calls sessionDestroyed
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public interface SmppServerHandler {
@@ -17,7 +17,7 @@
/**
* An extended interface for a Server (SMSC) SMPP session.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public interface SmppServerSession extends SmppSession {
@@ -31,7 +31,7 @@
* Defines a common interface for either a Client (ESME) or Server (SMSC) SMPP
* session.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public interface SmppSession {
@@ -45,7 +45,7 @@
CLIENT
}
- /** Session is in an intial state (not connected, but created) */
+ /** Session is in an initial state (not connected, but created) */
static public final int STATE_INITIAL = 0;
/** Session is connected and a bind is pending */
static public final int STATE_OPEN = 1;
@@ -54,7 +54,7 @@
static public final int STATE_BINDING = 2;
/** Session is bound (ready to process requests) */
static public final int STATE_BOUND = 3;
- /** Session is in the process of unbinding. This may have been initiated by us or them. */
+ /** Session is in the process of un-binding. This may have been initiated by us or them. */
static public final int STATE_UNBINDING = 4;
/** Session is unbound and closed (destroyed) */
static public final int STATE_CLOSED = 5;
@@ -99,7 +99,6 @@
*/
public String getStateName();
-
/**
* Gets the interface version currently in use between local and remote
* endpoints. This interface version is negotiated during the bind process
@@ -197,6 +196,16 @@
* @see #close()
*/
public void unbind(long timeoutInMillis);
+
+ /**
+ * Shutdown a session by ensuring the socket is closed and all
+ * resources are cleaned up. This method should the <b>last</b> method called
+ * before discarding or losing a reference to a session. Since this method
+ * cleans up all resources, make sure that any data you need to access is
+ * accessed <b>before</b> calling this method. After calling this method
+ * it is not guaranteed that <b>any</b> other method will correctly work.
+ */
+ public void shutdown();
/**
* Synchronously sends an "enquire_link" request to the remote endpoint and
@@ -21,7 +21,7 @@
/**
* Configuration to bind an SmppSession as an ESME to an SMSC.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public class SmppSessionConfiguration extends SmppConnectionConfiguration {
@@ -62,7 +62,7 @@ public SmppSessionConfiguration(SmppBindType type, String systemId, String passw
this.loggingOptions = new LoggingOptions();
this.windowWaitTimeout = SmppConstants.DEFAULT_WINDOW_WAIT_TIMEOUT;
this.requestExpiryTimeout = SmppConstants.DEFAULT_REQUEST_EXPIRY_TIMEOUT;
- this.windowMonitorInterval = -1;
+ this.windowMonitorInterval = SmppConstants.DEFAULT_WINDOW_MONITOR_INTERVAL;
}
public void setName(String value) {
@@ -23,7 +23,7 @@
/**
* Handles events received on an SmppSession.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public interface SmppSessionHandler extends PduTranscoderContext {
@@ -20,7 +20,7 @@
/**
* Utility methods for working with Netty Channels.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public class ChannelUtil {
@@ -17,7 +17,7 @@
/**
* Constants used for SMPP channels and pipelines.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public class SmppChannelConstants {
@@ -31,7 +31,7 @@
* nothing should actually be received so its safe to have a handler that does
* nothing.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
@ChannelPipelineCoverage("all")
public class SmppClientConnector extends SimpleChannelUpstreamHandler {
@@ -28,6 +28,8 @@
/**
* Channel handler for server SMPP sessions.
+ *
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
@ChannelPipelineCoverage("all")
public class SmppServerConnector extends SimpleChannelUpstreamHandler {
@@ -32,7 +32,7 @@
* SmppSession. The internal "options" object is tied directly to the SmppSession
* so that changes can be made on-the-fly during runtime.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
@ChannelPipelineCoverage("one")
public class SmppSessionLogger implements ChannelUpstreamHandler, ChannelDownstreamHandler {
@@ -24,7 +24,7 @@
* Channel handler responsible for decoding a ChannelBuffer into a PDU. A
* decoded PDU is then passed up the pipeline for further processing.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public class SmppSessionPduDecoder extends FrameDecoder {
@@ -26,7 +26,7 @@
* handler should be the first one in the pipeline to make sure all handlers
* after it have the correct thread name for proper logging.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
@ChannelPipelineCoverage("one")
public class SmppSessionThreadRenamer implements ChannelUpstreamHandler {
@@ -27,7 +27,7 @@
/**
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
@ChannelPipelineCoverage("one")
public class SmppSessionWrapper extends SimpleChannelHandler {
@@ -23,7 +23,7 @@
/**
* Default implementation of an SmppAsyncResponse.
*
- * @author joelauer
+ * @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public class DefaultPduAsyncResponse implements PduAsyncResponse {
// we internally "wrap" a PDU window future
Oops, something went wrong.

0 comments on commit eabd723

Please sign in to comment.