title: Share code (which uses an abstract operation) between two classes
body: <p>I'm developping a server application in Java. The server need two type of server classes. These classes have some methods in common, the code in these methods is exactly the same. So i create an abstract super-class containing all the shared code, and both classes are inheriting it. But, there is some part of the code that need to be precised by subclasses. I mean that the superclass "rely" on subclasses methods.</p>
  
  <p>Here is a purified example of what i mean:</p>
  
  <pre><code>public abstract class AbstractServer
  {
      public void loadConfig(String configPath)
      {
          //Load the configuration file.
  
          //This code is exactly the same for subclasses.
      }
  
      public void startRMI(int port)
      {
          //Create an empty RMI registry.
          //This part also need to be identical.
  
          //Here' where the superclass "rely" on subclasses.
          fillRegistry(); //Call the method overwritten by subclasses.
      }
  
      /**
      Bind remote objects in the RMI registry
      */
      protected abstract void fillRegistry(); //This method will be overriten by subclasses.
  }
  </code></pre>
  
  <p>I feel that it's really bad to make it like that, but i can't find another cleaner way to do it.</p>
  
  <p>So, what i want is some advice on how i could make it better.</p>
  
  <p>Thanks, and sorry for my bad english.</p>