[Ejtools-cvs] CVS: applications/jndi.browser/src/main/net/sourceforge/ejtools/jndibrowser/model JNDI
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-05-24 21:18:57
|
Update of /cvsroot/ejtools/applications/jndi.browser/src/main/net/sourceforge/ejtools/jndibrowser/model In directory usw-pr-cvs1:/tmp/cvs-serv31292/jndi.browser/src/main/net/sourceforge/ejtools/jndibrowser/model Modified Files: JNDIContext.java JNDIEntry.java Server.java Log Message: Add support for JavaBean Custom XDoclet Index: JNDIContext.java =================================================================== RCS file: /cvsroot/ejtools/applications/jndi.browser/src/main/net/sourceforge/ejtools/jndibrowser/model/JNDIContext.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** JNDIContext.java 15 May 2002 20:45:46 -0000 1.4 --- JNDIContext.java 24 May 2002 21:18:55 -0000 1.5 *************** *** 9,12 **** --- 9,13 ---- import java.awt.Component; import java.beans.Customizer; + import java.beans.beancontext.BeanContext; import java.beans.beancontext.BeanContextChild; import java.beans.beancontext.BeanContextChildComponentProxy; *************** *** 20,32 **** import net.sourceforge.ejtools.util.Sort; /** * Ancestor of all element in the JNDI tree. Represents a JNDI Context and can * contains other context. * ! * @author letiemble ! * @created 13 décembre 2001 ! * @version $Revision$ ! * @beaninfo:class displayName="JNDI Context" shortDescription="JNDI Context" ! * @beaninfo:icons color16="/toolbarButtonGraphics/general/Folder16.gif" */ public class JNDIContext extends BeanContextServicesSupport implements BeanContextChildComponentProxy --- 21,40 ---- import net.sourceforge.ejtools.util.Sort; + import org.apache.log4j.Category; + /** * Ancestor of all element in the JNDI tree. Represents a JNDI Context and can * contains other context. * ! * @author letiemble ! * @created 13 décembre 2001 ! * @version $Revision$ ! * @beaninfo:class displayName="JNDI Context" shortDescription="JNDI ! * Context" ! * @beaninfo:icons color16="/toolbarButtonGraphics/general/Folder16.gif" ! * @beaninfo:property name="name" class="java.lang.String" displayName="Name" ! * shortDescription="Name of the context" ! * @beaninfo:property name="path" class="java.lang.String" displayName="Full ! * Path" shortDescription="Absolute path of the context" */ public class JNDIContext extends BeanContextServicesSupport implements BeanContextChildComponentProxy *************** *** 34,46 **** /** Customizer of the JavaBean */ protected transient Customizer c = null; ! /** ! * Class name of the context ! * ! * @beaninfo:property name="name" class="java.lang.String" ! * displayName="Name" shortDescription="Name of the context" ! */ protected String className = ""; /** Name of the context */ protected String name = ""; --- 42,51 ---- /** Customizer of the JavaBean */ protected transient Customizer c = null; ! /** Class name of the context */ protected String className = ""; /** Name of the context */ protected String name = ""; + /** Description of the Field */ + private static Category logger = Category.getInstance(JNDIContext.class); *************** *** 91,94 **** --- 96,135 ---- /** + * Get the absolute JNDI path of the context + * + * @return The path value + */ + public String getPath() + { + try + { + BeanContext parent = getBeanContext(); + if (parent != null) + { + JNDIContext context = (JNDIContext) parent; + String path = context.getPath(); + if ((path == null) || ("".equals(path))) + { + return (getName()); + } + else + { + return (path + "/" + getName()); + } + } + else + { + return ""; + } + } + catch (Exception e) + { + logger.warn("Oops, not in a JNDIContext"); + } + return null; + } + + + /** * Override of BeanContextServicesSupport to allow recursive access to * BeanContext services *************** *** 151,154 **** --- 192,217 ---- { return name == null ? "Undefined" : name; + } + + + /** + * Sets the class name of this context + * + * @param className The class name + */ + protected void setClassName(String className) + { + this.className = className; + } + + + /** + * Sets the name of this context + * + * @param name The name + */ + protected void setName(String name) + { + this.name = name; } Index: JNDIEntry.java =================================================================== RCS file: /cvsroot/ejtools/applications/jndi.browser/src/main/net/sourceforge/ejtools/jndibrowser/model/JNDIEntry.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** JNDIEntry.java 15 May 2002 20:45:46 -0000 1.4 --- JNDIEntry.java 24 May 2002 21:18:55 -0000 1.5 *************** *** 7,10 **** --- 7,11 ---- package net.sourceforge.ejtools.jndibrowser.model; + /** * Describe a simple JNDI entry. *************** *** 19,22 **** --- 20,25 ---- * @beaninfo:property name="className" class="java.lang.String" * displayName="Class" shortDescription="Class of the entry" + * @beaninfo:property name="path" class="java.lang.String" displayName="Full + * Path" shortDescription="Absolute path of the context" */ public class JNDIEntry extends JNDIContext Index: Server.java =================================================================== RCS file: /cvsroot/ejtools/applications/jndi.browser/src/main/net/sourceforge/ejtools/jndibrowser/model/Server.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Server.java 15 May 2002 20:45:46 -0000 1.5 --- Server.java 24 May 2002 21:18:55 -0000 1.6 *************** *** 7,11 **** --- 7,13 ---- package net.sourceforge.ejtools.jndibrowser.model; + import java.lang.reflect.Proxy; import java.util.Collection; + import java.util.Hashtable; import java.util.Iterator; import java.util.Properties; *************** *** 15,18 **** --- 17,21 ---- import javax.naming.Context; import javax.naming.InitialContext; + import javax.naming.LinkRef; import javax.naming.NameClassPair; import javax.naming.NamingEnumeration; *************** *** 64,67 **** --- 67,72 ---- private static Category logger = Category.getInstance(Server.class); /** Description of the Field */ + private static Hashtable proxies = new Hashtable(); + /** Description of the Field */ public final static int DEEP_SEARCH = 0; /** Description of the Field */ *************** *** 96,99 **** --- 101,136 ---- + /** Description of the Method */ + public void connect() + { + logger.debug("Cleaning JNDI tree..."); + Iterator iterator = iterator(); + while (iterator.hasNext()) + { + remove(iterator.next()); + } + + try + { + Context context = new InitialContext(); + context = (Context) context.lookup(getContext()); + + Vector content = new Vector(); + list(context, content); + + logger.debug("Populating JNDI tree..."); + Iterator it = content.iterator(); + while (it.hasNext()) + { + add(it.next()); + } + } + catch (Exception e) + { + logger.error("Exception " + e.getMessage()); + } + } + + /** * Gets the context attribute of the JNDIServer object *************** *** 130,133 **** --- 167,181 ---- /** + * Gets the path attribute of the Server object + * + * @return The path value + */ + public String getPath() + { + return getContext(); + } + + + /** * Getter for the searchType attribute * *************** *** 181,184 **** --- 229,233 ---- Vector content = new Vector(); this.iterateContext(context, this.getContext(), content); + // this.iterateContext(context, "", content); logger.debug("Populating JNDI tree..."); *************** *** 252,255 **** --- 301,400 ---- /** + * Description of the Method + * + * @param ctx Description of the Parameter + * @param node Description of the Parameter + */ + protected void list(Context ctx, Collection node) + { + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + try + { + NamingEnumeration ne = ctx.list(""); + while (ne.hasMore()) + { + NameClassPair pair = (NameClassPair) ne.next(); + // logger.warn(">>> Pair: " + pair); + + String name = pair.getName(); + String className = pair.getClassName(); + boolean recursive = false; + boolean isLinkRef = false; + boolean isProxy = false; + + // logger.warn("Name=" + name); + // logger.warn("Class=" + className); + + Class c = null; + try + { + c = loader.loadClass(className); + // logger.warn("Class: " + c); + + if (Context.class.isAssignableFrom(c)) + { + recursive = true; + } + if (LinkRef.class.isAssignableFrom(c)) + { + isLinkRef = true; + } + + isProxy = Proxy.isProxyClass(c); + } + catch (ClassNotFoundException cnfe) + { + logger.warn("Exception " + cnfe.getMessage()); + } + catch (Exception e) + { + logger.warn("Exception " + e.getMessage()); + } + + if (recursive) + { + JNDIContext newNode = new JNDIContext(); + newNode.setName(name); + newNode.setClassName(className); + node.add(newNode); + + try + { + Object value = ctx.lookup(name); + if (value instanceof Context) + { + Context subctx = (Context) value; + list(subctx, newNode); + } + else + { + } + } + catch (Throwable t) + { + logger.warn("Throwable " + t); + } + } + else + { + JNDIContext newNode; + + newNode = new JNDIEntry(); + newNode.setName(name); + newNode.setClassName(className); + + node.add(newNode); + } + } + ne.close(); + } + catch (NamingException ne) + { + logger.error("error while listing context " + ctx.toString() + ": " + ne.toString(true)); + } + } + + + /** * Gets the context attribute of the JndiServer object * *************** *** 300,303 **** --- 445,449 ---- iterateContext(context1, s1, newNode); + // iterateContext(context1, "", newNode); } else *************** *** 305,308 **** --- 451,457 ---- JNDIContext newNode; + logger.debug("NC=" + nc.getName()); + logger.debug("NC=" + nc.getClassName()); + newNode = new JNDIEntry(); newNode.name = nc.getName(); *************** *** 381,384 **** return true; } - } --- 530,547 ---- return true; } + /** Load the list of proxies to create */ + /* + * static + * { + * proxies.put(javax.ejb.EJBHome.class, EJBHomeProxy.class); + * proxies.put(javax.ejb.EJBLocalHome.class, EJBLocalHomeProxy.class); + * proxies.put(javax.jms.ConnectionFactory.class, ConnectionFactoryProxy.class); + * proxies.put(javax.jms.Queue.class, QueueProxy.class); + * proxies.put(javax.jms.Topic.class, TopicProxy.class); + * proxies.put(javax.mail.Session.class, TopicProxy.class); + * proxies.put(javax.sql.DataSource.class, DataSourceProxy.class); + * proxies.put(javax.sql.XADataSource.class, XADataSourceProxy.class); + * } + */ + } |