/** * Creates a {@link ResourceUtils} object with the given context. * <p> * Uses the {@link ClassLoader} of the given {@code contextObject} for class * loading and the {@code contextMessage} string for error messages. * * @see ResourceUtils#create(ClassLoader, Object, String) * @see ResourceUtils#create(Object) */ public static final ResourceUtils create(Object contextObject, String contextMessage) { return new ResourceUtils(contextObject, contextMessage); }
@Override public Iterable<URL> getResources(String name) { return new ClassLoaderUtils(loader, mgmt).getResources(name); } }
/** * @return A predicate that tests whether its input is a resource readable by Brooklyn. * @see ResourceUtils#doesUrlExist(String) */ public static Predicate<String> urlExists() { return new ResourceExistsPredicate(); }
protected String getFileContents(String file) { return ResourceUtils.create(this).getResourceAsString(file); } }
private static InputStream getUrlStream(String url) { return ResourceUtils.create(Osgis.class).getResourceFromUrl(url); }
@Test(groups="Integration") public void testUtilsCommon() { ResourceUtils.create(this).checkUrlExists(BrooklynMavenArtifacts.localUrlForJar("brooklyn-utils-common")); }
@Override public URL getResource(String name) { return new ClassLoaderUtils(loader, mgmt).getResource(name); }
/** @see #checkUrlExists(String, String) */ public String checkUrlExists(String url) { return checkUrlExists(url, null); }
public static MavenArtifact jar(String artifactId) { return artifact(null, artifactId, "jar"); }
public static InetAddress getLocalhostInetAddress() { return BrooklynNetworkUtils.getLocalhostInetAddress(); }
@Beta public boolean isBundleWhiteListed(Bundle bundle) { WhiteListBundlePredicate p = createBundleMatchingPredicate(); return p.apply(bundle); }
/** This should not be exposed as it risks it leaking into places where it would be serialized. * Better for callers use {@link CatalogUtils#getClassLoadingContext(org.apache.brooklyn.api.entity.Entity)} or similar. }. */ private BrooklynClassLoadingContext getLoader() { return (loader!=null ? loader : getClassLoadingContextInternal(null, contextObject!=null ? contextObject : this)); }
private static URL[] tidy(URL[] urls) { for (int i=0; i<urls.length; i++) urls[i] = ResourceUtils.tidy(urls[i]); return urls; }
@SuppressWarnings("deprecation") public static void initLegacyLanguageExtensions() { org.apache.brooklyn.util.core.BrooklynLanguageExtensions.init(); }
private void assertLoadFails(String bundledClassName, ClassLoaderUtils... clua) { for (ClassLoaderUtils clu : clua) { assertLoadFails(clu, bundledClassName); } }
/** * Creates a {@link ResourceUtils} object with itself as the context. * * @see ResourceUtils#create(Object) */ public static final ResourceUtils create() { return new ResourceUtils(null); }
public static MavenArtifact artifact(String subgroupUnderIoBrooklyn, String artifactId, String packaging) { return artifact(subgroupUnderIoBrooklyn, artifactId, packaging, null); }
public ResourceUtils(ClassLoader loader, Object contextObject, String contextMessage) { this(getClassLoadingContextInternal(loader, contextObject), contextObject, contextMessage); }
/** * Creates a {@link ResourceUtils} object with a specific class loader and context. * <p> * Use the provided {@link BrooklynClassLoadingContext} object for class loading with the * {@code contextObject} for context and the {@code contextMessage} string for * error messages. * * @see ResourceUtils#create(Object, String) * @see ResourceUtils#create(Object) */ public static final ResourceUtils create(BrooklynClassLoadingContext loader, Object contextObject, String contextMessage) { return new ResourceUtils(loader, contextObject, contextMessage); }
public ResourceUtils(Object contextObject, String contextMessage) { this(contextObject==null ? null : getClassLoadingContextInternal(null, contextObject), contextObject, contextMessage); }