";
String HR = " ";
String pepperImg = "";
/**
* The main method of this JSP
*/
public void main(HttpServletRequest request, HttpSession session, JspWriter out) throws Exception{
this.request = request;
this.session = session;
this.out = out;
InitialContext ctx = null;
ClassLoader myLoader = null;
try{
myLoader = this.getClass().getClassLoader();
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.openejb.client.LocalInitialContextFactory");
ctx = new InitialContext( p );
} catch (Exception e){
formatThrowable(e);
}
try{
out.print(HR);
out.print("
");
// ---------------------------------------------------
// Can I lookup a home interface from the testsuite?
// ---------------------------------------------------
printTest("Looking up an ejb home ");
Object ejbHome = null;
try{
ejbHome = ctx.lookup( "client/tests/stateless/BasicStatelessHome" );
if (ejbHome instanceof java.rmi.Remote) out.println(OK);
} catch (Exception e){
out.println(FAIL);
return;
}
// ---------------------------------------------------
// Is the home interface visible?
// ---------------------------------------------------
printTest("Checking for the home interface class definition ");
Class homeInterface;
try{
homeInterface = Class.forName("org.openejb.test.stateless.BasicStatelessHome",true, myLoader);
out.println(OK);
} catch (Exception e){
out.println(FAIL);
return;
}
// ---------------------------------------------------
// Can I invoke a create method on the ejb home?
// ---------------------------------------------------
printTest("Invoking the create method on the ejb home ");
Object ejbObject = null;
try{
Class[] params = new Class[0];
Method create = null;
create = homeInterface.getDeclaredMethod("create", params);
ejbObject = create.invoke(ejbHome, new Object[0]);
if (ejbObject instanceof java.rmi.Remote) out.println(OK);
} catch (Exception e){
out.println(FAIL);
return;
}
// ---------------------------------------------------
// Is the remote interface visible?
// ---------------------------------------------------
printTest("Checking for the remote interface class definition ");
Class remoteInterface;
try{
remoteInterface = Class.forName("org.openejb.test.stateless.BasicStatelessObject",true, myLoader);
out.println(OK);
} catch (Exception e){
out.println(FAIL);
return;
}
// ---------------------------------------------------
// Can I invoke a business method on the ejb object?
// ---------------------------------------------------
printTest("Invoking a business method on the ejb object ");
Object returnValue = null;
try{
String message = "!snoitalutargnoC ,skroW gnihtyrevE";
Class[] params = new Class[]{String.class};
Method businessMethod = null;
businessMethod = remoteInterface.getDeclaredMethod("businessMethod", params);
returnValue = businessMethod.invoke(ejbObject, new Object[]{message});
if (returnValue instanceof java.lang.String) out.println(OK);
} catch (Exception e){
out.println(FAIL);
return;
}
out.print("
");
out.print(HR);
out.println(" The Enterprise Bean returned the following message: