From: Bill Erickson Date: Thu, 10 Nov 2016 19:46:45 +0000 (-0500) Subject: Native Messaging WIP - docs, tweaks X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c799eba36ff053a2ab8fd99adc22022b329d25ff;p=working%2FHatch.git Native Messaging WIP - docs, tweaks Signed-off-by: Bill Erickson --- diff --git a/src/org/evergreen_ils/hatch/MessageIO.java b/src/org/evergreen_ils/hatch/MessageIO.java index d24ecb0a22..caa3863fc3 100644 --- a/src/org/evergreen_ils/hatch/MessageIO.java +++ b/src/org/evergreen_ils/hatch/MessageIO.java @@ -1,9 +1,25 @@ +/* ----------------------------------------------------------------------- + * Copyright 2016 King County Library System + * Bill Erickson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ----------------------------------------------------------------------- + */ package org.evergreen_ils.hatch; import java.util.logging.*; import java.util.concurrent.LinkedBlockingQueue; import java.nio.ByteBuffer; import java.io.IOException; +import java.util.regex.Pattern; import org.json.*; /** @@ -16,11 +32,12 @@ public class MessageIO { private LinkedBlockingQueue inQueue; private LinkedBlockingQueue outQueue; - static final Logger logger = Hatch.getLogger(); private MessageReader reader; private MessageWriter writer; + static final Logger logger = Hatch.getLogger(); + public MessageIO() { inQueue = new LinkedBlockingQueue(); outQueue = new LinkedBlockingQueue(); @@ -111,7 +128,7 @@ public class MessageIO { String message = new String(msgBytes, "UTF-8"); - logger.info("MessageReader read: " + message); + logger.info("MessageReader read: " + message.length()); return message; } @@ -137,13 +154,14 @@ public class MessageIO { System.exit(1); } catch (IOException ioe) { + logger.warning(ioe.toString()); + continue; } catch (JSONException je) { logger.warning("Error parsing JSON message on STDIN " + je.toString() + " : " + message); - continue; } diff --git a/src/org/evergreen_ils/hatch/RequestHandler.java b/src/org/evergreen_ils/hatch/RequestHandler.java index 548ef827c9..4cce19ee66 100644 --- a/src/org/evergreen_ils/hatch/RequestHandler.java +++ b/src/org/evergreen_ils/hatch/RequestHandler.java @@ -1,3 +1,18 @@ +/* ----------------------------------------------------------------------- + * Copyright 2016 King County Library System + * Bill Erickson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ----------------------------------------------------------------------- + */ package org.evergreen_ils.hatch; import org.json.*; diff --git a/src/org/evergreen_ils/hatch/TestHatch.java b/src/org/evergreen_ils/hatch/TestHatch.java index 240d1e579f..08c68c9064 100644 --- a/src/org/evergreen_ils/hatch/TestHatch.java +++ b/src/org/evergreen_ils/hatch/TestHatch.java @@ -1,3 +1,18 @@ +/* ----------------------------------------------------------------------- + * Copyright 2016 King County Library System + * Bill Erickson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ----------------------------------------------------------------------- + */ package org.evergreen_ils.hatch; import java.util.logging.Logger;