hudson.remoting.Channel.setCurrent()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中hudson.remoting.Channel.setCurrent()方法的一些代码示例,展示了Channel.setCurrent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Channel.setCurrent()方法的具体详情如下:
包路径:hudson.remoting.Channel
类名称:Channel
方法名:setCurrent

Channel.setCurrent介绍

暂无

代码示例

代码示例来源:origin: jenkinsci/remoting

/** Consider calling {@link Channel#notifyWrite} afterwards. */
void writeTo(Channel channel, ObjectOutputStream oos) throws IOException {
  Channel old = Channel.setCurrent(channel);
  try {
    oos.writeObject(this);
  } finally {
    Channel.setCurrent(old);
  }
}

代码示例来源:origin: jenkinsci/remoting

/** Consider calling {@link Channel#notifyRead} afterwards. */
static Command readFromObjectStream(Channel channel, ObjectInputStream ois) throws IOException, ClassNotFoundException {
  Channel old = Channel.setCurrent(channel);
  try {
    return (Command)ois.readObject();
  } finally {
    Channel.setCurrent(old);
  }
}

代码示例来源:origin: jenkinsci/remoting

@SuppressWarnings("unchecked")
  @Override
  public RSP retrieve(Channel channel, ClassLoader cl) throws IOException, ClassNotFoundException, EXC {
    Channel old = Channel.setCurrent(channel);
    try {
      return (RSP) deserialize(channel, response, cl);
    } finally {
      Channel.setCurrent(old);
    }
  }
}

代码示例来源:origin: org.eclipse.hudson/hudson-remoting

/**
 * Deserializes the response byte stream into an object.
 */
