Java Code Examples for org.nutz.ioc.Ioc#get()

The following examples show how to use org.nutz.ioc.Ioc#get() . 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: MainLauncher.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化 定时任务
 * @param ioc
 */
private void initSysTask(Ioc ioc) {
    QuartzManager quartzManager = ioc.get(QuartzManager.class);
    quartzManager.clear();
    List<Task> taskList = taskService.query( Cnd.where("status", "=", true));
    for (Task sysTask : taskList) {
        try {
            QuartzJob qj = new QuartzJob();
            qj.setJobName(sysTask.getId());
            qj.setJobGroup(sysTask.getId());
            qj.setClassName(sysTask.getJobClass());
            qj.setCron(sysTask.getCron());
            qj.setComment(sysTask.getNote());
            qj.setDataMap(sysTask.getData());
            quartzManager.add(qj);
        } catch (Exception e) {
            log.error(e.getMessage());
        }
    }
}
 
Example 2
Source File: NutzTest.java    From hasor with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {
    Ioc ioc = new NutIoc(new ComboIocLoader("*js", "ioc/", "*hasor"));
    //
    // .启动 Hasor
    ioc.get(AppContext.class);
    System.out.println("start.");
    //
    //Client -> Server
    HasorBean hasorBean = ioc.get(AppContext.class).getInstance(HasorBean.class);
    System.out.println(hasorBean);
    //
    ioc.depose();
}