Applied patch from http://issues.apache.org/jira/browse/GERONIMO-1623, Thanks Mats./activemq Still need to setup a build system for this and have it dynamically download the smart pointer implemenation dependency (BSD lic.)

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@377433 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2006-02-13 17:43:48 +00:00
parent e7106d31b1
commit 3db3863583
111 changed files with 7215 additions and 0 deletions

View File

@ -0,0 +1,50 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "BrokerError.hpp"
using namespace apache::activemq::client;
/*
*
*/
BrokerError::BrokerError()
{
}
BrokerError::~BrokerError()
{
}
p<string> BrokerError::getExceptionClass()
{
return exceptionClass ;
}
void BrokerError::setExceptionClass(const char* exceptionClass)
{
this->exceptionClass->assign(exceptionClass) ;
}
p<string> BrokerError::getStackTrace()
{
return stackTrace ;
}
void BrokerError::setStackTrace(const char* stackTrace)
{
this->stackTrace->assign(stackTrace) ;
}

View File

@ -0,0 +1,56 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef BrokerError_hpp_
#define BrokerError_hpp_
#include <string>
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace ifr ;
using namespace std ;
/*
*
*/
class BrokerError
{
private:
p<string> exceptionClass ;
p<string> stackTrace ;
public:
BrokerError() ;
virtual ~BrokerError() ;
virtual p<string> getExceptionClass() ;
virtual void setExceptionClass(const char* exceptionClass) ;
virtual p<string> getStackTrace() ;
virtual void setStackTrace(const char* exceptionClass) ;
} ;
/* namespace */
}
}
}
#endif /*BrokerError_hpp_*/

View File

@ -0,0 +1,46 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "BrokerException.hpp"
using namespace apache::activemq::client;
/*
*
*/
BrokerException::BrokerException(p<BrokerError> cause)
: OpenWireException("") // TODO: Add trace
{
string message ;
brokerError = cause ;
// Build exception message
message.assign("The operation failed: Type: ") ;
message.append( cause->getExceptionClass()->c_str() ) ;
message.append(" stack: ") ;
message.append( cause->getStackTrace()->c_str() ) ;
}
BrokerException::~BrokerException()
{
// no-op
}
p<BrokerError> BrokerException::getCause()
{
return brokerError ;
}

View File

@ -0,0 +1,54 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef BrokerException_hpp_
#define BrokerException_hpp_
#include <string>
#include "BrokerError.hpp"
#include "OpenWireException.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace std;
using namespace ifr ;
/*
*
*/
class BrokerException : public OpenWireException
{
private:
p<BrokerError> brokerError ;
public:
BrokerException(p<BrokerError> cause) ;
virtual ~BrokerException() ;
virtual p<BrokerError> getCause() ;
};
/* namespace */
}
}
}
#endif /*BrokerException_hpp_*/

202
openwire-cpp/src/Connection.cpp Executable file
View File

@ -0,0 +1,202 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "Connection.hpp"
using namespace apache::activemq::client;
// --- Constructors -------------------------------------------------
/*
*
*/
Connection::Connection(p<ITransport> transport, p<ConnectionInfo> connectionInfo)
{
this->transport = transport ;
this->connectionInfo = connectionInfo ;
this->connected = false ;
this->transacted = false ;
this->closed = false ;
}
/*
*
*/
Connection::~Connection()
{
}
// --- Attribute methods --------------------------------------------
/*
*
*/
p<ITransport> Connection::getTransport()
{
return transport ;
}
/*
*
*/
void Connection::setTransport(p<ITransport> transport) throw(OpenWireException)
{
this->transport = transport ;
}
/*
*
*/
p<string> Connection::getClientId()
{
return connectionInfo->getClientId() ;
}
/*
*
*/
void Connection::setClientId(const char* value)
{
if( connected )
throw OpenWireException("You cannot change the ClientId once a connection is established") ;
connectionInfo->setClientId( value ) ;
}
/*
*
*/
bool Connection::getTransacted()
{
return transacted ;
}
/*
*
*/
void Connection::setTransacted(bool tx)
{
transacted = tx ;
}
/*
*
*/
AcknowledgementMode Connection::getAcknowledgementMode()
{
return acknowledgementMode ;
}
/*
*
*/
void Connection::setAcknowledgementMode(AcknowledgementMode mode)
{
acknowledgementMode = mode ;
}
// --- Operation methods --------------------------------------------
/*
*
*/
p<ISession> Connection::createSession() throw(OpenWireException)
{
return createSession(transacted, acknowledgementMode) ;
}
/*
*
*/
p<ISession> Connection::createSession(bool transacted, AcknowledgementMode mode) throw(OpenWireException)
{
checkConnected() ;
p<SessionInfo> sessionInfo = createSessionInfo(transacted, acknowledgementMode) ;
// Send session info to broker
syncRequest(sessionInfo) ;
p<ISession> session = new Session(this, sessionInfo) ;
sessions.push_back(session) ;
return session ;
}
/*
*
*/
p<Response> Connection::syncRequest(p<ICommand> command) throw(OpenWireException)
{
checkConnected() ;
p<Response> response = transport->request(command) ;
if( response->getCommandType() == ExceptionResponse::TYPE )
{
p<ExceptionResponse> exceptionResponse = (p<ExceptionResponse>&)response ;
p<BrokerError> brokerError = exceptionResponse->getException() ;
string message ;
// Build error message
message.assign("Request failed: ") ;
message.append( brokerError->getExceptionClass()->c_str() ) ;
message.append(", ") ;
message.append( brokerError->getStackTrace()->c_str() ) ;
throw new OpenWireException( message.c_str() ) ;
}
return response ;
}
// --- Implementation methods ---------------------------------------
/*
*
*/
p<SessionInfo> Connection::createSessionInfo(bool transacted, AcknowledgementMode acknowledgementMode)
{
p<SessionInfo> sessionInfo = new SessionInfo() ;
p<SessionId> sessionId = new SessionId() ;
sessionId->setConnectionId ( connectionInfo->getConnectionId()->getValue()->c_str() ) ;
mutex.lock() ;
sessionId->setValue( ++sessionCounter ) ;
mutex.unlock() ;
sessionInfo->setSessionId( sessionId ) ;
return sessionInfo ;
}
/*
*
*/
void Connection::checkConnected() throw(OpenWireException)
{
if( closed )
throw new ConnectionClosedException("Oops! Connection already closed.") ;
if( !connected )
{
syncRequest((p<ICommand>&)connectionInfo) ;
connected = true ;
}
}

100
openwire-cpp/src/Connection.hpp Executable file
View File

@ -0,0 +1,100 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef Connection_hpp_
#define Connection_hpp_
#include <list>
#include <string>
#include "ISession.hpp"
#include "IConnection.hpp"
#include "Session.hpp"
#include "OpenWireException.hpp"
#include "ConnectionClosedException.hpp"
#include "command/ExceptionResponse.hpp"
#include "command/ConnectionInfo.hpp"
#include "command/SessionInfo.hpp"
#include "command/SessionId.hpp"
#include "transport/ITransport.hpp"
#include "util/SimpleMutex.hpp"
#include "util/ifr/p"
// Turn off warning message for ignored exception specification
#ifdef _MSC_VER
#pragma warning( disable : 4290 )
#endif
namespace apache
{
namespace activemq
{
namespace client
{
using namespace std;
using namespace ifr;
using namespace apache::activemq::client::command;
using namespace apache::activemq::client::transport;
using namespace apache::activemq::client::util;
/*
*
*/
class Connection : public IConnection
{
private:
p<ConnectionInfo> connectionInfo ;
p<ITransport> transport ;
list< p<ISession> > sessions ;
bool transacted,
connected,
closed ;
AcknowledgementMode acknowledgementMode ;
long sessionCounter ;
SimpleMutex mutex ;
public:
// Constructors
Connection(p<ITransport> transport, p<ConnectionInfo> connectionInfo) ;
~Connection() ;
// Attribute methods
virtual AcknowledgementMode getAcknowledgementMode() ;
virtual void setAcknowledgementMode(AcknowledgementMode mode) ;
virtual p<string> getClientId() ;
virtual void setClientId(const char* value) ;
virtual bool getTransacted() ;
virtual void setTransacted(bool tx) ;
virtual p<ITransport> getTransport() ;
virtual void setTransport(p<ITransport> transport) throw(OpenWireException) ;
// Operation methods
virtual p<ISession> createSession() throw(OpenWireException) ;
virtual p<ISession> createSession(bool transacted, AcknowledgementMode mode) throw(OpenWireException) ;
virtual p<Response> syncRequest(p<ICommand> command) throw(OpenWireException) ;
protected:
// Implementation methods
p<SessionInfo> createSessionInfo(bool transacted, AcknowledgementMode mode) ;
void checkConnected() throw(OpenWireException) ;
} ;
/* namespace */
}
}
}
#endif /*Connection_hpp_*/

View File

@ -0,0 +1,33 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ConnectionClosedException.hpp"
using namespace apache::activemq::client;
/*
*
*/
ConnectionClosedException::ConnectionClosedException(const char* message)
: OpenWireException(message)
{
// no-op
}
ConnectionClosedException::~ConnectionClosedException()
{
// no-op
}

View File

@ -0,0 +1,44 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ConnectionClosedException_hpp_
#define ConnectionClosedException_hpp_
#include "OpenWireException.hpp"
namespace apache
{
namespace activemq
{
namespace client
{
/*
*
*/
class ConnectionClosedException : public OpenWireException
{
public:
ConnectionClosedException(const char* message) ;
virtual ~ConnectionClosedException() ;
};
/* namespace */
}
}
}
#endif /*ConnectionClosedException_hpp_*/

View File

@ -0,0 +1,201 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ConnectionFactory.hpp"
#include "Connection.hpp"
using namespace apache::activemq::client;
/*
*
*/
ConnectionFactory::ConnectionFactory()
{
host = new string() ;
host->assign("localhost") ;
port = 61616 ;
username = new string() ;
password = new string() ;
clientId = new string() ;
}
/*
*
*/
ConnectionFactory::ConnectionFactory(const char* host, int port)
{
this->host = new string() ;
this->host->assign(host) ;
this->port = port ;
username = new string() ;
password = new string() ;
clientId = new string() ;
}
/*
*
*/
ConnectionFactory::~ConnectionFactory()
{
}
// --- Attribute methods --------------------------------------------
/*
*
*/
p<string> ConnectionFactory::getHost()
{
return host ;
}
/*
*
*/
void ConnectionFactory::setHost(const char* host)
{
this->host->assign(host) ;
}
/*
*
*/
int ConnectionFactory::getPort()
{
return port ;
}
/*
*
*/
void ConnectionFactory::setPort(int port)
{
port = port ;
}
/*
*
*/
p<string> ConnectionFactory::getUsername()
{
return username ;
}
/*
*
*/
void ConnectionFactory::setUsername(const char* username)
{
this->username->assign(username) ;
}
/*
*
*/
p<string> ConnectionFactory::getPassword()
{
return password ;
}
/*
*
*/
void ConnectionFactory::setPassword(const char* password)
{
this->password->assign(password) ;
}
/*
*
*/
p<string> ConnectionFactory::getClientId()
{
return clientId ;
}
/*
*
*/
void ConnectionFactory::setClientId(const char* clientId)
{
this->clientId->assign(clientId) ;
}
// --- Operation methods --------------------------------------------
/*
*
*/
p<IConnection> ConnectionFactory::createConnection()
{
return createConnection(username->c_str(), password->c_str()) ;
}
/*
*
*/
p<IConnection> ConnectionFactory::createConnection(const char* username, const char* password)
{
p<ConnectionInfo> connectionInfo ;
p<ITransport> transport ;
p<Connection> connection ;
// Set up a new connection object
connectionInfo = createConnectionInfo(username, password) ;
transport = createTransport() ;
connection = new Connection(transport, connectionInfo) ;
connection->setClientId( clientId->c_str() ) ;
return connection ;
}
// --- Implementation methods ---------------------------------------
/*
*
*/
p<ConnectionInfo> ConnectionFactory::createConnectionInfo(const char* username, const char* password)
{
p<ConnectionInfo> connectionInfo = new ConnectionInfo() ;
p<ConnectionId> connectionId = new ConnectionId() ;
connectionId->setValue( createNewConnectionId()->c_str() ) ;
connectionInfo->setConnectionId( connectionId ) ;
connectionInfo->setUsername( username ) ;
connectionInfo->setPassword( password ) ;
return connectionInfo ;
}
/*
*
*/
p<string> ConnectionFactory::createNewConnectionId()
{
return Guid::getGuidString() ;
}
/*
*
*/
p<ITransport> ConnectionFactory::createTransport()
{
p<ITransport> transport = new SocketTransport(host->c_str(), port) ;
return transport ;
}

