本文整理汇总了Java中org.osgi.service.url.URLStreamHandlerService类的典型用法代码示例。如果您正苦于以下问题:Java URLStreamHandlerService类的具体用法?Java URLStreamHandlerService怎么用?Java URLStreamHandlerService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
URLStreamHandlerService类属于org.osgi.service.url包,在下文中一共展示了URLStreamHandlerService类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stop
import org.osgi.service.url.URLStreamHandlerService; //导入依赖的package包/类
@Test
public void stop() throws Exception {
BundleContext mockBundleContext = mock( BundleContext.class );
final ServiceRegistration mockArtifactUrlTransformerRegistration = mock( ServiceRegistration.class );
when( mockBundleContext
.registerService( eq( ArtifactUrlTransformer.class ), any( ArtifactUrlTransformer.class ), any() ) )
.thenReturn( mockArtifactUrlTransformerRegistration );
final ServiceRegistration mockURLStreamHandlerServiceRegistration = mock( ServiceRegistration.class );
when( mockBundleContext
.registerService( eq( URLStreamHandlerService.class ), any( URLStreamHandlerService.class ), any() ) )
.thenReturn( mockURLStreamHandlerServiceRegistration );
this.activator.start( mockBundleContext );
this.activator.stop( mockBundleContext );
verify( mockArtifactUrlTransformerRegistration, times( 1 ) ).unregister();
verify( mockURLStreamHandlerServiceRegistration, times( 1 ) ).unregister();
}
示例2: registerTomcatJNDIUrlService
import org.osgi.service.url.URLStreamHandlerService; //导入依赖的package包/类
private ServiceRegistration registerTomcatJNDIUrlService() {
Properties properties = new Properties();
properties.put(URLConstants.URL_HANDLER_PROTOCOL, "jndi");
final URLStreamHandler handler = new DirContextURLStreamHandler();
return bundleContext.registerService(URLStreamHandlerService.class.getName(),
new AbstractURLStreamHandlerService() {
private final static String EMPTY_STRING = "";
public URLConnection openConnection(URL u) throws IOException {
return new URL(u, EMPTY_STRING, handler).openConnection();
}
}, properties);
}
示例3: start
import org.osgi.service.url.URLStreamHandlerService; //导入依赖的package包/类
@Override
public void start(BundleContext context) throws Exception {
callbacks.add(new Service(context, URLStreamHandlerService.class.getName(), new BpmnURLHandler(), props("url.handler.protocol", "bpmn")));
callbacks.add(new Service(context, URLStreamHandlerService.class.getName(), new BarURLHandler(), props("url.handler.protocol", "bar")));
try {
callbacks.add(new Service(context, new String[]{ArtifactUrlTransformer.class.getName(), ArtifactListener.class.getName()}, new BpmnDeploymentListener(), null));
callbacks.add(new Service(context, new String[]{ArtifactUrlTransformer.class.getName(), ArtifactListener.class.getName()}, new BarDeploymentListener(), null));
} catch (NoClassDefFoundError e) {
LOGGER.warn("FileInstall package is not available, disabling fileinstall support");
LOGGER.debug("FileInstall package is not available, disabling fileinstall support", e);
}
callbacks.add(new Tracker(new Extender(context)));
}
示例4: start
import org.osgi.service.url.URLStreamHandlerService; //导入依赖的package包/类
public void start(BundleContext context) throws Exception {
callbacks.add(new Service(
context,
URLStreamHandlerService.class.getName(),
new BpmnURLHandler(),
props("url.handler.protocol", "bpmn")));
callbacks.add(new Service(
context,
URLStreamHandlerService.class.getName(),
new BarURLHandler(),
props("url.handler.protocol", "bar")));
try {
callbacks.add(new Service(
context,
new String[] { ArtifactUrlTransformer.class.getName(), ArtifactListener.class.getName() },
new BpmnDeploymentListener(),
null));
callbacks.add(new Service(
context,
new String[] { ArtifactUrlTransformer.class.getName(), ArtifactListener.class.getName() },
new BarDeploymentListener(),
null));
} catch (NoClassDefFoundError e) {
LOGGER.log( Level.WARNING, "FileInstall package is not available, disabling fileinstall support" );
LOGGER.log( Level.FINE, "FileInstall package is not available, disabling fileinstall support", e );
}
callbacks.add(new Tracker(new Extender(context)));
}
示例5: start
import org.osgi.service.url.URLStreamHandlerService; //导入依赖的package包/类
public void start( BundleContext bundleContext ) {
this.urlTransformer = new UrlTransformer();
this.urlTransformerRegistration = bundleContext.registerService( ArtifactUrlTransformer.class, this.urlTransformer, null );
this.urlHandler = new UrlHandler();
Dictionary<String, String> props = new Hashtable<>();
props.put( URLConstants.URL_HANDLER_PROTOCOL, WebPackageURLConnection.URL_PROTOCOL );
this.urlHandlerRegistration = bundleContext.registerService( URLStreamHandlerService.class, this.urlHandler, props );
}
示例6: start
import org.osgi.service.url.URLStreamHandlerService; //导入依赖的package包/类
@Test
public void start() throws Exception {
BundleContext mockBundleContext = mock( BundleContext.class );
this.activator.start( mockBundleContext );
verify( mockBundleContext, times( 1 ) ).registerService( eq( ArtifactUrlTransformer.class ), any( ArtifactUrlTransformer.class ), any() );
verify( mockBundleContext, times( 1 ) ).registerService( eq( URLStreamHandlerService.class ), any( URLStreamHandlerService.class ), any() );
}
示例7: init
import org.osgi.service.url.URLStreamHandlerService; //导入依赖的package包/类
@Override
public void init(BundleContext context, DependencyManager manager) throws Exception {
manager.add(createComponent().setInterface(new String[] { ArtifactUrlTransformer.class.getName(), ArtifactListener.class.getName() }, null)
.setImplementation(BpmnDeploymentListener.class));
manager.add(createComponent().setInterface(URLStreamHandlerService.class.getName(),
new Hashtable<String, String>(Collections.singletonMap("url.handler.protocol", "bpmn"))).setImplementation(BpmnURLHandler.class));
}
示例8: activate
import org.osgi.service.url.URLStreamHandlerService; //导入依赖的package包/类
protected void activate(final ComponentContext context) {
final Hashtable<String, String> dict = new Hashtable<String, String>();
dict.put(URLConstants.URL_HANDLER_PROTOCOL, "httppgp");
context.getBundleContext().registerService(
URLStreamHandlerService.class.getName(), this, dict);
}