[Json-rpc-java] CallableReferences
Cosio, Dan
dcosio at opsecsecurity.com
Mon Jul 30 20:17:18 SGT 2007
What the servlet recieves in request:
{"id": 2, "method": "EbayService.runCSReport", "params": ["{ \"javaClass\":\"com.opsec.gnetadmin.dto.ebayadmin.CSReportBean\",\"timeFrame\":\"All\"}"]}
method resolution in JSONBridge
public java.util.List com.opsec.gnetadmin.service.EbayAdminService.runCSReport(com.opsec.gnetadmin.dto.ebayadmin.CSReportBean)
In the JSONSerializer
public Object unmarshall(SerializerState state, Class clazz, Object json)
throws UnmarshallException
{
/* If we have a JSON object class hint that is a sub class of the
signature 'clazz', then override 'clazz' with the hint class. */
if(clazz != null &&
json instanceof JSONObject && <<<<<<<<<<<<<<<<<<<<<<<<<<<<Fails on this test From my debugger json={ "javaClass":"com.opsec.gnetadmin.dto.ebayadmin.CSReportBean","timeFrame":"All"}
((JSONObject)json).has("javaClass") &&
clazz.isAssignableFrom(getClassFromHint(json)))
clazz = getClassFromHint(json);
The above block doesn't return true because "json instanceof JSONObject" is false.. So, does my bean have to extend a JSONObject?
This is my bean
-----------------------------------------------
package com.opsec.gnetadmin.dto;
import java.io.Serializable;
public class CSReportBean implements Serializable
{
private String timeFrame;
public String getTimeFrame()
{
return timeFrame;
}
public void setTimeFrame(String timeFrame)
{
this.timeFrame = timeFrame;
}
}
Dan
-----Original Message-----
From: json-rpc-java-bounces at oss.metaparadigm.com on behalf of Maximiliano Fierro
Sent: Sun 7/29/2007 12:59 PM
To: json-rpc-java at oss.metaparadigm.com
Subject: [Json-rpc-java] CallableReferences
Guys, how are you?
This mail is intended to contact you about the CallableReferences and how to pass them to a method declared in a bridge. I have made some changes in order to get access to an object regitered as remote. In my case I have made some test and by now I don't get any troubbles and all is working ok. This are my changes:
In JSONRPCBridge:
first I must to create a new method for lookupObject in order to get an Object in objectMap by the objectKey:
//Added by elmasse
public Object lookupObject(Integer key)
throws Exception
{
synchronized (objectMap) {
ObjectInstance oi = (ObjectInstance)objectMap.get(key);
if(oi != null) return oi.o;
}
return null;
}
In ReferenceSerializer:
allow to unmarshall to get an Object previously register as CallableReference
public Object unmarshall(SerializerState state, Class clazz, Object o)
throws UnmarshallException
{
JSONObject jso = (JSONObject)o;
Object ref = null;
String json_type = jso.getString("JSONRPCType");
int object_id = jso.getInt("objectID");
if(json_type != null && json_type.equals("Reference")) {
synchronized (bridge.referenceMap) {
ref = bridge.referenceMap.get(new Integer(object_id));
}
}//Added by elmasse
else if(json_type != null && json_type.equals("CallableReference")){
try {
ref = bridge.lookupObject(new Integer(object_id));
} catch (Exception e) {
throw new UnmarshallException("Error while unmarshall CallableReference");
}
}
return ref;
}
I think that's all!
I'll be waiting for comments!!!
Regards!
elmasse!
PS: Sorry for my english, it isn't very well! :-(
____________________________________________________________________________________
¡Sé un mejor besador!
Compartí todo lo que sabés sobre besos.
http://ar.yahoo.com/promos/mejorbesador.html
_______________________________________________
Json-rpc-java mailing list
Json-rpc-java at oss.metaparadigm.com
http://oss.metaparadigm.com/mailman/listinfo/json-rpc-java
More information about the Json-rpc-java
mailing list