미사용 코드, 클래스, 설정 제거
This commit is contained in:
parent
3817c05987
commit
4be1ae4130
@ -30,7 +30,6 @@ dependencies {
|
||||
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.3'
|
||||
compileOnly 'org.projectlombok:lombok'
|
||||
developmentOnly 'org.springframework.boot:spring-boot-devtools'
|
||||
// runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
|
||||
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
|
||||
annotationProcessor 'org.projectlombok:lombok'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
|
||||
@ -25,16 +25,7 @@ public class RunnerConfiguration {
|
||||
System.setProperty("ROOTPATH", serverConfig.getServerRootPath());
|
||||
System.setProperty("DBMS", serverConfig.getString("DB.DBMS"));
|
||||
PropertyLoader.load();
|
||||
// try {
|
||||
// String[] array = serverConfig.getStringArray("test.list");
|
||||
// if (array != null && array.length > 0) {
|
||||
// for (String s : array) {
|
||||
// System.out.println("List : " + s);
|
||||
// }
|
||||
// }
|
||||
// } catch (ConfigurationException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
|
||||
return args -> System.out.println("Runner Bean #1 : " + serverConfig.getServerProperyFile());
|
||||
}
|
||||
|
||||
@ -49,6 +40,7 @@ public class RunnerConfiguration {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return args -> System.out.println("Runner Bean #2");
|
||||
}
|
||||
|
||||
@ -63,6 +55,7 @@ public class RunnerConfiguration {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return args -> System.out.println("Runner Bean #2");
|
||||
}
|
||||
|
||||
@ -77,6 +70,7 @@ public class RunnerConfiguration {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return args -> System.out.println("Runner Bean #2");
|
||||
}
|
||||
|
||||
@ -91,6 +85,7 @@ public class RunnerConfiguration {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return args -> System.out.println("Runner Bean #2");
|
||||
}
|
||||
|
||||
@ -105,6 +100,7 @@ public class RunnerConfiguration {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return args -> System.out.println("Runner Bean #2");
|
||||
}
|
||||
|
||||
@ -118,6 +114,7 @@ public class RunnerConfiguration {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return args -> System.out.println("Runner Bean #2");
|
||||
}
|
||||
|
||||
@ -131,6 +128,7 @@ public class RunnerConfiguration {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return args -> System.out.println("Runner Bean #2");
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,15 +183,6 @@ public class CollectClientService extends Service {
|
||||
this.deliverList = new ArrayList<>();
|
||||
}
|
||||
this.deliverList.add(msgId);
|
||||
// if (this.deliverBuilder == null) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (this.deliverBuilder.isEmpty()) {
|
||||
// this.deliverBuilder.append(msgId);
|
||||
// } else {
|
||||
// this.deliverBuilder.append(",").append(msgId);
|
||||
// }
|
||||
}
|
||||
|
||||
private void messageService() {
|
||||
@ -605,7 +596,6 @@ public class CollectClientService extends Service {
|
||||
|
||||
private void linkCheckService() {
|
||||
if (System.currentTimeMillis() - lastPacketSendTime < Packet.LINK_CHECK_CYCLE) {
|
||||
// saveSystemLog("LinkCheck Is Not");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -1,195 +0,0 @@
|
||||
package com.munjaon.client.server.service;
|
||||
|
||||
import com.munjaon.client.server.packet.Packet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class Server implements Runnable {
|
||||
private InetSocketAddress listenAddress;
|
||||
// 메시지는 개행으로 구분한다.
|
||||
private static char CR = (char) 0x0D;
|
||||
private static char LF = (char) 0x0A;
|
||||
// ip와 port 설정
|
||||
public Server(String address, int port) {
|
||||
listenAddress = new InetSocketAddress(address, port);
|
||||
}
|
||||
// Thread 실행.
|
||||
public void run() {
|
||||
// 셀렉터 설정
|
||||
try (Selector selector = Selector.open()) {
|
||||
// 채널 설정
|
||||
try (ServerSocketChannel serverChannel = ServerSocketChannel.open()) {
|
||||
System.out.println("ServerSocketChannel is open");
|
||||
// non-Blocking 설정
|
||||
serverChannel.configureBlocking(false);
|
||||
System.out.println("serverChannel.configureBlocking(false) >> ");
|
||||
// 서버 ip, port 설정
|
||||
serverChannel.socket().bind(listenAddress);
|
||||
System.out.println("serverChannel.socket().bind(listenAddress) >> ");
|
||||
// 채널에 accept 대기 설정
|
||||
serverChannel.register(selector, SelectionKey.OP_ACCEPT);
|
||||
System.out.println("serverChannel.register(selector, SelectionKey.OP_ACCEPT) >> ");
|
||||
// 셀렉터가 있을 경우.
|
||||
// while (selector.select() > 0) {
|
||||
while (true) {
|
||||
if (selector.select(10000) == 0) {
|
||||
System.out.println("selector.select() == 0");
|
||||
continue;
|
||||
}
|
||||
System.out.println("selector.select() > 0 >> ");
|
||||
// 셀렉터 키 셋를 가져온다.
|
||||
Iterator<SelectionKey> keys = selector.selectedKeys().iterator();
|
||||
// 키가 있으면..
|
||||
while (keys.hasNext()) {
|
||||
SelectionKey key = keys.next();
|
||||
//키 셋에서 제거.
|
||||
keys.remove();
|
||||
if (!key.isValid()) {
|
||||
continue;
|
||||
}
|
||||
// 접속일 경우..
|
||||
if (key.isAcceptable()) {
|
||||
this.accept(selector, key);
|
||||
// 수신일 경우..
|
||||
} else if (key.isReadable()) {
|
||||
this.receive(selector, key);
|
||||
// 발신일 경우..
|
||||
} else if (key.isWritable()) {
|
||||
this.send(selector, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// 접속시 호출 함수..
|
||||
private void accept(Selector selector, SelectionKey key) {
|
||||
try {
|
||||
// 키 채널을 가져온다.
|
||||
ServerSocketChannel serverChannel = (ServerSocketChannel) key.channel();
|
||||
// accept을 해서 Socket 채널을 가져온다.
|
||||
SocketChannel channel = serverChannel.accept();
|
||||
channel.configureBlocking(false);
|
||||
// 소켓 취득
|
||||
Socket socket = channel.socket();
|
||||
SocketAddress remoteAddr = socket.getRemoteSocketAddress();
|
||||
System.out.println("Connected to: " + remoteAddr);
|
||||
// 접속 Socket 단위로 사용되는 Buffer;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("Welcome server!\r\n>");
|
||||
// Socket 채널을 channel에 송신 등록한다
|
||||
channel.register(selector, SelectionKey.OP_WRITE, sb);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// 수신시 호출 함수..
|
||||
private void receive(Selector selector, SelectionKey key) {
|
||||
try {
|
||||
// 키 채널을 가져온다.
|
||||
SocketChannel channel = (SocketChannel) key.channel();
|
||||
// 연결이 끊겼는지 확인
|
||||
if ((channel.isConnected() || channel.isOpen()) == false) {
|
||||
System.out.println("java connection reset by client: ");
|
||||
// 키 닫기
|
||||
key.cancel();
|
||||
// 소켓 채널 닫기
|
||||
channel.close();
|
||||
// 종료
|
||||
return;
|
||||
}
|
||||
// 채널 Non-blocking 설정
|
||||
channel.configureBlocking(false);
|
||||
// 소켓 취득
|
||||
Socket socket = channel.socket();
|
||||
// Byte 버퍼 생성
|
||||
ByteBuffer buffer = ByteBuffer.allocate(1024);
|
||||
// ***데이터 수신***
|
||||
int size = channel.read(buffer);
|
||||
// 수신 크기가 없으면 소켓 접속 종료.
|
||||
if (size == -1) {
|
||||
SocketAddress remoteAddr = socket.getRemoteSocketAddress();
|
||||
System.out.println("Connection closed by client: " + remoteAddr);
|
||||
// 소켓 채널 닫기
|
||||
channel.close();
|
||||
// 소켓 닫기
|
||||
socket.close();
|
||||
// 키 닫기
|
||||
key.attach(null);
|
||||
key.cancel();
|
||||
return;
|
||||
}
|
||||
// ByteBuffer -> byte[]
|
||||
byte[] data = new byte[size];
|
||||
System.arraycopy(buffer.array(), 0, data, 0, size);
|
||||
// StringBuffer 취득
|
||||
StringBuffer sb = (StringBuffer) key.attachment();
|
||||
// 버퍼에 수신된 데이터 추가
|
||||
sb.append(new String(data));
|
||||
// 데이터 끝이 개행 일 경우.
|
||||
if (sb.length() > 2 && sb.charAt(sb.length() - 2) == CR && sb.charAt(sb.length() - 1) == LF) {
|
||||
// 개행 삭제
|
||||
sb.setLength(sb.length() - 2);
|
||||
// 메시지를 콘솔에 표시한다.
|
||||
String msg = sb.toString();
|
||||
System.out.println(msg);
|
||||
// exit 경우 접속을 종료한다.
|
||||
if ("exit".equals(msg)) {
|
||||
// 소켓 채널 닫기
|
||||
channel.close();
|
||||
// 소켓 닫기
|
||||
socket.close();
|
||||
// 키 닫기
|
||||
key.cancel();
|
||||
return;
|
||||
}
|
||||
// Echo - 메시지> 의 형태로 재 전송.
|
||||
sb.insert(0, "Echo - ");
|
||||
sb.append("\r\n>");
|
||||
// Socket 채널을 channel에 송신 등록한다
|
||||
channel.register(selector, SelectionKey.OP_WRITE, sb);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// 발신시 호출 함수
|
||||
private void send(Selector selector, SelectionKey key) {
|
||||
try {
|
||||
// 키 채널을 가져온다.
|
||||
SocketChannel channel = (SocketChannel) key.channel();
|
||||
// 채널 Non-blocking 설정
|
||||
channel.configureBlocking(false);
|
||||
// StringBuffer 취득
|
||||
StringBuffer sb = (StringBuffer) key.attachment();
|
||||
String data = sb.toString();
|
||||
// StringBuffer 초기화
|
||||
sb.setLength(0);
|
||||
// byte 형식으로 변환
|
||||
ByteBuffer buffer = ByteBuffer.wrap(data.getBytes(Packet.AGENT_CHARACTER_SET));
|
||||
// ***데이터 송신***
|
||||
channel.write(buffer);
|
||||
// Socket 채널을 channel에 수신 등록한다
|
||||
channel.register(selector, SelectionKey.OP_READ, sb);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// 시작 함수
|
||||
public static void main(String[] args) {
|
||||
// 포트는 10000을 Listen한다.
|
||||
Executors.newSingleThreadExecutor().execute(new Server("localhost", 10000));
|
||||
}
|
||||
}
|
||||
@ -1,125 +0,0 @@
|
||||
package com.munjaon.client.util;
|
||||
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.JDOMException;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
import org.jdom2.output.Format;
|
||||
import org.jdom2.output.XMLOutputter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.List;
|
||||
|
||||
public class XmlUtil {
|
||||
// private static Document getDOMParsedDocument(final String fileName) {
|
||||
// Document document = null;
|
||||
// try {
|
||||
//
|
||||
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
// //If want to make namespace aware.
|
||||
// //factory.setNamespaceAware(true);
|
||||
// DocumentBuilder documentBuilder = factory.newDocumentBuilder();
|
||||
// document = documentBuilder.parse(new File("C:\\Docs\\JDS\\ITN\\MMS01Header.xml"));
|
||||
//
|
||||
// NodeList nodeList = document.getDocumentElement().getChildNodes();
|
||||
// for (int i = 0; i < nodeList.getLength(); i++) {
|
||||
// Node node = nodeList.item(i);
|
||||
// if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
// Element elem = (Element) node;
|
||||
// System.out.println("createDate : " + elem.getAttribute("createDate"));
|
||||
// System.out.println("getTagName : " + elem.getTagName());
|
||||
// System.out.println("getNodeName : " + elem.getNodeName());
|
||||
// System.out.println("getTextContent : " + elem.getTextContent());
|
||||
//// String createDate = elem.getElementsByTagName("createDate").item(0).getChildNodes().item(0).getNodeValue();
|
||||
//// System.out.println("createDate : " + createDate);
|
||||
//// String PopCounter = elem.getElementsByTagName("PopCounter").item(0).getChildNodes().item(0).getNodeValue();
|
||||
//// System.out.println("PopCounter : " + PopCounter);
|
||||
//// Double salary = Double.parseDouble(elem.getElementsByTagName("salary").item(0).getChildNodes().item(0).getNodeValue());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (IOException | SAXException | ParserConfigurationException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return document;
|
||||
// }
|
||||
|
||||
private static Document getSaxParsedDocument(final String fileName) {
|
||||
Document document = null;
|
||||
|
||||
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
+ " <catalog>\r\n"
|
||||
+ " <book id=\"bk101\">"
|
||||
+ " <author>Gambardella, Matthew</author> "
|
||||
+ "<title>XML Developer's Guide</title>"
|
||||
+ " <genre>Computer</genre>"
|
||||
+ " <price>44.95</price> "
|
||||
+ "<publish_date>2000-10-01</publish_date> "
|
||||
+ "<description>An in-depth look at creating applications with XML.</description> "
|
||||
+ "</book>"
|
||||
+ " <book id=\"bk102\">"
|
||||
+ " <author>Ralls, Kim</author>"
|
||||
+ " <title>Midnight Rain</title>"
|
||||
+ " <genre>Fantasy</genre>"
|
||||
+ " <price>5.95</price>"
|
||||
+ " <publish_date>2000-12-16</publish_date>"
|
||||
+ " <description>A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.</description>"
|
||||
+ " </book> \r\n"
|
||||
+ "</catalog>\r\n";
|
||||
try {
|
||||
|
||||
SAXBuilder sax = new SAXBuilder();
|
||||
// String that contains XML
|
||||
Document doc = (Document) sax.build(new File("C:\\Docs\\JDS\\ITN\\MMS01Header.xml"));
|
||||
// org.jdom2.Document doc = sax.build(new StringReader(xml));
|
||||
|
||||
Element rootNode = doc.getRootElement();
|
||||
List<Element> bookElements = rootNode.getChildren();
|
||||
System.out.println("bookElements: " + bookElements);
|
||||
for(Element bookElement : bookElements){
|
||||
String name = bookElement.getName();
|
||||
String value = bookElement.getValue();
|
||||
System.out.println(name + " : " + value);
|
||||
}
|
||||
|
||||
} catch (IOException | JDOMException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return document;
|
||||
}
|
||||
|
||||
private static void writeSimpleXml() throws JDOMException, IOException {
|
||||
|
||||
String xml = "<root><child id=\"100\">mkyong</child></root>";
|
||||
SAXBuilder sb = new SAXBuilder();
|
||||
Document doc = sb.build(new StringReader(xml));
|
||||
|
||||
|
||||
Document docFile = new Document();
|
||||
|
||||
Element rootElement = new Element("ReadQueue");
|
||||
rootElement.addContent(new Element("createDate").setText("20240527"));
|
||||
rootElement.addContent(new Element("PopCounter").setText(Integer.toString(0)));
|
||||
|
||||
docFile.setRootElement(rootElement);
|
||||
|
||||
// default in compact mode
|
||||
// XMLOutputter xmlOutputter = new XMLOutputter();
|
||||
|
||||
// pretty print format
|
||||
XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat());
|
||||
|
||||
// output to console
|
||||
FileOutputStream fileOutputStream = new FileOutputStream("C:\\Docs\\JDS\\ITN\\file.xml");
|
||||
xmlOutputter.output(docFile, fileOutputStream);
|
||||
|
||||
}
|
||||
public static void main(String[] args) throws IOException, JDOMException {
|
||||
// XmlUtil.getDOMParsedDocument("C:\\Docs\\JDS\\ITN\\MMS01Header.xml");
|
||||
XmlUtil.getSaxParsedDocument("C:\\Docs\\JDS\\ITN\\MMS01Header.xml");
|
||||
XmlUtil.writeSimpleXml();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user