本文整理汇总了Java中org.jgroups.util.Util.objectFromStream方法的典型用法代码示例。如果您正苦于以下问题:Java Util.objectFromStream方法的具体用法?Java Util.objectFromStream怎么用?Java Util.objectFromStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jgroups.util.Util
的用法示例。
在下文中一共展示了Util.objectFromStream方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: objectFromBuffer
import org.jgroups.util.Util; //导入方法依赖的package包/类
public Object objectFromBuffer(byte[] buf, int offset, int length) throws Exception {
if(buf == null)
return null;
DataInputStream in=new DataInputStream(new ByteArrayInputStream(buf));
byte type=in.readByte();
if(type == NULL)
return null;
if(type == METHOD_CALL) {
short id=in.readShort();
short len=in.readShort();
Object[] args=len > 0? new Object[len] : null;
if(args != null) {
for(int i=0; i < args.length; i++)
args[i]=Util.objectFromStream(in);
}
return new MethodCall(id, args);
}
else if(type == VALUE) {
long expiration_time=in.readLong();
Object obj=Util.objectFromStream(in);
return new Cache.Value(obj, expiration_time);
}
else
return Util.objectFromStream(in);
}
示例2: setState
import org.jgroups.util.Util; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void setState(InputStream istream) throws Exception {
Map<String,List<Long>> tmp=(Map<String,List<Long>>)Util.objectFromStream(new DataInputStream(istream));
synchronized(map) {
map.clear();
map.putAll(tmp);
count.clear();
long time=System.currentTimeMillis() - start_time;
StringBuilder sb=new StringBuilder("\n++++++++++++++++++++++++++++++++++++++\n");
sb.append(channel.getAddress() + " <--- received state (in " + time + " ms), map has "
+ getSize(map) + " elements:\n");
for(Map.Entry<String,List<Long>> entry: map.entrySet())
sb.append(entry.getKey() + ": " + print(entry.getValue()) + "\n");
sb.append("++++++++++++++++++++++++++++++++++++++");
System.out.println(sb);
}
}
示例3: setState
import org.jgroups.util.Util; //导入方法依赖的package包/类
public void setState(InputStream input) throws Exception {
java.util.List<Node> copy=(List<Node>)Util.objectFromStream(new DataInputStream(input));
synchronized(nodes) {
nodes.clear();
nodes.addAll(copy);
}
repaint();
}
示例4: setState
import org.jgroups.util.Util; //导入方法依赖的package包/类
public void setState(InputStream istream) throws Exception {
if(set_error)
throw new RuntimeException("[dummy failure] state could not be set");
DataInputStream in=new DataInputStream(istream);
try {
received_state=Util.objectFromStream(in);
}
finally {
Util.close(in);
}
}
示例5: setState
import org.jgroups.util.Util; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void setState(InputStream istream) throws Exception {
Map<Object,Object> m=(Map<Object,Object>)Util.objectFromStream(new DataInputStream(istream));
synchronized(data) {
data.clear();
data.putAll(m);
}
}
示例6: setState
import org.jgroups.util.Util; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void setState(InputStream istream) throws Exception {
List<Integer> tmp=(List<Integer>)Util.objectFromStream(new DataInputStream(istream));
synchronized(state) {
state.clear();
state.addAll(tmp);
System.out.println(ch.getAddress() + " <-- state: " + state);
}
}
示例7: setState
import org.jgroups.util.Util; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void setState(InputStream input) throws Exception {
List<String> list=(List<String>)Util.objectFromStream(new DataInputStream(input));
synchronized(state) {
state.clear();
state.addAll(list);
}
System.out.println("received state (" + list.size() + " messages in chat history):");
for(String str: list) {
System.out.println(str);
}
}
示例8: setState
import org.jgroups.util.Util; //导入方法依赖的package包/类
public void setState(InputStream istream) throws Exception {
Object obj=Util.objectFromStream(new DataInputStream(istream));
root=(Node)((Node)obj).clone();
notifyAllNodesCreated(root);
}