當前位置: 首頁>>代碼示例>>Java>>正文


Java Env類代碼示例

本文整理匯總了Java中act.sys.Env的典型用法代碼示例。如果您正苦於以下問題:Java Env類的具體用法?Java Env怎麽用?Java Env使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Env類屬於act.sys包,在下文中一共展示了Env類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: visit

import act.sys.Env; //導入依賴的package包/類
@Override
public void visit(String name, Object value) {
    if ("value".equals(name)) {
        String s = S.string(value);
        if (type == Env.RequireProfile.class || type == Env.Profile.class) {
            matched = Env.profileMatches(s);
        } else if (type == Env.RequireGroup.class || type == Env.Group.class) {
            matched = Env.groupMatches(s);
        }
    } else if ("except".equals(name)) {
        except = (Boolean) value;
    } else if ("except".equals(name)) {
        except = (Boolean) value;
    }
    super.visit(name, value);
}
 
開發者ID:actframework,項目名稱:actframework,代碼行數:17,代碼來源:EnvAnnotationVisitor.java

示例2: loadAgent

import act.sys.Env; //導入依賴的package包/類
/**
 * Load an agent providing the full file path with parameters.
 */
public static void loadAgent(String jarFilePath, String params) {
    try {

        String pid = Env.PID.get();

        VirtualMachine vm;
        if (AttachProvider.providers().isEmpty()) {
            vm = getVirtualMachineImplementationFromEmbeddedOnes(pid);
        } else {
            vm = VirtualMachine.attach(pid);
        }

        final PrintStream ps = System.out;
        try {
            System.setOut(new PrintStream(new FileOutputStream(".ebean_agent.log")));
            vm.loadAgent(jarFilePath, params);
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("javaagent loaded: " + jarFilePath);
            }
        } finally {
            // ensure ebean2 EnhanceContext logout set to dump output
            Act.jobManager().on(AppEventId.CLASS_LOADER_INITIALIZED, new Runnable() {
                @Override
                public void run() {
                    System.setOut(ps);
                }
            });
        }
        vm.detach();

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:actframework,項目名稱:act-ebean,代碼行數:38,代碼來源:EbeanAgentLoader.java

示例3: init

import act.sys.Env; //導入依賴的package包/類
private synchronized void init() {
    if (null != jobClass) {
        return;
    }
    disabled = false;
    jobClass = $.classForName(classInfo.className(), cl);
    disabled = disabled || !Env.matches(jobClass);
    method = methodInfo.method();
    disabled = disabled || !Env.matches(method);
    if (disabled) {
        return;
    }
    isStatic = methodInfo.isStatic();
    if (!isStatic) {
        singleton = ReflectedInvokerHelper.tryGetSingleton(jobClass, app);
    }
    ParamValueLoaderManager paramValueLoaderManager = app.service(ParamValueLoaderManager.class);
    if (null != paramValueLoaderManager) {
        paramValueLoaderService = paramValueLoaderManager.get(JobContext.class);
    } else {
        // this job is scheduled to run before ParamValueLoaderManager initialized
    }

    if (!Modifier.isStatic(method.getModifiers())) {
        Class[] paramTypes = paramTypes();
        //constructorAccess = ConstructorAccess.get(controllerClass);
        methodAccess = MethodAccess.get(jobClass);
        methodIndex = methodAccess.getIndex(methodInfo.name(), paramTypes);
    } else {
        method.setAccessible(true);
    }
}
 
開發者ID:actframework,項目名稱:actframework,代碼行數:33,代碼來源:ReflectedJobInvoker.java

示例4: visitAnnotation

import act.sys.Env; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
    AnnotationVisitor av = super.visitAnnotation(desc, visible);
    Type type = Type.getType(desc);
    String className = type.getClassName();
    try {
        Class<? extends Annotation> c = (Class<? extends Annotation>)Class.forName(className);
        if (JobClassMetaInfo.isActionAnnotation(c)) {
            markRequireScan();
            if (null == methodInfo) {
                JobMethodMetaInfo tmp = new JobMethodMetaInfo(classInfo, paramTypes);
                methodInfo = tmp;
                classInfo.addAction(tmp);
                this.aav = new ActionAnnotationVisitor(av, c, methodInfo);
            } else {
                this.aav.add(c);
            }
            return this.aav;
        } else if (Env.isEnvAnnotation(c)) {
            this.eav = new EnvAnnotationVisitor(av, c);
            return this.eav;
        }
    } catch (Exception e) {
        throw E.unexpected(e);
    }
    //markNotTargetClass();
    return av;
}
 
