當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。