org.osgi.service.url.URLStreamHandlerService Java Examples
The following examples show how to use
org.osgi.service.url.URLStreamHandlerService.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Activator.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
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))); }
Example #2
Source File: Activator.java From flowable-engine with Apache License 2.0 | 5 votes |
@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))); }
Example #3
Source File: ServiceURLStreamHandlerFactory.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * */ private URLStreamHandler getServiceHandler(final String protocol) { try { final String filter = "(" + URLConstants.URL_HANDLER_PROTOCOL + "=" + protocol + ")"; @SuppressWarnings("unchecked") final Vector<FrameworkContext> sfws = (Vector<FrameworkContext>)framework.clone(); for (final FrameworkContext sfw : sfws) { @SuppressWarnings("unchecked") final ServiceReference<URLStreamHandlerService>[] srl = (ServiceReference<URLStreamHandlerService>[]) sfw.services .get(URLStreamHandlerService.class.getName(), filter, sfw.systemBundle, false); if (srl != null && srl.length > 0) { synchronized (wrapMap) { URLStreamHandlerWrapper wrapper = wrapMap.get(protocol); if (wrapper == null) { wrapper = new URLStreamHandlerWrapper(sfw, protocol); wrapMap.put(protocol, wrapper); } else { wrapper.addFramework(sfw); } return wrapper; } } } } catch (final InvalidSyntaxException e) { throw new RuntimeException("Failed to get service: " + e); } // no handler found return null; }
Example #4
Source File: URLStreamHandlerWrapper.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * */ private URLStreamHandlerService getService() { FrameworkContext fw; if (framework.size() == 1) { fw = framework.get(0); } else { // Get current FrameworkContext throw new RuntimeException("NYI - walk stack to get framework"); } synchronized (serviceListener) { if (best == null) { try { @SuppressWarnings("unchecked") final ServiceReference<URLStreamHandlerService>[] refs = (ServiceReference<URLStreamHandlerService>[]) fw.systemBundle.bundleContext.getServiceReferences(URLStreamHandlerService.class.getName(), filter); if (refs != null) { // KF gives us highest ranked first. best = refs[0]; } } catch (final InvalidSyntaxException _no) { } } if (best == null) { throw new IllegalStateException("null: Lost service for protocol="+ protocol); } if (bestService == null) { bestService = fw.systemBundle.bundleContext.getService(best); } if (bestService == null) { throw new IllegalStateException("null: Lost service for protocol=" + protocol); } currentFw = fw; return bestService; } }
Example #5
Source File: URLStreamHandlerWrapper.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public String toString() { final StringBuffer sb = new StringBuffer(); sb.append("URLStreamHandlerWrapper["); final ServiceReference<URLStreamHandlerService> ref = best; sb.append("protocol=" + protocol); // sb.append(", size=" + tracker.size()); if(ref != null) { sb.append(", id=" + ref.getProperty(Constants.SERVICE_ID)); sb.append(", rank=" + ref.getProperty(Constants.SERVICE_RANKING)); // ServiceReference[] srl = tracker.getServiceReferences(); // for(int i = 0; srl != null && i < srl.length; i++) { // sb.append(", {"); // sb.append("id=" + srl[i].getProperty(Constants.SERVICE_ID)); // sb.append(", rank=" + srl[i].getProperty(Constants.SERVICE_RANKING)); // String[] sa = (String[])srl[i].getProperty(URLConstants.URL_HANDLER_PROTOCOL); // sb.append(", proto="); // for(int j = 0; j < sa.length; j++) { // sb.append(sa[j]); // if(j < sa.length - 1) { // sb.append(", "); // } // } // sb.append("}"); // } } else { sb.append(" no service tracked"); } sb.append("]"); return sb.toString(); }
Example #6
Source File: Activator.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
@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)); }