/** * Initializes a handle registry with the default associations * between the content handles provided by the API and the supported * IO representation classes. Use this method only after clearing * or overwriting associations in the handle registry. */ static public void registerDefaultHandles() { HandleFactoryRegistryImpl.registerDefaults(getHandleRegistry()); }
/** * Initializes a handle registry with the default associations * between the content handles provided by the API and the supported * IO representation classes. Use this method only after clearing * or overwriting associations in the handle registry. */ static public void registerDefaultHandles() { HandleFactoryRegistryImpl.registerDefaults(getHandleRegistry()); }
@Override public DocumentWriteSet addAs(String docId, DocumentMetadataWriteHandle metadataHandle, Object content, String temporalDocumentURI) { if (content == null) throw new IllegalArgumentException("content must not be null"); Class<?> as = content.getClass(); ContentHandle<?> handle = DatabaseClientFactory.getHandleRegistry().makeHandle(as); Utilities.setHandleContent(handle, content); return add(docId, metadataHandle, handle, temporalDocumentURI); }
@Override public DocumentWriteSet addAs(String docId, DocumentMetadataWriteHandle metadataHandle, Object content) { if (content == null) throw new IllegalArgumentException("content must not be null"); Class<?> as = content.getClass(); ContentHandle<?> handle = DatabaseClientFactory.getHandleRegistry().makeHandle(as); Utilities.setHandleContent(handle, content); return add(docId, metadataHandle, handle); }
@Override public WriteBatcher addAs(String uri, DocumentMetadataWriteHandle metadataHandle, Object content) { if (content == null) throw new IllegalArgumentException("content must not be null"); AbstractWriteHandle handle; Class<?> as = content.getClass(); if (AbstractWriteHandle.class.isAssignableFrom(as)) { handle = (AbstractWriteHandle) content; } else { ContentHandle<?> contentHandle = DatabaseClientFactory.getHandleRegistry().makeHandle(as); Utilities.setHandleContent(contentHandle, content); handle = contentHandle; } return add(uri, metadataHandle, handle); }
@Override public <T> T getAs(Class<T> as) { ContentHandle<T> readHandle = DatabaseClientFactory.getHandleRegistry().makeHandle(as); if ( readHandle == null ) return null; HandleAccessor.receiveContent(readHandle, item); return readHandle.get(); } }
public <T> T getContentAs(Class<T> clazz) { ContentHandle<T> readHandle = DatabaseClientFactory.getHandleRegistry().makeHandle(clazz); readHandle = getContent(readHandle); if ( readHandle == null ) return null; return readHandle.get(); }
@Override public <T> T getAs(Class<T> clazz) { if ( getType() == EvalResult.Type.NULL ) return null; if (clazz == null) throw new IllegalArgumentException("clazz cannot be null"); ContentHandle<T> readHandle = DatabaseClientFactory.getHandleRegistry().makeHandle(clazz); if ( readHandle == null ) return null; readHandle = get(readHandle); if ( readHandle == null ) return null; return readHandle.get(); }
/** * Creates a client to access the database by means of a REST server. * * @param host the host with the REST server * @param port the port for the REST server * @param user the user with read, write, or administrative privileges * @param password the password for the user * @param type the type of authentication applied to the request * @param context the SSL context for authenticating with the server * @param verifier a callback for checking hostnames * @return a new client for making database requests */ static public DatabaseClient newClient(String host, int port, String user, String password, Authentication type, SSLContext context, SSLHostnameVerifier verifier) { DatabaseClientImpl client = newClientImpl(host, port, user, password, type, context, verifier); client.setHandleRegistry(getHandleRegistry().copy()); return client; } static private DatabaseClientImpl newClientImpl(String host, int port, String user, String password, Authentication type, SSLContext context, SSLHostnameVerifier verifier) {
@AfterClass public static void afterClass() { DatabaseClientFactory.getHandleRegistry().register(StringHandle.newFactory()); }
services, host, port, database, securityContext, connectionType ); client.setHandleRegistry(getHandleRegistry().copy()); return client;
@BeforeClass public static void beforeClass() { // demonstrate our ability to set advanced configuration on a mapper ObjectMapper mapper = new ObjectMapper(); // in this case, we're saying wrap our serialization with the name of the pojo class mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_OBJECT); // register a JacksonDatabindHandleFactory ready to marshall any City object to/from json // this enables the writeAs method below DatabaseClientFactory.getHandleRegistry().register( JacksonDatabindHandle.newFactory(mapper, City.class) ); // we cannot use the singleton DatabaseClient here because this test requires // a DatabaseClient created after calling getHandleRegistry().register() with City.class client = Common.newClient(); }
@BeforeClass public static void beforeClass() throws JAXBException { Common.connect(); DatabaseClientFactory.getHandleRegistry().register( JAXBHandle.newFactory(City.class) ); } @AfterClass
(i == 1) ? DatabaseClientFactory.getHandleRegistry() : clientFactoryBean.getHandleRegistry();