View File

@ -0,0 +1,89 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ConnectionFactory_hpp_
#define ConnectionFactory_hpp_
// Must be included before any STL includes
#include "util/Guid.hpp"
#include <string>
#include "IConnection.hpp"
#include "IConnectionFactory.hpp"
#include "command/ConnectionInfo.hpp"
#include "command/ConnectionId.hpp"
#include "transport/ITransport.hpp"
#include "transport/SocketTransport.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace apache::activemq::client::command;
using namespace apache::activemq::client::transport;
using namespace apache::activemq::client::util;
using namespace ifr;
/*
*
*/
class ConnectionFactory : IConnectionFactory
{
private:
p<string> host,
username,
password,
clientId ;
int port ;
public:
// Constructors
ConnectionFactory() ;
ConnectionFactory(const char* host, int port) ;
virtual ~ConnectionFactory() ;
// Attribute methods
virtual p<string> getHost() ;
virtual void setHost(const char* host) ;
virtual int getPort() ;
virtual void setPort(int port) ;
virtual p<string> getUsername() ;
virtual void setUsername(const char* username) ;
virtual p<string> getPassword() ;
virtual void setPassword(const char* password) ;
virtual p<string> getClientId() ;
virtual void setClientId(const char* clientId) ;
// Operation methods
virtual p<IConnection> createConnection() ;
virtual p<IConnection> createConnection(const char* username, const char* password) ;
protected:
// Implementation methods
virtual p<ConnectionInfo> createConnectionInfo(const char* username, const char* password) ;
virtual p<string> createNewConnectionId() ;
virtual p<ITransport> createTransport() ;
} ;
/* namespace */
}
}
}
#endif /*ConnectionFactory_hpp_*/

View File

@ -0,0 +1,33 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ConsumerClosedException.hpp"
using namespace apache::activemq::client;
/*
*
*/
ConsumerClosedException::ConsumerClosedException(const char* message)
: OpenWireException(message)
{
// no-op
}
ConsumerClosedException::~ConsumerClosedException()
{
// no-op
}

View File

@ -0,0 +1,44 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ConsumerClosedException_hpp_
#define ConsumerClosedException_hpp_
#include "OpenWireException.hpp"
namespace apache
{
namespace activemq
{
namespace client
{
/*
*
*/
class ConsumerClosedException : public OpenWireException
{
public:
ConsumerClosedException(const char* message) ;
~ConsumerClosedException() ;
};
/* namespace */
}
}
}
#endif /*ConsumerClosedException_hpp_*/

View File

@ -0,0 +1,41 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "DestinationFilter.hpp"
using namespace apache::activemq::client;
// Init static constants
const char* DestinationFilter::ANY_DESCENDENT = ">" ;
const char* DestinationFilter::ANY_CHILD = "*" ;
/*
*
*/
DestinationFilter::DestinationFilter()
{
}
DestinationFilter::~DestinationFilter()
{
// no-op
}
bool DestinationFilter::matches(p<ActiveMQMessage> message)
{
return matches( message->getDestination() ) ;
}

View File

@ -0,0 +1,55 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef DestinationFilter_hpp_
#define DestinationFilter_hpp_
#include "command/ActiveMQMessage.hpp"
#include "command/ActiveMQDestination.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace ifr;
using namespace apache::activemq::client::command;
/*
*
*/
class DestinationFilter
{
public:
const static char* ANY_DESCENDENT ;
const static char* ANY_CHILD ;
public:
DestinationFilter() ;
virtual ~DestinationFilter() ;
virtual bool matches(p<ActiveMQMessage> message) ;
virtual bool matches(p<ActiveMQDestination> destination) = 0 ;
};
/* namespace */
}
}
}
#endif /*DestinationFilter_hpp_*/

View File

@ -0,0 +1,47 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "FutureResponse.hpp"
using namespace apache::activemq::client;
/*
*
*/
FutureResponse::FutureResponse()
{
complete = false ;
response = NULL ;
}
FutureResponse::~FutureResponse()
{
}
p<Response> FutureResponse::getResponse()
{
return response ;
}
void FutureResponse::setResponse(p<Response> response)
{
response = response ;
}
bool FutureResponse::isCompleted()
{
return complete ;
}

View File

@ -0,0 +1,58 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FutureResponse_hpp_
#define FutureResponse_hpp_
#include <string>
#include "command/Response.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace ifr;
using namespace apache::activemq::client::command;
/*
* Interface for commands.
*/
class FutureResponse
{
private:
p<Response> response ;
bool complete ;
public:
FutureResponse() ;
virtual ~FutureResponse() ;
virtual p<Response> getResponse() ;
virtual void setResponse(p<Response> response) ;
virtual bool isCompleted() ;
// TODO: add notify/wait
} ;
/* namespace */
}
}
}
#endif /*FutureResponse_hpp_*/

View File

@ -0,0 +1,60 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IConnection_hpp_
#define IConnection_hpp_
#include "ISession.hpp"
#include "OpenWireException.hpp"
#include "util/ifr/p"
// Turn off warning message for ignored exception specification
#ifdef _MSC_VER
#pragma warning( disable : 4290 )
#endif
namespace apache
{
namespace activemq
{
namespace client
{
using namespace ifr;
enum AcknowledgementMode {
UnknownMode, AutoMode, ClientMode, TransactionalMode
} ;
/*
*
*/
struct IConnection
{
virtual p<ISession> createSession() throw(OpenWireException) = 0 ;
virtual p<ISession> createSession(bool transacted, AcknowledgementMode ackMode) throw(OpenWireException) = 0 ;
virtual bool getTransacted() = 0 ;
virtual void setTransacted(bool tx) = 0 ;
virtual AcknowledgementMode getAcknowledgementMode() = 0 ;
virtual void setAcknowledgementMode(AcknowledgementMode mode) = 0 ;
} ;
/* namespace */
}
}
}
#endif /*IConnection_hpp_*/

View File

@ -0,0 +1,46 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IConnectionFactory_hpp_
#define IConnectionFactory_hpp_
#include <string>
#include "IConnection.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace ifr;
/*
*
*/
struct IConnectionFactory
{
virtual p<IConnection> createConnection() = 0 ;
virtual p<IConnection> createConnection(const char* username, const char* password) = 0 ;
} ;
/* namespace */
}
}
}
#endif /*IConnectionFactory_hpp_*/

View File

@ -0,0 +1,43 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IDestination_hpp_
#define IDestination_hpp_
#include "command/ICommand.hpp"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace apache::activemq::client::command;
/*
*
*/
struct IDestination
{
// Empty marker interface
} ;
/* namespace */
}
}
}
#endif /*IDestination_hpp_*/

45
openwire-cpp/src/IMessage.hpp Executable file
View File

@ -0,0 +1,45 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IMessage_hpp_
#define IMessage_hpp_
#include "IDestination.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace ifr;
/*
*
*/
struct IMessage
{
virtual p<IDestination> getFromDestination() = 0 ;
virtual void setFromDestination(p<IDestination> destination) = 0 ;
} ;
/* namespace */
}
}
}
#endif /*IMessage_hpp_*/

View File

@ -0,0 +1,46 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IMessageConsumer_hpp_
#define IMessageConsumer_hpp_
#include <string>
#include "IMessage.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace ifr;
/*
*
*/
struct IMessageConsumer
{
virtual p<IMessage> receive() = 0 ;
virtual p<IMessage> receiveNoWait() = 0 ;
} ;
/* namespace */
}
}
}
#endif /*IMessageConsumer_hpp_*/

View File

@ -0,0 +1,47 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IMessageProducer_hpp_
#define IMessageProducer_hpp_
#include <string>
#include "IDestination.hpp"
#include "IMessage.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace ifr;
/*
*
*/
struct IMessageProducer
{
virtual void send(p<IMessage> message) = 0 ;
virtual void send(p<IDestination> destination, p<IMessage> message) = 0 ;
} ;
/* namespace */
}
}
}
#endif /*IMessageProducer_hpp_*/

47
openwire-cpp/src/IQueue.hpp Executable file
View File

@ -0,0 +1,47 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IQueue_hpp_
#define IQueue_hpp_
#include <string>
#include "IDestination.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace ifr;
using namespace std;
/*
*
*/
struct IQueue : IDestination
{
virtual p<string> getQueueName() = 0 ;
virtual void setQueueName(const char* name) = 0 ;
} ;
/* namespace */
}
}
}
#endif /*IQueue_hpp_*/

58
openwire-cpp/src/ISession.hpp Executable file
View File

@ -0,0 +1,58 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ISession_hpp_
#define ISession_hpp_
#include <string>
#include "IDestination.hpp"
#include "IMessageProducer.hpp"
#include "IMessageConsumer.hpp"
#include "IQueue.hpp"
#include "ITopic.hpp"
#include "ITextMessage.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace ifr;
/*
*
*/
struct ISession
{
virtual p<IMessageProducer> createProducer() = 0 ;
virtual p<IMessageProducer> createProducer(p<IDestination> destination) = 0 ;
virtual p<IMessageConsumer> createConsumer(p<IDestination> destination) = 0 ;
virtual p<IMessageConsumer> createConsumer(p<IDestination> destination, const char* selector) = 0 ;
virtual p<IQueue> getQueue(const char* name) = 0 ;
virtual p<ITopic> getTopic(const char* name) = 0 ;
virtual p<IMessage> createMessage() = 0 ;
virtual p<ITextMessage> createTextMessage() = 0 ;
virtual p<ITextMessage> createTextMessage(const char* text) = 0 ;
} ;
/* namespace */
}
}
}
#endif /*ISession_hpp_*/

View File

@ -0,0 +1,42 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ITemporaryQueue_hpp_
#define ITemporaryQueue_hpp_
#include <string>
#include "IDestination.hpp"
namespace apache
{
namespace activemq
{
namespace client
{
/*
*
*/
struct ITemporaryQueue : IDestination
{
} ;
/* namespace */
}
}
}
#endif /*ITemporaryQueue_hpp_*/

View File

