微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

org.osgi.framework.InvalidSyntaxException的实例源码

项目:gemini.blueprint    文件OsgiServiceDynamicInterceptorListenerTest.java   
protected void setUp() throws Exception {
    listener = new SimpleTargetSourceLifecycleListener();

    refs = new ServiceReference[] { new MockServiceReference() };

    bundleContext = new MockBundleContext() {

        public ServiceReference[] getServiceReferences(String clazz,String filter) throws InvalidSyntaxException {
            return refs;
        }
    };

    interceptor = new ServiceDynamicInterceptor(bundleContext,null,getClass().getClassLoader());
    interceptor.setListeners(new OsgiServiceLifecycleListener[] { listener });
    interceptor.setMandatoryService(false);
    interceptor.setProxy(new Object());
    interceptor.setServiceImporter(new Object());
    interceptor.setSticky(false);

    interceptor.setRetryTimeout(1);

    SimpleTargetSourceLifecycleListener.BIND = 0;
    SimpleTargetSourceLifecycleListener.UNBIND = 0;
}
项目:aries-jpa    文件PersistenceProviderTracker.java   
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);
    }
}
项目:aries-jpa    文件PropsConfigurationTest.java   
@Test
public void testRegistersManagedEMF() throws InvalidSyntaxException,ConfigurationException {

    AriesEntityManagerFactoryBuilder emfb = new AriesEntityManagerFactoryBuilder(
            containerContext,provider,providerBundle,punit);

    verify(containerContext).registerService(eq(ManagedService.class),any(ManagedService.class),argThat(servicePropsMatcher(
                    SERVICE_PID,"org.apache.aries.jpa.test-props")));

    // No EMF created as incomplete
    verifyZeroInteractions(msReg,provider);

    emfb.close();
    verify(msReg).unregister();
}
项目:Core    文件OsgiUtils.java   
public static <E> List<E> getServices(BundleContext bundleContext,Class<E> serviceType,String filter)
        throws InvalidSyntaxException {
    List<E> services = null;
    final ServiceReference[] refs = bundleContext.getServiceReferences(serviceType.getName(),filter);
    if (refs != null) {
        services = new ArrayList<>(refs.length);
        if (refs != null && refs.length > 0) {
            for (ServiceReference ref : refs) {
                E service = (E) bundleContext.getService(ref);
                services.add(service);
            }
        }
    } else
        services = Collections.unmodifiableList(new ArrayList<E>());
    return services;
}
项目:aries-jpa    文件PropsConfigurationTest.java   
@Test
public void testPUWithJtaDSGetsCreatedAutomatically() throws InvalidSyntaxException,ConfigurationException {

    when(containerContext.getServiceReferences((String) null,"(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name=testds))"))
        .thenReturn(new ServiceReference<?>[] {dsRef});

    when(punit.getJtaDataSourceName()).thenReturn(
            "osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=testds)");

    when(provider.createContainerEntityManagerFactory(eq(punit),any(Map.class))).thenReturn(emf);

    AriesEntityManagerFactoryBuilder emfb = new AriesEntityManagerFactoryBuilder(
            containerContext,punit);

    verify(punit).setJtaDataSource(ds);
    verify(punitContext).registerService(eq(EntityManagerFactory.class),any(EntityManagerFactory.class),argThat(servicePropsMatcher(JPA_UNIT_NAME,"test-props")));

    emfb.close();
}
项目:aries-jpa    文件PropsConfigurationTest.java   
@Test
public void testPUWithNonJtaDSGetsCreatedAutomatically() throws InvalidSyntaxException,"(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name=testds))"))
    .thenReturn(new ServiceReference<?>[] {dsRef});

    when(punit.getTransactionType()).thenReturn(RESOURCE_LOCAL);

    when(punit.getNonJtaDataSourceName()).thenReturn(
            "osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=testds)");

    when(provider.createContainerEntityManagerFactory(eq(punit),punit);

    verify(punit).setNonJtaDataSource(ds);
    verify(punitContext).registerService(eq(EntityManagerFactory.class),"test-props")));

    emfb.close();
}
项目:neoscada    文件AbstractDataSourceHandler.java   
protected void setDataSource ( final String dataSourceId ) throws InvalidSyntaxException
{
    logger.debug ( "Set datasource request: {}",dataSourceId );

    try
    {
        this.trackerLock.lock ();

        if ( this.tracker != null )
        {
            this.tracker.close ();
            this.tracker = null;
        }

        if ( dataSourceId != null )
        {
            this.tracker = new SingleDataSourceTracker ( this.poolTracker,dataSourceId,this.serviceListener );
            this.tracker.open ();
        }
    }
    finally
    {
        this.trackerLock.unlock ();
    }
}
项目:gemini.blueprint    文件nestedReferencesTest.java   
protected void setUp() throws Exception {

        BundleContext bundleContext = new MockBundleContext() {
            // service reference already registered
            public ServiceReference[] getServiceReferences(String clazz,String filter) throws InvalidSyntaxException {
                return new ServiceReference[0];
            }
        };

        appContext = new GenericApplicationContext();
        appContext.getbeanfactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
        appContext.setClassLoader(getClass().getClassLoader());

        XmlBeanDeFinitionReader reader = new XmlBeanDeFinitionReader(appContext);
        // reader.setEventListener(this.listener);
        reader.loadBeanDeFinitions(new ClassPathResource("osgiReferencenestedBeans.xml",getClass()));
        appContext.refresh();
    }
项目:neoscada    文件AbstractExporter.java   
public void init () throws InvalidSyntaxException
{
    final String filter = String.format ( "(%s=%s)",JaxWsExporter.EXPORT_ENABLED,true );
    synchronized ( this )
    {
        this.context.addServiceListener ( this,filter );
        final ServiceReference<?>[] refs = this.context.getServiceReferences ( (String)null,filter );
        if ( refs != null )
        {
            for ( final ServiceReference<?> ref : refs )
            {
                addService ( ref );
            }
        }
    }
}
项目:neoscada    文件FilterUtil.java   
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 () );
}
项目:neoscada    文件SingleDataSourceTracker.java   
/**
 * Create a new single datasource tracker
 * 
 * @param poolTracker
 *            the pool tracker to use
 * @param dataSourceId
 *            the id of the datasource to track
 * @param listener
 *            the listener that gets notified (must not be <code>null</code>)
 * @throws InvalidSyntaxException
 */
public SingleDataSourceTracker ( final ObjectPoolTracker<DataSource> poolTracker,final String dataSourceId,final ServiceListener listener ) throws InvalidSyntaxException
{
    this.listener = listener;
    if ( listener == null )
    {
        throw new NullPointerException ( "'listener' must not be null" );
    }

    this.tracker = new SingleObjectPoolServiceTracker<DataSource> ( poolTracker,new SingleObjectPoolServiceTracker.ServiceListener<DataSource> () {
        @Override
        public void serviceChange ( final DataSource service,final Dictionary<?,?> properties )
        {
            SingleDataSourceTracker.this.setDataSource ( service );
        }
    } );
}
项目:gemini.blueprint    文件OsgiServiceCollectionProxiesTest.java   
protected void setUp() throws Exception {
    services = new LinkedHashMap();

    BundleContext ctx = new MockBundleContext() {

        public ServiceReference[] getServiceReferences(String clazz,String filter) throws InvalidSyntaxException {
            return new ServiceReference[0];
        }

        public Object getService(ServiceReference reference) {
            Object service = services.get(reference);
            return (service == null ? new Object() : service);
        }

    };

    ClassLoader cl = getClass().getClassLoader();
    proxyCreator =
            new StaticServiceProxyCreator(new Class<?>[] { Cloneable.class },cl,ctx,ImportContextClassLoaderEnum.UNMANAGED,false,false);
}
项目:neoscada    文件ProxyDataSource.java   
private void setSources ( final String str ) throws InvalidSyntaxException
{
    if ( this.tracker != null )
    {
        this.tracker.close ();
        this.tracker = null;
    }

    this.sourceIds = convertSources ( str );
    this.sources = new HashMap<DataSource,ProxyDataSource.sourceHandler> ( this.sourceIds.size () );

    if ( this.sourceIds.isEmpty () )
    {
        // nothing to do if we don't have any source
        return;
    }

    this.tracker = new MultiDataSourceTracker ( this.poolTracker,this.sourceIds,this );
    this.tracker.open ();
}
项目:gemini.blueprint    文件MockBundleContext.java   
public ServiceReference[] getServiceReferences(String clazz,String filter) throws InvalidSyntaxException {
    // Some jiggery-pokery to get round the fact that we don't ever use the clazz
    if (clazz == null) {
        if (filter != null) {
            // flatten filter since the constants might be case insensitive
            String flattenFilter = filter.toLowerCase();
            int i = flattenFilter.indexOf(Constants.OBJECTCLASS.toLowerCase() + "=");
            if (i > 0) {
                clazz = filter.substring(i + Constants.OBJECTCLASS.length() + 1);
                clazz = clazz.substring(0,clazz.indexOf(")"));
            }
        } else {
            clazz = Object.class.getName();
           }
       }
    return new ServiceReference[] { new MockServiceReference(getBundle(),new String[] { clazz }) };
}
项目:gemini.blueprint    文件AbstractOsgiCollectionTest.java   
protected void setUp() throws Exception {
    services = new LinkedHashMap();

    context = new MockBundleContext() {

        public ServiceReference[] getServiceReferences(String clazz,String filter) throws InvalidSyntaxException {
            return new ServiceReference[0];
        }

        public Object getService(ServiceReference reference) {
            Object service = services.get(reference);
            return (service == null ? new Object() : service);
        }
    };

    col = createCollection();
    col.setrequiredAtStartup(false);
    col.afterPropertiesSet();
}
项目:neoscada    文件ProxyValueSource.java   
public ProxyValueSource ( final BundleContext context,final String id,final ProxyHistoricalItem item,final int priority ) throws InvalidSyntaxException
{

    this.item = item;
    this.priority = priority;

    this.listener = new SingleServiceListener<HistoricalItem> () {

        @Override
        public void serviceChange ( final ServiceReference<HistoricalItem> reference,final HistoricalItem service )
        {
            setService ( service );
        }
    };

    this.tracker = new SingleServiceTracker<HistoricalItem> ( context,FilterUtil.createClassAndPidFilter ( HistoricalItem.class.getName (),id ),this.listener );
    this.tracker.open ();
}
项目:neoscada    文件AverageDataSource.java   
private void setSources ( final String str ) throws InvalidSyntaxException
{
    if ( this.tracker != null )
    {
        this.tracker.close ();
        this.tracker = null;
    }

    for ( final DataSourceHandler source : this.sources.values () )
    {
        source.dispose ();
    }
    this.sources.clear ();
    this.sourceIds = convertSources ( str );

    if ( this.sourceIds.isEmpty () )
    {
        // nothing to do if we don't have any source
        return;
    }

    this.tracker = new MultiDataSourceTracker ( this.poolTracker,this );
    this.tracker.open ();
}
项目:neoscada    文件MovingAverageDataSource.java   
public void update ( final Map<String,String> parameters ) throws InvalidSyntaxException
{
    if ( this.triggerFuture != null )
    {
        this.triggerFuture.cancel ( false );
        this.triggerFuture = null;
    }

    final ConfigurationDataHelper cfg = new ConfigurationDataHelper ( parameters );
    try
    {
        this.dataSourceId = cfg.getStringChecked ( "datasource.id","'datasource.id' must be set" ); //$NON-NLS-1$
        this.trigger = cfg.getLongChecked ( "trigger","'trigger' must be set" ); //$NON-NLS-1$
        this.range = cfg.getLongChecked ( "range","'range' must be set" ); //$NON-NLS-1$
        this.nullrange = cfg.getLongChecked ( "nullRange","'nullRange' must be set" ); //$NON-NLS-1$
        this.triggerOnly = cfg.getBoolean ( "triggerOnly",false ); //$NON-NLS-1$
    }
    catch ( final IllegalArgumentException e )
    {
        updateAverage ( new AverageValues () );
        throw e;
    }

    handleChange ();
}
项目:neoscada    文件MovingAverageDataSource.java   
private void updateDataSource () throws InvalidSyntaxException
{
    logger.debug ( "updateDataSource ()" );
    if ( this.dataSourceTracker != null )
    {
        this.dataSourceTracker.close ();
        this.dataSourceTracker = null;
    }
    if ( this.dataSourceId != null )
    {
        logger.debug ( "track datasource {}",this.dataSourceId );
        this.dataSourceTracker = new SingleDataSourceTracker ( this.poolTracker,this.dataSourceId,new ServiceListener () {
            @Override
            public void dataSourceChanged ( final DataSource dataSource )
            {
                setDataSource ( dataSource );
            }
        } );
        this.dataSourceTracker.open ();
    }
}
项目:neoscada    文件HistoricalItemImpl.java   
private void updateDataSource () throws InvalidSyntaxException
{
    logger.debug ( "updateDataSource ()" );
    if ( this.dataSourceTracker != null )
    {
        this.dataSourceTracker.close ();
        this.dataSourceTracker = null;
    }
    if ( this.dataSourceId != null )
    {
        logger.debug ( "track datasource " + this.dataSourceId );
        this.dataSourceTracker = new SingleDataSourceTracker ( this.poolTracker,new ServiceListener () {
            @Override
            public void dataSourceChanged ( final DataSource dataSource )
            {
                setDataSource ( dataSource );
            }
        } );
        this.dataSourceTracker.open ();
    }
}
项目:gemini.blueprint    文件OsgiDefaultsTests.java   
protected void setUp() throws Exception {
    BundleContext bundleContext = new MockBundleContext() {
        // service reference already registered
        public ServiceReference[] getServiceReferences(String clazz,String filter) throws InvalidSyntaxException {
            return new ServiceReference[] { new MockServiceReference(new String[] { Serializable.class.getName() }) };
        }
    };

    appContext = new GenericApplicationContext();
    appContext.getbeanfactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
    appContext.setClassLoader(getClass().getClassLoader());

    XmlBeanDeFinitionReader reader = new XmlBeanDeFinitionReader(appContext);
    reader.loadBeanDeFinitions(new ClassPathResource("osgiDefaults.xml",getClass()));
    appContext.refresh();
}
项目:gemini.blueprint    文件OsgiSingleReferenceParserWithInvalidFilesTest.java   
protected void setUp() throws Exception {
    BundleContext bundleContext = new MockBundleContext() {
        // service reference already registered
        public ServiceReference[] getServiceReferences(String clazz,String filter) throws InvalidSyntaxException {
            return new ServiceReference[0];
        }
    };

    appContext = new GenericApplicationContext();
    appContext.getbeanfactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
    appContext.setClassLoader(getClass().getClassLoader());
}
项目:aries-jpa    文件DSFTracker.java   
static Filter createFilter(BundleContext context,String driverClass,String puName) {
    if (driverClass == null) {
        throw new IllegalArgumentException("No javax.persistence.jdbc.driver supplied in persistence.xml");
    }
    String filter = String.format("(&(objectClass=%s)(%s=%s))",DataSourceFactory.class.getName(),DataSourceFactory.Osgi_JDBC_DRIVER_CLASS,driverClass);
    LOGGER.info("Tracking DataSourceFactory for punit " + puName + " with filter " + filter);
    try {
        return context.createFilter(filter);
    } catch (InvalidSyntaxException e) {
        throw new IllegalArgumentException(e);
    }
}
项目:aries-jpa    文件DataSourceTracker.java   
static Filter createFilter(BundleContext context,String dsName,String puName) {
    if (dsName == null) {
        throw new IllegalArgumentException("No DataSource supplied in persistence.xml");
    }
    String subFilter = getSubFilter(dsName);
    String filter = String.format("(&(objectClass=%s)%s)",DataSource.class.getName(),subFilter);
    LOGGER.info("Tracking DataSource for punit " + puName + " with filter " + filter);
    try {
        return context.createFilter(filter);
    } catch (InvalidSyntaxException e) {
        throw new IllegalArgumentException(e);
    }
}
项目:aries-jpa    文件PropsConfigurationTest.java   
@Test
public void testIncompleteEmfWithoutProps() throws InvalidSyntaxException,ConfigurationException {

    when(provider.createContainerEntityManagerFactory(eq(punit),eq(singletonMap(PersistenceUnitTransactionType.class.getName(),JTA))))
        .thenReturn(emf);

    AriesEntityManagerFactoryBuilder emfb = new AriesEntityManagerFactoryBuilder(
            containerContext,punit);

    assertEquals(ECLIPSE_PERSISTENCE_PROVIDER,emfb.getPersistenceProviderName());
    assertEquals(providerBundle,emfb.getPersistenceProviderBundle());

    try {
        emfb.createEntityManagerFactory(null);
        fail("Should throw an exception as incomplete");
    } catch (IllegalArgumentException iae) {
        // Expected
    }


    // No EMF created as incomplete
    verifyZeroInteractions(emf,emfReg,provider);

    emfb.close();

    verifyZeroInteractions(emf,provider);
}
项目:aries-jpa    文件PropsConfigurationTest.java   
@Test
  public void testIncompleteEmfWithPropsGetsPassed() throws InvalidSyntaxException,ConfigurationException {

    Map<String,Object> providerProps = new HashMap<String,Object>();
    providerProps.put(PersistenceUnitTransactionType.class.getName(),JTA);
    providerProps.put("hibernate.hbm2ddl.auto","create-drop");

    when(provider.createContainerEntityManagerFactory(eq(punit),eq(providerProps))).thenReturn(emf);

    Map<String,Object> props = new Hashtable<String,Object>();
      props.put("hibernate.hbm2ddl.auto","create-drop");
      props.put("javax.persistence.dataSource",ds);

      AriesEntityManagerFactoryBuilder emfb = new AriesEntityManagerFactoryBuilder(
            containerContext,punit);
      emfb.createEntityManagerFactory(props);


      verify(punitContext).registerService(eq(EntityManagerFactory.class),and(argThat(servicePropsMatcher(JPA_UNIT_NAME,"test-props")),argThat(servicePropsMatcher("hibernate.hbm2ddl.auto","create-drop"))));

      emfb.close();
verify(emfReg).unregister();
verify(emf).close();
  }
