Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of automatic generation of zkconfigutil resolve

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "what is the method of automatic generation of zkconfigutil resolve". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

This template is actually eclipse editor template, which is a xml file. You can go to Window-> Preferences-> Java-> Editor-> Templates

Select import to import the xml

Suppose you have seen the use or principle implementation of zkconfigutil, and we know that in order to implement a zookeeper configuration for a property of a class, we need to write our own resolve for each field, which is very heavy and repetitive, so with this tool, if I have a Demo class

@ TypeZkConfigurable (path = "/ test/jerry", server = "localhost:2181", useOwnZkServer = false) public final class Demo {@ FieldZkConfigurable (resolve = DemoF1Resolve.class, dynamicUpdate = true) public static String F1 = "F1"; @ FieldZkConfigurable (resolve = DemoF2Resolve.class, dynamicUpdate = true) public static String F2 = "F2"; @ FieldZkConfigurable (resolve = DemoF3Resolve.class, dynamicUpdate = true) public static Boolean F3 = false;}

Now I want to write the DemoF2Resolve.class of the F2 field. You can write F2 in the blank space of the demo (it must be the same as the name of the corresponding attribute, or you can adjust it yourself), and then press the shortcut key of eclipse. Generally, ALT+/, will see resolve in the prompt list. Selecting this resolve,eclipse will generate DemoF2Resolve.class based on resolve_template.xml, if your property is of string type. Then you don't need to do anything next, you can use the

The code example is as follows:

Private static final class DemoF2Resolve extends AbstractResolve {@ Override public String resolve () {/ / TODO Auto-generated method stub return Demo.F2.toString () } @ Override public void dResolve (String src) {/ / TODO Auto-generated method stub Demo.F2 = src;}}

Add a generic resolve generation template

The cast_resolve_template.xml file is under the project template, address: cast_resolve_template

The automatically generated resolve is as follows:

Public static final class DemoF3Resolve extends AbstractResolve {@ Override public String resolve () {/ / TODO Auto-generated method stub return Demo.F3.toString () } @ Override public void dResolve (String src) {/ / TODO Auto-generated method stub Demo.F3 = Demo.F3.getClass (). Cast (src);} "what is the automatic generation method of zkconfigutil resolve"? thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report