response.setContentType(CONTENT_TYPE_TEXT_PLAIN);
// Create the EJB Container
final Map<String, String> ejbContainerProps = new HashMap<String, String>();
ejbContainerProps.put(EJBContainer.MODULES, ""); // Deploy no modules and do no scanning by default
final JBossEJBContainerProvider ejbContainer = (JBossEJBContainerProvider) EJBContainer
.createEJBContainer(ejbContainerProps);
final ShrinkWrapEJBContainer shrinkwrapEjbContainer = new ShrinkWrapEJBContainerImpl(ejbContainer);
// Define the EJB JAR
final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "outputSlsb.jar").addClasses(OutputBean.class,
OutputLocalBusiness.class);
// Deploy the JAR
shrinkwrapEjbContainer.deploy(archive);
// Look up the EJB
final Context context = ejbContainer.getContext();
final OutputLocalBusiness bean;
try
{
bean = (OutputLocalBusiness) context.lookup(OutputLocalBusiness.JNDI_NAME);
}
catch (final NamingException e)
{
throw new RuntimeException("Could not find bean proxy at " + OutputLocalBusiness.JNDI_NAME, e);
}
// Invoke
final String value = bean.getOutput();
// Undeploy
shrinkwrapEjbContainer.undeploy(archive);
// Shut down EJBContainer
ejbContainer.close();
// Write out
log.info("Got value from EJB: " + value);
response.getWriter().write(value);
}