项目:aries-jpa    文件PropsConfigurationTest.java   
@Test
  public void testPUWithDriverGetsCreatedAutomatically() throws InvalidSyntaxException,ConfigurationException {

    punitProperties.setProperty("javax.persistence.jdbc.driver","org.h2.Driver");
    punitProperties.setProperty("javax.persistence.jdbc.url",JDBC_URL);
    punitProperties.setProperty("javax.persistence.jdbc.user",JDBC_USER);
    punitProperties.setProperty("javax.persistence.jdbc.password",JDBC_PASSWORD);

    when(containerContext.getServiceReferences((String) null,"(&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.class=org.h2.Driver))"))
        .thenReturn(new ServiceReference<?>[] {dsfRef});


    when(provider.createContainerEntityManagerFactory(eq(punit),"test-props")));

    emfb.close();
verify(emfReg).unregister();
verify(emf).close();
  }
项目:aries-jpa    文件PropsConfigurationTest.java   
@Test
public void testLateBindingDriver() throws InvalidSyntaxException,ConfigurationException {


    when(containerContext.getServiceReferences((String) null,"(&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.class=org.h2.Driver))"))
    .thenReturn(new ServiceReference<?>[] {dsfRef});


    when(provider.createContainerEntityManagerFactory(eq(punit),punit);

    verifyZeroInteractions(provider);

    Map<String,Object> config = new HashMap<String,Object>();
    config.put("javax.persistence.jdbc.driver","org.h2.Driver");
    config.put("javax.persistence.jdbc.url",JDBC_URL);
    config.put("javax.persistence.jdbc.user",JDBC_USER);
    config.put("javax.persistence.jdbc.password",JDBC_PASSWORD);

    emfb.createEntityManagerFactory(config);

    verify(punit).setJtaDataSource(ds);
    verify(punitContext).registerService(eq(EntityManagerFactory.class),"test-props")));


    try {
        config.put("javax.persistence.jdbc.driver","org.apache.derby.client.ClientDriver");
        emfb.createEntityManagerFactory(config);
        fail("Must throw an IllegalArgumentException on rebind");
    } catch (IllegalArgumentException ise) {
        // Expected
    }

    emfb.close();
}
项目:aries-jpa    文件DataSourceTrackerTest.java   
@Test
public void testCreateFilterSimple() throws InvalidSyntaxException {
    BundleContext context = mock(BundleContext.class);

    DataSourceTracker.createFilter(context,"tasklist","test");

    verify(context,atLeastOnce()).createFilter(Mockito.eq("(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name=tasklist))"));
}
项目:aries-jpa    文件ManagedEMFTest.java   
@Test
  public void testemfWithoutProps() throws InvalidSyntaxException,ConfigurationException {
    ManagedEMF emf = new ManagedEMF(builder,"test");
      emf.updated(null);
      Mockito.verifyZeroInteractions(builder);

      Hashtable<String,Object>();
emf.updated(props);
      verify(builder).createEntityManagerFactory(props);

      emf.updated(null);
      verify(builder).closeEMF();

  }
