当前位置: 首页>>代码示例>>Java>>正文


Java Startup类代码示例

本文整理汇总了Java中org.apache.tapestry5.ioc.annotations.Startup的典型用法代码示例。如果您正苦于以下问题:Java Startup类的具体用法?Java Startup怎么用?Java Startup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Startup类属于org.apache.tapestry5.ioc.annotations包,在下文中一共展示了Startup类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scheduleJobs

import org.apache.tapestry5.ioc.annotations.Startup; //导入依赖的package包/类
@Startup
public static void scheduleJobs(ParallelExecutor executor,
		final IMemoryDB memoryDb,
		@Inject @Symbol(USE_MEMDB_PARAMETER) final String useMemoryDB,
		@Inject @Symbol(MAX_MEMDB_ROWS_PARAMETER) final String maxRecords) {

	System.out.println(USE_MEMDB_PARAMETER + "=" + useMemoryDB);
	System.out.println(MAX_MEMDB_ROWS_PARAMETER + "=" + maxRecords);
	if ("true".equalsIgnoreCase(useMemoryDB)) {
		System.out
				.println("Scheduling parallel job to load in-memory database.");
		executor.invoke(IMemoryDB.class, new Invokable<IMemoryDB>() {
			@Override
			public IMemoryDB invoke() {
				memoryDb.initialize(FastNumberUtils
						.parseIntWithCheck(maxRecords));
				return memoryDb;
			}
		});
	}
}
 
开发者ID:Sotera,项目名称:graphene-walker,代码行数:22,代码来源:WalkerDAOModule.java

示例2: initApplication

import org.apache.tapestry5.ioc.annotations.Startup; //导入依赖的package包/类
@Startup
    public static void initApplication(final HibernateSessionManager hsm)
    {
        final Session session = hsm.getSession();

//
//        final Work workClearDB = new Work() {
//            public void execute(final Connection connection) throws SQLException
//            {
//                final Statement statement = connection.createStatement();
//                statement.execute("TRUNCATE SCHEMA PUBLIC RESTART IDENTITY AND COMMIT NO CHECK");
//            }
//        };
//
//        try {
//            session.doWork(workClearDB);
//        } catch (final Throwable e) {
//            e.printStackTrace();
//        }
        
        
        // create sample data
        for (int i = 0;i<100;++i) {
            final String iv = String.valueOf(i);
            saveOrUpdate(session, new PHEUser("user"+iv, "user"+iv+"@user"+iv, "password_"+iv));        
        }
        
        hsm.commit();
    }
 
开发者ID:rlentz,项目名称:tahi_jndi,代码行数:30,代码来源:TestDataSetupModule.java

示例3: initApplication

import org.apache.tapestry5.ioc.annotations.Startup; //导入依赖的package包/类
@Startup
public static void initApplication(RegistryShutdownHub shutdownHub, ConfigurationService service, EpgDataService epgService, UserService userService, VdrDataService vdrService,
        ComponentClassResolver componentClassResolver, ComponentSource componentSource) {

    shutdownHub.addRegistryShutdownListener(new Runnable() {

        public void run() {
            service.shutdown();
        }
    });

    service.triggerInitialization();

    if (!service.isUseEpgd() && (service.getEpgVdrUuuid() != null)) {
        // Update database periodically (2 times a day)
        scheduler.scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                epgService.updateInternalEpgData(service.getEpgVdrUuuid());
            }
        }, 0, 12, TimeUnit.HOURS);
    }
    
    // create default admin user, if he does not exists
    User user = new User();
    if (!userService.existsUser("admin")) {
        user.setUsername("admin");
        user.setPassword("jonglisto");
        user = userService.createUser(user);
    }
                    
    // set default permission. Permission to do everything
    userService.addIndividualPermission("admin", "*", "admin_permission");
    
    // get all channel groups and update the permission
    service.getConfiguredViews().values() //
        .stream() //
        .forEach(v -> {
            System.err.println("Check View: " + v.getDisplayName());
            try {
                vdrService.getGroups(v.getChannelVdr().get()).get() //
                    .stream() //
                    .forEach(g -> {
                        System.err.println("Check Group: " + g);
                        userService.addPermission("channel:group:" + g, "perm_channel_group");
                    });
            } catch (Exception e) {
                System.err.println(e);
                // do nothing
            }
        });
    
    componentClassResolver.getPageNames().stream().forEach(s -> {
        // preload all pages
        componentSource.getPage(s);
    });
}
 
开发者ID:Zabrimus,项目名称:vdr-jonglisto,代码行数:58,代码来源:AppModule.java


注:本文中的org.apache.tapestry5.ioc.annotations.Startup类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。