private Annotation doAnnotation(DataInputStream in, ElementType member, RetentionPolicy policy, boolean collect) throws IOException { int type_index = in.readUnsignedShort(); if (annotations == null) annotations = new HashSet<String>(); annotations.add(pool[type_index].toString()); if (policy == RetentionPolicy.RUNTIME) { descriptors.add(new Integer(type_index)); hasRuntimeAnnotations = true; } else { hasClassAnnotations = true; } String name = (String) pool[type_index]; int num_element_value_pairs = in.readUnsignedShort(); Map<String, Object> elements = null; for (int v = 0; v < num_element_value_pairs; v++) { int element_name_index = in.readUnsignedShort(); String element = (String) pool[element_name_index]; Object value = doElementValue(in, member, policy, collect); if (collect) { if (elements == null) elements = new LinkedHashMap<String, Object>(); elements.put(element, value); } } if (collect) return new Annotation(name, elements, member, policy); else return null; }
if (annotation.getName().equals(COMPONENT_ANNOTATION)) { def.name = annotation.get("name"); def.factory = annotation.get("factory"); def.enabled = annotation.get("enabled"); def.immediate = annotation.get("immediate"); String cp = (String) annotation.get("configurationPolicy"); if (cp != null) { def.configurationPolicy = cp.toLowerCase(); Object[] provides = (Object[]) annotation.get("provides"); if (provides == null) { def.provides = interfaces; } else if (annotation.getName().equals(ACTIVATE_ANNOTATION)) { def.activate = method; } else if (annotation.getName().equals(DEACTIVATE_ANNOTATION)) { def.deactivate = method; } else if (annotation.getName().equals(MODIFIED_ANNOTATION)) { def.modified = method; } else if (annotation.getName().equals(REFERENCE_ANNOTATION)) { ComponentDef.Reference ref = getReference(annotation, method); ref.multiple = (Boolean) annotation.get("multiple"); ref.optional = (Boolean) annotation.get("optional"); ref.dynamic = (Boolean) annotation.get("dynamic"); Integer c = annotation.get("type"); if (c != null) { switch (c.intValue()) {
public void annotation(Annotation annotation) { try { Meta.OCD ocd = annotation.getAnnotation(Meta.OCD.class); Meta.AD ad = annotation.getAnnotation(Meta.AD.class); if (ocd != null) { this.ocdAnnotation = annotation; } if (ad != null) { assert method != null; methods.put(method, ad); } } catch (Exception e) { reporter.error("Error during annotation parsing %s : %s", clazz, e); e.printStackTrace(); } }
private void doProperties(aQute.lib.osgi.Annotation annotation) { Object[] properties = annotation.get(Component.PROPERTIES); if (properties != null) { for (Object o : properties) { String p = (String) o; if (PROPERTY_PATTERN.matcher(p).matches()) this.properties.add(p); else throw new IllegalArgumentException("Malformed property '" + p + "' on: " + annotation.get(Component.NAME)); } } }
Meta.OCD ocd = null; if (this.ocdAnnotation != null) ocd = this.ocdAnnotation.getAnnotation(Meta.OCD.class); else ocd = Configurable.createConfigurable(Meta.OCD.class, id = this.designatePid; // for the felix problems } else { if (ocdAnnotation.get("factory") != null) { factory = true;
private Reference getReference(Annotation annotation, String method) { String name = (String) annotation.get("name"); if (name == null) { Matcher m = BINDMETHOD.matcher(method); if (m.matches()) { name = m.group(2).toLowerCase() + m.group(3); } else name = method; } return def.newReference(name); }
if (annotation.getName().equals(Component.RNAME)) { set(COMPONENT_NAME, annotation.get(Component.NAME), "<>"); set(COMPONENT_FACTORY, annotation.get(Component.FACTORY), false); setBoolean(COMPONENT_ENABLED, annotation.get(Component.ENABLED), true); setBoolean(COMPONENT_IMMEDIATE, annotation.get(Component.IMMEDIATE), false); setBoolean(COMPONENT_SERVICEFACTORY, annotation.get(Component.SERVICEFACTORY), false); if (annotation.get(Component.DESIGNATE) != null) { String configs = annotation.get(Component.DESIGNATE); if (configs != null) { set(COMPONENT_DESIGNATE, Clazz.objectDescriptorToFQN(configs), ""); if (annotation.get(Component.DESIGNATE_FACTORY) != null) { String configs = annotation.get(Component.DESIGNATE_FACTORY); if (configs != null) { set(COMPONENT_DESIGNATEFACTORY, Clazz.objectDescriptorToFQN(configs), ""); setVersion((String) annotation.get(Component.VERSION)); String configurationPolicy = annotation.get(Component.CONFIGURATION_POLICY); if (configurationPolicy != null) set(COMPONENT_CONFIGURATION_POLICY, configurationPolicy.toLowerCase(), ""); Object[] provides = (Object[]) annotation.get(Component.PROVIDE); String[] p; if (provides == null) { } else if (annotation.getName().equals(Activate.RNAME)) { if (!checkMethod())
String version = a.get("value"); if (!info.containsKey(Constants.VERSION_ATTRIBUTE)) { if (version != null) { Map<String, String> attrs = doAttrbutes((Object[]) a.get(Export.MANDATORY), clazz, getReplacer()); if (!attrs.isEmpty()) { attrs = doAttrbutes((Object[]) a.get(Export.OPTIONAL), clazz, getReplacer()); if (!attrs.isEmpty()) { info.putAll(attrs); Object[] included = a.get(Export.INCLUDE); if (included != null && included.length > 0) { StringBuilder sb = new StringBuilder(); Object[] excluded = a.get(Export.EXCLUDE); if (excluded != null && excluded.length > 0) { StringBuilder sb = new StringBuilder(); Object[] uses = a.get(Export.USES); if (uses != null && uses.length > 0) { String old = info.get(USES_DIRECTIVE);
private Annotation doAnnotation(DataInputStream in, ElementType member, RetentionPolicy policy, boolean collect) throws IOException { int type_index = in.readUnsignedShort(); if (annotations == null) annotations = new HashSet<String>(); annotations.add(pool[type_index].toString()); if (policy == RetentionPolicy.RUNTIME) { descriptors.add(new Integer(type_index)); hasRuntimeAnnotations = true; } else { hasClassAnnotations = true; } String name = (String) pool[type_index]; int num_element_value_pairs = in.readUnsignedShort(); Map<String, Object> elements = null; for (int v = 0; v < num_element_value_pairs; v++) { int element_name_index = in.readUnsignedShort(); String element = (String) pool[element_name_index]; Object value = doElementValue(in, member, policy, collect); if (collect) { if (elements == null) elements = new LinkedHashMap<String, Object>(); elements.put(element, value); } } if (collect) return new Annotation(name, elements, member, policy); else return null; }
@SuppressWarnings("unchecked") public <T extends java.lang.annotation.Annotation> T getAnnotation() throws Exception { String cname = Clazz.objectDescriptorToFQN(name); Class<T> c = (Class<T>) getClass().getClassLoader().loadClass(cname); return getAnnotation(c); } public <T extends java.lang.annotation.Annotation> T getAnnotation(Class<T> c)
component.factory = comp.factory(); component.configurationPolicy = comp.configurationPolicy(); if (annotation.get("enabled") != null) component.enabled = comp.enabled(); if (annotation.get("factory") != null) component.factory = comp.factory(); if (annotation.get("immediate") != null) component.immediate = comp.immediate(); if (annotation.get("servicefactory") != null) component.servicefactory = comp.servicefactory(); Object [] x = annotation.get("service");
public void annotation(Annotation annotation) { try { java.lang.annotation.Annotation a = annotation.getAnnotation(); if (a instanceof Component) doComponent((Component) a, annotation); else if (a instanceof Activate) doActivate(); else if (a instanceof Deactivate) doDeactivate(); else if (a instanceof Modified) doModified(); else if (a instanceof Reference) doReference((Reference) a, annotation); } catch (Exception e) { e.printStackTrace(); analyzer.error("During generation of a component on class %s, exception %s", clazz, e); } }
def.bind = method; def.interfce = raw.get("service"); if (def.interfce != null) { def.interfce = Clazz.objectDescriptorToFQN(def.interfce);