标题:关于用Voyager Edge进行移动代理编程的一个问题
只看楼主
liugy52
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2006-10-1
 问题点数:0 回复次数:1 
关于用Voyager Edge进行移动代理编程的一个问题

下面是我的程序代码:

***** MobVectorTest.java *************************************************************

import com.recursionsw.ve.Factory;
import com.recursionsw.ve.StartupException;
import com.recursionsw.ve.Voyager;
import com.recursionsw.ve.mobility.IMobility;
import com.recursionsw.ve.mobility.Mobility;


public class MobVectorTest {
public static void main(String[] args) {
try {
Voyager.startup("6000");
IMyVector v = (IMyVector)Factory.create("MyVector");
IMobility mv = Mobility.of(v);
for (int i = 0; i < 4; i++) {
v.addElement(new Integer(i));
v.print();
if (i % 2 == 0)
mv.moveTo("//localhost/7000");
else
mv.moveTo("//localhost/6000");
}
} catch (StartupException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
Voyager.shutdown();
}
}

/***** IMyVector.java **********************************************************************/

public interface IMyVector extends com.recursionsw.java.util.IVector {
void print();
}

/***** MyVector.java ***********************************************************************/

import java.util.Vector;


public class MyVector extends Vector {

private static final long serialVersionUID = 1L;

public void print() {
System.out.println(this);
}
}

/***** IVector.java *************************************************************************/

/**
* IVector.java
* <p>
* @version 1.0
* @author generated by igen 6.0.5 at Wed Apr 18 09:41:49 CST 2007
*/

package com.recursionsw.java.util;

public interface IVector extends com.recursionsw.java.util.IAbstractList,
java.util.List, java.util.RandomAccess, java.lang.Cloneable,
java.io.Serializable {

void copyInto(java.lang.Object[] arg1);
void trimToSize();
void ensureCapacity(int arg1);
void setSize(int arg1);
int capacity();
java.util.Enumeration elements();
int indexOf(java.lang.Object arg1, int arg2);
int lastIndexOf(java.lang.Object arg1, int arg2);
java.lang.Object elementAt(int arg1);
java.lang.Object firstElement();
java.lang.Object lastElement();
void setElementAt(java.lang.Object arg1, int arg2);
void removeElementAt(int arg1);
void insertElementAt(java.lang.Object arg1, int arg2);
void addElement(java.lang.Object arg1);
boolean removeElement(java.lang.Object arg1);
void removeAllElements();
java.lang.Object clone();
}

/***** IAbstractList.java *****************************************************************/


/**
* IAbstractList.java
*
* @version 1.0
* @author generated by igen 6.0.5 at Wed Apr 18 09:41:49 CST 2007
*/

package com.recursionsw.java.util;

public interface IAbstractList extends
com.recursionsw.java.util.IAbstractCollection, java.util.List {
}


/***** IAbstractCollection.java *******************************************************************/


/**
* IAbstractCollection.java
* <p>
* @version 1.0
* @author generated by igen 6.0.5 at Wed Apr 18 09:41:49 CST 2007
*/

package com.recursionsw.java.util;

public interface IAbstractCollection extends java.util.Collection {
}


问题:启动一个新的命令行窗口:
启动VoyagerEdge
> voyageredge 7000

当运行程序后,在运行“voyageredge 6000“进程的窗口显示:
[0]
[0, 1]
[0, 1, 2]
[0, 1, 2, 3]

而运行voyageredge 7000的窗口中没有任何信息,这是为什么? 高手帮帮忙,我先在这谢谢各位了!!!

搜索更多相关主题的帖子: Voyager Edge 代理 
2007-04-18 09:57
liugy52
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2006-10-1
得分:0 

将程序修改后问题解决,但是前面的问题依旧没有弄清楚为什么会有错误

两个修改:
1。 mv.moveTo("//localhost/6000") ----> mv.moveTo("6000")
mv.moveTo("//localhost/7000") ----> mv.moveTo("7000")

2 MyVector不再继承于Vector类,而是将Vector类的一个实例作为MyVector类的成员对象。

程序的完整代码如下:

/***** MobVectorTest.java ****************************************************************/


import com.recursionsw.ve.Factory;
import com.recursionsw.ve.StartupException;
import com.recursionsw.ve.Voyager;
import com.recursionsw.ve.mobility.IMobility;
import com.recursionsw.ve.mobility.Mobility;


public class MobVectorTest {
public static void main(String[] args) {
try {
Voyager.startup("6000");
IMyVector v = (IMyVector)Factory.create("MyVector");
IMobility mv = Mobility.of(v);
for (int i = 0; i < 4; i++) {
v.addElement(new Integer(1));
v.print();
if (i % 2 == 0)
mv.moveTo("7000");
else
mv.moveTo("6000");
}
} catch (StartupException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
Voyager.shutdown();
}
}

/***** IMyVector.java ****************************************************************************/


public interface IMyVector {
void print();
void addElement(Object obj);
}


/****** MyVector.java ****************************************************************************/
import java.io.Serializable;
import java.util.Vector;


public class MyVector implements IMyVector, Serializable {

private static final long serialVersionUID = 1L;

private Vector v = new Vector();

public void print() {
System.out.println(v);
}

public void addElement(Object obj) {
v.addElement(obj);
}
}



程序显示结果:

窗口 voyageredge 6000

[1]
[1, 1, 1]

窗口 voyageredge 7000

[1, 1]
[1, 1, 1, 1]


我在大家热情的帮助下进步,谢谢你们!
2007-04-18 14:32



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-132773-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.768664 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved