Index: topia/src/java/org/codelutin/topia/distribution/DistributionHelper.java diff -u /dev/null topia/src/java/org/codelutin/topia/distribution/DistributionHelper.java:1.3 --- /dev/null Tue Jul 19 13:15:18 2005 +++ topia/src/java/org/codelutin/topia/distribution/DistributionHelper.java Tue Jul 19 13:15:13 2005 @@ -0,0 +1,79 @@ +/* *##% + * Copyright (C) 2002, 2003 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. + *##%*/ + +/* * + * AbstractDistributionHelper.java + * + * Created: 3 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.3 $ + * + * Mise a jour: $Date: 2005/07/19 13:15:13 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.distribution; + +import java.lang.reflect.Proxy; +import java.util.Properties; +import org.codelutin.topia.TopiaArgument; +import org.codelutin.topia.TopiaContext; +import org.codelutin.topia.TopiaException; + +public abstract class DistributionHelper { // DistributionHelper + + /** + * Le context a partir duquel on a recupere ce AbstractPersistenceHelper + */ + protected TopiaContext context = null; + + /** + * Les proprietes pour ce AbstractPersistenceHelper + */ + protected Properties properties = null; + + public TopiaContext getContext(){ + return context; + } + + public Properties getProperties(){ + return properties; + } + + public DistributionHelper(TopiaContext context, Properties properties) { + this.context = context; + this.properties = properties; + } + + public Object createProxy(Class interfacez){ + Object result = Proxy.newProxyInstance(TopiaDistributionProxy.class.getClassLoader(), + new Class[] { interfacez }, new TopiaDistributionProxy(this, interfacez)); + return result; + + } + + public Object call(Class service, String methodName, TopiaArgument args) throws TopiaException{ + return call(service, methodName, args.getArgs().toArray()); + } + + public abstract Object call(Class service, String methodName, Object [] args) throws TopiaException; + +} // DistributionHelper + Index: topia/src/java/org/codelutin/topia/distribution/JndiDistributionHelper.java diff -u topia/src/java/org/codelutin/topia/distribution/JndiDistributionHelper.java:1.2 topia/src/java/org/codelutin/topia/distribution/JndiDistributionHelper.java:1.3 --- topia/src/java/org/codelutin/topia/distribution/JndiDistributionHelper.java:1.2 Sun Aug 1 14:52:32 2004 +++ topia/src/java/org/codelutin/topia/distribution/JndiDistributionHelper.java Tue Jul 19 13:15:13 2005 @@ -1,5 +1,5 @@ /* *##% - * Copyright (C) 2002, 2003, 2004 + * Copyright (C) 2002, 2003, 2004 * Code Lutin, Cédric Pineau, Benjamin Poussin * * This program is free software; you can redistribute it and/or @@ -23,10 +23,10 @@ * Created: Jul 30, 2004 * * @author Cédric Pineau - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * - * Last update : $Date: 2004/08/01 14:52:32 $ - * by : $Author: pineau $ + * Last update : $Date: 2005/07/19 13:15:13 $ + * by : $Author: bpoussin $ */ package org.codelutin.topia.distribution; @@ -39,7 +39,7 @@ import org.codelutin.topia.TopiaException; /** - * + * */ public class JndiDistributionHelper extends AbstractDistributionHelper { @@ -51,7 +51,7 @@ super(context, properties); } - public Object call(Class service, String methodName, TopiaArgument args) throws TopiaException { + public Object call(Class service, String methodName, Object [] args) throws TopiaException { // Appel du service sur un EJB distant return null; // Object serviceImpl = getContext().getService(service, true); @@ -63,5 +63,5 @@ // } } - + } Index: topia/src/java/org/codelutin/topia/distribution/TopiaDistributionProxy.java diff -u /dev/null topia/src/java/org/codelutin/topia/distribution/TopiaDistributionProxy.java:1.1 --- /dev/null Tue Jul 19 13:15:18 2005 +++ topia/src/java/org/codelutin/topia/distribution/TopiaDistributionProxy.java Tue Jul 19 13:15:13 2005 @@ -0,0 +1,61 @@ +/* *##% + * Copyright (C) 2005 + * Code Lutin, Cédric Pineau, Benjamin Poussin + * + * 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. + *##%*/ + +/* * + * TopiaDistributionProxy.java + * + * Created: 16 juillet 2005 13:12:37 CEST + * + * @author Benjamin POUSSIN + * @version $Revision: 1.1 $ + * + * Last update: $Date: 2005/07/19 13:15:13 $ + * by : $Author: bpoussin $ + */ + +package org.codelutin.topia.distribution; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.codelutin.topia.TopiaArgument; + +public class TopiaDistributionProxy implements InvocationHandler { // TopiaDistributionProxy + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Logger log = Logger.getLogger("org.codelutin.topia.distribution.TopiaDistributionProxy"); + + protected DistributionHelper dh = null; + protected Class interfacez = null; + + public TopiaDistributionProxy(DistributionHelper dh, Class interfacez){ + this.dh = dh; + this.interfacez = interfacez; + } + + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + String methodName = method.getName(); + Object result = dh.call(dh.getContext().getTransaction(), interfacez, + methodName, args); + return result; + } + +} // TopiaDistributionProxy +