📄 ipcjmsadminconnection.java
字号:
* OpenJMSServer. This is only valid when in online mode.
*
* @param name - the unique consumer identifier.
* @param identifierId the unique identifier for this connection
* @return Vector - the result of the operation
*/
private Vector isConnected(String name, String identifierId) {
boolean result;
try {
result = getAdminConnection(identifierId).isConnected(name);
return pack(Boolean.TRUE, new Boolean(result));
} catch (JMSException exception) {
return pack(Boolean.FALSE, exception);
}
}
/**
* Add a new destination
*
* @param destination - the queue/topic name
* @param queue - true if this is a queue, false is a topic
* @param identifierId the unique identifier for this connection
* @return Vector - the result of the operation
*/
private Vector addDestination(String destination, Boolean queue,
String identifierId) {
boolean result;
try {
result =
getAdminConnection(identifierId).addDestination(destination, queue);
return pack(Boolean.TRUE, new Boolean(result));
} catch (JMSException exception) {
return pack(Boolean.FALSE, exception);
}
}
/**
* Destroy all references to a queue/topic. Remove all messages and
* Consumer registrations.
*
* @param destination - the queue/topic name
* @param identifierId the unique identifier for this connection
* @return Vector - result of the operation
*/
private Vector removeDestination(String destination, String identifierId) {
boolean result;
try {
result =
getAdminConnection(identifierId).removeDestination(destination);
return pack(Boolean.TRUE, new Boolean(result));
} catch (JMSException exception) {
return pack(Boolean.FALSE, exception);
}
}
/**
* Check if the specified destination exists.
*
* @param name - the destination name to check
* @param identifierId the unique identifier for this connection
* @return Vector - result of the operation
*/
private Vector destinationExists(String name, String identifierId) {
boolean result;
try {
result = getAdminConnection(identifierId).destinationExists(name);
return pack(Boolean.TRUE, new Boolean(result));
} catch (JMSException exception) {
return pack(Boolean.FALSE, exception);
}
}
/**
* Get a list of all the destinations
*
* @param identifierId the unique identifier for this connection
* @return Vector The result of the operation
*/
private Vector getAllDestinations(String identifierId) {
Vector result;
try {
result = getAdminConnection(identifierId).getAllDestinations();
return pack(Boolean.TRUE, result);
} catch (JMSException exception) {
return pack(Boolean.FALSE, exception);
}
}
/**
* Return the number of messages for a specific durable consumer
*
* @param topic topic name
* @param name consumer name
* @param identifierId the unique identifier for this connection
* @return Vector The result of the operation
*/
private Vector getDurableConsumerMessageCount(String topic, String name,
String identifierId) {
int result;
try {
result = getAdminConnection(identifierId).
getDurableConsumerMessageCount(topic, name);
return pack(Boolean.TRUE, new Integer(result));
} catch (JMSException exception) {
return pack(Boolean.FALSE, exception);
}
}
/**
* Return the number of messages in the given queue
*
* @param queue queue name
* @param identifierId the unique identifier for this connection
* @return Vector The result of the operation
*/
private Vector getQueueMessageCount(String queue, String identifierId) {
int result;
try {
result =
getAdminConnection(identifierId).getQueueMessageCount(queue);
return pack(Boolean.TRUE, new Integer(result));
} catch (JMSException exception) {
return pack(Boolean.FALSE, exception);
}
}
/**
* Remove all processed messages from the database.
*
* @param identifierId the unique identifier for this connection
* @return Vector The result of the operation
*/
private Vector purgeMessages(String identifierId) {
int result;
try {
result = getAdminConnection(identifierId).purgeMessages();
return pack(Boolean.TRUE, new Integer(result));
} catch (JMSException exception) {
return pack(Boolean.FALSE, exception);
}
}
/**
* Send a stop request to the OpenJMSServer.
*
* @param identifierId the unique identifier for this connection
* @return Vector The result of the operation
*/
private Vector stopServer(String identifierId) {
try {
getAdminConnection(identifierId).stopServer();
return pack(Boolean.TRUE, Boolean.TRUE);
} catch (JMSException exception) {
return pack(Boolean.FALSE, exception);
}
}
/**
* Add a user with the specified name
*
* @param username the users name
* @param password the users password
* @param identifierId the unique identifier for this connection
* @return Vector The result of the operation
*/
private Vector addUser(String username, String password,
String identifierId) {
boolean result;
try {
result =
getAdminConnection(identifierId).addUser(username, password);
return pack(Boolean.TRUE, new Boolean(result));
} catch (JMSException exception) {
return pack(Boolean.FALSE, exception);
}
}
/**
* Change password for the specified user
*
* @param username the users name
* @param password the users password
* @param identifierId the unique identifier for this connection
* @return Vector The result of the operation
*/
private Vector changePassword(String username, String password,
String identifierId) {
boolean result;
try {
result =
getAdminConnection(identifierId).changePassword(username, password);
return pack(Boolean.TRUE, new Boolean(result));
} catch (JMSException exception) {
return pack(Boolean.FALSE, exception);
}
}
/**
* Remove the specified user
*
* @param username the users name
* @param identifierId the unique identifier for this connection
* @return Vector the result of the operation
*/
private Vector removeUser(String username, String identifierId) {
boolean result;
try {
result = getAdminConnection(identifierId).removeUser(username);
return pack(Boolean.TRUE, new Boolean(result));
} catch (JMSException exception) {
return pack(Boolean.FALSE, exception);
}
}
/**
* Return a list of all registered users.
*
* @param identifierId the unique identifier for this connection
* @return Vector The result of the operation
*/
private Vector getAllUsers(String identifierId) {
Vector result;
try {
result = getAdminConnection(identifierId).getAllUsers();
return pack(Boolean.TRUE, result);
} catch (JMSException exception) {
return pack(Boolean.FALSE, exception);
}
}
/**
* Pack all the data that is required by the server in a vector.
* Set the size of the vector to be exactly the right size for efficiency.
*
* @param success Boolean indicating success or failure of request.
* @param ob The Object being returned.
* @return Vector The vector containing all the data.
*
*/
private Vector pack(Boolean success, Object ob) {
Vector v = new Vector(2);
v.add(success);
v.add(ob);
return v;
}
/**
* Get the AdminConnection for this connection.
*
* @param identifierId the unique id for this connection
* @return AdminConnection the connection
* @throws JMSSecurityException if the connection not exist
*/
private AdminConnection getAdminConnection(String identifierId)
throws JMSSecurityException {
AdminConnection connection =
AdminConnectionManager.instance().getConnection(identifierId);
if (connection == null) {
throw new JMSSecurityException("Not authorized for this operation");
}
return connection;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -