hudson.remoting.Which类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(165)

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

Which介绍

[英]Locates where a given class is loaded from.
[中]定位从中加载给定类的位置。

代码示例

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

/**
 * Adds a jar file that contains the given class.
 * @since 1.361
 */
public ClasspathBuilder addJarOf(Class c) throws IOException {
  return add(Which.jarFile(c));
}

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

public URL getWhereServletIsLoaded() throws IOException {
    return Which.jarURL(servletClass);
  }
}

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

/**
 * Locates the jar file that contains the given class.
 *
 * <p>
 * Note that jar files are not always loaded from {@link File},
 * so for diagnostics purposes {@link #jarURL(Class)} is preferrable.
 *
 * @throws IllegalArgumentException
 *      if failed to determine.
 */
public static File jarFile(Class clazz) throws IOException {
  return jarFile(classFileUrl(clazz),clazz.getName().replace('.','/')+".class");
}

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

URL res = jarURL(clazz);
String resURL = res.toExternalForm();
String originalURL = resURL;
if(resURL.startsWith("jar:file:") || resURL.startsWith("wsjar:file:"))
  return fromJarUrlToFile(resURL);
  return new File(decode(new URL("file:/"+resURL).getPath()));
  return new File(decode(new URL("file:"+resURL).getPath()));
  return new File(decode(new URL(resURL).getPath()));

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

String originalURL = resURL;
if(resURL.startsWith("jar:file:") || resURL.startsWith("wsjar:file:"))
  return fromJarUrlToFile(resURL);
  return new File(decode(new URL("file:/"+resURL).getPath()));
  return new File(decode(new URL("file:"+resURL).getPath()));
  return new File(decode(new URL(resURL).getPath()));

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

private static File fromJarUrlToFile(String resURL) throws MalformedURLException {
  resURL = resURL.substring(resURL.indexOf(':')+1, resURL.lastIndexOf('!')); // cut off "scheme:" and the file name portion
  return new File(decode(new URL(resURL).getPath()));
}

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

public static File jarFile(URL resource) throws IOException {
  return fromJarUrlToFile(resource.toExternalForm());
}

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

/**
 * Decode '%HH'.
 */
private static String decode(String s) {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  for( int i=0; i<s.length();i++ ) {
    char ch = s.charAt(i);
    if(ch=='%') {
      baos.write(hexToInt(s.charAt(i+1))*16 + hexToInt(s.charAt(i+2)));
      i+=2;
      continue;
    }
    baos.write(ch);
  }
  try {
    return new String(baos.toByteArray(),"UTF-8");
  } catch (UnsupportedEncodingException e) {
    throw new Error(e); // impossible
  }
}

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

/**
 * Locates the jar file that contains the given class.
 *
 * <p>
 * Note that jar files are not always loaded from {@link File},
 * so for diagnostics purposes {@link #jarURL(Class)} is preferrable.
 *
 * @param clazz Class
 * @throws IllegalArgumentException
 *      if failed to determine the class File URL.
 * @return
 *      JAR File, which contains the class.
 */
@Nonnull
public static File jarFile(Class clazz) throws IOException {
  return jarFile(classFileUrl(clazz),clazz.getName().replace('.','/')+".class");
}

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

URL res = jarURL(clazz);
String resURL = res.toExternalForm();
String originalURL = resURL;
if(resURL.startsWith("jar:file:") || resURL.startsWith("wsjar:file:"))
  return fromJarUrlToFile(resURL);
  return new File(decode(new URL("file:/"+resURL).getPath()));
  return new File(decode(new URL("file:"+resURL).getPath()));
  return new File(decode(new URL(resURL).getPath()));

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

String originalURL = resURL;
if(resURL.startsWith("jar:file:") || resURL.startsWith("wsjar:file:"))
  return fromJarUrlToFile(resURL);
  return new File(decode(new URL("file:/"+resURL).getPath()));
  return new File(decode(new URL("file:"+resURL).getPath()));
  return new File(decode(new URL(resURL).getPath()));

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

private static File fromJarUrlToFile(String resURL) throws MalformedURLException {
  resURL = resURL.substring(resURL.indexOf(':')+1, resURL.lastIndexOf('!')); // cut off "scheme:" and the file name portion
  return new File(decode(new URL(resURL).getPath()));
}

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

public static File jarFile(URL resource) throws IOException {
  return fromJarUrlToFile(resource.toExternalForm());
}

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

/**
 * Decode '%HH'.
 */
private static String decode(String s) {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  for( int i=0; i<s.length();i++ ) {
    char ch = s.charAt(i);
    if(ch=='%') {
      baos.write(hexToInt(s.charAt(i+1))*16 + hexToInt(s.charAt(i+2)));
      i+=2;
      continue;
    }
    baos.write(ch);
  }
  try {
    return new String(baos.toByteArray(),"UTF-8");
  } catch (UnsupportedEncodingException e) {
    throw new Error(e); // impossible
  }
}

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

/**
 * With fix to JENKINS-11251 (remoting 2.15), this is no longer necessary.
 * But I'm keeping it for a while so that users who manually deploy agent.jar has time to deploy new version
 * before this goes away.
 */
private void syncIO() throws InterruptedException {
  try {
    if (channel!=null)
      channel.syncLocalIO();
  } catch (AbstractMethodError e) {
    // legacy agent.jar. Handle this gracefully
    try {
      LOGGER.log(Level.WARNING,"Looks like an old agent.jar. Please update "+ Which.jarFile(Channel.class)+" to the new version",e);
    } catch (IOException ignored) {
      // really ignore this time
    }
  }
}

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

final URL urlOfClassFile = Which.classFileUrl(c);
  File jar = Which.jarFile(c);
  if (jar.isFile()) {// for historical reasons the jarFile method can return a directory
    Checksum sum = channel.jarLoader.calcChecksum(jar);

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

public URL getWhereAntIsLoaded() throws IOException {
    return Which.jarURL(antClass);
  }
}

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

private static File fromJarUrlToFile(String resURL) throws MalformedURLException {
  resURL = resURL.substring(resURL.indexOf(':')+1, resURL.lastIndexOf('!')); // cut off "scheme:" and the file name portion
  return new File(decode(new URL(resURL).getPath()));
}

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

public static File jarFile(URL resource) throws IOException {
  return fromJarUrlToFile(resource.toExternalForm());
}

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

/**
 * Decode '%HH'.
 */
private static String decode(String s) {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  for( int i=0; i<s.length();i++ ) {
    char ch = s.charAt(i);
    if(ch=='%') {
      baos.write(hexToInt(s.charAt(i+1))*16 + hexToInt(s.charAt(i+2)));
      i+=2;
      continue;
    }
    baos.write(ch);
  }
  try {
    return new String(baos.toByteArray(),"UTF-8");
  } catch (UnsupportedEncodingException e) {
    throw new Error(e); // impossible
  }
}

相关文章