我正在开发一个需要基于对象的身份验证和授权的服务器端应用程序.我喜欢Shiro的简单性,但为了与JAAS兼容,我编写了一个使用Apache Shiro作为底层机制的LoginModule.
但我的问题是我找不到将JAAS授权检查委托给Shiro的方法.我怎样才能做到这一点?
我写了一个包含属性元数据的自定义注释,并且AnnotationProcessor:
@SupportedAnnotationTypes({"<package>.Property"})
public class PropertyProcessor extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
// Get messager object
Messager messager = processingEnv.getMessager();
// Iterate through the annotations
for(TypeElement typeElement : annotations) {
// Iterate through the annotated elements
for(Element element : roundEnv.getElementsAnnotatedWith(typeElement)) {
// Get Property annotation
Property property = element.getAnnotation(Property.class);
}
}
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
这是一个问题,我之前使用过Javassist,但它依赖于类加载器,我认为它不适合OSGi应用程序.我想在Property编译带有注释的类时更改生成的字节码.
在Java中,有没有办法在类A的成员方法中创建扩展抽象类A的任何类的实例?扩展抽象类A的类将使用此方法返回其实例,但我不想在所有子类中使用"return this();"实现相同的方法.亲切的.
编辑:对不起,简短的解释.在我的应用程序中,有一个名为Application的接口,它有一个返回Application类型的getInstance()方法.有一个名为AbstractApplication的抽象类,它是Application接口实现的便利类,但只有接口在其他应用程序中公开.在其他一些应用程序中,将会查找应用程序对象,此查找将返回应用程序类型(接口),而不是特定的实现.现在这是我的问题; 有没有办法在AbstractApplication类中实现getInstance(),所以子类不需要实现这个方法?