當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。