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


Java Filter类代码示例

本文整理汇总了Java中org.osgi.framework.Filter的典型用法代码示例。如果您正苦于以下问题:Java Filter类的具体用法?Java Filter怎么用?Java Filter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Filter类属于org.osgi.framework包,在下文中一共展示了Filter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createFilter

import org.osgi.framework.Filter; //导入依赖的package包/类
private static Filter createFilter(BundleContext context, PersistenceUnit punit) {
    String filter;
    if (punit.getPersistenceProviderClassName() != null) {
        filter = String.format("(&(objectClass=%s)(%s=%s))",
                               PersistenceProvider.class.getName(),
                               JAVAX_PERSISTENCE_PROVIDER,
                               punit.getPersistenceProviderClassName());
    } else {
        filter = String.format("(objectClass=%s)", PersistenceProvider.class.getName());
    }

    try {
        return context.createFilter(filter);
    } catch (InvalidSyntaxException e) {
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:18,代码来源:PersistenceProviderTracker.java

示例2: createFilter

import org.osgi.framework.Filter; //导入依赖的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

示例3: createFilter

import org.osgi.framework.Filter; //导入依赖的package包/类
protected Filter createFilter ()
{
    try
    {
        Class<?> filterClazz;
        if ( this.clazz != null )
        {
            filterClazz = this.clazz;
        }
        else
        {
            filterClazz = ConnectionService.class;
        }

        return FilterUtil.createAndFilter ( filterClazz.getName (), createFilterParameters () );
    }
    catch ( final InvalidSyntaxException e )
    {
        logger.warn ( "Failed to create filter", e );
        return null;
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:23,代码来源:ConnectionTracker.java

示例4: EventServiceImpl

import org.osgi.framework.Filter; //导入依赖的package包/类
public EventServiceImpl ( final BundleContext context ) throws InvalidSyntaxException
{
    this.context = context;

    this.storeListener = new StoreListener () {

        @Override
        public void notify ( final Event event )
        {
            EventServiceImpl.this.eventStored ( event );
        }
    };

    final Filter filter = FilterUtil.createClassFilter ( Storage.class.getName () );
    this.storageTracker = new SingleServiceTracker<Storage> ( this.context, filter, new SingleServiceListener<Storage> () {

        @Override
        public void serviceChange ( final ServiceReference<Storage> reference, final Storage service )
        {
            setStorage ( service );
        }
    } );
    this.storageTracker.open ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:25,代码来源:EventServiceImpl.java

示例5: before

import org.osgi.framework.Filter; //导入依赖的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

示例6: sendInitialBootstrappingEvents

import org.osgi.framework.Filter; //导入依赖的package包/类
private void sendInitialBootstrappingEvents(Set<MandatoryServiceDependency> deps) {
	// send the fine grained event
	List<OsgiServiceDependencyEvent> events = getUnsatisfiedDependenciesAsEvents(deps);
	for (OsgiServiceDependencyEvent nestedEvent : events) {
		BootstrappingDependencyEvent dependencyEvent =
				new BootstrappingDependencyEvent(context, context.getBundle(), nestedEvent);
		publishEvent(dependencyEvent);
	}

	// followed by the composite one
	String filterAsString = createDependencyFilter(deps);
	Filter filter = (filterAsString != null ? OsgiFilterUtils.createFilter(filterAsString) : null);
	BootstrappingDependenciesEvent event =
			new BootstrappingDependenciesEvent(context, context.getBundle(), events, filter, waitTime);

	publishEvent(event);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:18,代码来源:DependencyServiceManager.java

示例7: BootstrappingDependenciesEvent

import org.osgi.framework.Filter; //导入依赖的package包/类
/**
 * Constructs a new <code>BootstrappingDependencyEvent</code> instance.
 * 
 * @param source
 */
public BootstrappingDependenciesEvent(ApplicationContext source, Bundle bundle,
		Collection<OsgiServiceDependencyEvent> nestedEvents, Filter filter, long timeLeft) {
	super(source, bundle);
	Assert.notNull(nestedEvents);
	this.dependencyEvents = nestedEvents;
	this.dependenciesFilter = filter;
	this.timeLeft = timeLeft;

	List<String> depFilters = new ArrayList<String>(dependencyEvents.size());

	for (OsgiServiceDependencyEvent dependency : nestedEvents) {
		depFilters.add(dependency.getServiceDependency().getServiceFilter().toString());
	}

	dependencyFilters = Collections.unmodifiableCollection(depFilters);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:22,代码来源:BootstrappingDependenciesEvent.java

示例8: DefaultOsgiServiceDependency

import org.osgi.framework.Filter; //导入依赖的package包/类
/**
 * Constructs a new <code>DefaultOsgiServiceDependency</code> instance.
 * 
 * @param beanName dependency bean name (can be null)
 * @param filter dependency OSGi filter (can be null)
 * @param mandatoryService flag indicating whether the dependency is
 * mandatory or not
 */
public DefaultOsgiServiceDependency(String beanName, Filter filter, boolean mandatoryService) {
	this.beanName = beanName;
	this.filter = filter;
	this.mandatoryService = mandatoryService;

	// calculate internal fields
	toString = "DependencyService[Name=" + (beanName != null ? beanName : "null") + "][Filter=" + filter
			+ "][Mandatory=" + mandatoryService + "]";

	int result = 17;
	result = 37 * result + DefaultOsgiServiceDependency.class.hashCode();
	result = 37 * result + (filter == null ? 0 : filter.hashCode());
	result = 37 * result + (beanName == null ? 0 : beanName.hashCode());
	result = 37 * result + (mandatoryService ? 0 : 1);
	hashCode = result;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:25,代码来源:DefaultOsgiServiceDependency.java

示例9: activate

import org.osgi.framework.Filter; //导入依赖的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

示例10: testNotifyListener

import org.osgi.framework.Filter; //导入依赖的package包/类
@Test
public void testNotifyListener() throws InvalidSyntaxException {
    EndpointDescription endpoint1 = createEndpoint("myClass");
    EndpointDescription endpoint2 = createEndpoint("notMyClass");

    // Expect listener to be called for endpoint1 but not for endpoint2 
    EndpointListener epl = listenerExpects(endpoint1, "(objectClass=myClass)");

    EndpointRepository exportRepository = new EndpointRepository();
    EndpointListenerNotifier tm = new EndpointListenerNotifier(exportRepository);

    EasyMock.replay(epl);
    Set<Filter> filters = new HashSet<Filter>();
    filters.add(FrameworkUtil.createFilter("(objectClass=myClass)"));
    tm.add(epl, filters);
    tm.endpointAdded(endpoint1, null);
    tm.endpointAdded(endpoint2, null);
    tm.endpointRemoved(endpoint1, null);
    tm.endpointRemoved(endpoint2, null);
    EasyMock.verify(epl);
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:22,代码来源:EndpointListenerNotifierTest.java

示例11: testNotifyListeners

import org.osgi.framework.Filter; //导入依赖的package包/类
@Test
public void testNotifyListeners() throws InvalidSyntaxException {
    EndpointDescription endpoint1 = createEndpoint("myClass");
    
    EndpointListener epl = EasyMock.createStrictMock(EndpointListener.class);
    epl.endpointAdded(EasyMock.eq(endpoint1), EasyMock.eq("(objectClass=myClass)"));
    EasyMock.expectLastCall().once();
    epl.endpointRemoved(EasyMock.eq(endpoint1), EasyMock.eq("(objectClass=myClass)"));
    EasyMock.expectLastCall().once();

    EndpointRepository exportRepository = new EndpointRepository();
    EndpointListenerNotifier tm = new EndpointListenerNotifier(exportRepository);

    EasyMock.replay(epl);
    Set<Filter> filters = new HashSet<Filter>();
    filters.add(FrameworkUtil.createFilter("(objectClass=myClass)"));
    tm.add(epl, filters);
    tm.endpointAdded(endpoint1, null);
    tm.endpointRemoved(endpoint1, null);
    tm.remove(epl);
    EasyMock.verify(epl);
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:23,代码来源:EndpointListenerNotifierTest.java

示例12: test

import org.osgi.framework.Filter; //导入依赖的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

示例13: findServices

import org.osgi.framework.Filter; //导入依赖的package包/类
public Collection<RegistryServiceReference> findServices(String clazz, String filter) {
  ArrayList<RegistryServiceReference> refs = new ArrayList<RegistryServiceReference>();
  try {
    Filter f = filter == null ? null : ctx.createFilter(filter);
    
    for ( RegistryServiceReference ref : references.values() ) {
      if ( clazz == null || clazz.equals( ref.getInterface() ) ) {
        if ( f == null || f.match( new Hashtable(ref.getProperties()) ) ) {
          refs.add( ref );
        }
      }
    }
  } catch (InvalidSyntaxException e) {
    throw new IllegalStateException(e);
  }
  return refs;
}
 
开发者ID:mcculls,项目名称:osgi-in-action,代码行数:18,代码来源:DummyRegistry.java

示例14: getServiceReferences

import org.osgi.framework.Filter; //导入依赖的package包/类
public ServiceReference[] getServiceReferences(String str, String str2) throws InvalidSyntaxException {
    Collection collection;
    checkValid();
    Filter fromString = RFC1960Filter.fromString(str2);
    if (str == null) {
        collection = Framework.services;
    } else {
        List list = (List) Framework.classes_services.get(str);
        if (list == null) {
            return null;
        }
    }
    List arrayList = new ArrayList();
    ServiceReferenceImpl[] serviceReferenceImplArr = (ServiceReferenceImpl[]) collection.toArray(new ServiceReferenceImpl[collection.size()]);
    for (int i = 0; i < serviceReferenceImplArr.length; i++) {
        if (fromString.match(serviceReferenceImplArr[i])) {
            arrayList.add(serviceReferenceImplArr[i]);
        }
    }
    if (Framework.DEBUG_SERVICES && log.isInfoEnabled()) {
        log.info("Framework: REQUESTED SERVICES " + str + " " + str2);
        log.info("\tRETURNED " + arrayList);
    }
    return arrayList.size() == 0 ? null : (ServiceReference[]) arrayList.toArray(new ServiceReference[arrayList.size()]);
}
 
开发者ID:achellies,项目名称:AtlasForAndroid,代码行数:26,代码来源:BundleContextImpl.java

示例15: equals

import org.osgi.framework.Filter; //导入依赖的package包/类
public boolean equals(Object obj) {
    if (!(obj instanceof RFC1960Filter)) {
        return false;
    }
    RFC1960Filter rFC1960Filter = (RFC1960Filter) obj;
    if (this.operands.size() != rFC1960Filter.operands.size()) {
        return false;
    }
    Filter[] filterArr = (Filter[]) this.operands.toArray(new Filter[this.operands.size()]);
    Filter[] filterArr2 = (Filter[]) rFC1960Filter.operands.toArray(new Filter[this.operands.size()]);
    for (int i = EQUALS; i < filterArr.length; i += PRESENT) {
        if (!filterArr[i].equals(filterArr2[i])) {
            return false;
        }
    }
    return true;
}
 
开发者ID:achellies,项目名称:AtlasForAndroid,代码行数:18,代码来源:RFC1960Filter.java


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