protected static Resource toResource(Object value) { if (value instanceof File) { return new FileResource((File) value); } else if (value instanceof URL) { return new URLResource((URL) value); } else { throw new IllegalArgumentException("Cannot convert value " + value + " into a Resource. Expected File or URL"); } }
protected static Resource toResource(Object value) { if (value instanceof File) { return new FileResource((File) value); } else if (value instanceof URL) { return new URLResource((URL) value); } else { throw new IllegalArgumentException("Cannot convert value " + value + " into a Resource. Expected File or URL"); } }
static void traverse(Jar jar, int rootlength, File directory, Pattern doNotCopy) { if (doNotCopy.matcher(directory.getName()).matches()) return; File files[] = directory.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) traverse(jar, rootlength, files[i], doNotCopy); else { String path = files[i].getAbsolutePath().substring( rootlength + 1); if (File.separatorChar != '/') path = path.replace(File.separatorChar, '/'); jar.putResource(path, new FileResource(files[i]), true); } } }
static void traverse(Jar jar, int rootlength, File directory, Pattern doNotCopy) { if (doNotCopy != null && doNotCopy.matcher(directory.getName()).matches()) return; jar.updateModified(directory.lastModified(), "Dir change"); File files[] = directory.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) traverse(jar, rootlength, files[i], doNotCopy); else { String path = files[i].getAbsolutePath().substring( rootlength + 1); if (File.separatorChar != '/') path = path.replace(File.separatorChar, '/'); jar.putResource(path, new FileResource(files[i]), true); } } }
public Resource make(Builder builder, String destination, Map<String, String> argumentsOnMake) throws Exception { String type = argumentsOnMake.get("type"); if (!type.equals("copy")) return null; String from = argumentsOnMake.get("from"); if (from == null) { String content = argumentsOnMake.get("content"); if (content == null) throw new IllegalArgumentException( "No 'from' or 'content' field in copy " + argumentsOnMake); return new EmbeddedResource(content.getBytes("UTF-8"),0); } else { File f = builder.getFile(from); if (f.isFile()) return new FileResource(f); else { try { URL url = new URL(from); return new URLResource(url); } catch(MalformedURLException mfue) { // We ignore this } throw new IllegalArgumentException( "Copy source does not exist " + from + " for destination " + destination); } } }
public Resource make(Builder builder, String destination, Map<String, String> argumentsOnMake) throws Exception { String type = argumentsOnMake.get("type"); if (!type.equals("copy")) return null; String from = argumentsOnMake.get("from"); if (from == null) { String content = argumentsOnMake.get("content"); if (content == null) throw new IllegalArgumentException( "No 'from' or 'content' field in copy " + argumentsOnMake); return new EmbeddedResource(content.getBytes("UTF-8"),0); } else { File f = builder.getFile(from); if (f.isFile()) return new FileResource(f); else { try { URL url = new URL(from); return new URLResource(url); } catch(MalformedURLException mfue) { // We ignore this } throw new IllegalArgumentException( "Copy source does not exist " + from + " for destination " + destination); } } }
public static ComponentDef getComponentDef(File f) throws Exception { Resource r = new FileResource(f); Clazz c = new Clazz("", r); AnnotationReader car = new AnnotationReader(c); return car.getComponent(); }
private void copy(Jar jar, String path, File from, boolean preprocess, Map<String, String> extra) throws Exception { if (doNotCopy.matcher(from.getName()).matches()) return; if (from.isDirectory()) { File files[] = from.listFiles(); for (int i = 0; i < files.length; i++) { copy(jar, appendPath(path,files[i].getName()), files[i], preprocess, extra); } } else { if (from.exists()) { Resource resource = new FileResource(from); if (preprocess) { resource = new PreprocessResource(this, resource); } String x = extra.get("extra"); if (x != null) resource.setExtra(x); if (path.endsWith("/")) path = path + from.getName(); jar.putResource(path, resource); } else { error("Input file does not exist: " + from); } } }
if (ff.isFile()) { dot.putResource("OSGI-OPT/src/" + pack + fixed[j], new FileResource(ff)); new FileResource(f));
String name = "OSGI-OPT/src/" + pack + fixed[j]; dot.putResource(name, new FileResource(ff)); dot.putResource("OSGI-OPT/src/" + path, new FileResource(f));
private void copy(Jar jar, String path, File from, boolean preprocess, Map<String, String> extra) throws Exception { if (doNotCopy(from.getName())) return; if (from.isDirectory()) { File files[] = from.listFiles(); for (int i = 0; i < files.length; i++) { copy(jar, appendPath(path, files[i].getName()), files[i], preprocess, extra); } } else { if (from.exists()) { Resource resource = new FileResource(from); if (preprocess) { resource = new PreprocessResource(this, resource); } String x = extra.get("extra"); if (x != null) resource.setExtra(x); if (path.endsWith("/")) path = path + from.getName(); jar.putResource(path, resource); if (isTrue(extra.get(LIB_DIRECTIVE))) { setProperty(BUNDLE_CLASSPATH, append(getProperty(BUNDLE_CLASSPATH), path)); } } else { error("Input file does not exist: " + from); } } }
String name = getName(skip, prefix, c, ".jar"); if (name != null) output.putResource(name, new FileResource(c.getFile())); trace("storing %s in %s", c, name); break; String name = getName(skip, prefix, c, ".lib"); if (name != null) { output.putResource(name, new FileResource(c.getFile())); trace("store library %s", name); for (Container child : c.getMembers()) {