我想在寓言中创建一个抽象存储库。
我可以连接到存储在不同服务器上的存储库。但是,当我尝试使用federate函数将它们组合起来时,它会引发一个错误,它无法在第二服务器上找到存储库。
我在此链接中找到了相同的问题,但这无济于事。有提示吗?
这是我的代码:
AGServer server = new AGServer(SERVER_URL, USERNAME, PASSWORD);
AGServer server2 = new AGServer(SERVER_URL2, USERNAME2, PASSWORD2);
println("Available catalogs: " + server.listCatalogs());
AGRepositoryConnection custCon = server.createRepositoryConnection("repo1", CATALOG_ID, false);
AGRepositoryConnection supCon = server2.createRepositoryConnection("repo2", CATALOG_ID, false);
AGAbstractRepository rainbowRepo = server2.federate(custCon.getRepository(), supCon.getRepository());
rainbowRepo.initialize();
AGRepositoryConnection rainbowConn = rainbowRepo.getConnection();
SailRepository
class在联邦上下文中实现FederatedServiceResolverClient
,因此您可以使用类Sailrepository添加带有不同存储库的联合商店:
AGServer server = new AGServer(SERVER_URL, USERNAME, PASSWORD);
AGServer server2 = new AGServer(SERVER_URL2, USERNAME2, PASSWORD2);
AGRepository repo1 = server.getCatalog(CATALOG_ID).openRepository("repo1");
AGRepository repo2 = server2.getCatalog(CATALOG_ID).openRepository("repo2");
Federation federation = new Federation();
federation.addMember(repo1);
federation.addMember(repo2);
federation.setReadOnly(true);
SailRepository rainbowRepo = new SailRepository(federation);
rainbowRepo .initialize();
SailRepositoryConnection rainbowConn = rainbowRepo .getConnection(); //for querying and updating the contents of the repository.