本文整理匯總了Java中org.osgi.framework.Bundle.UNINSTALLED屬性的典型用法代碼示例。如果您正苦於以下問題:Java Bundle.UNINSTALLED屬性的具體用法?Java Bundle.UNINSTALLED怎麽用?Java Bundle.UNINSTALLED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.osgi.framework.Bundle
的用法示例。
在下文中一共展示了Bundle.UNINSTALLED屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findResources
@Override
public Enumeration<URL> findResources(String name) {
//Netigso.start();
Bundle b = bundle;
if (b == null) {
LOG.log(Level.WARNING, "Trying to load resource before initialization finished {0}", name);
return Enumerations.empty();
}
Enumeration ret = null;
try {
if (b.getState() != Bundle.UNINSTALLED) {
ret = b.getResources(name);
}
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
return ret == null ? Enumerations.<URL>empty() : NbCollections.checkedEnumerationByFilter(ret, URL.class, true);
}
示例2: getOSGiBundle
private Bundle getOSGiBundle(String symbolicName, BundleContext bcontext) {
ServiceReference<PackageAdmin> ref = bcontext.getServiceReference(PackageAdmin.class);
PackageAdmin packageAdmin = bcontext.getService(ref);
if (packageAdmin == null)
return null;
Bundle[] bundles = packageAdmin.getBundles(symbolicName, null);
if (bundles == null)
return null;
//Return the first bundle that is not installed or uninstalled
for (int i = 0; i < bundles.length; i++) {
if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
return bundles[i];
}
}
return null;
}
示例3: getOSGiBundle
private Bundle getOSGiBundle(String symbolicName) {
ServiceReference<PackageAdmin> ref = context.getBundleContext().getServiceReference(PackageAdmin.class);
PackageAdmin packageAdmin = context.getBundleContext().getService(ref);
if (packageAdmin == null)
return null;
Bundle[] bundles = packageAdmin.getBundles(symbolicName, null);
if (bundles == null)
return null;
//Return the first bundle that is not installed or uninstalled
for (int i = 0; i < bundles.length; i++) {
if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
return bundles[i];
}
}
return null;
}
示例4: testIsBundleResolved
public void testIsBundleResolved() throws Exception {
OsgiBundleUtilsTest.state = Bundle.UNINSTALLED;
assertFalse(OsgiBundleUtils.isBundleResolved(bundle));
OsgiBundleUtilsTest.state = Bundle.INSTALLED;
assertFalse(OsgiBundleUtils.isBundleResolved(bundle));
OsgiBundleUtilsTest.state = Bundle.ACTIVE;
assertTrue(OsgiBundleUtils.isBundleResolved(bundle));
OsgiBundleUtilsTest.state = Bundle.RESOLVED;
assertTrue(OsgiBundleUtils.isBundleResolved(bundle));
OsgiBundleUtilsTest.state = Bundle.STOPPING;
assertTrue(OsgiBundleUtils.isBundleResolved(bundle));
OsgiBundleUtilsTest.state = Bundle.STARTING;
assertTrue(OsgiBundleUtils.isBundleResolved(bundle));
}
示例5: findBundle
private Bundle findBundle(String bsn) {
Bundle found = null;
for (Bundle bundle : this.bundleContext.getBundles()) {
if (bsn.equals(bundle.getSymbolicName()) && bundle.getState() != Bundle.UNINSTALLED) {
if (found != null && bundle.getBundleId() != found.getBundleId()) {
throw new IllegalArgumentException("Ambiguous bundle symbolic name " + bsn);
}
found = bundle;
}
}
return found;
}
示例6: setUp
protected void setUp() throws Exception {
OsgiStringUtilsTest.state = Bundle.UNINSTALLED;
bundle = new MockBundle() {
public int getState() {
return state;
}
};
}
示例7: setUp
protected void setUp() throws Exception {
OsgiBundleUtilsTest.state = Bundle.UNINSTALLED;
bundle = new MockBundle() {
public int getState() {
return state;
}
};
}
示例8: createEntityManagerFactory
@Override
public EntityManagerFactory createEntityManagerFactory(Map<String, Object> props) {
synchronized (this) {
if (closed) {
throw new IllegalStateException("The EntityManagerFactoryBuilder for " +
getPUName() + " is no longer valid");
}
}
if (bundle.getState() == Bundle.UNINSTALLED || bundle.getState() == Bundle.INSTALLED
|| bundle.getState() == Bundle.STOPPING) {
// Not sure why but during the TCK tests updated sometimes was
// called for uninstalled bundles
throw new IllegalStateException("The EntityManagerFactoryBuilder for " +
getPUName() + " is no longer valid");
}
Map<String, Object> processedProperties = processProperties(props);
synchronized (this) {
if(processedProperties.equals(activeProps) && emf != null) {
return emf;
}
}
closeEMF();
final EntityManagerFactory toUse = createAndPublishEMF(processedProperties);
return (EntityManagerFactory) Proxy.newProxyInstance(getClass().getClassLoader(),
new Class<?>[] {EntityManagerFactory.class}, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if("close".equals(method.getName())) {
// Close the registration as per the spec
closeEMF();
// Do not delegate as the closeEMF call already closes
return null;
}
return method.invoke(toUse, args);
}
});
}
示例9: findProviders
@Override
public List<Capability> findProviders(Requirement requirement) {
List<Capability> resultCaps = new LinkedList<>();
// Find from installed bundles
Bundle[] bundles = this.bundleContext.getBundles();
for (Bundle bundle : bundles) {
if (bundle.getState() == Bundle.UNINSTALLED) {
continue; // Skip UNINSTALLED bundles
}
BundleRevision revision = bundle.adapt(BundleRevision.class);
List<Capability> bundleCaps = revision.getCapabilities(requirement.getNamespace());
if (bundleCaps != null) {
for (Capability bundleCap : bundleCaps) {
if (match(requirement, bundleCap, this.log)) {
resultCaps.add(bundleCap);
}
}
}
}
// Find from repositories
for (Entry<URI, Repository> repoEntry : this.repositories.entrySet()) {
Repository repository = repoEntry.getValue();
Map<Requirement, Collection<Capability>> providers = repository.findProviders(Collections.singleton(requirement));
if (providers != null) {
Collection<Capability> repoCaps = providers.get(requirement);
if (repoCaps != null) {
resultCaps.addAll(repoCaps);
for (Capability repoCap : repoCaps) {
// Get the list of physical URIs for this resource.
Resource resource = repoCap.getResource();
// Keep track of which repositories own which resources.
this.resourceRepositoryMap.putIfAbsent(resource, repository);
// Resolve the Resource's URI relative to the Repository Index URI and save for later.
URI repoIndexUri = repoEntry.getKey();
URI resolvedUri = resolveResourceLocation(resource, repoIndexUri);
if (resolvedUri != null) {
// Cache the resolved URI into the resource URI map, which will be used after resolve.
this.resourceLocationMap.put(resource, resolvedUri.toString());
}
}
}
}
}
return resultCaps;
}