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>


우분투 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/



우분투에서 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;
}
}

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 라고 나오는데 환경에 따라 위의 사용자 홈 디렉토리에 있음

2014년 3월 29일 토요일

한성노트북 U54X GA630 elementary OS luna에서 무선랜 설정(우분투 12.04)

한성노트북 U54X GA630에 elementary OS luna(우분투 12.04 기반)를 설치하면 무선랜이 잡히지 않는다.
리얼텍 무선랜이 들어가 있는데 우분투 12.04에서 이를 잘 인식하지 못하는듯 하다.
구글링해보면 해당 내용이 많은 걸로 봐선 리눅스와 별로 안친한 놈인것으로 생각됨
(리얼텍의 경우 드라이버를 공개하긴 한데 타 오픈 소스 그룹들에 협력적이지 않은 것 같다)

*드라이버 잡는법
  참고 URL: http://tei827.tistory.com/41
$ sudo apt-get install build-essential linux-headers-generic linux-headers-`uname -r`
$ wget -O- http://dl.dropbox.com/u/57056576/DRIVERS/REALTEK/rtl_92ce_92se_92de_8723ae_linux_mac80211_0006.0514.2012.tar.gz | tar -xz
$ cd rtl_92ce_92se_92de_8723ae_linux_mac80211_0006.0514.2012
$ make
$ sudo make install
$ sudo modprobe rtl8723e