Package org.springframework.osgi.io

Examples of org.springframework.osgi.io.OsgiBundleResourcePatternResolver


    protected void register(final Bundle bundle) {
        Map<String, Callable<Class>> map = factories.get(bundle.getBundleId());

        Vector<URL> v = new Vector<URL>();
        try {
            Resource[] resources = new OsgiBundleResourcePatternResolver(bundle).getResources("classpath*:META-INF/services/*");
            for (Resource r : resources) {
                v.add(r.getURL());
            }
        } catch (IOException e1) {
            e1.printStackTrace();
View Full Code Here


   * Creates an OSGi specific resource pattern resolver.
   *
   * @return returns an OSGi specific pattern resolver.
   */
  protected ResourcePatternResolver createResourcePatternResolver() {
    return new OsgiBundleResourcePatternResolver(getBundle());
  }
View Full Code Here


  public void testResolveResourceWithFilePrefix() throws Exception {
    Bundle bundle = OsgiBundleUtils.findBundleBySymbolicName(bundleContext, EXPANDED_BUNDLE_SYM_NAME);
    assertTrue(bundle.getLocation().startsWith(REFERENCE_PROTOCOL));
    ResourcePatternResolver resolver = new OsgiBundleResourcePatternResolver(bundle);
    Resource res = resolver.getResource("resource.res");
    assertTrue(res.getFile().exists());
  }
View Full Code Here

  public void testResolveResourceWithReferenceFilePrefix() throws Exception {
    Bundle bundle = OsgiBundleUtils.findBundleBySymbolicName(bundleContext, EXPANDED_BUNDLE_SYM_NAME);
    assertTrue(bundle.getLocation().startsWith(REFERENCE_PROTOCOL));
    assertNotNull(new URL(bundle.getLocation()).getFile());
    ResourcePatternResolver resolver = new OsgiBundleResourcePatternResolver(bundle);
    Resource res = resolver.getResource("/META-INF/MANIFEST.MF");
    assertTrue(res.getFile().exists());
  }
View Full Code Here

    // load file using absolute path
    defaultLoader = new DefaultResourceLoader();
    thisClass = defaultLoader.getResource(getClass().getName().replace('.', '/').concat(".class"));
    bundle = bundleContext.getBundle();
    loader = new OsgiBundleResourceLoader(bundle);
    patternLoader = new OsgiBundleResourcePatternResolver(loader);

  }
View Full Code Here

  private ResourcePatternResolver osgiRPR;

  protected void onSetUp() throws Exception {
    super.onSetUp();
    osgiRL = new OsgiBundleResourceLoader(bundle);
    osgiRPR = new OsgiBundleResourcePatternResolver(bundle);
  }
View Full Code Here

    ServiceReference[] services = bundle.getServicesInUse();
    return (services == null ? new ServiceReference[0] : services);
  }

  public Collection<String> search(Bundle bundle, String pattern) {
    OsgiBundleResourcePatternResolver patternResolver = new OsgiBundleResourcePatternResolver(bundle);
    Collection<String> result = new ArrayList<String>();
    try {
      for (Resource resource : patternResolver.getResources(pattern)) {
        result.add(resource.getURI().toString());
      }
    }
    catch (IOException ex) {
      // invalid pattern
View Full Code Here

   * Creates an OSGi specific resource pattern resolver.
   *
   * @return returns an OSGi specific pattern resolver.
   */
  protected ResourcePatternResolver createResourcePatternResolver() {
    return new OsgiBundleResourcePatternResolver(getBundle());
  }
View Full Code Here

  }

  private ResourcePatternResolver getNoRootCpBundleResourceResolver() {
    Bundle bnd = OsgiBundleUtils.findBundleBySymbolicName(bundleContext, NO_ROOT_BND_SYM);
    assertNotNull("noRootClassPath bundle was not found", bnd);
    return new OsgiBundleResourcePatternResolver(bnd);
  }
View Full Code Here

   * @param bundle
   * @return
   * @throws Exception
   */
  private static Resource[] getBundleTagLibs(Bundle bundle) throws IOException {
    ResourcePatternResolver resolver = new OsgiBundleResourcePatternResolver(bundle);
    return resolver.getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + META_INF + "/**/" + TLD_PATTERN);
  }
View Full Code Here

TOP

Related Classes of org.springframework.osgi.io.OsgiBundleResourcePatternResolver

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.