@ -0,0 +1,42 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ITemporaryTopic_hpp_
#define ITemporaryTopic_hpp_
#include <string>
#include "IDestination.hpp"
namespace apache
{
namespace activemq
{
namespace client
{
/*
*
*/
struct ITemporaryTopic : IDestination
{
} ;
/* namespace */
}
}
}
#endif /*ITemporaryTopic_hpp_*/

View File

@ -0,0 +1,45 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ITextMessage_hpp_
#define ITextMessage_hpp_
#include <string>
#include "IMessage.hpp"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace std;
/*
*
*/
struct ITextMessage : IMessage
{
virtual string* getText() = 0 ;
virtual void setText(string* txt) = 0 ;
} ;
/* namespace */
}
}
}
#endif /*ITextMessage_hpp_*/

47
openwire-cpp/src/ITopic.hpp Executable file
View File

@ -0,0 +1,47 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ITopic_hpp_
#define ITopic_hpp_
#include <string>
#include "IDestination.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace ifr;
using namespace std;
/*
*
*/
struct ITopic : IDestination
{
virtual p<string> getTopicName() = 0 ;
virtual void setTopicName(const char* name) = 0 ;
} ;
/* namespace */
}
}
}
#endif /*ITopic_hpp_*/

View File

@ -0,0 +1,56 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "MessageConsumer.hpp"
using namespace apache::activemq::client;
/*
*
*/
MessageConsumer::MessageConsumer(p<Session> session, p<ConsumerInfo> producerInfo)
{
this->session = session ;
this->consumerInfo = consumerInfo ;
this->closed = false ;
}
MessageConsumer::~MessageConsumer()
{
session->disposeOf( consumerInfo->getConsumerId() ) ;
}
p<IMessage> MessageConsumer::receive()
{
checkClosed() ;
// TODO
return NULL ;
}
p<IMessage> MessageConsumer::receiveNoWait()
{
checkClosed() ;
// TODO
return NULL ;
}
// Implementation methods ------------------------------------------------
void MessageConsumer::checkClosed() throw(OpenWireException)
{
if( closed )
throw new ConnectionClosedException("Oops! Connection already closed") ;
}

View File

@ -0,0 +1,74 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MessageConsumer_hpp_
#define MessageConsume_hpp_
#include <string>
#include "IDestination.hpp"
#include "IMessage.hpp"
#include "IMessageConsumer.hpp"
#include "Session.hpp"
#include "OpenWireException.hpp"
#include "ConnectionClosedException.hpp"
#include "command/ConsumerInfo.hpp"
#include "util/ifr/p"
// Turn off warning message for ignored exception specification
#ifdef _MSC_VER
#pragma warning( disable : 4290 )
#endif
namespace apache
{
namespace activemq
{
namespace client
{
using namespace ifr;
/*
*
*/
class MessageConsumer : public IMessageConsumer
{
private:
p<Session> session ;
p<ConsumerInfo> consumerInfo ;
bool closed ;
public:
MessageConsumer(p<Session> session, p<ConsumerInfo> consumerInfo) ;
~MessageConsumer() ;
/* TODO
virtual void setMessageListener(p<IMessageListener> listener) ;
virtual p<IMessageListener> getMessageListener() ;
*/
virtual p<IMessage> receive() ;
virtual p<IMessage> receiveNoWait() ;
protected:
void checkClosed() throw(OpenWireException) ;
} ;
/* namespace */
}
}
}
#endif /*IMessageConsumer_hpp_*/

View File

@ -0,0 +1,43 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "MessageProducer.hpp"
using namespace apache::activemq::client;
/*
*
*/
MessageProducer::MessageProducer(p<Session> session, p<ProducerInfo> producerInfo)
{
this->session = session ;
this->producerInfo = producerInfo ;
}
MessageProducer::~MessageProducer()
{
session->disposeOf( producerInfo->getProducerId() ) ;
}
void MessageProducer::send(p<IMessage> message)
{
send(producerInfo->getDestination(), message) ;
}
void MessageProducer::send(p<IDestination> destination, p<IMessage> message)
{
session->doSend(destination, message) ;
}

View File

@ -0,0 +1,58 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MessageProducer_hpp_
#define MessageProducer_hpp_
#include <string>
#include "IDestination.hpp"
#include "IMessage.hpp"
#include "IMessageProducer.hpp"
#include "Session.hpp"
#include "command/ProducerInfo.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace ifr;
/*
*
*/
class MessageProducer : public IMessageProducer
{
private:
p<Session> session ;
p<ProducerInfo> producerInfo ;
public:
MessageProducer(p<Session> session, p<ProducerInfo> producerInfo) ;
~MessageProducer() ;
virtual void send(p<IMessage> message) ;
virtual void send(p<IDestination> destination, p<IMessage> message) ;
} ;
/* namespace */
}
}
}
#endif /*IMessageProducer_hpp_*/

View File

@ -0,0 +1,33 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "OpenWireException.hpp"
using namespace apache::activemq::client;
/*
*
*/
OpenWireException::OpenWireException(const char* message)
: exception(message)
{
// no-op
}
OpenWireException::~OpenWireException()
{
// no-op
}

View File

@ -0,0 +1,44 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OpenWireException_hpp_
#define OpenWireException_hpp_
#include <exception>
namespace apache
{
namespace activemq
{
namespace client
{
/*
*
*/
class OpenWireException : public exception
{
public:
OpenWireException(const char* message) ;
~OpenWireException() ;
} ;
/* namespace */
}
}
}
#endif /*OpenWireException_hpp_*/

150
openwire-cpp/src/Session.cpp Executable file
View File

@ -0,0 +1,150 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "Session.hpp"
#include "command/ActiveMQQueue.hpp"
#include "command/ActiveMQTopic.hpp"
#include "command/ActiveMQMessage.hpp"
#include "command/ActiveMQTextMessage.hpp"
#include "command/ProducerInfo.hpp"
#include "command/ConsumerInfo.hpp"
#include "command/MessageAck.hpp"
#include "MessageConsumer.hpp"
#include "MessageProducer.hpp"
#include "Connection.hpp"
using namespace apache::activemq::client;
/*
*
*/
Session::Session(p<Connection> connection, p<SessionInfo> info)
{
this->connection = connection ;
this->sessionInfo = info ;
}
Session::~Session()
{
// De-activate session
disposeOf(sessionInfo->getSessionId()) ; //(IDataStructure*)
}
p<IMessageProducer> Session::createProducer()
{
return createProducer(NULL) ;
}
p<IMessageProducer> Session::createProducer(p<IDestination> destination)
{
p<ProducerInfo> command = createProducerInfo(destination) ;
connection->syncRequest(command) ; //(ICommand*)
p<IMessageProducer> messageProducer = new MessageProducer(this, command) ;
return messageProducer ;
}
void Session::acknowledge(p<IMessage> message)
{
if( ackMode == ClientMode )
{
p<MessageAck> msgAck = new MessageAck() ;
// TODO complete packet
connection->syncRequest(msgAck) ; //(ICommand*)
}
}
p<IMessageConsumer> Session::createConsumer(p<IDestination> destination)
{
return createConsumer(destination, NULL) ;
}
p<IMessageConsumer> Session::createConsumer(p<IDestination> destination, const char* selector)
{
p<ConsumerInfo> command = createConsumerInfo(destination, selector) ;
connection->syncRequest(command) ; //(ICommand*)
p<IMessageConsumer> messageConsumer = new MessageConsumer(this, command) ;
return messageConsumer ;
}
p<IQueue> Session::getQueue(const char* name)
{
p<IQueue> queue = (IQueue*)new ActiveMQQueue(name) ;
return queue ;
}
p<ITopic> Session::getTopic(const char* name)
{
p<ITopic> topic = (ITopic*)new ActiveMQTopic(name) ;
return topic ;
}
p<IMessage> Session::createMessage()
{
p<IMessage> message = (IMessage*)new ActiveMQMessage() ;
return message ;
}
p<ITextMessage> Session::createTextMessage()
{
p<ITextMessage> message = (ITextMessage*)new ActiveMQTextMessage() ;
return message ;
}
p<ITextMessage> Session::createTextMessage(const char* text)
{
p<ITextMessage> message = (ITextMessage*)new ActiveMQTextMessage(text) ;
return message ;
}
void Session::doSend(p<IDestination> destination, p<IMessage> message)
{
p<ActiveMQMessage> command = ActiveMQMessage::transform(message) ;
// TODO complete packet
connection->syncRequest(command) ; //(ICommand*)
}
void Session::disposeOf(p<IDataStructure> objectId)
{
p<RemoveInfo> command = new RemoveInfo() ;
command->setObjectId( objectId ) ;
connection->syncRequest(command) ; //(ICommand*)
}
// Implementation methods ------------------------------------------
p<ConsumerInfo> Session::createConsumerInfo(p<IDestination> destination, const char* selector)
{
p<ConsumerInfo> consumerInfo = new ConsumerInfo() ;
p<ConsumerId> consumerId = new ConsumerId() ;
consumerId->setSessionId( sessionInfo->getSessionId()->getValue() ) ;
mutex.lock() ;
consumerId->setValue( ++consumerCounter ) ;
mutex.unlock() ;
// TODO complete packet
consumerInfo->setConsumerId( consumerId ) ;
return consumerInfo ;
}
p<ProducerInfo> Session::createProducerInfo(p<IDestination> destination)
{
p<ProducerInfo> producerInfo = new ProducerInfo() ;
// TODO complete packet
return producerInfo ;
}

81
openwire-cpp/src/Session.hpp Executable file
View File

@ -0,0 +1,81 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef Session_hpp_
#define Session_hpp_
#include <string>
#include "IMessage.hpp"
#include "ISession.hpp"
#include "command/IDataStructure.hpp"
#include "command/ConsumerInfo.hpp"
#include "command/ProducerInfo.hpp"
#include "command/RemoveInfo.hpp"
#include "command/SessionInfo.hpp"
#include "util/SimpleMutex.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace ifr;
using namespace apache::activemq::client::util;
class Connection;
enum AcknowledgementMode;
/*
*
*/
class Session : public ISession
{
private:
p<Connection> connection ;
p<SessionInfo> sessionInfo ;
AcknowledgementMode ackMode ;
long consumerCounter ;
SimpleMutex mutex ;
public:
Session(p<Connection> connection, p<SessionInfo> sessionInfo) ;
~Session() ;
virtual p<IMessageProducer> createProducer() ;
virtual p<IMessageProducer> createProducer(p<IDestination> destination) ;
virtual p<IMessageConsumer> createConsumer(p<IDestination> destination) ;
virtual p<IMessageConsumer> createConsumer(p<IDestination> destination, const char* selector) ;
virtual p<IQueue> getQueue(const char* name) ;
virtual p<ITopic> getTopic(const char* name) ;
virtual p<IMessage> createMessage() ;
virtual p<ITextMessage> createTextMessage() ;
virtual p<ITextMessage> createTextMessage(const char* text) ;
virtual void acknowledge(p<IMessage> message) ;
virtual void doSend(p<IDestination> destination, p<IMessage> message) ;
virtual void disposeOf(p<IDataStructure> objectId) ;
protected:
p<ConsumerInfo> createConsumerInfo(p<IDestination> destination, const char* selector) ;
p<ProducerInfo> createProducerInfo(p<IDestination> destination) ;
} ;
/* namespace */
}
}
}
#endif /*Session_hpp_*/

