Java quick development framework lml menus and permissions

Source: Internet
Author: User

The harvest is not for no reason.

Any framework should have its own menu and permission management policies. lml was not available. Later I learned from it. Lml draws on the menus, permission management policies, and permission review policies of the castle. Monorail framework that the company is using without reservation to ensure the perfection of the shanzhai. Due to my limited ability, I have not read the source code of Castle. Monorail in actual circumstances. Sorry for the rough points. I will correct and improve them in the future.

A menu is a link. In lml, any method in each action can be a menu. In actual situations, we never use a method without returning a view as a menu, however, it may correspond to a permission.

The permission is not a link, but the access link, even through the menu access link, may need to pass the permission review. Links and permissions are also highly correlated.

Although I may explain it rough, you can understand the relationship as follows:

1. A menu has a link.

2. Access to a link may need to pass the permission review, that is, a link (possibly a menu) can correspond to a permission.

Note the following:

3. permissions in lml do not exist independently. They are displayed based on a menu. The reason is: In our module development, basically an action class corresponds to a module. A module is actually equivalent to a menu and all the permissions that appear in this action class, make it belong to this large menu, and it is related to collection and management.

The lml menu Permission Policy draws on Castle. Monorail to understand some problems. Please forgive me.

Four steps are required to use the lml menu and permission management policy:

1. Configure menu and permission initialization bean,CodeAs follows:

Permission initialization Bean

 
<BeanID= "Initmenupower"Class= "LML. Core. system. initmenupower"><PropertyName= "Packages"Value= "LML. Action. System, LML. Action. Article"/></Bean>

The initialization parameters are the package names that require the initialization menu and permissions. Separate multiple package names with commas.

2. Define a permission interceptor for the action configuration. The Code is as follows:

Custom permission interceptor

     <  Interceptors  >  <  Interceptor  Name  = "Power"  Class  = "LML. Core. system. powerinterceptor"  > </  Interceptor  >          < Interceptor-Stack  Name  = "Basestack"  >              <  Interceptor-ref  Name  = "Defaultstack"  > </  Interceptor-ref  >              <  Interceptor-ref  Name  = "Power"  > </ Interceptor-ref  >          </  Interceptor-Stack  >      </  Interceptors  > 

3. Define menus and permissions for methods (LINKS), and use annotations to define them in LML. The Code is as follows:

Use annotations to define menus and permissions

@ Sysmenu (menuid = "system", menuname = "System Management", menupic = "sys.png", menuparent = "", menulevel = 1, menusort = 1) @ Syspower (powerid= "Systempower", powermenu = "system", powername = "System Management View")Public VoidSystem (){}

The meanings of parameters of sysmenu are: menu ID, menu name, menu image, parent menu ID, menu level, and menu sorting.

Each parameter of syspower has the following meanings: Permission ID, menu ID, and permission name.

4. initialization.

Initialization: Collect the menus and permissions defined in step 3 in the system, and insert them to the database for permanent storage. There is no doubt that the database structure needs to be self-designed.

After completing the above four steps, the system will be able to automatically collect menus and permissions and manage them.

In the next set, we will talk about initialization operations.

After a brief introduction, I think everyone knows how to use menus and permissions in LML. I think you can design and develop a similar menu and permission management policy by yourself, it's also a bag of snacks. The requirement for lml is simple enough, and menus and permissions are no exception. Without complex concepts and complex syntax, you can use the preceding steps to integrate a business system into more flexible menu and permission management.

of course, this is not perfect. Simple strategies cannot do complicated things. Ugly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.