当前位置: 首页>>代码示例>>Java>>正文


Java Util.objectFromStream方法代码示例

本文整理汇总了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);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:27,代码来源:PartitionedHashMap.java

示例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);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:18,代码来源:StateTransferTest.java

示例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();
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:9,代码来源:GraphPanel.java

示例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);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:12,代码来源:StateTransferTest2.java

示例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);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:9,代码来源:ReconciliationTest.java

示例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);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:10,代码来源:ConcurrentStartupTest.java

示例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);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:13,代码来源:SimpleChat.java

示例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);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:6,代码来源:ReplicatedTree.java


注:本文中的org.jgroups.util.Util.objectFromStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。