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


Java ObjectServer类代码示例

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


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

示例1: FileHostKindDetectsConfigurationObject

import com.db4o.ObjectServer; //导入依赖的package包/类
@Test(expectedExceptions = RuntimeException.class)
public void FileHostKindDetectsConfigurationObject() {
    Injector injector = Guice.createInjector(PersistenceService.usingDb4o()
            .across(UnitOfWork.TRANSACTION)
            .buildModule(),

            new AbstractModule() {
                protected void configure() {
                    bindConstant().annotatedWith(Db4Objects.class).to("TestDatabase2.data");
                    Configuration config = Db4o.newConfiguration();
                    config.readOnly(true); // so we can test it gets picked up
                    bind(Configuration.class).toInstance(config);
                }
            });

    injector.getInstance(ReadOnlyDb4oDao.class).persist(new Db4oTestObject("myText"));
    injector.getInstance(ObjectServer.class).close();
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:19,代码来源:Db4oHostKindTest.java

示例2: FileHostKindDoesNotRequireConfigurationObject

import com.db4o.ObjectServer; //导入依赖的package包/类
@Test
public void FileHostKindDoesNotRequireConfigurationObject() {
    Injector injector = Guice.createInjector(PersistenceService.usingDb4o()
            .across(UnitOfWork.TRANSACTION)
            .buildModule(),

            new AbstractModule() {
                protected void configure() {
                    bindConstant().annotatedWith(Db4Objects.class).to("TestDatabase3.data");
                }
            });

    injector.getInstance(ReadOnlyDb4oDao.class).persist(new Db4oTestObject("myText"));
    injector.getInstance(ObjectServer.class).close();

}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:17,代码来源:Db4oHostKindTest.java

示例3: get

import com.db4o.ObjectServer; //导入依赖的package包/类
public ObjectServer get() {
    Db4oSettings actualSettings = getSettings();

    //validate configuration object
    if ((!HostKind.FILE.equals(actualSettings.getHostKind())) && null == actualSettings.getConfiguration())
        throw new IllegalStateException("Must specify a Configuration when using " + actualSettings.getHost() + " server mode." +
                " For starters, try: bind(Configuration.class).toInstance(Db4o.newConfiguration());");

    //use local (i.e. open our own) object server?
    if (HostKind.LOCAL.equals(actualSettings.getHostKind())) {
        ObjectServer objectServer = Db4o.openServer(actualSettings.getConfiguration(), actualSettings.getDatabaseFileName(), actualSettings.getPort());

        //auth if credentials are available
        if (!empty(actualSettings.getUser()))
            objectServer.grantAccess(actualSettings.getUser(), actualSettings.getPassword());

        return objectServer;
        //otherwise it's a simple local-file database
    } else if (HostKind.FILE.equals(actualSettings.getHostKind())) {
        // optional Configuration instance
        if (actualSettings.getConfiguration() != null) {
            return Db4o.openServer(actualSettings.getConfiguration(), actualSettings.getDatabaseFileName(), actualSettings.getPort());
        } else {
            return Db4o.openServer(actualSettings.getDatabaseFileName(), actualSettings.getPort());
        }
    }
    // remote, fake objectServer.
    return new NullObjectServer();
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:30,代码来源:ObjectServerProvider.java

示例4: configure

import com.db4o.ObjectServer; //导入依赖的package包/类
protected void configure() {
    bindWithUnitAnnotation(ObjectServer.class).toProvider(osp);
    
    bindWithUnitAnnotation(ObjectContainer.class).toProvider(ocp);
    bindWithUnitAnnotation(PersistenceService.class).toInstance(pService);
    bindWithUnitAnnotation(WorkManager.class).toInstance(workManager);

    MethodInterceptor txInterceptor = new Db4oLocalTxnInterceptor(iwm, config.getUnitOfWork());
    bindTransactionInterceptor(txInterceptor);

    if (binder().currentStage() == Stage.DEVELOPMENT) {
        MethodInterceptor throwingMethodInterceptor = new MethodInterceptor() {
            public Object invoke(MethodInvocation methodInvocation) throws Throwable {
                throw new UnsupportedOperationException("Dynamic Finders are not supported with DB4O. " +
                        "Remove the @Finder annotations and make sure to use unit annotations " +
                        "when using multiple modules (avoids interception conflicts).");
            }
        };
        bindFinderInterceptor(throwingMethodInterceptor);
    }
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:22,代码来源:Db4oPersistenceStrategy.java

示例5: LocalHostKindWorks

import com.db4o.ObjectServer; //导入依赖的package包/类
@Test
public void LocalHostKindWorks() {
    Injector injector = Guice.createInjector(PersistenceService.usingDb4o()
            .across(UnitOfWork.TRANSACTION)
            .buildModule(),

            new AbstractModule() {
                protected void configure() {
                    bindConstant().annotatedWith(Names.named(Db4Objects.PORT)).to
                            ("1234");
                    bindConstant().annotatedWith(Names.named(Db4Objects.HOST)).to
                            ("localhost");
                    bindConstant().annotatedWith(Names.named(Db4Objects.USER)).to
                            ("db4ouser");
                    bindConstant().annotatedWith(Names.named
                            (Db4Objects.PASSWORD)).to("secret");
                    bindConstant().annotatedWith(Db4Objects.class).to
                            ("bigGame.db");

                    Configuration config = Db4o.newConfiguration();
                    bind(Configuration.class).toInstance(config);
                }
            });

    injector.getInstance(ReadOnlyDb4oDao.class).persist(new Db4oTestObject("myText"));
    injector.getInstance(ObjectServer.class).close();


}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:30,代码来源:Db4oHostKindTest.java

示例6: beginWork

import com.db4o.ObjectServer; //导入依赖的package包/类
public ObjectContainer beginWork() {
    ObjectServer objectServer = this.objectServerProvider.get();
    Db4oSettings settings = this.objectServerProvider.getSettings();
    ObjectContainer objectContainer;
    if (!ManagedContext.hasBind(ObjectContainer.class, objectServer)) {
        //open local server client
        if (settings.isLocal()) {
            objectContainer = Db4o.openClient(objectServer.ext().configure(),
                    settings.getHost(),
                    settings.getPort(),
                    settings.getUser(),
                    settings.getPassword());

        //open remote client
        } else if (settings.isRemote()) {
            objectContainer = Db4o.openClient(settings.getConfiguration(),
                    settings.getHost(),
                    settings.getPort(),
                    settings.getUser(),
                    settings.getPassword());

        //open file based client
        } else {
            objectContainer = objectServer.openClient();
        }
        ManagedContext.bind(ObjectContainer.class, objectServer, objectContainer);
    } else {
        objectContainer = ManagedContext.getBind(ObjectContainer.class, objectServer);
    }
    if (!objectContainer.ext().isClosed()) {
        return objectContainer;
    } else {
        // this one has been closed, try again
        ManagedContext.unbind(ObjectContainer.class, objectServer);
        return beginWork();
    }
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:38,代码来源:Db4oInternalWorkManager.java

示例7: endWork

import com.db4o.ObjectServer; //导入依赖的package包/类
public void endWork() {
    ObjectServer os = this.objectServerProvider.get();
    if (ManagedContext.hasBind(ObjectContainer.class, os)) {
        ObjectContainer objectContainer = ManagedContext.unbind(ObjectContainer.class, os);
        if (objectContainer != null && !objectContainer.ext().isClosed()) objectContainer.close();
    }
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:8,代码来源:Db4oInternalWorkManager.java

示例8: Db4oPersistenceService

import com.db4o.ObjectServer; //导入依赖的package包/类
public Db4oPersistenceService(Provider<ObjectServer> objectServerProvider) {
    this.objectServerProvider = objectServerProvider;
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:4,代码来源:Db4oPersistenceService.java

示例9: postClass

import com.db4o.ObjectServer; //导入依赖的package包/类
@AfterClass
public void postClass() {
	injector.getInstance(ObjectServer.class).close();
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:5,代码来源:JoiningLocalTransactionsTest.java

示例10: postClass

import com.db4o.ObjectServer; //导入依赖的package包/类
@AfterClass
public void postClass() {
	injector.getInstance(ObjectServer.class).close();
       TestCleanup.clearWorkManagers();
   }
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:6,代码来源:Db4oWorkManagerTest.java


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