use of javax.json.spi.JsonProvider in project jaqy by Teradata.
the class JsonPrinter method print.
@Override
public long print(JaqyResultSet rs, PrintWriter pw, long limit, JaqyInterpreter interpreter) throws Exception {
JsonProvider provider = new CookJsonProvider();
HashMap<String, Object> config = new HashMap<String, Object>();
config.put(CookJsonProvider.FORMAT, CookJsonProvider.FORMAT_JSON);
if (m_pretty)
config.put(JsonGenerator.PRETTY_PRINTING, Boolean.TRUE);
switch(m_binaryFormat) {
case Base64:
config.put(CookJsonProvider.BINARY_FORMAT, CookJsonProvider.BINARY_FORMAT_BASE64);
break;
case Hex:
config.put(CookJsonProvider.BINARY_FORMAT, CookJsonProvider.BINARY_FORMAT_HEX);
break;
}
CookJsonGenerator g = (CookJsonGenerator) provider.createGeneratorFactory(config).createGenerator(pw);
long count = JsonUtils.print(interpreter.getGlobals(), g, rs, limit);
pw.println();
return count;
}
use of javax.json.spi.JsonProvider in project javaee7-firstcup by ecabrerar.
the class DeviceSessionHandler method toggleDevice.
public void toggleDevice(int id) {
JsonProvider provider = JsonProvider.provider();
Device device = getDeviceById(id);
if (device != null) {
if ("On".equals(device.getStatus())) {
device.setStatus("Off");
} else {
device.setStatus("On");
}
JsonObject updateDevMessage = provider.createObjectBuilder().add("action", "toggle").add("id", device.getId()).add("status", device.getStatus()).build();
sendToAllConnectedSessions(updateDevMessage);
}
}
use of javax.json.spi.JsonProvider in project component-runtime by Talend.
the class ComponentManager method containerServices.
protected void containerServices(final Container container, final Map<Class<?>, Object> services) {
// note: we can move it to manager instances at some point
final JsonProvider jsonpProvider = new PreComputedJsonpProvider(container.getId(), this.jsonpProvider, jsonpParserFactory, jsonpWriterFactory, jsonpBuilderFactory, jsonpGeneratorFactory, jsonpReaderFactory);
services.put(JsonProvider.class, jsonpProvider);
services.put(JsonBuilderFactory.class, javaProxyEnricherFactory.asSerializable(container.getLoader(), container.getId(), JsonBuilderFactory.class.getName(), jsonpBuilderFactory));
services.put(JsonParserFactory.class, javaProxyEnricherFactory.asSerializable(container.getLoader(), container.getId(), JsonParserFactory.class.getName(), jsonpParserFactory));
services.put(JsonReaderFactory.class, javaProxyEnricherFactory.asSerializable(container.getLoader(), container.getId(), JsonReaderFactory.class.getName(), jsonpReaderFactory));
services.put(JsonWriterFactory.class, javaProxyEnricherFactory.asSerializable(container.getLoader(), container.getId(), JsonWriterFactory.class.getName(), jsonpWriterFactory));
services.put(JsonGeneratorFactory.class, javaProxyEnricherFactory.asSerializable(container.getLoader(), container.getId(), JsonGeneratorFactory.class.getName(), jsonpGeneratorFactory));
final Jsonb jsonb = jsonbProvider.create().withProvider(// reuses the same memory buffering
jsonpProvider).withConfig(new JsonbConfig().setProperty("johnzon.cdi.activated", false)).build();
final Jsonb serializableJsonb = Jsonb.class.cast(javaProxyEnricherFactory.asSerializable(container.getLoader(), container.getId(), Jsonb.class.getName(), jsonb));
services.put(Jsonb.class, serializableJsonb);
// not JSON services
services.put(HttpClientFactory.class, new HttpClientFactoryImpl(container.getId(), reflections, serializableJsonb, services));
services.put(LocalCache.class, new LocalCacheService(container.getId()));
services.put(LocalConfiguration.class, new LocalConfigurationService(createRawLocalConfigurations(), container.getId()));
services.put(ProxyGenerator.class, proxyGenerator);
services.put(Resolver.class, new ResolverImpl(container.getId(), container.getLocalDependencyRelativeResolver()));
}
Aggregations