http://issues.jabsorb.org/show_bug.cgi?id=71

           Summary: Bean methods overloading problem
           Product: jabsorb
           Version: 1.3
               URL: http://itx.ru
            Status: NEW
          Severity: defect
          Priority: medium
         Component: serializer
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


Version 1.3.1
I found a problem with bean methods overloading. For example I have:
        1) Class  User{
                Integer Id;
                String  Name;
                Date OpenDate;
                // .....
                // geters and setter here
                // .....
           }
        2) Class Departament{
                Integer Id;
                String  Name;
                Date OpenDate;
                // .....
                // geters and setter here
                // .....
           }
        3) Class OperationalJobs {
                List getBy(User user) {
                        List rez=new ArrayList();
                        // .....
                        return rez;
                }
                List getBy(Department department) {
                        List rez=new ArrayList();
                        // .....
                        return rez;
                }
            }

When you call the method getBy() on the client side (JS code):
        dep = {className: 'Departament'};
        dep.name="Dmitry";
        dep.id=100;
        rez = jsonrpc.OperationalJobs.getBy(dep);
But in fact, get method "List getBy(User user)" will be invoked!

The reason is that in the method tryUnmarshall class JSONSerializer method
arguments are compared by content, rather than by type.My ugly solution
following:
diff ~/work/java/ws-other/jabsorb-1.3.1/src/org/jabsorb/JSONSerializer.java
jabsorb-1.3.1/src/org/jabsorb/JSONSerializer.java 
575,578c575
<     // Exclude arguments similar by content but different class
<     boolean eq = clazz != null && json instanceof JSONObject
<     && ((JSONObject) json).has("javaClass")
<     && clazz.equals(getClassFromHint(json));
---
> 
583d579
<     
609c605
<     Serializer s = getSerializer(clazz,  json.getClass());
---
>     Serializer s = getSerializer(clazz, json.getClass());
612,613c608
<         // Exclude arguments similar by content but different class
<       return new ObjectMatch(s.tryUnmarshall(state, clazz,
json).getMismatch()+(eq?0:1));
---
>       return s.tryUnmarshall(state, clazz, json);


-- 
Configure bugmail: http://issues.jabsorb.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
You are the assignee for the bug.

_______________________________________________
Jabsorb-dev mailing list
[email protected]
http://lists.jabsorb.org/mailman/listinfo/jabsorb-dev

Reply via email to