Index: topia2/src/java/org/codelutin/topia/service/TopiaApplicationServiceAbstract.java diff -u /dev/null topia2/src/java/org/codelutin/topia/service/TopiaApplicationServiceAbstract.java:1.1 --- /dev/null Wed Apr 18 12:21:30 2007 +++ topia2/src/java/org/codelutin/topia/service/TopiaApplicationServiceAbstract.java Wed Apr 18 12:21:24 2007 @@ -0,0 +1,53 @@ +/* *##% + * 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 org.codelutin.topia.TopiaContext; + +/** + * TopiaAplicationServiceAbstract.java + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2007/04/18 12:21:24 $ By : $Author: chatellier $ + */ +public class TopiaApplicationServiceAbstract implements TopiaApplicationService { + + /* + * (non-Javadoc) + * + * @see org.codelutin.topia.service.TopiaApplicationService#getTopiaContext() + */ + public TopiaContext getTopiaContext() { + // TODO Auto-generated method stub + return null; + } + + /* + * (non-Javadoc) + * + * @see org.codelutin.topia.service.TopiaApplicationService#setTopiaContext(org.codelutin.topia.TopiaContext) + */ + public void setTopiaContext(TopiaContext tc) { + // TODO Auto-generated method stub + + } + +} Index: topia2/src/java/org/codelutin/topia/service/TopiaServiceServerAbstract.java diff -u /dev/null topia2/src/java/org/codelutin/topia/service/TopiaServiceServerAbstract.java:1.1 --- /dev/null Wed Apr 18 12:21:30 2007 +++ topia2/src/java/org/codelutin/topia/service/TopiaServiceServerAbstract.java Wed Apr 18 12:21:24 2007 @@ -0,0 +1,62 @@ +/* *##% + * 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.Method; + +/** + * TopiaServiceServer.java + * + * Methodes communes a tous les servers renvoie l'appel sur le dispatcher + * principal. + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2007/04/18 12:21:24 $ By : $Author: chatellier $ + */ +public abstract class TopiaServiceServerAbstract implements TopiaServiceServer { + + /** Le dispatcher principal */ + private TopiaServiceProvider mainDispatcher; + + /** + * Set dispatcher + * + * @param mainDispatcher + */ + public void setTopiaServiceProvider(TopiaServiceProvider mainDispatcher) { + this.mainDispatcher = mainDispatcher; + } + + /** + * Disptach + * + * @param className + * la classe + * @param methodName + * le nom de la methode + * @param args + * les arguments + * @return le resultat de l'appel + */ + protected Object invoke(Method method, Object[] args) { + return mainDispatcher.execute(method, args); + } +} Index: topia2/src/java/org/codelutin/topia/service/TopiaServiceProvider.java diff -u /dev/null topia2/src/java/org/codelutin/topia/service/TopiaServiceProvider.java:1.1 --- /dev/null Wed Apr 18 12:21:30 2007 +++ topia2/src/java/org/codelutin/topia/service/TopiaServiceProvider.java Wed Apr 18 12:21:24 2007 @@ -0,0 +1,236 @@ +/* *##% + * 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.InvocationTargetException; +import java.lang.reflect.Method; +import java.rmi.RemoteException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.beanutils.MethodUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codelutin.topia.service.servers.RMIServer; +import org.codelutin.topia.service.servers.SOAPServer; +import org.codelutin.topia.service.servers.XMLRPCServer; + +/** + * TopiaServiceProvider.java + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2007/04/18 12:21:24 $ By : $Author: chatellier $ + */ +public class TopiaServiceProvider { + + /** Logger (common logging) */ + private static final Log logger = LogFactory + .getLog(TopiaServiceProvider.class); + + /** + * Map de correspondance interface -> instance + */ + private Map, TopiaApplicationService> mapInstanceForClass; + + /** + * Map de corresponcance class servant a creer une instance pour une + * interface (pour chaque requete) + */ + private Map, Class> mapClassForClass; + + /** + * Sert a savoir si des servers ont deja ete lance ou pas. + */ + private Map mapDispatcherForProtocole; + + /** + * Constructeur + */ + public TopiaServiceProvider() { + // instancaition des maps + mapInstanceForClass = new HashMap, TopiaApplicationService>(); + mapClassForClass = new HashMap, Class>(); + mapDispatcherForProtocole = new HashMap(); + } + + /** + * + * @param interfaze + * @param clazz + * @param protocole + */ + public void addServiceClass( + Class interfaze, + Class clazz, Protocole protocole) { + TopiaServiceServer server = initDispatcher(protocole); + if (server != null) { + server.addService(interfaze); + mapClassForClass.put(interfaze, clazz); + launchDispatcher(protocole); + } + } + + /** + * + * @param interfaze + * @param instance + * @param protocole + */ + public void addServiceInstance( + Class interfaze, + TopiaApplicationService instance, Protocole protocole) { + TopiaServiceServer server = initDispatcher(protocole); + if (server != null) { + server.addService(interfaze); + mapInstanceForClass.put(interfaze, instance); + launchDispatcher(protocole); + } + + } + + /** + * + * @param protocole + */ + private TopiaServiceServer initDispatcher(Protocole protocole) { + + TopiaServiceServer server = mapDispatcherForProtocole.get(protocole); + + // si un serveur n'est pas deja creer pour ce protocole + if (server == null) { + + switch (protocole) { + case XML_RPC: + server = new XMLRPCServer(); + break; + case RMI: + try { + server = new RMIServer(); + } catch (RemoteException e) { + logger.debug("Can't start RMIServer.",e); + } + break; + case SOAP: + server = new SOAPServer(); + break; + default: + logger.debug("Unsupported protocole"); + break; + } + + // ajoute a la liste + mapDispatcherForProtocole.put(protocole, server); + // renseigne le dispatcher + server.setTopiaServiceProvider(this); + } + + return server; + } + + /** + * + * @param protocole + */ + private void launchDispatcher(Protocole protocole) { + TopiaServiceServer server = mapDispatcherForProtocole.get(protocole); + + /*switch (protocole) { + case XML_RPC: + // le lance + server.launch(); + break; + case RMI: + server.launch(); + break; + case SOAP: + server.launch(); + break; + default: + logger.debug("Unsupported protocole"); + break; + }*/ + server.launch(); + } + + /** + * Effectue l'appel reel suivant comment a ete fournit le service, classe ou + * instance. + * + * @param args + * les arguments + * @param method + * la methode + * @return le resultat de l'appel de la methode + */ + public Object execute(Method method, Object[] args) { + // log + logger.debug("Request service : " + + method.getDeclaringClass().getName() + "." + method.getName() + + "(" + Arrays.toString(args) + ")"); + + Object result = null; + + // la classe du service + Class clazz = null; + try { + clazz = method.getDeclaringClass(); + + // le service + TopiaApplicationService tasService = null; + + // recherche du service dans la map class -> class + if (mapClassForClass.get(clazz) != null) { + tasService = mapClassForClass.get(clazz).newInstance(); + } + // sinon dans la map clazz -> instance + else if (mapInstanceForClass.get(clazz) != null) { + tasService = mapInstanceForClass.get(clazz); + } else + logger.warn("No service set for class " + clazz.getName()); + + // Appel via commons beanutils + result = MethodUtils.invokeMethod(tasService, method.getName(), + args); + + } catch (InstantiationException e) { + logger.debug("Can't instanciate class", e); + } catch (IllegalAccessException e) { + logger.debug("Can't access class", e); + } catch (SecurityException e) { + logger.debug("Can't call method '" + clazz.getName() + + "' in class '" + clazz.getName() + + "' (SecurityException)", e); + } catch (NoSuchMethodException e) { + logger.debug("No method '" + clazz.getName() + "' found in class '" + + clazz.getName() + "'", e); + } catch (IllegalArgumentException e) { + logger.debug("Can't call method '" + clazz.getName() + + "' in class '" + clazz.getName() + "' (security)", e); + } catch (InvocationTargetException e) { + logger.debug("Can't call method '" + clazz.getName() + + "' in class '" + clazz.getName() + + "' (InvocationTargetException)", e); + } + + return result; + } +} Index: topia2/src/java/org/codelutin/topia/service/TopiaApplicationService.java diff -u /dev/null topia2/src/java/org/codelutin/topia/service/TopiaApplicationService.java:1.1 --- /dev/null Wed Apr 18 12:21:30 2007 +++ topia2/src/java/org/codelutin/topia/service/TopiaApplicationService.java Wed Apr 18 12:21:24 2007 @@ -0,0 +1,33 @@ +/* *##% + * 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; + +/** + * TopiaApplicationService.java + * + * Represente un service Topia. + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2007/04/18 12:21:24 $ By : $Author: chatellier $ + */ +public interface TopiaApplicationService { + +} Index: topia2/src/java/org/codelutin/topia/service/package.html diff -u /dev/null topia2/src/java/org/codelutin/topia/service/package.html:1.1 --- /dev/null Wed Apr 18 12:21:30 2007 +++ topia2/src/java/org/codelutin/topia/service/package.html Wed Apr 18 12:21:24 2007 @@ -0,0 +1,30 @@ + + + + + + + + + + +

La couche de service ToPIA.

+ +

Toutes l'utilisation s'effectue au travers de la factory TopiaServiceFactory.

+ +

Services utilisés

+ +

TopiaServiceFactory.getService(Class) permet de recuperer une interface + sur un service, son implmentation est chargée comme definie dans la + configuration.

+ +

Services fournit

+ +

TopiaServiceFactory.addService(Class,Class,Protocole...) et + TopiaServiceFactory.addService(Class,Object,Protocole...) permettent de mettre + à disposition un service sur un protocole donné

+ + + Index: topia2/src/java/org/codelutin/topia/service/TopiaServiceServer.java diff -u /dev/null topia2/src/java/org/codelutin/topia/service/TopiaServiceServer.java:1.1 --- /dev/null Wed Apr 18 12:21:30 2007 +++ topia2/src/java/org/codelutin/topia/service/TopiaServiceServer.java Wed Apr 18 12:21:24 2007 @@ -0,0 +1,51 @@ +/* *##% + * 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; + +/** + * TopiaServiceServer.java + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2007/04/18 12:21:24 $ By : $Author: chatellier $ + */ +public interface TopiaServiceServer { + + /** + * Ajoute un service devant etre gere. + * + * @param clazz + * le nom de l'interface. + */ + public abstract void addService( + Class clazz); + + /** + * Lance le serveur + */ + public abstract void launch(); + + /** + * Set dispatcher + * + * @param mainDispatcher + */ + public void setTopiaServiceProvider(TopiaServiceProvider mainDispatcher); +} Index: topia2/src/java/org/codelutin/topia/service/Protocole.java diff -u /dev/null topia2/src/java/org/codelutin/topia/service/Protocole.java:1.1 --- /dev/null Wed Apr 18 12:21:30 2007 +++ topia2/src/java/org/codelutin/topia/service/Protocole.java Wed Apr 18 12:21:24 2007 @@ -0,0 +1,38 @@ +/* *##% + * 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; + +/** + * Protocole. + * + * Liste des protocoles de web services supportes + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2007/04/18 12:21:24 $ By : $Author: chatellier $ + */ +public enum Protocole { + /** RMI */ + RMI, + /** XML-RPC */ + XML_RPC, + /** SOAP */ + SOAP +} Index: topia2/src/java/org/codelutin/topia/service/TopiaServiceFactory.java diff -u /dev/null topia2/src/java/org/codelutin/topia/service/TopiaServiceFactory.java:1.1 --- /dev/null Wed Apr 18 12:21:30 2007 +++ topia2/src/java/org/codelutin/topia/service/TopiaServiceFactory.java Wed Apr 18 12:21:24 2007 @@ -0,0 +1,305 @@ +/* *##% + * 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 org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +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/04/18 12:21:24 $ By : $Author: chatellier $ + */ +public class TopiaServiceFactory { + + /** Fichier de configuration par defaut */ + static final String DEFAULT_CONFIG_PROPERTIES = "TopiaApplicationServices.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 logger = LogFactory + .getLog(TopiaServiceFactory.class); + + /** + * 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; + } + + /** + * Fournit une interface sur un service en l'implementant comme definit dans + * la configuration. + * + * Configuration (TopiaApplicationServices.properties par defaut) : + * topia.application.service.fqn=local://fqnImpl/#new + * topia.application.service.fqn=local://fqnImpl + * topia.application.service.fqn=rmi://127.0.0.1:1099 + * topia.application.service.fqn=xmlrpc://127.0.0.1:9090 ... + * + * @param + * l'interface doit etendre TopiaApplicationService + * @param serviceclazz + * l'interface du service + * @return l'implementation du service ou null si le service ne + * peut etre charge + * @see TopiaApplicationService + * @throws TopiaNotFoundException + * si le fichier de configuration n'existe pas + * @throws TopiaException + * si le service ne peut pas etre charge + */ + @SuppressWarnings("unchecked") + public static E getService( + Class serviceclazz) throws TopiaNotFoundException, + TopiaException { + + // l'implementation a retourner + E serviceimpl = (E) mapServiceCache.get(serviceclazz); + + // s'il etait dans le cache on le retourne directement + // dans le cas "#new" il n'est jamais dans le cache, donc recree + if (serviceimpl != null) { + return serviceimpl; + } + + // configuration + Properties config = getConfiguration(); + + // recherche du service + String serviceUrl = (String) config.get(TOPIA_APPLICATION_SERVICE_BEGIN + + serviceclazz.getCanonicalName()); + if (serviceUrl == null) { + logger.error("Properties '" + TOPIA_APPLICATION_SERVICE_BEGIN + + serviceclazz.getCanonicalName() + + "' not found in configuration"); + throw new TopiaNotFoundException("Service '" + + serviceclazz.getCanonicalName() + + "' not definided in configuration"); + } else { + + try { + // conversion de l'URI + URI uriService = new URI(serviceUrl); + String protocole = uriService.getScheme(); + String host = uriService.getHost(); + String fragment = uriService.getFragment(); + + // ensuite ca depend si le service est local ou distant + // local = local://fqn + // sinon, c'est distant + if ("local".equalsIgnoreCase(protocole)) { + + String fqClassImpl = host; + logger.debug("Trying to load local service : " + + fqClassImpl); + + // instanciation dynamique + try { + Class resultClass = (Class) Class + .forName(fqClassImpl); + serviceimpl = resultClass.newInstance(); + + // mise en cache + // sauf dans le cas ou il y a un "#new" a la fin de + // l'uri + if (!"new".equalsIgnoreCase(fragment)) { + mapServiceCache.put(serviceclazz, serviceimpl); + } + } catch (ClassNotFoundException eee) { + throw new TopiaException("Can't find service class " + + fqClassImpl); + } catch (InstantiationException eee) { + throw new TopiaException( + "Can't instanciate service class " + + fqClassImpl); + } catch (IllegalAccessException eee) { + throw new TopiaException("Can't access service class " + + fqClassImpl); + } + } + // prefix non local => proxy + else { + logger + .debug("Trying to get remote service : " + + serviceUrl); + + TopiaProxy tProxy = getProxyForURI(uriService); + + if (tProxy == null) { + logger.debug("Unsupported protocole : " + protocole); + } else { + + tProxy.setURI(uriService); + tProxy.setClass(serviceclazz); + + // le proxy tProxy definit suivant le protocole + // gere maintenant tous les appels sur l'interface + // demandee (serviceclazz) + serviceimpl = (E) Proxy.newProxyInstance(serviceclazz + .getClassLoader(), + new Class[] { serviceclazz }, tProxy); + + // mise en cache + mapServiceCache.put(serviceclazz, serviceimpl); + } + } + } catch (URISyntaxException e) { + logger + .warn("URI for service '" + + serviceclazz.getCanonicalName() + + "' is invalid !", e); + return null; + } + } + + return serviceimpl; + } + + /** + * Retourne l'implementation d'un TopiaProxy en fonction du protocole de + * l'URI + * + * @param uriService + * @return l'implementation ou null si le protocol n'est pas géré + */ + private static TopiaProxy getProxyForURI(URI uriService) { + + // result + TopiaProxy tProxy = null; + + if ("rmi".equalsIgnoreCase(uriService.getScheme())) { + tProxy = new RMIProxy(); + } else if ("xml-rpc".equalsIgnoreCase(uriService.getScheme())) { + tProxy = new XMLRPCProxy(); + } else if ("soap".equalsIgnoreCase(uriService.getScheme())) { + tProxy = new SOAPProxy(); + } + + return tProxy; + } + + /** + * Ajoute un service fournit par ToPIA. + * + * @param interfaze + * l'interface du service + * @param clazz + * la classe qui permet de creer des instances de + * l'implementation du service + * @param protocoles + * les protocoles de diffusion du service + * + * @see TopiaApplicationService + */ + public static void addService( + Class interfaze, + Class clazz, + Protocole... protocoles) { + logger.debug("Adding service for '" + interfaze + "' in protocoles : " + + Arrays.toString(protocoles)); + + for (Protocole protocole : protocoles) { + mainDispatcher.addServiceClass(interfaze, clazz, protocole); + } + } + + /** + * Ajoute un service fournit par ToPIA. + * + * Celle-ci renvoie toujours la meme instance du service. + * + * @param + * un type qui etend TopiaApplicationService + * @param interfaze + * l'interface du service + * @param instance + * l'instance de l'implementation du service + * @param protocoles + * les protocoles de diffusion du service + * + * @see TopiaApplicationService + */ + public static void addService( + Class interfaze, E instance, Protocole... protocoles) { + logger.debug("Adding service for '" + interfaze + + "'(unique instance) in protocoles : " + + Arrays.toString(protocoles)); + + for (Protocole protocole : protocoles) { + mainDispatcher.addServiceInstance(interfaze, instance, protocole); + } + } +} Index: topia2/src/java/org/codelutin/topia/service/TopiaProxy.java diff -u /dev/null topia2/src/java/org/codelutin/topia/service/TopiaProxy.java:1.1 --- /dev/null Wed Apr 18 12:21:30 2007 +++ topia2/src/java/org/codelutin/topia/service/TopiaProxy.java Wed Apr 18 12:21:24 2007 @@ -0,0 +1,50 @@ +/* *##% + * 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.InvocationHandler; +import java.net.URI; + +/** + * TopiaProxy.java + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2007/04/18 12:21:24 $ By : $Author: chatellier $ + */ +public interface TopiaProxy extends InvocationHandler, TopiaApplicationService { + + /** + * Rensigne l'URI du service + * + * @param uri + * l'URI + * @see java.net.URI + */ + public void setURI(URI uri); + + /** + * Renseigne la classe geree + * + * @param clazz + * la class + */ + public void setClass(Class clazz); +}