• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ServerRuntime类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: provideLinkRestRuntime

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
@Singleton
@Provides
LinkRestRuntime provideLinkRestRuntime(
        Injector injector,
        Set<LrFeatureProvider> featureProviders,
        Set<LinkRestAdapter> adapters) {

    LinkRestBuilder builder;

    Binding<ServerRuntime> binding = injector.getExistingBinding(Key.get(ServerRuntime.class));
    if (binding == null) {
        builder = new LinkRestBuilder().cayenneService(new PojoCayennePersister());
    } else {
        ServerRuntime cayenneRuntime = binding.getProvider().get();
        builder = new LinkRestBuilder().cayenneRuntime(cayenneRuntime);
    }

    featureProviders.forEach(builder::feature);
    adapters.forEach(builder::adapter);

    return builder.build();
}
 
开发者ID:bootique,项目名称:bootique-linkrest,代码行数:23,代码来源:LinkRestModule.java


示例2: tablesInInsertOrder

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
static Table[] tablesInInsertOrder(BQRuntime runtime, Collection<DbEntity> dbEntities) {

        // note: do not obtain sorter from Cayenne DI. It is not a singleton and will come
        // uninitialized
        ServerRuntime serverRuntime = runtime.getInstance(ServerRuntime.class);
        EntitySorter sorter = serverRuntime.getDataDomain().getEntitySorter();

        List<DbEntity> list = new ArrayList<>(dbEntities);
        sorter.sortDbEntities(list, false);

        DatabaseChannel channel = DatabaseChannel.get(runtime);

        Table[] tables = new Table[list.size()];
        for (int i = 0; i < tables.length; i++) {
            tables[i] = createTableModel(channel, list.get(i));
        }
        return tables;
    }
 
开发者ID:bootique,项目名称:bootique-cayenne,代码行数:19,代码来源:CayenneModelUtils.java


示例3: cayenneBuilder

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
/**
 * Creates and returns a preconfigured {@link ServerRuntimeBuilder} with
 * Cayenne config, name, Java8 integration module and a DataSource. Override
 * to add custom modules, extra projects, etc.
 *
 * @param dataSourceFactory injected Bootique {@link DataSourceFactory}
 * @return a {@link ServerRuntimeBuilder} that can be extended in
 * subclasses.
 */
protected ServerRuntimeBuilder cayenneBuilder(DataSourceFactory dataSourceFactory) {

    // building our own Cayenne extensions module...
    return ServerRuntime.builder(name).addModule(binder -> {

        // provide schema creation hook
        if (createSchema) {
            binder.bind(SchemaUpdateStrategyFactory.class).toInstance(descriptor -> new CreateIfNoSchemaStrategy());
        }

        DefaultDataSourceName defaultDataSourceName = defaultDataSourceName(dataSourceFactory);
        binder.bind(Key.get(DefaultDataSourceName.class)).toInstance(defaultDataSourceName);
        binder.bindList(DataMapConfig.class).addAll(maps);

        // provide default DataNode
        // TODO: copied from Cayenne, as the corresponding provider is not public or rather
        // until https://issues.apache.org/jira/browse/CAY-2095 is implemented
        binder.bind(DataDomain.class).toProvider(SyntheticNodeDataDomainProvider.class);

        // Bootique DataSource hooks...
        BQCayenneDataSourceFactory bqCayenneDSFactory =
                new BQCayenneDataSourceFactory(dataSourceFactory, datasource, maps);
        binder.bind(org.apache.cayenne.configuration.server.DataSourceFactory.class).toInstance(bqCayenneDSFactory);
    });
}
 
开发者ID:bootique,项目名称:bootique-cayenne,代码行数:35,代码来源:ServerRuntimeFactory.java


示例4: testCreateCayenneRuntime_NoName

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
@Test
public void testCreateCayenneRuntime_NoName() {
	ServerRuntimeFactory factory = new ServerRuntimeFactory();
	factory.setDatasource("ds1");

	ServerRuntime runtime = factory.createCayenneRuntime(mockDSFactory, Collections.emptyList());
	try {
		DataDomain domain = runtime.getDataDomain();
		assertEquals("cayenne", domain.getName());

		assertEquals(1, domain.getDataNodes().size());
		assertNotNull(domain.getDefaultNode());
		assertEquals("cayenne", domain.getDefaultNode().getName());

	} finally {
		runtime.shutdown();
	}
}
 
