/**
  * This method removes the identified method.
  *
  * @param method The method to remove.
  * @throws com.rift.coad.daemon.jython.JythonDaemonException
  */
 public void updateMethod(DataMapperMethod method) throws JythonDaemonException {
   try {
     Session session = SemanticUtil.getInstance(JythonMappingManagerDaemonImpl.class).getSession();
     List<DataMapperMethod> methods = listMethods(session);
     method.setService(Constants.SERVICE_ID);
     for (DataMapperMethod meth : methods) {
       if (meth.equals(method)) {
         session.persist(method);
         methods.remove(meth);
         methods.add(method);
         DataMapperBrokerUtil util1 =
             new DataMapperBrokerUtil(Constants.SERVICE_ID, Constants.DATA_MAPPER);
         util1.register(methods.toArray(new DataMapperMethod[0]));
         return;
       }
     }
     log.debug("The entry was not found to update.");
     throw new JythonDaemonException("The entry was not to update.");
   } catch (JythonDaemonException ex) {
     throw ex;
   } catch (Exception ex) {
     log.error("Failed to update the method : " + ex.getMessage(), ex);
     throw new JythonDaemonException("Failed to add method : " + ex.getMessage(), ex);
   }
 }
 /** This method is called to process events. */
 public void process() {
   while (!monitor.isTerminated()) {
     monitor.monitor();
   }
   try {
     SemanticUtil.closeInstance(JythonMappingManagerDaemonImpl.class);
   } catch (Exception ex) {
     log.error("Failed to close the semantic session manager : " + ex.getMessage(), ex);
   }
 }
 /**
  * This method returns a list of methods registered with the data mapper.
  *
  * @return The list of methods registered with this data mapper.
  * @throws com.rift.coad.daemon.jython.JythonDaemonException
  */
 public List<DataMapperMethod> listMethods() throws JythonDaemonException {
   try {
     return listMethods(
         SemanticUtil.getInstance(JythonMappingManagerDaemonImpl.class).getSession());
   } catch (JythonDaemonException ex) {
     throw ex;
   } catch (Exception ex) {
     log.error("Failed to retrieve a list of all the registered methods : " + ex.getMessage(), ex);
     throw new JythonDaemonException(
         "Failed to retrieve a list of all the registered methods : " + ex.getMessage(), ex);
   }
 }
  /**
   * This method adds a new method to the list of methods
   *
   * @param method This method adds the specified method.
   * @throws com.rift.coad.daemon.jython.JythonDaemonException
   */
  public void addMethod(DataMapperMethod newMethod) throws JythonDaemonException {
    try {
      Session session = SemanticUtil.getInstance(JythonMappingManagerDaemonImpl.class).getSession();
      List<DataMapperMethod> methods = listMethods(session);
      for (DataMapperMethod method : methods) {
        if (method.equals(newMethod)) {
          log.error("Duplicate method : " + newMethod.getName());
          throw new JythonDaemonException("Duplicate method : " + newMethod.getName());
        }
      }
      newMethod.setService(Constants.SERVICE_ID);
      methods.add(newMethod);
      session.persist(newMethod);

      DataMapperBrokerUtil util1 =
          new DataMapperBrokerUtil(Constants.SERVICE_ID, Constants.DATA_MAPPER);
      util1.register(methods.toArray(new DataMapperMethod[0]));
    } catch (JythonDaemonException ex) {
      throw ex;
    } catch (Exception ex) {
      log.error("Failed to add method : " + ex.getMessage(), ex);
      throw new JythonDaemonException("Failed to add method : " + ex.getMessage(), ex);
    }
  }