changeset 347:86935b872385

*** empty log message ***
author kono
date Tue, 14 Oct 2008 09:33:31 +0900
parents edf0e0a5ffc8
children 1bc132a6b879
files rep/SessionManager.java rep/handler/REPEditorHandler.java rep/handler/REPHandler.java rep/handler/REPSessionManagerHandler.java rep/xml/SessionXMLDecoder.java test/XMLTest.java
diffstat 6 files changed, 28 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/rep/SessionManager.java	Tue Oct 14 09:33:31 2008 +0900
+++ b/rep/SessionManager.java	Tue Oct 14 09:33:31 2008 +0900
@@ -170,9 +170,7 @@
 			} else {
 				try {
 					manage(p.channel, p.command);
-				} catch (IOException e1) {
-					close(p.channel);
-				} catch (SAXException e1) {
+				} catch (Exception e1) {
 					close(p.channel);
 				}		
 			}
--- a/rep/handler/REPEditorHandler.java	Tue Oct 14 09:33:31 2008 +0900
+++ b/rep/handler/REPEditorHandler.java	Tue Oct 14 09:33:31 2008 +0900
@@ -1,7 +1,5 @@
 package rep.handler;
 
-import java.io.IOException;
-
 import rep.REPCommand;
 import rep.SessionManager;
 import rep.channel.REPSelectionKey;
@@ -16,7 +14,7 @@
 		this.manager = manager;
 	}
 
-	public void handle(REPSelectionKey<REPCommand> key) throws IOException {
+	public void handle(REPSelectionKey<REPCommand> key) throws Exception {
 		REPSocketChannel<REPCommand> channel = key.channel1();
 		REPCommand command = channel.read();
 		SessionManager.logger.writeLog("REPHandlerImpl.handle() read : command = " + command +" from "+channel);
--- a/rep/handler/REPHandler.java	Tue Oct 14 09:33:31 2008 +0900
+++ b/rep/handler/REPHandler.java	Tue Oct 14 09:33:31 2008 +0900
@@ -1,12 +1,11 @@
 package rep.handler;
 
-import java.io.IOException;
 import rep.REPCommand;
 import rep.channel.REPSelectionKey;
 import rep.channel.REPSocketChannel;
 
 public interface REPHandler {
-	void handle(REPSelectionKey<REPCommand> key)throws IOException;
+	void handle(REPSelectionKey<REPCommand> key)throws Exception;
 
 	void cancel(REPSocketChannel<REPCommand> socketChannel);
 
--- a/rep/handler/REPSessionManagerHandler.java	Tue Oct 14 09:33:31 2008 +0900
+++ b/rep/handler/REPSessionManagerHandler.java	Tue Oct 14 09:33:31 2008 +0900
@@ -1,7 +1,5 @@
 package rep.handler;
 
-import java.io.IOException;
-
 import rep.Forwarder;
 import rep.REPCommand;
 import rep.Session;
@@ -21,7 +19,7 @@
 		manager.remove(socketChannel);
 	}
 
-	public void handle(REPSelectionKey<REPCommand> key) throws IOException {
+	public void handle(REPSelectionKey<REPCommand> key) throws Exception {
 		/*
 		 * SessionManagerから来たコマンドは、Editor関係のコマンドは、
 		 * sessionとeidを判定して、そのeditorにforwardしてやれば良い。
--- a/rep/xml/SessionXMLDecoder.java	Tue Oct 14 09:33:31 2008 +0900
+++ b/rep/xml/SessionXMLDecoder.java	Tue Oct 14 09:33:31 2008 +0900
@@ -1,14 +1,17 @@
 package rep.xml;
 
+import java.io.IOException;
 import java.io.StringReader;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 
 import rep.Editor;
 import rep.Session;
@@ -16,34 +19,37 @@
 
 public class SessionXMLDecoder {
 
-	public SessionXMLDecoder(String string) {
+	DocumentBuilderFactory factory;
+	DocumentBuilder builder;
+
+	public SessionXMLDecoder(String string) throws SAXException, IOException {
 		decode(string);
 	}
 
 	public SessionXMLDecoder() {
+		factory = DocumentBuilderFactory.newInstance();
+		try {
+			factory.newDocumentBuilder();
+		} catch (ParserConfigurationException e) {
+		}
 	}
 
-	public SessionList decode(String string) {
+	public SessionList decode(String string) throws SAXException, IOException {
 		SessionList sessionlist = null;
 		//System.out.println("");
-		try {
-			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-			DocumentBuilder builder = factory.newDocumentBuilder();
-			InputSource source = new InputSource(new StringReader(string));
-			//source.setEncoding("UTF-8");
-			Document doc = builder.parse(source);
-			Element root = doc.getDocumentElement();
-			
-			//sessionlist = createSessionList(root);
-			sessionlist = generateSessionList(root);
-			sessionlist.setMaxHost(getSessionManagerHost(root));
-			
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
+		InputSource source = new InputSource(new StringReader(string));
+		//source.setEncoding("UTF-8");
+		Document doc = builder.parse(source);
+		Element root = doc.getDocumentElement();
+
+		//sessionlist = createSessionList(root);
+		sessionlist = generateSessionList(root);
+		sessionlist.setMaxHost(getSessionManagerHost(root));
+
+
 		return sessionlist;
 	}
-	
+
 	private String getSessionManagerHost(Element root) {
 		NodeList nodelist = root.getChildNodes();
 		String host = null;
--- a/test/XMLTest.java	Tue Oct 14 09:33:31 2008 +0900
+++ b/test/XMLTest.java	Tue Oct 14 09:33:31 2008 +0900
@@ -1,9 +1,5 @@
 package test;
 
-import java.io.IOException;
-
-import org.xml.sax.SAXException;
-
 import rep.Editor;
 import rep.Session;
 import rep.SessionList;