⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admincontroller.java

📁 一个类似于openJMS分布在ObjectWeb之下的JMS消息中间件。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    JndiTreeNode node = new JndiTreeNode(this, ctx, new Binding(name, factory));    insertJndiNode(node);  }  public void createDestination(ServerTreeNode serverNode, String name, String type) throws Exception  {    try    {      if (ctx.lookup(name) != null)        throw new Exception("Name already bound in JNDI context");    }    catch (NameNotFoundException exc) {}  	Destination dest = null;  	if ("Q".equals(type))  	  dest = org.objectweb.joram.client.jms.Queue.create(  	      serverNode.getServerId(), name);  	if ("T".equals(type))  	  dest = org.objectweb.joram.client.jms.Topic.create(  	      serverNode.getServerId(), name);  	if ("DMQ".equals(type))  	  dest = org.objectweb.joram.client.jms.admin.DeadMQueue.create(  	      serverNode.getServerId(), name);    ctx.bind(name, dest);    JndiTreeNode node = new JndiTreeNode(this, ctx, new Binding(name, dest));    insertJndiNode(node);    DestinationTreeNode destNode = new DestinationTreeNode(this, dest);    adminTreeModel.insertNodeInto(destNode, serverNode.getDestinationRoot(),                                  serverNode.getDestinationRoot().getChildCount());  }  public void deleteObject(JndiTreeNode node) throws Exception  {  	String name = node.getName();  	Object obj = ctx.lookup(name);    try    {      org.objectweb.joram.client.jms.Destination dest =         (org.objectweb.joram.client.jms.Destination) obj;      dest.delete();      DestinationTreeNode dtn = findDestinationNode(adminRoot, dest);      if (dtn != null)      	adminTreeModel.removeNodeFromParent(findDestinationNode(adminRoot, dest));    }    catch (ClassCastException cce) {}    ctx.unbind(name);    jndiTreeModel.removeNodeFromParent(node);  }  public void createUser(ServerTreeNode serverNode, String name, String passwd)     throws Exception {    User user = User.create(name, passwd, serverNode.getServerId());    UserTreeNode userNode = new UserTreeNode(this, user);    adminTreeModel.insertNodeInto(userNode,                                   serverNode.getUserRoot(),                                  serverNode.getUserRoot().getChildCount());  }  public void createDomain(ServerTreeNode serverNode, String domainName, int port)     throws Exception {    AdminModule.addDomain(domainName, (short)serverNode.getServerId(), port);    DomainTreeNode dtn = new DomainTreeNode(this, domainName);    adminTreeModel.insertNodeInto(dtn,                                   serverNode.getDomainRoot(),                                  serverNode.getDomainRoot().getChildCount());  }  public void updateUser(UserTreeNode userNode, String name, String passwd)     throws Exception {    userNode.getUser().update(name, passwd);    adminTreeModel.nodeChanged(userNode);  }  public void deleteUser(UserTreeNode node)     throws Exception {    node.getUser().delete();    adminTreeModel.removeNodeFromParent(node);  }  public void deleteMessage(MessageTreeNode msgTn)     throws Exception {    DefaultMutableTreeNode parentTn =       (DefaultMutableTreeNode)msgTn.getParent();    if (parentTn instanceof SubscriptionTreeNode) {      SubscriptionTreeNode subTn =         (SubscriptionTreeNode)parentTn;      SubscriptionRootTreeNode subRootTn =         (SubscriptionRootTreeNode)subTn.getParent();      UserTreeNode userTn =         (UserTreeNode)subRootTn.getParent();      ServerTreeNode serverTn = userTn.getParentServerTreeNode();      userTn.getUser().deleteMessage(        subTn.getSubscription().getName(),        msgTn.getMessageId());    } else {      MessageRootTreeNode msgRootTn =         (MessageRootTreeNode)parentTn;      QueueTreeNode queueTreeNode =         (QueueTreeNode)msgRootTn.getParent();      queueTreeNode.getQueue().deleteMessage(        msgTn.getMessageId());    }    adminTreeModel.removeNodeFromParent(msgTn);  }  public void clearSubscription(SubscriptionTreeNode subTn)     throws Exception {    SubscriptionRootTreeNode subRootTn =       (SubscriptionRootTreeNode)subTn.getParent();    UserTreeNode userTn = (UserTreeNode)subRootTn.getParent();    ServerTreeNode serverTn = userTn.getParentServerTreeNode();    userTn.getUser().clearSubscription(      subTn.getSubscription().getName());    while(subTn.getChildCount() > 0) {      MessageTreeNode msgTn = (MessageTreeNode)subTn.getChildAt(0);      adminTreeModel.removeNodeFromParent(msgTn);    }  }  public void clearQueue(QueueTreeNode queueTn) throws Exception {    queueTn.getQueue().clear();    MessageRootTreeNode msgRootTn = queueTn.getMessageRootTreeNode();    while(msgRootTn.getChildCount() > 0) {      MessageTreeNode msgTn = (MessageTreeNode)msgRootTn.getChildAt(0);      adminTreeModel.removeNodeFromParent(msgTn);    }  }  public int getPendingMessages(Queue q) throws Exception  {    return ((org.objectweb.joram.client.jms.Queue) q).getPendingMessages();  }  public int getPendingRequests(Queue q) throws Exception  {    return ((org.objectweb.joram.client.jms.Queue) q).getPendingRequests();  }  public int getSubscriptions(Topic t) throws Exception  {    return ((org.objectweb.joram.client.jms.Topic) t).getSubscriptions();  }  public int getDefaultThreshold(int serverId) throws Exception  {    return AdminModule.getDefaultThreshold(serverId);  }  public void setDefaultThreshold(int serverId, int threshold) throws Exception  {    AdminModule.setDefaultThreshold(serverId, threshold);  }  public DeadMQueue getDefaultDMQ(int serverId) throws Exception  {    return AdminModule.getDefaultDMQ(serverId);  }  public void setDefaultDMQ(int serverId, DeadMQueue dmq) throws Exception  {    AdminModule.setDefaultDMQ(serverId, dmq);  }  public void unsetDefaultThreshold(int serverId) throws Exception  {    AdminModule.setDefaultThreshold(serverId, -1);  }  public void unsetDefaultDMQ(int serverId) throws Exception  {    AdminModule.setDefaultDMQ(serverId, null);  }  public int getUserThreshold(User user) throws Exception  {    return user.getThreshold();  }  public void setUserThreshold(User user, int threshold) throws Exception  {    user.setThreshold(threshold);  }  public DeadMQueue getUserDMQ(User user) throws Exception  {    return user.getDMQ();  }  public void setUserDMQ(User user, DeadMQueue dmq) throws Exception  {    user.setDMQ(dmq);  }  public void unsetUserThreshold(User user) throws Exception  {    user.setThreshold(-1);  }  public void unsetUserDMQ(User user) throws Exception  {    user.setDMQ(null);  }  public int getQueueThreshold(Queue queue) throws Exception  {    return ((org.objectweb.joram.client.jms.Queue) queue).getThreshold();  }  public void setQueueThreshold(Queue queue, int threshold) throws Exception  {    ((org.objectweb.joram.client.jms.Queue) queue).setThreshold(threshold);  }  public DeadMQueue getDestinationDMQ(Destination dest) throws Exception  {    return ((org.objectweb.joram.client.jms.Destination) dest).getDMQ();  }  public void setDestinationDMQ(Destination dest, DeadMQueue dmq) throws Exception  {    ((org.objectweb.joram.client.jms.Destination) dest).setDMQ(dmq);  }  public void unsetQueueThreshold(Queue queue) throws Exception  {    ((org.objectweb.joram.client.jms.Queue) queue).setThreshold(-1);  }  public void unsetDestinationDMQ(Destination dest) throws Exception  {    ((org.objectweb.joram.client.jms.Destination) dest).setDMQ(null);  }  public boolean isFreelyReadable(Destination dest) throws Exception  {    return ((org.objectweb.joram.client.jms.Destination) dest).isFreelyReadable();  }  public boolean isFreelyWritable(Destination dest) throws Exception  {    return ((org.objectweb.joram.client.jms.Destination) dest).isFreelyWriteable();  }  public void setFreeReading(Destination dest) throws Exception  {    ((org.objectweb.joram.client.jms.Destination) dest).setFreeReading();  }  public void setFreeWriting(Destination dest) throws Exception  {    ((org.objectweb.joram.client.jms.Destination) dest).setFreeWriting();  }  public void unsetFreeReading(Destination dest) throws Exception  {    ((org.objectweb.joram.client.jms.Destination) dest).unsetFreeReading();  }  public void unsetFreeWriting(Destination dest) throws Exception  {    ((org.objectweb.joram.client.jms.Destination) dest).unsetFreeWriting();  }  public List getAuthorizedReaders(Destination dest) throws Exception  {    return ((org.objectweb.joram.client.jms.Destination) dest).getReaders();  }  public List getAuthorizedWriters(Destination dest) throws Exception  {    return ((org.objectweb.joram.client.jms.Destination) dest).getWriters();  }  public void setReader(User user, Destination dest) throws Exception  {    ((org.objectweb.joram.client.jms.Destination) dest).setReader(user);  }  public void setWriter(User user, Destination dest) throws Exception  {    ((org.objectweb.joram.client.jms.Destination) dest).setWriter(user);  }  public void unsetReader(User user, Destination dest) throws Exception  {    ((org.objectweb.joram.client.jms.Destination) dest).unsetReader(user);  }  public void unsetWriter(User user, Destination dest) throws Exception  {    ((org.objectweb.joram.client.jms.Destination) dest).unsetWriter(user);  }  public String getAdminConnectionStatus() { return adminConnectionStr; }  public boolean isAdminConnected() { return adminConnected; }  public boolean isJndiConnected() { return jndiConnected; }  private void cleanupAdminTree()  {  	while (adminRoot.getChildCount() > 0)  	  adminTreeModel.removeNodeFromParent((MutableTreeNode) adminRoot.getChildAt(0));  }    private void cleanupJndiTree()  {  	while (jndiRoot.getChildCount() > 0)  	  jndiTreeModel.removeNodeFromParent((MutableTreeNode) jndiRoot.getChildAt(0));  }  private void insertJndiNode(JndiTreeNode n)  {  	int i;  	for (i = 0; i < jndiRoot.getChildCount(); i++) {  	  JndiTreeNode curr = (JndiTreeNode) jndiRoot.getChildAt(i);  	  if (n.getName().compareTo(curr.getName()) < 0)  	    break;  	}    jndiTreeModel.insertNodeInto(n, jndiRoot, i);  }	private DestinationTreeNode findDestinationNode(TreeNode from, Destination dest) {		for (int i = 0; i < from.getChildCount(); i++) {			TreeNode current = from.getChildAt(i);			try {				DestinationTreeNode dtn = (DestinationTreeNode) current;				if (dtn.getDestination().equals(dest))					return dtn;			}			catch (ClassCastException exc) {				if (current.getChildCount() > 0)					return findDestinationNode(current, dest);			}		}		return null;	}	protected String findDestinationJndiName(Destination dest) {		for (int i = 0; i < jndiRoot.getChildCount(); i++) {			JndiTreeNode current = (JndiTreeNode) jndiRoot.getChildAt(i);			Object obj = current.getObject();			if (obj instanceof Destination && ((Destination) obj).equals(dest))				return current.getName();		}		return null;	}  protected void notifyListener(ControllerEvent e)  {  	if (gui != null)  	  gui.adminControllerEvent(e);  }  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -