Stuart McCulloch | 26e7a5a | 2011-10-17 10:31:43 +0000 | [diff] [blame^] | 1 | package aQute.bnd.make.metatype; |
| 2 | |
| 3 | import java.util.*; |
| 4 | |
| 5 | import aQute.bnd.annotation.metatype.*; |
| 6 | import aQute.bnd.service.*; |
| 7 | import aQute.lib.osgi.*; |
| 8 | import aQute.lib.osgi.Clazz.*; |
| 9 | |
| 10 | /** |
| 11 | * This class is responsible for meta type types. It is a plugin that can |
| 12 | * @author aqute |
| 13 | * |
| 14 | */ |
| 15 | public class MetatypePlugin implements AnalyzerPlugin { |
| 16 | |
| 17 | public boolean analyzeJar(Analyzer analyzer) throws Exception { |
| 18 | |
| 19 | Map<String, Map<String, String>> map = analyzer.parseHeader(analyzer |
| 20 | .getProperty(Constants.METATYPE)); |
| 21 | |
| 22 | Jar jar = analyzer.getJar(); |
| 23 | for (String name : map.keySet()) { |
| 24 | Collection<Clazz> metatypes = analyzer.getClasses("", QUERY.ANNOTATION.toString(), |
| 25 | Meta.OCD.class.getName(), // |
| 26 | QUERY.NAMED.toString(), name // |
| 27 | ); |
| 28 | for (Clazz c : metatypes) { |
| 29 | jar.putResource("OSGI-INF/metatype/" + c.getFQN() + ".xml", new MetaTypeReader(c, |
| 30 | analyzer)); |
| 31 | } |
| 32 | } |
| 33 | return false; |
| 34 | } |
| 35 | } |