r1246 - trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services
Author: glandais Date: 2008-02-26 10:37:33 +0000 (Tue, 26 Feb 2008) New Revision: 1246 Removed: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteService.java Log: unused (transfered to service) Deleted: 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-26 10:36:00 UTC (rev 1245) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteService.java 2008-02-26 10:37:33 UTC (rev 1246) @@ -1,91 +0,0 @@ -/* -* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* ##% */ -package fr.cemagref.simexplorer.is.ui.web.services; - -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; -import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; - -/** - * The Class RemoteService. - */ -public abstract class RemoteService { - - /** The Constant PROVIDER_URL. */ - private final static String PROVIDER_URL = "java.naming.provider.url"; - - /** The Constant FACTORY_INITIAL. */ - private final static String FACTORY_INITIAL = "java.naming.factory.initial"; - - /** The Constant FACTORY_URL_PKGS. */ - private final static String FACTORY_URL_PKGS = "java.naming.factory.url.pkgs"; - - /** The services. */ - protected static Map<String, Object> services = new HashMap<String, Object>(); - - /** - * Gets the service. - * - * @param serviceName the service name - * - * @return the service - * @throws SimExplorerException if any problem while init of service - */ - protected static Object getService(String serviceName) throws SimExplorerException { - Object service; - - if (!services.containsKey(serviceName)) { - try { - Properties props = initProperties(); - Context context; - try { - context = new InitialContext(props); - } catch (Exception e) { - context = new InitialContext(); - } - services.put(serviceName, context.lookup(serviceName)); - } catch (NamingException e) { - throw new SimExplorerTechnicalException(e); - } - } - service = services.get(serviceName); - - return service; - } - - /** - * Inits the properties. - * - * @return the properties - */ - 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)
-
glandais@users.labs.libre-entreprise.org