theClass.addInterface(classPool.get(BeanInterface.class.getName()));
CtMethod theMethod = new CtMethod(
classPool.get("java.lang.String"), "interfaceMethod",
new CtClass[0], theClass);
theMethod.setBody("return \"Hello, World!\";");
theClass.addMethod(theMethod);
Class clazz = theClass.toClass();
return ( BeanInterface )clazz.newInstance();
} catch (Exception e) {
throw new ApplicationRuntimeException("Cannot construct instance.",
e);