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


Java Externalizable.readExternal方法代码示例

本文整理汇总了Java中java.io.Externalizable.readExternal方法的典型用法代码示例。如果您正苦于以下问题:Java Externalizable.readExternal方法的具体用法?Java Externalizable.readExternal怎么用?Java Externalizable.readExternal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.Externalizable的用法示例。


在下文中一共展示了Externalizable.readExternal方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCommandObject

import java.io.Externalizable; //导入方法依赖的package包/类
/**
 * Returns the instantiated bean.
 * If the bean implements <code>CommandObject</code>, its
 * <code>setCommandContext</code> method will be called.
 * @param dh the data handler describing the command data
 * @param loader the class loader used to instantiate the bean
 */
public Object getCommandObject(DataHandler dh, ClassLoader loader)
  throws IOException, ClassNotFoundException
{
  Object object = Beans.instantiate(loader, className);
  if (object != null)
    {
      if (object instanceof CommandObject)
        {
          CommandObject command = (CommandObject)object;
          command.setCommandContext(verb, dh);
        }
      else if (dh != null && (object instanceof Externalizable))
        {
          InputStream in = dh.getInputStream();
          if (in != null)
            {
              Externalizable externalizable = (Externalizable)object;
              externalizable.readExternal(new ObjectInputStream(in));
            }
        }
    }
  return object;
}
 
开发者ID:vilie,项目名称:javify,代码行数:31,代码来源:CommandInfo.java

示例2: readMessageHeader

import java.io.Externalizable; //导入方法依赖的package包/类
private MessageHeader readMessageHeader(final SocketChannel channel, final ObjectInputStream objectInput)
    throws IOException, ClassNotFoundException {
  final INode to;
  if (objectInput.read() == 1) {
    to = null;
  } else {
    if (objectInput.read() == 1) {
      // this may be null if we
      // have not yet fully joined the network
      to = nioSocket.getLocalNode();
    } else {
      to = new Node();
      ((Node) to).readExternal(objectInput);
    }
  }
  final INode from;
  final int readMark = objectInput.read();
  if (readMark == 1) {
    from = nioSocket.getRemoteNode(channel);
  } else if (readMark == 2) {
    from = null;
  } else {
    from = new Node();
    ((Node) from).readExternal(objectInput);
  }
  final Serializable message;
  final byte type = (byte) objectInput.read();
  if (type != Byte.MAX_VALUE) {
    final Externalizable template = getTemplate(type);
    template.readExternal(objectInput);
    message = template;
  } else {
    message = (Serializable) objectInput.readObject();
  }
  return new MessageHeader(to, from, message);
}
 
开发者ID:triplea-game,项目名称:triplea,代码行数:37,代码来源:Decoder.java

示例3: externalize

import java.io.Externalizable; //导入方法依赖的package包/类
private void externalize(final Externalizable original, final Externalizable copy) throws IOException, ClassNotFoundException {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream out = new ObjectOutputStream(baos);

    original.writeExternal(out);
    out.close();

    final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    final ObjectInputStream in = new ObjectInputStream(bais);

    copy.readExternal(in);
}
 
开发者ID:apache,项目名称:tomee,代码行数:13,代码来源:JndiRequestTest.java

示例4: read

import java.io.Externalizable; //导入方法依赖的package包/类
@Override
public Externalizable read(Kryo kryo, Input input, Class<Externalizable> type) {
    try {
        Externalizable e = type.newInstance();
        KryoObjectInput koi = new KryoObjectInput(input,kryo);
        e.readExternal(koi);
        return e;
    } catch (IOException | ClassNotFoundException | IllegalAccessException | InstantiationException e1) {
        throw new RuntimeException(e1);
    }
}
 
开发者ID:splicemachine,项目名称:spliceengine,代码行数:12,代码来源:ExternalizableSerializer.java

示例5: readObject

import java.io.Externalizable; //导入方法依赖的package包/类
public static void readObject(@Nonnull final InputStream is, @Nonnull final Externalizable dst)
        throws IOException, ClassNotFoundException {
    ObjectInputStream ois = new ObjectInputStream(is);
    dst.readExternal(ois);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:6,代码来源:ObjectUtils.java


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