r922 - trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services
Author: tchemit Date: 2008-02-13 14:38:24 +0000 (Wed, 13 Feb 2008) New Revision: 922 Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteService.java Log: kdo Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteService.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteService.java 2008-02-13 14:37:54 UTC (rev 921) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteService.java 2008-02-13 14:38:24 UTC (rev 922) @@ -32,6 +32,10 @@ */ public abstract class RemoteService { + private final static String PROVIDER_URL = "java.naming.provider.url"; + private final static String FACTORY_INITIAL = "java.naming.factory.initial"; + private final static String FACTORY_URL_PKGS = "java.naming.factory.url.pkgs"; + /** The services. */ protected static Map<String, Object> services = new HashMap<String, Object>(); @@ -44,20 +48,14 @@ * @return the service */ protected static Object getService(String serviceName) { - Object service = null; + Object service; - if (services.get(serviceName) == null) { - Properties properties = (Properties) System.getProperties().clone(); - properties.put("java.naming.provider.url", "jnp://localhost:1099"); - properties.put("java.naming.factory.initial", - "org.jnp.interfaces.NamingContextFactory"); - properties - .put("java.naming.factory.url.pkgs", "org.jnp.interfaces"); - + if (!services.containsKey(serviceName)) { try { + Properties props = initProperties(); Context context; try { - context = new InitialContext(properties); + context = new InitialContext(props); } catch (Exception e) { context = new InitialContext(); } @@ -71,4 +69,12 @@ return service; } + protected static Properties initProperties() { + Properties props = (Properties) System.getProperties().clone(); + props.put(PROVIDER_URL, "jnp://localhost:1099"); + props.put(FACTORY_INITIAL,"org.jnp.interfaces.NamingContextFactory"); + props.put(FACTORY_URL_PKGS, "org.jnp.interfaces"); + return props; + } + }
participants (1)
-
tchemit@users.labs.libre-entreprise.org