public RSP retrieve(Channel channel, ClassLoader cl) throws IOException, ClassNotFoundException, EXC {
  Channel old = Channel.setCurrent(channel);
  try {
    Object o = UserRequest.deserialize(channel,response,cl);
    if(isException)
      throw (EXC)o;
    else
      return (RSP) o;
  } finally {
    Channel.setCurrent(old);
  }
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-remoting

/**
 * Deserializes the response byte stream into an object.
 */
public RSP retrieve(Channel channel, ClassLoader cl) throws IOException, ClassNotFoundException, EXC {
  Channel old = Channel.setCurrent(channel);
  try {
    Object o = UserRequest.deserialize(channel,response,cl);
    if(isException)
      throw (EXC)o;
    else
      return (RSP) o;
  } finally {
    Channel.setCurrent(old);
  }
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Deserializes the response byte stream into an object.
 */
public RSP retrieve(Channel channel, ClassLoader cl) throws IOException, ClassNotFoundException, EXC {
  Channel old = Channel.setCurrent(channel);
  try {
    Object o = UserRequest.deserialize(channel,response,cl);
    if(isException)
      throw (EXC)o;
    else
      return (RSP) o;
  } finally {
    Channel.setCurrent(old);
  }
}

代码示例来源:origin: org.eclipse.hudson/hudson-remoting

private byte[] _serialize(Object o, final Channel channel) throws IOException {
  Channel old = Channel.setCurrent(channel);
  try {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos;
    if (channel.remoteCapability.supportsMultiClassLoaderRPC())
      oos = new MultiClassLoaderSerializer.Output(channel,baos);
    else
      oos = new ObjectOutputStream(baos);
    oos.writeObject(o);
    return baos.toByteArray();
  } finally {
    Channel.setCurrent(old);
  }
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-remoting

private byte[] _serialize(Object o, final Channel channel) throws IOException {
  Channel old = Channel.setCurrent(channel);
  try {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos;
    if (channel.remoteCapability.supportsMultiClassLoaderRPC())
      oos = new MultiClassLoaderSerializer.Output(channel,baos);
    else
      oos = new ObjectOutputStream(baos);
    oos.writeObject(o);
    return baos.toByteArray();
  } finally {
    Channel.setCurrent(old);
  }
}

代码示例来源:origin: hudson/hudson-2.x

private byte[] _serialize(Object o, final Channel channel) throws IOException {
  Channel old = Channel.setCurrent(channel);
  try {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos;
    if (channel.remoteCapability.supportsMultiClassLoaderRPC())
      oos = new MultiClassLoaderSerializer.Output(channel,baos);
    else
      oos = new ObjectOutputStream(baos);
    oos.writeObject(o);
    return baos.toByteArray();
  } finally {
    Channel.setCurrent(old);
  }
}

代码示例来源:origin: jenkinsci/remoting

/**
 * Deserializes the response byte stream into an object.
 */
public RSP retrieve(Channel channel, ClassLoader cl) throws IOException, ClassNotFoundException, EXC {
  Channel old = Channel.setCurrent(channel);
  try {
    Object o = UserRequest.deserialize(channel,response,cl);
    if(isException) {
      channel.attachCallSiteStackTrace((Throwable)o);
      throw (EXC) o;
    } else
      return (RSP) o;
  } finally {
    Channel.setCurrent(old);
  }
}

代码示例来源:origin: jenkinsci/remoting

private byte[] _serialize(Object o, final Channel channel) throws IOException {
  Channel old = Channel.setCurrent(channel);
  try {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos;
    if (channel.remoteCapability.supportsMultiClassLoaderRPC())
      oos = new MultiClassLoaderSerializer.Output(channel,baos);
    else
      oos = AnonymousClassWarnings.checkingObjectOutputStream(baos);
    oos.writeObject(o);
    return baos.toByteArray();
  } finally {
    Channel.setCurrent(old);
  }
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-remoting

/**
 * Sends a command to the remote end and executes it there.
 * <p/>
 * <p/>
 * This is the lowest layer of abstraction in {@link Channel}.
 * {@link Command}s are executed on a remote system in the order they are sent.
 */
/*package*/
synchronized void send(Command cmd) throws IOException {
  if (outClosed != null) {
    throw new ChannelClosedException(outClosed);
  }
  if (logger.isLoggable(Level.FINE)) {
    logger.fine("Send " + cmd);
  }
  Channel old = Channel.setCurrent(this);
  try {
    oos.writeObject(cmd);
    oos.flush();        // make sure the command reaches the other end.
  } finally {
    Channel.setCurrent(old);
  }
  // unless this is the last command, have OOS and remote OIS forget all the objects we sent
  // in this command. Otherwise it'll keep objects in memory unnecessarily.
  // However, this may fail if the command was the close, because that's supposed to be the last command
  // ever sent. See the comment from jglick on HUDSON-3077 about what happens if we do oos.reset(). 
  if (!(cmd instanceof CloseCommand)) {
    oos.reset();
  }
}

代码示例来源:origin: org.eclipse.hudson/hudson-remoting

/**
 * Sends a command to the remote end and executes it there.
 * <p/>
 * <p/>
 * This is the lowest layer of abstraction in {@link Channel}.
 * {@link Command}s are executed on a remote system in the order they are sent.
 */
/*package*/
synchronized void send(Command cmd) throws IOException {
  if (outClosed != null) {
    throw new ChannelClosedException(outClosed);
  }
  if (logger.isLoggable(Level.FINE)) {
    logger.fine("Send " + cmd);
  }
  Channel old = Channel.setCurrent(this);
  try {
    oos.writeObject(cmd);
    oos.flush();        // make sure the command reaches the other end.
  } finally {
    Channel.setCurrent(old);
  }
  // unless this is the last command, have OOS and remote OIS forget all the objects we sent
  // in this command. Otherwise it'll keep objects in memory unnecessarily.
  // However, this may fail if the command was the close, because that's supposed to be the last command
  // ever sent. See the comment from jglick on HUDSON-3077 about what happens if we do oos.reset(). 
  if (!(cmd instanceof CloseCommand)) {
    oos.reset();
  }
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Sends a command to the remote end and executes it there.
 * <p/>
 * <p/>
 * This is the lowest layer of abstraction in {@link Channel}.
 * {@link Command}s are executed on a remote system in the order they are sent.
 */
/*package*/
synchronized void send(Command cmd) throws IOException {
  if (outClosed != null) {
    throw new ChannelClosedException(outClosed);
  }
  if (logger.isLoggable(Level.FINE)) {
    logger.fine("Send " + cmd);
  }
  Channel old = Channel.setCurrent(this);
  try {
    oos.writeObject(cmd);
    oos.flush();        // make sure the command reaches the other end.
  } finally {
    Channel.setCurrent(old);
  }
  // unless this is the last command, have OOS and remote OIS forget all the objects we sent
  // in this command. Otherwise it'll keep objects in memory unnecessarily.
  // However, this may fail if the command was the close, because that's supposed to be the last command
  // ever sent. See the comment from jglick on HUDSON-3077 about what happens if we do oos.reset(). 
  if (!(cmd instanceof CloseCommand)) {
    oos.reset();
  }
}

代码示例来源:origin: jenkinsci/remoting

@SuppressWarnings("unchecked")
  @Override
  public RSP retrieve(Channel channel, ClassLoader cl) throws IOException, ClassNotFoundException, EXC {
    Channel old = Channel.setCurrent(channel);
    try {
      Throwable t = null;
      if (rawResponse != null) {
        try {
          t = (Throwable) deserialize(channel, rawResponse, cl);
        } catch (Exception x) {
          LOGGER.log(Level.FINE, "could not deserialize exception response", x);
        }
      }
      if (t == null) {
        t = (Throwable) deserialize(channel, proxyResponse, cl);
      }
      channel.attachCallSiteStackTrace(t);
      throw (EXC) t;
    } finally {
      Channel.setCurrent(old);
    }
  }
}

代码示例来源:origin: hudson/hudson-2.x

while (inClosed == null) {
  try {
    Channel old = Channel.setCurrent(Channel.this);
    try {
      cmd = (Command) ois.readObject();
      lastHeard = System.currentTimeMillis();
    } finally {
      Channel.setCurrent(old);

代码示例来源:origin: org.eclipse.hudson/hudson-remoting

while (inClosed == null) {
  try {
    Channel old = Channel.setCurrent(Channel.this);
    try {
      cmd = (Command) ois.readObject();
      lastHeard = System.currentTimeMillis();
    } finally {
      Channel.setCurrent(old);

代码示例来源:origin: org.eclipse.hudson.main/hudson-remoting

while (inClosed == null) {
  try {
    Channel old = Channel.setCurrent(Channel.this);
    try {
      cmd = (Command) ois.readObject();
      lastHeard = System.currentTimeMillis();
    } finally {
      Channel.setCurrent(old);

代码示例来源:origin: hudson/hudson-2.x

Channel oldc = Channel.setCurrent(channel);
try {
  Object o;
  Channel.setCurrent(oldc);

代码示例来源:origin: org.eclipse.hudson/hudson-remoting

Channel oldc = Channel.setCurrent(channel);
try {
  Object o;
  Channel.setCurrent(oldc);

相关文章