| | |
| | | package de.uhilger.wbx; |
| | | |
| | | import java.io.File; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | import javax.naming.Context; |
| | | import javax.naming.InitialContext; |
| | | import javax.naming.NamingException; |
| | | import javax.servlet.ServletContext; |
| | | |
| | | /** |
| | |
| | | |
| | | private static final Logger logger = Logger.getLogger(WbxUtils.class.getName()); |
| | | |
| | | public static final String JNDI_CTX_NAME = "java:comp/env"; |
| | | |
| | | public static final String NOT_FOUND = " nicht gefunden"; |
| | | public static final String NO_STRING = " ist kein String"; |
| | | public static final String EMPTY_STRING = ""; |
| | | |
| | | //public static final String FILE_BASE = "filebase"; |
| | | //public static final String DATENABLAGE = "datenAblage"; |
| | | |
| | | public int getJNDIInt(String paramName, int defaultVal) { |
| | | String jndiStr = getJNDIParameter(paramName, Integer.toString(defaultVal)); |
| | | try { |
| | | return Integer.parseInt(jndiStr); |
| | | } catch(NumberFormatException ex) { |
| | | logger.log(Level.FINE, ex.getMessage()); |
| | | return defaultVal; |
| | | } |
| | | } |
| | | |
| | | public String getJNDIParameter(String pname, String defaultVal) { |
| | | try { |
| | | // unseren environment naming context ermitteln |
| | | Context initCtx = new InitialContext(); |
| | | Context envCtx = (Context) initCtx.lookup(JNDI_CTX_NAME); |
| | | |
| | | // unseren Parameter lesen |
| | | Object o = envCtx.lookup(pname); |
| | | if(o instanceof String) { |
| | | return o.toString(); |
| | | } else { |
| | | return defaultVal; |
| | | } |
| | | } catch (NamingException ex) { |
| | | logger.log(Level.FINE, ex.getMessage()); |
| | | return defaultVal; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Bei der WebBox ist das Datenverzeichnis relativ zum Verzeichnis |
| | | * $CATALINA_BASE/webapps untergebracht. |