package beans; import common.*; import oracle.aurora.jndi.sess_iiop.ServiceCtx; import javax.naming.Context; import javax.naming.InitialContext; import javax.servlet.http.HttpSessionBindingListener; import javax.servlet.http.HttpSessionBindingEvent; import java.util.Hashtable; public class HelloCorbaWrapperBean implements HttpSessionBindingListener { private Hello hello = null; public String doCallCORBA(String serviceURL, String inJServer) { try { Context ic = null; if (hello == null) { if (inJServer != null) { // use simplified and optimized lookup in JServer ic = new InitialContext(); } else if (serviceURL != null) { // not running in JServer, use standard lookup Hashtable env = new Hashtable(); env.put(Context.URL_PKG_PREFIXES, "oracle.aurora.jndi"); env.put(Context.SECURITY_PRINCIPAL, "scott"); env.put(Context.SECURITY_CREDENTIALS, "tiger"); env.put(Context.SECURITY_AUTHENTICATION, ServiceCtx.NON_SSL_LOGIN); ic = new InitialContext (env); } hello = (Hello)ic.lookup (serviceURL + "/test/HelloCorb"); } return (hello.helloWorld()); } catch (Exception e) { return "Error occurred: " + e; } } public void valueBound(HttpSessionBindingEvent event) { // nothing to do here, Corba object will be created // only when a query is submitted } public synchronized void valueUnbound(HttpSessionBindingEvent event) { // method is exceuted when bean is removed from the session if (hello != null) { try { hello._release(); } catch (Exception e) {} } } }