public void init(ProcessingContext env) throws NullPointerException { this.processingContext = env; // HashMap<P, HashSet<Name>> supportedAnnotationsMap = new HashMap<P, HashSet<Name>>(); LinkedHashMap<String, P> pluginMap = new LinkedHashMap<String, P>(); StringBuilder msg = new StringBuilder("Using plugins:"); for (P plugin : env.loadServices(pluginType)) { msg.append(" ").append(plugin.getName()); pluginMap.put(plugin.getName(), plugin); } env.info(msg); // Collect processed annotations HashSet<Class<? extends java.lang.annotation.Annotation>> supportedAnnotations = new HashSet<Class<? extends java.lang.annotation.Annotation>>(); for (P plugin : pluginMap.values()) { HashSet<Name> pluginSupportedAnnotations = new HashSet<Name>(); for (Class<? extends Annotation> annotationType : plugin.init(env)) { pluginSupportedAnnotations.add(Name.create(annotationType)); supportedAnnotations.add(annotationType); } env.info("Plugin " + plugin.getName() + " supports " + pluginSupportedAnnotations); supportedAnnotationsMap.put(plugin, pluginSupportedAnnotations); } // this.pluginMap = pluginMap; this.supportedAnnotationsMap = supportedAnnotationsMap; this.supportedAnnotations = supportedAnnotations; }
public void init(ProcessingContext env) throws NullPointerException { this.processingContext = env; // HashMap<P, HashSet<Name>> supportedAnnotationsMap = new HashMap<P, HashSet<Name>>(); LinkedHashMap<String, P> pluginMap = new LinkedHashMap<String, P>(); StringBuilder msg = new StringBuilder("Using plugins:"); for (P plugin : env.loadServices(pluginType)) { msg.append(" ").append(plugin.getName()); pluginMap.put(plugin.getName(), plugin); } env.info(msg); // Collect processed annotations HashSet<Class<? extends java.lang.annotation.Annotation>> supportedAnnotations = new HashSet<Class<? extends java.lang.annotation.Annotation>>(); for (P plugin : pluginMap.values()) { HashSet<Name> pluginSupportedAnnotations = new HashSet<Name>(); for (Class<? extends Annotation> annotationType : plugin.init(env)) { pluginSupportedAnnotations.add(Name.create(annotationType)); supportedAnnotations.add(annotationType); } env.info("Plugin " + plugin.getName() + " supports " + pluginSupportedAnnotations); supportedAnnotationsMap.put(plugin, pluginSupportedAnnotations); } // this.pluginMap = pluginMap; this.supportedAnnotationsMap = supportedAnnotationsMap; this.supportedAnnotations = supportedAnnotations; }
for (ValueType<?> valueType : ValueType.DEFAULT) { for (Class<?> type : valueType.getTypes()) { valueTypes.add(ElementHandle.Type.create(Name.create(type)));
for (ValueType<?> valueType : ValueType.DEFAULT) { for (Class<?> type : valueType.getTypes()) { valueTypes.add(ElementHandle.Type.create(Name.create(type)));
private void emitConfig(AnnotationKey key, AnnotationState added) { if (key.getType().equals(Name.create(RequiresGuest.class)) || key.getType().equals(Name.create(RequiresUser.class)) || key.getType().equals(Name.create(RequiresAuthentication.class)) || key.getType().equals(Name.create(RequiresRoles.class)) || key.getType().equals(Name.create(RequiresPermissions.class)) || key.getType().equals(Name.create(Login.class)) || key.getType().equals(Name.create(Logout.class))) { if (key.getElement() instanceof ElementHandle.Method) { Map<AnnotationKey, AnnotationState> annotations = methods.get(key.getElement()); if (annotations == null) { annotations = new HashMap<AnnotationKey, AnnotationState>(); methods.put(key.getElement(), annotations); } annotations.put(key, added); } else if (key.getElement() instanceof ElementHandle.Type) { if (key.getType().equals(Name.create(RequiresGuest.class)) || key.getType().equals(Name.create(RequiresAuthentication.class)) || key.getType().equals(Name.create(RequiresUser.class))) { Map<AnnotationKey, AnnotationState> annotations = controllers.get(key.getElement()); if (annotations == null) { annotations = new HashMap<AnnotationKey, AnnotationState>(); controllers.put(key.getElement(), annotations); } annotations.put(key, added); } else throw new UnsupportedOperationException("Unsupported " + key.getType() + " at " + key.getElement()); } } }
if (key.getType().equals(Name.create(RequiresGuest.class))) { controllerJSON.set("require", "guest"); } else if (key.getType().equals(Name.create(RequiresAuthentication.class))) { controllerJSON.set("require", "authenticate"); } else if (key.getType().equals(Name.create(RequiresUser.class))) { controllerJSON.set("require", "user");
private void emitConfig(JSON json, AnnotationKey key, AnnotationState added) { if (key.getType().equals(Name.create(Login.class))) { if (json.get("operator") != null) { throw new UnsupportedOperationException("Unsupported multiple operators at " + key.getElement()); } else if (key.getType().equals(Name.create(Logout.class))) { if (json.get("operator") != null) { throw new UnsupportedOperationException("Unsupported multiple operators at " + key.getElement()); } else if (key.getType().equals(Name.create(RequiresGuest.class))) { if (json.get("require") != null || json.get("permissions") != null || json.get("roles") != null) { throw new UnsupportedOperationException("Unsupported multiple requirements at " + key.getElement()); } else if (key.getType().equals(Name.create(RequiresUser.class))) { if (json.get("require") != null || json.get("permissions") != null || json.get("roles") != null) { throw new UnsupportedOperationException("Unsupported multiple requirements at " + key.getElement()); } else if (key.getType().equals(Name.create(RequiresAuthentication.class))) { if (json.get("require") != null || json.get("permissions") != null || json.get("roles") != null) { throw new UnsupportedOperationException("Unsupported multiple requirements at " + key.getElement()); } else if (key.getType().equals(Name.create(RequiresPermissions.class))) { if (json.get("require") != null) { throw new UnsupportedOperationException("Unsupported multiple requirements at " + key.getElement()); } else if (key.getType().equals(Name.create(RequiresRoles.class))) { if (json.get("require") != null) { throw new UnsupportedOperationException("Unsupported multiple requirements at " + key.getElement());
@Override public void processAnnotationAdded(ApplicationMetaModel metaModel, AnnotationKey key, AnnotationState added) { ElementHandle.Package handle = metaModel.getHandle(); if (key.getType().equals(Name.create(Shiro.class))) { JSON json = new JSON(); json.set("rememberMe", added.get("rememberMe")); json.set("config", added.get("config")); List<AnnotationState> realms = (List<AnnotationState>)added.get("realms"); JSON realmsJSON = new JSON(); if (realms != null) { for (AnnotationState sel : realms) { ElementHandle.Type clazz = (juzu.impl.compiler.ElementHandle.Type)sel.get("value"); String name = (String)sel.get("name"); realmsJSON.set(clazz.getName().toString(), new JSON().set("name", name)); } } json.set("realms", realmsJSON); enableMap.put(handle, json); } else { emitConfig(key, added); } }