本文整理匯總了Java中org.osgi.framework.wiring.BundleWiring.getClassLoader方法的典型用法代碼示例。如果您正苦於以下問題:Java BundleWiring.getClassLoader方法的具體用法?Java BundleWiring.getClassLoader怎麽用?Java BundleWiring.getClassLoader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.osgi.framework.wiring.BundleWiring
的用法示例。
在下文中一共展示了BundleWiring.getClassLoader方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processClass
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
@Override
public byte[] processClass(String className, byte[] bytes, ClasspathEntry ce, BundleEntry be, ClasspathManager cm) {
final BaseData bd = ce.getBaseData();
if (bd == null) {
return bytes;
}
final Bundle b = bd.getBundle();
if (b == null) {
return bytes;
}
BundleWiring w = b.adapt(org.osgi.framework.wiring.BundleWiring.class);
if (w == null) {
return bytes;
}
ClassLoader loader = w.getClassLoader();
return archive.patchByteCode(loader, className, ce.getDomain(), bytes);
}
示例2: weave
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
@Override
public void weave(WovenClass wovenClass) {
BundleWiring wiring = wovenClass.getBundleWiring();
Bundle bundle = wiring.getBundle();
ClassLoader cl = wiring.getClassLoader();
Collection<ClassTransformer> transformersToTry = getTransformers(bundle);
for (ClassTransformer transformer : transformersToTry) {
if (transformClass(wovenClass, cl, transformer)) {
LOGGER.info("Weaving " + wovenClass.getClassName() + " using " + transformer.getClass().getName());
break;
}
}
Class<?> dClass = wovenClass.getDefinedClass();
if (transformersToTry.isEmpty() && dClass != null && dClass.getAnnotation(Entity.class) != null) {
LOGGER.warn("Loading " + wovenClass.getClassName() + " before transformer is present");
}
}
示例3: addingService
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
@Override
public ServiceTracker
<CXFJaxRsServiceRegistrator, ?>
addingService(ServiceReference<Object> reference) {
String applicationSelector =
reference.getProperty("jaxrs.application.select").toString();
Bundle bundle = reference.getBundle();
BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
ClassLoader classLoader = bundleWiring.getClassLoader();
Object service = _bundleContext.getService(reference);
try {
Filter filter = _bundleContext.createFilter(
"(&(objectClass=" + CXFJaxRsServiceRegistrator.class.getName() +
")" + applicationSelector + ")");
ServiceTracker
<CXFJaxRsServiceRegistrator, ?>
serviceTracker = new ServiceTracker<>(
_bundleContext, filter,
new AddonsServiceTrackerCustomizer(
_bundleContext, classLoader, service));
serviceTracker.open();
return serviceTracker;
}
catch (InvalidSyntaxException ise) {
_bundleContext.ungetService(reference);
throw new RuntimeException(ise);
}
}
示例4: createBus
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
private ExtensionManagerBus createBus() {
BundleWiring wiring = _bundleContext.getBundle().adapt(
BundleWiring.class);
@SuppressWarnings("unchecked")
Map<String, Object> properties = new HashMap<>(_configurationMap);
ExtensionManagerBus bus = new ExtensionManagerBus(
null, properties, wiring.getClassLoader());
bus.initialize();
return bus;
}
示例5: unregisterBundleJDOClasses
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
/**
* Unregisters all entity classes registered to JDO that are accessible from bundle class loader. This method
* should be called after bundle that registers MDS entities gets unresolved, so that they are removed from
* JDO cache. Not doing this might produce hard to track exception when refreshing MDS Entities Bundle after
* bundle removal.
*
* @param bundle the bundle for which entity classes are to be unregistered
*/
public static void unregisterBundleJDOClasses(Bundle bundle) {
BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
if (null == bundleWiring) {
LOGGER.warn("Cannot unregister JDO entity classes: bundle wiring for {} bundle is unavailable.",
bundle.getSymbolicName());
} else {
ClassLoader bundleClassLoader = bundleWiring.getClassLoader();
getJDOImplHelper().unregisterClasses(bundleClassLoader);
LOGGER.info("Unregistered JDO entity classes for bundle {}.", bundle.getSymbolicName());
}
}
示例6: getClassLoader
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
@Override
public ClassLoader getClassLoader(String componentName, String componentVersion,
ComponentReference componentReference) {
Bundle bundle = getBundle(componentName, componentVersion, componentReference);
BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
return bundleWiring.getClassLoader();
}
示例7: getBundleClassLoader
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
private ClassLoader getBundleClassLoader() {
BundleContext bundleContext = FrameworkUtil.getBundle(Main.class).getBundleContext();
Bundle bundle = bundleContext.getBundle();
BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
ClassLoader classLoader = bundleWiring.getClassLoader();
return classLoader;
}
示例8: installModule
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
private Module installModule(Bundle bundle) {
Module module = getModule(bundle.getBundleId());
if (module != null)
return module;
BundleWiring wiring = bundle.adapt(BundleWiring.class);
ClassLoader classLoader = wiring != null ? wiring.getClassLoader() : null;
if (classLoader == null)
return null;
Resource resource = ThreadResourceAssociation.getResource();
Dictionary<String, String> headers = bundle.getHeaders();
if (resource == null) {
ResourceBuilder builder = new DictionaryResourceBuilder().load(headers);
if (builder.isValid() == false) {
String symbolicName = bundle.getSymbolicName();
String version = bundle.getVersion().toString();
builder.addIdentityCapability(symbolicName, version);
}
resource = builder.getResource();
}
try {
module = installModule(classLoader, resource, headers);
} catch (ModuleException ex) {
LOGGER.error("Cannot install module from: " + bundle, ex);
}
return module;
}
示例9: getBundleLoader
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
private static ClassLoader getBundleLoader(String name) {
Bundle bundle = Platform.getBundle(name);
BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
return bundleWiring.getClassLoader();
}
示例10: toClassLoader
import org.osgi.framework.wiring.BundleWiring; //導入方法依賴的package包/類
@Override
public ClassLoader toClassLoader() {
final Bundle bundle = this.context.getBundle();
final BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
return bundleWiring.getClassLoader();
}