?? offlineconnection.java
字號:
System.err.println("Failed to get message count for " + topic +
" b/c " + exception.toString());
try {
connection.rollback();
} catch (Exception nested) {
// ignore
}
} catch (Exception exception) {
// ignore for the moment
} finally {
if (connection != null) {
try {
connection.close();
} catch (Exception nested) {
// ignore
}
}
}
return count;
}
// implementation of AbstractAdminConnection.getQueueMessageCount
public int getQueueMessageCount(String queue) {
int count = -1;
Connection connection = null;
try {
connection = DatabaseService.getConnection();
count = DatabaseService.getAdapter().getQueueMessageCount(
connection, queue);
connection.commit();
} catch (PersistenceException exception) {
System.err.println("Failed to get message count for " + queue +
" b/c " + exception.toString());
try {
connection.rollback();
} catch (Exception nested) {
// ignore
}
} catch (Exception exception) {
// ignore for the moment
} finally {
if (connection != null) {
try {
connection.close();
} catch (Exception nested) {
// ignore
}
}
}
return count;
}
// implementation of AbstractAdminConnection.durableConsumerExists
public boolean durableConsumerExists(String name) {
boolean result = false;
Connection connection = null;
try {
connection = DatabaseService.getConnection();
result = DatabaseService.getAdapter().durableConsumerExists(
connection, name);
connection.commit();
} catch (PersistenceException exception) {
System.err.println("Failed on consumer exists for " + name +
" b/c " + exception.toString());
try {
connection.rollback();
} catch (Exception nested) {
// ignore
}
} catch (Exception exception) {
// ignore for the moment
} finally {
if (connection != null) {
try {
connection.close();
} catch (Exception nested) {
// ignore
}
}
}
return result;
}
// implementation of AbstractAdminConnection.getDurableConsumers
public Enumeration getDurableConsumers(String topic) {
Enumeration result = null;
Connection connection = null;
try {
connection = DatabaseService.getConnection();
result = DatabaseService.getAdapter().getDurableConsumers(
connection, topic);
connection.commit();
} catch (PersistenceException exception) {
System.err.println("Failed on getDurableConsumers for " + topic +
" b/c " + exception.toString());
try {
connection.rollback();
} catch (Exception nested) {
// ignore
}
} catch (Exception exception) {
// ignore for the moment
} finally {
if (connection != null) {
try {
connection.close();
} catch (Exception nested) {
// ignore
}
}
}
return result;
}
// implementation of AbstractAdminConnection.removeDestination
public boolean removeDestination(String destination) {
boolean result = false;
Connection connection = null;
try {
connection = DatabaseService.getConnection();
DatabaseService.getAdapter().removeDestination(connection,
destination);
if (_context == null) {
// connect to the JNDI server and get a reference to
// root context
Hashtable props = new Hashtable();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.exolab.jms.jndi.intravm.IntravmJndiServer");
_context = new InitialContext(props);
}
_context.unbind(destination);
connection.commit();
result = true;
} catch (PersistenceException exception) {
System.err.println("Failed on getDurableConsumers for " +
destination + " b/c " + exception.toString());
try {
connection.rollback();
} catch (Exception nested) {
// ignore
}
} catch (javax.naming.NamingException err) {
System.err.println("Failed to removeDestination " + destination +
" b/c" + err.toString());
try {
connection.rollback();
} catch (Exception nested) {
// ignore
}
} catch (Exception exception) {
// ignore for the moment
} finally {
if (connection != null) {
try {
connection.close();
} catch (Exception nested) {
// ignore
}
}
}
return result;
}
// implementation of AbstractAdminConnection.purgeMessages
public int purgeMessages() {
return DatabaseService.getAdapter().purgeMessages();
}
// implementation of AbstractAdminConnection.stopServer
public void stopServer() {
JOptionPane.showMessageDialog
(_parent, "Not available in offline mode",
"Shutdown Error", JOptionPane.ERROR_MESSAGE);
}
// implementation of AbstractAdminConnection.addUser
public boolean addUser(String username, String password) {
Connection connection = null;
boolean success = false;
try {
connection = DatabaseService.getConnection();
DatabaseService.getAdapter().addUser(connection,
new User(username, password));
connection.commit();
success = true;
} catch (PersistenceException exception) {
System.err.println("Failed to add user " + username +
exception.toString());
try {
connection.rollback();
} catch (Exception nested) {
// ignore
}
} catch (Exception exception) {
// ignore for the moment
} finally {
if (connection != null) {
try {
connection.close();
} catch (Exception nested) {
// ignore
}
}
}
return success;
}
// implementation of AbstractAdminConnection.changePassord
public boolean changePassword(String username, String password) {
Connection connection = null;
boolean success = false;
try {
connection = DatabaseService.getConnection();
DatabaseService.getAdapter().updateUser(connection,
new User(username, password));
connection.commit();
success = true;
} catch (PersistenceException exception) {
System.err.println("Failed to add user " + username +
exception.toString());
try {
connection.rollback();
} catch (Exception nested) {
// ignore
}
} catch (Exception exception) {
// ignore for the moment
} finally {
if (connection != null) {
try {
connection.close();
} catch (Exception nested) {
// ignore
}
}
}
return success;
}
// implementation of AbstractAdminConnection.removeUser
public boolean removeUser(String username) {
boolean result = false;
Connection connection = null;
try {
connection = DatabaseService.getConnection();
DatabaseService.getAdapter().removeUser(connection,
new User(username, null));
connection.commit();
result = true;
} catch (PersistenceException exception) {
System.err.println("Failed on remove user for " +
username + exception.toString());
try {
connection.rollback();
} catch (Exception nested) {
// ignore
}
} catch (Exception exception) {
// ignore for the moment
} finally {
if (connection != null) {
try {
connection.close();
} catch (Exception nested) {
// ignore
}
}
}
return result;
}
// implementation of AbstractAdminConnection.getAllUsers
public Enumeration getAllUsers() {
Enumeration result = null;
Connection connection = null;
try {
connection = DatabaseService.getConnection();
result = DatabaseService.getAdapter().getAllUsers(
connection);
connection.commit();
} catch (PersistenceException exception) {
System.err.println("Failed on getAllUsers "
+ exception.toString());
try {
connection.rollback();
} catch (Exception nested) {
// ignore
}
} catch (Exception exception) {
// ignore for the moment
} finally {
if (connection != null) {
try {
connection.close();
} catch (Exception nested) {
// ignore
}
}
}
return result;
}
} //-- OfflineConnection
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -