/** @return the managementBeanFactory */
 ManagementBeanFactory getManagementBeanFactory() throws DMException {
   if (this.managementBeanFactory == null) {
     List<SetupProperties> setOfProperties = this.getSetOfProperties();
     Properties properties = SetupPropertiesHelper.getProperties(setOfProperties);
     return ManagementBeanFactory.newInstance(properties);
   }
   return managementBeanFactory;
 }
  /**
   * @param message
   * @param httpRequest
   * @throws Sync4jException
   */
  private void process4IMEI(SyncML message, HttpServletRequest httpRequest) throws Sync4jException {
    // Get parameter
    String bsp = httpRequest.getParameter(BootstrapService.BOOTSTRAP_PARAMETRERS_NAME);
    URLParameters params = URLParameters.decode(bsp);
    if (params == null) {
      return;
    }
    String bootstrapDeviceExtID = params.getDeviceExtID();
    // String bootstrapDeviceID =
    // httpRequest.getParameter(BootstrapService.BOOTSTRAP_DEVICE_ID_PARAMETER_NAME);
    if (StringUtils.isEmpty(bootstrapDeviceExtID)) {
      return;
    }
    // Get Real IMEI
    String deviceExternalID = message.getSyncHdr().getSource().getLocURI();

    if (bootstrapDeviceExtID.equalsIgnoreCase(deviceExternalID)) {
      return;
    }
    ManagementBeanFactory factory = null;
    try {
      factory = ManagementBeanFactory.newInstance(EngineConfig.getProperties());

      DeviceBean deviceBean = factory.createDeviceBean();
      Device d = deviceBean.getDeviceByExternalID(deviceExternalID);
      if (d != null) {
        // Already exists, give up
        return;
      }

      Device device = deviceBean.getDeviceByExternalID(bootstrapDeviceExtID);
      if (device != null) {
        log.info("Change device IMEI from: " + device.getExternalId() + " to: " + deviceExternalID);
        factory.beginTransaction();
        device.setExternalId(deviceExternalID);
        deviceBean.update(device);
        factory.commit();
      }

    } catch (Exception ex) {
      if (factory != null) {
        factory.rollback();
      }
      log.error(
          "Failure in change device IMEI from: "
              + bootstrapDeviceExtID
              + " to: "
              + deviceExternalID,
          ex);
    } finally {
      if (factory != null) {
        factory.release();
      }
    }
  }