Commit f344c2ef authored by Dele Olajide's avatar Dele Olajide

Merge branch 'master' of https://github.com/deleolajide/Openfire

parents c1024520 2b66e746
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Stomp Plugin Changelog</title>
<style type="text/css">
BODY {
font-size : 100%;
}
BODY, TD, TH {
font-family : tahoma, verdana, arial, helvetica, sans-serif;
font-size : 0.8em;
}
H2 {
font-size : 10pt;
font-weight : bold;
padding-left : 1em;
}
A:hover {
text-decoration : none;
}
H1 {
font-family : tahoma, arial, helvetica, sans-serif;
font-size : 1.4em;
font-weight: bold;
border-bottom : 1px #ccc solid;
padding-bottom : 2px;
}
TT {
font-family : courier new;
font-weight : bold;
color : #060;
}
PRE {
font-family : courier new;
font-size : 100%;
}
</style>
</head>
<body>
<h1>
Stomp Plugin Changelog
</h1>
<p><b>1.0.0</b> -- October 20th, 2014</p>
<ul>
<li>Initial release.</li>
</ul>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<class>org.jivesoftware.openfire.plugin.StompPlugin</class>
<name>Stomp Plugin</name>
<description>Simple (or Streaming) Text Oriented Message Protocol (STOMP)</description>
<author>Ignite Realtime Community</author>
<version>0.0.1</version>
<date>09/20/2014</date>
<minServerVersion>3.10.0</minServerVersion>
</plugin>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Stomp Plugin Readme</title>
<style type="text/css">
BODY {
font-size : 100%;
}
BODY, TD, TH {
font-family : tahoma, verdana, arial, helvetica, sans-serif;
font-size : 0.8em;
}
H2 {
font-size : 10pt;
font-weight : bold;
}
A:hover {
text-decoration : none;
}
H1 {
font-family : tahoma, arial, helvetica, sans-serif;
font-size : 1.4em;
font-weight: bold;
border-bottom : 1px #ccc solid;
padding-bottom : 2px;
}
TT {
font-family : courier new;
font-weight : bold;
color : #060;
}
PRE {
font-family : courier new;
font-size : 100%;
}
</style>
</head>
<body>
<h1>
Stomp Plugin Readme
</h1>
<h2>Overview</h2>
<p>
The plugin implements a simple text-based protocol, designed for working with message-oriented middleware. It provides an interoperable wire format that allows STOMP clients to talk with any message broker supporting the protocol. It is thus language-agnostic, meaning a broker developed for one language or platform can receive communications from client software developed in another language.
</p>
</body>
</html>
This diff is collapsed.
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.message.AbstractBodyMessageHeader;
/**
* The Class AbstractClientBodyMessageHeader.
*/
@StampyLibrary(libraryName="stampy-core")
public class AbstractClientBodyMessageHeader extends AbstractBodyMessageHeader implements ClientMessageHeader {
private static final long serialVersionUID = -4466902797463186691L;
/**
* Sets the receipt.
*
* @param receipt
* the new receipt
*/
public void setReceipt(String receipt) {
addHeader(RECEIPT, receipt);
}
/*
* (non-Javadoc)
*
* @see asia.stampy.client.message.ClientMessageHeader#getReceipt()
*/
@Override
public String getReceipt() {
return getHeaderValue(RECEIPT);
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.message.AbstractMessageHeader;
/**
* The Class AbstractClientMessageHeader.
*/
@StampyLibrary(libraryName="stampy-core")
public class AbstractClientMessageHeader extends AbstractMessageHeader implements ClientMessageHeader {
private static final long serialVersionUID = -6352998102776340557L;
/**
* Sets the receipt.
*
* @param receipt
* the new receipt
*/
public void setReceipt(String receipt) {
addHeader(RECEIPT, receipt);
}
/*
* (non-Javadoc)
*
* @see asia.stampy.client.message.ClientMessageHeader#getReceipt()
*/
@Override
public String getReceipt() {
return getHeaderValue(RECEIPT);
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message;
import asia.stampy.common.StampyLibrary;
/**
* <i>any client frame other than CONNECT MAY specify a receipt header with an
* arbitrary value. This will cause the server to acknowledge the processing of
* the client frame with a RECEIPT frame</i>
*/
@StampyLibrary(libraryName="stampy-core")
public interface ClientMessageHeader {
/** The Constant RECEIPT. */
public static final String RECEIPT = "receipt";
/**
* Gets the receipt.
*
* @return the receipt
*/
String getReceipt();
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.abort;
import asia.stampy.client.message.AbstractClientMessageHeader;
import asia.stampy.common.StampyLibrary;
/**
* The Class AbortHeader.
*/
@StampyLibrary(libraryName="stampy-core")
public class AbortHeader extends AbstractClientMessageHeader {
private static final long serialVersionUID = 5682449671872257059L;
/** The Constant TRANSACTION. */
public static final String TRANSACTION = "transaction";
/**
* Sets the transaction.
*
* @param transaction
* the new transaction
*/
public void setTransaction(String transaction) {
addHeader(TRANSACTION, transaction);
}
/**
* Gets the transaction.
*
* @return the transaction
*/
public String getTransaction() {
return getHeaderValue(TRANSACTION);
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.abort;
import org.apache.commons.lang.StringUtils;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.message.AbstractMessage;
import asia.stampy.common.message.InvalidStompMessageException;
import asia.stampy.common.message.StompMessageType;
/**
* The Class AbortMessage.
*/
@StampyLibrary(libraryName="stampy-core")
public class AbortMessage extends AbstractMessage<AbortHeader> {
private static final long serialVersionUID = -7511003273041211848L;
/**
* Instantiates a new abort message.
*
* @param transaction
* the transaction
*/
public AbortMessage(String transaction) {
this();
getHeader().setTransaction(transaction);
}
/**
* Instantiates a new abort message.
*/
public AbortMessage() {
super(StompMessageType.ABORT);
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#createNewHeader()
*/
@Override
protected AbortHeader createNewHeader() {
return new AbortHeader();
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#validate()
*/
@Override
public void validate() {
if (StringUtils.isEmpty(getHeader().getTransaction())) {
throw new InvalidStompMessageException(AbortHeader.TRANSACTION + " is required");
}
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides the STOMP 1.2 ABORT header and message classes
</body>
</html>
\ No newline at end of file
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.ack;
import asia.stampy.client.message.AbstractClientMessageHeader;
import asia.stampy.common.StampyLibrary;
/**
* The Class AckHeader.
*/
@StampyLibrary(libraryName="stampy-core")
public class AckHeader extends AbstractClientMessageHeader {
private static final long serialVersionUID = 5190052881939069233L;
/** The Constant TRANSACTION. */
public static final String TRANSACTION = "transaction";
/** The Constant ID. */
public static final String ID = "id";
/**
* Sets the id.
*
* @param id
* the new id
*/
public void setId(String id) {
addHeader(ID, id);
}
/**
* Gets the id.
*
* @return the id
*/
public String getId() {
return getHeaderValue(ID);
}
/**
* Sets the transaction.
*
* @param transaction
* the new transaction
*/
public void setTransaction(String transaction) {
addHeader(TRANSACTION, transaction);
}
/**
* Gets the transaction.
*
* @return the transaction
*/
public String getTransaction() {
return getHeaderValue(TRANSACTION);
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.ack;
import org.apache.commons.lang.StringUtils;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.message.AbstractMessage;
import asia.stampy.common.message.InvalidStompMessageException;
import asia.stampy.common.message.StompMessageType;
/**
* The Class AckMessage.
*/
@StampyLibrary(libraryName="stampy-core")
public class AckMessage extends AbstractMessage<AckHeader> {
private static final long serialVersionUID = 1984356410866237324L;
/**
* Instantiates a new ack message.
*
* @param id
* the id
*/
public AckMessage(String id) {
this();
getHeader().setId(id);
}
/**
* Instantiates a new ack message.
*/
public AckMessage() {
super(StompMessageType.ACK);
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#createNewHeader()
*/
@Override
protected AckHeader createNewHeader() {
return new AckHeader();
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#validate()
*/
@Override
public void validate() {
if (StringUtils.isEmpty(getHeader().getId())) {
throw new InvalidStompMessageException(AckHeader.ID + " is required");
}
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides the STOMP 1.2 ACK header and message classes
</body>
</html>
\ No newline at end of file
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.begin;
import asia.stampy.client.message.AbstractClientMessageHeader;
import asia.stampy.common.StampyLibrary;
/**
* The Class BeginHeader.
*/
@StampyLibrary(libraryName="stampy-core")
public class BeginHeader extends AbstractClientMessageHeader {
private static final long serialVersionUID = 1752296477013796007L;
/** The Constant TRANSACTION. */
public static final String TRANSACTION = "transaction";
/**
* Sets the transaction.
*
* @param transaction
* the new transaction
*/
public void setTransaction(String transaction) {
addHeader(TRANSACTION, transaction);
}
/**
* Gets the transaction.
*
* @return the transaction
*/
public String getTransaction() {
return getHeaderValue(TRANSACTION);
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.begin;
import org.apache.commons.lang.StringUtils;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.message.AbstractMessage;
import asia.stampy.common.message.InvalidStompMessageException;
import asia.stampy.common.message.StompMessageType;
/**
* The Class BeginMessage.
*/
@StampyLibrary(libraryName="stampy-core")
public class BeginMessage extends AbstractMessage<BeginHeader> {
private static final long serialVersionUID = -1331929421949592240L;
/**
* Instantiates a new begin message.
*
* @param transaction
* the transaction
*/
public BeginMessage(String transaction) {
this();
getHeader().setTransaction(transaction);
}
/**
* Instantiates a new begin message.
*/
public BeginMessage() {
super(StompMessageType.BEGIN);
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#createNewHeader()
*/
@Override
protected BeginHeader createNewHeader() {
return new BeginHeader();
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#validate()
*/
@Override
public void validate() {
if (StringUtils.isEmpty(getHeader().getTransaction())) {
throw new InvalidStompMessageException(BeginHeader.TRANSACTION + " is required");
}
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides the STOMP 1.2 BEGIN header and message classes
</body>
</html>
\ No newline at end of file
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.commit;
import asia.stampy.client.message.AbstractClientMessageHeader;
import asia.stampy.common.StampyLibrary;
/**
* The Class CommitHeader.
*/
@StampyLibrary(libraryName="stampy-core")
public class CommitHeader extends AbstractClientMessageHeader {
private static final long serialVersionUID = 503530501264860164L;
/** The Constant TRANSACTION. */
public static final String TRANSACTION = "transaction";
/**
* Sets the transaction.
*
* @param transaction
* the new transaction
*/
public void setTransaction(String transaction) {
addHeader(TRANSACTION, transaction);
}
/**
* Gets the transaction.
*
* @return the transaction
*/
public String getTransaction() {
return getHeaderValue(TRANSACTION);
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.commit;
import org.apache.commons.lang.StringUtils;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.message.AbstractMessage;
import asia.stampy.common.message.InvalidStompMessageException;
import asia.stampy.common.message.StompMessageType;
/**
* The Class CommitMessage.
*/
@StampyLibrary(libraryName="stampy-core")
public class CommitMessage extends AbstractMessage<CommitHeader> {
private static final long serialVersionUID = 3916270310464057075L;
/**
* Instantiates a new commit message.
*
* @param transaction
* the transaction
*/
public CommitMessage(String transaction) {
this();
getHeader().setTransaction(transaction);
}
/**
* Instantiates a new commit message.
*/
public CommitMessage() {
super(StompMessageType.COMMIT);
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#createNewHeader()
*/
@Override
protected CommitHeader createNewHeader() {
return new CommitHeader();
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#validate()
*/
@Override
public void validate() {
if (StringUtils.isEmpty(getHeader().getTransaction())) {
throw new InvalidStompMessageException(CommitHeader.TRANSACTION + " is required");
}
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides the STOMP 1.2 COMMIT header and message classes
</body>
</html>
\ No newline at end of file
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.connect;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.message.AbstractMessageHeader;
/**
* The Class ConnectHeader.
*/
@StampyLibrary(libraryName="stampy-core")
public class ConnectHeader extends AbstractMessageHeader {
private static final long serialVersionUID = 6732326426523759109L;
/** The Constant HEART_BEAT. */
public static final String HEART_BEAT = "heart-beat";
/** The Constant PASSCODE. */
public static final String PASSCODE = "passcode";
/** The Constant LOGIN. */
public static final String LOGIN = "login";
/** The Constant HOST. */
public static final String HOST = "host";
/** The Constant ACCEPT_VERSION. */
public static final String ACCEPT_VERSION = "accept-version";
/**
* Sets the accept version.
*
* @param acceptVersion
* the new accept version
*/
public void setAcceptVersion(String acceptVersion) {
addHeader(ACCEPT_VERSION, acceptVersion);
}
/**
* Gets the accept version.
*
* @return the accept version
*/
public String getAcceptVersion() {
return getHeaderValue(ACCEPT_VERSION);
}
/**
* Sets the host.
*
* @param host
* the new host
*/
public void setHost(String host) {
addHeader(HOST, host);
}
/**
* Gets the host.
*
* @return the host
*/
public String getHost() {
return getHeaderValue(HOST);
}
/**
* Sets the login.
*
* @param user
* the new login
*/
public void setLogin(String user) {
addHeader(LOGIN, user);
}
/**
* Gets the login.
*
* @return the login
*/
public String getLogin() {
return getHeaderValue(LOGIN);
}
/**
* Sets the passcode.
*
* @param passcode
* the new passcode
*/
public void setPasscode(String passcode) {
addHeader(PASSCODE, passcode);
}
/**
* Gets the passcode.
*
* @return the passcode
*/
public String getPasscode() {
return getHeaderValue(PASSCODE);
}
/**
* Sets the heartbeat.
*
* @param outgoingHeartbeat
* the client hb millis
* @param incomingHeartbeat
* the server hb millis
*/
public void setHeartbeat(int outgoingHeartbeat, int incomingHeartbeat) {
addHeader(HEART_BEAT, Integer.toString(outgoingHeartbeat) + "," + Integer.toString(incomingHeartbeat));
}
/**
* Gets the outgoing heartbeat sleep time requested in milliseconds.
*
* @return the client heartbeat
*/
public int getOutgoingHeartbeat() {
return getHeartbeat(0);
}
/**
* Gets the incoming heartbeat sleep time requested in milliseconds.
*
* @return the server heartbeat
*/
public int getIncomingHeartbeat() {
return getHeartbeat(1);
}
private int getHeartbeat(int pos) {
String hb = getHeaderValue(HEART_BEAT);
if (hb == null) return 0;
String[] parts = hb.split(",");
return Integer.parseInt(parts[pos]);
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.connect;
import org.apache.commons.lang.StringUtils;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.message.AbstractMessage;
import asia.stampy.common.message.InvalidStompMessageException;
import asia.stampy.common.message.StompMessageType;
/**
* The Class ConnectMessage.
*/
@StampyLibrary(libraryName="stampy-core")
public class ConnectMessage extends AbstractMessage<ConnectHeader> {
private static final long serialVersionUID = 1164477258648698915L;
/**
* Instantiates a new connect message.
*
* @param acceptVersion
* the accept version
* @param host
* the host
*/
public ConnectMessage(String acceptVersion, String host) {
this();
getHeader().setAcceptVersion(acceptVersion);
getHeader().setHost(host);
}
/**
* Instantiates a new connect message.
*
* @param host
* the host
*/
public ConnectMessage(String host) {
this("1.2", host);
}
/**
* Instantiates a new connect message.
*/
public ConnectMessage() {
super(StompMessageType.CONNECT);
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#createNewHeader()
*/
@Override
protected ConnectHeader createNewHeader() {
return new ConnectHeader();
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#validate()
*/
@Override
public void validate() {
if (StringUtils.isEmpty(getHeader().getAcceptVersion())) {
throw new InvalidStompMessageException(ConnectHeader.ACCEPT_VERSION + " is required, 1.2 only");
}
if (StringUtils.isEmpty(getHeader().getHost())) {
throw new InvalidStompMessageException(ConnectHeader.HOST + " is required");
}
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides the STOMP 1.2 COMMIT header and message classes
</body>
</html>
\ No newline at end of file
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.disconnect;
import asia.stampy.client.message.AbstractClientMessageHeader;
import asia.stampy.common.StampyLibrary;
/**
* The Class DisconnectHeader.
*/
@StampyLibrary(libraryName="stampy-core")
public class DisconnectHeader extends AbstractClientMessageHeader {
private static final long serialVersionUID = 8733385162050781626L;
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.disconnect;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.message.AbstractMessage;
import asia.stampy.common.message.StompMessageType;
/**
* The Class DisconnectMessage.
*/
@StampyLibrary(libraryName="stampy-core")
public class DisconnectMessage extends AbstractMessage<DisconnectHeader> {
private static final long serialVersionUID = -7353329342186049989L;
/**
* Instantiates a new disconnect message.
*/
public DisconnectMessage() {
super(StompMessageType.DISCONNECT);
getHeader();
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#createNewHeader()
*/
@Override
protected DisconnectHeader createNewHeader() {
return new DisconnectHeader();
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#validate()
*/
@Override
public void validate() {
// TODO Auto-generated method stub
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides the STOMP 1.2 DISCONNECT header and message classes
</body>
</html>
\ No newline at end of file
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.nack;
import asia.stampy.client.message.AbstractClientMessageHeader;
import asia.stampy.common.StampyLibrary;
/**
* The Class NackHeader.
*/
@StampyLibrary(libraryName="stampy-core")
public class NackHeader extends AbstractClientMessageHeader {
private static final long serialVersionUID = -2432737523178348294L;
/** The Constant TRANSACTION. */
public static final String TRANSACTION = "transaction";
/** The Constant ID. */
public static final String ID = "id";
/**
* Sets the id.
*
* @param id
* the new id
*/
public void setId(String id) {
addHeader(ID, id);
}
/**
* Gets the id.
*
* @return the id
*/
public String getId() {
return getHeaderValue(ID);
}
/**
* Sets the transaction.
*
* @param transaction
* the new transaction
*/
public void setTransaction(String transaction) {
addHeader(TRANSACTION, transaction);
}
/**
* Gets the transaction.
*
* @return the transaction
*/
public String getTransaction() {
return getHeaderValue(TRANSACTION);
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.nack;
import org.apache.commons.lang.StringUtils;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.message.AbstractMessage;
import asia.stampy.common.message.InvalidStompMessageException;
import asia.stampy.common.message.StompMessageType;
/**
* The Class NackMessage.
*/
@StampyLibrary(libraryName="stampy-core")
public class NackMessage extends AbstractMessage<NackHeader> {
private static final long serialVersionUID = -1213685585376641464L;
/**
* Instantiates a new nack message.
*
* @param id
* the id
*/
public NackMessage(String id) {
this();
getHeader().setId(id);
}
/**
* Instantiates a new nack message.
*/
public NackMessage() {
super(StompMessageType.NACK);
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#createNewHeader()
*/
@Override
protected NackHeader createNewHeader() {
return new NackHeader();
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#validate()
*/
@Override
public void validate() {
if (StringUtils.isEmpty(getHeader().getId())) {
throw new InvalidStompMessageException(NackHeader.ID + " is required");
}
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides the STOMP 1.2 NACK header and message classes
</body>
</html>
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides the abstract client header classes
</body>
</html>
\ No newline at end of file
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.send;
import asia.stampy.client.message.AbstractClientBodyMessageHeader;
import asia.stampy.common.StampyLibrary;
/**
* The Class SendHeader.
*/
@StampyLibrary(libraryName="stampy-core")
public class SendHeader extends AbstractClientBodyMessageHeader {
private static final long serialVersionUID = -4105777135779226205L;
/** The Constant TRANSACTION. */
public static final String TRANSACTION = "transaction";
/** The Constant DESTINATION. */
public static final String DESTINATION = "destination";
/**
* Sets the destination.
*
* @param destination
* the new destination
*/
public void setDestination(String destination) {
addHeader(DESTINATION, destination);
}
/**
* Gets the destination.
*
* @return the destination
*/
public String getDestination() {
return getHeaderValue(DESTINATION);
}
/**
* Sets the transaction.
*
* @param transaction
* the new transaction
*/
public void setTransaction(String transaction) {
addHeader(TRANSACTION, transaction);
}
/**
* Gets the transaction.
*
* @return the transaction
*/
public String getTransaction() {
return getHeaderValue(TRANSACTION);
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.send;
import org.apache.commons.lang.StringUtils;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.message.AbstractBodyMessage;
import asia.stampy.common.message.InvalidStompMessageException;
import asia.stampy.common.message.StompMessageType;
/**
* The Class SendMessage.
*/
@StampyLibrary(libraryName="stampy-core")
public class SendMessage extends AbstractBodyMessage<SendHeader> {
private static final long serialVersionUID = -104251665180607773L;
/**
* Instantiates a new send message.
*
* @param destination
* the destination
* @param receipt
* the receipt
*/
public SendMessage(String destination, String receipt) {
this();
getHeader().setDestination(destination);
getHeader().setReceipt(receipt);
}
/**
* Instantiates a new send message.
*/
public SendMessage() {
super(StompMessageType.SEND);
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#createNewHeader()
*/
@Override
protected SendHeader createNewHeader() {
return new SendHeader();
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#validate()
*/
@Override
public void validate() {
if (StringUtils.isEmpty(getHeader().getDestination())) {
throw new InvalidStompMessageException(SendHeader.DESTINATION + " is required");
}
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides the STOMP 1.2 SEND header and message classes
</body>
</html>
\ No newline at end of file
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.stomp;
import asia.stampy.client.message.connect.ConnectHeader;
import asia.stampy.common.StampyLibrary;
/**
* The Class StompHeader.
*/
@StampyLibrary(libraryName="stampy-core")
public class StompHeader extends ConnectHeader {
private static final long serialVersionUID = 6132294214673104951L;
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.stomp;
import org.apache.commons.lang.StringUtils;
import asia.stampy.client.message.connect.ConnectHeader;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.message.AbstractMessage;
import asia.stampy.common.message.InvalidStompMessageException;
import asia.stampy.common.message.StompMessageType;
/**
* The Class StompMessage.
*/
@StampyLibrary(libraryName="stampy-core")
public class StompMessage extends AbstractMessage<StompHeader> {
private static final long serialVersionUID = 4889982516009469738L;
/**
* Instantiates a new stomp message.
*
* @param host
* the host
*/
public StompMessage(String host) {
this();
getHeader().setAcceptVersion("1.2");
getHeader().setHost(host);
}
/**
* Instantiates a new stomp message.
*/
public StompMessage() {
super(StompMessageType.STOMP);
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#createNewHeader()
*/
@Override
protected StompHeader createNewHeader() {
return new StompHeader();
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#validate()
*/
@Override
public void validate() {
if (StringUtils.isEmpty(getHeader().getAcceptVersion())) {
throw new InvalidStompMessageException(ConnectHeader.ACCEPT_VERSION + " is required, 1.2 only");
}
if (StringUtils.isEmpty(getHeader().getHost())) {
throw new InvalidStompMessageException(ConnectHeader.HOST + " is required");
}
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides the STOMP 1.2 STOMP header and message classes
</body>
</html>
\ No newline at end of file
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.subscribe;
import asia.stampy.client.message.AbstractClientMessageHeader;
import asia.stampy.common.StampyLibrary;
/**
* The Class SubscribeHeader.
*/
@StampyLibrary(libraryName="stampy-core")
public class SubscribeHeader extends AbstractClientMessageHeader {
private static final long serialVersionUID = 2321658220170938363L;
/** The Constant ID. */
public static final String ID = "id";
/** The Constant ACK. */
public static final String ACK = "ack";
/** The Constant DESTINATION. */
public static final String DESTINATION = "destination";
/**
* The Enum Ack.
*/
public enum Ack {
/** The auto. */
auto("auto"),
/** The client. */
client("client"),
/** The client individual. */
clientIndividual("client-individual");
/** The ack value. */
String ackValue;
/**
* Instantiates a new ack.
*
* @param ackValue
* the ack value
*/
Ack(String ackValue) {
this.ackValue = ackValue;
}
/**
* Gets the ack value.
*
* @return the ack value
*/
public String getAckValue() {
return ackValue;
}
/**
* From string.
*
* @param s
* the s
* @return the ack
*/
public static Ack fromString(String s) {
for (Ack ack : Ack.values()) {
if (ack.getAckValue().equals(s)) {
return ack;
}
}
return null;
}
}
/**
* Sets the destination.
*
* @param destination
* the new destination
*/
public void setDestination(String destination) {
addHeader(DESTINATION, destination);
}
/**
* Gets the destination.
*
* @return the destination
*/
public String getDestination() {
return getHeaderValue(DESTINATION);
}
/**
* Sets the ack.
*
* @param ack
* the new ack
*/
public void setAck(Ack ack) {
addHeader(ACK, ack.getAckValue());
}
/**
* Gets the ack.
*
* @return the ack
*/
public Ack getAck() {
String s = getHeaderValue(ACK);
if (s == null) return null;
return Ack.fromString(s);
}
/**
* Sets the id.
*
* @param id
* the new id
*/
public void setId(String id) {
addHeader(ID, id);
}
/**
* Gets the id.
*
* @return the id
*/
public String getId() {
return getHeaderValue(ID);
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.subscribe;
import org.apache.commons.lang.StringUtils;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.message.AbstractMessage;
import asia.stampy.common.message.InvalidStompMessageException;
import asia.stampy.common.message.StompMessageType;
/**
* The Class SubscribeMessage.
*/
@StampyLibrary(libraryName="stampy-core")
public class SubscribeMessage extends AbstractMessage<SubscribeHeader> {
private static final long serialVersionUID = -7008261320884282352L;
/**
* Instantiates a new subscribe message.
*
* @param destination
* the destination
* @param id
* the id
*/
public SubscribeMessage(String destination, String id) {
this();
getHeader().setDestination(destination);
getHeader().setId(id);
}
/**
* Instantiates a new subscribe message.
*/
public SubscribeMessage() {
super(StompMessageType.SUBSCRIBE);
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#createNewHeader()
*/
@Override
protected SubscribeHeader createNewHeader() {
return new SubscribeHeader();
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#validate()
*/
@Override
public void validate() {
if (StringUtils.isEmpty(getHeader().getDestination())) {
throw new InvalidStompMessageException(SubscribeHeader.DESTINATION + " is required");
}
if (StringUtils.isEmpty(getHeader().getId())) {
throw new InvalidStompMessageException(SubscribeHeader.ID + " is required");
}
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides the STOMP 1.2 SUBSCRIBE header and message classes
</body>
</html>
\ No newline at end of file
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.unsubscribe;
import asia.stampy.client.message.AbstractClientMessageHeader;
import asia.stampy.common.StampyLibrary;
/**
* The Class UnsubscribeHeader.
*/
@StampyLibrary(libraryName="stampy-core")
public class UnsubscribeHeader extends AbstractClientMessageHeader {
private static final long serialVersionUID = -6205303835381181615L;
/** The Constant ID. */
public static final String ID = "id";
/**
* Sets the id.
*
* @param id
* the new id
*/
public void setId(String id) {
addHeader(ID, id);
}
/**
* Gets the id.
*
* @return the id
*/
public String getId() {
return getHeaderValue(ID);
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.client.message.unsubscribe;
import org.apache.commons.lang.StringUtils;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.message.AbstractMessage;
import asia.stampy.common.message.InvalidStompMessageException;
import asia.stampy.common.message.StompMessageType;
/**
* The Class UnsubscribeMessage.
*/
@StampyLibrary(libraryName="stampy-core")
public class UnsubscribeMessage extends AbstractMessage<UnsubscribeHeader> {
private static final long serialVersionUID = -4889351559871669847L;
/**
* Instantiates a new unsubscribe message.
*
* @param id
* the id
*/
public UnsubscribeMessage(String id) {
this();
getHeader().setId(id);
}
/**
* Instantiates a new unsubscribe message.
*/
public UnsubscribeMessage() {
super(StompMessageType.UNSUBSCRIBE);
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#createNewHeader()
*/
@Override
protected UnsubscribeHeader createNewHeader() {
return new UnsubscribeHeader();
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#validate()
*/
@Override
public void validate() {
if (StringUtils.isEmpty(getHeader().getId())) {
throw new InvalidStompMessageException(UnsubscribeHeader.ID + " is required");
}
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides the STOMP 1.2 UNSUBSCRIBE header and message classes
</body>
</html>
\ No newline at end of file
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
/**
* The Annotation StampyLibrary defines which class belongs to which library.
* For Javadoc purposes.
*/
@Documented
@Target(ElementType.TYPE)
@StampyLibrary(libraryName="stampy-core")
public @interface StampyLibrary {
/**
* Library name.
*
* @return the string
*/
String libraryName();
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.gateway;
import java.lang.invoke.MethodHandles;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import asia.stampy.common.StampyLibrary;
/**
* This default implementation of an {@link UnparseableMessageHandler} logs a
* non-STOMP message at warning level.
*/
@StampyLibrary(libraryName="stampy-client-server")
public class DefaultUnparseableMessageHandler implements UnparseableMessageHandler {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
/*
* (non-Javadoc)
*
* @see
* asia.stampy.common.gateway.UnparseableMessageHandler#unparseableMessage
* (java .lang.String, asia.stampy.common.HostPort)
*/
@Override
public void unparseableMessage(String message, HostPort hostPort) throws Exception {
log.warn("Unparseable message {} received from {}", message, hostPort);
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.gateway;
import java.io.Serializable;
import java.net.InetSocketAddress;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import asia.stampy.common.StampyLibrary;
/**
* A HostPort is a simple bean encapsulating which host and port has made a
* connection. Useful on the server side to keep track of who is connected,
* where subscriptions go etc.
*/
@StampyLibrary(libraryName="stampy-client-server")
public class HostPort implements Serializable {
private static final long serialVersionUID = 7989783689512750362L;
private final String host;
private final int port;
/**
* Instantiates a new host port.
*
* @param host
* the host
* @param port
* the port
*/
public HostPort(String host, int port) {
this.host = host;
this.port = port;
}
/**
* Instantiates a new host port.
*
* @param address
* the address
*/
public HostPort(InetSocketAddress address) {
this.host = address.getAddress().getHostAddress();
this.port = address.getPort();
}
/**
* Gets the host.
*
* @return the host
*/
public String getHost() {
return host;
}
/**
* Gets the port.
*
* @return the port
*/
public int getPort() {
return port;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
return EqualsBuilder.reflectionEquals(this, o);
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return getHost() + ":" + getPort();
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.gateway;
import asia.stampy.common.StampyLibrary;
/**
* Signals that no further {@link StampyMessageListener}s should be invoked.
* Should be thrown by any implementation of a {@link StampyMessageListener}
* that wants to halt downstream processing of the message.
*/
@StampyLibrary(libraryName="stampy-client-server")
public class MessageListenerHaltException extends Exception {
private static final long serialVersionUID = -2918764833295344951L;
/**
* Instantiates a new message listener halt exception.
*/
public MessageListenerHaltException() {
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.gateway;
import asia.stampy.common.StampyLibrary;
/**
* This is a tagging interface to ensure that any implementations implement at
* least one {@link SecurityMessageListener}, and that it is called first in the
* list. It is up to applications using Stampy to ensure that appropriate
* security checks are performed for their environment.
*
* @see AbstractStampyMessageGateway#notifyMessageListeners(asia.stampy.common.message.StampyMessage, HostPort)
*
* @author burton
*
*/
@StampyLibrary(libraryName="stampy-client-server")
public interface SecurityMessageListener extends StampyMessageListener {
}
package asia.stampy.common.gateway;
import java.lang.invoke.MethodHandles;
import javax.annotation.Resource;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import asia.stampy.client.message.ClientMessageHeader;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.heartbeat.StampyHeartbeatContainer;
import asia.stampy.common.message.StampyMessage;
import asia.stampy.common.parsing.StompMessageParser;
import asia.stampy.common.parsing.UnparseableException;
import asia.stampy.server.message.error.ErrorMessage;
/**
* This class implements methods shared across handler implementations.
* @author burton
*
*/
@Resource
@StampyLibrary(libraryName="stampy-client-server")
public class StampyHandlerHelper {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private StompMessageParser parser = new StompMessageParser();
private StampyHeartbeatContainer heartbeatContainer;
private AbstractStampyMessageGateway gateway;
private UnparseableMessageHandler unparseableMessageHandler = new DefaultUnparseableMessageHandler();
/**
* Handle unexpected error.
*
* @param hostPort
* the host port
* @param msg
* the msg
* @param sm
* the sm
* @param e
* the e
*/
public void handleUnexpectedError(HostPort hostPort, String msg, StampyMessage<?> sm, Exception e) {
try {
if (sm == null) {
errorHandle(e, hostPort);
} else {
errorHandle(sm, e, hostPort);
}
} catch (Exception e1) {
log.error("Unexpected exception sending error message for {}", hostPort, e1);
}
}
/**
* Handle unparseable message.
*
* @param hostPort
* the host port
* @param msg
* the msg
* @param e
* the e
*/
public void handleUnparseableMessage(HostPort hostPort, String msg, UnparseableException e) {
log.debug("Unparseable message, delegating to unparseable message handler");
try {
getUnparseableMessageHandler().unparseableMessage(msg, hostPort);
} catch (Exception e1) {
try {
errorHandle(e1, hostPort);
} catch (Exception e2) {
log.error("Could not parse message {} for {}", msg, hostPort, e);
log.error("Unexpected exception sending error message for {}", hostPort, e2);
}
}
}
/**
* Error handle. Logs the error.
*
* @param message
* the message
* @param e
* the e
* @param hostPort
* the host port
* @throws Exception
* the exception
*/
protected void errorHandle(StampyMessage<?> message, Exception e, HostPort hostPort) throws Exception {
log.error("Handling error, sending error message to {}", hostPort, e);
String receipt = message.getHeader().getHeaderValue(ClientMessageHeader.RECEIPT);
ErrorMessage error = new ErrorMessage(StringUtils.isEmpty(receipt) ? "n/a" : receipt);
error.getHeader().setMessageHeader("Could not execute " + message.getMessageType() + " - " + e.getMessage());
getGateway().sendMessage(error.toStompMessage(true), hostPort);
}
/**
* Error handle. Logs the error.
*
* @param e
* the e
* @param hostPort
* the host port
* @throws Exception
* the exception
*/
protected void errorHandle(Exception e, HostPort hostPort) throws Exception {
log.error("Handling error, sending error message to {}", hostPort, e);
ErrorMessage error = new ErrorMessage("n/a");
error.getHeader().setMessageHeader(e.getMessage());
getGateway().sendMessage(error.toStompMessage(true), hostPort);
}
/**
* Checks if the message is a heartbeat.
*
* @param msg
* the msg
* @return true, if is heartbeat
*/
public boolean isHeartbeat(String msg) {
return msg.equals(StampyHeartbeatContainer.HB1) || msg.equals(StampyHeartbeatContainer.HB2);
}
/**
* Checks if is valid object. Must be a string.
*
* @param message
* the message
* @return true, if is valid object
*/
public boolean isValidObject(Object message) {
return message instanceof String;
}
/**
* Reset heartbeat.
*
* @param hostPort
* the host port
*/
public void resetHeartbeat(HostPort hostPort) {
getHeartbeatContainer().reset(hostPort);
}
public StompMessageParser getParser() {
return parser;
}
public void setParser(StompMessageParser parser) {
this.parser = parser;
}
public StampyHeartbeatContainer getHeartbeatContainer() {
return heartbeatContainer;
}
public void setHeartbeatContainer(StampyHeartbeatContainer heartbeatContainer) {
this.heartbeatContainer = heartbeatContainer;
}
public AbstractStampyMessageGateway getGateway() {
return gateway;
}
public void setGateway(AbstractStampyMessageGateway gateway) {
this.gateway = gateway;
}
public UnparseableMessageHandler getUnparseableMessageHandler() {
return unparseableMessageHandler;
}
public void setUnparseableMessageHandler(UnparseableMessageHandler unparseableMessageHandler) {
this.unparseableMessageHandler = unparseableMessageHandler;
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.gateway;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.message.StampyMessage;
import asia.stampy.common.message.StompMessageType;
/**
* Implement to process specified {@link StampyMessage}s.
*
* @see AbstractStampyMessageGateway
*/
@StampyLibrary(libraryName="stampy-client-server")
public interface StampyMessageListener {
/**
* Gets the message types of which the implementation is interested.
*
* @return the message types
*/
StompMessageType[] getMessageTypes();
/**
* Returns true if the message should be processed by the implementation.
*
* @param message
* the message
* @return true, if is for message
*/
boolean isForMessage(StampyMessage<?> message);
/**
* Invoked when the type and the message are to be processed by the
* implementation.
*
* @param message
* the message
* @param hostPort
* the host port
* @throws Exception
* the exception
*/
void messageReceived(StampyMessage<?> message, HostPort hostPort) throws Exception;
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.gateway;
import asia.stampy.common.StampyLibrary;
/**
* Thrown when an instance of {@link SecurityMessageListener} has not been
* configured first in the list.
*
* @author burton
* @see AbstractStampyMessageGateway#notifyMessageListeners(asia.stampy.common.message.StampyMessage,
* HostPort)
*
*/
@StampyLibrary(libraryName="stampy-client-server")
public class StampySecurityException extends RuntimeException {
private static final long serialVersionUID = -9157111717358793044L;
/**
* Instantiates a new stampy security exception.
*/
public StampySecurityException() {
super(
"An instance of SecurityMinaMessageListener has not been configured first in the list of StampyMinaMessageListeners");
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.gateway;
import asia.stampy.common.StampyLibrary;
/**
* Implementations deal with messages that cannot be parsed into STOMP messages.
*/
@StampyLibrary(libraryName="stampy-client-server")
public interface UnparseableMessageHandler {
/**
* Process the non-STOMP message.
*
* @param message
* the message
* @param hostPort
* the host port
* @throws Exception
* the exception
*/
void unparseableMessage(String message, HostPort hostPort) throws Exception;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides interfaces and super classes for the implementation of STOMP 1.2 clients and servers
</body>
</html>
\ No newline at end of file
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.heartbeat;
import java.lang.invoke.MethodHandles;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.gateway.AbstractStampyMessageGateway;
import asia.stampy.common.gateway.HostPort;
/**
* Encapsulates all the currently active {@link PaceMaker}s. This class is a
* singleton; wire into the system appropriately.
*/
@Resource
@StampyLibrary(libraryName = "stampy-client-server")
public class HeartbeatContainer implements StampyHeartbeatContainer {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private Map<HostPort, PaceMaker> paceMakers = new ConcurrentHashMap<HostPort, PaceMaker>();
/* (non-Javadoc)
* @see asia.stampy.common.heartbeat.StampyHeartbeatContainer#start(asia.stampy.common.gateway.HostPort, asia.stampy.common.gateway.AbstractStampyMessageGateway, int)
*/
@Override
public void start(HostPort hostPort, AbstractStampyMessageGateway gateway, int timeMillis) {
PaceMaker paceMaker = new PaceMaker(timeMillis);
paceMaker.setHostPort(hostPort);
paceMaker.setGateway(gateway);
paceMaker.start();
add(hostPort, paceMaker);
}
/* (non-Javadoc)
* @see asia.stampy.common.heartbeat.StampyHeartbeatContainer#stop(asia.stampy.common.gateway.HostPort)
*/
@Override
public void stop(HostPort hostPort) {
PaceMaker paceMaker = paceMakers.get(hostPort);
if (paceMaker != null) {
log.info("Stopping PaceMaker for {}", hostPort);
paceMaker.stop();
}
}
/**
* Adds a new {@link PaceMaker} for the specified {@link HostPort}.
*
* @param hostPort
* the host port
* @param paceMaker
* the pace maker
*/
protected void add(HostPort hostPort, PaceMaker paceMaker) {
stop(hostPort);
log.info("Adding PaceMaker for {}", hostPort);
paceMakers.put(hostPort, paceMaker);
}
/* (non-Javadoc)
* @see asia.stampy.common.heartbeat.StampyHeartbeatContainer#remove(asia.stampy.common.gateway.HostPort)
*/
@Override
public void remove(HostPort hostPort) {
stop(hostPort);
log.info("Removing PaceMaker for {}", hostPort);
paceMakers.remove(hostPort);
}
/* (non-Javadoc)
* @see asia.stampy.common.heartbeat.StampyHeartbeatContainer#reset(asia.stampy.common.gateway.HostPort)
*/
@Override
public void reset(HostPort hostPort) {
if (hostPort == null) return;
log.trace("Resetting PaceMaker for {}", hostPort);
PaceMaker paceMaker = paceMakers.get(hostPort);
if (paceMaker != null) paceMaker.reset();
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.heartbeat;
import java.lang.invoke.MethodHandles;
import java.util.Timer;
import java.util.TimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.gateway.AbstractStampyMessageGateway;
import asia.stampy.common.gateway.HostPort;
/**
* Sends heartbeats to a remote connection as specified by the STOMP
* specification.
*/
@StampyLibrary(libraryName="stampy-client-server")
class PaceMaker {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private long timeInMillis;
private TimerTask stopwatch;
private Timer timer = new Timer("Stampy PaceMaker", true);
private AbstractStampyMessageGateway gateway;
private HostPort hostPort;
private int heartbeatCount;
/**
* Instantiates a new pace maker.
*
* @param timeInMillis
* the time in millis
*/
public PaceMaker(int timeInMillis) {
this.timeInMillis = timeInMillis;
}
/**
* Reset.
*/
public synchronized void reset() {
log.trace("PaceMaker reset invoked");
setHeartbeatCount(0);
stop();
start();
}
/**
* Stop.
*/
public void stop() {
log.trace("PaceMaker stop invoked");
if (stopwatch != null) {
stopwatch.cancel();
timer.purge();
}
}
/**
* Start.
*/
public void start() {
log.trace("PaceMaker start invoked for sleep time of {} ms", getSleepTime());
stopwatch = new TimerTask() {
@Override
public void run() {
executeHeartbeat();
}
};
timer.schedule(stopwatch, getSleepTime());
}
private void executeHeartbeat() {
if (heartbeatCount >= 2) {
log.warn("No response after 2 heartbeats, closing connection");
gateway.closeConnection(getHostPort());
} else {
try {
if (gateway.isConnected(getHostPort())) {
gateway.sendMessage(StampyHeartbeatContainer.HB1, getHostPort());
log.debug("Sent heartbeat");
start();
heartbeatCount++;
}
} catch (Exception e) {
log.error("Could not send heartbeat", e);
}
}
}
/**
* Gets the sleep time.
*
* @return the sleep time
*/
public long getSleepTime() {
return timeInMillis;
}
/**
* Gets the message gateway.
*
* @return the message gateway
*/
public AbstractStampyMessageGateway getGateway() {
return gateway;
}
/**
* Sets the message gateway. Must be called upon instantiation.
*
* @param gateway
* the new message gateway
*/
public void setGateway(AbstractStampyMessageGateway gateway) {
this.gateway = gateway;
}
/**
* Gets the host port.
*
* @return the host port
*/
public HostPort getHostPort() {
return hostPort;
}
/**
* Sets the host port. Must be called upon instantiation.
*
* @param hostPort
* the new host port
*/
public void setHostPort(HostPort hostPort) {
this.hostPort = hostPort;
}
/**
* Gets the heartbeat count. If the count reaches 2 then the connection is
* assumed to be dead and the connection to the remote host is closed.
*
* @return the heartbeat count
*/
public int getHeartbeatCount() {
return heartbeatCount;
}
/**
* Sets the heartbeat count.
*
* @param heartbeatCount
* the new heartbeat count
*/
public void setHeartbeatCount(int heartbeatCount) {
this.heartbeatCount = heartbeatCount;
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.heartbeat;
import asia.stampy.common.gateway.AbstractStampyMessageGateway;
import asia.stampy.common.gateway.HostPort;
public interface StampyHeartbeatContainer {
/** The Constant HB1. */
public static final String HB1 = "\n";
/** The Constant HB2. */
public static final String HB2 = "\r\n";
/**
* Starts a heartbeat for the specified host & port.
* @param hostPort
* @param gateway
* @param timeMillis
*/
public abstract void start(HostPort hostPort, AbstractStampyMessageGateway gateway, int timeMillis);
/**
* Stops heartbeats to the specified {@link HostPort}.
*
* @param hostPort
* the host port
*/
public abstract void stop(HostPort hostPort);
/**
* Removes the {@link PaceMaker} specified by {@link HostPort}.
*
* @param hostPort
* the host port
*/
public abstract void remove(HostPort hostPort);
/**
* Resets the {@link PaceMaker} for the specified {@link HostPort}, preventing
* a heartbeat from being sent.
*
* @param hostPort
* the host port
*/
public abstract void reset(HostPort hostPort);
}
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides heartbeat management classes
</body>
</html>
\ No newline at end of file
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.message;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import org.apache.commons.lang.NotImplementedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.serialization.SerializationUtils;
/**
* Abstract class representing STOMP messages with a body. Binary bodies are
* catered for, provided they are Java objects.
*
* @param <HDR>
* the generic type
*/
@StampyLibrary(libraryName="stampy-core")
public abstract class AbstractBodyMessage<HDR extends AbstractBodyMessageHeader> extends AbstractMessage<HDR> {
private static final long serialVersionUID = 3988865546656906553L;
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
/** The Constant JAVA_BASE64_MIME_TYPE. */
public static final String JAVA_BASE64_MIME_TYPE = "java/base64";
private String bodyEncoding = JAVA_BASE64_MIME_TYPE;
private Object body;
/**
* Instantiates a new abstract body message.
*
* @param messageType
* the message type
*/
protected AbstractBodyMessage(StompMessageType messageType) {
super(messageType);
}
/**
* Gets the body.
*
* @param <O>
* the generic type
* @return the body
*/
@SuppressWarnings("unchecked")
public <O extends Object> O getBody() {
return (O) body;
}
/**
* Sets the body.
*
* @param <O>
* the generic type
* @param body
* the new body
*/
public <O extends Object> void setBody(O body) {
this.body = body;
}
/**
* Sets the mime type.
*
* @param mimeType
* the new mime type
*/
public void setMimeType(String mimeType) {
getHeader().setContentType(mimeType);
}
/**
* Sets the mime type.
*
* @param mimeType
* the mime type
* @param encoding
* the encoding
*/
public void setMimeType(String mimeType, String encoding) {
mimeType += ";charset=" + encoding;
setMimeType(mimeType);
}
/**
* Checks if is text.
*
* @return true, if is text
*/
public boolean isText() {
String value = getHeader().getContentType();
if (value == null) return true;
return value.contains("text/");
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.AbstractMessage#postHeader()
*/
@Override
protected String postHeader() {
if (getBody() == null) return null;
if (isText()) {
return getBody();
} else {
try {
String encoded = getBodyEncoding().equals(JAVA_BASE64_MIME_TYPE) ? getObjectArrayAsBase64(getBody())
: getObjectArrayAsString(getBody());
getHeader().removeHeader(AbstractBodyMessageHeader.CONTENT_TYPE);
getHeader().removeHeader(AbstractMessageHeader.CONTENT_LENGTH);
getHeader().setContentLength(encoded.length());
getHeader().setContentType(getBodyEncoding());
return encoded;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
/**
* Should the {@link AbstractBodyMessage#getBodyEncoding()} return a value
* other than {@link AbstractBodyMessage#JAVA_BASE64_MIME_TYPE}, this method
* will be invoked. The default implementation throws a
* NotImplementedException. Override as necessary.
*
* @param body
* the body
* @return the object array as string
*/
protected String getObjectArrayAsString(Object body) {
throw new NotImplementedException("Subclass the abstract body message and override getObjectArrayAsString for "
+ getBodyEncoding() + " encoding");
}
/**
* Gets the object array as base64.
*
* @param o
* the o
* @return the object array as base64
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public String getObjectArrayAsBase64(Object o) throws IOException {
log.debug("Serializing object to a string using Base64 encoding", o);
return SerializationUtils.serializeBase64(o);
}
/**
* Gets the body encoding. Defaults to
* {@link AbstractBodyMessage#JAVA_BASE64_MIME_TYPE}.
*
* @return the body encoding
*/
public String getBodyEncoding() {
return bodyEncoding;
}
/**
* Sets the body encoding.
*
* @param bodyEncoding
* the new body encoding
*/
public void setBodyEncoding(String bodyEncoding) {
this.bodyEncoding = bodyEncoding;
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.message;
import asia.stampy.common.StampyLibrary;
/**
* The Class AbstractBodyMessageHeader.
*/
@StampyLibrary(libraryName="stampy-core")
public class AbstractBodyMessageHeader extends AbstractMessageHeader {
private static final long serialVersionUID = -4546439038775868974L;
/** The Constant CONTENT_TYPE. */
public static final String CONTENT_TYPE = "content-type";
/**
* Sets the content type.
*
* @param mimeType
* the new content type
*/
public void setContentType(String mimeType) {
addHeader(CONTENT_TYPE, mimeType);
}
/**
* Gets the content type.
*
* @return the content type
*/
public String getContentType() {
return getHeaderValue(CONTENT_TYPE);
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.message;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.parsing.StompMessageParser;
/**
* Abstract implementation of a {@link StampyMessage}.
*
* @param <HDR>
* the generic type
*/
@StampyLibrary(libraryName="stampy-core")
public abstract class AbstractMessage<HDR extends StampyMessageHeader> implements StampyMessage<HDR> {
private static final long serialVersionUID = -577180637937320507L;
private HDR header;
private final StompMessageType messageType;
/**
* Instantiates a new abstract message.
*
* @param messageType
* the message type
*/
protected AbstractMessage(StompMessageType messageType) {
this.messageType = messageType;
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.StampyMessage#getHeader()
*/
@Override
public HDR getHeader() {
if (header == null) header = createNewHeader();
return header;
}
/**
* Creates the new header.
*
* @return the hdr
*/
protected abstract HDR createNewHeader();
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.StampyMessage#getMessageType()
*/
@Override
public StompMessageType getMessageType() {
return messageType;
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.StampyMessage#toStompMessage(boolean)
*/
@Override
public final String toStompMessage(boolean validate) {
if (validate) validate();
StringBuilder builder = new StringBuilder();
String body = postHeader();
builder.append(getMessageType().name());
String header = getHeader().toMessageHeader();
if (StringUtils.isNotEmpty(header)) {
builder.append("\n");
builder.append(header);
}
builder.append("\n\n");
builder.append(body);
builder.append(StompMessageParser.EOM);
return builder.toString();
}
/**
* Validates the message should {@link AbstractMessage#toStompMessage(true)}
* be called.
*/
@Override
public abstract void validate();
/**
* This method is used to create the body of the message, if applicable. The
* default implementation returns null.
*
* @return the string
*/
protected String postHeader() {
return null;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
return EqualsBuilder.reflectionEquals(this, o);
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.message;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import asia.stampy.common.StampyLibrary;
/**
* Abstract implementation of a {@link StampyMessageHeader}.
*/
@StampyLibrary(libraryName = "stampy-core")
public abstract class AbstractMessageHeader implements StampyMessageHeader {
private static final long serialVersionUID = 4570408820942642173L;
/** The Constant CONTENT_LENGTH. */
public static final String CONTENT_LENGTH = "content-length";
private Map<String, List<String>> headers = new HashMap<String, List<String>>();
/**
* Sets the content length.
*
* @param length
* the new content length
*/
public void setContentLength(int length) {
addHeader(CONTENT_LENGTH, Integer.toString(length));
}
/**
* Gets the content length.
*
* @return the content length
*/
public int getContentLength() {
String length = getHeaderValue(CONTENT_LENGTH);
if (length == null) return -1;
return Integer.parseInt(length);
}
/**
* <i>If a client or a server receives repeated frame header entries, only the
* first header entry SHOULD be used as the value of header entry. Subsequent
* values are only used to maintain a history of state changes of the header
* and MAY be ignored.</i><br>
* <br>
*
* Values are added in order, only the first value added is returned in
* {@link AbstractMessageHeader#getHeaderValue(String)}
*/
@Override
public void addHeader(String key, String value) {
getList(key).add(value);
}
@Override
public void addHeader(String key, String value, int idx) {
getList(key).add(idx, value);
}
/*
* (non-Javadoc)
*
* @see
* asia.stampy.common.message.StampyMessageHeader#removeHeader(java.lang.String
* )
*/
@Override
public void removeHeader(String key) {
headers.remove(key);
}
/*
* (non-Javadoc)
*
* @see
* asia.stampy.common.message.StampyMessageHeader#getHeaderValue(java.lang
* .String)
*/
@Override
public String getHeaderValue(String key) {
List<String> list = getList(key);
return list.isEmpty() ? null : list.get(0);
}
@Override
public List<String> getHeaderValues(String key) {
return new ArrayList<String>(getList(key));
}
/*
* (non-Javadoc)
*
* @see
* asia.stampy.common.message.StampyMessageHeader#hasHeader(java.lang.String)
*/
@Override
public boolean hasHeader(String key) {
return headers.containsKey(key) && !getList(key).isEmpty();
}
private List<String> getList(String key) {
List<String> list = headers.get(key);
if (list == null) {
list = new ArrayList<String>();
headers.put(key, list);
}
return list;
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.StampyMessageHeader#toMessageHeader()
*/
@Override
public final String toMessageHeader() {
boolean first = true;
StringBuilder builder = new StringBuilder();
for (Entry<String, List<String>> entry : headers.entrySet()) {
if (entry.getValue() == null || entry.getValue().isEmpty()) continue;
for (String value : entry.getValue()) {
if (!first) builder.append("\n");
builder.append(entry.getKey());
builder.append(":");
builder.append(value);
first = false;
}
}
return builder.toString();
}
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.StampyMessageHeader#getHeaders()
*/
@Override
public Map<String, List<String>> getHeaders() {
return new HashMap<String, List<String>>(headers);
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
return EqualsBuilder.reflectionEquals(this, o);
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return toMessageHeader();
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.message;
import asia.stampy.common.StampyLibrary;
/**
* The Class InvalidStompMessageException.
*/
@StampyLibrary(libraryName="stampy-core")
public class InvalidStompMessageException extends RuntimeException {
private static final long serialVersionUID = 4139832823187771410L;
/**
* Instantiates a new invalid stomp message exception.
*
* @param message
* the message
*/
public InvalidStompMessageException(String message) {
super(message);
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.message;
import java.io.Serializable;
import asia.stampy.common.StampyLibrary;
/**
* All Stampy implementations of STOMP messages must implement this interface.
*
* @param <HDR>
* the generic type
*/
@StampyLibrary(libraryName="stampy-core")
public interface StampyMessage<HDR extends StampyMessageHeader> extends Serializable {
/**
* Gets the header.
*
* @return the header
*/
HDR getHeader();
/**
* Returns a STOMP-string representation of a {@link StampyMessage}.
*
* @param validate
* if true message validation is executed
* @return the string
*/
String toStompMessage(boolean validate);
/**
* Gets the message type.
*
* @return the message type
*/
StompMessageType getMessageType();
/**
* Performs validation on the message.
*/
void validate();
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.message;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import asia.stampy.common.StampyLibrary;
/**
* The Interface StampyMessageHeader.
*/
@StampyLibrary(libraryName = "stampy-core")
public interface StampyMessageHeader extends Serializable {
/**
* To message header.
*
* @return the string
*/
String toMessageHeader();
/**
* Adds the header.
*
* @param key
* the key
* @param value
* the value
*/
void addHeader(String key, String value);
/**
* Adds a header at the specified index.
*
* @param key
* @param value
* @param idx
*/
void addHeader(String key, String value, int idx);
/**
* Checks for header.
*
* @param key
* the key
* @return true, if successful
*/
boolean hasHeader(String key);
/**
* Removes the header and all its value.
*
* @param key
* the key
*/
void removeHeader(String key);
/**
* Gets the first header value.
*
* @param key
* the key
* @return the header value
*/
String getHeaderValue(String key);
/**
* Returns all the values associated with the header key.
*
* @param key
* @return
*/
List<String> getHeaderValues(String key);
/**
* Gets the headers.
*
* @return the headers
*/
Map<String, List<String>> getHeaders();
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.message;
import asia.stampy.common.StampyLibrary;
/**
* The Enum of all STOMP message types.
*/
@StampyLibrary(libraryName="stampy-core")
public enum StompMessageType {
/** The connect. */
CONNECT,
/** The stomp. */
STOMP,
/** The connected. */
CONNECTED,
/** The send. */
SEND(true),
/** The subscribe. */
SUBSCRIBE,
/** The unsubscribe. */
UNSUBSCRIBE,
/** The ack. */
ACK,
/** The nack. */
NACK,
/** The begin. */
BEGIN,
/** The commit. */
COMMIT,
/** The abort. */
ABORT,
/** The disconnect. */
DISCONNECT,
/** The message. */
MESSAGE(true),
/** The receipt. */
RECEIPT,
/** The error. */
ERROR(true);
/** The has body. */
boolean hasBody;
/**
* Instantiates a new stampy message type.
*/
StompMessageType() {
this(false);
}
/**
* Instantiates a new stampy message type.
*
* @param hasBody
* the has body
*/
StompMessageType(boolean hasBody) {
this.hasBody = hasBody;
}
/**
* Checks for body.
*
* @return true, if successful
*/
public boolean hasBody() {
return hasBody;
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.message.interceptor;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.gateway.AbstractStampyMessageGateway;
import asia.stampy.common.gateway.HostPort;
import asia.stampy.common.message.StampyMessage;
/**
* The Class AbstractOutgoingMessageInterceptor.
*/
@StampyLibrary(libraryName="stampy-client-server")
public abstract class AbstractOutgoingMessageInterceptor<SVR extends AbstractStampyMessageGateway> implements
StampyOutgoingMessageInterceptor {
private SVR gateway;
/*
* (non-Javadoc)
*
* @see
* asia.stampy.common.message.interceptor.StampyOutgoingMessageInterceptor
* #interceptMessage(asia.stampy.common.message.StampyMessage)
*/
@Override
public void interceptMessage(StampyMessage<?> message) throws InterceptException {
for (HostPort hostPort : getGateway().getConnectedHostPorts()) {
interceptMessage(message, hostPort);
}
}
/**
* Gets the gateway.
*
* @return the gateway
*/
public SVR getGateway() {
return gateway;
}
/**
* Sets the gateway.
*
* @param gateway
* the new gateway
*/
public void setGateway(SVR gateway) {
this.gateway = gateway;
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.message.interceptor;
import asia.stampy.common.StampyLibrary;
import asia.stampy.common.gateway.AbstractStampyMessageGateway;
import asia.stampy.common.gateway.HostPort;
/**
* The Class AbstractOutgoingTextInterceptor.
*/
@StampyLibrary(libraryName="stampy-client-server")
public abstract class AbstractOutgoingTextInterceptor<SVR extends AbstractStampyMessageGateway> implements
StampyOutgoingTextInterceptor {
private SVR gateway;
/*
* (non-Javadoc)
*
* @see asia.stampy.common.message.interceptor.StampyOutgoingTextInterceptor#
* interceptMessage(java.lang.String)
*/
@Override
public void interceptMessage(String message) throws InterceptException {
for (HostPort hostPort : getGateway().getConnectedHostPorts()) {
interceptMessage(message, hostPort);
}
}
/**
* Gets the gateway.
*
* @return the gateway
*/
public SVR getGateway() {
return gateway;
}
/**
* Sets the gateway.
*
* @param gateway
* the new gateway
*/
public void setGateway(SVR gateway) {
this.gateway = gateway;
}
}
/*
* Copyright (C) 2013 Burton Alexander
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package asia.stampy.common.message.interceptor;
import asia.stampy.common.StampyLibrary;
/**
* The Class InterceptException, thrown by the implementation of an interceptor
* when the sending of a message is to be aborted.
*/
@StampyLibrary(libraryName="stampy-client-server")
public class InterceptException extends Exception {
private static final long serialVersionUID = 3708895403125259300L;
/**
* Instantiates a new intercept exception.
*
* @param message
* the message
*/
public InterceptException(String message) {
super(message);
}
/**
* Instantiates a new intercept exception.
*
* @param message
* the message
* @param cause
* the cause
*/
public InterceptException(String message, Throwable cause) {
super(message, cause);
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides interceptor classes to capture outgoing message state, trigger events etc.
</body>
</html>
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides the STOMP 1.2 common interfaces and super classes for messages
</body>
</html>
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides common classes
</body>
</html>
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Provides message parsing tools
</body>
</html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment