本文整理汇总了Java中org.apache.twill.api.ClassAcceptor类的典型用法代码示例。如果您正苦于以下问题:Java ClassAcceptor类的具体用法?Java ClassAcceptor怎么用?Java ClassAcceptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClassAcceptor类属于org.apache.twill.api包,在下文中一共展示了ClassAcceptor类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ApplicationBundler
import org.apache.twill.api.ClassAcceptor; //导入依赖的package包/类
/**
* Constructs an ApplicationBundler.
*
* @param excludePackages Class packages to exclude
* @param includePackages Class packages that should be included. Anything in this list will override the
* one provided in excludePackages.
*/
public ApplicationBundler(final Iterable<String> excludePackages, final Iterable<String> includePackages) {
this(new ClassAcceptor() {
@Override
public boolean accept(String className, URL classUrl, URL classPathUrl) {
for (String includePackage : includePackages) {
if (className.startsWith(includePackage)) {
return true;
}
}
for (String excludePackage : excludePackages) {
if (className.startsWith(excludePackage)) {
return false;
}
}
return true;
}
});
}
示例2: YarnTwillPreparer
import org.apache.twill.api.ClassAcceptor; //导入依赖的package包/类
YarnTwillPreparer(Configuration config, TwillSpecification twillSpec, RunId runId,
String zkConnectString, Location appLocation, @Nullable String extraOptions,
LocationCache locationCache, YarnTwillControllerFactory controllerFactory) {
this.config = config;
this.twillSpec = twillSpec;
this.runId = runId;
this.zkConnectString = zkConnectString;
this.appLocation = appLocation;
this.controllerFactory = controllerFactory;
this.credentials = createCredentials();
this.extraOptions = extraOptions == null ? "" : extraOptions;
this.classAcceptor = new ClassAcceptor();
this.locationCache = locationCache;
}
示例3: createLauncherJar
import org.apache.twill.api.ClassAcceptor; //导入依赖的package包/类
/**
* Creates the launcher.jar for launch the main application.
*/
private void createLauncherJar(Map<String, LocalFile> localFiles) throws URISyntaxException, IOException {
LOG.debug("Create and copy {}", Constants.Files.LAUNCHER_JAR);
Location location = locationCache.get(Constants.Files.LAUNCHER_JAR, new LocationCache.Loader() {
@Override
public void load(String name, Location targetLocation) throws IOException {
// Create a jar file with the TwillLauncher and FindFreePort and dependent classes inside.
try (JarOutputStream jarOut = new JarOutputStream(targetLocation.getOutputStream())) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = getClass().getClassLoader();
}
Dependencies.findClassDependencies(classLoader, new ClassAcceptor() {
@Override
public boolean accept(String className, URL classUrl, URL classPathUrl) {
try {
jarOut.putNextEntry(new JarEntry(className.replace('.', '/') + ".class"));
try (InputStream is = classUrl.openStream()) {
ByteStreams.copy(is, jarOut);
}
} catch (IOException e) {
throw Throwables.propagate(e);
}
return true;
}
}, TwillLauncher.class.getName(), FindFreePort.class.getName());
}
}
});
LOG.debug("Done {}", Constants.Files.LAUNCHER_JAR);
localFiles.put(Constants.Files.LAUNCHER_JAR, createLocalFile(Constants.Files.LAUNCHER_JAR, location));
}
示例4: findDependencies
import org.apache.twill.api.ClassAcceptor; //导入依赖的package包/类
private void findDependencies(Iterable<Class<?>> classes, final Set<String> entries,
final JarOutputStream jarOut) throws IOException {
Iterable<String> classNames = Iterables.transform(classes, new Function<Class<?>, String>() {
@Override
public String apply(Class<?> input) {
return input.getName();
}
});
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = getClass().getClassLoader();
}
// Record the set of classpath URL that are already added to the jar
final Set<URL> seenClassPaths = Sets.newHashSet();
Dependencies.findClassDependencies(classLoader, new ClassAcceptor() {
@Override
public boolean accept(String className, URL classUrl, URL classPathUrl) {
if (bootstrapClassPaths.contains(classPathUrl.getFile())) {
return false;
}
if (!classAcceptor.accept(className, classUrl, classPathUrl)) {
return false;
}
if (seenClassPaths.add(classPathUrl)) {
putEntry(className, classUrl, classPathUrl, entries, jarOut);
}
return true;
}
}, classNames);
}
示例5: withBundlerClassAcceptor
import org.apache.twill.api.ClassAcceptor; //导入依赖的package包/类
@Override
public TwillPreparer withBundlerClassAcceptor(ClassAcceptor classAcceptor) {
this.classAcceptor = classAcceptor;
return this;
}
示例6: createBundler
import org.apache.twill.api.ClassAcceptor; //导入依赖的package包/类
private ApplicationBundler createBundler(ClassAcceptor classAcceptor) {
return new ApplicationBundler(classAcceptor).setTempDir(getLocalStagingDir());
}
示例7: findClassDependencies
import org.apache.twill.api.ClassAcceptor; //导入依赖的package包/类
public static void findClassDependencies(ClassLoader classLoader,
ClassAcceptor acceptor,
String...classesToResolve) throws IOException {
findClassDependencies(classLoader, acceptor, ImmutableList.copyOf(classesToResolve));
}