當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。