package com.calexo.openhra.serveur;
import java.util.Hashtable;
import javax.naming.Context;
import com.calexo.javixo.Javixo;
import com.calexo.openhra.interfaces.ejb.Config;
import com.calexo.openhra.interfaces.ejb.ConfigHome;
import com.calexo.openhra.interfaces.ejb.ConfigUtil;
public class Javixo4OpenHRA extends Javixo {
public Javixo4OpenHRA() {
super.setEndPoint(getConfig("AvixoEndPoint"));
super.setWebUser(getConfig("AvixoWebUser"));
super.setWebPass(getConfig("AvixoWebPass"));
System.out.println("Javixo4OpenHRA - Pret");
}
/**
* Get the initial naming context props
*/
public static Hashtable getInitialContextProps() {
Hashtable props = new Hashtable();
props.put( Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory" );
props.put( Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
props.put( Context.PROVIDER_URL, "jnp://localhost:1099");
return props;
}
/**
* Se connecte au Bean Config de CRAS pour r�cup�rer la valeur de
* la config donc la cl� est fournie
* @param String pId
* @return String valeur de la config
*/
public static String getConfig(String pId)
{
//Logger log = Logger.getLogger(ToNamed.class);
ConfigHome cfgHome;
String ret=null;
try {
//cfgHome = ConfigUtil.getHome(getInitialContextProps());
cfgHome = ConfigUtil.getHome();
ret = ((Config)cfgHome.findByPrimaryKey(pId)).getConfigString();
} catch (Exception e) {
//e.printStackTrace();
System.err.println("getConfig(" + pId + ") introuvable");
return null;
}
return ret;
}
}