本文整理汇总了Java中com.marklogic.client.DatabaseClientFactory类的典型用法代码示例。如果您正苦于以下问题:Java DatabaseClientFactory类的具体用法?Java DatabaseClientFactory怎么用?Java DatabaseClientFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseClientFactory类属于com.marklogic.client包,在下文中一共展示了DatabaseClientFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getClientBasedOnAuth
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
/**
* Public utility that returns DatabaseClient based on auth
* @return DatabaseClient
*/
public DatabaseClient getClientBasedOnAuth(String host, int port, String user, String password, String database, String auth) {
Authentication type;
if(auth != null)
{
type = Authentication.valueOfUncased(auth);
if(type == Authentication.BASIC)
{
return DatabaseClientFactory.newClient(host, port, database, new DatabaseClientFactory.BasicAuthContext(user, password));
}
else if(type == Authentication.DIGEST)
{
return DatabaseClientFactory.newClient(host, port, new DatabaseClientFactory.DigestAuthContext(user, password));
}
}
return null;
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:24,代码来源:Util.java
示例2: testConnectionWithMLConnectionVariablesWithoutDatabase
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
@Test
public void testConnectionWithMLConnectionVariablesWithoutDatabase()
{
MarkLogicRepository markLogicRepository = new MarkLogicRepository(host, port, new DatabaseClientFactory.DigestAuthContext(user, password));
markLogicRepository.initialize();
MarkLogicRepositoryConnection con = markLogicRepository.getConnection();
ValueFactory vf = con.getValueFactory();
Resource context10 = vf.createIRI("http://marklogic.com/test/context10");
IRI alice = vf.createIRI("http://example.org/people/alice");
IRI name = vf.createIRI("http://example.org/ontology/name");
Literal alicesName = vf.createLiteral("Alice");
con.begin();
con.add(alice, name, alicesName, context10);
con.commit();
RepositoryResult<Statement> result = con.getStatements(alice, null, null, context10);
Model model = Iterations.addAll(result, new LinkedHashModel());
Assert.assertEquals(1, model.size());
markLogicRepository.shutDown();
markLogicRepository.initialize();
con = markLogicRepository.getConnection();
result = con.getStatements(alice, null, null, context10);
model = Iterations.addAll(result, new LinkedHashModel());
Assert.assertEquals(1, model.size());
con.clear();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:27,代码来源:MarkLogicRepositoryConnectionTest.java
示例3: testConnectionWithMLClientApiSecurityContextWithoutDatabase
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
@Test
public void testConnectionWithMLClientApiSecurityContextWithoutDatabase()
{
MarkLogicRepository markLogicRepository = new MarkLogicRepository(host, port, new DatabaseClientFactory.DigestAuthContext(user, password));
markLogicRepository.initialize();
MarkLogicRepositoryConnection con = markLogicRepository.getConnection();
ValueFactory vf = con.getValueFactory();
Resource context12 = vf.createIRI("http://marklogic.com/test/context12");
IRI alice = vf.createIRI("http://example.org/people/alice");
IRI name = vf.createIRI("http://example.org/ontology/name");
Literal alicesName = vf.createLiteral("Alice");
con.begin();
con.add(alice, name, alicesName, context12);
con.commit();
RepositoryResult<Statement> result = con.getStatements(alice, null, null, context12);
Model model = Iterations.addAll(result, new LinkedHashModel());
Assert.assertEquals(1, model.size());
markLogicRepository.shutDown();
markLogicRepository.initialize();
con = markLogicRepository.getConnection();
result = con.getStatements(alice, null, null, context12);
model = Iterations.addAll(result, new LinkedHashModel());
Assert.assertEquals(1, model.size());
con.clear();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:27,代码来源:MarkLogicRepositoryConnectionTest.java
示例4: testConnectionWithMLClientApiSecurityContextWithDatabase
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
@Test
public void testConnectionWithMLClientApiSecurityContextWithDatabase()
{
MarkLogicRepository markLogicRepository = new MarkLogicRepository(host, port, "marklogic-rdf4j-test-content", new DatabaseClientFactory.DigestAuthContext(user, password));
markLogicRepository.initialize();
MarkLogicRepositoryConnection con = markLogicRepository.getConnection();
ValueFactory vf = con.getValueFactory();
Resource context12 = vf.createIRI("http://marklogic.com/test/context12");
IRI alice = vf.createIRI("http://example.org/people/alice");
IRI name = vf.createIRI("http://example.org/ontology/name");
Literal alicesName = vf.createLiteral("Alice");
con.begin();
con.add(alice, name, alicesName, context12);
con.commit();
RepositoryResult<Statement> result = con.getStatements(alice, null, null, context12);
Model model = Iterations.addAll(result, new LinkedHashModel());
Assert.assertEquals(1, model.size());
markLogicRepository.shutDown();
markLogicRepository.initialize();
con = markLogicRepository.getConnection();
result = con.getStatements(alice, null, null, context12);
model = Iterations.addAll(result, new LinkedHashModel());
Assert.assertEquals(1, model.size());
con.clear();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:27,代码来源:MarkLogicRepositoryConnectionTest.java
示例5: setupData
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
private void setupData() {
DatabaseClient dbClient = DatabaseClientFactory.newClient(host, restPort, "admin", "admin",
Authentication.DIGEST);
String tripleDocOne = "<semantic-document>\n" + "<title>First Title</title>\n" + "<popularity>1</popularity>\n"
+ "<size>100</size>\n" + "<sem:triples xmlns:sem=\"http://marklogic.com/semantics\">"
+ "<sem:triple><sem:subject>http://example.org/r9928</sem:subject>"
+ "<sem:predicate>http://example.org/p3</sem:predicate>"
+ "<sem:object datatype=\"http://www.w3.org/2001/XMLSchema#int\">1</sem:object></sem:triple>"
+ "</sem:triples>\n" + "</semantic-document>";
String tripleDocTwo = "<semantic-document>\n" + "<title>Second Title</title>\n" + "<popularity>5</popularity>\n"
+ "<size>500</size>\n" + "<sem:triples xmlns:sem=\"http://marklogic.com/semantics\">"
+ "<sem:triple><sem:subject>http://example.org/r9929</sem:subject>"
+ "<sem:predicate>http://example.org/p3</sem:predicate>"
+ "<sem:object datatype=\"http://www.w3.org/2001/XMLSchema#int\">2</sem:object></sem:triple>"
+ "</sem:triples>\n" + "</semantic-document>";
DataMovementManager dmManager = dbClient.newDataMovementManager();
WriteBatcher batcher = dmManager.newWriteBatcher();
batcher.add("/directory1/doc1.xml", new StringHandle().with(tripleDocOne)).add("/directory2/doc2.xml",
new StringHandle().with(tripleDocTwo));
batcher.flushAndWait();
dbClient.release();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:26,代码来源:MarkLogicRepositoryConnectionTest.java
示例6: loadPropsAndInit
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
public static MarkLogicDatasetGraph loadPropsAndInit() {
Properties props = new Properties();
// two attempts to load
try {
props.load(new FileInputStream("marklogic-jena-examples/gradle.properties"));
} catch (IOException e) {
// gradle prefers this path.
try {
props.load(new FileInputStream("gradle.properties"));
} catch (IOException e2) {
System.err.println("problem loading properties file.");
System.exit(1);
}
}
String host = props.getProperty("mlHost");
int port = Integer.parseInt(props.getProperty("mlRestPort"));
String user = props.getProperty("writerUser");
String pass = props.getProperty("writerPassword");
DatabaseClient client = DatabaseClientFactory.newClient(host, port,
new DatabaseClientFactory.DigestAuthContext(user, pass));
MarkLogicDatasetGraph dg = MarkLogicDatasetGraphFactory
.createDatasetGraph(client);
return dg;
}
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:26,代码来源:ExampleUtils.java
示例7: setup
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
@Before
public void setup() throws IOException {
client = testDatabaseClient = DatabaseClientFactory.newClient(batchDatabaseClientConfig.getHost(),
batchDatabaseClientConfig.getPort(), new DatabaseClientFactory.DigestAuthContext(batchDatabaseClientConfig.getUsername(),
batchDatabaseClientConfig.getPassword()));
clientTestHelper = new ClientTestHelper();
SimpleDatabaseClientProvider dbConfig = new SimpleDatabaseClientProvider(batchDatabaseClientConfig);
clientTestHelper.setDatabaseClientProvider(dbConfig);
testDatabaseClient = DatabaseClientFactory.newClient(batchDatabaseClientConfig.getHost(),
batchDatabaseClientConfig.getPort(),
new DatabaseClientFactory.DigestAuthContext(
batchDatabaseClientConfig.getUsername(), batchDatabaseClientConfig.getPassword()));
docMgr = testDatabaseClient.newXMLDocumentManager();
Resource transform = getApplicationContext().getResource("classpath:/transforms/simple.xqy");
TransformExtensionsManager transMgr = testDatabaseClient.newServerConfigManager().newTransformExtensionsManager();
FileHandle fileHandle = new FileHandle(transform.getFile());
fileHandle.setFormat(Format.XML);
transMgr.writeXQueryTransform(transformName, fileHandle);
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:22,代码来源:MarkLogicItemWriterTest.java
示例8: setup
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
@Before
public void setup() {
DatabaseClientFactory.SecurityContext securityContext =
new DatabaseClientFactory.DigestAuthContext(databaseClientConfig.getUsername(),
databaseClientConfig.getPassword());
client = DatabaseClientFactory.newClient(databaseClientConfig.getHost(),
databaseClientConfig.getPort(), securityContext);
helper = new ClientTestHelper();
helper.setDatabaseClientProvider(getClientProvider());
XMLDocumentManager docMgr = client.newXMLDocumentManager();
StringHandle xml1 = new StringHandle("<hello />");
DocumentMetadataHandle metadata = new DocumentMetadataHandle();
metadata.withCollections("a");
DocumentMetadataHandle metadata2 = new DocumentMetadataHandle();
metadata2.withCollections("b");
for (int i = 0; i < 600; i++) {
DocumentMetadataHandle h = (i % 2 == 0) ? metadata : metadata2;
docMgr.write("hello" + i + ".xml", h, xml1);
}
helper.assertCollectionSize("a = 300", "a", 300);
helper.assertCollectionSize("b = 300", "b", 300);
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:27,代码来源:ValuesItemReaderTest.java
示例9: buildCertificateAuthContent
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
protected DatabaseClientFactory.SecurityContext buildCertificateAuthContent(DatabaseClientConfig config) {
String certFile = config.getCertFile();
if (certFile != null) {
try {
if (config.getCertPassword() != null) {
return new DatabaseClientFactory.CertificateAuthContext(certFile, config.getCertPassword());
}
return new DatabaseClientFactory.CertificateAuthContext(certFile);
} catch (Exception ex) {
throw new RuntimeException("Unable to build CertificateAuthContext: " + ex.getMessage(), ex);
}
}
DatabaseClientFactory.SSLHostnameVerifier verifier = config.getSslHostnameVerifier();
if (verifier != null) {
return new DatabaseClientFactory.CertificateAuthContext(config.getSslContext(), verifier);
}
return new DatabaseClientFactory.CertificateAuthContext(config.getSslContext());
}
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:19,代码来源:DefaultConfiguredDatabaseClientFactory.java
示例10: auth
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
/**
* Authenticate the given user with MarkLogic database, returns false
* if unsuccessful since user has no permissions to access the database.
*/
public synchronized boolean auth(String username, String password) {
logger.info("Setting up connection to MarkLogic server {}:{} for user {} ...", host, port, username);
try {
DatabaseClient client = DatabaseClientFactory.newClient(host, port, username, password,
DatabaseClientFactory.Authentication.DIGEST);
// ~~
testQuery(client);
logger.info("Successfully logged in {}", username);
clients.putIfAbsent(username, client);
return true;
} catch (Exception e) {
logger.warn("Unable to login user {}: {}", username, e.getMessage());
return false;
}
}
开发者ID:nikos,项目名称:spring-boot-starter-marklogic,代码行数:20,代码来源:MarkLogicConnections.java
示例11: loadPropsAndInit
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
public static MarkLogicRepository loadPropsAndInit() {
Properties props = new Properties();
try {
props.load(new FileInputStream("gradle.properties"));
} catch (IOException e) {
System.err.println("problem loading properties file.");
System.exit(1);
}
String host = props.getProperty("mlHost");
int port = Integer.parseInt(props.getProperty("mlRestPort"));
String user = props.getProperty("writerUser");
String pass = props.getProperty("writerPassword");
return new MarkLogicRepository(host, port, new DatabaseClientFactory.DigestAuthContext(user, pass));
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:16,代码来源:Setup.java
示例12: MarkLogicRepository
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
/**
*
* Constructor initialized with connection vars to MarkLogic server.
*
* @param host the host with the REST server
* @param port the port for the REST server
* @param database the MarkLogic database to be used.
* @param securityContext a Java Client API SecurityContext. Can be made with com.marklogic.client.DatabaseClientFactory
*/
public MarkLogicRepository(String host, int port, String database, DatabaseClientFactory.SecurityContext securityContext) {
super();
this.f = SimpleValueFactory.getInstance();
this.quadMode = true;
this.host = host;
this.port = port;
this.database = database;
this.securityContext = securityContext;
this.databaseClient = util.getClientBasedOnAuth(this.host, this.port, this.database, this.securityContext);
this.client = new MarkLogicClient(databaseClient);
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:21,代码来源:MarkLogicRepository.java
示例13: negativeTestRepo2
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
@Test
public void negativeTestRepo2()
throws Exception {
Repository rep = new MarkLogicRepository(host, port, new DatabaseClientFactory.DigestAuthContext(user, password));
rep.initialize();
rep.shutDown();
// should throw error as we shutdown repo
exception.expect(RepositoryException.class);
exception.expectMessage("MarkLogicRepository not initialized.");
@SuppressWarnings("unused")
RepositoryConnection conn = rep.getConnection();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:15,代码来源:MarkLogicRepositoryTest.java
示例14: testRepo
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
@Test
public void testRepo()
throws Exception {
Repository rep = new MarkLogicRepository(host, port, new DatabaseClientFactory.DigestAuthContext(user, password));
rep.initialize();
rep.shutDown();
rep.initialize();
Assert.assertTrue(rep.getDataDir() == null);
Assert.assertTrue(rep.isWritable());
Assert.assertTrue(rep.getValueFactory() instanceof SimpleValueFactory);
Assert.assertTrue(rep.getConnection() instanceof MarkLogicRepositoryConnection);
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:15,代码来源:MarkLogicRepositoryTest.java
示例15: testRepo2
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
@Test
public void testRepo2()
throws Exception {
MarkLogicRepository rep = new MarkLogicRepository(host, port, new DatabaseClientFactory.DigestAuthContext(user, password));
rep.initialize();
rep.shutDown();
rep.initialize();
Assert.assertTrue(rep.getDataDir() == null);
Assert.assertTrue(rep.isWritable());
Assert.assertTrue(rep.getValueFactory() instanceof SimpleValueFactory);
Assert.assertTrue(rep.getConnection() instanceof MarkLogicRepositoryConnection);
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:15,代码来源:MarkLogicRepositoryTest.java
示例16: TestRepoWithJavaAPIClientDatabaseClient
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
@Test
public void TestRepoWithJavaAPIClientDatabaseClient()
throws Exception {
DatabaseClient databaseClient = DatabaseClientFactory.newClient(host, port, new DatabaseClientFactory.DigestAuthContext(user, password));
Repository rep = new MarkLogicRepository(databaseClient);
rep.initialize();
Assert.assertTrue(rep instanceof Repository);
RepositoryConnection conn = rep.getConnection();
Assert.assertTrue(conn instanceof RepositoryConnection);
conn.close();
rep.shutDown();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:13,代码来源:MarkLogicRepositoryTest.java
示例17: PersistenceService
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
public PersistenceService(String host, int port, String user, String password) {
markLogicRepository = new MarkLogicRepository(host, port, new DatabaseClientFactory.DigestAuthContext(user, password));
try {
markLogicRepository.initialize();
} catch (RepositoryException e) {
throw new RuntimeException("error initialising repo", e);
}
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:9,代码来源:MultiThreadedPersistenceTest.java
示例18: SingleConnectionPersistenceService
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
public SingleConnectionPersistenceService(String host, int port, String user, String password) {
MarkLogicRepository markLogicRepository = new MarkLogicRepository(host, port, new DatabaseClientFactory.DigestAuthContext(user, password));
try {
markLogicRepository.initialize();
connection = markLogicRepository.getConnection();
} catch (RepositoryException e) {
throw new RuntimeException("error initialising repo", e);
}
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:10,代码来源:MultiThreadedPersistenceTest.java
示例19: MultipleConnectionPersistenceService
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
public MultipleConnectionPersistenceService(String host, int port, String user, String password) {
try {
DatabaseClient databaseClient = DatabaseClientFactory.newClient(host, port, new DatabaseClientFactory.DigestAuthContext(user, password));
markLogicRepository = new MarkLogicRepository(databaseClient);
markLogicRepository.initialize();
} catch (RepositoryException e) {
throw new RuntimeException("error initialising repo", e);
}
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:10,代码来源:MultiThreadedPersistenceTest.java
示例20: testConnectionWithMLClientApiObjectWithDatabase
import com.marklogic.client.DatabaseClientFactory; //导入依赖的package包/类
@Test
public void testConnectionWithMLClientApiObjectWithDatabase()
{
DatabaseClient databaseClient = DatabaseClientFactory.newClient(host, port, "marklogic-rdf4j-test-content", new DatabaseClientFactory.DigestAuthContext(user, password));
MarkLogicRepository markLogicRepository = new MarkLogicRepository(databaseClient);
markLogicRepository.initialize();
MarkLogicRepositoryConnection con = markLogicRepository.getConnection();
ValueFactory vf = con.getValueFactory();
Resource context10 = vf.createIRI("http://marklogic.com/test/context10");
IRI alice = vf.createIRI("http://example.org/people/alice");
IRI name = vf.createIRI("http://example.org/ontology/name");
Literal alicesName = vf.createLiteral("Alice");
con.begin();
con.add(alice, name, alicesName, context10);
con.commit();
RepositoryResult<Statement> result = con.getStatements(alice, null, null, context10);
Model model = Iterations.addAll(result, new LinkedHashModel());
Assert.assertEquals(1, model.size());
markLogicRepository.shutDown();
markLogicRepository.initialize();
con = markLogicRepository.getConnection();
result = con.getStatements(alice, null, null, context10);
model = Iterations.addAll(result, new LinkedHashModel());
Assert.assertEquals(1, model.size());
con.clear();
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:28,代码来源:MarkLogicRepositoryConnectionTest.java
注:本文中的com.marklogic.client.DatabaseClientFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论