Implementing Registrar

  1. follow general java practices to create a java file inside src/ directory. You can name it anyway you want too, and place it in any package you want too.

  2. import following three classes:
    import psoft.hsphere.resource.registrar.LoggableRegistrar;
    import psoft.hsphere.resource.registrar.RegistrarTransactionData;
    import psoft.hsphere.resource.registrar.RegistrarException;
  3. Create your registrar class:
    public class MyRegistrar extends LoggableRegistrar {
    Note: You should use AsyncLoggableRegistrar in case if you are implementing a registrar that supports asyncronic registration.
  4. Create log variable, that you will later use for loggin purposes (see log4j manual for more info):
        private static org.apache.log4j.Category log =
  5. Define member variables for registrar settings, to keep info like server name, port, login & password (as well as any other variables you might need):
        protected String server;
        protected int port;
        protected String login;
        protected String password;
  6. implement constructor, with two arguments Integer id, String description. Initialize registrar settings. You can perform any other initialization actions there as well. The id parameter corresponds to Entity ID.
    public MyRegistrar(Integer id, String description) throws Exception {
      super(id, description);
      /* see Deployment Descriptor form tag for defining registrar settings */
      server = get("server");
      try {
        port = Integer.parseInt(get("port"));
      } catch (NumberFormatException nfe) {
        port = 20001; //setting default port value, if we cannot parse the settings
      login = get("login");
      password = get("password");
  7. Implement all the methods of Registar interface and abstract merhods of the LoggableRegistrar. If any of the methods cannot be implemented, because it is not supported by registrar, throw following exception inside the body of the message:
      throw new RegistrarException(RegistrarException.NOT_IMPLEMENTED,
                "NOT IMPLEMENTED");
  8. Implement getSupportedTLDs method. It should list TLDs that are supported by this implementation of registrar.
        public String[] getSupportedTLDs() throws Exception {
            return new String[]{"com", "net", "org", "biz", "info", "us"};
* The implementation of registrar class has to be thread safe, as single object will be used for all domain registrations using that registrar.