Package org.osgi.framework.wiring

Examples of org.osgi.framework.wiring.BundleWiring


   
    Configuration configuration = new Configuration();
    configuration.getProperties().put( AvailableSettings.JTA_PLATFORM, osgiJtaPlatform );
   
    // Allow bundles to put the config file somewhere other than the root level.
    final BundleWiring bundleWiring = (BundleWiring) requestingBundle.adapt( BundleWiring.class );
    final Collection<String> cfgResources = bundleWiring.listResources( "/", "hibernate.cfg.xml",
        BundleWiring.LISTRESOURCES_RECURSE );
    if (cfgResources.size() == 0) {
      configuration.configure();
    }
    else {
View Full Code Here


        // skip first bundle
        iterator.next();
        // attempt to load the class from the remaining bundles
        while (iterator.hasNext()) {
            Bundle bundle = iterator.next();
            BundleWiring wiring = bundle.adapt(BundleWiring.class);
            if (wiring != null) {
                List<BundleCapability> capabilities = wiring.getCapabilities(BundleRevision.PACKAGE_NAMESPACE);
                if (capabilities != null && !capabilities.isEmpty()) {
                    for (BundleCapability capability : capabilities) {
                        Map<String, Object> attributes = capability.getAttributes();
                        if (attributes != null) {
                            String packageName = String.valueOf(attributes.get(BundleRevision.PACKAGE_NAMESPACE));
View Full Code Here

   
    // OSGi 4.3 API
   
    private static LinkedHashSet<Bundle> getWiredBundles43(Bundle bundle) {
        LinkedHashSet<Bundle> wiredBundles = new LinkedHashSet<Bundle>();
        BundleWiring wiring = bundle.adapt(BundleWiring.class);
        if (wiring != null) {
            List<BundleWire> wires;
            wires = wiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
            for (BundleWire wire : wires) {
                wiredBundles.add(wire.getProviderWiring().getBundle());
            }
            wires = wiring.getRequiredWires(BundleRevision.BUNDLE_NAMESPACE);
            for (BundleWire wire : wires) {
                wiredBundles.add(wire.getProviderWiring().getBundle());
            }
        }       
        return wiredBundles;
View Full Code Here

        return urlPath;
    }

    private void loadImplementationsInBundle(final Test test, final String packageName) {
        //Do not remove the cast on the next line as removing it will cause a compile error on Java 7.
        final BundleWiring wiring = (BundleWiring) FrameworkUtil.getBundle(
                ResolverUtil.class).adapt(BundleWiring.class);
        final Collection<String> list = wiring.listResources(packageName, "*.class",
            BundleWiring.LISTRESOURCES_RECURSE);
        for (final String name : list) {
            addIfMatching(test, name);
        }
    }
View Full Code Here

        BundleRevision revision = bundle.adapt(BundleRevision.class);
        for (BundleRequirement req : revision.getDeclaredRequirements(PackageNamespace.PACKAGE_NAMESPACE)) {
            if (PackageNamespace.RESOLUTION_OPTIONAL.equals(req.getDirectives().get(PackageNamespace.REQUIREMENT_RESOLUTION_DIRECTIVE))) {
               
                // Find the wire for this optional package import
                BundleWiring wiring = bundle.adapt(BundleWiring.class);
                BundleWire reqwire = null;
                if (wiring != null) {
                    for (BundleWire wire : wiring.getRequiredWires(PackageNamespace.PACKAGE_NAMESPACE)) {
                        if (req.equals(wire.getRequirement())) {
                            BundleCapability cap = wire.getCapability();
                            BundleRevision provider = wire.getProvider();
                            LOGGER.debug("Optional requirement {} from {} wires to capability {} provided by {}", req, bundle, cap, provider);
                            reqwire = wire;
View Full Code Here

    final Configuration configuration = new Configuration();
    configuration.getProperties().put( AvailableSettings.JTA_PLATFORM, osgiJtaPlatform );
   
    // Allow bundles to put the config file somewhere other than the root level.
    final BundleWiring bundleWiring = (BundleWiring) requestingBundle.adapt( BundleWiring.class );
    final Collection<String> cfgResources = bundleWiring.listResources( "/", "hibernate.cfg.xml",
        BundleWiring.LISTRESOURCES_RECURSE );
    if (cfgResources.size() == 0) {
      configuration.configure();
    }
    else {
View Full Code Here

class JPAAnnotationScanner implements AnnotationScanner {

 
  public Collection<String> findJPAAnnotatedClasses(Bundle b) {
    BundleWiring bw = b.adapt(BundleWiring.class);
    Collection<String> resources = bw.listResources("/", "*.class",
        BundleWiring.LISTRESOURCES_LOCAL | BundleWiring.LISTRESOURCES_RECURSE);
   
    Collection<String> classes = new ArrayList<String>();
    ClassLoader cl = new TempBundleDelegatingClassLoader(b, this.getClass().getClassLoader());
    for(String s : resources) {
View Full Code Here

  private final ConcurrentMap<Bundle, LinkedHashSet<WrappingTransformer>> registeredTransformers
      = new ConcurrentHashMap<Bundle, LinkedHashSet<WrappingTransformer>>();
 
  public void weave(WovenClass wovenClass) {
   
    BundleWiring wiring = wovenClass.getBundleWiring();
   
    Collection<WrappingTransformer> transformers = registeredTransformers.get(
        wiring.getBundle());
   
    if(transformers != null) {
      Collection<WrappingTransformer> transformersToTry;
      synchronized (transformers) {
        transformersToTry = new ArrayList<WrappingTransformer>(transformers);
      }
      for(WrappingTransformer transformer : transformersToTry) {
        try {
          byte[] result = transformer.transform(wiring.getClassLoader(),
              wovenClass.getClassName(), wovenClass.getDefinedClass(),
              wovenClass.getProtectionDomain(), wovenClass.getBytes());
          if(result != null) {
            wovenClass.setBytes(result);
            wovenClass.getDynamicImports().addAll(transformer.getPackagesToAdd());
View Full Code Here

        Set<Bundle> bundles = tree.flatten();
        Map<String, Set<Bundle>> exports = new HashMap<String, Set<Bundle>>();

        for (Bundle bundle : bundles) {
            for (BundleRevision revision : bundle.adapt(BundleRevisions.class).getRevisions()) {
                BundleWiring wiring = revision.getWiring();
                if (wiring != null) {
                    List<BundleWire> wires = wiring.getProvidedWires(BundleRevision.PACKAGE_NAMESPACE);
                    if (wires != null) {
                        for (BundleWire wire : wires) {
                            String name = wire.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE).toString();
                            if (exports.get(name) == null) {
                                exports.put(name, new HashSet<Bundle>());
View Full Code Here

     */
    private void createNodeForImport(Node<Bundle> node, Bundle bundle, Clause i) {
        VersionRange range = VersionRange.parseVersionRange(i.getAttribute(Constants.VERSION_ATTRIBUTE));
        boolean foundMatch = false;
        for (Bundle b : bundleContext.getBundles()) {
            BundleWiring wiring = b.adapt(BundleWiring.class);
            if (wiring != null) {
                List<BundleCapability> caps = wiring.getCapabilities(BundleRevision.PACKAGE_NAMESPACE);
                if (caps != null) {
                    for (BundleCapability cap : caps) {
                        String n = getAttribute(cap, BundleRevision.PACKAGE_NAMESPACE);
                        String v = getAttribute(cap, Constants.VERSION_ATTRIBUTE);
                        if (i.getName().equals(n) && range.contains(VersionTable.getVersion(v))) {
View Full Code Here

TOP

Related Classes of org.osgi.framework.wiring.BundleWiring

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.