use of com.peterphi.std.guice.restclient.resteasy.impl.JAXBContextResolver in project stdlib by petergeneric.
the class LogForwardDaemonPreGuice method start.
private void start() {
final String instanceId = config.get(GuiceProperties.INSTANCE_ID);
// TODO fix this!
final String localEndpoint = config.get(GuiceProperties.LOCAL_REST_SERVICES_ENDPOINT, "http://unknown");
final boolean useMoxy = config.getBoolean(GuiceProperties.MOXY_ENABLED, true);
// Construct the necessary classes to create resteasy proxy clients.
// We must do this independent of the guice creation path because we'll be running as Guice is starting up
final JAXBContextResolver jaxb = new JAXBContextResolver(new JAXBSerialiserFactory(useMoxy));
this.clientFactory = new ResteasyClientFactoryImpl(null, null, null, jaxb);
ResteasyProxyClientFactoryImpl proxyFactory = new ResteasyProxyClientFactoryImpl(clientFactory, config);
// Instantiate the services
final ServiceManagerLoggingRestService logService = proxyFactory.getClient(ServiceManagerLoggingRestService.class);
final ServiceManagerRegistryRestService registryService = proxyFactory.getClient(ServiceManagerRegistryRestService.class);
this.daemon = new ServiceManagerLogForwardDaemon(instanceId, URI.create(localEndpoint), registryService, logService, this::guiceHasTakenOver);
// Start the thread running
this.daemon.startThread();
}
use of com.peterphi.std.guice.restclient.resteasy.impl.JAXBContextResolver in project stdlib by petergeneric.
the class GuiceFactory method applyNetworkConfiguration.
/**
* Add to the configuration any properties defined by the network configuration endpoint (if network config is enabled in a
* previous property)
*
* @param config
*/
private static void applyNetworkConfiguration(final GuiceConfig config) {
final String configEndpoint = config.get(GuiceProperties.CONFIG_ENDPOINT, null);
final Boolean configSkip = config.getBoolean(GuiceProperties.CONFIG_SKIP, false);
if (configEndpoint != null && !configSkip) {
final boolean useMoxy = config.getBoolean(GuiceProperties.MOXY_ENABLED, true);
final JAXBContextResolver jaxb = new JAXBContextResolver(new JAXBSerialiserFactory(useMoxy));
final ResteasyClientFactoryImpl clientFactory = new ResteasyClientFactoryImpl(null, null, null, jaxb);
try {
final ResteasyProxyClientFactoryImpl proxyFactory = new ResteasyProxyClientFactoryImpl(clientFactory, config);
final ConfigRestService client = proxyFactory.getClient(ConfigRestService.class);
// We set it in the config because otherwise the NetworkConfigReloadDaemon won't be able to load the config
if (config.get(GuiceProperties.CONFIG_PATH) == null) {
config.set(GuiceProperties.CONFIG_PATH, "services/" + config.get(GuiceProperties.SERVLET_CONTEXT_NAME, "unknown-service"));
}
// Get the config path to read
final String path = config.get(GuiceProperties.CONFIG_PATH);
final ConfigPropertyData data = client.read(path, config.get(GuiceProperties.INSTANCE_ID), null);
for (ConfigPropertyValue property : data.properties) {
config.set(property.name, property.value);
}
// Let others know that the configuration data is coming from a network source
config.set(GuiceProperties.CONFIG_SOURCE, GuiceConstants.CONFIG_SOURCE_NETWORK);
if (data.revision != null)
config.set(GuiceProperties.CONFIG_REVISION, data.revision);
} finally {
clientFactory.shutdown();
}
} else {
// Config is not coming from the network
config.set(GuiceProperties.CONFIG_SOURCE, GuiceConstants.CONFIG_SOURCE_LOCAL);
}
}
Aggregations