一种实现 JBuilder 里 Open Tools 功能的思路
zy422 2003-06-11 07:46:29
执行类文件 live
在 sendmsg 方法里安放接口
public boolean sendmsg(String msg)
{
.
.
.
.
.
//*****************************************************
// 调用自定义接口
try
{
ClassLoader loader = this.getClass().getClassLoader();
Object o;
Class c;
c=loader.loadClass("live.live2");
if(c!=null);
{
o = c.newInstance();
((live2Interface) o).sendmsg(msg);//调用接口里的方法
}
binvokei=true;
}
catch(Exception e)
{
binvokei=false;
System.out.println("invoke live2 interface()"+e);
}
//*****************************************************
if(!binvokei)
{
try
{
...
}
catch(Exception e)
{
System.out.println("sendmsg()"+e);
return false;
}
}
return true;
}
接口文件
package live;
public interface live2Interface {
public String livebootdir="/";
public String livepath="/";
public String tagtitle="Title";
public String tagpath="Path";
public String tagdate="Date";
public String tagtime="Time";
public boolean sendmsg(String msg);//需要实现的接口方法
......
}