コード例 #1
5
  @Test
  public void testCnxManagerTimeout() throws Exception {
    Random rand = new Random();
    byte b = (byte) rand.nextInt();
    int deadPort = PortAssignment.unique();
    String deadAddress = new String("10.1.1." + b);

    LOG.info("This is the dead address I'm trying: " + deadAddress);

    peers.put(
        Long.valueOf(2),
        new QuorumServer(
            2,
            new InetSocketAddress(deadAddress, deadPort),
            new InetSocketAddress(deadAddress, PortAssignment.unique())));
    peerTmpdir[2] = ClientBase.createTmpDir();

    QuorumPeer peer =
        new QuorumPeer(peers, peerTmpdir[1], peerTmpdir[1], peerClientPort[1], 3, 1, 1000, 2, 2);
    QuorumCnxManager cnxManager = new QuorumCnxManager(peer);
    QuorumCnxManager.Listener listener = cnxManager.listener;
    if (listener != null) {
      listener.start();
    } else {
      LOG.error("Null listener when initializing cnx manager");
    }

    long begin = System.currentTimeMillis();
    cnxManager.toSend(new Long(2), createMsg(ServerState.LOOKING.ordinal(), 1, -1, 1));
    long end = System.currentTimeMillis();

    if ((end - begin) > 6000) fail("Waited more than necessary");
  }
コード例 #2
1
ファイル: MyConfig.java プロジェクト: code-Blog/LovePanda
 /** 配置处理器 */
 public void configHandler(Handlers me) {
   logger.info("配置处理器开始..");
   me.add(new ContextPathHandler("base"));
   DruidStatViewHandler dsvh = new DruidStatViewHandler("/druid");
   me.add(dsvh);
   logger.info("配置处理器结束..");
 }
コード例 #3
1
ファイル: MyConfig.java プロジェクト: code-Blog/LovePanda
 /** 配置插件 */
 public void configPlugin(Plugins me) {
   logger.info("配置插件开始..");
   DruidPlugin dp =
       new DruidPlugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password"));
   WallFilter wf = new WallFilter();
   wf.setDbType("mysql");
   dp.addFilter(wf);
   me.add(dp);
   // 配置Ecache插件
   me.add(new EhCachePlugin());
   // 配置ActiveRecord插件
   ActiveRecordPlugin arp = new ActiveRecordPlugin(dp);
   me.add(arp);
   arp.setDevMode(true);
   arp.setShowSql(true);
   // 此项目并没有用到jfinal2.2的javabean与model的合体,感兴趣的可以参照jfinal官网的demo
   arp.addMapping("blog", Blog.class); // 映射blog 表到 Blog模型
   arp.addMapping("user", User.class); // 用户
   arp.addMapping("qquser", Qquser.class); // qq用户
   arp.addMapping("blogcategory", Blogcategory.class); // 博客分类
   arp.addMapping("userlogininfo", Userlogininfo.class); // 用户登陆信息
   arp.addMapping("advice", Advice.class); // 建议
   arp.addMapping("role", Role.class); // 角色
   arp.addMapping("userrole", Userrole.class); // 用户角色中间表
   arp.addMapping("picrecommend", Picrecommend.class); // 首页图片推荐--推荐尺寸为630*350
   arp.addMapping("beauty", Beauty.class); // 美图
   arp.addMapping("gonggao", Gonggao.class); // 公告
   arp.addMapping("iplog", Iplog.class); // ip和URL日志
   arp.addMapping("video", Video.class); // 视频模块
   arp.addMapping("resourceslog", Resourceslog.class); // 系统资源监控日志
   arp.addMapping("link", Link.class); // 友情链接
   logger.info("配置插件结束..");
 }
