Writing a Java class as a service component

This procedure shows how to write a Java class as a service component using these methods:

  1. Use a text editor to write a Java file that includes the three Java methods. For example:

    package serviceTest;
    public class oneService {
        boolean bstop = false;
        public void start()
    {
                System.out.println("oneService start!");
                bstop = false;
    }
    
        public void run()
        {
             while(!bstop)
             {
                    System.out.println("oneService runing...");
                     try {
                             Thread.sleep(1000);
                  }catch (InterruptedException e) { 
                   }
             }
        }
    
         public void stop()
         {
              bstop = true;
              System.out.println("oneService stop!");
         }
    }
    
  2. Save and compile this Java file to a class file.

  3. Create a JAR file for the class file.

  4. Place the JAR file in %EAServer%\lib\ext\.

  5. Log in to the Management Console.

  6. Select the Service Components folder, right-click, and select Add.

    1. Type the name of the service component, for example, oneservice.

    2. Choose Finish.

  7. Select oneservice from the Service Components subfolders.

    1. Type the name of the component in the Component property field on the right side of the Management Console window. For example, serviceTest.oneService.

    2. Select the Start Before Binding check box.

    3. Select Apply to save the new settings.

  8. Select the Servers folder.

    1. Select the server where EAServer is running. For example, zeus-deskwxp.

    2. Select the Services tab.

    3. Select the service component that you have just created, for example, oneservice from the list.

    4. Click Apply to save the new settings.

  9. Restart EAServer.

When you run the service component, the log file or console displays these messages:

oneService start!
oneService runing...”,

If you stop EAServer, the log file or console displays this message:

oneService stop!”