/*
Copyright 2005 Matthew J. Battey
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.
This software implements a Java interface to SAFMQ (see http://safmq.sourceforge.net).
Created on Mar 21, 2005
*/
package com.safmq;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.URI;
import java.util.Vector;
/**
* This class provides an interface to communicate with a SAFMQ message queue
* server. Typically instances of this class are constructed by the
* <code>MQBuilder</code> class, however constructing the class directly
* is also allowed.
*
* <p>Once constructed, this class may be used to construct
* instances of the class <code>MessageQueue</code> to abstract the connection
* interface to the message queue level.</p>
*
* <p><b>Note:</b> This class is not thread safe, and applications should
* take precautions to not initiate communications with a message queue via
* more than one (1) thread simultaneously.</p>
*
* @author Matt
* @see MQBuilder#buildConnection(URI,String,String)
* @see MessageQueue
*/
public class MQConnection {
final static String FORWARD_QUEUE_NAME = "_FORWARD_";
Socket s;
DataInputStream in;
DataOutputStream out;
int server_major_protocol_version;
int server_minor_protocol_version;
/**
* Result data from a call to <code>MQConnection.EnumerateQueues(Vector)</code>.
* Instances of this class are placed into the vector passed to
* <code>EnumerateQueues()</code> to detail the specifics of the queue.
*
* @author matt
* @see MQConnection#EnumerateQueues(Vector) MQConnection.EnumerateQueues(Vector)
*/
public class QueueData {
String name;
String owner;
/**
* Constructs the QueueData object from the queue's name and owner.
* @param name The name of the queue.
* @param owner The name of the queue's owner.
*/
QueueData(String name, String owner) {
this.name = name;
this.owner = owner;
}
/**
* Provides the queue's name.
* @return The queue's name.
*/
public String getName() {
return name;
}
/**
* Provides the queue's owner's name.
* @return The queue's owner's name.
*/
public String getOwner() {
return owner;
}
}
/**
* Contains an entity's permisison when accessing a queue.
*
* @author Matt
*/
public class QueuePermissions {
String entityName;
boolean isgroup;
boolean read;
boolean write;
boolean destroy;
boolean changeSecurity;
/**
* Constructs the QueuePermissions from the name of the entity and
* flags regarding its relationsihp with the queried queue. This object
* is used as a result to
* <code>MQConnection.queueEnumeratePermissions(String,Vector)</code>.
*
* @param entityName The name of the entity these permissions pertain to
* @param isgroup A flag indicating this entity is a group (otherwise
* a user)
* @param read A flag indicating whether this entity may read from
* the queue
* @param write A flag indicating whether this entity may write to
* the queue
* @param destroy A flag indicating whether this entity may remove the
* queue from the server
* @param changeSecurity A flag indicating whether this entity may change
* the security permissions of the queue
*/
QueuePermissions(String entityName, boolean isgroup, boolean read, boolean write, boolean destroy, boolean changeSecurity) {
this.entityName = entityName;
this.isgroup = isgroup;
this.read = read;
this.write = write;
this.destroy = destroy;
this.changeSecurity = changeSecurity;
}
/**
* Provides the name of the entity these permissions pertain to.
* @return Returns the name of the entity these permissions pertain to.
*/
public String getEntityName() {
return entityName;
}
/**
* Provides the flag whether this entity may remove the queue from the server.
*
* @return Returns the flag whether this entity may remove the queue from the server.
*/
public boolean getDestroy() {
return destroy;
}
/**
* Provids a flag whether this entity is a group.
* @return Returns a flag whether this entity is a group.
*/
public boolean getIsGroup() {
return isgroup;
}
/**
* Provides a flag whether this entity is allowed to read from the queue.
* @return Returns a flag whether this entity is allowed to read from the queue.
*/
public boolean getRead() {
return read;
}
/**
* Provides a flag whether this entity is allowed to write to the queue.
* @return Returns a flag whether this entity is allowed to write to the queue.
*/
public boolean getWrite() {
return write;
}
/**
* Provides a flag whether the entity is allowed to change the security for the queue.
* @return The a flag whether the entity is allowed to change the security for the queue.
*/
public boolean getChangeSecurity() {
return changeSecurity;
}
}
/**
* Result data from a call to <code>MQConnection.EnumerateUsers(Vector)</code>.
* Instances of this class are placed into the vector passed to
* <code>EnumerateUsers()</code> to detail the specifics of the user.
*
* @author matt
*/
public class UserDescription {
String name;
String description;
/**
* Constructs the object from the user's name and description.
*
* @param name The name of the user
* @param description The description of the user
*/
UserDescription(String name, String description) {
this.name = name;
this.description = description;
}
/**
* Provides the name of the user
* @return The name of the user
*/
public String getName() {
return name;
}
/**
* Provides the description of the user
* @return The description of the user
*/
public String getDescription() {
return description;
}
public boolean equals(Object o) {
return o != null && (this==o || ((o instanceof UserDescription) && ((UserDescription)o).getName().equals(getName())) || o.equals(getName()));
}
public String toString() {
return getClass().getName()+":["+getName()+"]";
}
}
/**
* For external use of UserDescriptions.
*
* @param name Name of the account
* @param desc Description of the account
* @return A newly allocated <code>UserDescription</code> object.
*/
public UserDescription genDesc(String name, String desc) {
return new UserDescription(name,desc);
}
/**
* Constructs the object from the name of the server, the tcp/ip port to be used
* the user's name and password.
*
* @param server The network name of the server to be contacted
* @param port The TCP/IP port to be utilized in communications with the server
* @param user The name of the user wishing to connect to the server
* @param password The password of the user wishing to connect to the server
* @throws MQException In the case that the supplied credentials are not accepted by
* the SAFMQ server. The value of <code>MQException.getErrorCode()</code>
* could be but is not limited to:
*<table border=0 cellpadding=3 cellspac
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共220个文件
java:45个
h:37个
html:31个
一个简单实用的开源C++消息中间件SAFMQ - [软件开发] - [开源 消息中间件 SAFMQ ] 2006-11-23 在很多网络应用中,尤其那些服务器有时不在线的应用中,将客户端的数据变更按照产生顺序同步到服务器的操作是比较复杂的。为了解决这种问题,可以采用消息中间件产品(例如Windows的MSMQ还有IBM的MQ),但是这种产品比较庞大而且花费不少,对于小规模应用而言没有必要。 SAFMQ(全称为Store and Forward Message Queue)是一个简单的消息中间件,采用C++编写,采用Apache授权机制。截至2006年11月SAFMQ的的版本为0.5.2,发布于2006年9月。目前版本具有如下的功能: 1. 提供多队列、多优先级的消息转发服务。 2. 支持文本、二进制的消息类型。 3. 支持转发功能,即多个消息中间件之间的消息转发。 4. 支持事务操作 5. 支持Java、PHP客户端 6. 支持SSL加密 7. 支持用户权限 8. 支持对消息的标记 9. 支持TTL(Time To Live)时间戳
资源推荐
资源详情
资源评论
收起资源包目录
safmq.src.0.5.gz_MQ-2_saf_中间件 服务器_中间件服务器_消息队列 (220个子文件)
qmanager.bat 95B
uuidgen.c 7KB
mac_addr_dlpi.c 5KB
_getopt_long.c 3KB
uuidgenwin.c 934B
ClassGraphPanel.class 4KB
ClassGraphPanel.class 4KB
ClassLayout.class 2KB
ClassLayout.class 2KB
NavigatorButton.class 2KB
NavigatorButton.class 2KB
ClassGraph.class 1KB
ClassGraph.class 1KB
.classpath 235B
safmq.conf 1KB
configure 2KB
ServiceThread.cpp 48KB
MQConnection.cpp 44KB
safmqc.cpp 42KB
safmqclient.cpp 26KB
QStorage.cpp 23KB
QAccessControl.cpp 22KB
sslsocket.cpp 21KB
tcpsocket.cpp 19KB
utilities.cpp 12KB
ntservice.cpp 11KB
ntservice.cpp 10KB
MessageQueue.cpp 8KB
main.cpp 8KB
MQFactory.cpp 7KB
QManager.cpp 6KB
ForwardThread.cpp 5KB
TransactionManager.cpp 5KB
thdlib.cpp 4KB
SystemDelivery.cpp 4KB
Signal.cpp 3KB
param_config.cpp 3KB
DirectoryList.cpp 3KB
SSLServerThread.cpp 3KB
SystemConnection.cpp 2KB
ServerThread.cpp 2KB
Mutex.cpp 2KB
httpclient.cpp 1KB
server.cpp 1KB
httpclient.cpp,v 1KB
server.cpp,v 1KB
Thumbs.db 32KB
safmq.dsp 10KB
safmqlib.dsp 8KB
safmqc.dsp 7KB
safmqclient.dsp 4KB
winnt.dsp 4KB
safmq.dsw 1KB
safmqclient.dsw 825B
winnt.dsw 533B
group.gif 1KB
group.gif 1KB
user.gif 1KB
server.gif 1KB
user.gif 1KB
groupsmall.gif 916B
queuesmall.gif 910B
serversmall_u.gif 904B
serversmall_dc.gif 902B
serversmall_c.gif 902B
usersmall.gif 898B
remove.gif 869B
remove.gif 581B
add.gif 580B
queuesmall.GIF 469B
icon2.gif 326B
icon1.gif 326B
icon2.gif 326B
icon1.gif 326B
groupsmall.gif 325B
usersmall.gif 325B
serversmall_u.GIF 325B
serversmall_c.GIF 325B
serversmall_dc.GIF 325B
server.gif 227B
add.gif 86B
server_operators.h 12KB
safmq.h 12KB
comdefs.h 10KB
socstream.h 10KB
tcpsocket.h 10KB
client_operators.h 9KB
QAccessControl.h 9KB
quectrl.h 8KB
QStorage.h 8KB
MQConnection.h 8KB
randpq.h 7KB
ntservice.h 6KB
bufstream.h 6KB
utilities.h 6KB
sslsocket.h 5KB
urldecode.h 5KB
regutil.h 4KB
ServiceThread.h 4KB
QManager.h 2KB
共 220 条
- 1
- 2
- 3
资源评论
alvarocfc
- 粉丝: 105
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功