コード例 #4
1
  @Override
  public void afterCompletion(
      HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
      throws Exception {
    if (ex == null) {
      return;
    }

    if (excludedExceptions.contains(ex.getClass())) {
      return;
    }
    for (Class<? extends Exception> excludedException : excludedExceptions) {
      if (excludedException.isInstance(ex)) {
        return;
      }
    }

    if (handler instanceof HandlerMethod) {
      HandlerMethod handlerMethod = (HandlerMethod) handler;
      Logger controllerLogger = Logger.getLogger(handlerMethod.getBeanType());
      controllerLogger.error(String.format("uncaught exception from %s", handlerMethod), ex);
    } else {
      logger.error(
          String.format("uncaught exception from a handler of unknown type: %s", handler), ex);
    }
  }
コード例 #5
1
  private void load(String normalizedFilePath, String filePath) {
    max_weight = -1;

    BufferedReader br;
    try {
      if (normalize) {
        br = new BufferedReader(new FileReader(normalizedFilePath));
      } else {
        br = new BufferedReader(new FileReader(filePath));
      }
      cTran2wt.clear();

      String line = "";
      while ((line = br.readLine()) != null) {
        String[] tokens = line.split("\t");
        //                    if (tokens[0].equals(tokens[1])) {
        //                        continue;
        //                    }
        if (max_weight < Double.valueOf(tokens[2])) {
          max_weight = Double.valueOf(tokens[2]);
        }
        Transition t = new Transition(tokens[0], tokens[1]);
        cTran2wt.put(t, Double.valueOf(tokens[2]));
      }
      br.close();

      logger.debug("size(): " + cTran2wt.size());
      logger.debug("max_weight: " + max_weight);
    } catch (IOException e) {
      logger.error("not happened", e);
    }
  }
コード例 #6
1
ファイル: Custom.java プロジェクト: carlosamtech/SmartWetLab
  /** {@inheritDoc} */
  public LLRPBitList encodeBinarySpecific() {
    LLRPBitList resultBits = new LLRPBitList();

    if (vendorIdentifier == null) {
      LOGGER.warn(" vendorIdentifier not set");
      throw new MissingParameterException(
          " vendorIdentifier not set  for Parameter of Type Custom");
    }

    resultBits.append(vendorIdentifier.encodeBinary());

    if (parameterSubtype == null) {
      LOGGER.warn(" parameterSubtype not set");
      throw new MissingParameterException(
          " parameterSubtype not set  for Parameter of Type Custom");
    }

    resultBits.append(parameterSubtype.encodeBinary());

    if (data == null) {
      LOGGER.warn(" data not set");
      throw new MissingParameterException(" data not set  for Parameter of Type Custom");
    }

    resultBits.append(data.encodeBinary());

    return resultBits;
  }
コード例 #7
1
ファイル: UserDao.java プロジェクト: dsonti/deal70
  @Override
  public long update() throws DataModelException, TMException, SQLException {
    UserData user = (UserData) datamodel;

    ResultSet rst = null;
    try {
      String sql = UPDATE_USER;
      Collection<SQLValue> bindVars = new ArrayList<SQLValue>();

      bindVars.add(SQLValue.String(user.getUserName()));
      bindVars.add(SQLValue.String(user.getFirstName()));
      bindVars.add(SQLValue.String(user.getMiddleName()));
      bindVars.add(SQLValue.String(user.getLastName()));
      bindVars.add(SQLValue.String(user.getMailId()));
      bindVars.add(SQLValue.String(user.getPassword()));
      bindVars.add(SQLValue.Blob((Blob) user.getImage()));
      bindVars.add(SQLValue.String(user.getDob()));
      bindVars.add(SQLValue.Long(user.getSex()));
      bindVars.add(SQLValue.Long(user.getAddressId()));
      bindVars.add(SQLValue.String(user.getMaritalStatus()));
      bindVars.add(SQLValue.String(user.getNationality()));
      bindVars.add(SQLValue.Boolean(user.isActive()));
      bindVars.add(SQLValue.String(user.getActivationKey()));
      bindVars.add(SQLValue.Long(user.getId()));

      logger.debug("QUERY - Loading Address :" + sql);
      return executeUpdate(sql, bindVars);
    } catch (SQLException sql) {
      logger.error("SQL-Exception", sql);
      throw new TMException("SQL-Exception", sql.getLocalizedMessage());
    } finally {
      close(null, rst);
    }
  }
コード例 #8
0
ファイル: RMIDeployer.java プロジェクト: arunsrajan/Singam
 public void init(List serviceList, ServerConfig serverConfig, MBeanServer mbeanServer) {
   System.setProperty("java.io.tmpdir", serverConfig.getCachedir());
   try {
     this.serviceList = serviceList;
     this.serverConfig = serverConfig;
     this.mbeanServer = mbeanServer;
     fsManager.init();
   } catch (Exception e) {
     log.error("Unable to initialie file system: " + fsManager, e);
   }
   try {
     registry = LocateRegistry.createRegistry(Integer.parseInt(serverConfig.getRmiregistryport()));
     ic = new InitialContext();
     Context subctx = null;
     try {
       subctx = (Context) ic.lookup("java:");
     } catch (Exception ex) {
       log.error("initializing the java context", ex);
       // ex.printStackTrace();
     }
     if (subctx == null) {
       ic.createSubcontext("java:");
     }
     remoteBindingInterface = new RemoteBindingObject(ic);
     Object jndilookupobj =
         UnicastRemoteObject.exportObject(
             remoteBindingInterface, Integer.parseInt(serverConfig.getRmiregistryport()));
     registry.rebind("RemoteBindingObject", (Remote) jndilookupobj);
   } catch (Exception ex) {
     log.error("error in registring to the remote binding object", ex);
     // e1.printStackTrace();
   }
   log.info("initialized");
 }
コード例 #9
0
  /** Finishes the execution context */
  public static void finish() {
    Connection conn = JForumExecutionContext.getConnection(false);

    if (conn != null) {
      if (SystemGlobals.getBoolValue(ConfigKeys.DATABASE_USE_TRANSACTIONS)) {
        if (JForumExecutionContext.shouldRollback()) {
          try {
            conn.rollback();
          } catch (Exception e) {
            logger.error("Error while rolling back a transaction", e);
          }
        } else {
          try {
            conn.commit();
          } catch (Exception e) {
            logger.error("Error while commiting a transaction", e);
          }
        }
      }

      try {
        DBConnection.getImplementation().releaseConnection(conn);
      } catch (Exception e) {
        logger.error("Error while releasing the connection : " + e, e);
      }
    }

    userData.set(null);
  }
コード例 #10
0
  @Test
  public void testCreateFile() throws Exception {
    log.debug(" **** testCreateFile **** ");
    File f = new File(mytempdir + File.separator + "just_created");
    try {
      fw = new FolderWatcher(new File(mytempdir), 100);
      fw.initialRun();

      final CountDownLatch latch = new CountDownLatch(1);
      fw.addListener(
          new IModificationListener() {

            public void fileModified(File f, ModifyActions action) {
              Assert.assertEquals("just_created", f.getName());
              Assert.assertEquals(ModifyActions.CREATED, action);
              latch.countDown();
            }
          });
      fw.run();

      f.createNewFile();

      log.debug("We expect CREATED");
      if (!latch.await(3, TimeUnit.SECONDS)) {
        Assert.fail("No callback occured");
      }
      f.delete();
      fw.cancel();
    } catch (Exception e) {
      fw.cancel();
      f.delete();
      throw e;
    }
  }
コード例 #11
0
  @Override
  public boolean applyNetworkACLs(
      final Network network,
      final List<? extends NetworkACLItem> rules,
      final VirtualRouter router,
      final boolean isPrivateGateway)
      throws ResourceUnavailableException {

    if (rules == null || rules.isEmpty()) {
      s_logger.debug("No network ACLs to be applied for network " + network.getId());
      return true;
    }

    s_logger.debug("APPLYING NETWORK ACLs RULES");

    final String typeString = "network acls";
    final boolean isPodLevelException = false;
    final boolean failWhenDisconnect = false;
    final Long podId = null;

    final NetworkAclsRules aclsRules = new NetworkAclsRules(network, rules, isPrivateGateway);

    final boolean result =
        applyRules(
            network,
            router,
            typeString,
            isPodLevelException,
            podId,
            failWhenDisconnect,
            new RuleApplierWrapper<RuleApplier>(aclsRules));
    return result;
  }
コード例 #12
0
  public static void Update(Unlocked p) throws ResponseException {
    PreparedStatement statement = null;
    String query =
        "Update unlocked SET fk_profile_id=?,bonus_info=?,content_info=? where fk_profile_id=?;";
    Connection connect = null;
    IConnection c = MiscUtil.getIConnection();

    try {
      connect = c.init();
      statement = connect.prepareStatement(query);
      statement.setLong(1, p.getProfileId());
      statement.setString(2, p.getBonusInfo());
      statement.setString(3, p.getContentInfo());
      statement.setLong(4, p.getProfileId());
      statement.executeUpdate();
    } catch (SQLException e) {
      logger.error("SQL Error", e);
      throw new ResponseException("SQL Error", HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (ResponseException e) {
      throw e;
    } finally {
      try {
        if (statement != null) statement.close();
        if (connect != null) connect.close();
      } catch (SQLException e) {
        logger.error("SQL Error", e);
      }
    }
  }
コード例 #13
0
  public static ResultSet Read() throws ResponseException {
    ResultSet rs = null;
    PreparedStatement statement = null;
    String query = "select * from unlocked;";
    Connection connect = null;
    CachedRowSet crs = null;
    IConnection c = MiscUtil.getIConnection();

    try (CachedRowSet crs2 = RowSetProvider.newFactory().createCachedRowSet()) {
      connect = c.init();
      statement = connect.prepareStatement(query);
      rs = statement.executeQuery();
      crs2.populate(rs);
      crs = crs2.createCopy();
    } catch (SQLException e) {
      logger.error("SQL Error", e);
      throw new ResponseException("SQL Error", HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (ResponseException e) {
      throw e;
    } finally {
      try {
        if (statement != null) statement.close();
        if (connect != null) connect.close();
      } catch (SQLException e) {
        logger.error("SQL Error", e);
      }
    }
    return (crs);
  }
コード例 #14
0
ファイル: ExecuteJAR.java プロジェクト: vjutvik/Contiki-IPsec
  private static void handleExportAttributesFromJAR(Element e, File config, File toDir) {
    for (Element c : ((List<Element>) e.getChildren()).toArray(new Element[0])) {
      Attribute a = c.getAttribute("EXPORT");
      if (a != null && a.getValue().equals("copy")) {
        /* Copy file from JAR */
        File file = GUI.restoreConfigRelativePath(config, new File(c.getText()));
        InputStream inputStream = GUI.class.getResourceAsStream("/" + file.getName());
        if (inputStream == null) {
          throw new RuntimeException("Could not unpack file: " + file);
        }
        byte[] fileData = ArrayUtils.readFromStream(inputStream);
        if (fileData == null) {
          logger.info("Failed unpacking file");
          throw new RuntimeException("Could not unpack file: " + file);
        }
        if (OVERWRITE || !file.exists()) {
          boolean ok = ArrayUtils.writeToFile(file, fileData);
          if (!ok) {
            throw new RuntimeException("Failed unpacking file: " + file);
          }
          logger.info("Unpacked file from JAR: " + file.getName());
        } else if (OVERWRITE) {
          logger.info("Skip: unpack file from JAR: " + file.getName());
        }
      }

      /* Recursive search */
      handleExportAttributesFromJAR(c, config, toDir);
    }
  }
コード例 #15
0
 /**
  * The name for this host.
  *
  * @see #HOSTNAME
  * @see <a href="http://trac.bigdata.com/ticket/886" >Provide workaround for bad reverse DNS
  *     setups</a>
  */
 public static final String getCanonicalHostName() {
   String s = System.getProperty(HOSTNAME);
   if (s != null) {
     // Trim whitespace.
     s = s.trim();
   }
   if (s != null && s.length() != 0) {
     log.warn("Hostname override: hostname=" + s);
   } else {
     try {
       /*
        * Note: This should be the host *name* NOT an IP address of a
        * preferred Ethernet adaptor.
        */
       s = InetAddress.getLocalHost().getCanonicalHostName();
     } catch (Throwable t) {
       log.warn("Could not resolve canonical name for host: " + t);
     }
     try {
       s = InetAddress.getLocalHost().getHostName();
     } catch (Throwable t) {
       log.warn("Could not resolve name for host: " + t);
       s = "localhost";
     }
   }
   return s;
 }
コード例 #16
0
ファイル: RateCodesDAO.java プロジェクト: muraleekrish/pric
 public HashMap getAllRateCodes() {
   /**
    * Requires - Modifies - Effects -
    *
    * @throws -
    */
   Criteria objCriteria = null;
   Session objSession = null;
   Integer totRecordCount = null;
   List objList = null;
   HashMap hmResult = new HashMap();
   try {
     logger.info("GETTING ALL RATE CODES");
     objSession = HibernateUtil.getSession();
     objCriteria = objSession.createCriteria(RateCodesVO.class);
     totRecordCount = new Integer(objCriteria.list().size());
     objList = objCriteria.list();
     hmResult.put("TotalRecordCount", totRecordCount);
     hmResult.put("Records", objList);
     logger.info("GOT ALL RATE CODES");
   } catch (HibernateException e) {
     logger.error("HIBERNATE EXCEPTION DURING GET ALL RATE CODES", e);
     e.printStackTrace();
   } finally {
     if (objSession != null) {
       objSession.close();
     }
   }
   return hmResult;
 }
コード例 #17
0
ファイル: RateCodesDAO.java プロジェクト: muraleekrish/pric
 public Collection getAllRateCodes(int tdspId) {
   /**
    * Requires - Modifies - Effects -
    *
    * @throws -
    */
   Criteria objCriteria = null;
   Session objSession = null;
   List objList = null;
   try {
     logger.info("GETTING ALL RATE CODES BY TDSP ID");
     objSession = HibernateUtil.getSession();
     objCriteria =
         objSession
             .createCriteria(RateCodesVO.class)
             .add(Restrictions.eq("tdsp.tdspIdentifier", new Integer(tdspId)));
     objCriteria.addOrder(Order.asc("rateCode"));
     objList = objCriteria.list();
     logger.info("GOT ALL RATE CODES BY TDSP ID");
   } catch (HibernateException e) {
     logger.error("HIBERNATE EXCEPTION DURING GET ALL RATE CODES BY TDSP ID", e);
     e.printStackTrace();
   } finally {
     if (objSession != null) {
       objSession.close();
     }
   }
   return objList;
 }
コード例 #18
0
  public void applySettingStatusReport(JSONObject js) {
    /**
     * This breaks the mold a bit.. but its more efficient. This gets called off the top of
     * ParseJson if it has an "SR" in it. Sr's are called so often that instead of walking the
     * normal parsing tree.. this skips to the end
     */
    try {
      Iterator ii = js.keySet().iterator();
      // This is a special multi single value response object
      while (ii.hasNext()) {
        String key = ii.next().toString();

        responseCommand rc =
            new responseCommand(MNEMONIC_GROUP_SYSTEM, key.toString(), js.get(key).toString());
        TinygDriver.getInstance().machine.applyJsonStatusReport(rc);
        //                _applySettings(rc.buildJsonObject(), rc.getSettingParent()); //we will
        // supply the parent object name for each key pair
      }
      setChanged();
      message[0] = "STATUS_REPORT";
      message[1] = null;
      notifyObservers(message);

    } catch (Exception ex) {
      logger.error("[!] Error in applySettingStatusReport(JsonOBject js) : " + ex.getMessage());
      logger.error("[!]js.tostring " + js.toString());
      setChanged();
      message[0] = "STATUS_REPORT";
      message[1] = null;
      notifyObservers(message);
    }
  }
コード例 #19
0
ファイル: Custom.java プロジェクト: carlosamtech/SmartWetLab
  /** {@inheritDoc} */
  public Content encodeXML(String name, Namespace ns) {
    // element in namespace defined by parent element
    Element element = new Element(name, ns);
    // child element are always in default LLRP namespace
    ns = Namespace.getNamespace("llrp", LLRPConstants.LLRPNAMESPACE);

    if (vendorIdentifier == null) {
      LOGGER.warn(" vendorIdentifier not set");
      throw new MissingParameterException(" vendorIdentifier not set");
    } else {
      element.addContent(vendorIdentifier.encodeXML("VendorIdentifier", ns));
    }

    if (parameterSubtype == null) {
      LOGGER.warn(" parameterSubtype not set");
      throw new MissingParameterException(" parameterSubtype not set");
    } else {
      element.addContent(parameterSubtype.encodeXML("ParameterSubtype", ns));
    }

    if (data == null) {
      LOGGER.warn(" data not set");
      throw new MissingParameterException(" data not set");
    } else {
      element.addContent(data.encodeXML("Data", ns));
    }

    // parameters
    return element;
  }
コード例 #20
0
  public DeleteReportDataResponseType deleteData(final DeleteReportDataType request)
      throws EucalyptusCloudException {
    final DeleteReportDataResponseType reply = request.getReply();
    reply.getResponseMetadata().setRequestId(reply.getCorrelationId());

    checkAuthorized();

    Date endDate;
    if (request.getEndDate() != null) {
      endDate = new Date(parseDate(request.getEndDate()));
    } else {
      throw new ReportingException(
          HttpResponseStatus.BAD_REQUEST,
          ReportingException.BAD_REQUEST,
          "Bad request: End date is required");
    }

    logger.info("Deleting report data up to " + request.getEndDate());

    try {
      reply.setResult(new DeleteDataResultType(Import.deleteAll(endDate)));
    } catch (final Exception e) {
      logger.error(e, e);
      throw new ReportingException(
          HttpResponseStatus.INTERNAL_SERVER_ERROR,
          ReportingException.INTERNAL_SERVER_ERROR,
          "Error deleting report data");
    }

    return reply;
  }
コード例 #21
0
ファイル: LinksCSReader.java プロジェクト: matsim-org/matsim
  public final void createPersonQuadTree() {
    log.info("TEST");
    double minx = (1.0D / 0.0D);
    double miny = (1.0D / 0.0D);
    double maxx = (-1.0D / 0.0D);
    double maxy = (-1.0D / 0.0D);

    for (ActivityFacility f : this.scenario.getActivityFacilities().getFacilities().values()) {
      if (f.getCoord().getX() < minx) minx = f.getCoord().getX();
      if (f.getCoord().getY() < miny) miny = f.getCoord().getY();
      if (f.getCoord().getX() > maxx) maxx = f.getCoord().getX();
      if (f.getCoord().getY() > maxy) maxy = f.getCoord().getY();
    }
    minx -= 1.0D;
    miny -= 1.0D;
    maxx += 1.0D;
    maxy += 1.0D;
    QuadTree<Person> personQuadTree = new QuadTree<>(minx, miny, maxx, maxy);
    for (Person p : this.scenario.getPopulation().getPersons().values()) {
      Coord c =
          ((ActivityFacility)
                  this.scenario
                      .getActivityFacilities()
                      .getFacilities()
                      .get(
                          PopulationUtils.getFirstActivity(((Plan) p.getSelectedPlan()))
                              .getFacilityId()))
              .getCoord();
      personQuadTree.put(c.getX(), c.getY(), p);
    }
    log.info("PersonQuadTree has been created");
    this.personQuadTree = personQuadTree;
  }
コード例 #22
0
ファイル: ProcessFileDataset.java プロジェクト: openhie/os-cr
  public void parseFile(File file) {
    log.debug("Will attempt to process the file: " + file.getAbsolutePath());
    BufferedReader reader = null;
    try {
      reader = new BufferedReader(new FileReader(file));
    } catch (FileNotFoundException e) {
      log.error("Unable to read the input file. Error: " + e);
      throw new RuntimeException("Unable to read the input file.");
    }

    try {
      boolean done = false;
      int lineIndex = 0;
      while (!done) {
        String line = reader.readLine();
        if (line == null) {
          done = true;
          continue;
        }
        processLine(line, lineIndex++);
      }
    } catch (IOException e) {
      log.error("Failed while loading the input file. Error: " + e);
      throw new RuntimeException("Failed while loading the input file.");
    }
  }
コード例 #23
0
ファイル: AbstractModule.java プロジェクト: JetBrains/MPS
  protected Iterable<ModelRoot> loadRoots() {
    ModuleDescriptor descriptor = getModuleDescriptor();
    if (descriptor == null) {
      return Collections.emptyList();
    }

    List<ModelRoot> result = new ArrayList<ModelRoot>();
    for (ModelRootDescriptor modelRoot : descriptor.getModelRootDescriptors()) {
      try {
        ModelRootFactory modelRootFactory =
            PersistenceFacade.getInstance().getModelRootFactory(modelRoot.getType());
        if (modelRootFactory == null) {
          LOG.error(
              "Unknown model root type: `" + modelRoot.getType() + "'. Requested by: " + this);
          continue;
        }

        ModelRoot root = modelRootFactory.create();
        Memento mementoWithFS = new MementoWithFS(modelRoot.getMemento(), myFileSystem);
        root.load(mementoWithFS);
        result.add(root);
      } catch (Exception e) {
        LOG.error(
            "Error loading models from root with type: `"
                + modelRoot.getType()
                + "'. Requested by: "
                + this,
            e);
      }
    }
    return result;
  }
コード例 #24
0
ファイル: ProcessFileDataset.java プロジェクト: openhie/os-cr
 /**
  * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16, 16 (^-separated)
  * rec_id,given_name,surname,street_number,address_1,address_2,suburb,postcode,state,date_of_birth,age,phone_number,soc_sec_id,blocking_number,gender(M/F/O),race,account,id-seq
  */
 private void getPerson(int lineIndex, String line) throws ParseException {
   String[] fields = new String[MAX_FIELD_COUNT];
   int length = line.length();
   int begin = 0;
   int end = 0;
   int fieldIndex = 0;
   while (end < length) {
     while (end < length - 1 && line.charAt(end) != ',') {
       end++;
     }
     if (end == length - 1) {
       break;
     }
     fields[fieldIndex++] = line.substring(begin, end);
     end++;
     begin = end;
   }
   fields[fieldIndex] = line.substring(begin, end + 1);
   if (isPopulatedField(fields[16])) {
     log.debug("Extracted an account number of " + fields[16]);
     PersonIdentifier id = extractAccountIdentifier(fields[16]);
     log.debug("We have an ID of " + id);
     log.debug("Will set the account number to: " + String.format("%07d", lineIndex));
     id.setIdentifier(String.format("%07d", lineIndex));
     outputLine(fields, id);
   }
 }
コード例 #25
0
ファイル: MyConfig.java プロジェクト: code-Blog/LovePanda
 /** 配置全局拦截器 */
 public void configInterceptor(Interceptors me) {
   logger.info("配置全局拦截器开始..");
   me.addGlobalActionInterceptor(new PhoneInterceptor());
   me.addGlobalActionInterceptor(new LogInterceptor());
   me.add(new TxByMethodRegex("(.*save.*|.*update.*|.*delete.*)")); // 2.2改动
   logger.info("配置全局拦截器结束..");
 }
コード例 #26
0
 static {
   appender = new ListAppender(new PatternLayout("%d{DATE} - %m"), list);
   appender.setName("ListAppender");
   appender.setThreshold(Level.INFO);
   log = log.getLogger(ControllerLogger.class);
   log.addAppender(appender);
 }
コード例 #27
0
ファイル: MyConfig.java プロジェクト: code-Blog/LovePanda
 @Override
 public void afterJFinalStart() {
   logger.info("afterJFinalStart开始..");
   // 公告
   List<Gonggao> listGonggao = Gonggao.me.listAll();
   JFinal.me().getServletContext().setAttribute("gonggao", listGonggao);
   // 全局博客分类
   List<Blogcategory> listBlogcategory = Blogcategory.me.listAll();
   com.fly.common.Constants.setListBlogcategory(listBlogcategory);
   JFinal.me().getServletContext().setAttribute("cloudcategory", listBlogcategory);
   // 友情链接
   List<Link> listLink = Link.me.listAll();
   JFinal.me().getServletContext().setAttribute("systemListLink", listLink);
   // 网站域名
   JFinal.me().getServletContext().setAttribute("siteUrl", PropKit.get("siteUrl"));
   // 网站名称
   JFinal.me().getServletContext().setAttribute("siteName", PropKit.get("siteName"));
   // 多少插件短地址,注册时候的端地址,需自己注册,在配置文件中修改,默认写的是test
   JFinal.me()
       .getServletContext()
       .setAttribute("duoshuoShortName", PropKit.get("duoshuoShortName"));
   // 是否开放注册
   JFinal.me()
       .getServletContext()
       .setAttribute("systemRegisterOpen", PropKit.get("systemRegisterOpen"));
   // 是否开放普通用户写博客,传美图,发视频
   JFinal.me().getServletContext().setAttribute("systemEditOpen", PropKit.get("systemEditOpen"));
   TimerResourcesLog.start();
   // 定时器(目前主要是每天定时清理资源日志,一天有720条资源日志,每天凌晨2点清理一周前的日志,可自己修改时间)
   TimerManager tm = new TimerManager();
   tm.init();
   logger.info("afterJFinalStart结束..");
 }
コード例 #28
0
ファイル: UserDao.java プロジェクト: dsonti/deal70
  @Override
  public DataModel read() throws DataModelException, TMException, SQLException {
    UserData user = (UserData) datamodel;

    ResultSet rst = null;
    try {
      String sql = READ_USER;
      Collection<SQLValue> bindVars = new ArrayList<SQLValue>();
      if (user.getId() > 0) {
        sql += AND + "`ID` = ? ";
        bindVars.add(SQLValue.Long(user.getId()));
      }
      if (user.getUserName() != null) {
        sql += AND + "`USER_NAME` = ? ";
        bindVars.add(SQLValue.String(user.getUserName()));
      }
      if (user.getPassword() != null) {
        sql += AND + "`PASSWORD` = ? ";
        bindVars.add(SQLValue.String(user.getPassword()));
      }
      logger.debug("QUERY - Loading Address :" + sql);
      rst = executeQuery(sql, bindVars);

      return loadUserVO(user, rst);
    } catch (SQLException sql) {
      logger.error("SQL-Exception", sql);
      throw new TMException("SQL-Exception", sql.getLocalizedMessage());
    } finally {
      close(null, rst);
    }
  }
コード例 #29
0
ファイル: DAOAgentPool.java プロジェクト: srvarey/postion
 public static void register(GaiaDAOAgent agent) {
   if (daoAgentList == null) {
     try {
       daoAgentList = new ArrayList();
       daoCallerAgent = new DAOCallerAgent();
       String containerName = agent.getContainerController().getContainerName();
       Integer id = new Integer(containerName.substring(6));
       AgentController controller =
           agent
               .getContainerController()
               .acceptNewAgent(
                   DAOCallerAgent.class.getSimpleName() + "-" + id + "-0", daoCallerAgent);
       controller.start();
       positionCallerAgent = new DAOCallerAgent();
       logger.error("accept agent PositionCallerAgent-" + id + "-0 from " + agent.getName());
       controller =
           agent
               .getContainerController()
               .acceptNewAgent("PositionCallerAgent-" + id + "-0", positionCallerAgent);
       controller.start();
     } catch (ControllerException | NumberFormatException e) {
       logger.error(StringUtils.formatErrorMessage(e));
     }
   }
   daoAgentList.add(agent);
 }
コード例 #30
0
  /** This convenience method is set aside for readability. */
  private void getHibernateSession() {
    // import org.jboss.jpa.tx.TransactionScopedEntityManager;

    // Find a method for getting a hibernate session.
    Method[] emMethods = em.getClass().getMethods();
    for (Method method : emMethods) {
      if (method.getName().equals("getHibernateSession")) {
        // Once found, invoke the method.
        try {
          Object returnObj = method.invoke(em);
          if (returnObj instanceof Session) {
            session = (Session) returnObj;
          } else {
            logger.warn(
                "Invoking 'getHibernateSession()' returned type of "
                    + returnObj.getClass().getName()
                    + " instead of a hibernate session.");
          }
        } catch (Exception ex) {
          logger.error(
              "Failed to invoke the getter to obtain the hibernate session " + ex.getMessage());
          ex.printStackTrace();
        }
      }
    }

    if (session == null) {
      logger.error("Failed to find hibernate session from " + em.toString());
    }
  }