开发者ID:bootique,项目名称:bootique-cayenne,代码行数:19,代码来源:ServerRuntimeFactoryTest.java


示例5: testCreateCayenneRuntime_Name

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
@Test
public void testCreateCayenneRuntime_Name() {
	ServerRuntimeFactory factory = new ServerRuntimeFactory();
	factory.setConfigs(asList("cayenne-project1.xml"));
	factory.setDatasource("ds1");
	factory.setName("me");

	ServerRuntime runtime = factory.createCayenneRuntime(mockDSFactory, Collections.emptyList());
	try {

		DataDomain domain = runtime.getDataDomain();
		assertEquals("me", domain.getName());

		assertEquals(1, domain.getDataNodes().size());
		assertNotNull(domain.getDefaultNode());
		assertEquals("me", domain.getDefaultNode().getName());

	} finally {
		runtime.shutdown();
	}
}
 
开发者ID:bootique,项目名称:bootique-cayenne,代码行数:22,代码来源:ServerRuntimeFactoryTest.java


示例6: testCreateCayenneRuntime_Configs

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
@Test
public void testCreateCayenneRuntime_Configs() {
	ServerRuntimeFactory factory = new ServerRuntimeFactory();
	factory.setDatasource("ds1");
	factory.setConfigs(asList("cayenne-project2.xml", "cayenne-project1.xml"));

	ServerRuntime runtime = factory.createCayenneRuntime(mockDSFactory, Collections.emptyList());
	try {

		DataDomain domain = runtime.getDataDomain();
		assertNotNull(domain.getEntityResolver().getDbEntity("db_entity"));
		assertNotNull(domain.getEntityResolver().getDbEntity("db_entity2"));

	} finally {
		runtime.shutdown();
	}
}
 
开发者ID:bootique,项目名称:bootique-cayenne,代码行数:18,代码来源:ServerRuntimeFactoryTest.java


示例7: testConfig_ExplicitMaps_SharedDatasource

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
@Test
public void testConfig_ExplicitMaps_SharedDatasource() {

    ServerRuntime runtime = testFactory.app("--config=classpath:config_explicit_maps.yml")
            .autoLoadModules()
            .createRuntime()
            .getInstance(ServerRuntime.class);

    DataDomain domain = runtime.getDataDomain();
    assertNotNull(domain.getEntityResolver().getDbEntity("db_entity"));
    assertNotNull(domain.getEntityResolver().getDbEntity("db_entity2"));

    // trigger a DB op
    SQLSelect.dataRowQuery("map1", "SELECT * FROM db_entity").select(runtime.newContext());
    SQLSelect.dataRowQuery("map2", "SELECT * FROM db_entity2").select(runtime.newContext());
}
 
开发者ID:bootique,项目名称:bootique-cayenne,代码行数:17,代码来源:CayenneModuleIT.java


示例8: testConfig_ExplicitMaps_DifferentDatasources

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
@Test
public void testConfig_ExplicitMaps_DifferentDatasources() {

    ServerRuntime runtime = testFactory.app("--config=classpath:config_explicit_maps_2.yml")
            .autoLoadModules()
            .createRuntime()
            .getInstance(ServerRuntime.class);

    DataDomain domain = runtime.getDataDomain();
    assertNotNull(domain.getEntityResolver().getDbEntity("db_entity"));
    assertNotNull(domain.getEntityResolver().getDbEntity("db_entity2"));

    // trigger a DB op
    SQLSelect.dataRowQuery("map1", "SELECT * FROM db_entity").select(runtime.newContext());
    SQLSelect.dataRowQuery("map2", "SELECT * FROM db_entity2").select(runtime.newContext());
}
 
开发者ID:bootique,项目名称:bootique-cayenne,代码行数:17,代码来源:CayenneModuleIT.java


