通用的做法是用socket联系起在本地的两个应用。
解决方案 »
- Java JFrame或者JDialog如何实现任务栏图标的高亮闪烁,像QQ那种
- 不停止服务器的情况下,新增jar包可以正常调用?
- DataSource dataSource = (DataSource) context.lookup(WAPSecurityJNDI)
- 关于list中bean复制问题(急)
- JTextField 文本域改变要注册哪个监听器得到
- 为什么JAVA API文档中老是出现<T>是类似C++中的模板吗?是的话在JAVA中要怎么理解
- 用JAVA能做出透明的窗体吗? JFrame
- 好难的问题,在线等待,问一个JAR包中包含一个XML文件,在程序中要读这个文件(只读),那么程序中的路径要怎么写
- UTF-8转换的问题
- win2000的环境变量再配置不好我不学java了,实在是学不了啊,请各位老大拉我一把啊,
- 2003年软考答案
- 小弟学了一段时间JAVA,很多东西不懂,向高手请教
{
/** Table for storing the message queues */
Hashtable ivQueueTable = new Hashtable(); /**
* Insert the method's description here.
* Creation date: (2000/06/13 11:20:17 AM)
* @return java.lang.String
*/
public synchronized HashMap getAllQueueLen()
{
HashMap lvQueueLenMap = new HashMap(); Iterator lvIter = ivQueueTable.keySet().iterator(); while (lvIter.hasNext())
{
String lvProcessorName = (String)lvIter.next();
try
{
int lvLen = getQueueLength(lvProcessorName);
lvQueueLenMap.put(lvProcessorName, new Integer(lvLen));
}
catch (Exception lvException)
{}
} return lvQueueLenMap;
} /**
* Gets the number of priority queue
* @param pQueueName is the name of the message queue
* @return Returns the number of priority queue
*/
public int getMaximumPriorityQueueSize(String pQueueName) throws Exception
{
msqQueueElement lvQueue = (msqQueueElement)ivQueueTable.get(pQueueName);
// Check whether the request queue is registered or not
// if the queue is not registered, exception will be thrown
if (lvQueue == null)
throw new errQueueNotFoundException(pQueueName); return lvQueue.getMaximumPriorityQueueSize();
} /**
* Gets message from the message queue
* @param pQueueName is the name of the message queue
* @return Returns the message extracted from the message queue
*/
public Object getMessage(String pQueueName) throws Exception
{
msqQueueElement lvQueue = (msqQueueElement)ivQueueTable.get(pQueueName);
// Check whether the request queue is registered or not
// if the queue is not registered, exception will be thrown
if (lvQueue == null)
throw new errQueueNotFoundException(pQueueName); return lvQueue.get();
} /**
* Gets the current queue length of the message queue
* @param pQueueName is the name of the message queue
* @return Returns the total number of message queued in the message queues
*/
public int getQueueLength(String pQueueName) throws errQueueNotFoundException
{
msqQueueElement lvQueue = (msqQueueElement)ivQueueTable.get(pQueueName);
// Check whether the request queue is registered or not
// if the queue is not registered, exception will be thrown
if (lvQueue == null)
throw new errQueueNotFoundException(pQueueName); return lvQueue.getQueueLength();
}
/**
* Posts the message to the destination queue
* @param pQueueName is the name of the message queue
* @param pMessage is the message that needs to be queued
*/
public void postMessage(String pQueueName, Object pMessage) throws errQueueNotFoundException
{
msqQueueElement lvQueueElement = (msqQueueElement)ivQueueTable.get(pQueueName);
if (lvQueueElement != null)
lvQueueElement.put(pMessage);
else
throw new errQueueNotFoundException(pQueueName);
}
/**
* Posts the message to the destination queue with priority
* @param pQueueName is the name of the message queue
* @param pMessage is the message that needs to be queued
* @param pPriority is the priority of the queue
*/
public void postMessage(String pQueueName, Object pMessage, int pPriority) throws errQueueNotFoundException
{
msqQueueElement lvQueueElement = (msqQueueElement)ivQueueTable.get(pQueueName);
if (lvQueueElement != null)
lvQueueElement.put(pMessage, pPriority);
else
throw new errQueueNotFoundException(pQueueName);
}
/**
* Insert the method's description here.
* Creation date: (2000/06/13 11:20:17 AM)
* @return java.lang.String
*/
public void printAllQueueLen()
{
String lvResult = "";
TreeMap lvQueueLenMap = new TreeMap(getAllQueueLen()); Iterator lvIter = lvQueueLenMap.keySet().iterator();
while (lvIter.hasNext())
{
String lvProcessorName = (String)lvIter.next(); Integer lvLen = (Integer) lvQueueLenMap.get(lvProcessorName); lvResult = lvResult + lvProcessorName + " = " + lvLen + "\r\n";
} System.out.println(lvResult);
}
/**
* Creates a message queue with default number of priority and registers it
* @param pQueueName is the name of the message queue
*/
public synchronized void registerQueue(String pQueueName) throws errQueueSizeException, errQueueAlreadyRegisteredException
{
if (ivQueueTable.containsKey(pQueueName))
throw new errQueueAlreadyRegisteredException(pQueueName);
msqQueueElement lvQueueElement = new msqQueueElement();
ivQueueTable.put(pQueueName, lvQueueElement);
}
/**
* Creates a message queue with user defined number of priority and registers it
* @param pQueueName is the name of the message queue
* @param pPriorityQueueSize is the size of the priority queue
*/
public synchronized void registerQueue(String pQueueName, int pPriorityQueueSize) throws errQueueSizeException
{
msqQueueElement lvQueueElement = new msqQueueElement(pPriorityQueueSize);
ivQueueTable.put(pQueueName, lvQueueElement);
}
/**
* Destroys the specified message queue
* @param pQueueName is the name of the message queue
*/
public synchronized void unregisterQueue(String pQueueName)
{
if (ivQueueTable.containsKey(pQueueName))
ivQueueTable.remove(pQueueName);
}
}