View File

@ -0,0 +1,61 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "TraceException.hpp"
using namespace apache::activemq::client;
/*
*
*/
TraceException::TraceException()
: exception()
{
// no-op
} ;
/*
*
*/
TraceException::TraceException(const char* msg)
: exception(msg)
{
// no-op
} ;
/*
*
*/
TraceException::TraceException(const char* fileName, int lineNo, const char* message)
: exception(message)
{
char buf[10] ;
trace = new string() ;
trace->append(fileName) ;
trace->append(" at ") ;
trace->append( itoa(lineNo, buf, 10) ) ;
}
TraceException::~TraceException()
{
// no-op
}
p<string> TraceException::where()
{
return trace ;
}

View File

@ -0,0 +1,54 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TraceException_hpp_
#define TraceException_hpp_
#include <exception>
#include <string>
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
using namespace std ;
using namespace ifr ;
/*
* Base class for all exceptions containing trace information.
*/
class TraceException : public exception
{
p<string> trace ;
public:
TraceException() ;
TraceException(const char* msg) ;
TraceException(const char* fileName, int lineNo, const char* msg) ;
virtual ~TraceException() ;
p<string> where() ;
} ;
/* namespace */
}
}
}
#endif /*TraceException_hpp_*/

View File

@ -0,0 +1,116 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
#include "command/AbstractCommand.hpp"
#include "command/ActiveMQMessage.hpp"
#include "command/ActiveMQTextMessage.hpp"
#include "command/MessageAck.hpp"
#include "command/Response.hpp"
#include "command/ConsumerInfo.hpp"
#include "command/ProducerInfo.hpp"
#include "command/BrokerInfo.hpp"
#include "command/ConnectionInfo.hpp"
#include "command/RemoveInfo.hpp"
#include "command/SessionInfo.hpp"
using namespace apache::activemq::client::command;
/*
*
*/
AbstractCommand::AbstractCommand()
{
}
AbstractCommand::~AbstractCommand()
{
}
int AbstractCommand::getCommandType()
{
return 0 ;
}
p<string> AbstractCommand::getCommandTypeAsString(int type)
{
p<string> packetType = new string() ;
switch( type )
{
case ActiveMQMessage::TYPE:
packetType->assign("ACTIVEMQ_MESSAGE") ;
break ;
case ActiveMQTextMessage::TYPE:
packetType->assign("ACTIVEMQ_TEXT_MESSAGE") ;
break ;
// case ActiveMQObjectMessage::TYPE:
// packetType->assign("ACTIVEMQ_OBJECT_MESSAGE") ;
// break ;
// case ActiveMQBytesMessage::TYPE:
// packetType->assign("ACTIVEMQ_BYTES_MESSAGE") ;
// break ;
// case ActiveMQStreamMessage::TYPE:
// packetType->assign("ACTIVEMQ_STREAM_MESSAGE") ;
// break ;
// case ActiveMQMapMessage::TYPE:
// packetType->assign("ACTIVEMQ_MAP_MESSAGE") ;
// break ;
case MessageAck::TYPE:
packetType->assign("ACTIVEMQ_MSG_ACK") ;
break ;
case Response::TYPE:
packetType->assign("RESPONSE") ;
break ;
case ConsumerInfo::TYPE:
packetType->assign("CONSUMER_INFO") ;
break ;
case ProducerInfo::TYPE:
packetType->assign("PRODUCER_INFO") ;
break;
// case TransactionInfo::TYPE:
// packetType->assign("TRANSACTION_INFO") ;
// break ;
case BrokerInfo::TYPE:
packetType->assign("BROKER_INFO") ;
break ;
case ConnectionInfo::TYPE:
packetType->assign("CONNECTION_INFO") ;
break ;
case SessionInfo::TYPE:
packetType->assign("SESSION_INFO") ;
break ;
// case RemoveSubscriptionInfo::TYPE:
// packetType->assign("DURABLE_UNSUBSCRIBE") ;
// break ;
// case IntegerResponse::TYPE:
// packetType->assign("INT_RESPONSE_RECEIPT_INFO") ;
// break ;
// case WireFormatInfo::TYPE:
// packetType->assign("WIRE_FORMAT_INFO") ;
// break ;
case RemoveInfo::TYPE:
packetType->assign("REMOVE_INFO") ;
break ;
// case KeepAliveInfo::TYPE:
// packetType->assign("KEEP_ALIVE") ;
// break ;
default:
packetType->assign("UNDEFINED") ;
break ;
}
return packetType ;
}

View File

@ -0,0 +1,57 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef AbstractCommand_hpp_
#define AbstractCommand_hpp_
#include <string>
#include "command/ICommand.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
using namespace std;
/*
*
*/
class AbstractCommand : public ICommand
{
protected:
AbstractCommand() ;
public:
~AbstractCommand() ;
virtual int getCommandType() ;
static p<string> getCommandTypeAsString(int type) ;
} ;
/* namespace */
}
}
}
}
#endif /*AbstractCommand_hpp_*/

View File

@ -0,0 +1,30 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/ActiveMQDestination.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
ActiveMQDestination::ActiveMQDestination()
{
}
ActiveMQDestination::~ActiveMQDestination()
{
}

View File

@ -0,0 +1,49 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ActiveMQDestination_hpp_
#define ActiveMQDestination_hpp_
#include "IDestination.hpp"
#include "command/AbstractCommand.hpp"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace apache::activemq::client;
/*
* Dummy, should be auto-generated.
*/
class ActiveMQDestination : public AbstractCommand, IDestination
{
public:
ActiveMQDestination() ;
virtual ~ActiveMQDestination() ;
} ;
/* namespace */
}
}
}
}
#endif /*ActiveMQDestination_hpp_*/

View File

@ -0,0 +1,50 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/ActiveMQMessage.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
ActiveMQMessage::ActiveMQMessage()
{
destination = NULL ;
}
ActiveMQMessage::ActiveMQMessage(const char* name)
{
}
ActiveMQMessage::~ActiveMQMessage()
{
}
p<IDestination> ActiveMQMessage::getFromDestination()
{
return destination ;
}
void ActiveMQMessage::setFromDestination(p<IDestination> destination)
{
this->destination = destination ;
}
p<ActiveMQMessage> ActiveMQMessage::transform(p<IMessage> message)
{
return (p<ActiveMQMessage>&)message ;
}

View File

@ -0,0 +1,65 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ActiveMQMessage_hpp_
#define ActiveMQMessage_hpp_
#include <string>
#include "IDestination.hpp"
#include "IMessage.hpp"
#include "command/Message.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
using namespace apache::activemq::client;
/*
* Dummy, should be auto-generated.
*/
class ActiveMQMessage : public Message, IMessage
{
private:
p<IDestination> destination ;
public:
const static int TYPE = 23 ;
public:
ActiveMQMessage() ;
ActiveMQMessage(const char* name) ;
virtual ~ActiveMQMessage() ;
virtual p<IDestination> getFromDestination() ;
virtual void setFromDestination(p<IDestination> destination) ;
static p<ActiveMQMessage> transform(p<IMessage> message) ;
} ;
/* namespace */
}
}
}
}
#endif /*ActiveMQMessage_hpp_*/

View File

@ -0,0 +1,34 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/ActiveMQQueue.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
ActiveMQQueue::ActiveMQQueue()
{
}
ActiveMQQueue::ActiveMQQueue(const char* name)
{
}
ActiveMQQueue::~ActiveMQQueue()
{
}

View File

@ -0,0 +1,48 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ActiveMQQueue_hpp_
#define ActiveMQQueue_hpp_
#include "command/ActiveMQDestination.hpp"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
/*
* Dummy, should be auto-generated.
*/
class ActiveMQQueue : public ActiveMQDestination
{
public:
ActiveMQQueue() ;
ActiveMQQueue(const char* name) ;
virtual ~ActiveMQQueue() ;
} ;
/* namespace */
}
}
}
}
#endif /*ActiveMQQueue_hpp_*/

View File

@ -0,0 +1,35 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/ActiveMQTextMessage.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
ActiveMQTextMessage::ActiveMQTextMessage()
{
}
ActiveMQTextMessage::ActiveMQTextMessage(const char* name)
: ActiveMQMessage(name)
{
}
ActiveMQTextMessage::~ActiveMQTextMessage()
{
}

View File

@ -0,0 +1,51 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ActiveMQTextMessage_hpp_
#define ActiveMQTextMessage_hpp_
#include "ActiveMQMessage.hpp"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
/*
* Dummy, should be auto-generated.
*/
class ActiveMQTextMessage : public ActiveMQMessage
{
public:
const static int TYPE = 28 ;
public:
ActiveMQTextMessage() ;
ActiveMQTextMessage(const char* name) ;
virtual ~ActiveMQTextMessage() ;
} ;
/* namespace */
}
}
}
}
#endif /*ActiveMQTextMessage_hpp_*/

View File

@ -0,0 +1,34 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/ActiveMQTopic.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
ActiveMQTopic::ActiveMQTopic()
{
}
ActiveMQTopic::ActiveMQTopic(const char* name)
{
}
ActiveMQTopic::~ActiveMQTopic()
{
}

View File

@ -0,0 +1,48 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ActiveMQTopic_hpp_
#define ActiveMQTopic_hpp_
#include "command/ActiveMQDestination.hpp"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
/*
* Dummy, should be auto-generated.
*/
class ActiveMQTopic : public ActiveMQDestination
{
public:
ActiveMQTopic() ;
ActiveMQTopic(const char* name) ;
virtual ~ActiveMQTopic() ;
} ;
/* namespace */
}
}
}
}
#endif /*ActiveMQTopic_hpp_*/

View File

@ -0,0 +1,95 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/BaseCommand.hpp"
using namespace apache::activemq::client::command;
// Constructors -----------------------------------------------------
/*
*
*/
BaseCommand::BaseCommand()
{
}
BaseCommand::~BaseCommand()
{
}
// Attribute methods ------------------------------------------------
int BaseCommand::getHashCode()
{
return commandId ;
}
int BaseCommand::getCommandType()
{
return BaseCommand::TYPE ;
}
int BaseCommand::getCommandId()
{
return commandId ;
}
void BaseCommand::setCommandId(int id)
{
commandId = id ;
}
bool BaseCommand::isResponseRequired()
{
return responseRequired ;
}
void BaseCommand::setResponseRequired(bool required)
{
responseRequired = required ;
}
// Operation methods ------------------------------------------------
bool BaseCommand::operator== (BaseCommand& other)
{
if( getCommandType() == other.getCommandType() &&
commandId == other.commandId &&
responseRequired == other.responseRequired )
{
return true ;
}
return false ;
}
p<string> BaseCommand::toString()
{
p<string> str = new string() ;
char buffer[5] ;
str->assign( getCommandTypeAsString( getCommandType() )->c_str() ) ;
if( str->length() == 0 )
str->assign("") ;
str->append(": id = ") ;
str->append( itoa(getCommandId(), buffer, 10) ) ;
return str ;
}

View File

@ -0,0 +1,69 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef BaseCommand_hpp_
#define BaseCommand_hpp_
#include <string>
#include "command/AbstractCommand.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
using namespace std;
/*
*
*/
class BaseCommand : public AbstractCommand
{
private:
int commandId ;
bool responseRequired ;
public:
const static int TYPE = 0 ;
public:
BaseCommand() ;
virtual ~BaseCommand() ;
// Equals operator
bool operator== (BaseCommand& other) ;
virtual int getHashCode() ;
virtual int getCommandType() ;
virtual int getCommandId() ;
virtual void setCommandId(int id) ;
virtual bool isResponseRequired() ;
virtual void setResponseRequired(bool required) ;
virtual p<string> toString() ;
};
/* namespace */
}
}
}
}
#endif /*BaseCommand_hpp_*/

View File

@ -0,0 +1,47 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/BrokerId.hpp"
using namespace apache::activemq::client::command;
/*
*
*/
BrokerId::BrokerId()
{
value = new string() ;
}
BrokerId::~BrokerId()
{
// no-op
}
int BrokerId::getCommandType()
{
return BrokerId::TYPE ;
}
p<string> BrokerId::getValue()
{
return value ;
}
void BrokerId::setValue(const char* brokerId)
{
this->value->assign( brokerId ) ;
}

View File

@ -0,0 +1,61 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef BrokerId_hpp_
#define BrokerId_hpp_
#include <string>
#include "command/AbstractCommand.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
using namespace std ;
/*
*
*/
class BrokerId : public AbstractCommand
{
private:
p<string> value ;
public:
const static char TYPE = 124 ;
public:
BrokerId() ;
virtual ~BrokerId() ;
virtual int getCommandType() ;
virtual p<string> getValue() ;
virtual void setValue(const char* brokerId) ;
} ;
/* namespace */
}
}
}
}
#endif /*BrokerId_hpp_*/

View File

@ -0,0 +1,80 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/BrokerInfo.hpp"
using namespace apache::activemq::client::command;
/*
*
*/
BrokerInfo::BrokerInfo()
{
brokerId = NULL ;
brokerURL = new string() ;
brokerName = new string() ;
peerInfos = NULL ;
}
BrokerInfo::~BrokerInfo()
{
// no-op
}
int BrokerInfo::getCommandType()
{
return BrokerInfo::TYPE ;
}
p<string> BrokerInfo::getBrokerName()
{
return brokerName ;
}
void BrokerInfo::setBrokerName(const char* name)
{
brokerName->assign(name) ;
}
p<BrokerId> BrokerInfo::getBrokerId()
{
return brokerId ;
}
void BrokerInfo::setBrokerId(p<BrokerId> brokerId)
{
this->brokerId = brokerId ;
}
p<string> BrokerInfo::getBrokerURL()
{
return brokerURL ;
}
void BrokerInfo::setBrokerURL(const char* url)
{
this->brokerURL->assign(url) ;
}
ap<BrokerInfo> BrokerInfo::getPeerBrokerInfo()
{
return peerInfos ;
}
void BrokerInfo::setPeerBrokerInfo(ap<BrokerInfo> info)
{
peerInfos = info ;
}

View File

@ -0,0 +1,72 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef BrokerInfo_hpp_
#define BrokerInfo_hpp_
#include <string>
#include "command/BaseCommand.hpp"
#include "command/BrokerId.hpp"
#include "util/ifr/ap"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
using namespace std;
/*
*
*/
class BrokerInfo : public BaseCommand
{
private:
p<BrokerId> brokerId ;
p<string> brokerURL,
brokerName ;
ap<BrokerInfo> peerInfos ;
public:
const static char TYPE = 2 ;
public:
BrokerInfo() ;
virtual ~BrokerInfo() ;
virtual int getCommandType() ;
virtual p<string> getBrokerName() ;
virtual void setBrokerName(const char* name) ;
virtual p<BrokerId> getBrokerId() ;
virtual void setBrokerId(p<BrokerId> id) ;
virtual p<string> getBrokerURL() ;
virtual void setBrokerURL(const char* url) ;
virtual ap<BrokerInfo> getPeerBrokerInfo() ;
virtual void setPeerBrokerInfo(ap<BrokerInfo> info) ;
} ;
/* namespace */
}
}
}
}
#endif /*BrokerInfo_hpp_*/

View File

@ -0,0 +1,46 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/ConnectionId.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
ConnectionId::ConnectionId()
{
value = new string() ;
}
ConnectionId::~ConnectionId()
{
}
int ConnectionId::getCommandType()
{
return ConnectionId::TYPE ;
}
void ConnectionId::setValue(const char* value)
{
this->value->assign(value) ;
}
p<string> ConnectionId::getValue()
{
return value ;
}

View File

@ -0,0 +1,60 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ConnectionId_hpp_
#define ConnectionId_hpp_
#include <string>
#include "command/AbstractCommand.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
using namespace std;
/*
* Dummy, should be auto-generated.
*/
class ConnectionId : public AbstractCommand
{
private:
p<string> value ;
const static int TYPE = 120 ;
public:
ConnectionId() ;
virtual ~ConnectionId() ;
virtual int getCommandType() ;
virtual void setValue(const char* value) ;
virtual p<string> getValue() ;
} ;
/* namespace */
}
}
}
}
#endif /*ConnectionId_hpp_*/

View File

@ -0,0 +1,85 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/ConnectionInfo.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
ConnectionInfo::ConnectionInfo()
{
connectionId = NULL ;
brokerPath = NULL ;
username = new string() ;
password = new string() ;
clientId = new string() ;
}
ConnectionInfo::~ConnectionInfo()
{
}
p<ConnectionId> ConnectionInfo::getConnectionId()
{
return connectionId ;
}
void ConnectionInfo::setConnectionId(p<ConnectionId> connectionId)
{
this->connectionId = connectionId ;
}
p<string> ConnectionInfo::getUsername()
{
return this->username ;
}
void ConnectionInfo::setUsername(const char* username)
{
this->username->assign( username ) ;
}
p<string> ConnectionInfo::getPassword()
{
return this->password ;
}
void ConnectionInfo::setPassword(const char* password)
{
this->password->assign( password ) ;
}
p<string> ConnectionInfo::getClientId()
{
return this->clientId ;
}
void ConnectionInfo::setClientId(const char* clientId)
{
this->clientId->assign( clientId ) ;
}
p<BrokerId*> ConnectionInfo::getBrokerPath()
{
return this->brokerPath ;
}
void ConnectionInfo::setBrokerPath(p<BrokerId*> brokerPath)
{
this->brokerPath = brokerPath ;
}

View File

@ -0,0 +1,73 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ConnectionInfo_hpp_
#define ConnectionInfo_hpp_
#include <string>
#include "command/BaseCommand.hpp"
#include "command/BrokerId.hpp"
#include "command/ConnectionId.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
using namespace std;
/*
* Dummy, should be auto-generated.
*/
class ConnectionInfo : public BaseCommand
{
private:
p<ConnectionId> connectionId ;
p<BrokerId*> brokerPath ;
p<string> username,
password,
clientId ;
public:
const static int TYPE = 3 ;
public:
ConnectionInfo() ;
virtual ~ConnectionInfo() ;
virtual p<ConnectionId> getConnectionId() ;
virtual void setConnectionId(p<ConnectionId> connectionId) ;
virtual p<string> getUsername() ;
virtual void setUsername(const char* username) ;
virtual p<string> getPassword() ;
virtual void setPassword(const char* password) ;
virtual p<string> getClientId() ;
virtual void setClientId(const char* clientId) ;
virtual p<BrokerId*> getBrokerPath() ;
virtual void setBrokerPath(p<BrokerId*> brokerPath) ;
} ;
/* namespace */
}
}
}
}
#endif /*ConnectionInfo_hpp_*/

View File

@ -0,0 +1,66 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/ConsumerId.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
ConsumerId::ConsumerId()
{
connectionId = new string() ;
}
ConsumerId::~ConsumerId()
{
}
int ConsumerId::getCommandType()
{
return ConsumerId::TYPE ;
}
void ConsumerId::setValue(long consumerId)
{
this->consumerId = consumerId ;
}
long ConsumerId::getValue()
{
return consumerId ;
}
void ConsumerId::setSessionId(long sessionId)
{
this->sessionId = sessionId ;
}
long ConsumerId::getSessionId()
{
return sessionId ;
}
void ConsumerId::setConnectionId(const char* connectionId)
{
this->connectionId->assign( connectionId ) ;
}
p<string> ConsumerId::getConnectionId()
{
return connectionId ;
}

View File

@ -0,0 +1,66 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ConsumerId_hpp_
#define ConsumerId_hpp_
#include <string>
#include "command/AbstractCommand.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
using namespace std;
/*
* Dummy, should be auto-generated.
*/
class ConsumerId : public AbstractCommand
{
private:
p<string> connectionId ;
long sessionId,
consumerId ;
const static int TYPE = 122 ;
public:
ConsumerId() ;
virtual ~ConsumerId() ;
virtual int getCommandType() ;
virtual void setValue(long consumerId) ;
virtual long getValue() ;
virtual void setSessionId(long sessionId) ;
virtual long getSessionId() ;
virtual void setConnectionId(const char* connectionId) ;
virtual p<string> getConnectionId() ;
} ;
/* namespace */
}
}
}
}
#endif /*ConsumerId_hpp_*/

View File

@ -0,0 +1,46 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/ConsumerInfo.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
ConsumerInfo::ConsumerInfo()
{
consumerId = NULL ;
}
ConsumerInfo::ConsumerInfo(const char* name)
{
consumerId = NULL ;
}
ConsumerInfo::~ConsumerInfo()
{
}
p<ConsumerId> ConsumerInfo::getConsumerId()
{
return consumerId ;
}
void ConsumerInfo::setConsumerId(p<ConsumerId> consumerId)
{
this->consumerId = consumerId ;
}

View File

@ -0,0 +1,60 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ConsumerInfo_hpp_
#define ConsumerInfo_hpp_
#include "command/BaseCommand.hpp"
#include "command/ConsumerId.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
/*
* Dummy, should be auto-generated.
*/
class ConsumerInfo : public BaseCommand
{
private:
p<ConsumerId> consumerId ;
public:
const static int TYPE = 5 ;
public:
ConsumerInfo() ;
ConsumerInfo(const char* name) ;
virtual ~ConsumerInfo() ;
virtual p<ConsumerId> getConsumerId() ;
virtual void setConsumerId(p<ConsumerId> consumerId) ;
} ;
/* namespace */
}
}
}
}
#endif /*ConsumerInfo_hpp_*/

View File

@ -0,0 +1,45 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/ExceptionResponse.hpp"
using namespace apache::activemq::client::command;
/*
*
*/
ExceptionResponse::ExceptionResponse()
{
}
ExceptionResponse::~ExceptionResponse()
{
}
int ExceptionResponse::getCommandType()
{
return ExceptionResponse::TYPE ;
}
p<BrokerError> ExceptionResponse::getException()
{
return exception ;
}
void ExceptionResponse::setException(p<BrokerError> exception)
{
this->exception = exception ;
}

View File

@ -0,0 +1,61 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ExceptionResponse_hpp_
#define ExceptionResponse_hpp_
#include "BrokerError.hpp"
#include "command/Response.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
using namespace apache::activemq::client;
/*
*
*/
class ExceptionResponse : public Response
{
private:
p<BrokerError> exception ;
public:
static const int TYPE = 31 ;
public:
ExceptionResponse() ;
~ExceptionResponse() ;
virtual int getCommandType() ;
p<BrokerError> getException() ;
void setException(p<BrokerError> exception) ;
};
/* namespace */
}
}
}
}
#endif /*ExceptionResponse_hpp_*/

View File

@ -0,0 +1,45 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ICommand_hpp_
#define ICommand_hpp_
#include "command/IDataStructure.hpp"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
/*
* Interface for commands.
*/
struct ICommand : IDataStructure
{
// virtual char getCommandType() = 0 ;
} ;
/* namespace */
}
}
}
}
#endif /*ICommand_hpp_*/

View File

@ -0,0 +1,43 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IDataStructure_hpp_
#define IDataStructure_hpp_
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
/*
* Mockup interface for writing to streams.
*/
struct IDataStructure
{
virtual int getCommandType() = 0 ;
} ;
/* namespace */
}
}
}
}
#endif /*IDataStructure_hpp_*/

View File

@ -0,0 +1,40 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/Message.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
Message::Message()
{
}
Message::~Message()
{
}
p<ActiveMQDestination> Message::getDestination()
{
return destination ;
}
void Message::setDestination(p<ActiveMQDestination> destination)
{
this->destination = destination ;
}

View File

@ -0,0 +1,58 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef Message_hpp_
#define Message_hpp_
#include <string>
#include "IMessage.hpp"
#include "command/BaseCommand.hpp"
#include "command/ActiveMQDestination.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
/*
* Dummy, should be auto-generated.
*/
class Message : public BaseCommand
{
private:
p<ActiveMQDestination> destination ;
public:
Message() ;
virtual ~Message() ;
virtual p<ActiveMQDestination> getDestination() ;
virtual void setDestination(p<ActiveMQDestination> destination) ;
} ;
/* namespace */
}
}
}
}
#endif /*Message_hpp_*/

View File

@ -0,0 +1,30 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/MessageAck.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
MessageAck::MessageAck()
{
}
MessageAck::~MessageAck()
{
}

View File

@ -0,0 +1,50 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MessageAck_hpp_
#define MessageAck_hpp_
#include "command/BaseCommand.hpp"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
/*
* Dummy, should be auto-generated.
*/
class MessageAck : public BaseCommand
{
public:
const static int TYPE = 22 ;
public:
MessageAck() ;
virtual ~MessageAck() ;
} ;
/* namespace */
}
}
}
}
#endif /*MessageAck_hpp_*/

View File

@ -0,0 +1,66 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/ProducerId.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
ProducerId::ProducerId()
{
connectionId = new string() ;
}
ProducerId::~ProducerId()
{
}
int ProducerId::getCommandType()
{
return ProducerId::TYPE ;
}
void ProducerId::setValue(long producerId)
{
this->producerId = producerId ;
}
long ProducerId::getValue()
{
return producerId ;
}
long ProducerId::getSessionId()
{
return sessionId ;
}
void ProducerId::setSessionId(long sessionId)
{
this->sessionId = sessionId ;
}
p<string> ProducerId::getConnectionId()
{
return connectionId ;
}
void ProducerId::setConnectionId(const char* connectionId)
{
this->connectionId->assign( connectionId ) ;
}

View File

@ -0,0 +1,66 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ProducerId_hpp_
#define ProducerId_hpp_
#include <string>
#include "command/AbstractCommand.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
using namespace std;
/*
* Dummy, should be auto-generated.
*/
class ProducerId : public AbstractCommand
{
private:
p<string> connectionId ;
long sessionId,
producerId ;
const static int TYPE = 123 ;
public:
ProducerId() ;
virtual ~ProducerId() ;
virtual int getCommandType() ;
virtual void setValue(long producerId) ;
virtual long getValue() ;
virtual void setSessionId(long sessionId) ;
virtual long getSessionId() ;
virtual void setConnectionId(const char* connectionId) ;
virtual p<string> getConnectionId() ;
} ;
/* namespace */
}
}
}
}
#endif /*ProducerId_hpp_*/

View File

@ -0,0 +1,52 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/ProducerInfo.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
ProducerInfo::ProducerInfo()
{
this->producerId = NULL ;
this->destination = NULL ;
}
ProducerInfo::~ProducerInfo()
{
}
p<ProducerId> ProducerInfo::getProducerId()
{
return producerId ;
}
void ProducerInfo::setProducerId(p<ProducerId> producerId)
{
this->producerId = producerId ;
}
p<IDestination> ProducerInfo::getDestination()
{
return destination ;
}
void ProducerInfo::setDestination(p<IDestination> destination)
{
this->destination = destination ;
}

View File

@ -0,0 +1,65 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ProducerInfo_hpp_
#define ProducerInfo_hpp_
#include <string>
#include "IDestination.hpp"
#include "command/BaseCommand.hpp"
#include "command/ProducerId.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
using namespace apache::activemq::client;
/*
* Dummy, should be auto-generated.
*/
class ProducerInfo : public BaseCommand
{
private:
p<ProducerId> producerId ;
p<IDestination> destination ;
public:
const static int TYPE = 6 ;
public:
ProducerInfo() ;
virtual ~ProducerInfo() ;
virtual p<ProducerId> getProducerId() ;
virtual void setProducerId(p<ProducerId> producerId) ;
virtual p<IDestination> getDestination() ;
virtual void setDestination(p<IDestination> destination) ;
} ;
/* namespace */
}
}
}
}
#endif /*ProducerInfo_hpp_*/

View File

@ -0,0 +1,40 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/RemoveInfo.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
RemoveInfo::RemoveInfo()
{
}
RemoveInfo::~RemoveInfo()
{
}
p<IDataStructure> RemoveInfo::getObjectId()
{
return objectId ;
}
void RemoveInfo::setObjectId(p<IDataStructure> oid)
{
this->objectId = oid ;
}

View File

@ -0,0 +1,59 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef RemoveInfo_hpp_
#define RemoveInfo_hpp_
#include "command/BaseCommand.hpp"
#include "command/IDataStructure.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
/*
* Dummy, should be auto-generated.
*/
class RemoveInfo : public BaseCommand
{
private:
p<IDataStructure> objectId ;
public:
const static int TYPE = 12 ;
public:
RemoveInfo() ;
virtual ~RemoveInfo() ;
virtual p<IDataStructure> getObjectId() ;
virtual void setObjectId(p<IDataStructure> oid) ;
} ;
/* namespace */
}
}
}
}
#endif /*RemoveInfo_hpp_*/

View File

@ -0,0 +1,30 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/Response.hpp"
using namespace apache::activemq::client::command;
/*
*
*/
Response::Response()
{
}
Response::~Response()
{
}

View File

@ -0,0 +1,50 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef Response_hpp_
#define Response_hpp_
#include "command/BaseCommand.hpp"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
/*
* Interface for commands.
*/
class Response : public BaseCommand
{
public:
const static int TYPE = 30 ;
public:
Response() ;
~Response() ;
};
/* namespace */
}
}
}
}
#endif /*Response_hpp_*/

View File

@ -0,0 +1,56 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/SessionId.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
SessionId::SessionId()
{
connectionId = new string() ;
}
SessionId::~SessionId()
{
}
int SessionId::getCommandType()
{
return SessionId::TYPE ;
}
void SessionId::setValue(long sessionId)
{
this->sessionId = sessionId ;
}
long SessionId::getValue()
{
return sessionId ;
}
void SessionId::setConnectionId(const char* connectionId)
{
this->connectionId->assign( connectionId ) ;
}
p<string> SessionId::getConnectionId()
{
return connectionId ;
}

View File

@ -0,0 +1,63 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SessionId_hpp_
#define SessionId_hpp_
#include <string>
#include "command/AbstractCommand.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
using namespace std;
/*
* Dummy, should be auto-generated.
*/
class SessionId : public AbstractCommand
{
private:
p<string> connectionId ;
long sessionId ;
const static int TYPE = 121 ;
public:
SessionId() ;
virtual ~SessionId() ;
virtual int getCommandType() ;
virtual void setValue(long id) ;
virtual long getValue() ;
virtual void setConnectionId(const char* cid) ;
virtual p<string> getConnectionId() ;
} ;
/* namespace */
}
}
}
}
#endif /*SessionId_hpp_*/

View File

@ -0,0 +1,40 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "command/SessionInfo.hpp"
using namespace apache::activemq::client::command;
/*
* Dummy, should be auto-generated
*/
SessionInfo::SessionInfo()
{
}
SessionInfo::~SessionInfo()
{
}
p<SessionId> SessionInfo::getSessionId()
{
return sessionId ;
}
void SessionInfo::setSessionId(p<SessionId> sessionId)
{
this->sessionId = sessionId ;
}

View File

@ -0,0 +1,59 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SessionInfo_hpp_
#define SessionInfo_hpp_
#include "command/BaseCommand.hpp"
#include "command/SessionId.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace command
{
using namespace ifr;
/*
* Dummy, should be auto-generated.
*/
class SessionInfo : public BaseCommand
{
private:
p<SessionId> sessionId ;
public:
const static int TYPE = 4 ;
public:
SessionInfo() ;
virtual ~SessionInfo() ;
virtual p<SessionId> getSessionId() ;
virtual void setSessionId(p<SessionId> sessionId) ;
} ;
/* namespace */
}
}
}
}
#endif /*SessionInfo_hpp_*/

View File

@ -0,0 +1,143 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "io/BinaryReader.hpp"
using namespace apache::activemq::client::io;
/*
*
*/
BinaryReader::BinaryReader()
{
// no-op
}
/*
*
*/
BinaryReader::~BinaryReader()
{
// no-op
}
/*
*
*/
char BinaryReader::readByte() throw(IOException)
{
char value ;
// Read a single byte
read(&value, sizeof(char)) ;
return value ;
}
/*
*
*/
bool BinaryReader::readBoolean() throw(IOException)
{
bool value ;
// Read a boolean
read((char*)&value, sizeof(bool)) ;
return value ;
}
/*
*
*/
double BinaryReader::readDouble() throw(IOException)
{
double value ;
// Read a double and convert from big endian to little endian if necessary
read((char*)&value, sizeof(double) ) ;
return ntohd(value) ;
}
/*
*
*/
float BinaryReader::readFloat() throw(IOException)
{
float value ;
// Read a float and convert from big endian to little endian if necessary
read((char*)&value, sizeof(float)) ;
return ntohf(value) ;
}
/*
*
*/
short BinaryReader::readShort() throw(IOException)
{
short value ;
// Read a short and convert from big endian to little endian if necessary
read((char*)&value, sizeof(short)) ;
return ntohs(value) ;
}
/*
*
*/
int BinaryReader::readInt() throw(IOException)
{
int value ;
// Read an int and convert from big endian to little endian if necessary
read((char*)&value, sizeof(int)) ;
return ntohi(value) ;
}
/*
*
*/
long long BinaryReader::readLong() throw(IOException)
{
long long value ;
// Read a long long and convert from big endian to little endian if necessary
read((char*)&value, sizeof(long long)) ;
return ntohl(value) ;
}
/*
*
*/
p<string> BinaryReader::readString() throw(IOException)
{
p<string> value ;
char* buffer ;
short length ;
// Read length of string
length = readShort() ;
buffer = new char[length+1] ;
// Read string bytes
read(buffer, length) ;
*(buffer+length) = '\0' ;
// Create string class
value = new string() ;
value->assign(buffer) ;
return value ;
}

View File

@ -0,0 +1,69 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef BinaryReader_hpp_
#define BinaryReader_hpp_
#include "util/Endian.hpp"
#include "io/IReader.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace io
{
using namespace ifr;
/*
* The BinaryReader class reads primitive C++ data types from an
* underlying input stream in a Java compatible way. Strings are
* read as raw bytes, no character decoding is performed.
*
* All numeric data types are assumed to be available in big
* endian (network byte order) and are converted automatically
* to little endian if needed by the platform.
*
* Should any error occur an IOException will be thrown.
*/
class BinaryReader : public IReader
{
public:
BinaryReader() ;
virtual ~BinaryReader() ;
virtual void close() throw(IOException) = 0 ;
virtual int read(char* buffer, int size) throw(IOException) = 0 ;
virtual char readByte() throw(IOException) ;
virtual bool readBoolean() throw(IOException) ;
virtual double readDouble() throw(IOException) ;
virtual float readFloat() throw(IOException) ;
virtual short readShort() throw(IOException) ;
virtual int readInt() throw(IOException) ;
virtual long long readLong() throw(IOException) ;
virtual p<string> readString() throw(IOException) ;
} ;
/* namespace */
}
}
}
}
#endif /*BinaryReader_hpp_*/

View File

@ -0,0 +1,96 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "io/BinaryWriter.hpp"
using namespace apache::activemq::client::io;
/*
*
*/
BinaryWriter::BinaryWriter()
{
// no-op
}
/*
*
*/
BinaryWriter::~BinaryWriter()
{
// no-op
}
void BinaryWriter::writeByte(char value) throw(IOException)
{
// Write a single byte
write((char*)&value, sizeof(char)) ;
}
void BinaryWriter::writeBoolean(bool value) throw(IOException)
{
// Write a boolean
write((char*)&value, sizeof(bool)) ;
}
void BinaryWriter::writeDouble(double v) throw(IOException)
{
// Write a double, convert from little endian to big endian if necessary
double value = htond(v) ;
write((char*)&value, sizeof(double)) ;
}
void BinaryWriter::writeFloat(float v) throw(IOException)
{
// Write a float, convert from little endian to big endian if necessary
float value = htonf(v) ;
write((char*)&value, sizeof(float)) ;
}
void BinaryWriter::writeShort(short v) throw(IOException)
{
// Write a short, convert from little endian to big endian if necessary
short value = htons(v) ;
write((char*)&value, sizeof(short)) ;
}
void BinaryWriter::writeInt(int v) throw(IOException)
{
// Write an int, convert from little endian to big endian if necessary
int value = htoni(v) ;
write((char*)&value, sizeof(int)) ;
}
void BinaryWriter::writeLong(long long v) throw(IOException)
{
// Write a long long, convert from little endian to big endian if necessary
long long value = htonl(v) ;
write((char*)&value, sizeof(long long)) ;
}
void BinaryWriter::writeString(p<string> value) throw(IOException)
{
// Assert argument
if( value->length() > USHRT_MAX )
throw IOException("String length exceeds maximum length") ;
// Write length of string
short length = (short)value->length() ;
writeShort( length ) ;
// Write string contents
write((char*)value->c_str(), length) ;
}

View File

@ -0,0 +1,70 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef BinaryWriter_hpp_
#define BinaryWriter_hpp_
#include "util/Endian.hpp"
#include "io/IWriter.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace io
{
using namespace ifr;
/*
* The BinaryWriter class writes primitive C++ data types to an
* underlying output stream in a Java compatible way. Strings
* are written as raw bytes, no character encoding is performed.
*
* All numeric data types are written in big endian (network byte
* order) and if the platform is little endian they are converted
* automatically.
*
* Should any error occur an IOException will be thrown.
*/
class BinaryWriter : public IWriter
{
public:
BinaryWriter() ;
virtual ~BinaryWriter() ;
virtual void close() throw(IOException) = 0 ;
virtual void flush() throw(IOException) = 0 ;
virtual int write(char* buffer, int size) throw(IOException) = 0 ;
virtual void writeByte(char v) throw(IOException) ;
virtual void writeBoolean(bool v) throw(IOException) ;
virtual void writeDouble(double v) throw(IOException) ;
virtual void writeFloat(float v) throw(IOException) ;
virtual void writeShort(short v) throw(IOException) ;
virtual void writeInt(int v) throw(IOException) ;
virtual void writeLong(long long v) throw(IOException) ;
virtual void writeString(p<string> v) throw(IOException) ;
} ;
/* namespace */
}
}
}
}
#endif /*BinaryWriter_hpp_*/

View File

@ -0,0 +1,52 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IOException_hpp_
#define IOException_hpp_
#include "TraceException.hpp"
namespace apache
{
namespace activemq
{
namespace client
{
namespace io
{
using namespace std ;
/*
* Signals that an I/O exception of some sort has occurred.
*/
class IOException : public TraceException
{
public:
IOException() : TraceException()
{ /* no-op */ } ;
IOException(const char *const& msg) : TraceException(msg)
{ /* no-op */ } ;
IOException(const char* fileName, int lineNo, const char* msg) : TraceException(msg)
{ /* no-op */ } ;
} ;
/* namespace */
}
}
}
}
#endif /*IOException_hpp_*/

68
openwire-cpp/src/io/IReader.hpp Executable file
View File

@ -0,0 +1,68 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IReader_hpp_
#define IReader_hpp_
// Turn off warning message for ignored exception specification
#ifdef _MSC_VER
#pragma warning( disable : 4290 )
#endif
#include <string>
#include "io/IOException.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace io
{
using namespace std ;
using namespace ifr ;
/*
* The IReader interface provides for reading bytes from a binary stream
* and reconstructing from them data in any of the C++ primitive types.
* Strings are read as raw bytes, no character decoding is performed. If
* any byte cannot be read for any reason, an IOException is thrown.
*/
struct IReader
{
virtual ~IReader() { } ; // Required for SP's
virtual void close() throw(IOException) = 0 ;
virtual int read(char* buffer, int size) throw(IOException) = 0 ;
virtual char readByte() throw(IOException) = 0 ;
virtual bool readBoolean() throw(IOException) = 0 ;
virtual double readDouble() throw(IOException) = 0 ;
virtual float readFloat() throw(IOException) = 0 ;
virtual short readShort() throw(IOException) = 0 ;
virtual int readInt() throw(IOException) = 0 ;
virtual long long readLong() throw(IOException) = 0 ;
virtual p<string> readString() throw(IOException) = 0 ;
} ;
/* namespace */
}
}
}
}
#endif /*IReader_hpp_*/

70
openwire-cpp/src/io/IWriter.hpp Executable file
View File

@ -0,0 +1,70 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IWriter_hpp_
#define IWriter_hpp_
// Turn off warning message for ignored exception specification
#ifdef _MSC_VER
#pragma warning( disable : 4290 )
#endif
#include <string>
#include "io/IOException.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace io
{
using namespace std ;
using namespace ifr ;
/*
* The IWriter interface provides for converting data from any of the
* C++ primitive types to a series of bytes and writing these bytes to
* a binary stream. Strings are written as raw bytes, no character
* encoding is performed. If a byte cannot be written for any reason,
* an IOException is thrown.
*/
struct IWriter
{
virtual ~IWriter() { } ; // Needed for SP's
virtual void close() throw(IOException) = 0 ;
virtual void flush() throw(IOException) = 0 ;
virtual int write(char* buffer, int size) throw(IOException) = 0 ;
virtual void writeByte(char v) throw(IOException) = 0 ;
virtual void writeBoolean(bool v) throw(IOException) = 0 ;
virtual void writeDouble(double v) throw(IOException) = 0 ;
virtual void writeFloat(float v) throw(IOException) = 0 ;
virtual void writeShort(short v) throw(IOException) = 0 ;
virtual void writeInt(int v) throw(IOException) = 0 ;
virtual void writeLong(long long v) throw(IOException) = 0 ;
virtual void writeString(p<string> v) throw(IOException) = 0 ;
} ;
/* namespace */
}
}
}
}
#endif /*IWriter_hpp_*/

View File

@ -0,0 +1,77 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "io/SocketBinaryReader.hpp"
using namespace apache::activemq::client::io;
/*
*
*/
SocketBinaryReader::SocketBinaryReader(apr_socket_t* socket)
{
this->socket = socket ;
}
/*
*
*/
SocketBinaryReader::~SocketBinaryReader()
{
// no-op
}
void SocketBinaryReader::close() throw(IOException)
{
// no-op
}
/*
*
*/
int SocketBinaryReader::read(char* buffer, int size) throw(IOException)
{
apr_size_t length, remaining = size ;
apr_status_t rc ;
// Loop until requested number of bytes are read
while( remaining > 0 )
{
// Try to read remaining bytes
length = remaining ;
// Read some bytes from socket
rc = apr_socket_recv(socket, buffer, &length) ;
// Adjust buffer pointer and remaining number of bytes
buffer += length ;
remaining -= length ;
// Exit on any error
if( rc != APR_SUCCESS )
{
string message ;
char buf[10] ;
// Construct error message
message.assign("Failed to read from socket. Code = ") ;
message.append( itoa(rc, buf, 10) ) ;
throw IOException(__FILE__, __LINE__, message.c_str()) ;
}
}
return (int)size ;
}

View File

@ -0,0 +1,58 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SocketBinaryReader_hpp_
#define SocketBinaryReader_hpp_
#include <apr_network_io.h>
#include "io/BinaryReader.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace io
{
using namespace ifr ;
/*
* SocketBinaryReader reads primitive C++ data types from a
* socket stream. It currently uses APR sockets for
* platform independency.
*/
class SocketBinaryReader : public BinaryReader
{
private:
apr_socket_t* socket ;
public:
SocketBinaryReader(apr_socket_t* socket) ;
~SocketBinaryReader() ;
virtual void close() throw(IOException) ;
virtual int read(char* buffer, int size) throw(IOException) ;
} ;
/* namespace */
}
}
}
}
#endif /*SocketBinaryReader_hpp_*/

View File

@ -0,0 +1,82 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "io/SocketBinaryWriter.hpp"
using namespace apache::activemq::client::io;
/*
*
*/
SocketBinaryWriter::SocketBinaryWriter(apr_socket_t* socket)
{
this->socket = socket ;
}
/*
*
*/
SocketBinaryWriter::~SocketBinaryWriter()
{
// no-op
}
void SocketBinaryWriter::close() throw(IOException)
{
// no-op
}
void SocketBinaryWriter::flush() throw(IOException)
{
// no-op
}
/*
*
*/
int SocketBinaryWriter::write(char* buffer, int size) throw(IOException)
{
apr_size_t length, remaining = size ;
apr_status_t rc ;
// Loop until requested number of bytes are read
while( remaining > 0 )
{
// Try to read remaining bytes
length = remaining ;
// Write some bytes to socket
rc = apr_socket_send(socket, buffer, &length) ;
// Adjust buffer pointer and remaining number of bytes
buffer += length ;
remaining -= length ;
// Exit on any error
if( rc != APR_SUCCESS )
{
string message ;
char buf[10] ;
// Construct error message
message.assign("Failed to write to socket. Code = ") ;
message.append( itoa(rc, buf, 10) ) ;
throw IOException(__FILE__, __LINE__, message.c_str()) ;
}
}
return (int)size ;
}

View File