開發者ID:actframework,項目名稱:actframework,代碼行數:30,代碼來源:JobByteCodeScanner.java

示例5: visitEnum

import act.sys.Env; //導入依賴的package包/類
@Override
public void visitEnum(String name, String desc, String value) {
    if ("value".equals(name) && desc.contains("Mode")) {
        Act.Mode mode = Act.Mode.valueOf(value);
        if (!Env.modeMatches(mode)) {
            matched = false;
        }
    }
    super.visitEnum(name, desc, value);
}
 
開發者ID:actframework,項目名稱:actframework,代碼行數:11,代碼來源:EnvAnnotationVisitor.java

示例6: initInfoBuffer

import act.sys.Env; //導入依賴的package包/類
private void initInfoBuffer(App app) {
    Map<String, Object> map = C.Map(
            "actVersion", Act.VERSION.getVersion(),
            "appVersion", Act.appVersion().getVersion(),
            "appName", app.name(),
            "pid", Env.PID.get(),
            "baseDir", app.base().getAbsoluteFile(),
            "mode", Act.mode().name(),
            "profile", Act.profile(),
            "group", Act.nodeGroup()
    );
    this.info = new Unit(map, Banner.cachedBanner());
}
 
開發者ID:actframework,項目名稱:actframework,代碼行數:14,代碼來源:Info.java

示例7: checkStatus

import act.sys.Env; //導入依賴的package包/類
/**
 * This method will get called every x, where
 * `x` is configured through `every.check_status`
 * configuration
 */
@Every(value = "every.check_status", id = "CHECK_STATUS")
@Env.Group("job")
public void checkStatus() {
    JobLog.log("SomeService.checkStatus");
}
 
開發者ID:actframework,項目名稱:act-demo-apps,代碼行數:11,代碼來源:SomeService.java

示例8: WebSocketConnectionHandler

import act.sys.Env; //導入依賴的package包/類
public WebSocketConnectionHandler(ActionMethodMetaInfo methodInfo, WebSocketConnectionManager manager) {
    this.connectionManager = $.notNull(manager);
    if (null == methodInfo) {
        this.isWsHandler = false;
        this.disabled = true;
        return;
    }
    App app = manager.app();
    this.cl = app.classLoader();
    this.handler = $.notNull(methodInfo);
    this.controller = handler.classInfo();

    this.paramLoaderService = app.service(ParamValueLoaderManager.class).get(WebSocketContext.class);
    this.jsonDTOClassManager = app.service(JsonDTOClassManager.class);

    this.handlerClass = $.classForName(controller.className(), cl);
    this.disabled = !Env.matches(handlerClass);

    paramTypes = paramTypes(cl);

    try {
        this.method = handlerClass.getMethod(methodInfo.name(), paramTypes);
        this.isWsHandler = null != this.method.getAnnotation(WsAction.class);
        this.disabled = this.disabled || !Env.matches(method);
    } catch (NoSuchMethodException e) {
        throw E.unexpected(e);
    }

    if (!isWsHandler || disabled) {
        return;
    }

    this.isStatic = methodInfo.isStatic();
    if (!this.isStatic) {
        //constructorAccess = ConstructorAccess.get(controllerClass);
        methodAccess = MethodAccess.get(handlerClass);
        methodIndex = methodAccess.getIndex(methodInfo.name(), paramTypes);
        host = Act.getInstance(handlerClass);
    } else {
        method.setAccessible(true);
    }

    paramCount = handler.paramCount();
    paramSpecs = jsonDTOClassManager.beanSpecs(handlerClass, method);
    fieldsAndParamsCount = paramSpecs.size();
    if (fieldsAndParamsCount == 1) {
        singleJsonFieldName = paramSpecs.get(0).name();
    }
    // todo: do we want to allow inject Annotation type into web socket
    // handler method param list?
    ParamValueLoader[] loaders = paramLoaderService.methodParamLoaders(host, method, null);
    if (loaders.length > 0) {
        int realParamCnt = 0;
        for (ParamValueLoader loader : loaders) {
            if (loader instanceof ProvidedValueLoader) {
                continue;
            }
            realParamCnt++;
        }
        isSingleParam = 1 == realParamCnt;
    }
}
 
