Learn notes - Add a Restart Server function to Lomboz

xiaoxiao2021-03-06  86

Add a Restart Server feature to Lomboz recently learned Java. Today, there is nothing to read at home, open the eclipse213 to write a few servlets, each modified code must first pass the Lomboz menu Stop Server and Run Server to repeatedly start Stop jboss, really TMD trouble, suddenly there is an idea to have an idea to emerge in my mind, then add a restartserver menu command to Lomboz, so you can restart JBOSS, haha, good idea, do you have to do it. Since I didn't have seen the information on ECLISP plug-in, I tried it according to the three-pool of cats learned, let everyone laugh ~~ First search the Lomboz plug-in directory to find the class or configuration file used by the menu, that is, through Windows The resource manager searches for a file containing the "Run Server" string.

I found a Plugin.xml file under D: /eclipse213/plugins/com.ObjectLearn.jdt.j2ee, open to see, there are such a few sentences Wow, excitement, this is not the right-click menu of Lomboz (old bird is not allowed to laugh, I haven't seen ECLISP plug-in development information ~)! See what it means: label = "restart server" tooltip = "launch the application server in run mode after stop the application" class = "com.ObjectLearn.jdt .j2ee.ui.Actions.launchrestartAction "MenuBarpath =" J2EE.MAIN / Group1 "(Command menu group) ID =" com.objectlearn.j2ee.Actions.launch "(menu item ID name) Since you are not a old bird, you don't know how to have a deep meaning of these projects. In short, you will write a back, the code is as follows:

ID = "com.Objectlearn.j2ee.Actions.launchrestArtAction> After the modification, start Eclipse, find that as I imagined, there is a restart server in the Lomboz right-click menu, the heart is stealing :) I plan to Herd the restart server command writes in com.objectLearn.jdt.j2ee.ui.Actions.launchrestartAction, how to write this class? Rewote? It seems to be very troublesome, or see if you can use the original Run Server and Stop Server command classes, after all, you will be started with Stop Server and then Run Server, think of this D: /Eclipse213/plugins/com.ObjectLepsen. JDT.j2ee's Lomboz.jar unwielded, and found launchrunAction.class according to com.Objectlearn.jdt.j2ee.ui.Actions.launchrunAction, this class is C: / javadc / lomboz2 / COM / ObjectlearN / JDT / J2EE / Ui / actions / launchrunAction.class, use DJ Java Decompiler 3.7 to compile, good, code readability is very good, probably looked at the code to find that the specific server operation action is in C: / Javadc / Lomboz2 / COM / objectlearn / jdt / j2ee / launcher / J2EELaunchConfiguration.class completed in that way have a specific idea in J2EELaunchConfiguration.class added a restart method: public static void restart (IProject project, TargetServer selectedServer, String mode) throws CoreException , Exception {Try {stop (project, selectedserver); // originally used to stop the server in the class Run (Project, SELECTEDSERVER, MODE); // Originally in the class for starting the server} catch (Exception E ) {}} Compiled, prompting 59 errors, carefully look at the class path, according to the error prompt, modify the classpath, then compile, pass! ! Cool!

It is to resolve how to call the Restart method by right-click menu, first copy a launchrunAction.class in a C: / Javadc / Lomboz2 / COM / ObjectLearn / JDT / J2EE / UI / ActionS directory named LaunchrestAction.class, this name The Class description in the plugin.xml file corresponds to, the anti-compile launchrestAction.class, the code is also very well-readable, found below: public void run (IAAADITION Action) {Run (New irunnablewithProgress () {

public void run (IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {IFolder folder = (IFolder) getSelectedResources () [0]; Project p = Project.findProject (folder.getProject ()); Module container = (Module) p.getContainers () .get (folder); if (container! = null) try {// will be modified by the statement, here is the starter server J2EELAUNCONFIGURATION.Run (p.GetProject (), Container.getDefaultTargetServer (), "run");} Catch (Exception E) {J2EEPLUGIN.LOG (E);}}}, "Error Launching Container", 1);

Because the J2ELAUNCONFIGURATION class has just added a restart method, just call it, and modify J2EELAUNCONFIGURATION.RUN to j2eelaunchconfiguration.restart is constant, compiled, because just put the classpath, this time By compiling. Now all the files have been made, open D: /eclipse213/plugins/com.ObjectLearn.jdt.j2ee Lomboz.jar, the modified file override the file in the jar package, start Eclipse, haha, Success! !

转载请注明原文地址:https://www.9cbs.com/read-122694.html

New Post(0)