当前位置: 首页>>代码示例>>Java>>正文


Java FrameworkUtil.createFilter方法代码示例

本文整理汇总了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 () );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:FilterUtil.java

示例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();
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:20,代码来源:InstallerIntegrationTest.java

示例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();
}
 
开发者ID:fassmus,项目名称:liferay-devcon-2016-hystrix,代码行数:30,代码来源:LiferayHystrixMetricsStreamServlet.java

示例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);
}
 
开发者ID:apache,项目名称:aries-jax-rs-whiteboard,代码行数:24,代码来源:TargetFilter.java

示例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 () );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:16,代码来源:FilterUtil.java

示例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;
	}
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:33,代码来源:PluginResolveContext.java

示例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);
        }
    };
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:8,代码来源:OsgiFilterUtilsTest.java

示例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));
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:8,代码来源:Activator.java

示例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));
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:15,代码来源:ListenerHookImplTest.java

示例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;
    }
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:14,代码来源:LocalDiscovery.java

示例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;
    }
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:14,代码来源:ConfigDiscovery.java

示例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();
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:33,代码来源:DistributionProviderTrackerTest.java

示例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();
}
 
开发者ID:liferay-labs,项目名称:arquillian-liferay,代码行数:29,代码来源:LiferayWaitForServiceBuilderObserver.java

示例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);

}
 
开发者ID:osgi,项目名称:osgi.enroute.examples.jdbc,代码行数:28,代码来源:BootstrapTest.java

示例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 ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:5,代码来源:FilterUtil.java


注:本文中的org.osgi.framework.FrameworkUtil.createFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。