2014년 4월 23일 수요일
2014년 4월 22일 화요일
Java web service framework 비교
Support | Contract | 비고 | |
Apache AXIS2 | first, last | 가장 많이 사용(기준?) Spring framework 적용가능 |
|
Apache CXF | JAX-WS JAX-RS SAAJ Web Services Metadata for the Java Platform |
first, last | 가장 널리 사용되고 있는 추세 (AXIS2에서 CXF로 넘어오는 경우가 많음) AXIS2 보다 사용하기 편리 웹서비스 관련 표준들을 준수 (WSDL 2.0은 아직 지원하지 않음) 최소한의 오버해드로 웹서비스 관련 프레임웍 중 성능이 가장 뛰어남(?) Spring framework 적용가능 전자정부 표준 프레임워크에서 사용 |
Jersey | JAX-RS | ? | |
Spring-WS | JAX-RS | first | JAX-WS 표준을 완벽히 지원하지 않음 JAX-WS 같은 Spring annotation 지원 개발자가 작성해야할 코드가 가장 작음 |
RESTEasy | JAX-RS JAXB |
? | JBoss 프로젝트 Rich set of providers for: XML, JSON, YAML, Fastinfoset, Multipart, XOP, Atom, etc. JAXB marshalling into XML, JSON, Jackson, Fastinfoset, and Atom as well as wrappers for maps, arrays, lists, and sets of JAXB Objects. Gzip content-encoding 지원 |
Restlet | JAX-RS | ? | 경량 REST 프레임워크 Xstream, Jackson을 이용한 XML, JSON marshalling, unmarshalling 지원 FreeMarker, Velocity 통합가능 대용량 멀티파트 데이터 처리를 위해 Apache FileUpload와 통합가능 |
Spring @MVC | N/A | Spring MVC를 이용해서 RESTful 서비스를 구현 https://spring.io/guides/gs/rest-service/ |
* JAX-WS : Java API for XML-Based Web Services (JAX-WS) 2.0 – JSR-224
* JAX-RS : The Java API for RESTful Web Services – JSR-311
* SAAJ : SOAP with Attachments API for Java (SAAJ) – JSR-67
* JAXB : Java Architecture for XML Binding
2014년 4월 5일 토요일
Spring 3.1에서 RequestMapping 리스트 출력하기
/********************************************************************************
EndpointDocController.java
********************************************************************************/
package com.test.spring.controller;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
@Controller
public class EndpointDocController{
@Autowired
private RequestMappingHandlerMapping requestMappingHandlerMapping;
@RequestMapping( value = "/endPoints", method = RequestMethod.GET )
public String getEndPointsInView( Model model )
{
Map<RequestMappingInfo, HandlerMethod> map = requestMappingHandlerMapping.getHandlerMethods();
model.addAttribute( "map", map );
return "tools/endPoints";
}
}
/********************************************************************************
endPoints.jsp
********************************************************************************/
<%@ page session="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head><title>Endpoint list</title></head>
<body>
<table>
<thead>
<tr>
<th>path</th>
<th>methods</th>
<th>consumes</th>
<th>produces</th>
<th>params</th>
<th>headers</th>
<th>custom</th>
</tr>
</thead>
<tbody>
<c:forEach items="${map}" var="obj">
<tr>
<td>${obj}</td>
<td>${obj.key.patternsCondition}</td>
<td>${obj.value}</td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
라벨:
3.1,
list,
RequestMapping,
spring
우분투 13.10 설정
* Sun JDK 설치
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
java -version
* Install Gnome 3.10 in Ubuntu 13.10
http://itsfoss.com/install-gnome-3-ubuntu-1310/
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
java -version
* Install Gnome 3.10 in Ubuntu 13.10
http://itsfoss.com/install-gnome-3-ubuntu-1310/
우분투에서 GIT 설정
$ apt-get install git-core git-doc
$ mkdir /var/lib/git/public
$ cd /var/lib/git/public
$ git init
$ cd /var/lib/git
$ git clone --bare public public.git
$ chmod -R 777 /var/lib/git/public.git
jBoss EAP 6.0에서 SLF4J LogBack 설정하기
jBoss EAP 6.0에서 SLF4J LogBack 설정하기
* jboss.server.base.dir/standalone/configuration/standalone.xml 수정
/********************************************************************************
<subsystem xmlns="urn:jboss:domain:logging:1.1">
<console-handler name="CONSOLE">
<level name="DEBUG"/>
<formatter>
<!--
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
-->
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %s%n"/>
</formatter>
</console-handler>
...
<logger category="com.mydomain">
<level name="DEBUG"/>
</logger>
<root-logger>
<level name="DEBUG"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
</subsystem>
********************************************************************************/
jBoss Log Formatter Syntax
https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Application_Platform/6/html/Administration_and_Configuration_Guide/chap-The_Logging_Subsystem.html#Log_Formatter_Syntax1
%d The current date/time (yyyy-MM-dd HH:mm:ss,SSS form)
%p The level of the log entry (info/debug/etc)
%c The category of the logging event
%t The name of the current thread
%s The simple log message (no exception trace)
%E The exception stack trace (with extended module information)
* pom.xml 수정
/*********************************************************************************
<properties>
<ver.slf4j>1.7.5</ver.slf4j>
<version.logback>1.0.11</version.logback>
</properties>
<dependencies>
...
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${ver.slf4j}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${version.logback}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${version.logback}</version>
</dependency>
...
</dependencies>
********************************************************************************/
* /WEB-INF/jboss-deployment-structure.xml 추가
/********************************************************************************
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
</exclusions>
</deployment>
</jboss-deployment-structure>
********************************************************************************/
* src/main/resources/logback.xml
/********************************************************************************
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!--
<pattern>%d %5p | %t | %-55logger{55} | %m %n</pattern>
-->
<pattern>%5p %logger{5} %m%n</pattern>
</encoder>
</appender>
<logger name="com.mydomain">
<level value="DEBUG" />
</logger>
<root>
<level value="DEBUG" />
<appender-ref ref="CONSOLE" />
</root>
</configuration>
********************************************************************************/
http://logback.qos.ch/manual/layouts.html
apache commons compress 이용한 TAR 생성
package test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateFormatUtils;
public class CommonCompressTest{
/**
* @param args
*/
public static void main(String[] args) throws Exception {
String tarFilename = "c:\\tmp\\" + DateFormatUtils.format(System.currentTimeMillis(), "yyyyMMdd-HHmmss") + "-" + UUID.randomUUID().toString() + ".tar";
String baseDir = "C:\\tmp\\aa";
makeTar(tarFilename, baseDir, true);
}
public static void makeTar(String tarFilename, String baseDir, boolean removeIt) throws Exception {
final OutputStream os = new FileOutputStream(tarFilename);
TarArchiveOutputStream taos = new TarArchiveOutputStream(os);
List<File> fileList = getFileList(baseDir);
for (int ii = 0; ii < fileList.size(); ii++){
File entryFile = fileList.get(ii);
if (entryFile.isDirectory() == true)
continue;
String entryName = StringUtils.substring(entryFile.getAbsolutePath(), baseDir.length());
// System.out.println(entryName);
// System.out.println(entryFile);
TarArchiveEntry entry = new TarArchiveEntry(entryName);
byte[] buff = null;
if (entryFile.isFile()) {
buff = IOUtils.toByteArray(new FileInputStream(entryFile));
entry.setSize(buff.length);
}
taos.putArchiveEntry(entry);
if (entryFile.isFile()) {
taos.write(buff);
}
taos.closeArchiveEntry();
}
// System.out.println(fileList);
taos.close();
os.close();
System.out.println("baseDir=" + baseDir);
if (removeIt == true) {
org.apache.commons.io.FileUtils.deleteQuietly(new File(baseDir));
}
}
public static List<File> getFileList(String baseDir) {
List<File> fileList = new ArrayList<File>();
File root = new File(baseDir);
File[] list = root.listFiles();
for ( File f : list ) {
if ( f.isDirectory() ) {
fileList.add(f);
List<File> subFileList = getFileList(f.getAbsolutePath() );
fileList.addAll(subFileList);
// System.out.println( "Dir:" + f.getAbsoluteFile() );
}
else {
fileList.add(f);
// System.out.println( "File:" + f.getAbsoluteFile() );
}
}
return fileList;
}
}
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateFormatUtils;
public class CommonCompressTest{
/**
* @param args
*/
public static void main(String[] args) throws Exception {
String tarFilename = "c:\\tmp\\" + DateFormatUtils.format(System.currentTimeMillis(), "yyyyMMdd-HHmmss") + "-" + UUID.randomUUID().toString() + ".tar";
String baseDir = "C:\\tmp\\aa";
makeTar(tarFilename, baseDir, true);
}
public static void makeTar(String tarFilename, String baseDir, boolean removeIt) throws Exception {
final OutputStream os = new FileOutputStream(tarFilename);
TarArchiveOutputStream taos = new TarArchiveOutputStream(os);
List<File> fileList = getFileList(baseDir);
for (int ii = 0; ii < fileList.size(); ii++){
File entryFile = fileList.get(ii);
if (entryFile.isDirectory() == true)
continue;
String entryName = StringUtils.substring(entryFile.getAbsolutePath(), baseDir.length());
// System.out.println(entryName);
// System.out.println(entryFile);
TarArchiveEntry entry = new TarArchiveEntry(entryName);
byte[] buff = null;
if (entryFile.isFile()) {
buff = IOUtils.toByteArray(new FileInputStream(entryFile));
entry.setSize(buff.length);
}
taos.putArchiveEntry(entry);
if (entryFile.isFile()) {
taos.write(buff);
}
taos.closeArchiveEntry();
}
// System.out.println(fileList);
taos.close();
os.close();
System.out.println("baseDir=" + baseDir);
if (removeIt == true) {
org.apache.commons.io.FileUtils.deleteQuietly(new File(baseDir));
}
}
public static List<File> getFileList(String baseDir) {
List<File> fileList = new ArrayList<File>();
File root = new File(baseDir);
File[] list = root.listFiles();
for ( File f : list ) {
if ( f.isDirectory() ) {
fileList.add(f);
List<File> subFileList = getFileList(f.getAbsolutePath() );
fileList.addAll(subFileList);
// System.out.println( "Dir:" + f.getAbsoluteFile() );
}
else {
fileList.add(f);
// System.out.println( "File:" + f.getAbsoluteFile() );
}
}
return fileList;
}
}
2014년 4월 2일 수요일
Subversion 계정정보 삭제
* 환경
OS X 10.9.2
STS 3.4.0 (Based on Eclipse 4.3.1)
Subclipse 1.8.x
* Subclipse 설정에 따라 아래 두개 파일중 하나 삭제 (그냥 다 삭제해도 무방한듯..)
~/.eclipse_keyring
~/.subversion/auth
* 구글링 해보면 keyring 파일이 {EcliipseInstallDir}/configuration/org.eclipse.core.runtime/.keyring 라고 나오는데 환경에 따라 위의 사용자 홈 디렉토리에 있음
피드 구독하기:
글 (Atom)