本文整理汇总了Java中org.osgi.framework.FrameworkUtil.createFilter方法的典型用法代码示例。如果您正苦于以下问题:Java FrameworkUtil.createFilter方法的具体用法?Java FrameworkUtil.createFilter怎么用?Java FrameworkUtil.createFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osgi.framework.FrameworkUtil
的用法示例。
在下文中一共展示了FrameworkUtil.createFilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFilter
import org.osgi.framework.FrameworkUtil; //导入方法依赖的package包/类
protected static Filter createFilter ( final String operand, final Filter... filters ) throws InvalidSyntaxException
{
final StringBuilder sb = new StringBuilder ();
sb.append ( "(" );
sb.append ( operand );
for ( final Filter filter : filters )
{
sb.append ( filter.toString () );
}
sb.append ( ")" );
return FrameworkUtil.createFilter ( sb.toString () );
}
示例2: before
import org.osgi.framework.FrameworkUtil; //导入方法依赖的package包/类
@Before
public void before() throws Exception {
assertAllBundlesResolved();
// Track ArtifactInstaller service ONLY from bundle org.osc.installer
Bundle installerBundle = findBundle("osc-installer");
Filter artifactInstallerTrackerFilter = FrameworkUtil.createFilter(String.format("(&(objectClass=%s)(service.bundleid=%d))", ArtifactInstaller.class.getName(), installerBundle.getBundleId()));
this.artifactInstallerTracker = new ServiceTracker<>(this.bundleContext, artifactInstallerTrackerFilter, null);
this.artifactInstallerTracker.open();
// Wait up to 5 seconds for ArtifactInstaller to appear
ArtifactInstaller artifactInstaller = this.artifactInstallerTracker.waitForService(5000);
if (artifactInstaller == null) {
fail("ArtifactInstaller service not available within 5 seconds");
}
this.fwkInstallerTracker = new ServiceTracker<>(this.bundleContext, FrameworkInstaller.class, null);
this.fwkInstallerTracker.open();
}
示例3: activate
import org.osgi.framework.FrameworkUtil; //导入方法依赖的package包/类
/**
* OSGi component lifecycle listener for actication and modification of this
* service.
*
* @param componentContext
* OSGi component context.
* @param properties
* OSGi configuration properties.
* @throws Exception
* is thrown if the activation or modification of the service
* goes wrong.
*/
@Activate
@Modified
protected void activate(ComponentContext componentContext, Map<String, Object> properties) throws Exception {
// Check if a service tracker for the context path exists and close it.
if (_serviceTracker != null) {
_serviceTracker.close();
}
// Create a filter for ServletContext components and start tracking.
Filter filter = FrameworkUtil
.createFilter("(&(objectClass=" + ServletContext.class.getName() + ")(osgi.web.contextpath=*))");
_serviceTracker = new ServiceTracker<>(componentContext.getBundleContext(), filter, this);
_serviceTracker.open();
}
示例4: test
import org.osgi.framework.FrameworkUtil; //导入方法依赖的package包/类
@Override
public boolean test(CachingServiceReference<T> ref) {
String target = (String)ref.getProperty(JAX_RS_WHITEBOARD_TARGET);
if (target == null) {
return true;
}
Filter filter;
try {
filter = FrameworkUtil.createFilter(target);
}
catch (InvalidSyntaxException ise) {
if (_log.isErrorEnabled()) {
_log.error("Invalid '{}' filter syntax in {}", JAX_RS_WHITEBOARD_TARGET, ref);
}
return false;
}
return filter.match(_serviceRuntimeReference);
}
示例5: createSimpleOr
import org.osgi.framework.FrameworkUtil; //导入方法依赖的package包/类
public static Filter createSimpleOr ( final String attribute, final Set<String> values ) throws InvalidSyntaxException
{
final StringBuilder sb = new StringBuilder ();
sb.append ( "(|" );
for ( final String value : values )
{
addPair ( sb, attribute, value );
}
sb.append ( ")" );
return FrameworkUtil.createFilter ( sb.toString () );
}
示例6: match
import org.osgi.framework.FrameworkUtil; //导入方法依赖的package包/类
static boolean match(Requirement requirement, Capability capability, LogService log) {
// Namespace MUST match
if (!requirement.getNamespace().equals(capability.getNamespace())) {
return false;
}
// If capability effective!=resolve then it matches only requirements with same effective
String capabilityEffective = capability.getDirectives().get(Namespace.CAPABILITY_EFFECTIVE_DIRECTIVE);
if (capabilityEffective != null) {
String requirementEffective = requirement.getDirectives().get(Namespace.REQUIREMENT_EFFECTIVE_DIRECTIVE);
if (!capabilityEffective.equals(Namespace.EFFECTIVE_RESOLVE) && !capabilityEffective.equals(requirementEffective)) {
return false;
}
}
String filterStr = requirement.getDirectives().get(Namespace.REQUIREMENT_FILTER_DIRECTIVE);
if (filterStr == null) {
return true; // no filter, the requirement always matches
}
try {
Filter filter = FrameworkUtil.createFilter(filterStr);
return filter.matches(capability.getAttributes());
} catch (InvalidSyntaxException e) {
if (log != null) {
Resource resource = requirement.getResource();
String id = resource != null ? getIdentity(resource) : "<unknown>";
log.log(LogService.LOG_ERROR, String.format("Invalid filter syntax in requirement from resource %s: %s", id, filterStr), e);
}
return false;
}
}
示例7: getBundleContext
import org.osgi.framework.FrameworkUtil; //导入方法依赖的package包/类
protected BundleContext getBundleContext() {
return new MockBundleContext() {
public Filter createFilter(String filter) throws InvalidSyntaxException {
return FrameworkUtil.createFilter(filter);
}
};
}
示例8: exportPolicyFilter
import org.osgi.framework.FrameworkUtil; //导入方法依赖的package包/类
private Filter exportPolicyFilter(BundleContext bc) throws InvalidSyntaxException {
String filter = bc.getProperty(RSA_EXPORT_POLICY_FILTER);
if (filter == null) {
filter = "(name=default)";
}
return FrameworkUtil.createFilter(String.format("(&(objectClass=%s)%s)", ExportPolicy.class.getName(), filter));
}
示例9: testExtendFilter
import org.osgi.framework.FrameworkUtil; //导入方法依赖的package包/类
@Test
public void testExtendFilter() throws InvalidSyntaxException {
String filter = "(a=b)";
BundleContext bc = createBundleContext();
filter = new ListenerHookImpl(bc, null).extendFilter(filter);
Filter f = FrameworkUtil.createFilter(filter);
Dictionary<String, String> m = new Hashtable<String, String>();
m.put("a", "b");
assertTrue(filter + " filter must match as uuid is missing", f.match(m));
m.put(RemoteConstants.ENDPOINT_FRAMEWORK_UUID, "MyUUID");
assertFalse(filter + " filter must NOT match as uuid is the local one", f.match(m));
}
示例10: matchFilter
import org.osgi.framework.FrameworkUtil; //导入方法依赖的package包/类
private static boolean matchFilter(String filter, EndpointDescription endpoint) {
if (filter == null) {
return false;
}
try {
Filter f = FrameworkUtil.createFilter(filter);
Dictionary<String, Object> dict = new Hashtable<String, Object>(endpoint.getProperties());
return f.match(dict);
} catch (Exception e) {
return false;
}
}
示例11: matchFilter
import org.osgi.framework.FrameworkUtil; //导入方法依赖的package包/类
private static boolean matchFilter(String filter, EndpointDescription endpoint) {
if (filter == null) {
return false;
}
try {
Filter f = FrameworkUtil.createFilter(filter);
Dictionary<String, Object> dict = new Hashtable<>(endpoint.getProperties());
return f.match(dict);
} catch (Exception e) {
return false;
}
}
示例12: testAddingWithNullValues
import org.osgi.framework.FrameworkUtil; //导入方法依赖的package包/类
@Test
public void testAddingWithNullValues() throws InvalidSyntaxException {
IMocksControl c = EasyMock.createControl();
DistributionProvider provider = c.createMock(DistributionProvider.class);
ServiceReference<DistributionProvider> providerRef = c.createMock(ServiceReference.class);
EasyMock.expect(providerRef.getProperty(RemoteConstants.REMOTE_INTENTS_SUPPORTED)).andReturn(null);
EasyMock.expect(providerRef.getProperty(RemoteConstants.REMOTE_CONFIGS_SUPPORTED)).andReturn(null);
BundleContext context = c.createMock(BundleContext.class);
String filterSt = String.format("(objectClass=%s)", DistributionProvider.class.getName());
Filter filter = FrameworkUtil.createFilter(filterSt);
EasyMock.expect(context.createFilter(filterSt)).andReturn(filter);
EasyMock.expect(context.getService(providerRef)).andReturn(provider);
ServiceRegistration rsaReg = c.createMock(ServiceRegistration.class);
EasyMock.expect(context.registerService(EasyMock.isA(String.class), EasyMock.isA(ServiceFactory.class),
EasyMock.isA(Dictionary.class)))
.andReturn(rsaReg).atLeastOnce();
context.addServiceListener(EasyMock.isA(ServiceListener.class), EasyMock.isA(String.class));
EasyMock.expectLastCall();
final BundleContext apiContext = c.createMock(BundleContext.class);
c.replay();
DistributionProviderTracker tracker = new DistributionProviderTracker(context) {
protected BundleContext getAPIContext() {
return apiContext;
};
};
tracker.addingService(providerRef);
c.verify();
}
示例13: execute
import org.osgi.framework.FrameworkUtil; //导入方法依赖的package包/类
public void execute(@Observes(precedence = Integer.MAX_VALUE)
EventContext<BeforeSuite> event) throws InvalidSyntaxException {
Bundle bundle = FrameworkUtil.getBundle(getClass());
BundleContext bundleContext = bundle.getBundleContext();
Filter filter = FrameworkUtil.createFilter(
"(&(objectClass=org.springframework.context.ApplicationContext)" +
"(org.springframework.context.service.name=" +
bundle.getSymbolicName() + "))");
ServiceTracker<ApplicationContext, ApplicationContext> serviceTracker =
new ServiceTracker<>(bundleContext, filter, null);
serviceTracker.open();
try {
serviceTracker.waitForService(30 * 1000L);
}
catch (InterruptedException ie) {
throw new RuntimeException(ie);
}
serviceTracker.close();
event.proceed();
}
示例14: setUp
import org.osgi.framework.FrameworkUtil; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Before
public void setUp() throws Exception{
configAdmin = (ConfigurationAdmin) cmTracker.waitForService(5000);
assertNotNull(configAdmin);
assertNotNull(txServiceProps.getProperty("aries.dsf.target.filter"));
Filter dsfFilter = FrameworkUtil.createFilter("(&("+
Constants.OBJECTCLASS + "="+DataSourceFactory.class.getName()+")"+txServiceProps.getProperty("aries.dsf.target.filter")+")");
dsfTracker = new ServiceTracker<>(context,dsfFilter, null);
dsfTracker.open();
Filter cpFilter = FrameworkUtil.createFilter("(&("+
Constants.OBJECTCLASS+"="+JDBCConnectionProvider.class.getName()+")"
+ "(dataSourceName=addressBookDS)"
+")");
cpTracker = new ServiceTracker<>(context, cpFilter, null);
cpTracker.open();
localJDBCProviderConfig = configAdmin.createFactoryConfiguration(FACTORY_PID_ARIES_TX_CONTROL_JDBC_LOCAL,null);
localJDBCProviderConfig.update((Hashtable)txServiceProps);
}
示例15: createClassFilter
import org.osgi.framework.FrameworkUtil; //导入方法依赖的package包/类
public static Filter createClassFilter ( final String clazz ) throws InvalidSyntaxException
{
return FrameworkUtil.createFilter ( String.format ( "(%s=%s)", Constants.OBJECTCLASS, clazz ) );
}