Index: topia2/src/java/org/codelutin/topia/service/TopiaApplicationServiceFactory.java
diff -u /dev/null topia2/src/java/org/codelutin/topia/service/TopiaApplicationServiceFactory.java:1.1
--- /dev/null Fri May 25 16:11:09 2007
+++ topia2/src/java/org/codelutin/topia/service/TopiaApplicationServiceFactory.java Fri May 25 16:11:04 2007
@@ -0,0 +1,389 @@
+/* *##%
+ * Copyright (C) 2006 Code Lutin
+ *
+ * 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 org.codelutin.topia.service;
+
+import java.lang.reflect.Proxy;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.topia.TopiaContext;
+import org.codelutin.topia.TopiaException;
+import org.codelutin.topia.TopiaNotFoundException;
+import org.codelutin.topia.framework.TopiaUtil;
+import org.codelutin.topia.service.clients.RMIProxy;
+import org.codelutin.topia.service.clients.SOAPProxy;
+import org.codelutin.topia.service.clients.XMLRPCProxy;
+
+/**
+ * TopiaServiceFactory.java
+ *
+ * Classe utilisee pour charger les services.
+ *
+ * Deux utilisations possibles :
+ *
client: pour avoir une interface sur un service local ou distant
+ *
serveur: pour avoir un service local au serveur
+ *
+ * Sert aussi au serveur pour declarer des services
+ *
+ * @author chatellier
+ * @version $Revision: 1.1 $
+ *
+ * Last update : $Date: 2007/05/25 16:11:04 $ By : $Author: ndupont $
+ */
+public class TopiaApplicationServiceFactory {
+
+ /** Fichier de configuration par defaut */
+ static final String DEFAULT_CONFIG_PROPERTIES = "TopiaContextImpl.properties";
+
+ /** Nom de la propriete de definition des services utilises */
+ static final String TOPIA_APPLICATION_SERVICE_BEGIN = "topia.application.service.";
+
+ /** Nom de la propriete de definition des service fournit */
+ static final String TOPIA_APPLICATION_PROVIDE_BEGIN = "topia.application.provide.";
+
+ /**
+ * Nom du dossier ou sont generer certains fichiers (doit etre dans le
+ * classpath )
+ */
+ public static String TOPIA_GENERATION_DIRECTORY = "topiagen";
+
+ /** Fichier de configuration */
+ private static Properties config;
+
+ /** Dispatcher (servers) */
+ private static final TopiaServiceProvider mainDispatcher = new TopiaServiceProvider();
+
+ /**
+ * Stockage des services deja instancies
+ */
+ private static Map, TopiaApplicationService> mapServiceCache = new HashMap, TopiaApplicationService>();
+
+ /** Logger (common logging) */
+ private static final Log log = LogFactory
+ .getLog(TopiaApplicationServiceFactory.class);
+
+ private static TopiaContext defaultServiceContext;
+
+ /**
+ * Retourne la configuration. Charge le fichier s'il n'a pas deja ete
+ * charge.
+ *
+ * @throws TopiaNotFoundException
+ * si le fichier de configuration ne peut pas etre charge
+ */
+ static Properties getConfiguration() throws TopiaNotFoundException {
+ if (config == null) {
+ config = TopiaUtil.getProperties(DEFAULT_CONFIG_PROPERTIES);
+ }
+ return config;
+ }
+
+ /**
+ * Charge et lance tous les services contenus dans le fichier de
+ * configuration
+ *
+ * @param config
+ * les proprietes du fichier de configuration
+ * @param context
+ * le contexte pere des contextes fournis aux services
+ * @throws TopiaException
+ */
+ @SuppressWarnings("unchecked")
+ public static void loadServices(Properties config, TopiaContext context)
+ throws TopiaException {
+ if (context == null)
+ throw new NullPointerException(
+ "I need a valid TopiaContext to initialise application services");
+ defaultServiceContext = context;
+ // lecture du fichier de configuration
+ if (config == null) {
+ try {
+ config = getConfiguration();
+ } catch (TopiaNotFoundException e) {
+ throw new TopiaNotFoundException(
+ "Can't find configuration file "
+ + DEFAULT_CONFIG_PROPERTIES);
+ }
+ }
+ // pour chaque service applicatif
+ Set