[Idrs-commit] CVS: Idrs/dev/src/net/sourceforge/idrs/jndi JndiConnection.java,1.1,1.2
Brought to you by:
bigman921
|
From: Marc B. <big...@us...> - 2003-03-26 21:33:46
|
Update of /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/jndi
In directory sc8-pr-cvs1:/tmp/cvs-serv31636/dev/src/net/sourceforge/idrs/jndi
Modified Files:
JndiConnection.java
Log Message:
refactored navigation tags, also added a <navcur> tag that generates a link that will kepp a page it it's current state, minus any specified parameters.
Index: JndiConnection.java
===================================================================
RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/jndi/JndiConnection.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** JndiConnection.java 17 Mar 2003 14:05:02 -0000 1.1
--- JndiConnection.java 26 Mar 2003 21:33:12 -0000 1.2
***************
*** 13,16 ****
--- 13,21 ----
import java.util.*;
import net.sourceforge.idrs.exceptions.*;
+ import javax.ejb.*;
+ import javax.rmi.*;
+ import java.lang.reflect.*;
+ import javax.servlet.*;
+ import javax.servlet.http.*;
/**
***************
*** 19,33 ****
*/
public class JndiConnection implements java.sql.Connection {
/** JNDI connection */
Context con;
/**Stores properties for initialization */
- Hashtable env;
/**
*Returns the context used to connect
*/
public Context getContext() {
return this.con;
}
--- 24,48 ----
*/
public class JndiConnection implements java.sql.Connection {
+ public static final String IDRS_STATEFULL_EJB = "IDRS_STATEFULL_EJB";
+ public static final String IDRS_USER_CONTEXT = "IDRS_USER_CONTEXT";
+
+
+
+ HashMap homes;
+ HashMap stateless;
+
/** JNDI connection */
Context con;
/**Stores properties for initialization */
+
+
/**
*Returns the context used to connect
*/
public Context getContext() {
+
return this.con;
}
***************
*** 42,47 ****
--- 57,68 ----
*/
public JndiConnection(String url, Properties props) throws SQLException {
+ homes = new HashMap();
+ stateless = new HashMap();
+
+
props.put(Context.PROVIDER_URL,url);
+
+
try {
//System.out.println("gonna create");
***************
*** 67,72 ****
}
!
--- 88,174 ----
}
+
+ private EJBObject lookup(String name, String home, String remote, boolean stateless) throws Exception {
+ Object obj = con.lookup(name);
+
+ EJBHome hm = (EJBHome) PortableRemoteObject.narrow(obj,Class.forName(home));
+ homes.put(home,hm);
+
+ return lookup(home,hm,name,stateless);
+
+ }
+
+ private EJBObject lookup(String home, EJBHome hm,String name,boolean stateless) throws Exception {
+ EJBObject ejb;
+
+ Method create = Class.forName(home).getMethod("create",new Class[] {});
+ ejb = (EJBObject) create.invoke(hm,new Object[] {});
+ if (stateless) {
+ this.stateless.put(name,ejb);
+ }
+
+ return ejb;
+ }
! public EJBObject getEJB(String name, String home, String remote, boolean stateless,HttpSession session) throws Exception {
!
! EJBObject ejb;
! EJBHome homeInt;
! Handle handle;
! HashMap statefull;
!
! Context ctx = this.con;
!
! if (stateless) {
! ejb = (EJBObject) this.stateless.get(name);
!
! if (ejb != null) return ejb;
!
! homeInt = (EJBHome) this.homes.get(home);
!
! if (homeInt != null) return lookup(name,home,remote,stateless);
!
! Object obj = ctx.lookup(name);
! homeInt = (EJBHome) PortableRemoteObject.narrow(obj,Class.forName(home));
!
!
! return lookup(home,homeInt,name,stateless);
!
! }
! else {
! ejb = null;
! statefull = (HashMap) session.getAttribute(JndiConnection.IDRS_STATEFULL_EJB);
! if (statefull == null) {
! statefull = new HashMap();
! session.setAttribute(JndiConnection.IDRS_STATEFULL_EJB,statefull);
! }
!
! ejb = (EJBObject) statefull.get(name);
!
! if (ejb != null) return ejb;
!
! homeInt = (EJBHome) this.homes.get(home);
!
! if (homeInt != null) {
! return lookup(name,home,remote,stateless);
! }
!
! Object obj = ctx.lookup(name);
! homeInt = (EJBHome) PortableRemoteObject.narrow(obj,Class.forName(home));
!
! return lookup(home,homeInt,name,stateless);
! }
!
!
!
!
! /*Object obj = ctx.lookup(name);
!
! EJBHome hm = (EJBHome) PortableRemoteObject.narrow(obj,Class.forName(home));
!
! Method create = Class.forName(home).getMethod("create",new Class[] {});
! return (EJBObject) create.invoke(hm,new Object[] {});*/
!
! }
|