@ -0,0 +1,59 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SocketBinaryWriter_hpp_
#define SocketBinaryWriter_hpp_
#include <apr_network_io.h>
#include "io/BinaryWriter.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace io
{
using namespace ifr ;
/*
* SocketBinaryWriter writes primitive C++ data types to a
* socket stream. It currently uses APR sockets for
* platform independency.
*/
class SocketBinaryWriter : public BinaryWriter
{
private:
apr_socket_t* socket ;
public:
SocketBinaryWriter(apr_socket_t* socket) ;
virtual ~SocketBinaryWriter() ;
virtual void close() throw(IOException) ;
virtual void flush() throw(IOException) ;
virtual int write(char* buffer, int size) throw(IOException) ;
} ;
/* namespace */
}
}
}
}
#endif /*SocketBinaryWriter_hpp_*/

View File

@ -0,0 +1,146 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "marshal/AbstractCommandMarshaller.hpp"
#include "marshal/BrokerInfoMarshaller.hpp"
#include "marshal/BrokerIdMarshaller.hpp"
using namespace apache::activemq::client::marshal;
/*
*
*/
AbstractCommandMarshaller::AbstractCommandMarshaller()
{
}
AbstractCommandMarshaller::~AbstractCommandMarshaller()
{
}
p<ICommand> AbstractCommandMarshaller::readCommand(p<BinaryReader> reader)
{
p<ICommand> command = createCommand() ;
buildCommand(command, reader) ;
return command ;
}
// Implementation methods -----------------------------------------------------------
p<BrokerError> AbstractCommandMarshaller::readBrokerError(p<BinaryReader> reader)
{
p<BrokerError> error = new BrokerError() ;
error->setExceptionClass( reader->readString()->c_str() ) ;
error->setStackTrace( reader->readString()->c_str() ) ;
return error ;
}
void AbstractCommandMarshaller::writeBrokerError(p<BrokerError> command, p<BinaryWriter> writer)
{
writer->writeString( command->getExceptionClass() ) ;
writer->writeString( command->getStackTrace() ) ;
}
p<IDestination> AbstractCommandMarshaller::readDestination(p<BinaryReader> reader)
{
return (p<IDestination>&)CommandMarshallerRegistry::readCommand(reader) ;
}
void AbstractCommandMarshaller::writeDestination(p<IDestination> command, p<BinaryWriter> writer)
{
CommandMarshallerRegistry::writeCommand((p<ICommand>&)command, writer) ;
}
ap<BrokerId> AbstractCommandMarshaller::readBrokerIds(p<BinaryReader> reader)
{
int size = reader->readInt() ;
p<BrokerIdMarshaller> marshaller = CommandMarshallerRegistry::getBrokerIdMarshaller() ;
ap<BrokerId> brokerIds (size);
for( int i = 0; i < size; i++ )
brokerIds[i] = (p<BrokerId>&)marshaller->readCommand(reader) ;
return brokerIds ;
}
void AbstractCommandMarshaller::writeBrokerIds(ap<BrokerId> commands, p<BinaryWriter> writer)
{
int size = (int)commands.size() ;
p<BrokerIdMarshaller> marshaller = CommandMarshallerRegistry::getBrokerIdMarshaller() ;
writer->writeInt(size) ;
for( int i = 0; i < size; i++ )
marshaller->writeCommand(commands[i], writer) ;
}
ap<BrokerInfo> AbstractCommandMarshaller::readBrokerInfos(p<BinaryReader> reader)
{
int size = reader->readInt() ;
p<BrokerInfoMarshaller> marshaller = CommandMarshallerRegistry::getBrokerInfoMarshaller() ;
ap<BrokerInfo> brokerInfos (size) ;
for( int i = 0; i < size; i++ )
brokerInfos[i] = (p<BrokerInfo>&)marshaller->readCommand(reader) ;
return brokerInfos ;
}
void AbstractCommandMarshaller::writeBrokerInfos(ap<BrokerInfo> commands, p<BinaryWriter> writer)
{
int size = (int)commands.size() ;
p<BrokerInfoMarshaller> marshaller = CommandMarshallerRegistry::getBrokerInfoMarshaller() ;
writer->writeInt(size) ;
for( int i = 0; i < size; i++ )
marshaller->writeCommand((p<ICommand>&)commands[i], writer);
}
ap<IDataStructure> AbstractCommandMarshaller::readDataStructures(p<BinaryReader> reader)
{
int size = reader->readInt() ;
ap<IDataStructure> dataStructs (size) ;
for( int i = 0; i < size; i++ )
dataStructs[i] = (p<IDataStructure>&)CommandMarshallerRegistry::readCommand(reader) ;
return dataStructs ;
}
void AbstractCommandMarshaller::writeDataStructures(ap<IDataStructure> commands, p<BinaryWriter> writer)
{
int size = (int)commands.size() ;
writer->writeInt(size) ;
for( int i = 0; i < size; i++ )
CommandMarshallerRegistry::writeCommand((p<ICommand>&)commands[i], writer) ;
}
char* AbstractCommandMarshaller::readBytes(p<BinaryReader> reader)
{
int size = reader->readInt() ;
char* buffer = new char[size];
reader->read(buffer, size) ;
return buffer ;
}
void AbstractCommandMarshaller::writeBytes(char* buffer, int size, p<BinaryWriter> writer)
{
writer->writeInt(size) ;
writer->write(buffer, size) ;
}

View File

@ -0,0 +1,81 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef AbstractCommandMarshaller_hpp_
#define AbstractCommandMarshaller_hpp_
#include "IDestination.hpp"
#include "BrokerError.hpp"
#include "command/ICommand.hpp"
#include "command/IDataStructure.hpp"
#include "command/BrokerInfo.hpp"
#include "command/BrokerId.hpp"
#include "io/BinaryReader.hpp"
#include "io/BinaryWriter.hpp"
#include "marshal/CommandMarshallerRegistry.hpp"
#include "util/ifr/p"
#include "util/ifr/ap"
namespace apache
{
namespace activemq
{
namespace client
{
namespace marshal
{
using namespace ifr ;
using namespace std ;
using namespace apache::activemq::client;
using namespace apache::activemq::client::command;
using namespace apache::activemq::client::io;
/*
*
*/
class AbstractCommandMarshaller
{
public:
AbstractCommandMarshaller() ;
virtual ~AbstractCommandMarshaller() ;
virtual p<ICommand> createCommand() = 0 ;
virtual p<ICommand> readCommand(p<BinaryReader> reader) ;
virtual void buildCommand(p<ICommand> command, p<BinaryReader> reader) = 0 ;
virtual void writeCommand(p<ICommand> command, p<BinaryWriter> writer) = 0 ;
protected:
virtual p<BrokerError> readBrokerError(p<BinaryReader> reader) ;
virtual void writeBrokerError(p<BrokerError> command, p<BinaryWriter> writer) ;
virtual p<IDestination> readDestination(p<BinaryReader> reader) ;
virtual void writeDestination(p<IDestination> command, p<BinaryWriter> writer) ;
virtual ap<BrokerId> readBrokerIds(p<BinaryReader> reader) ;
virtual void writeBrokerIds(ap<BrokerId> commands, p<BinaryWriter> writer) ;
virtual ap<BrokerInfo> readBrokerInfos(p<BinaryReader> reader) ;
virtual void writeBrokerInfos(ap<BrokerInfo> commands, p<BinaryWriter> writer) ;
virtual ap<IDataStructure> readDataStructures(p<BinaryReader> reader) ;
virtual void writeDataStructures(ap<IDataStructure> commands, p<BinaryWriter> writer) ;
virtual char* readBytes(p<BinaryReader> reader) ;
virtual void writeBytes(char* buffer, int size, p<BinaryWriter> writer) ;
} ;
/* namespace */
}
}
}
}
#endif /*AbstractCommandMarshaller_hpp_*/

View File

@ -0,0 +1,53 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "marshal/BrokerIdMarshaller.hpp"
using namespace apache::activemq::client::marshal;
/*
*
*/
BrokerIdMarshaller::BrokerIdMarshaller()
{
// no-op
}
BrokerIdMarshaller::~BrokerIdMarshaller()
{
// no-op
}
p<ICommand> BrokerIdMarshaller::createCommand()
{
return new BrokerId() ;
}
void BrokerIdMarshaller::buildCommand(p<ICommand> command, p<BinaryReader> reader)
{
//AbstractCommandMarshaller::buildCommand(command, reader) ;
p<BrokerId> brokerId = (p<BrokerId>&)command ;
brokerId->setValue( reader->readString()->c_str() ) ;
}
void BrokerIdMarshaller::writeCommand(p<ICommand> command, p<BinaryWriter> writer)
{
//AbstractCommandMarshaller::writeCommand(command, writer) ;
p<BrokerId> brokerId = (p<BrokerId>&)command ;
writer->writeString( brokerId->getValue() ) ;
}

View File

@ -0,0 +1,59 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef BrokerIdMarshaller_hpp_
#define BrokerIdMarshaller_hpp_
#include "command/ICommand.hpp"
#include "command/BrokerId.hpp"
#include "io/BinaryReader.hpp"
#include "io/BinaryWriter.hpp"
#include "marshal/AbstractCommandMarshaller.hpp"
#include "util/ifr/p"
namespace apache
{
namespace activemq
{
namespace client
{
namespace marshal
{
using namespace ifr ;
using namespace apache::activemq::client::command;
using namespace apache::activemq::client::io;
/*
*
*/
class BrokerIdMarshaller : public AbstractCommandMarshaller
{
public:
BrokerIdMarshaller() ;
virtual ~BrokerIdMarshaller() ;
virtual p<ICommand> createCommand() ;
virtual void buildCommand(p<ICommand> command, p<BinaryReader> reader) ;
virtual void writeCommand(p<ICommand> command, p<BinaryWriter> writer) ;
} ;
/* namespace */
}
}
}
}
#endif /*BrokerIdMarshaller_hpp_*/

View File

@ -0,0 +1,59 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "marshal/BrokerInfoMarshaller.hpp"
using namespace apache::activemq::client::marshal;
/*
*
*/
BrokerInfoMarshaller::BrokerInfoMarshaller()
{
// no-op
}
BrokerInfoMarshaller::~BrokerInfoMarshaller()
{
// no-op
}
p<ICommand> BrokerInfoMarshaller::createCommand()
{
return new BrokerInfo() ;
}
void BrokerInfoMarshaller::buildCommand(p<ICommand> command, p<BinaryReader> reader)
{
//AbstractCommandMarshaller::buildCommand(command, reader) ;
p<BrokerInfo> brokerInfo = (p<BrokerInfo>&)command ;
brokerInfo->setBrokerId( (p<BrokerId>&)CommandMarshallerRegistry::getBrokerInfoMarshaller()->readCommand(reader) ) ;
brokerInfo->setBrokerURL( reader->readString()->c_str() ) ;
brokerInfo->setPeerBrokerInfo( AbstractCommandMarshaller::readBrokerInfos(reader) ) ;
brokerInfo->setBrokerName( reader->readString()->c_str() ) ;
}
void BrokerInfoMarshaller::writeCommand(p<ICommand> command, p<BinaryWriter> writer)
{
//AbstractCommandMarshaller::writeCommand(command, writer) ;
p<BrokerInfo> brokerInfo = (p<BrokerInfo>&)command ;
CommandMarshallerRegistry::getBrokerInfoMarshaller()->writeCommand(brokerInfo->getBrokerId(), writer) ;
writer->writeString( brokerInfo->getBrokerURL() ) ;
AbstractCommandMarshaller::writeBrokerInfos( brokerInfo->getPeerBrokerInfo(), writer) ;
writer->writeString( brokerInfo->getBrokerName() ) ;
}

Some files were not shown because too many files have changed in this diff Show More