Index: topia/src/java/org/codelutin/topia/persistence/TopiaPersistenceProxy.java diff -u topia/src/java/org/codelutin/topia/persistence/TopiaPersistenceProxy.java:1.22 topia/src/java/org/codelutin/topia/persistence/TopiaPersistenceProxy.java:1.23 --- topia/src/java/org/codelutin/topia/persistence/TopiaPersistenceProxy.java:1.22 Thu Nov 10 10:04:07 2005 +++ topia/src/java/org/codelutin/topia/persistence/TopiaPersistenceProxy.java Fri Nov 25 18:49:08 2005 @@ -23,9 +23,9 @@ * Created: 16 juillet 2005 23:52:35 CEST * * @author Benjamin POUSSIN -* @version $Revision: 1.22 $ +* @version $Revision: 1.23 $ * -* Last update: $Date: 2005/11/10 10:04:07 $ +* Last update: $Date: 2005/11/25 18:49:08 $ * by : $Author: thimel $ */ @@ -447,12 +447,19 @@ Method m = null; TopiaEntityOperation op = null; try{ + //On récupère l'implantation d'operation si elle existe op = ph.getContext().getEntityOperation(interfacez); - Class [] argsType = (Class[])ArrayUtil.concat(new Class[]{interfacez}, - method.getParameterTypes()); - m = MethodUtils.getAccessibleMethod(op.getClass(), methodName, - argsType); - }catch(TopiaNotFoundException eee){ + + Class[] argClasses = (Class[])ArrayUtil.concat( + new Class[] {interfacez}, + method.getParameterTypes()); + m = MethodUtils.getAccessibleMethod( + op.getClass(), methodName, argClasses); + }catch(TopiaNotFoundException tnfe){ + if (log.isTraceEnabled()) { +// log.trace("L'implantation des operations associees a \"" + +// interfacez.getName() + "\" n'a pas ete trouvee"); + } } if(m == null && MethodInfoHelper.type(method) == MethodType.OPERATION){ @@ -468,15 +475,15 @@ // d'avoir une autre methode d'acces au champs par exemple avoir une // deuxieme methode commencant par _ pour indiquer que c la methode // d'acces au champs qui ne doit pas etre surchargée et qui pourrait - // etre utilisée dans la methode surchargé d'acces au champs pour - // recuperer la valeur du champs. - if(m != null && MethodInfoHelper.type(method) == MethodType.FIELD_ACCESSOR){ - log.warn("Attribute access method overwriten in Operation implementation class is not allow."); + // etre utilisee dans la methode surchargee d'acces aux champs pour + // recuperer la valeur du champ. + if(m != null && MethodInfoHelper.type(method) == MethodType.FIELD_ACCESSOR && methodName.startsWith("_")){ + log.warn("Overwritting '_' attribute access method in Operation implementation class is not allowed. Skipping method call."); } else if (m != null) { // on a retrouvé la méthode sur les operations, // on peut donc l'appeler - Object [] argsObject = ArrayUtil.concat(new Object[]{proxy}, args); - return m.invoke(op, argsObject); + args = ArrayUtil.concat(new Object[] {entity}, args); + return m.invoke(op, args); } else { // La methode n'a pas ete trouvee sur la classe implantant // les methodes de l'objet, c peut-etre une methode que l'on @@ -491,6 +498,14 @@ && method.getParameterTypes().length == 1){ return equals(entity, method, args[0]); }else if(MethodInfoHelper.type(method) == MethodType.FIELD_ACCESSOR){ + if (!methodName.startsWith("_")) { + //On substitue la méthode appelée par son équivalent commencant par '_' + methodName = "_" + methodName; + method = MethodUtils.getAccessibleMethod( + method.getDeclaringClass(), + methodName, + method.getParameterTypes()); + } // la méthode est une méthode d'acces aux attributs String fieldName = MethodInfoHelper.field(method); Class fieldType = MethodInfoHelper.fieldType(method); @@ -504,7 +519,7 @@ // // FIXME 20050921 bpoussin: non plus maintenant avec les // JDBCTransformer et le LazyAttibute. donc - // quand ca marche refactore le code pour peut-etre + // quand ca marche refactore le codemethodName pour peut-etre // faire la meme chose qu'un champs normal if(MethodInfoHelper.isFieldModifier(method)){ // methode pour modifier le champs @@ -582,17 +597,17 @@ } } else { if(MethodInfoHelper.isFieldModifier(method)){ - if(methodName.startsWith("add")){ + if(methodName.startsWith("_add")){ addFieldAssociationCardinalityN( assoPS, partyA, thisField, otherField, entity, (TopiaEntity)args[0], otherCardinality[1] == 1); return null; - } else if(methodName.startsWith("remove")){ + } else if(methodName.startsWith("_remove")){ removeFieldAssociationCardinalityN( assoPS, thisField, otherField, entity, (TopiaEntity)args[0]); return null; - } else if(methodName.startsWith("clear")){ + } else if(methodName.startsWith("_clear")){ clearFieldAssociationCardinalityN( assoPS, thisField, otherField, entity); return null; @@ -621,14 +636,11 @@ return result; } } - } else { - System.err.println(MethodInfoHelper.type(method)); } } - log.fatal("Can't find called method: " + method + " methodName: " + method.getName() + " methodArgType: " + Arrays.toString(method.getParameterTypes())); + log.fatal("Can't find called method: " + method + " methodName: " + method.getName() + " methodArgType: " + Arrays.toString(method.getParameterTypes()) + " methodType: " + MethodInfoHelper.type(method)); // FIXME gérer les appels de méthode spécifique d'attribut (add, remove, ...) throw new UnsupportedOperationException("This proxy doesn't support this operation: " + method); } } // TopiaPersistenceProxy -