项目:aries-jpa    文件ManagedEMFTest.java   
@Test
public void testemfWithProps() throws InvalidSyntaxException,"test");

    Dictionary<String,Object>();
    props.put("hibernate.hbm2ddl.auto","create-drop");
    emf.updated(props);

    verify(builder).createEntityManagerFactory(Collections.<String,Object>singletonMap(
            "hibernate.hbm2ddl.auto","create-drop"));
}
项目:neoscada    文件ObjectPoolTracker.java   
public ObjectPoolTracker ( final BundleContext context,final String poolClass ) throws InvalidSyntaxException
{
    final Map<String,String> parameters = new HashMap<String,String> ();
    parameters.put ( ObjectPool.OBJECT_POOL_CLASS,poolClass );
    final Filter filter = FilterUtil.createAndFilter ( ObjectPool.class.getName (),parameters );

    this.poolTracker = new ServiceTracker<ObjectPool<S>,ObjectPool<S>> ( context,filter,new ServiceTrackerCustomizer<ObjectPool<S>,ObjectPool<S>> () {

        @Override
        public void removedService ( final ServiceReference<ObjectPool<S>> reference,final ObjectPool<S> service )
        {
            context.ungetService ( reference );
            ObjectPoolTracker.this.removePool ( service );
        }

        @Override
        public void modifiedService ( final ServiceReference<ObjectPool<S>> reference,final ObjectPool<S> service )
        {
            ObjectPoolTracker.this.modifyPool ( service,reference );
        }

        @Override
        public ObjectPool<S> addingService ( final ServiceReference<ObjectPool<S>> reference )
        {
            final ObjectPool<S> o = context.getService ( reference );
            ObjectPoolTracker.this.addPool ( o,reference );
            return o;
        }
    } );
}
项目:neoscada    文件FilterUtil.java   
protected static Filter createFilter ( final String operand,final Map<String,String> parameters ) throws InvalidSyntaxException
{
    final StringBuilder sb = new StringBuilder ();

    sb.append ( "(" );
    sb.append ( operand );

    for ( final Map.Entry<String,String> entry : parameters.entrySet () )
    {
        addPair ( sb,entry.getKey (),entry.getValue () );
    }
    sb.append ( ")" );

    return FrameworkUtil.createFilter ( sb.toString () );
}
项目:hashsdn-controller    文件WaitingServiceTracker.java   
/**
 * Creates an instance.
 *
 * @param serviceInterface
 *            the service interface
 * @param context
 *            the BundleContext
 * @param filter
 *            the Osgi service filter
 * @return new WaitingServiceTracker instance
 */
public static <T> WaitingServiceTracker<T> create(@Nonnull final Class<T> serviceInterface,@Nonnull final BundleContext context,@Nonnull final String filter) {
    String newFilter = String.format("(&(%s=%s)%s)",Constants.OBJECTCLASS,serviceInterface.getName(),filter);
    try {
        ServiceTracker<T,?> tracker = new ServiceTracker<>(context,context.createFilter(newFilter),null);
        tracker.open();
        return new WaitingServiceTracker<>(serviceInterface,tracker);
    } catch (final InvalidSyntaxException e) {
        throw new IllegalArgumentException(String.format("Invalid Osgi filter %s",newFilter),e);
    }
}
项目:gemini.blueprint    文件OsgiServiceNamespaceHandlerTest.java   
protected void setUp() throws Exception {

        services.clear();

        RegistrationListener.BIND_CALLS = 0;
        RegistrationListener.UNBIND_CALLS = 0;

        CustomregistrationListener.REG_CALLS = 0;
        CustomregistrationListener.UNREG_CALLS = 0;

        registration = new MockServiceRegistration();

        bundleContext = new MockBundleContext() {

            public ServiceReference[] getServiceReferences(String clazz,String filter) throws InvalidSyntaxException {
                return new ServiceReference[] { new MockServiceReference(new String[] { Cloneable.class.getName() }) };
            }

            public ServiceRegistration registerService(String[] clazzes,Object service,Dictionary properties) {
                services.add(service);
                return registration;
            }
        };

        appContext = new GenericApplicationContext();
        appContext.getbeanfactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));

        XmlBeanDeFinitionReader reader = new XmlBeanDeFinitionReader(appContext);
        // reader.setEventListener(this.listener);
        reader.loadBeanDeFinitions(new ClassPathResource("osgiServiceNamespaceHandlerTests.xml",getClass()));
        appContext.refresh();
    }
