Пример #1
0
  /**
   * 初始化容器 <功能详细描述>
   *
   * @param currentApplicationContext [参数说明]
   * @return void [返回类型说明]
   * @exception throws [异常类型] [异常说明]
   * @see [类、类#方法、类#成员]
   */
  private void init(ApplicationContext currentApplicationContext) {
    // 启动时,利用ruleLoad加载,并将规则压入缓存中
    loadAndPutInCacheWhenStart();

    // 根据规则类型,对加载的规则进行校验
    List<RuleAndValidatorWrap> ruleAndValidatorWrapList =
        new ArrayList<RuleContext.RuleAndValidatorWrap>();
    if (this.ruleKeyMapCache.values() != null) {
      for (Rule ruleTemp : this.ruleKeyMapCache.values()) {
        if (!RuleStateEnum.OPERATION.equals(ruleTemp.getState())) {
          // 非运营态的规则无需进行验证
          continue;
        }
        RuleRegister<? extends Rule> ruleValidatorTemp =
            ruleRegisterMap.get(ruleTemp.getRuleType());
        if (ruleValidatorTemp != null) {
          RuleAndValidatorWrap rvWrapTemp = new RuleAndValidatorWrap(ruleTemp, ruleValidatorTemp);
          ruleAndValidatorWrapList.add(rvWrapTemp);
        }
      }
    }
    validateWhenLoadFinish(ruleAndValidatorWrapList);

    // 规则加载完成后,发出规则加载完成事件
    currentApplicationContext.publishEvent(
        new RuleContextInitializedEvent(currentApplicationContext));
  }
Пример #2
0
 @RequestMapping(value = "saveRole", method = RequestMethod.POST)
 public String save(
     @ModelAttribute @Valid RoleDomain roleDomain,
     BindingResult bindingResult,
     HttpServletRequest request,
     HttpSession session) {
   if (Strings.isNullOrEmpty(roleDomain.getName())) {
     bindingResult.rejectValue("name", "", "角色名称不能为空");
     return "";
   }
   OsRole osRole = new OsRole();
   osRole.setName(roleDomain.getName());
   osRole.setRemark(roleDomain.getRemark());
   iRoleService.save(osRole, roleDomain.getOsPermissions());
   String user =
       null != session.getAttribute("account")
           ? String.valueOf(session.getAttribute("account"))
           : "admin";
   StringBuilder stringBuilder =
       new StringBuilder("管理员[")
           .append(user)
           .append("]")
           .append("创建了角色[")
           .append(roleDomain.getName())
           .append("]");
   applicationContext.publishEvent(
       new LogEvent(this, stringBuilder.toString(), user, request.getRemoteHost()));
   return "redirect:roles";
 }
  @SuppressWarnings("unchecked")
  @Override
  public void addRolesToUserRoleReject(Long[] roleIds, Long userId) {
    if (userId == null || roleIds == null || roleIds.length == 0) {
      throw new ServiceLogicalException("请选择数据");
    }
    roleIds = (Long[]) ZBeanUtil.removeDuplicateWithOrder(roleIds);
    String hql = "select urj.rbacRole.id from RbacUserRoleReject urj where urj.rbacUser.id=:userId";
    List<Long> roleIdInUserRoleReject =
        (List<Long>)
            baseDaoImpl.findJustList(
                hql, new ParamObject(POType.H_NO_NC).addAllowNull("userId", userId));
    if (roleIdInUserRoleReject == null) {
      roleIdInUserRoleReject = new ArrayList<Long>();
    }
    List<RbacUserRoleReject> grsList = new ArrayList<RbacUserRoleReject>();
    for (Long roleId : roleIds) {
      if (!roleIdInUserRoleReject.contains(roleId)) {
        grsList.add(new RbacUserRoleReject(new RbacUser(userId), new RbacRole(roleId)));
      }
    }
    if (grsList != null && grsList.size() > 0) {
      baseDaoImpl.saveOrUpdate(grsList);
    }
    try {
      applicationContext.publishEvent(new RoleOrDeptChangedEvent(userId));
    } catch (Exception e) {

    }
  }
Пример #4
0
 @org.springframework.web.bind.annotation.RequestMapping(headers = "X-Github-Event=status")
 public String hook(
     @org.springframework.web.bind.annotation.RequestParam("payload") String payload,
     @org.springframework.web.bind.annotation.RequestHeader("X-Github-Delivery") String delivery)
     throws java.io.IOException {
   log.info("delivery={}, payload={}", delivery, payload);
   StatusEventPayload eventPayload = objectMapper.readValue(payload, StatusEventPayload.class);
   applicationContext.publishEvent(eventPayload);
   return "OK";
 }
  @Override
  public void removeRolesFromUserRole(Long[] roleIds, Long userId) {
    if (userId == null || roleIds == null || roleIds.length == 0) {
      throw new ServiceLogicalException("请选择数据");
    }
    String hql =
        "delete from RbacUserRole ur  where ur.rbacUser.id=:userId and ur.rbacRole.id in (:roleIds)";
    baseDaoImpl.executeUpdate(
        hql,
        new ParamObject(POType.H_NO_NC)
            .addAllowNull("userId", userId)
            .addAllowNull("roleIds", roleIds));
    try {
      applicationContext.publishEvent(new RoleOrDeptChangedEvent(userId));
    } catch (Exception e) {

    }
  }
Пример #6
0
  @Override
  public void onApplicationEvent(ContextRefreshedEvent event) {
    serviceQueueRegistry
        .getItems()
        .forEach(
            item -> {
              final ServiceQueue serviceQueue =
                  applicationContext.getBean(item.getKey(), ServiceQueue.class);

              if (clusteredEventManager != null
                  && (boolean) item.getValue().get("remoteEventListener")) {
                clusteredEventManager.joinService(serviceQueue);
              }

              if (serviceEndpointServer != null
                  && (boolean) item.getValue().get("exposeRemoteEndpoint")) {
                final String endpointLocation = (String) item.getValue().get("endpointLocation");
                logger.info(
                    AnsiOutput.toString(
                        "Registering endpoint: ", BOLD, GREEN, endpointLocation, NORMAL));
                serviceEndpointServer.addServiceQueue(endpointLocation, serviceQueue);

                logger.info("Starting service queue as part of endpoint {}", serviceQueue.name());
                serviceQueue.startServiceQueue();
              } else {
                logger.info("Starting service queue standalone {}", serviceQueue.name());
                serviceQueue.start();
                serviceQueue.startCallBackHandler();
              }
            });
    if (serviceEndpointServer != null) {
      serviceEndpointServer.start();
    }

    applicationContext.publishEvent(new QBitStartedEvent(applicationContext));
  }
Пример #7
0
 public void publishEvent(ApplicationEvent arg0) {
   applicationContext.publishEvent(arg0);
 }