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

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

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

Channel.setCurrent介绍

暂无

代码示例

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

  1. /** Consider calling {@link Channel#notifyWrite} afterwards. */
  2. void writeTo(Channel channel, ObjectOutputStream oos) throws IOException {
  3. Channel old = Channel.setCurrent(channel);
  4. try {
  5. oos.writeObject(this);
  6. } finally {
  7. Channel.setCurrent(old);
  8. }
  9. }

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

  1. /** Consider calling {@link Channel#notifyRead} afterwards. */
  2. static Command readFromObjectStream(Channel channel, ObjectInputStream ois) throws IOException, ClassNotFoundException {
  3. Channel old = Channel.setCurrent(channel);
  4. try {
  5. return (Command)ois.readObject();
  6. } finally {
  7. Channel.setCurrent(old);
  8. }
  9. }

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

  1. @SuppressWarnings("unchecked")
  2. @Override
  3. public RSP retrieve(Channel channel, ClassLoader cl) throws IOException, ClassNotFoundException, EXC {
  4. Channel old = Channel.setCurrent(channel);
  5. try {
  6. return (RSP) deserialize(channel, response, cl);
  7. } finally {
  8. Channel.setCurrent(old);
  9. }
  10. }
  11. }

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

  1. /**
  2. * Deserializes the response byte stream into an object.
  3. */
  4. public RSP retrieve(Channel channel, ClassLoader cl) throws IOException, ClassNotFoundException, EXC {
  5. Channel old = Channel.setCurrent(channel);
  6. try {
  7. Object o = UserRequest.deserialize(channel,response,cl);
  8. if(isException)
  9. throw (EXC)o;
  10. else
  11. return (RSP) o;
  12. } finally {
  13. Channel.setCurrent(old);
  14. }
  15. }

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

  1. /**
  2. * Deserializes the response byte stream into an object.
  3. */
  4. public RSP retrieve(Channel channel, ClassLoader cl) throws IOException, ClassNotFoundException, EXC {
  5. Channel old = Channel.setCurrent(channel);
  6. try {
  7. Object o = UserRequest.deserialize(channel,response,cl);
  8. if(isException)
  9. throw (EXC)o;
  10. else
  11. return (RSP) o;
  12. } finally {
  13. Channel.setCurrent(old);
  14. }
  15. }

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

  1. /**
  2. * Deserializes the response byte stream into an object.
  3. */
  4. public RSP retrieve(Channel channel, ClassLoader cl) throws IOException, ClassNotFoundException, EXC {
  5. Channel old = Channel.setCurrent(channel);
  6. try {
  7. Object o = UserRequest.deserialize(channel,response,cl);
  8. if(isException)
  9. throw (EXC)o;
  10. else
  11. return (RSP) o;
  12. } finally {
  13. Channel.setCurrent(old);
  14. }
  15. }

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

  1. private byte[] _serialize(Object o, final Channel channel) throws IOException {
  2. Channel old = Channel.setCurrent(channel);
  3. try {
  4. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  5. ObjectOutputStream oos;
  6. if (channel.remoteCapability.supportsMultiClassLoaderRPC())
  7. oos = new MultiClassLoaderSerializer.Output(channel,baos);
  8. else
  9. oos = new ObjectOutputStream(baos);
  10. oos.writeObject(o);
  11. return baos.toByteArray();
  12. } finally {
  13. Channel.setCurrent(old);
  14. }
  15. }

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

  1. private byte[] _serialize(Object o, final Channel channel) throws IOException {
  2. Channel old = Channel.setCurrent(channel);
  3. try {
  4. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  5. ObjectOutputStream oos;
  6. if (channel.remoteCapability.supportsMultiClassLoaderRPC())
  7. oos = new MultiClassLoaderSerializer.Output(channel,baos);
  8. else
  9. oos = new ObjectOutputStream(baos);
  10. oos.writeObject(o);
  11. return baos.toByteArray();
  12. } finally {
  13. Channel.setCurrent(old);
  14. }
  15. }

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

  1. private byte[] _serialize(Object o, final Channel channel) throws IOException {
  2. Channel old = Channel.setCurrent(channel);
  3. try {
  4. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  5. ObjectOutputStream oos;
  6. if (channel.remoteCapability.supportsMultiClassLoaderRPC())
  7. oos = new MultiClassLoaderSerializer.Output(channel,baos);
  8. else
  9. oos = new ObjectOutputStream(baos);
  10. oos.writeObject(o);
  11. return baos.toByteArray();
  12. } finally {
  13. Channel.setCurrent(old);
  14. }
  15. }

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

  1. /**
  2. * Deserializes the response byte stream into an object.
  3. */
  4. public RSP retrieve(Channel channel, ClassLoader cl) throws IOException, ClassNotFoundException, EXC {
  5. Channel old = Channel.setCurrent(channel);
  6. try {
  7. Object o = UserRequest.deserialize(channel,response,cl);
  8. if(isException) {
  9. channel.attachCallSiteStackTrace((Throwable)o);
  10. throw (EXC) o;
  11. } else
  12. return (RSP) o;
  13. } finally {
  14. Channel.setCurrent(old);
  15. }
  16. }

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

  1. private byte[] _serialize(Object o, final Channel channel) throws IOException {
  2. Channel old = Channel.setCurrent(channel);
  3. try {
  4. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  5. ObjectOutputStream oos;
  6. if (channel.remoteCapability.supportsMultiClassLoaderRPC())
  7. oos = new MultiClassLoaderSerializer.Output(channel,baos);
  8. else
  9. oos = AnonymousClassWarnings.checkingObjectOutputStream(baos);
  10. oos.writeObject(o);
  11. return baos.toByteArray();
  12. } finally {
  13. Channel.setCurrent(old);
  14. }
  15. }

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

  1. /**
  2. * Sends a command to the remote end and executes it there.
  3. * <p/>
  4. * <p/>
  5. * This is the lowest layer of abstraction in {@link Channel}.
  6. * {@link Command}s are executed on a remote system in the order they are sent.
  7. */
  8. /*package*/
  9. synchronized void send(Command cmd) throws IOException {
  10. if (outClosed != null) {
  11. throw new ChannelClosedException(outClosed);
  12. }
  13. if (logger.isLoggable(Level.FINE)) {
  14. logger.fine("Send " + cmd);
  15. }
  16. Channel old = Channel.setCurrent(this);
  17. try {
  18. oos.writeObject(cmd);
  19. oos.flush(); // make sure the command reaches the other end.
  20. } finally {
  21. Channel.setCurrent(old);
  22. }
  23. // unless this is the last command, have OOS and remote OIS forget all the objects we sent
  24. // in this command. Otherwise it'll keep objects in memory unnecessarily.
  25. // However, this may fail if the command was the close, because that's supposed to be the last command
  26. // ever sent. See the comment from jglick on HUDSON-3077 about what happens if we do oos.reset().
  27. if (!(cmd instanceof CloseCommand)) {
  28. oos.reset();
  29. }
  30. }

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

  1. /**
  2. * Sends a command to the remote end and executes it there.
  3. * <p/>
  4. * <p/>
  5. * This is the lowest layer of abstraction in {@link Channel}.
  6. * {@link Command}s are executed on a remote system in the order they are sent.
  7. */
  8. /*package*/
  9. synchronized void send(Command cmd) throws IOException {
  10. if (outClosed != null) {
  11. throw new ChannelClosedException(outClosed);
  12. }
  13. if (logger.isLoggable(Level.FINE)) {
  14. logger.fine("Send " + cmd);
  15. }
  16. Channel old = Channel.setCurrent(this);
  17. try {
  18. oos.writeObject(cmd);
  19. oos.flush(); // make sure the command reaches the other end.
  20. } finally {
  21. Channel.setCurrent(old);
  22. }
  23. // unless this is the last command, have OOS and remote OIS forget all the objects we sent
  24. // in this command. Otherwise it'll keep objects in memory unnecessarily.
  25. // However, this may fail if the command was the close, because that's supposed to be the last command
  26. // ever sent. See the comment from jglick on HUDSON-3077 about what happens if we do oos.reset().
  27. if (!(cmd instanceof CloseCommand)) {
  28. oos.reset();
  29. }
  30. }

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

  1. /**
  2. * Sends a command to the remote end and executes it there.
  3. * <p/>
  4. * <p/>
  5. * This is the lowest layer of abstraction in {@link Channel}.
  6. * {@link Command}s are executed on a remote system in the order they are sent.
  7. */
  8. /*package*/
  9. synchronized void send(Command cmd) throws IOException {
  10. if (outClosed != null) {
  11. throw new ChannelClosedException(outClosed);
  12. }
  13. if (logger.isLoggable(Level.FINE)) {
  14. logger.fine("Send " + cmd);
  15. }
  16. Channel old = Channel.setCurrent(this);
  17. try {
  18. oos.writeObject(cmd);
  19. oos.flush(); // make sure the command reaches the other end.
  20. } finally {
  21. Channel.setCurrent(old);
  22. }
  23. // unless this is the last command, have OOS and remote OIS forget all the objects we sent
  24. // in this command. Otherwise it'll keep objects in memory unnecessarily.
  25. // However, this may fail if the command was the close, because that's supposed to be the last command
  26. // ever sent. See the comment from jglick on HUDSON-3077 about what happens if we do oos.reset().
  27. if (!(cmd instanceof CloseCommand)) {
  28. oos.reset();
  29. }
  30. }

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

  1. @SuppressWarnings("unchecked")
  2. @Override
  3. public RSP retrieve(Channel channel, ClassLoader cl) throws IOException, ClassNotFoundException, EXC {
  4. Channel old = Channel.setCurrent(channel);
  5. try {
  6. Throwable t = null;
  7. if (rawResponse != null) {
  8. try {
  9. t = (Throwable) deserialize(channel, rawResponse, cl);
  10. } catch (Exception x) {
  11. LOGGER.log(Level.FINE, "could not deserialize exception response", x);
  12. }
  13. }
  14. if (t == null) {
  15. t = (Throwable) deserialize(channel, proxyResponse, cl);
  16. }
  17. channel.attachCallSiteStackTrace(t);
  18. throw (EXC) t;
  19. } finally {
  20. Channel.setCurrent(old);
  21. }
  22. }
  23. }

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

  1. while (inClosed == null) {
  2. try {
  3. Channel old = Channel.setCurrent(Channel.this);
  4. try {
  5. cmd = (Command) ois.readObject();
  6. lastHeard = System.currentTimeMillis();
  7. } finally {
  8. Channel.setCurrent(old);

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

  1. while (inClosed == null) {
  2. try {
  3. Channel old = Channel.setCurrent(Channel.this);
  4. try {
  5. cmd = (Command) ois.readObject();
  6. lastHeard = System.currentTimeMillis();
  7. } finally {
  8. Channel.setCurrent(old);

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

  1. while (inClosed == null) {
  2. try {
  3. Channel old = Channel.setCurrent(Channel.this);
  4. try {
  5. cmd = (Command) ois.readObject();
  6. lastHeard = System.currentTimeMillis();
  7. } finally {
  8. Channel.setCurrent(old);

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

  1. Channel oldc = Channel.setCurrent(channel);
  2. try {
  3. Object o;
  4. Channel.setCurrent(oldc);

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

  1. Channel oldc = Channel.setCurrent(channel);
  2. try {
  3. Object o;
  4. Channel.setCurrent(oldc);

相关文章