本文整理了Java中org.osgi.framework.Bundle.getServicesInUse()
方法的一些代码示例,展示了Bundle.getServicesInUse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.getServicesInUse()
方法的具体详情如下:
包路径:org.osgi.framework.Bundle
类名称:Bundle
方法名:getServicesInUse
[英]Returns this bundle's ServiceReference list for all services it is using or returns null if this bundle is not using any services. A bundle is considered to be using a service if it has any unreleased service objects.
If the Java Runtime Environment supports permissions, a ServiceReference object to a service is included in the returned list only if the caller has the ServicePermission to get the service using at least one of the named classes the service was registered under.
The list is valid at the time of the call to this method, however, as the Framework is a very dynamic environment, services can be modified or unregistered at anytime.
[中]返回此捆绑包正在使用的所有服务的ServiceReference列表,如果此捆绑包未使用任何服务,则返回null。如果捆绑包有任何未发布的服务对象,则认为它正在使用服务。
如果Java运行时环境支持权限,则仅当调用方具有ServicePermission,可以使用服务注册时使用的至少一个命名类获取服务时,服务的ServiceReference对象才会包含在返回的列表中。
该列表在调用此方法时有效,但是,由于框架是一个非常动态的环境,因此可以随时修改或取消注册服务。
代码示例来源:origin: org.eclipse/org.eclipse.osgi
public ServiceReference<?>[] getServicesInUse() {
Bundle current = systemBundle;
if (current == null)
return null;
return current.getServicesInUse();
}
代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.osgi
public ServiceReference<?>[] getServicesInUse() {
Bundle current = systemBundle;
if (current == null)
return null;
return current.getServicesInUse();
}
代码示例来源:origin: org.apache.felix/org.apache.felix.connect
public ServiceReference[] getServicesInUse()
{
return m_bundle.getServicesInUse();
}
代码示例来源:origin: org.jboss.osgi/jboss-osgi-spi
public ServiceReference[] getServicesInUse()
{
return bundle.getServicesInUse();
}
代码示例来源:origin: apache/felix
public ServiceReference[] getServicesInUse()
{
return m_bundle.getServicesInUse();
}
代码示例来源:origin: org.apache.xbean/xbean-bundleutils
public ServiceReference[] getServicesInUse() {
return bundle.getServicesInUse();
}
代码示例来源:origin: org.ops4j.pax.cdi/pax-cdi-weld
public ServiceReference[] getServicesInUse() {
return bundle.getServicesInUse();
}
代码示例来源:origin: org.apache.felix/org.apache.felix.webconsole
public BundleInfo[] getBundleInfo( Bundle bundle, String webConsoleRoot, Locale locale )
{
final ServiceReference[] refs = bundle.getServicesInUse();
if ( null == refs || refs.length == 0 )
return NO_INFO;
BundleInfo[] ret = new BundleInfo[refs.length];
for ( int i = 0; i < refs.length; i++ )
{
ret[i] = toInfo( refs[i], webConsoleRoot, locale );
}
return ret;
}
代码示例来源:origin: apache/felix
public BundleInfo[] getBundleInfo( Bundle bundle, String webConsoleRoot, Locale locale )
{
final ServiceReference[] refs = bundle.getServicesInUse();
if ( null == refs || refs.length == 0 )
return NO_INFO;
BundleInfo[] ret = new BundleInfo[refs.length];
for ( int i = 0; i < refs.length; i++ )
{
ret[i] = toInfo( refs[i], webConsoleRoot, locale );
}
return ret;
}
代码示例来源:origin: apache/felix
public String[] getServicesInUse() {
return InstrumentationSupport.getServiceNames(bundle.getServicesInUse());
}
/* (non-Javadoc)
代码示例来源:origin: apache/karaf
static boolean printServiceRequirements(Bundle b) {
boolean matches = false;
try {
ServiceReference<?>[] refs = b.getServicesInUse();
if ((refs != null) && (refs.length > 0)) {
matches = true;
// Print properties for each service.
for (ServiceReference<?> ref : refs) {
// Print object class with "namespace".
System.out.println(
NONSTANDARD_SERVICE_NAMESPACE
+ "; "
+ ShellUtil.getValueString(ref.getProperty("objectClass"))
+ " provided by:");
System.out.println(" " + ref.getBundle());
}
}
} catch (Exception ex) {
System.err.println(ex.toString());
}
return matches;
}
代码示例来源:origin: apache/felix
/**
* a driver bundle is idle if it isn't connected to a device bundle.
*
* @return
*/
private boolean isInUse()
{
ServiceReference[] used = m_bundle.getServicesInUse();
if ( used == null || used.length == 0 )
{
return false;
}
for ( ServiceReference ref : used )
{
if ( Util.isDevice( ref ) )
{
return true;
}
}
return false;
}
代码示例来源:origin: org.apache.karaf.bundle/org.apache.karaf.bundle.core
static boolean printServiceRequirements(Bundle b) {
boolean matches = false;
try {
ServiceReference<?>[] refs = b.getServicesInUse();
if ((refs != null) && (refs.length > 0)) {
matches = true;
// Print properties for each service.
for (ServiceReference<?> ref : refs) {
// Print object class with "namespace".
System.out.println(
NONSTANDARD_SERVICE_NAMESPACE
+ "; "
+ ShellUtil.getValueString(ref.getProperty("objectClass"))
+ " provided by:");
System.out.println(" " + ref.getBundle());
}
}
} catch (Exception ex) {
System.err.println(ex.toString());
}
return matches;
}
代码示例来源:origin: apache/felix
static boolean printServiceRequirements(Bundle b, Formatter f)
{
boolean matches = false;
try
{
ServiceReference<?>[] refs = b.getServicesInUse();
if ((refs != null) && (refs.length > 0))
{
matches = true;
// Print properties for each service.
for (ServiceReference<?> ref : refs)
{
// Print object class with "namespace".
f.format("%s; %s provided by:%n %s%n",
NONSTANDARD_SERVICE_NAMESPACE,
Util.getValueString(ref.getProperty("objectClass")),
ref.getBundle());
}
}
}
catch (Exception ex)
{
System.err.println(ex.toString());
}
return matches;
}
代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.osgi
@Override
protected void doExecute(List<Bundle> bundles) throws Exception {
for (Bundle bundle : bundles) {
ServiceReference[] refs = (inUse) ? bundle.getServicesInUse() : bundle.getRegisteredServices();
printServices(bundle, refs, showProperties);
}
}
代码示例来源:origin: apache/karaf
@Override
protected void executeOnBundle(Bundle bundle) throws Exception {
ServiceReference<?>[] refs = (inUse) ? bundle.getServicesInUse() : bundle.getRegisteredServices();
printServices(bundle, refs, showProperties);
}
代码示例来源:origin: org.apache.karaf.bundle/org.apache.karaf.bundle.core
@Override
protected void executeOnBundle(Bundle bundle) throws Exception {
ServiceReference<?>[] refs = (inUse) ? bundle.getServicesInUse() : bundle.getRegisteredServices();
printServices(bundle, refs, showProperties);
}
代码示例来源:origin: org.apache.geronimo.plugins/console-base-portlets
private List<ServicePerspective> getUsingServicePerspectives(Bundle bundle){
ServiceReference[] serviceRefs = bundle.getServicesInUse();
List<ServicePerspective> usingServicePerspectives = new ArrayList<ServicePerspective>();
if (serviceRefs != null && serviceRefs.length!=0){
for (ServiceReference ref : serviceRefs){
ServiceInfo info = new ServiceInfo(ref);
ServicePerspective perspective = new ServicePerspective(info);
perspective.addBundleInfo(new SimpleBundleInfo(ref.getBundle()));
usingServicePerspectives.add(perspective);
}
}
return usingServicePerspectives;
}
代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.osgi
refs = bundle.getServicesInUse();
} else {
refs = bundle.getRegisteredServices();
代码示例来源:origin: com.atlassian.plugin.rest/atlassian-rest-plugin-manager-plugin
private OsgiBundleDetails expandOsgiBundleDetails(OsgiBundleDetails details, UriBuilder bundleUriBuilder, Bundle bundle)
{
details.setRegisteredServices(getOsgiServices(bundleUriBuilder, bundle.getRegisteredServices()));
details.setUsedServices(getOsgiServices(bundleUriBuilder, bundle.getServicesInUse()));
details.setExportedPackages(new OsgiPackagesAttributesValueParser().parseValue(Constants.EXPORT_PACKAGE, (String) bundle.getHeaders().get(Constants.EXPORT_PACKAGE)));
details.setImportedPackages(new OsgiPackagesAttributesValueParser().parseValue(Constants.IMPORT_PACKAGE, (String) bundle.getHeaders().get(Constants.IMPORT_PACKAGE)));
details.setPrivatePackages(new OsgiPackagesAttributesValueParser().parseValue("Private-Package", (String) bundle.getHeaders().get("Private-Package")));
return details;
}
内容来源于网络,如有侵权,请联系作者删除!