[Ejtools-cvs] CVS: libraries/common/src/main/net/sourceforge/ejtools/util JNDI.java,NONE,1.1 Limited
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-04-19 07:05:05
|
Update of /cvsroot/ejtools/libraries/common/src/main/net/sourceforge/ejtools/util In directory usw-pr-cvs1:/tmp/cvs-serv20920 Added Files: JNDI.java LimitedStack.java Sort.java Log Message: Initial Import --- NEW FILE: JNDI.java --- package net.sourceforge.ejtools.util; import java.io.*; import java.rmi.*; import java.sql.*; import java.util.*; import javax.ejb.*; import javax.management.*; import javax.management.j2ee.*; import javax.naming.*; import javax.rmi.*; import javax.servlet.*; import javax.servlet.http.*; import javax.sql.*; import org.apache.log4j.*; /** * Description of the Class * * @author letiembl * @created 12 novembre 2001 */ public abstract class JNDI { /** Description of the Method */ public static void setJNDIProperties() { try { InputStream in = JNDI.class.getResourceAsStream("/jndi.properties"); if (in != null) { // Load the jndi properties file Properties props = new Properties(); props.load(in); in.close(); System.out.println("Setting System Properties"); // Set up the environment System.setProperty(Context.INITIAL_CONTEXT_FACTORY, props.getProperty(Context.INITIAL_CONTEXT_FACTORY)); System.setProperty(Context.URL_PKG_PREFIXES, props.getProperty(Context.URL_PKG_PREFIXES)); System.setProperty(Context.PROVIDER_URL, props.getProperty(Context.PROVIDER_URL)); } } catch (IOException ioe) { ioe.printStackTrace(); // Ignore it } } } --- NEW FILE: LimitedStack.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.util; import java.util.Stack; /** * Description of the Class * * @author laurent * @created 24 décembre 2001 * @todo Javadoc to complete */ public class LimitedStack extends Stack { private int maximumSize; /** Constructor for the LimitedStack object */ public LimitedStack() { this(10); } /** * Constructor for the LimitedStack object * * @param size Description of Parameter */ public LimitedStack(int size) { this.maximumSize = size; } /** * Description of the Method * * @param item Description of Parameter * @return Description of the Returned Value */ public Object push(Object item) { if (this.contains(item)) { this.remove(this.indexOf(item)); } else { if (this.size() >= this.maximumSize) { this.remove(0); } } return super.push(item); } } --- NEW FILE: Sort.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.util; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.Vector; /** * Description of the Class * * @author laurent * @created 24 décembre 2001 * @todo Javadoc to complete */ public abstract class Sort { /** * Gets the childrenByClass attribute of the Sort class * * @param enum Description of Parameter * @param c Description of Parameter * @return The childrenByClass value */ public static Iterator getChildrenByClass(Iterator enum, Class c) { Object obj; Vector v = new Vector(); while (enum.hasNext()) { if (c.isAssignableFrom((obj = enum.next()).getClass())) { v.addElement(obj); } } return v.iterator(); } /** * Description of the Method * * @param enum Description of Parameter * @return Description of the Returned Value */ public static Iterator sortByClass(Iterator enum) { Vector v = new Vector(); while (enum.hasNext()) { v.addElement(enum.next()); } Collections.sort(v, new Comparator() { public int compare(Object o1, Object o2) { return o1.getClass().getName().compareTo(o2.getClass().getName()); } public boolean equals(Object obj) { return true; // Ever called? } }); return v.iterator(); } /** * Description of the Method * * @param enum Description of Parameter * @return Description of the Returned Value */ public static Iterator sortByClassAndName(Iterator enum) { Vector v = new Vector(); while (enum.hasNext()) { v.addElement(enum.next()); } Collections.sort(v, new Comparator() { public int compare(Object o1, Object o2) { int ret = o1.getClass().getName().compareTo(o2.getClass().getName()); if (ret == 0) { ret = o1.toString().compareTo(o2.toString()); } return ret; } public boolean equals(Object obj) { return true; // Ever called? } }); return v.iterator(); } /** * Description of the Method * * @param enum Description of Parameter * @return Description of the Returned Value */ public static Iterator sortByName(Iterator enum) { Vector v = new Vector(); while (enum.hasNext()) { v.addElement(enum.next()); } Collections.sort(v, new Comparator() { public int compare(Object o1, Object o2) { return o1.toString().compareTo(o2.toString()); } public boolean equals(Object obj) { return true; // Ever called? } }); return v.iterator(); } } |