|
Jetty example source code file (MessageImpl.java)
The Jetty MessageImpl.java source codepackage org.mortbay.cometd; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import org.mortbay.util.ajax.JSON; import dojox.cometd.Bayeux; import dojox.cometd.Message; public class MessageImpl extends HashMap<String, Object> implements Message, org.mortbay.util.ajax.JSON.Generator { MessagePool _pool; String _clientId; String _json; String _channel; String _id; Object _data; Message _associated; AtomicInteger _refs=new AtomicInteger(); /* ------------------------------------------------------------ */ public MessageImpl() { super(8); } /* ------------------------------------------------------------ */ public MessageImpl(MessagePool bayeux) { super(8); _pool=bayeux; } /* ------------------------------------------------------------ */ public void incRef() { _refs.getAndIncrement(); } /* ------------------------------------------------------------ */ public void decRef() { int r= _refs.decrementAndGet(); if (r==0 && _pool!=null) _pool.recycleMessage(this); else if (r<0) throw new IllegalStateException(); } /* ------------------------------------------------------------ */ public String getChannel() { return _channel; } /* ------------------------------------------------------------ */ public String getClientId() { if (_clientId==null) _clientId=(String)get(Bayeux.CLIENT_FIELD); return _clientId; } /* ------------------------------------------------------------ */ public String getId() { return _id; } /* ------------------------------------------------------------ */ public Object getData() { return _data; } /* ------------------------------------------------------------ */ public void addJSON(StringBuffer buffer) { buffer.append(getJSON()); } /* ------------------------------------------------------------ */ public String getJSON() { if (_json==null) { JSON json=_pool==null?JSON.getDefault():_pool.getMsgJSON(); StringBuffer buf = new StringBuffer(json.getStringBufferSize()); synchronized(buf) { json.appendMap(buf,this); _json=buf.toString(); } } return _json; } /* ------------------------------------------------------------ */ /* (non-Javadoc) * @see java.util.HashMap#clear() */ public void clear() { _json=null; _id=null; _channel=null; _clientId=null; setAssociated(null); _refs.set(0); Iterator<Map.Entry Other Jetty examples (source code examples)Here is a short list of links related to this Jetty MessageImpl.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.