開發者ID:actframework,項目名稱:actframework,代碼行數:63,代碼來源:WebSocketConnectionHandler.java

示例9: matches

import act.sys.Env; //導入依賴的package包/類
@Override
boolean matches(EnvAnnotationVisitor visitor) {
    return Env.profileMatches(visitor.value, visitor.except);
}
 
開發者ID:actframework,項目名稱:actframework,代碼行數:5,代碼來源:EnvMatcher.java

示例10: pid

import act.sys.Env; //導入依賴的package包/類
@Command(name = "act.pid", help = "Print current process ID")
public String pid() {
    return Env.PID.get();
}
 
開發者ID:actframework,項目名稱:actframework,代碼行數:5,代碼來源:SysUtilAdmin.java

示例11: initPidBuffer

import act.sys.Env; //導入依賴的package包/類
private void initPidBuffer() {
    this.pid = new Unit("pid", Env.PID.get());
}
 
開發者ID:actframework,項目名稱:actframework,代碼行數:4,代碼來源:Info.java

示例12: banner

import act.sys.Env; //導入依賴的package包/類
public static String banner(AppDescriptor appDescriptor) {
    String bannerText = null;

    String udfBanner = udfBanner();
    if (null != udfBanner) {
        bannerText = S.concat(udfBanner, "\n");
    }
    if (null == bannerText) {
        bannerText = asciiArt(appDescriptor.getAppName());
    }
    int bannerTextWidth = width(bannerText);

    String favicon = favicon();
    int faviconWidth = width(favicon);
    int maxWidth = Math.max(faviconWidth, bannerTextWidth);

    S.Buffer sb = S.buffer();
    String actVersion = Act.VERSION.getVersion();
    if ("ACTFRAMEWORK".equals(appDescriptor.getAppName())) {
        sb.append(bannerText);
        if (S.notBlank(favicon)) {
            sb.append("\n");
            addFavicon(sb, favicon, maxWidth, faviconWidth);
        }
        int n = actVersion.length();
        int padLeft = (maxWidth - n + 1) / 2;
        sb.append(S.times(" ", padLeft)).append(actVersion).append("\n");
    } else {
        sb.append(bannerText);
        if (S.notBlank(favicon)) {
            sb.append("\n");
            addFavicon(sb, favicon, maxWidth, faviconWidth);
            sb.append("\n");
            sb.append(poweredBy(maxWidth, actVersion, true));
        } else {
            sb.append(poweredBy(maxWidth, actVersion, false));
        }
        sb.append("\n\n version: ").append(appDescriptor.getVersion().getVersion());
    }
    File aFile = new File("");
    String group = Act.nodeGroup();
    sb.append("\nscan pkg: ").append(System.getProperty(AppConfigKey.SCAN_PACKAGE.key()));
    sb.append("\nbase dir: ").append(aFile.getAbsolutePath());
    sb.append("\n     pid: ").append(Env.PID.get());
    sb.append("\n profile: ").append(ConfLoader.confSetName());
    sb.append("\n    mode: ").append(Act.mode());
    if (S.notBlank(group)) {
        sb.append("\n   group: ").append(group);
    }
    sb.append("\n");
    sb.append("\n     zen: ").append(Zen.wordsOfTheDay());
    sb.append("\n");

    return sb.toString();
}
 
開發者ID:actframework,項目名稱:actframework,代碼行數:56,代碼來源:Banner.java

示例13: isModuleAllowed

import act.sys.Env; //導入依賴的package包/類
private static boolean isModuleAllowed(Class<?> moduleClass) {
    return Env.matches(moduleClass);
}
 
開發者ID:actframework,項目名稱:actframework,代碼行數:4,代碼來源:GenieInjector.java


注:本文中的act.sys.Env類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。