Codota Logo
Osgis
Code IndexAdd Codota to your IDE (free)

How to use
Osgis
in
org.apache.brooklyn.util.core.osgi

Best Java code snippets using org.apache.brooklyn.util.core.osgi.Osgis (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: org.apache.brooklyn/brooklyn-core

/**
 * Tries to find a bundle in the given framework with name matching either `name' or `name:version'.
 * @deprecated since 0.7.0 use {@link #bundleFinder(Framework)} */ @Deprecated
public static Maybe<Bundle> getBundle(Framework framework, String symbolicNameOptionallyWithVersion) {
  return bundleFinder(framework).id(symbolicNameOptionallyWithVersion).find();
}

origin: org.apache.brooklyn/brooklyn-core

/** installs the given JAR file as an OSGi bundle; all manifest info should be already set up.
 * bundle-start semantics are TBD.
 * 
 * @deprecated since 0.12.0, use {@link OsgiManager#installUploadedBundle(org.apache.brooklyn.api.typereg.ManagedBundle, InputStream)}*/
@Deprecated
public Bundle installBundle(File f, boolean start) {
  try {
    Bundle b = Osgis.install( framework, "file://"+f.getAbsolutePath() );
    if (start) {
      // benefits of start:
      // a) we get wiring issues thrown here, and
      // b) catalog.bom in root will be scanned synchronously here
      // however drawbacks:
      // c) other code doesn't always do it (method above)
      // d) heavier-weight earlier
      // e) tests in IDE break (but mvn fine)
      b.start();
    }
    
    return b;
    
  } catch (Exception e) {
    throw Exceptions.propagateAnnotated("Error starting bundle from "+f, e);
  }
}

origin: org.apache.brooklyn/brooklyn-core

public Optional<String> getPrefix(Class<?> type) {
  Optional<Bundle> bundle  = (bundleRetriever != null) ? bundleRetriever.apply(type) : Osgis.getBundleOf(type);
  if (bundle.isPresent()) {
    // Previously we didn't include the bundle prefix for whitelisted bundles. However,
    // that means once a bundle is whitelisted it must always be whitelisted. That is 
    // annoying for customer-upgrades of persisted state created pre-karaf. For those 
    // upgrades, the temporary whitelist is a useful way to allow rebind to complete 
    // successfully. The persisted state will then be re-written with the appropriate
    // prefixes. It is also better that we treat persistence/rebind of classes from 
    // Brooklyn bundles in the same way as customer bundles.
    return Optional.of(bundle.get().getSymbolicName() + DELIMITER);
  }
  return Optional.absent();
}

origin: org.apache.brooklyn/brooklyn-core

boolean isLocal = isLocalUrl(url);
String localUrl = url;
if (!isLocal) {
  localUrl = cacheFile(url);
  Bundle bundle = getInstalledBundle(framework, localUrl);
  if (bundle != null) {
    return bundle;
  InputStream stream = getUrlStream(localUrl);
  Bundle installedBundle = framework.getBundleContext().installBundle(url, stream);
origin: org.apache.brooklyn/brooklyn-core

Framework framework = Osgis.getFramework(storageTempDir.getAbsolutePath(), true);
  InternalEntityFactory factory = new InternalEntityFactory(managementContext, managementContext.getEntityManager().getEntityTypeRegistry(), policyFactory);
  Bundle bundle = Osgis.install(framework, BROOKLYN_TEST_OSGI_ENTITIES_PATH);
  @SuppressWarnings("unchecked")
  Class<? extends Entity> bundleCls = (Class<? extends Entity>) bundle.loadClass("org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl");
origin: org.apache.brooklyn/brooklyn-core

/** @deprecated since 0.9.0, replaced by {@link #getFramework(java.lang.String, boolean) } */
@Deprecated
public static Framework newFrameworkStarted(String felixCacheDir, boolean clean, Map<?,?> extraStartupConfig) {
  return getFramework(felixCacheDir, clean);
}
origin: org.apache.brooklyn/brooklyn-core

public static void tearDownOsgiFramework(Framework framework, File storageTempDir) throws BundleException, InterruptedException, IOException {
  Osgis.ungetFramework(framework);
  framework = null;
  if (storageTempDir != null) {
    FileUtils.deleteDirectory(storageTempDir);
    storageTempDir = null;
  }
}
origin: org.apache.brooklyn/brooklyn-core

private static String cacheFile(String url) {
  InputStream in = getUrlStream(url);
  File cache = Os.writeToTempFile(in, "bundle-cache", "jar");
  return cache.toURI().toString();
}
origin: org.apache.brooklyn/brooklyn-core

@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception {
  storageTempDir = Os.newTempDir("osgi-standalone");
  framework = Osgis.getFramework(storageTempDir.getAbsolutePath(), true);
}
origin: org.apache.brooklyn/brooklyn-core

Osgis.ungetFramework(framework);
origin: org.apache.brooklyn/brooklyn-core

  stream = new JarInputStream(getUrlStream(url));
} catch (IOException e) {
  throw Exceptions.propagate(e);
origin: org.apache.brooklyn/brooklyn-core

/** @deprecated since 0.7.0 use {@link #bundleFinder(Framework)} */ @Deprecated
public static List<Bundle> getBundlesByName(Framework framework, String symbolicName) {
  return bundleFinder(framework).symbolicName(symbolicName).findAll();
}
origin: org.apache.brooklyn/brooklyn-core

protected Bundle install(String url) throws BundleException {
  try {
    return Osgis.install(framework, url);
  } catch (Exception e) {
    throw new IllegalStateException("test resources not available; may be an IDE issue, so try a mvn rebuild of this project", e);
  }
}
origin: org.apache.brooklyn/brooklyn-core

framework = Osgis.getFramework(osgiFrameworkCacheDir.getAbsolutePath(), false);
log.debug("OSGi framework container created in "+osgiFrameworkCacheDir+" mgmt node "+mgmt.getManagementNodeId()+
  (reuseFramework ? "(reusable, "+numberOfReusableFrameworksCreated.get()+" total)" : "") );
origin: org.apache.brooklyn/brooklyn-camp

  protected void assertBundleVersionOf(Object obj, String expectedVersion) {
    assertNotNull(obj);
    Class<?> clazz = (obj instanceof Class) ? (Class<?>)obj : obj.getClass();
    assertEquals(Osgis.getBundleOf(clazz).get().getVersion().toString(), expectedVersion);
  }
}
origin: org.apache.brooklyn/brooklyn-core

void checkCorrectlyInstalled(OsgiBundleWithUrl bundle, Bundle b) {
  String nv = b.getSymbolicName()+":"+b.getVersion().toString();
  if (!isBundleNameEqualOrAbsent(bundle, b)) {
    throw new IllegalStateException("Bundle already installed as "+nv+" but user explicitly requested "+bundle);
  }
  List<Bundle> matches = Osgis.bundleFinder(framework)
      .symbolicName(b.getSymbolicName())
      .version(b.getVersion().toString())
      .findAll();
  if (matches.isEmpty()) {
    log.error("OSGi could not find bundle "+nv+" in search after installing it from "+bundle);
  } else if (matches.size()==1) {
    log.debug("Bundle from "+bundle.getUrl()+" successfully installed as " + nv + " ("+b+")");
  } else {
    log.warn("OSGi has multiple bundles matching "+nv+", when installing "+bundle+"; not guaranteed which versions will be consumed");
    // TODO for snapshot versions we should indicate which one is best to use
  }
}
origin: org.apache.brooklyn/brooklyn-core

/** @deprecated since 0.12.0 use {@link #install(ManagedBundle, InputStream, boolean, boolean)} */
@Deprecated
public synchronized Bundle registerBundle(CatalogBundle bundleMetadata) {
  try {
    Bundle alreadyBundle = checkBundleInstalledThrowIfInconsistent(bundleMetadata, true);
    if (alreadyBundle!=null) {
      return alreadyBundle;
    }
    Bundle bundleInstalled = Osgis.install(framework, bundleMetadata.getUrl());
    checkCorrectlyInstalled(bundleMetadata, bundleInstalled);
    return bundleInstalled;
  } catch (Exception e) {
    Exceptions.propagateIfFatal(e);
    throw new IllegalStateException("Bundle from "+bundleMetadata.getUrl()+" failed to install: " + e.getMessage(), e);
  }
}
origin: org.apache.brooklyn/brooklyn-core

/** @deprecated since 0.7.0 use {@link #bundleFinder(Framework)} */ @Deprecated
public static List<Bundle> getBundlesByName(Framework framework, String symbolicName, Predicate<Version> versionMatcher) {
  return bundleFinder(framework).symbolicName(symbolicName).version(versionMatcher).findAll();
}
origin: org.apache.brooklyn/brooklyn-core

protected Bundle installFromClasspath(String resourceName) throws BundleException {
  TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), resourceName);
  try {
    return Osgis.install(framework, String.format("classpath:%s", resourceName));
  } catch (Exception e) {
    throw Exceptions.propagate(e);
  }
}
origin: org.apache.brooklyn/brooklyn-core

/** @deprecated since 0.7.0 use {@link #bundleFinder(Framework)} */ @Deprecated
public static Maybe<Bundle> getBundle(Framework framework, String symbolicName, Version version) {
  return bundleFinder(framework).symbolicName(symbolicName).version(Predicates.equalTo(version)).findUnique();
}
org.apache.brooklyn.util.core.osgiOsgis

Javadoc

utilities for working with osgi. osgi support is in early days (June 2014) so this class is beta, subject to change, particularly in how framework is started and bundles installed.

Most used methods

  • bundleFinder
  • install
    Installs a bundle from the given URL, doing a check if already installed, and using the ResourceUtil
  • getBundleOf
  • getFramework
    Provides an OSGI framework. When running inside an OSGi container, the container framework is return
  • ungetFramework
    Stops/ungets the OSGi framework. See #getFramework(java.lang.String,boolean)
  • cacheFile
  • getInstalledBundle
  • getUrlStream
  • isLocalUrl

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSystemService (Context)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • getApplicationContext (Context)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • JCheckBox (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now