📄 joramadmin.java
字号:
* @exception AdminException If the creation fails. */ public void createUser(String name, String password) throws AdminException { try { User.create(name,password); } catch (ConnectException exc) { throw new AdminException("createUser() failed: admin connection " + "has been lost."); } } /** * Creates or retrieves a user on the underlying JORAM server. * * @exception AdminException If the creation fails. */ public void createUser(String name, String password, int serverId) throws AdminException { try { User.create(name,password,serverId); } catch (ConnectException exc) { throw new AdminException("createUser() failed: admin connection " + "has been lost."); } } /** * Creates or retrieves a queue destination on the underlying JORAM server, * (re)binds the corresponding <code>Queue</code> instance. * * @param name The name of the queue. * * @exception AdminException If the creation fails. */ public Destination createQueue(String name) throws AdminException { try { return createQueue(platformAdmin.getLocalServerId(), name, "org.objectweb.joram.mom.dest.Queue", null); } catch (ConnectException exc) { throw new AdminException("createQueue() failed: admin connection " + "has been lost."); } } /** * Creates or retrieves a queue destination on the underlying JORAM server, * (re)binds the corresponding <code>Queue</code> instance. * * @param serverId The identifier of the server where deploying the queue. * @param name The name of the queue. * * @exception AdminException If the creation fails. */ public Destination createQueue(int serverId, String name) throws AdminException { return createQueue(serverId, name, "org.objectweb.joram.mom.dest.Queue", null); } /** * Creates or retrieves a queue destination on the underlying JORAM server, * (re)binds the corresponding <code>Queue</code> instance. * * @param serverId The identifier of the server where deploying the queue. * @param name The name of the queue. * @param className The queue class name. * @param prop The queue properties. * * @exception AdminException If the creation fails. */ public Destination createQueue(int serverId, String name, String className, Properties prop) throws AdminException { try { Queue queue = Queue.create(serverId, name, className, prop); return queue; } catch (ConnectException exc) { throw new AdminException("createQueue() failed: admin connection " + "has been lost."); } } /** * Creates or retrieves a topic destination on the underlying JORAM server, * (re)binds the corresponding <code>Topic</code> instance. * * @exception AdminException If the creation fails. */ public Destination createTopic(String name) throws AdminException { try { return createTopic(platformAdmin.getLocalServerId(), name, "org.objectweb.joram.mom.dest.Topic", null); } catch (ConnectException exc) { throw new AdminException("createTopic() failed: admin connection " + "has been lost."); } } /** * Creates or retrieves a topic destination on the underlying JORAM server, * (re)binds the corresponding <code>Topic</code> instance. * * @param serverId The identifier of the server where deploying the topic. * @param name The name of the topic. * * @exception AdminException If the creation fails. */ public Destination createTopic(int serverId, String name) throws AdminException { return createTopic(serverId, name, "org.objectweb.joram.mom.dest.Topic", null); } /** * Creates or retrieves a topic destination on the underlying JORAM server, * (re)binds the corresponding <code>Topic</code> instance. * * @param serverId The identifier of the server where deploying the topic. * @param name The name of the topic. * @param className The topic class name. * @param prop The topic properties. * * @exception AdminException If the creation fails. */ public Destination createTopic(int serverId, String name, String className, Properties prop) throws AdminException { try { Topic topic = Topic.create(serverId, name, className, prop); return topic; } catch (ConnectException exc) { throw new AdminException("createTopic() failed: admin connection " + "has been lost."); } } public static boolean executeXMLAdmin(String cfgDir, String cfgFileName) throws Exception { return AdminModule.executeXMLAdmin(cfgDir, cfgFileName); } public static boolean executeXMLAdmin(String path) throws Exception { return AdminModule.executeXMLAdmin(path); } /** * Reload the joramAdmin.xml file * @param the path for the joramAdmin file * @throws AdminException if an error occurs */ public boolean executeXMLAdminJMX(String path) throws Exception { throw new Exception("Not implemented yet"); } /** * Export the repository content to an XML file * - only the destinations objects are retrieved in this version * - xml script format of the admin objects (joramAdmin.xml) * @param exportDir target directory where the export file will be put * @throws AdminException if an error occurs */ public void exportRepositoryToFile(String exportDir) throws AdminException { if (JoramTracing.dbgClient.isLoggable(BasicLevel.DEBUG)) { JoramTracing.dbgClient.log(BasicLevel.DEBUG, "export repository to " + exportDir.toString()); } StringBuffer strbuf = new StringBuffer(); int indent = 0; strbuf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); strbuf.append("<!--\n"); strbuf.append(" Exported JMS objects : \n"); strbuf.append(" - destinations : Topic/Queue \n"); strbuf.append(" The file can be reloaded through the admin interface (joramAdmin.executeXMLAdmin())\n"); strbuf.append("-->\n"); strbuf.append("<JoramAdmin>\n"); indent += 2; // Get the srv list List srvList = platformAdmin.getServersIds(); if (srvList != null) { // For each server Iterator it = srvList.iterator(); while (it.hasNext()) { try { Integer sid = (Integer) it.next(); // Export the JMS destinations List destList = AdminModule.getDestinations(sid.intValue(), timeOut); Iterator destIt = destList.iterator(); while (destIt.hasNext()) { org.objectweb.joram.client.jms.Destination dest = (org.objectweb.joram.client.jms.Destination) destIt .next(); strbuf.append(dest.toXml(indent, sid.intValue())); } } catch (Exception exc) { throw new AdminException("exportRepositoryToFile() failed - " + exc); } } if (JoramTracing.dbgClient.isLoggable(BasicLevel.DEBUG)) { JoramTracing.dbgClient.log(BasicLevel.DEBUG, "exported objects : \n" + strbuf.toString()); } } indent -= 2; strbuf.append("</JoramAdmin>"); // Flush the file in the specified directory File exportFile = null; FileOutputStream fos = null; try { exportFile = new File(exportDir, getAdminFileExportXML()); fos = new FileOutputStream(exportFile); fos.write(strbuf.toString().getBytes()); } catch(Exception ioe) { throw new AdminException("exportRepositoryToFile() failed - " + ioe); } finally { try { exportFile = null; fos.close(); } catch (Exception e) { if (JoramTracing.dbgClient.isLoggable(BasicLevel.DEBUG)) { JoramTracing.dbgClient.log(BasicLevel.DEBUG, "Unable to close the file : " + fos); } } if (JoramTracing.dbgClient.isLoggable(BasicLevel.DEBUG)) { JoramTracing.dbgClient.log(BasicLevel.DEBUG, "File : " + exportDir + "/" + getAdminFileExportXML() + " created"); } } } public String getAdminFileExportXML() { return adminFileExportXML; } public void setAdminFileExportXML(String adminFileExportXML) { this.adminFileExportXML = adminFileExportXML; } public static boolean isHa() { return isHa; } public static void setHa(boolean isHa) { JoramAdmin.isHa = isHa; AdminModule.setHa(isHa); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -