private void handleInheritedClasses(Clazz child) throws Exception { TypeRef[] ifaces = child.getInterfaces(); if (ifaces != null) { for (TypeRef ref : ifaces) { parseAndMergeInheritedMetadata(ref, child); } } TypeRef superClazz = child.getSuper(); if (superClazz != null) { parseAndMergeInheritedMetadata(superClazz, child); } }
public InputStream openInputStream() throws IOException { final PipedInputStream pin = new PipedInputStream(); final PipedOutputStream pout = new PipedOutputStream(pin); getExecutor().execute(new Runnable() { public void run() { try { write(pout); } catch (IOException e) { // Cause an exception in the other end IO.close(pin); } IO.close(pout); } }); return pin; }
public void write(OutputStream out) throws IOException { try { finish(); } catch (Exception e) { throw new RuntimeException(e); } PrintWriter pw = new PrintWriter(new OutputStreamWriter(out, "UTF-8")); pw.println("<?xml version='1.0'?>"); metadata.print(0, pw); pw.flush(); }
private void parseAndMergeInheritedMetadata(TypeRef ref, Clazz child) throws Exception { if (ref.isJava()) return; Clazz ec = reporter.findClass(ref); if (ec == null) { reporter.error("Missing inherited class for Metatype annotations: " + ref + " from " + child.getClassName()); } else { MetaTypeReader mtr = new MetaTypeReader(ec, reporter); mtr.setDesignate(designatePid, factory); mtr.finish(); for (Map.Entry<MethodDef,Meta.AD> entry : mtr.methods.entrySet()) addMethod(entry.getKey(), entry.getValue()); handleInheritedClasses(ec); } }
/** * Create a Metatype and Designate record out of the given * configurations. * * @param name * @param config * @throws Exception */ private boolean designate(String name, String config, boolean factory) throws Exception { if (config == null) return false; for (String c : Processor.split(config)) { TypeRef ref = analyzer.getTypeRefFromFQN(c); Clazz clazz = analyzer.findClass(ref); if (clazz != null) { analyzer.referTo(ref); MetaTypeReader r = new MetaTypeReader(clazz, analyzer); r.setDesignate(name, factory); String rname = "OSGI-INF/metatype/" + name + ".xml"; analyzer.getJar() .putResource(rname, r); } else { analyzer.error("Cannot find designated configuration class %s for component %s", c, name); } } return true; }
public boolean analyzeJar(Analyzer analyzer) throws Exception { Parameters map = analyzer.parseHeader(analyzer.getProperty(Constants.METATYPE)); Jar jar = analyzer.getJar(); for (String name : map.keySet()) { Collection<Clazz> metatypes = analyzer.getClasses("", QUERY.ANNOTATED.toString(), Meta.OCD.class.getName(), // QUERY.NAMED.toString(), name // ); for (Clazz c : metatypes) { jar.putResource("OSGI-INF/metatype/" + c.getFQN() + ".xml", new MetaTypeReader(c, analyzer)); } } return false; } }
public void run() { try { write(pout); } catch (IOException e) { // Cause an exception in the other end IO.close(pin); } IO.close(pout); } });
private void parseAndMergeInheritedMetadata(TypeRef ref, Clazz child) throws Exception { if (ref.isJava()) return; Clazz ec = reporter.findClass(ref); if (ec == null) { reporter.error("Missing inherited class for Metatype annotations: %s from %s", ref, child.getClassName()); } else { @SuppressWarnings("resource") MetaTypeReader mtr = new MetaTypeReader(ec, reporter); mtr.setDesignate(designatePid, factory); mtr.finish(); for (Map.Entry<MethodDef, Annotation> entry : mtr.methods.entrySet()) addMethod(entry.getKey(), entry.getValue()); handleInheritedClasses(ec); } }
/** * Create a Metatype and Designate record out of the given * configurations. * * @param name * @param config * @throws Exception */ private boolean designate(String name, String config, boolean factory) throws Exception { if (config == null) return false; for (String c : Processor.split(config)) { TypeRef ref = analyzer.getTypeRefFromFQN(c); Clazz clazz = analyzer.findClass(ref); if (clazz != null) { analyzer.referTo(ref); MetaTypeReader r = new MetaTypeReader(clazz, analyzer); r.setDesignate(name, factory); String rname = "OSGI-INF/metatype/" + name + ".xml"; analyzer.getJar().putResource(rname, r); } else { analyzer.error("Cannot find designated configuration class %s for component %s", c, name); } } return true; }
@Override public void write(OutputStream out) throws IOException { try { finish(); } catch (Exception e) { throw new RuntimeException(e); } PrintWriter pw = new PrintWriter(new OutputStreamWriter(out, "UTF-8")); pw.println("<?xml version='1.0'?>"); metadata.print(0, pw); pw.flush(); }
private void handleInheritedClasses(Clazz child) throws Exception { TypeRef[] ifaces = child.getInterfaces(); if (ifaces != null) { for (TypeRef ref : ifaces) { parseAndMergeInheritedMetadata(ref, child); } } TypeRef superClazz = child.getSuper(); if (superClazz != null) { parseAndMergeInheritedMetadata(superClazz, child); } }
private void parseAndMergeInheritedMetadata(TypeRef ref, Clazz child) throws Exception { if (ref.isJava()) return; Clazz ec = reporter.findClass(ref); if (ec == null) { reporter.error("Missing inherited class for Metatype annotations: " + ref + " from " + child.getClassName()); } else { MetaTypeReader mtr = new MetaTypeReader(ec, reporter); mtr.setDesignate(designatePid, factory); mtr.finish(); for (Map.Entry<MethodDef,Meta.AD> entry : mtr.methods.entrySet()) addMethod(entry.getKey(), entry.getValue()); handleInheritedClasses(ec); } }
/** * Create a Metatype and Designate record out of the given * configurations. * * @param name * @param config * @throws Exception */ private boolean designate(String name, String config, boolean factory) throws Exception { if (config == null) return false; for (String c : Processor.split(config)) { TypeRef ref = analyzer.getTypeRefFromFQN(c); Clazz clazz = analyzer.findClass(ref); if (clazz != null) { analyzer.referTo(ref); MetaTypeReader r = new MetaTypeReader(clazz, analyzer); r.setDesignate(name, factory); String rname = "OSGI-INF/metatype/" + name + ".xml"; analyzer.getJar().putResource(rname, r); } else { analyzer.error("Cannot find designated configuration class %s for component %s", c, name); } } return true; }
@Override public void write(OutputStream out) throws IOException { try { finish(); } catch (Exception e) { throw new RuntimeException(e); } PrintWriter pw = new PrintWriter(new OutputStreamWriter(out, "UTF-8")); pw.println("<?xml version='1.0'?>"); metadata.print(0, pw); pw.flush(); }
private void handleInheritedClasses(Clazz child) throws Exception { TypeRef[] ifaces = child.getInterfaces(); if (ifaces != null) { for (TypeRef ref : ifaces) { parseAndMergeInheritedMetadata(ref, child); } } TypeRef superClazz = child.getSuper(); if (superClazz != null) { parseAndMergeInheritedMetadata(superClazz, child); } }
/** * Create a Metatype and Designate record out of the given * configurations. * * @param name * @param config * @throws Exception */ private boolean designate(String name, String config, boolean factory) throws Exception { if (config == null) return false; for (String c : Processor.split(config)) { TypeRef ref = analyzer.getTypeRefFromFQN(c); Clazz clazz = analyzer.findClass(ref); if (clazz != null) { analyzer.referTo(ref); MetaTypeReader r = new MetaTypeReader(clazz, analyzer); r.setDesignate(name, factory); String rname = "OSGI-INF/metatype/" + name + ".xml"; analyzer.getJar() .putResource(rname, r); } else { analyzer.error("Cannot find designated configuration class %s for component %s", c, name); } } return true; }
@Override public void write(OutputStream out) throws IOException { try { finish(); } catch (Exception e) { throw new RuntimeException(e); } PrintWriter pw = new PrintWriter(new OutputStreamWriter(out, "UTF-8")); pw.println("<?xml version='1.0'?>"); metadata.print(0, pw); pw.flush(); }
private void handleInheritedClasses(Clazz child) throws Exception { TypeRef[] ifaces = child.getInterfaces(); if (ifaces != null) { for (TypeRef ref : ifaces) { parseAndMergeInheritedMetadata(ref, child); } } TypeRef superClazz = child.getSuper(); if (superClazz != null) { parseAndMergeInheritedMetadata(superClazz, child); } }
@Override public void write(OutputStream out) throws IOException { try { finish(); } catch (Exception e) { throw new RuntimeException(e); } PrintWriter pw = IO.writer(out, UTF_8); pw.print("<?xml version='1.0' encoding='UTF-8'?>\n"); metadata.print(0, pw); pw.flush(); }
@Override public void write(OutputStream out) throws IOException { try { finish(); } catch (Exception e) { throw new RuntimeException(e); } PrintWriter pw = IO.writer(out, UTF_8); pw.print("<?xml version='1.0' encoding='UTF-8'?>\n"); metadata.print(0, pw); pw.flush(); }