示例9: testDefaultDataSource

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
@Test
public void testDefaultDataSource() throws SQLException {

    ServerRuntime runtime = testFactory.app("--config=classpath:noconfig.yml")
            .autoLoadModules()
            .createRuntime()
            .getInstance(ServerRuntime.class);

    DataDomain domain = runtime.getDataDomain();
    assertNotNull(domain.getDataNode("cayenne"));

    try(Connection c = domain.getDataNode("cayenne").getDataSource().getConnection();) {
        DatabaseMetaData md = c.getMetaData();
        assertEquals("jdbc:derby:target/derby/bqjdbc_noconfig", md.getURL());
    }
}
 
开发者ID:bootique,项目名称:bootique-cayenne,代码行数:17,代码来源:CayenneModuleIT.java


示例10: testUndefinedDataSource

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
@Test
public void testUndefinedDataSource() throws SQLException {

    ServerRuntime runtime = testFactory.app("--config=classpath:noconfig_2ds.yml")
            .autoLoadModules()
            .createRuntime()
            .getInstance(ServerRuntime.class);

    try {
        runtime.getDataDomain();
    }
    catch (DataDomainLoadException e) {
        assertTrue(e.getCause().getMessage()
                .startsWith("Can't map Cayenne DataSource: 'cayenne.datasource' is missing."));
    }
}
 
开发者ID:bootique,项目名称:bootique-cayenne,代码行数:17,代码来源:CayenneModuleIT.java


示例11: testUnmatchedDataSource

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
@Test
public void testUnmatchedDataSource() throws SQLException {

    ServerRuntime runtime = testFactory.app("--config=classpath:noconfig_2ds_unmatched.yml")
            .autoLoadModules()
            .createRuntime()
            .getInstance(ServerRuntime.class);

    try {
        runtime.getDataDomain();
        fail();
    }
    catch (DataDomainLoadException e) {
        String message = e.getCause().getMessage();
        assertEquals("No configuration present for DataSource named 'ds3'", message);
    }
}
 
开发者ID:bootique,项目名称:bootique-cayenne,代码行数:18,代码来源:CayenneModuleIT.java


示例12: testContributeModules

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
@Test
public void testContributeModules() {

    Module guiceModule = b -> {
        org.apache.cayenne.di.Module cayenneModule = (cb) -> cb.bind(CayenneModuleIT.class).toInstance(this);
        CayenneModule.extend(b).addModule(cayenneModule);
    };

    ServerRuntime runtime = testFactory.app("--config=classpath:fullconfig.yml")
            .autoLoadModules()
            .module(guiceModule)
            .createRuntime()
            .getInstance(ServerRuntime.class);

    assertSame(this, runtime.getInjector().getInstance(CayenneModuleIT.class));
}
 
开发者ID:bootique,项目名称:bootique-cayenne,代码行数:17,代码来源:CayenneModuleIT.java


示例13: beforeClass

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() {

    InvalidationHandler invalidationHandler = type -> {
        if (type.getAnnotation(CacheGroups.class) != null) {
            return null;
        }

        return p -> asList(new CacheGroupDescriptor("cayenne1"), new CacheGroupDescriptor("nocayenne1"));
    };

    TEST_RUNTIME = TEST_FACTORY.app("-c", "classpath:bq1.yml")
            .autoLoadModules()
            .module(b -> CayenneJCacheModule.extend(b).addInvalidationHandler(invalidationHandler))
            .createRuntime();
    SERVER_RUNTIME = TEST_RUNTIME.getInstance(ServerRuntime.class);
}
 
开发者ID:bootique,项目名称:bootique-cayenne,代码行数:18,代码来源:CacheInvalidationIT.java


示例14: before

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
@Before
public void before() {

	ds1 = mock(DataSource.class);
	ds2 = mock(DataSource.class);

	DataNode dn1 = mock(DataNode.class);
	when(dn1.getName()).thenReturn("dn1");
	when(dn1.getDataSource()).thenReturn(ds1);

	DataNode dn2 = mock(DataNode.class);
	when(dn2.getName()).thenReturn("dn2");
	when(dn2.getDataSource()).thenReturn(ds2);

	DataDomain domain = new DataDomain("dd");
	domain.addNode(dn1);
	domain.addNode(dn2);

	ServerRuntime runtime = mock(ServerRuntime.class);
	when(runtime.getDataDomain()).thenReturn(domain);

	cayenneService = new TargetCayenneService(runtime);
}
 
