Define an annotation first
Import java.lang.annotation.Retention; Import Java.lang.annotation.RetentionPolicy, @Retention (retentionpolicy.runtime) public @Interface annotationlimit { String mid (); String pid ();}
Public Static voidMain (string[] args)throwsNosuchmethodexception, SecurityException {method= Testexc.class. Getdeclaredmethod ("hehe", String.class); if(Method.isannotationpresent (Annotationlimit.class) ) {Annotationlimit an= Method.getannotation (annotationlimit.class); System.out.println (An.mid ()+"#" +an.pid ()); }Else{System.out.println ("No Limit"); }} @AnnotationLimit (Mid= "1", pid= "2") Static voidhehe (String s) {System.out.println ("NNN"); }
Coarse-grained permission control, usually through the session, session of the word because the user after logging on after modifying the database state, the user can not be controlled by real-time database query.
Through annotations can get configuration information combined with user ID for real-time query to see if the URL can access the corresponding method to achieve fine-grained permission control.
Fine-grained permission control with annotation @