Package org.eclipse.jetty.util.ajax.JSON

Examples of org.eclipse.jetty.util.ajax.JSON.Convertor


    _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());
View Full Code Here


   
    /* ------------------------------------------------------------ */
    public void toJSON(Object obj, Output out)
    {
        String clsName=obj.getClass().getName();
        Convertor convertor=_json.getConvertorFor(clsName);
        if (convertor==null)
        {
            try
            {
                Class cls=Loader.loadClass(JSON.class,clsName);
                convertor=new JSONPojoConvertor(cls,_fromJson);
                _json.addConvertorFor(clsName, convertor);
             }
            catch (ClassNotFoundException e)
            {
                JSON.LOG.warn(e);
            }
        }
        if (convertor!=null)
        {
            convertor.toJSON(obj, out);
        }
    }
View Full Code Here

    {
        Map map=object;
        String clsName=(String)map.get("class");
        if (clsName!=null)
        {
            Convertor convertor=_json.getConvertorFor(clsName);
            if (convertor==null)
            {
                try
                {
                    Class cls=Loader.loadClass(JSON.class,clsName);
                    convertor=new JSONPojoConvertor(cls,_fromJson);
                    _json.addConvertorFor(clsName, convertor);
                }
                catch (ClassNotFoundException e)
                {
                    JSON.LOG.warn(e);
                }
            }
            if (convertor!=null)
            {
                return convertor.fromJSON(object);
            }
        }
        return map;
    }
View Full Code Here

   
    /* ------------------------------------------------------------ */
    public void toJSON(Object obj, Output out)
    {
        String clsName=obj.getClass().getName();
        Convertor convertor=_json.getConvertorFor(clsName);
        if (convertor==null)
        {
            try
            {
                Class cls=Loader.loadClass(JSON.class,clsName);
                convertor=new JSONPojoConvertor(cls,_fromJson);
                _json.addConvertorFor(clsName, convertor);
             }
            catch (ClassNotFoundException e)
            {
                JSON.LOG.warn(e);
            }
        }
        if (convertor!=null)
        {
            convertor.toJSON(obj, out);
        }
    }
View Full Code Here

    {
        Map map=object;
        String clsName=(String)map.get("class");
        if (clsName!=null)
        {
            Convertor convertor=_json.getConvertorFor(clsName);
            if (convertor==null)
            {
                try
                {
                    Class cls=Loader.loadClass(JSON.class,clsName);
                    convertor=new JSONPojoConvertor(cls,_fromJson);
                    _json.addConvertorFor(clsName, convertor);
                }
                catch (ClassNotFoundException e)
                {
                    JSON.LOG.warn(e);
                }
            }
            if (convertor!=null)
            {
                return convertor.fromJSON(object);
            }
        }
        return map;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.util.ajax.JSON.Convertor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.