Java Code Examples for io.jboot.Jboot#isDevMode()

The following examples show how to use io.jboot.Jboot#isDevMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddonInterceptorProcesser.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void invoke() {
    if (index < inters.length) {
        Interceptor interceptor = inters[index++];
        try {
            interceptor.intercept(this);
        }finally {
            if (Jboot.isDevMode()){
                System.out.println("addon interceptor intercepted : " + interceptor);
            }
        }

    } else if (index++ == inters.length) {
        invocation.invoke();
    }
}
 
Example 2
Source File: JbootrpcManager.java    From jboot with Apache License 2.0 5 votes vote down vote up
public void exportRPCBean(Jbootrpc jbootrpc) {
        List<Class> classes = ClassScanner.scanClassByAnnotation(RPCBean.class, true);
        if (ArrayUtil.isNullOrEmpty(classes)) {
            return;
        }

        for (Class clazz : classes) {
            RPCBean rpcBean = (RPCBean) clazz.getAnnotation(RPCBean.class);
            Class[] inters = clazz.getInterfaces();
            if (inters == null || inters.length == 0) {
                throw new JbootException(String.format("class[%s] has no interface, can not use @RPCBean", clazz));
            }

            //对某些系统的类 进行排除,例如:Serializable 等
            Class[] excludes = ArrayUtil.concat(default_excludes, rpcBean.exclude());
            for (Class inter : inters) {
                boolean isContinue = false;
                for (Class ex : excludes) {
                    if (ex.isAssignableFrom(inter)) {
                        isContinue = true;
                        break;
                    }
                }

                if (isContinue) {
                    continue;
                }

                if (jbootrpc.serviceExport(inter, Aop.get(clazz), new JbootrpcServiceConfig(rpcBean))) {
                    if (Jboot.isDevMode()) {
//                        System.out.println("rpc service[" + inter + "] has exported ok!");
                    }
                }
            }
        }
    }
 
Example 3
Source File: JbootEventManager.java    From jboot with Apache License 2.0 5 votes vote down vote up
/**
 * 手从初始化 EventListener ,手动注册
 *
 * @param eventListener
 * @param async
 * @param actions
 */
public void registerListener(JbootEventListener eventListener, boolean async, String... actions) {

    for (String action : actions) {
        List<JbootEventListener> list = async ? asyncListenerMap.get(action) : listenerMap.get(action);

        if (null == list) {
            list = new ArrayList<>();
        }

        if (list.contains(eventListener)) {
            continue;
        }

        list.add(eventListener);

        WeightUtil.sort(list);

        if (async) {
            asyncListenerMap.put(action, list);
        } else {
            listenerMap.put(action, list);
        }
    }

    if (Jboot.isDevMode()) {
        log.debug(String.format("listener[%s]-->>registered.", eventListener));
    }
}
 
Example 4
Source File: JbootEventManager.java    From jboot with Apache License 2.0 5 votes vote down vote up
private void invokeListeners(final JbootEvent event, List<JbootEventListener> syncListeners) {
    for (final JbootEventListener listener : syncListeners) {
        try {
            if (Jboot.isDevMode()) {
                log.debug(String.format("listener[%s]-->>onEvent(%s)", listener, event));
            }
            listener.onEvent(event);
        } catch (Throwable e) {
            log.error(String.format("listener[%s] onEvent is error! ", listener.getClass()), e);
        }
    }
}
 
Example 5
Source File: SqlDebugger.java    From jboot with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isPrint(Config config, String sql, Object... paras) {
    return Jboot.isDevMode();
}
 
Example 6
Source File: PayController.java    From jpress with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void back() {

        PayService service = getPayService();
        render404If(service == null);

        Map<String, Object> params = getParams(service);
        if (Jboot.isDevMode()) {
            LOG.debug("back:" + JSON.toJSONString(params));
        }

        String trxNo = getTrxNo(service, params);
        if (StrUtil.isBlank(trxNo)){
            redirect("/pay/fail");
            return;
        }

        if (params == null || !service.verify(params)) {
            redirect("/pay/fail/" + trxNo);
            return;
        }

        // paypal 不走异步回调,需要在这进行处理,只要 service.verify(params) 验证通过
        // 就代表 paypal 支付成功了
        PaymentRecord payment = paymentService.findByTrxNo(trxNo);
        if (service instanceof PayPalPayService){

            if (payment.getPaySuccessAmount() == null) {
                payment.setPaySuccessAmount(payment.getPayAmount());
            }

            payment.setPayStatus(PayStatus.SUCCESS_PAYPAL.getStatus());
            payment.setThirdpartyType("paypal");
            payment.setThirdpartyUserOpenid(params.get("PayerID").toString());
            payment.setThirdpartyTransactionId(params.get("paymentId").toString());

            payment.setStatus(PaymentRecord.STATUS_PAY_SUCCESS);
            payment.setPayCompleteTime(new Date());
            payment.setPaySuccessTime(new Date());


            if (paymentService.update(payment)) {
                paymentService.notifySuccess(payment.getId());
            }
        }


        if (payment.isPaySuccess()) {
            redirect("/pay/success/" + trxNo);
        } else {
            redirect("/pay/fail/" + trxNo);
        }

    }
 
Example 7
Source File: JbootEventManager.java    From jboot with Apache License 2.0 3 votes vote down vote up
public void unRegisterListener(Class<? extends JbootEventListener> listenerClass) {

        deleteListner(listenerMap, listenerClass);
        deleteListner(asyncListenerMap, listenerClass);

        if (Jboot.isDevMode()) {
            log.debug(String.format("listener[%s]-->>unRegisterListener.", listenerClass));
        }

    }
 
Example 8
Source File: LimitFallbackProcesserDefault.java    From jboot with Apache License 2.0 2 votes vote down vote up
/**
 * 处理 Service 层的限流
 *
 * @param resource
 * @param inv
 */
protected void doProcessServiceLimit(String resource, Invocation inv) {
    if (Jboot.isDevMode()) {
        System.err.println(resource + " is limited by LimitFallbackProcesser, return null");
    }
}