org.apache.struts2.osgi
Class DefaultBundleAccessor

java.lang.Object
  extended by org.apache.struts2.osgi.DefaultBundleAccessor
All Implemented Interfaces:
BundleAccessor

public class DefaultBundleAccessor
extends java.lang.Object
implements BundleAccessor

Helper class that find resources and loads classes from the list of bundles


Field Summary
 
Fields inherited from interface org.apache.struts2.osgi.BundleAccessor
CURRENT_BUNDLE_NAME
 
Constructor Summary
DefaultBundleAccessor()
           
 
Method Summary
 void addPackageFromBundle(org.osgi.framework.Bundle bundle, java.lang.String packageName)
          Add as Bundle -> Package mapping
 org.osgi.framework.ServiceReference[] getAllServiceReferences(java.lang.String className)
           
static DefaultBundleAccessor getInstance()
           
 java.util.Set<java.lang.String> getPackagesByBundle(org.osgi.framework.Bundle bundle)
           
 java.lang.Object getService(org.osgi.framework.ServiceReference ref)
           
 org.osgi.framework.ServiceReference getServiceReference(java.lang.String className)
           
 org.osgi.framework.ServiceReference[] getServiceReferences(java.lang.String className, java.lang.String params)
           
 java.lang.Class<?> loadClass(java.lang.String className)
           
 java.net.URL loadResource(java.lang.String name)
           
 java.net.URL loadResource(java.lang.String name, boolean translate)
           
 java.io.InputStream loadResourceAsStream(java.lang.String name)
           
 java.net.URL loadResourceFromAllBundles(java.lang.String name)
           
 java.io.InputStream loadResourceFromAllBundlesAsStream(java.lang.String name)
           
 java.util.List<java.net.URL> loadResources(java.lang.String name)
           
 java.util.List<java.net.URL> loadResources(java.lang.String name, boolean translate)
           
 void setBundleContext(org.osgi.framework.BundleContext bundleContext)
           
 void setOsgiHost(OsgiHost osgiHost)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultBundleAccessor

public DefaultBundleAccessor()
Method Detail

getInstance

public static DefaultBundleAccessor getInstance()

getService

public java.lang.Object getService(org.osgi.framework.ServiceReference ref)
Specified by:
getService in interface BundleAccessor

getServiceReference

public org.osgi.framework.ServiceReference getServiceReference(java.lang.String className)
Specified by:
getServiceReference in interface BundleAccessor

getAllServiceReferences

public org.osgi.framework.ServiceReference[] getAllServiceReferences(java.lang.String className)
Specified by:
getAllServiceReferences in interface BundleAccessor

getServiceReferences

public org.osgi.framework.ServiceReference[] getServiceReferences(java.lang.String className,
                                                                  java.lang.String params)
                                                           throws org.osgi.framework.InvalidSyntaxException
Specified by:
getServiceReferences in interface BundleAccessor
Throws:
org.osgi.framework.InvalidSyntaxException

addPackageFromBundle

public void addPackageFromBundle(org.osgi.framework.Bundle bundle,
                                 java.lang.String packageName)
Add as Bundle -> Package mapping

Specified by:
addPackageFromBundle in interface BundleAccessor
Parameters:
bundle - the bundle where the package was loaded from
packageName - the anme of the loaded package

loadClass

public java.lang.Class<?> loadClass(java.lang.String className)
                             throws java.lang.ClassNotFoundException
Specified by:
loadClass in interface BundleAccessor
Throws:
java.lang.ClassNotFoundException

loadResources

public java.util.List<java.net.URL> loadResources(java.lang.String name)
                                           throws java.io.IOException
Throws:
java.io.IOException

loadResources

public java.util.List<java.net.URL> loadResources(java.lang.String name,
                                                  boolean translate)
                                           throws java.io.IOException
Throws:
java.io.IOException

loadResourceFromAllBundles

public java.net.URL loadResourceFromAllBundles(java.lang.String name)
                                        throws java.io.IOException
Specified by:
loadResourceFromAllBundles in interface BundleAccessor
Throws:
java.io.IOException

loadResourceFromAllBundlesAsStream

public java.io.InputStream loadResourceFromAllBundlesAsStream(java.lang.String name)
                                                       throws java.io.IOException
Specified by:
loadResourceFromAllBundlesAsStream in interface BundleAccessor
Throws:
java.io.IOException

loadResource

public java.net.URL loadResource(java.lang.String name)

loadResource

public java.net.URL loadResource(java.lang.String name,
                                 boolean translate)

getPackagesByBundle

public java.util.Set<java.lang.String> getPackagesByBundle(org.osgi.framework.Bundle bundle)
Specified by:
getPackagesByBundle in interface BundleAccessor

loadResourceAsStream

public java.io.InputStream loadResourceAsStream(java.lang.String name)
                                         throws java.io.IOException
Specified by:
loadResourceAsStream in interface BundleAccessor
Throws:
java.io.IOException

setBundleContext

public void setBundleContext(org.osgi.framework.BundleContext bundleContext)
Specified by:
setBundleContext in interface BundleAccessor

setOsgiHost

public void setOsgiHost(OsgiHost osgiHost)
Specified by:
setOsgiHost in interface BundleAccessor


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.