本文整理汇总了Java中org.codehaus.jackson.map.MappingJsonFactory类的典型用法代码示例。如果您正苦于以下问题:Java MappingJsonFactory类的具体用法?Java MappingJsonFactory怎么用?Java MappingJsonFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MappingJsonFactory类属于org.codehaus.jackson.map包,在下文中一共展示了MappingJsonFactory类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jsonResponse
import org.codehaus.jackson.map.MappingJsonFactory; //导入依赖的package包/类
public static Response jsonResponse (Object obj, Class clazz) throws JAXBException{
StringWriter writer = new StringWriter();
try {
ObjectMapper mapper = new ObjectMapper();
MappingJsonFactory jsonFactory = new MappingJsonFactory();
JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(writer);
mapper.writeValue(jsonGenerator, obj);
writer.close();
} catch (IOException e) {
}
return Response.status(200).type("application/json").entity(writer.toString()).build();
}
示例2: onMessage
import org.codehaus.jackson.map.MappingJsonFactory; //导入依赖的package包/类
@Override
default public void onMessage(final String message)
{
try
{
onEvent(new MappingJsonFactory().createJsonParser(message).readValueAs(Event.class));
}
catch (final Exception e)
{
_logger.log(Level.SEVERE, "Can't convert json to Map<String,Object>" + message, e);
onEvent(new Event());
}
}
示例3: decode
import org.codehaus.jackson.map.MappingJsonFactory; //导入依赖的package包/类
public static <T> T decode(final int status, final String str, final Class<T> t)
{
try
{
if (200 == status || 201 == status)
return new MappingJsonFactory().createJsonParser(str).readValueAs(t);
else
throw new ApiV4Exception(new MappingJsonFactory().createJsonParser(str).readValueAs(com.cloudtemple.mattermost.traders.Error.class));
}
catch (final IOException e)
{
_logger.log(Level.SEVERE, "", e);
throw new ApiV4Exception(e);
}
}
示例4: jsonToHostDefinition
import org.codehaus.jackson.map.MappingJsonFactory; //导入依赖的package包/类
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
MappingJsonFactory f = new MappingJsonFactory();
JsonParser jp;
try {
jp = f.createJsonParser(json);
} catch (JsonParseException e) {
throw new IOException(e);
}
jp.nextToken();
if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
throw new IOException("Expected START_OBJECT");
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
throw new IOException("Expected FIELD_NAME");
}
String n = jp.getCurrentName();
jp.nextToken();
if (jp.getText().equals(""))
continue;
else if (n.equals("attachment")) {
while (jp.nextToken() != JsonToken.END_OBJECT) {
String field = jp.getCurrentName();
if (field.equals("id")) {
host.attachment = jp.getText();
} else if (field.equals("mac")) {
host.mac = jp.getText();
}
}
}
}
jp.close();
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:39,代码来源:HostResource.java
示例5: getEntryNameFromJson
import org.codehaus.jackson.map.MappingJsonFactory; //导入依赖的package包/类
/**
* Gets the entry name of a flow mod
* @param fmJson The OFFlowMod in a JSON representation
* @return The name of the OFFlowMod, null if not found
* @throws IOException If there was an error parsing the JSON
*/
public static String getEntryNameFromJson(String fmJson) throws IOException{
MappingJsonFactory f = new MappingJsonFactory();
JsonParser jp;
try {
jp = f.createJsonParser(fmJson);
} catch (JsonParseException e) {
throw new IOException(e);
}
jp.nextToken();
if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
throw new IOException("Expected START_OBJECT");
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
throw new IOException("Expected FIELD_NAME");
}
String n = jp.getCurrentName();
jp.nextToken();
if (jp.getText().equals(""))
continue;
if (n == "name")
return jp.getText();
}
return null;
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:38,代码来源:StaticFlowEntries.java
示例6: jsonExtractSubnetMask
import org.codehaus.jackson.map.MappingJsonFactory; //导入依赖的package包/类
/**
* Extracts subnet mask from a JSON string
* @param fmJson The JSON formatted string
* @return The subnet mask
* @throws IOException If there was an error parsing the JSON
*/
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
String subnet_mask = "";
MappingJsonFactory f = new MappingJsonFactory();
JsonParser jp;
try {
jp = f.createJsonParser(fmJson);
} catch (JsonParseException e) {
throw new IOException(e);
}
jp.nextToken();
if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
throw new IOException("Expected START_OBJECT");
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
throw new IOException("Expected FIELD_NAME");
}
String n = jp.getCurrentName();
jp.nextToken();
if (jp.getText().equals(""))
continue;
if (n == "subnet-mask") {
subnet_mask = jp.getText();
break;
}
}
return subnet_mask;
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:41,代码来源:FirewallResource.java
示例7: JacksonSerializer
import org.codehaus.jackson.map.MappingJsonFactory; //导入依赖的package包/类
public JacksonSerializer()
{
this.serializerFactory = new CustomSerializerFactory();
this.serializerFactory.addGenericMapping(CGLIBLazyInitializer.class, new CGLIBLazyInitializerHandler());
this.factory = new MappingJsonFactory(new ObjectMapper(this.serializerFactory));
this.factory.setGeneratorFeature(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true);
}
示例8: JSONLogProvider
import org.codehaus.jackson.map.MappingJsonFactory; //导入依赖的package包/类
public JSONLogProvider(Reader reader, JSONLogEntryLoader loader) {
this.loader = loader;
try {
this.parser = new MappingJsonFactory().createJsonParser(reader);
} catch (IOException e) {
throw new RuntimeException("JSON Stream cannot be read");
}
}
示例9: getEntryNameFromJson
import org.codehaus.jackson.map.MappingJsonFactory; //导入依赖的package包/类
/**
* Gets the entry name of a flow mod
* @param fmJson The OFFlowMod in a JSON representation
* @return The name of the OFFlowMod, null if not found
* @throws IOException If there was an error parsing the JSON
*/
public static String getEntryNameFromJson(String fmJson) throws IOException{
MappingJsonFactory f = new MappingJsonFactory();
JsonParser jp;
try {
jp = f.createJsonParser(fmJson);
} catch (JsonParseException e) {
throw new IOException(e);
}
jp.nextToken();
if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
throw new IOException("Expected START_OBJECT");
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
throw new IOException("Expected FIELD_NAME");
}
String n = jp.getCurrentName();
jp.nextToken();
if (jp.getText().equals(""))
continue;
if (n == "name")
return jp.getText();
}
return null;
}
示例10: toJSON
import org.codehaus.jackson.map.MappingJsonFactory; //导入依赖的package包/类
public void toJSON(Writer writer, T value) throws IOException {
MappingJsonFactory factory = new MappingJsonFactory();
JsonGenerator generator = factory.createJsonGenerator(writer);
if (usePrettyPrinter) {
generator.useDefaultPrettyPrinter();
}
objectMapper.writeValue(generator, value);
}
示例11: jsonToNetworkDefinition
import org.codehaus.jackson.map.MappingJsonFactory; //导入依赖的package包/类
protected void jsonToNetworkDefinition(String json, NetworkDefinition network) throws IOException {
MappingJsonFactory f = new MappingJsonFactory();
JsonParser jp;
try {
jp = f.createJsonParser(json);
} catch (JsonParseException e) {
throw new IOException(e);
}
jp.nextToken();
if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
throw new IOException("Expected START_OBJECT");
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
throw new IOException("Expected FIELD_NAME");
}
String n = jp.getCurrentName();
jp.nextToken();
if (jp.getText().equals(""))
continue;
else if (n.equals("network")) {
while (jp.nextToken() != JsonToken.END_OBJECT) {
String field = jp.getCurrentName();
if (field.equals("name")) {
network.name = jp.getText();
} else if (field.equals("gateway")) {
String gw = jp.getText();
if ((gw != null) && (!gw.equals("null")))
network.gateway = gw;
} else if (field.equals("id")) {
network.guid = jp.getText();
} else {
log.warn("Unrecognized field {} in " +
"parsing network definition",
jp.getText());
}
}
}
}
jp.close();
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:47,代码来源:NetworkResource.java
示例12: jsonToStorageEntry
import org.codehaus.jackson.map.MappingJsonFactory; //导入依赖的package包/类
/**
* Turns a JSON formatted Static Flow Pusher string into a storage entry
* Expects a string in JSON along the lines of:
* {
* "switch": "AA:BB:CC:DD:EE:FF:00:11",
* "name": "flow-mod-1",
* "cookie": "0",
* "priority": "32768",
* "ingress-port": "1",
* "actions": "output=2",
* }
* @param fmJson The JSON formatted static flow pusher entry
* @return The map of the storage entry
* @throws IOException If there was an error parsing the JSON
*/
public static Map<String, Object> jsonToStorageEntry(String fmJson) throws IOException {
Map<String, Object> entry = new HashMap<String, Object>();
MappingJsonFactory f = new MappingJsonFactory();
JsonParser jp;
try {
jp = f.createJsonParser(fmJson);
} catch (JsonParseException e) {
throw new IOException(e);
}
jp.nextToken();
if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
throw new IOException("Expected START_OBJECT");
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
throw new IOException("Expected FIELD_NAME");
}
String n = jp.getCurrentName();
jp.nextToken();
if (jp.getText().equals(""))
continue;
if (n == "name")
entry.put(StaticFlowEntryPusher.COLUMN_NAME, jp.getText());
else if (n == "switch")
entry.put(StaticFlowEntryPusher.COLUMN_SWITCH, jp.getText());
else if (n == "actions")
entry.put(StaticFlowEntryPusher.COLUMN_ACTIONS, jp.getText());
else if (n == "priority")
entry.put(StaticFlowEntryPusher.COLUMN_PRIORITY, jp.getText());
else if (n == "active")
entry.put(StaticFlowEntryPusher.COLUMN_ACTIVE, jp.getText());
else if (n == "wildcards")
entry.put(StaticFlowEntryPusher.COLUMN_WILDCARD, jp.getText());
else if (n == "ingress-port")
entry.put(StaticFlowEntryPusher.COLUMN_IN_PORT, jp.getText());
else if (n == "src-mac")
entry.put(StaticFlowEntryPusher.COLUMN_DL_SRC, jp.getText());
else if (n == "dst-mac")
entry.put(StaticFlowEntryPusher.COLUMN_DL_DST, jp.getText());
else if (n == "vlan-id")
entry.put(StaticFlowEntryPusher.COLUMN_DL_VLAN, jp.getText());
else if (n == "vlan-priority")
entry.put(StaticFlowEntryPusher.COLUMN_DL_VLAN_PCP, jp.getText());
else if (n == "ether-type")
entry.put(StaticFlowEntryPusher.COLUMN_DL_TYPE, jp.getText());
else if (n == "tos-bits")
entry.put(StaticFlowEntryPusher.COLUMN_NW_TOS, jp.getText());
else if (n == "protocol")
entry.put(StaticFlowEntryPusher.COLUMN_NW_PROTO, jp.getText());
else if (n == "src-ip")
entry.put(StaticFlowEntryPusher.COLUMN_NW_SRC, jp.getText());
else if (n == "dst-ip")
entry.put(StaticFlowEntryPusher.COLUMN_NW_DST, jp.getText());
else if (n == "src-port")
entry.put(StaticFlowEntryPusher.COLUMN_TP_SRC, jp.getText());
else if (n == "dst-port")
entry.put(StaticFlowEntryPusher.COLUMN_TP_DST, jp.getText());
}
return entry;
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:82,代码来源:StaticFlowEntries.java
示例13: serviceStart
import org.codehaus.jackson.map.MappingJsonFactory; //导入依赖的package包/类
@Override
protected void serviceStart() throws Exception {
super.serviceStart();
LOG.info("Starting {}", getName());
summaryStore.start();
Configuration conf = getConfig();
aclManager = new TimelineACLsManager(conf);
aclManager.setTimelineStore(summaryStore);
summaryTdm = new TimelineDataManager(summaryStore, aclManager);
summaryTdm.init(conf);
addService(summaryTdm);
// start child services that aren't already started
super.serviceStart();
if (!fs.exists(activeRootPath)) {
fs.mkdirs(activeRootPath);
fs.setPermission(activeRootPath, ACTIVE_DIR_PERMISSION);
}
if (!fs.exists(doneRootPath)) {
fs.mkdirs(doneRootPath);
fs.setPermission(doneRootPath, DONE_DIR_PERMISSION);
}
objMapper = new ObjectMapper();
objMapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
jsonFactory = new MappingJsonFactory(objMapper);
final long scanIntervalSecs = conf.getLong(
YarnConfiguration
.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_SCAN_INTERVAL_SECONDS,
YarnConfiguration
.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_SCAN_INTERVAL_SECONDS_DEFAULT
);
final long cleanerIntervalSecs = conf.getLong(
YarnConfiguration
.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_CLEANER_INTERVAL_SECONDS,
YarnConfiguration
.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_CLEANER_INTERVAL_SECONDS_DEFAULT
);
final int numThreads = conf.getInt(
YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_THREADS,
YarnConfiguration
.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_THREADS_DEFAULT);
LOG.info("Scanning active directory {} every {} seconds", activeRootPath,
scanIntervalSecs);
LOG.info("Cleaning logs every {} seconds", cleanerIntervalSecs);
executor = new ScheduledThreadPoolExecutor(numThreads,
new ThreadFactoryBuilder().setNameFormat("EntityLogPluginWorker #%d")
.build());
executor.scheduleAtFixedRate(new EntityLogScanner(), 0, scanIntervalSecs,
TimeUnit.SECONDS);
executor.scheduleAtFixedRate(new EntityLogCleaner(), cleanerIntervalSecs,
cleanerIntervalSecs, TimeUnit.SECONDS);
}
示例14: JsonStreamParser
import org.codehaus.jackson.map.MappingJsonFactory; //导入依赖的package包/类
public JsonStreamParser(File jsonFile) throws IOException {
factory = new MappingJsonFactory();
parser = factory.createJsonParser(jsonFile);
}