项目:neoscada    文件MapperHandlerFactoryImpl.java   
public MapperHandlerFactoryImpl ( final BundleContext context,final ObjectPoolTracker<MasterItem> poolTracker,final ObjectPoolTracker<ValueMapper> mapperPoolTracker,final int defaultPriority ) throws InvalidSyntaxException
{
    super ( context );
    this.poolTracker = poolTracker;
    this.mapperPoolTracker = mapperPoolTracker;
    this.defaultPriority = defaultPriority;
}
项目:neoscada    文件FilterUtil.java   
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 () );
}
项目:gemini.blueprint    文件MockBundleContext.java   
public void addServiceListener(ServiceListener listener) {
    try {
        addServiceListener(listener,null);
    } catch (InvalidSyntaxException ex) {
        throw new IllegalStateException("exception should not occur");
    }
}
项目:neoscada    文件SumSourceFactory.java   
public SumSourceFactory ( final BundleContext context,final Executor executor ) throws InvalidSyntaxException
{
    super ( context );
    this.executor = executor;

    this.objectPool = new ObjectPoolImpl<DataSource> ();
    this.poolRegistration = ObjectPoolHelper.registerObjectPool ( context,this.objectPool,DataSource.class );

    this.poolTracker = new ObjectPoolTracker<DataSource> ( context,DataSource.class );
    this.poolTracker.open ();
}
项目:neoscada    文件AbstractServiceImpl.java   
public AbstractServiceImpl ( final BundleContext context,final Executor executor ) throws InvalidSyntaxException
{
    this.executor = executor;
    this.authorizationHelper = new TrackingAuthorizationImplementation ( context );
    this.authorizationTracker = new TrackingAuthorizationTracker ( context );

    this.authenticationImplemenation = new TrackingAuthenticationImplementation ( context );

    this.auditLogTracker = new TrackingAuditLogImplementation ( context );

    setAuthorizationImplementation ( this.authorizationHelper );
    setAuthenticationImplementation ( this.authenticationImplemenation );
    setAuditLogService ( this.auditLogTracker );
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。