本文整理匯總了Java中org.osgi.framework.InvalidSyntaxException類的典型用法代碼示例。如果您正苦於以下問題:Java InvalidSyntaxException類的具體用法?Java InvalidSyntaxException怎麽用?Java InvalidSyntaxException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
InvalidSyntaxException類屬於org.osgi.framework包,在下文中一共展示了InvalidSyntaxException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUp
import org.osgi.framework.InvalidSyntaxException; //導入依賴的package包/類
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, 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;
}
示例2: createFilter
import org.osgi.framework.InvalidSyntaxException; //導入依賴的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);
}
}
示例3: testRegistersManagedEMF
import org.osgi.framework.InvalidSyntaxException; //導入依賴的package包/類
@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();
}
示例4: getServices
import org.osgi.framework.InvalidSyntaxException; //導入依賴的package包/類
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;
}
示例5: testPUWithJtaDSGetsCreatedAutomatically
import org.osgi.framework.InvalidSyntaxException; //導入依賴的package包/類
@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, provider, providerBundle, punit);
verify(punit).setJtaDataSource(ds);
verify(punitContext).registerService(eq(EntityManagerFactory.class),
any(EntityManagerFactory.class), argThat(servicePropsMatcher(JPA_UNIT_NAME, "test-props")));
emfb.close();
}
示例6: testPUWithNonJtaDSGetsCreatedAutomatically
import org.osgi.framework.InvalidSyntaxException; //導入依賴的package包/類
@Test
public void testPUWithNonJtaDSGetsCreatedAutomatically() throws InvalidSyntaxException, ConfigurationException {
when(containerContext.getServiceReferences((String) null,
"(&(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),
any(Map.class))).thenReturn(emf);
AriesEntityManagerFactoryBuilder emfb = new AriesEntityManagerFactoryBuilder(
containerContext, provider, providerBundle, punit);
verify(punit).setNonJtaDataSource(ds);
verify(punitContext).registerService(eq(EntityManagerFactory.class),
any(EntityManagerFactory.class), argThat(servicePropsMatcher(JPA_UNIT_NAME, "test-props")));
emfb.close();
}
示例7: setDataSource
import org.osgi.framework.InvalidSyntaxException; //導入依賴的package包/類
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 ();
}
}
示例8: setUp
import org.osgi.framework.InvalidSyntaxException; //導入依賴的package包/類
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();
}
示例9: init
import org.osgi.framework.InvalidSyntaxException; //導入依賴的package包/類
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 );
}
}
}
}
示例10: createFilter
import org.osgi.framework.InvalidSyntaxException; //導入依賴的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 () );
}
示例11: SingleDataSourceTracker
import org.osgi.framework.InvalidSyntaxException; //導入依賴的package包/類
/**
* 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, dataSourceId, new SingleObjectPoolServiceTracker.ServiceListener<DataSource> () {
@Override
public void serviceChange ( final DataSource service, final Dictionary<?, ?> properties )
{
SingleDataSourceTracker.this.setDataSource ( service );
}
} );
}
示例12: setUp
import org.osgi.framework.InvalidSyntaxException; //導入依賴的package包/類
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, cl, ctx,
ImportContextClassLoaderEnum.UNMANAGED, false, false);
}
示例13: setSources
import org.osgi.framework.InvalidSyntaxException; //導入依賴的package包/類
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 ();
}
示例14: getServiceReferences
import org.osgi.framework.InvalidSyntaxException; //導入依賴的package包/類
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 }) };
}
示例15: setUp
import org.osgi.framework.InvalidSyntaxException; //導入依賴的package包/類
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();
}