From: Frederic D. <de...@us...> - 2004-04-30 07:19:46
|
Update of /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/boony In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1703/src/org/fudaa/dodico/boony Modified Files: BoonyDeserializerHandlerOld.java BoonyLib.java BoonyBase64.java BoonyDeserializerHandler.java BoonyXmlSerializer.java Added Files: BoonyInterface.java Removed Files: ServeurUsine.java DUsine.java.cpy Log Message: Changement des classes OLB en Olb Reintegration du package usine --- DUsine.java.cpy DELETED --- Index: BoonyBase64.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/boony/BoonyBase64.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BoonyBase64.java 27 Apr 2004 15:57:55 -0000 1.1 --- BoonyBase64.java 30 Apr 2004 07:18:33 -0000 1.2 *************** *** 27,32 **** import java.io.OutputStream; import java.io.UnsupportedEncodingException; - import java.util.Locale; - import java.util.ResourceBundle; /** --- 27,30 ---- --- NEW FILE: BoonyInterface.java --- /** * @file BoonyInterface.java * @creation 28 avr. 2004 * @modification $Date: 2004/04/30 07:18:33 $ * @license GNU General Public License 2 * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne * @mail fud...@li... */ package org.fudaa.dodico.boony; import org.omg.PortableServer.POA; /** * @author Fred Deniger * @version $Id: BoonyInterface.java,v 1.1 2004/04/30 07:18:33 deniger Exp $ */ public interface BoonyInterface { public POA getPOA(); public boolean isAllLocal(); public org.omg.CORBA.Object buildStubFromDelegate(Object _delegate); } --- ServeurUsine.java DELETED --- Index: BoonyDeserializerHandlerOld.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/boony/BoonyDeserializerHandlerOld.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BoonyDeserializerHandlerOld.java 27 Apr 2004 15:57:55 -0000 1.1 --- BoonyDeserializerHandlerOld.java 30 Apr 2004 07:18:32 -0000 1.2 *************** *** 26,30 **** import org.fudaa.dodico.boony.BoonyXmlDeserializer.CorbaEnum; - import org.fudaa.dodico.objet.CDodico; class BoonyDeserializerHandlerOld extends MstHandlerBase implements --- 26,29 ---- *************** *** 176,180 **** } r = (Servant) d.tieConstructor_.newInstance(new Object[] { null, ! (BoonyLib.isAllLocal() ? null : CDodico.getPOA())}); } catch (Exception _e) { --- 175,179 ---- } r = (Servant) d.tieConstructor_.newInstance(new Object[] { null, ! (BoonyLib.isAllLocal() ? null : BoonyLib.getPOA())}); } catch (Exception _e) { Index: BoonyXmlSerializer.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/boony/BoonyXmlSerializer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BoonyXmlSerializer.java 27 Apr 2004 15:57:55 -0000 1.1 --- BoonyXmlSerializer.java 30 Apr 2004 07:18:33 -0000 1.2 *************** *** 40,44 **** import com.memoire.yapod.YapodSerializer; - import org.fudaa.dodico.corba.hydraulique1d.IEtude1d; import org.fudaa.dodico.corba.hydraulique1d.IEtude1dHelper; --- 40,43 ---- *************** *** 46,49 **** --- 45,49 ---- import org.fudaa.dodico.objet.CDodico; import org.fudaa.dodico.objet.DObjet; + import org.fudaa.dodico.objet.UsineLib; public class BoonyXmlSerializer implements YapodSerializer { *************** *** 91,95 **** private DObjet getObjectToDo(org.omg.CORBA.Object _ref) { ! if (BoonyLib.isAllLocal()) { return (DObjet) _ref; } --- 91,95 ---- private DObjet getObjectToDo(org.omg.CORBA.Object _ref) { ! if (UsineLib.isAllLocal()) { return (DObjet) _ref; } *************** *** 190,194 **** try { String f = args[1]; ! BoonyLib.setAllLocal(true); DataInputStream FluxLu = new DataInputStream( new BufferedInputStream(new FileInputStream(f))); --- 190,194 ---- try { String f = args[1]; ! UsineLib.setAllLocal(true); DataInputStream FluxLu = new DataInputStream( new BufferedInputStream(new FileInputStream(f))); *************** *** 213,217 **** try { ! BoonyLib.setAllLocal(true); /* * IEtude1d e = BoonyLib.findUsine().creeHydraulique1dEtude1d(); e.description("toto"); --- 213,217 ---- try { ! UsineLib.setAllLocal(true); /* * IEtude1d e = BoonyLib.findUsine().creeHydraulique1dEtude1d(); e.description("toto"); Index: BoonyDeserializerHandler.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/boony/BoonyDeserializerHandler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BoonyDeserializerHandler.java 27 Apr 2004 15:57:55 -0000 1.1 --- BoonyDeserializerHandler.java 30 Apr 2004 07:18:33 -0000 1.2 *************** *** 27,31 **** import org.fudaa.dodico.boony.BoonyXmlDeserializer.CorbaEnum; - import org.fudaa.dodico.objet.DObjet; class BoonyDeserializerHandler implements ContentHandler,BoonyDeserializerHandlerInterface { --- 27,30 ---- *************** *** 89,93 **** } ! protected void saveCorbaObject(DObjet _dobjet) { if (!isCorba_) return; if (dobjetIObjet == null) { --- 88,92 ---- } ! protected void saveCorbaObject(Object _dobjet) { if (!isCorba_) return; if (dobjetIObjet == null) { *************** *** 172,176 **** obj.put(id, o); if (isCorba_ && "iobject".equals(_element)) { ! saveCorbaObject((DObjet) o); } } --- 171,175 ---- obj.put(id, o); if (isCorba_ && "iobject".equals(_element)) { ! saveCorbaObject(o); } } Index: BoonyLib.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/boony/BoonyLib.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BoonyLib.java 27 Apr 2004 16:34:27 -0000 1.2 --- BoonyLib.java 30 Apr 2004 07:18:33 -0000 1.3 *************** *** 1,128 **** ! /* ! * @file UsineHelper.java @creation 24 juin 2003 @modification $Date$ @license ! * GNU General Public License 2 @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne @mail ! * de...@fu... */ package org.fudaa.dodico.boony; - import java.lang.reflect.Constructor; import java.lang.reflect.Field; - import java.lang.reflect.Method; ! import org.omg.CORBA.portable.ObjectImpl; import org.omg.PortableServer.Servant; ! import org.fudaa.dodico.corba.boony.IUsine; ! import org.fudaa.dodico.corba.boony.IUsineHelper; ! import org.fudaa.dodico.corba.boony.IUsine_Tie; ! import org.fudaa.dodico.corba.objet.IService; ! import org.fudaa.dodico.corba.objet.IServiceHelper; ! import org.fudaa.dodico.objet.CDodico; ! import org.fudaa.dodico.objet.DObjet; /** ! * @author deniger * @version $Id$ */ public class BoonyLib { ! ! private static String defpackage = "org.fudaa.dodico"; ! private static String corbapackage = "org.fudaa.dodico.corba"; ! ! /** ! * Reference l'usine locale utilisee. Est nulle, si la connexion se fait a distance. ! */ ! private static IUsine usine_ = null; ! ! private static boolean isUsineTypeSet_; ! //true si tous les objets seront locaux : plus rapide ! private static boolean isAllLocal_; /** * */ ! private BoonyLib() { super(); } ! ! public static void setAllLocal(boolean _b) { ! if (isUsineTypeSet_) { ! new Throwable("Le fonctionnement de l'usine est deja etabli").printStackTrace(); ! } ! isUsineTypeSet_ = true; ! isAllLocal_ = _b; ! } ! ! /** ! * Permet de savoir si l'objet a ete cree dans la jvm courante. ! * ! * @param _object instance de ObjectImpl ! * @return true si l'objet a été crée dans la jvm courante ! */ ! public static boolean isObjectInLocalJvm(ObjectImpl _object) { ! return _object._is_local(); ! } ! ! ! ! public static boolean isAllLocal() { ! return isAllLocal_; ! } ! ! static IUsine creeUsine() { ! if (usine_ != null) return usine_; ! if (isAllLocal_){ ! usine_ = new DUsine(true); ! ((DUsine)usine_).setTie(usine_); ! } ! else { ! try { ! usine_ = IUsineHelper.narrow(CDodico.getPOA().servant_to_reference( ! new IUsine_Tie(new DUsine(false), CDodico.getPOA()))); ! } ! catch (Exception e) { ! e.printStackTrace(); ! } ! } ! return usine_; ! } ! ! public static boolean isUsinePolicySet() { ! return isUsineTypeSet_; ! } ! ! public static IService createService(Class _dobjectclass) { ! ! DObjet o = null; ! try { ! Constructor x = _dobjectclass.getDeclaredConstructor(new Class[] {}); ! o = (DObjet) x.newInstance(new Object[] {}); ! } ! catch (Exception _e) { ! _e.printStackTrace(); ! } ! if (o == null) return null; ! else return IServiceHelper.narrow(buildStubFromDObject(o)); ! } ! ! public final static IUsine findUsine(int _time) { ! if (usine_ != null) return usine_; ! if (isAllLocal_) { ! if (usine_ == null) usine_ = creeUsine(); ! return usine_; ! } ! ! int n = 0; ! IUsine u = null; ! while (n < 3 && u == null) { ! u = IUsineHelper.narrow(CDodico.findServerByInterface("::usine::IUsine", _time)); ! n++; ! } ! usine_ = u; ! return usine_; ! } ! ! public static DObjet getDelegate(Servant _s) { ! DObjet r = null; try { Field[] fs = _s.getClass().getDeclaredFields(); --- 1,34 ---- ! /** ! * @file BoonyLib.java ! * @creation 28 avr. 2004 ! * @modification $Date$ ! * @license GNU General Public License 2 ! * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne ! * @mail fud...@li... */ package org.fudaa.dodico.boony; import java.lang.reflect.Field; ! import org.omg.PortableServer.POA; import org.omg.PortableServer.Servant; ! /** ! * @author Fred Deniger * @version $Id$ */ public class BoonyLib { ! private static BoonyInterface boonyImpl_; /** * */ ! public BoonyLib() { super(); } ! public static Object getDelegate(Servant _s) { ! Object r = null; try { Field[] fs = _s.getClass().getDeclaredFields(); *************** *** 135,139 **** } f.setAccessible(true); ! r = (DObjet) f.get(_s); } catch (SecurityException _e) { --- 41,45 ---- } f.setAccessible(true); ! r = f.get(_s); } catch (SecurityException _e) { *************** *** 145,224 **** return r; } - ! ! ! ! static Object buildStubFromTie(Servant _tieObject, String _tieClass) { ! if (isAllLocal_) { return getDelegate(_tieObject); } ! ! try { ! org.omg.CORBA.Object rf = CDodico.getPOA().servant_to_reference(_tieObject); ! int idx = _tieClass.lastIndexOf('.') + 1; ! String corbaObjPackage = _tieClass.substring(0, idx); ! String tieName = _tieClass.substring(idx); ! Class helper = Class.forName(corbaObjPackage + tieName.substring(0, tieName.length() - 4) ! + "Helper"); ! Method msNarrow = helper.getMethod("narrow", new Class[] { org.omg.CORBA.Object.class}); ! return msNarrow.invoke(null, new Object[] { rf}); ! } ! catch (Exception _e1) { ! _e1.printStackTrace(); } ! return null; ! } ! ! static org.omg.CORBA.Object buildStubFromDObject(DObjet _dobjet) { ! if (isAllLocal_) { ! //DEBUG A virer ! _dobjet.setTie(_dobjet); ! return _dobjet; ! } ! Servant r = null; ! Class c = _dobjet.getClass(); ! //totalname=org.fudaa.dodico.ef.DNoeud ! String totalname = c.getName(); ! //name=DNoeud ! String name = totalname.substring(totalname.lastIndexOf('.') + 1); ! // tie=INoeud_Tie ! String tie = "I" + name.substring(1) + "_Tie"; ! String packageName = totalname.substring(0, totalname.lastIndexOf('.') + 1); ! ! String corbaObjPackage = corbapackage + packageName.substring(defpackage.length()); ! ! try { ! Class tieClass = Class.forName(corbaObjPackage + tie); ! Constructor[] cs = tieClass.getConstructors(); ! Constructor csfinal = null; ! for (int i = cs.length - 1; i >= 0; i--) { ! if (cs[i].getParameterTypes().length == 2) { ! csfinal = cs[i]; ! break; ! } ! } ! r = (Servant) csfinal.newInstance(new Object[] { _dobjet, CDodico.getPOA()}); ! } ! catch (Exception _e) { ! _e.printStackTrace(); ! return null; ! } ! try { ! org.omg.CORBA.Object rf = CDodico.getPOA().servant_to_reference(r); ! Class helper = Class.forName(corbaObjPackage + "I" + name.substring(1) + "Helper"); ! Method msNarrow = helper.getMethod("narrow", new Class[] { org.omg.CORBA.Object.class}); ! return (org.omg.CORBA.Object) msNarrow.invoke(null, new Object[] { rf}); ! } ! catch (Exception _e1) { ! _e1.printStackTrace(); ! } ! return null; } ! ! public final static IUsine findUsine() { ! return findUsine(2000); } ! ! ! } \ No newline at end of file --- 51,76 ---- return r; } ! public static void setBoonyImpl(BoonyInterface _impl){ ! if(boonyImpl_!=null){ ! throw new IllegalAccessError("impl already set"); } ! boonyImpl_=_impl; } ! ! public static BoonyInterface getBoonyImpl(){ ! return boonyImpl_; } ! ! public static POA getPOA(){ ! return boonyImpl_.getPOA(); ! } ! ! public static boolean isAllLocal(){ ! return boonyImpl_.isAllLocal(); } ! static org.omg.CORBA.Object buildStubFromDObject(Object _dobjet) { ! return boonyImpl_.buildStubFromDelegate(_dobjet); ! } ! } |