@Override protected void doStart() throws Exception { Hashtable<String, Object> props = new Hashtable<>(); props.put("url.handler.protocol", "blueprint"); register(URLStreamHandlerService.class, new BlueprintURLHandler(), props); register(new Class[] { ArtifactUrlTransformer.class, ArtifactListener.class }, new BlueprintDeploymentListener()); }
@Override public InputStream getInputStream() throws IOException { try { ByteArrayOutputStream os = new ByteArrayOutputStream(); BlueprintTransformer.transform(createUrl(url.getPath()), os); os.close(); return new ByteArrayInputStream(os.toByteArray()); } catch (Exception e) { throw new IOException("Error opening blueprint xml url", e); } } };
/** * Open the connection for the given URL. * * @param url the url from which to open a connection. * @return a connection on the specified URL. * @throws IOException if an error occurs or if the URL is malformed. */ @Override public URLConnection openConnection(URL url) throws IOException { if (url.getPath() == null || url.getPath().trim().length() == 0) { throw new MalformedURLException ("Path cannot be null or empty. Syntax: " + SYNTAX ); } logger.debug("Blueprint xml URL is: [" + url.getPath() + "]"); return new Connection(url); }
public static void transform(URL url, OutputStream os) throws Exception { Document doc = parse(url); String name = getPath(url); int idx = name.lastIndexOf('/'); if (idx >= 0) { m.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, str[0]); m.getMainAttributes().putValue(Constants.BUNDLE_VERSION, str[1]); String importPkgs = getImportPackages(analyze(new DOMSource(doc))); if (importPkgs != null && importPkgs.length() > 0) { m.getMainAttributes().putValue(Constants.IMPORT_PACKAGE, importPkgs); long lastModified = getLastModified(url);
@Override public URLStreamHandler createURLStreamHandler(String protocol) { switch (protocol) { case MVN_URI_PREFIX: return new org.ops4j.pax.url.mvn.Handler(); case WRAP_URI_PREFIX: return new org.ops4j.pax.url.wrap.Handler(); case FEATURE_URI_PREFIX: return new FeatureURLHandler(); case BLUEPRINT_URI_PREFIX: return new BlueprintURLHandler(); default: return null; } }
public boolean canHandle(File artifact) { try { if (artifact.isFile() && artifact.getName().endsWith(".xml")) { Document doc = parse(artifact); String name = doc.getDocumentElement().getLocalName(); String uri = doc.getDocumentElement().getNamespaceURI(); if ("blueprint".equals(name) && "http://www.osgi.org/xmlns/blueprint/v1.0.0".equals(uri)) { return true; } } } catch (Exception e) { logger.error("Unable to parse deployed file " + artifact.getAbsolutePath(), e); } return false; }
public static void transform(URL url, OutputStream os) throws Exception { Document doc = parse(url); String name = getPath(url); int idx = name.lastIndexOf('/'); if (idx >= 0) { m.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, str[0]); m.getMainAttributes().putValue(Constants.BUNDLE_VERSION, str[1]); String importPkgs = getImportPackages(analyze(new DOMSource(doc))); if (importPkgs != null && importPkgs.length() > 0) { m.getMainAttributes().putValue(Constants.IMPORT_PACKAGE, importPkgs); long lastModified = getLastModified(url);
@Override protected void doStart() throws Exception { Hashtable<String, Object> props = new Hashtable<>(); props.put("url.handler.protocol", "blueprint"); register(URLStreamHandlerService.class, new BlueprintURLHandler(), props); register(new Class[] { ArtifactUrlTransformer.class, ArtifactListener.class }, new BlueprintDeploymentListener()); }
@Override public InputStream getInputStream() throws IOException { try { ByteArrayOutputStream os = new ByteArrayOutputStream(); BlueprintTransformer.transform(createUrl(url.getPath()), os); os.close(); return new ByteArrayInputStream(os.toByteArray()); } catch (Exception e) { throw new IOException("Error opening blueprint xml url", e); } } };
/** * Open the connection for the given URL. * * @param url the url from which to open a connection. * @return a connection on the specified URL. * @throws IOException if an error occurs or if the URL is malformed. */ @Override public URLConnection openConnection(URL url) throws IOException { if (url.getPath() == null || url.getPath().trim().length() == 0) { throw new MalformedURLException ("Path cannot be null or empty. Syntax: " + SYNTAX ); } logger.debug("Blueprint xml URL is: [" + url.getPath() + "]"); return new Connection(url); }
public boolean canHandle(File artifact) { try { if (artifact.isFile() && artifact.getName().endsWith(".xml")) { Document doc = parse(artifact); String name = doc.getDocumentElement().getLocalName(); String uri = doc.getDocumentElement().getNamespaceURI(); if ("blueprint".equals(name) && "http://www.osgi.org/xmlns/blueprint/v1.0.0".equals(uri)) { return true; } } } catch (Exception e) { logger.error("Unable to parse deployed file " + artifact.getAbsolutePath(), e); } return false; }
@Override public InputStream getInputStream() throws IOException { try { ByteArrayOutputStream os = new ByteArrayOutputStream(); BlueprintTransformer.transform(new URL(url.getPath()), os); os.close(); return new ByteArrayInputStream(os.toByteArray()); } catch (Exception e) { logger.error("Error opening blueprint xml url", e); throw new IOException("Error opening blueprint xml url", e); } } }
@Override public InputStream getInputStream() throws IOException { try { ByteArrayOutputStream os = new ByteArrayOutputStream(); BlueprintTransformer.transform(new URL(url.getPath()), os); os.close(); return new ByteArrayInputStream(os.toByteArray()); } catch (Exception e) { logger.error("Error opening blueprint xml url", e); throw new IOException("Error opening blueprint xml url", e); } } }