package com.dxm.servlet;
public interface MyServlet {
public void init();
public void service();
public void destroy();
}
package com.dxm.servlet;
public class MyServletImpl implements MyServlet {
@Override
public void init() {
System.out.println("init");
}
@Override
public void service() {
System.out.println("sevice");
}
@Override
public void destroy() {
System.out.println("destroy");
}
}
package com.dxm.servlet;
import org.junit.Test;
public class TestServlet {
@Test
public void test()
{
try {
String className="com.dxm.servlet.MyServletImpl";
Class clazz = Class.forName(className);
MyServletImpl my = (MyServletImpl) clazz.newInstance();
my.init();
my.service();
my.destroy();
} catch (Exception e) {
}
}
}