act.job.OnAppStart Java Examples

The following examples show how to use act.job.OnAppStart. 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: Gh1145.java    From actframework with Apache License 2.0 6 votes vote down vote up
@OnAppStart
public void generateRandomData() {
    // populate data list
    for (int i = 0; i < 10000; ++i) {
        Data data = new Data();
        for (int j = 0; j < 30; ++j) {
            String key = "key" + j;
            data.putValue(key, "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
        }
        list.add(data);
    }

    // try get csv file checksum
    String content = csvContent();
    checksum = IO.checksum(content.getBytes());
}
 
Example #2
Source File: EnumLookupCache.java    From actframework with Apache License 2.0 6 votes vote down vote up
@OnAppStart(async = true)
public void loadEligibleEnums(ClassInfoRepository repo, final App app) {
    final ClassNode enumRoot = repo.node(Enum.class.getName());
    final $.Predicate<String> tester = app.config().appClassTester();
    enumRoot.visitSubTree(new Lang.Visitor<ClassNode>() {
        @Override
        public void visit(ClassNode classNode) throws Lang.Break {
            String name = classNode.name();
            if (tester.test(name) && !name.startsWith("act.")) {
                Class<? extends Enum> enumType = $.cast(app.classForName(name));
                Object[] constants = enumType.getEnumConstants();
                if (null != constants && constants.length > 0) {
                    String simpleName = enumType.getSimpleName();
                    Class<?> existing = eligibleEnums.get(simpleName);
                    if (null != existing && existing.getName().equals(enumType.getName())) {
                        warn("Ambiguous enum name found between %s and %s", existing.getName(), enumType.getName());
                    } else {
                        eligibleEnums.put(simpleName, enumType);
                    }
                }
            }
        }
    });
    eligibleEnumSize = eligibleEnums.size();
}
 
Example #3
Source File: Processor.java    From act-doc with Apache License 2.0 5 votes vote down vote up
@OnAppStart
public void ensureWorkspace() {
    File file = workspace();
    if (!file.exists()) {
        if (!file.mkdir()) {
            throw new UnexpectedException("Workspace not ready for use: " + file.getAbsolutePath());
        }
    }
}
 
Example #4
Source File: Gh829.java    From actframework with Apache License 2.0 5 votes vote down vote up
@OnAppStart
public void prepareData() {
    foos = new ArrayList<>();
    for (int i = 0; i < 10; ++i) {
        foos.add(new Foo());
    }
}
 
Example #5
Source File: $$.java    From actframework with Apache License 2.0 5 votes vote down vote up
@OnAppStart
public static void init() {
    StringUtils.evaluator = new $.Transformer<String, String>() {
        @Override
        public String transform(String s) {
            return S.string(Act.appConfig().getIgnoreCase(s));
        }
    };
    codecs = $.cast(C.Map(
            DateTime.class, Act.getInstance(JodaDateTimeCodec.class),
            LocalDateTime.class, Act.getInstance(JodaLocalDateTimeCodec.class),
            LocalDate.class, Act.getInstance(JodaLocalDateCodec.class),
            LocalTime.class, Act.getInstance(JodaLocalTimeCodec.class)
    ));
}
 
Example #6
Source File: AppEntry.java    From actframework with Apache License 2.0 4 votes vote down vote up
@OnAppStart
public void onAppStart(User.Dao userDao) {
    User user = new User();
    user.name = "tom";
    userDao.save(user);
}
 
Example #7
Source File: AppEntry.java    From actframework with Apache License 2.0 4 votes vote down vote up
@OnAppStart
public void doJob() {
    DateTime dateTime = $.convert("2018-11-13T13:28:01.952+1100").hint("iso").to(DateTime.class);
    System.out.println(dateTime);
}
 
Example #8
Source File: Gh1138.java    From actframework with Apache License 2.0 4 votes vote down vote up
@OnAppStart
@Every(value = "1s", startImmediately = false)
public void incr() {
    n++;
}
 
Example #9
Source File: Tags.java    From actframework with Apache License 2.0 4 votes vote down vote up
@OnAppStart
@Override
protected void releaseResources() {
    Destroyable.Util.tryDestroyAll(fastTags, ApplicationScoped.class);
}
 
Example #10
Source File: InvalidJobService.java    From actframework with Apache License 2.0 4 votes vote down vote up
@OnAppStart
public void bar() {
}
 
Example #11
Source File: GH222.java    From actframework with Apache License 2.0 4 votes vote down vote up
@OnAppStart
public void syncCallback() {
    syncThreadId = Thread.currentThread().getId();
}
 
Example #12
Source File: GH222.java    From actframework with Apache License 2.0 4 votes vote down vote up
@OnAppStart(async = true)
public void asyncCallback() {
    asyncThreadId = Thread.currentThread().getId();
}
 
Example #13
Source File: HelloWorldController.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@OnAppStart
public void routing() {
    Act.getNonblock("/json", context -> context.resp()
            .contentType(JSON_TYPE)
            .writeContent(JSON.toJSONString(new Message(HELLO_WORLD), SerializerFeature.DisableCircularReferenceDetect)));
}