_presence = (PresenceEventPackage) getServletContext().getAttribute(PresenceEventPackage.class.getName());
_locationService = (LocationService) getServletContext().getAttribute(LocationService.class.getName());
_xcapPolicyManager = (XcapPolicyManager) getServletContext().getAttribute(PolicyManager.class.getName());
_watcherInfo = (WatcherInfoEventPackage) getServletContext().getAttribute(WatcherInfoEventPackage.class.getName());
JSON.getDefault().addConvertor(Resource.class, new Convertor()
{
public void toJSON(Object obj, Output out)
{
Resource resource = (Resource) obj;
out.add("uri", resource.getUri());
}
public Object fromJSON(Map object) { return null; }
});
JSON.getDefault().addConvertor(EventResource.class, new Convertor()
{
public void toJSON(Object obj, Output out)
{
EventResource resource = (EventResource) obj;
out.add("uri", resource.getUri());
out.add("subscriptions", resource.getSubscriptions());
}
public Object fromJSON(Map object) { return null; }
});
JSON.getDefault().addConvertor(Subscription.class, new Convertor()
{
public void toJSON(Object obj, Output out)
{
Subscription subscription = (Subscription) obj;
out.add("uri", subscription.getUri());
out.add("state", subscription.getState().toString());
out.add("authorized", subscription.isAuthorized());
}
public Object fromJSON(Map object) { return null; }
});
JSON.getDefault().addConvertor(Registration.class, new Convertor()
{
public void toJSON(Object obj, Output out)
{
Registration record = (Registration) obj;
out.add("aor", record.getUri());
out.add("bindings", record.getBindings());
}
public Object fromJSON(Map object) { return null; }
});
JSON.getDefault().addConvertor(Binding.class, new Convertor()
{
public void toJSON(Object obj, Output out)
{
Binding binding = (Binding) obj;
out.add("contact", binding.getContact());
out.add("expiration", new Date(binding.getExpirationTime()));
}
public Object fromJSON(Map object) { return null; }
});
JSON.getDefault().addConvertor(XcapPolicy.class, new Convertor()
{
public void toJSON(Object obj, Output out)
{
XcapPolicy policy = (XcapPolicy) obj;
out.add("Resource", policy.getResourceUri());
out.add("XcapResources", policy.getXcapResources());
}
public Object fromJSON(Map object) { return null; }
});
JSON.getDefault().addConvertor(ResourceHolder.class, new Convertor()
{
public void toJSON(Object obj, Output out)
{
ResourceHolder holder = (ResourceHolder) obj;
out.add("lock", holder.getHoldCount());