开发者ID:nhl,项目名称:link-move,代码行数:24,代码来源:TargetCayenneServiceTest.java


示例15: configure

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
@Override
public Application configure() {

	EntityResolver mockResolver = mock(EntityResolver.class);
	DataChannel mockChannel = mock(DataChannel.class);
	when(mockChannel.getEntityResolver()).thenReturn(mockResolver);

	ServerRuntime runtime = mock(ServerRuntime.class);
	when(runtime.getChannel()).thenReturn(mockChannel);

	Feature lrFeature = LinkRestBuilder.build(runtime);

	Feature testFeature = new Feature() {

		@Override
		public boolean configure(FeatureContext context) {
			context.register(ExceptionResource.class);
			return true;
		}
	};

	return new ResourceConfig().register(testFeature).register(lrFeature);
}
 
开发者ID:nhl,项目名称:link-rest,代码行数:24,代码来源:GET_ExceptionIT.java


示例16: configure

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
@Override
public Application configure() {

	EntityResolver mockResolver = mock(EntityResolver.class);
	DataChannel mockChannel = mock(DataChannel.class);
	when(mockChannel.getEntityResolver()).thenReturn(mockResolver);

	ServerRuntime runtime = mock(ServerRuntime.class);
	when(runtime.getChannel()).thenReturn(mockChannel);

	Feature lrFeature = LinkRestBuilder.build(runtime);

	Feature feature = new Feature() {

		@Override
		public boolean configure(FeatureContext context) {
			context.register(SimpleResponseResource.class);
			return true;
		}
	};

	return new ResourceConfig().register(feature).register(lrFeature);
}
 
开发者ID:nhl,项目名称:link-rest,代码行数:24,代码来源:GET_SimpleResponseIT.java


示例17: DefaultCayenneService

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
DefaultCayenneService(Context context) {
    // Build Cayenne runtime with custom resource locator, to be able load it from Android assets.
    runtime = ServerRuntime.builder()
            .addModule(binder -> binder.bind(ResourceLocator.class).to(AssetsResourceLocator.class))
            .addConfig("assets:cayenne-project.xml")
            .build();
    sharedContext = runtime.newContext();
}
 
开发者ID:stariy95,项目名称:cayenne-android-demo,代码行数:9,代码来源:DefaultCayenneService.java


示例18: createCayenne

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
private static ServerRuntime createCayenne(String url, String driver) {

		return new ServerRuntimeBuilder().jdbcDriver(driver).url(url).addConfig("cayenne-project.xml")
				// this would ensure test schema creation on the first run
				.addModule(binder -> binder.bind(SchemaUpdateStrategy.class).to(CreateIfNoSchemaStrategy.class))
				.build();
	}
 
开发者ID:andrus,项目名称:link-rest-cms-demo,代码行数:8,代码来源:JaxRsApplication.java


示例19: createLinkMoveRuntime

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
@Provides
public LmRuntime createLinkMoveRuntime(
        ConfigurationFactory configFactory,
        Injector injector,
        ServerRuntime targetRuntime,
        Set<LinkMoveBuilderCallback> buildCallbacks) {

    return configFactory
            .config(LinkMoveFactory.class, configPrefix)
            .createLinkMove(injector, targetRuntime, buildCallbacks);
}
 
开发者ID:bootique,项目名称:bootique-linkmove,代码行数:12,代码来源:LinkMoveModule.java


示例20: createLinkMove

import org.apache.cayenne.configuration.server.ServerRuntime; //导入依赖的package包/类
public LmRuntime createLinkMove(
        Injector injector,
        ServerRuntime targetRuntime,
        Set<LinkMoveBuilderCallback> builderCallbacks) {

    ResourceResolver resolver = createResolver();
    LmRuntimeBuilder builder = new LmRuntimeBuilder()
            .withTargetRuntime(targetRuntime)
            .extractorResolver(resolver);

    connectorFactories.forEach(factory -> addToBuilder(builder, factory, injector));

    builderCallbacks.forEach(c -> c.build(builder));
    return builder.build();
}
 
开发者ID:bootique,项目名称:bootique-linkmove,代码行数:16,代码来源:LinkMoveFactory.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ReplicationTransmitter类代码示例发布时间:2022-05-22
下一篇:
Java ContinueNode类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap