/**
*
常用的
Classloader
,根据制定的目录,装载该目录下面的所有的
jar
和
zip
文件到
classloader
中
*
@param
parent
上一级
Classloader
*
@param
libDir
lib
目录
*
@throws
MalformedURLException
*/
YankeeClassLoader(ClassLoader parent, File libDir)
throws
MalformedURLException;
|
/**
*
Bootstrap
的入口方法,
也是本地动态链接库调用的入口方法
*
*
@param
args
*
动态链接库传入的启动参数。
*/
public
static
void
main(String args[]);
/**
*
开始服务,
该方法有
procrun
调用
*
@throws
Exception
*/
public
void
start()
throws
Exception ;
/*
*
主线程一直循环,
否则整个服务启动以后将会退出。
*/
public
void
await() ;
/*
*
停止我们的服务
*/
public
void
stop()
throws
Exception ;
|
public
void
start() {
if
(
started
) {
System.
out
.println(
"already started, abort"
);
return
;
}
System.
out
.println(
"i am start"
);
try
{
impl
=
new
TestInterfaceImpl();
TestInterface interface1 = (TestInterface) UnicastRemoteObject
.exportObject(
impl
, 0);
LocateRegistry.createRegistry(6666);
LocateRegistry.getRegistry(6666).rebind(
"test"
, interface1);
System.
out
.println(
"bind successfully"
);
started
=
true
;
testThread
=
new
TestThread();
new
Thread(
testThread
).start();
System.
out
.println(
"i am main..."
);
}
catch
(IOException e) {
//
TODO
Auto-generated catch block
e.printStackTrace();
}
}
|
public
void
stop() {
if
(!
started
) {
System.
out
.println(
"not started, abort"
);
return
;
}
try
{
UnicastRemoteObject.unexportObject(
impl
,
true
);
started
=
false
;
}
catch
(NoSuchObjectException e) {
//
TODO
Auto-generated catch block
e.printStackTrace();
}
System.
out
.println(
"stop rmi successfully..."
);
testThread
.setRunning(
false
);
System.
out
.println(
"stop test thread successfully..."
);
System.
out
.println(
"I am stoop"
);
}
|