@Override public SourceURL get(Context ctx, Data item) throws Exception { Serializable s = r.get(ctx, item); return (s == null) ? null : new SourceURL(s.toString()); }
public SSLConnection(SourceURL url) throws Exception { super(url); this.host = url.getHost(); this.port = url.getPort(); if (url.getParameters().containsKey("keystorePassword")) this.password = url.getParameters().get("keystorePassword") .toCharArray(); else this.password = null; if (url.getParameters().containsKey("keystoreUrl")) { SourceURL ksUrl = new SourceURL(url.getParameters().get( "keystoreUrl")); loadKeyStore(ksUrl, password); } else this.keyStore = null; if (url.getParameters().containsKey("truststoreUrl")) { this.trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); SourceURL tsUrl = new SourceURL(url.getParameters().get( "truststoreUrl")); String trustpw = url.getParameters().get("truststorePassword"); if (trustpw == null) { trustpw = new String(password); } loadTrustStore(tsUrl, trustpw.toCharArray()); } else { this.trustStore = this.keyStore; } }
private SourceURL createUrl(String fileName) throws Exception { String urlString = url.getProtocol() + ":" + url.getPath() + "/" + fileName; return new SourceURL(urlString); }
/** * @see stream.urls.Connection#connect() */ @Override public InputStream connect() throws IOException { boolean removeAfterRead = "true".equalsIgnoreCase(url.getParameters() .get("remove")); String pattern = ".*"; if (url.getParameters().containsKey("pattern")) { pattern = url.getParameters().get("pattern"); } File file = new File(url.getPath()); seqFileStream = new SequentialFileInputStream(file, pattern, removeAfterRead); return seqFileStream; }
SourceURL src = new SourceURL(args[0]); log.info("Ttying to read configuration from {}", src); xml = XMLUtils.parseDocument(src.openStream()); } else { log.info("Reading XML configuration from {}", url);
/** * <p> * Returns a string representing the connection url (works currently only * with tcp connections). * </p> * * TODO Better: Implement and call SourceURL.toString() method * * @return a string representing the connection url */ protected String getConnectionString() { if (urlCache == null) { StringBuilder sb = new StringBuilder(url.getProtocol()); sb.append("://"); sb.append(url.getHost()); sb.append(":"); sb.append(url.getPort()); urlCache = sb.toString(); } return urlCache; }
dir = new File(this.url.getFile()); if (!dir.isDirectory() && (!(this.url.getProtocol() .equals(SourceURL.PROTOCOL_FILE)) || !(this.url .getProtocol().equals(SourceURL.PROTOCOL_CLASSPATH)))) throw new IllegalArgumentException("Given URL " + url.getPath() + "is no local directory"); else {
/** * @see stream.urls.Connection#connect() */ @Override public InputStream connect() throws IOException { if (stream == null) { Configuration config = new Configuration(); FileSystem fs = FileSystem.get(URI.create(url.toString()), config); stream = fs.open(new Path(url.toString())); } return stream; }
@Override public void init() throws Exception { if (filesAreRead.getAndSet(false)) { log.debug("Initializing directory stream with URL '{}'", url.toString()); log.debug(" file path of URL is: {}", url.getFile()); dir = new File(url.getFile()); // dir = new File(new URI(url.toString())); if (!dir.isDirectory()) throw new IllegalArgumentException("Directory not found"); dirPath = dir.getAbsolutePath(); files = dir.list(); counter = new AtomicInteger(0); } }
protected InputStream getInputStream() throws Exception { if (in == null) { in = url.openStream(); } return in; }
/** * @param url */ public TcpListener(SourceURL url) { super(url); port = url.getPort(); try { inputStream = new TcpInputStream(port); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } }
@Override public void init() throws Exception { log.debug("Initializing directory stream with URL '{}'", url.toString()); log.debug(" file path of URL is: {}", url.getFile()); dir = new File(url.getFile()); // dir = new File(new URI(url.toString())); if (!dir.isDirectory()) throw new IllegalArgumentException("Directory not found"); dirPath = dir.getAbsolutePath(); files = dir.list(); counter = 0; }
log.debug("Properties URL is: {}", purl); SourceURL propUrl = new SourceURL(purl); p.load(propUrl.openStream()); for (Object k : p.keySet()) { String key = k.toString();
/** * <p> * Returns a string representing the connection url (works currently only * with tcp connections). * </p> * * TODO Better: Implement and call SourceURL.toString() method * * @return a string representing the connection url */ protected String getConnectionString() { if (urlCache == null) { StringBuilder sb = new StringBuilder(url.getProtocol()); sb.append("://"); sb.append(url.getHost()); sb.append(":"); sb.append(url.getPort()); urlCache = sb.toString(); } return urlCache; }
dir = new File(this.url.getFile()); if (!dir.isDirectory() && (!(this.url.getProtocol() .equals(SourceURL.PROTOCOL_FILE)) || !(this.url .getProtocol().equals(SourceURL.PROTOCOL_CLASSPATH)))) throw new IllegalArgumentException("Given URL " + url.getPath() + "is no local directory"); else {
String theUrl = url.toString();
@Override public void init() throws Exception { if (filesAreRead.getAndSet(false)) { log.debug("Initializing directory stream with URL '{}'", url.toString()); log.debug(" file path of URL is: {}", url.getFile()); dir = new File(url.getFile()); // dir = new File(new URI(url.toString())); if (!dir.isDirectory()) throw new IllegalArgumentException("Directory not found"); dirPath = dir.getAbsolutePath(); files = dir.list(); counter = new AtomicInteger(0); } }