JSON 포맷으로 데이터를 주고 받는 서버나 클라이언트 혹은 앱을 개발하다 보면, 보내고 받은 데이터의 포맷이 맞는지 그리고 받은 데이터를 디버깅하기 위해서 포맷팅을 해서 가독성있게 바꾸는 작업을 빈번하게 하게 됩니다.. 이 때, 프로그램상에서 로그나 콘솔에 포맷팅을 해서 가독성있게 보여줄 수 있겠지만, 여간 불편한게 아니죠.. 

보통, 웹 서버를 통해서 JSON 데이터를 받게되면, 스트림으로 주~욱 받게 됩니다.. 그러면, byte[]로 받아서 String으로 변환을 해서 포맷팅을 하든, 아파치 HTTPClient같은 넘을 사용해서 결과로 String을 받아오든지 합니다..

결국, 다시 한번 String을 포맷팅을 해야 가독성이 생기게 됩니다.. 그래서, 받은 String 데이터를 Validate와 Formatting을 해주는 사이트를 찾아서 받은 String 데이터를 넣어서 포맷팅된 JSON으로 보게 되네요..

그래서, 유용한 사이트를 몇개 정리해 봅니다..

1. http://www.freeformatter.com/
 지원하는 Formatter와 Validator는 아래와 같이 매우 다양합니다.. 매우 다양한 포맷을 지원하기 때문에 개발하면서 매우 유용한 사이트가 될 것 같습니다..
 - JSON Formatter & Validator :

 - HTML Formatter & Validator :
 - XML Formatter :
 - SQL Formatter :
 - String Escaper :
 - Url Encoder / Url Decoder :
 - Base 64 Encoder / Base 64 Decoder :
 - JavaScript Minifier - Online YUI Compressor for JavaScript :
 - CSS Minifier - Online YUI Compressor for CSS : 
 - Message Digest : 

2. http://jsonlint.com/
 JSON Formatter와 Validator로 가장 유명할 것으로 생각이 드는 사이트 입니다..
 
3. http://jsonformat.com/
 JSON Formatter와 Validator를 지원하고 있고, 추가적으로 HTML Formatter도 지원하고 있네요.. 

4. http://jsonformatter.curiousconcept.com/
 JSON Formatter와 Validator를 지원합니다.. 


위의 사이트중 한개만 즐겨찾기 해 놓으면, JSON 포맷 기반의 프로젝트 하기에 편할 것으로 생각이 듭니다..
저작자 표시
안드로이드 프로그래밍을 하다보니..
XML로 UI를 설정하는데, 속성이 너무많아서 보기 쉽지 않네요.. ^^;;

보통 Source -> Format으로 코드의 indent를 맞췄는데..
XML은 바로 아래 Source -> Format Active Elements 가 있네요..

하지만, Source -> Format Active Elements 하면 아래와 같이 바뀌네요..

<TextView android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:text="텍스트 수정 " />

그래서, 한줄로 맞춰보는걸 찾아보니...

Preference -> XML-> XML Files -> Editor -> Formatting 에서..
Split multiple attributes each on a new line 을 선택하면 되네요.. ^^

다시, Source -> Format Active Elements 하면 아래와 같이 바뀌네요..
만족스럽습니다.. ^^

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="텍스트 수정 " />


저작자 표시
restfb 라이브러리가 로그를 log4j에서 java.util.logging 패키지로 바꿨네요.. ^^;;
log4j에 대한 의존을 하지 않아서 깔끔하긴 한데.. 모랄까.. 실제적(?)이지 않다고 해야 하나?? 

restfb에서 log를 console에 찍히지 않게 하려면 아래의 logging.properties 파일을 만들고 java를 실행할 때, 옵션으로 설정파일을 읽어주면 됩니다.  

ex) java -Djava.util.logging.config.file=./conf/logging.properties -Xms128m -Xmx1024m -server -jar xxx-xxx-server.jar

logging.properties
############################################################
# logging.properties
# usage : java -Djava.util.logging.config.file=logging.properties
############################################################

handlers = java.util.logging.FileHandler, java.util.logging.ConsoleHandler
.level= ALL
########### level ##########
# SEVERE
# WARNING
# INFO
# CONFIG
# FINE
# FINER
# FINEST (최저치)
#############################
 
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

# default file output is in user's home directory.
java.util.logging.ConsoleHandler.level = WARNING
java.util.logging.FileHandler.pattern = /var/justin/mywho-livefeed-qserver/restfb_%u.log
# 10240000 == 10M, 102400000 == 100M, 1024000000 == 1G  
java.util.logging.FileHandler.limit = 1024000000
java.util.logging.FileHandler.count = 5
java.util.logging.FileHandler.append = true
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

# Limit the message that are printed on the console to INFO and above.
java.util.logging.ConsoleHandler.level = SEVERE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################
com.restfb = INFO
저작자 표시
eclipse에서 xml, 기본 에디터로 다루기 참 불편하죠..
그래서, xml이나 다른 포맷들을 지원하는 editor가 별도로 존재하구요.. ^^
xml을 다루기 위해서 사용하는 에디터로 eclipse에서 plug-in해서 사용할 수 있는 넘으로 Rinzo XML Editor를 추천합니다. element action, validation, autocompletion, xpath view 기능등을 지원하는데 아주 좋네요.. ^^

아래는 사이트에 있는 xpath viewer screenshot 입니다..
저작자 표시
자바로 프로젝트를 하다보면, 몇개의 라이브러리는 기본적으로 사용을 합니다.
좀 큰 프로젝트를 하다보면, 적게는 10개이상의 라이브러리를 사용할 텐데요.. 빌드를 하면서 의존 라이브러리를 일일히 manifest 파일에 기입을 해 주기는 매우 불편한 일이 되겠죠..
하지만, lib 폴더의 jar파일을 동적으로 로딩해서 jar로 배포할 때 넣어주면, 위 불편함이 순식간에 가시겠죵??ㅋㅋ

사용방법은 아래처럼 사용하면 됩니다.
<attribute name="Class-Path" value="lib/ conf/ ${lib-manifest-path}" />

아래 코드를 build.xml에 넣으시면 됩니다.
    <target name="gen-manifest" description="Generate CLASSPATH to use in manifest">
        <pathconvert dirsep='${file.separator}' property="full-lib-dir">
            <path>
                 <pathelement path="lib"/>
            </path>
        </pathconvert>

        <echo>full-lib-dir: ${full-lib-dir}</echo>

        <pathconvert pathsep=" " dirsep="/" property="manifest-path">
            <path>
                <fileset dir="lib" includes="*"/>
            </path>
            <map from="${full-lib-dir}${file.separator}" to=""/>
        </pathconvert>

        <echo>manifest-path: ${manifest-path}</echo>
       
        <pathconvert pathsep=" " dirsep="/" property="lib-manifest-path">
            <path>
                <fileset dir="lib" includes="*"/>
            </path>
            <map from="${full-lib-dir}${file.separator}" to="lib/"/>
        </pathconvert>

        <echo>lib-manifest-path: ${lib-manifest-path}</echo>
    </target>

위 코드는 아래 링크에서 가져왔습니다. 너무 감사드립니다.. ^^

Ant: construct manifest classpath 


저작자 표시
웹에 데이타를 전송해 주기 위해서, 데이타를 캐시하고 있는 서버에서 데이타를 json 포맷으로 가지고 있습니다.
라이브러리는 google-gson을 사용합니다..  json simple이나 jacson json processor에 비해서 속도는 뒤 떨어지지만, library의 사용성(?), 편리함(?) 때문에 사용을 하고 있습니다.. 데이타 저장을 위해서 json 포맷이다 보니, character set에 따라 크기, 즉 메모리나 데이타의 전송량이 달라지기 때문에, utf-8로 인코딩을 하고 byte[]의 길이를 체크해 보니.. 사이즈가 똑 같네요.. ^^;;
흠.. 소스 뒤져보니, utf-8로 인코딩을 하네요.. ㅋㅋ

http://code.google.com/p/google-gson/
http://google-gson.googlecode.com/svn/tags/1.5/docs/javadocs/index.html
http://sites.google.com/site/gson/gson-user-guide

저작자 표시
ROME Library는..
ROME is an set of open source Java tools for parsing, generating and publishing RSS and Atom feeds. The core ROME library depends only on the JDOM XML parser and supports parsing, generating and converting all of the popular RSS and Atom formats including RSS 0.90, RSS 0.91 Netscape, RSS 0.91 Userland, RSS 0.92, RSS 0.93, RSS 0.94, RSS 1.0, RSS 2.0, Atom 0.3, and Atom 1.0. You can parse to an RSS object model, an Atom object model or an abstract SyndFeed model that can model either family of formats.
아래는 ROME Library를 이요한 예제 코드입니다.

import java.net.URL;
import java.util.Date;
import java.util.List;

import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;

public class RssAtomTest {
    private static String url ="http://www.sjava.net/rss";
    /**
     * @param args
     */
    public static void main(String[] args) throws Exception {
       
        URL feedUrl = new URL(url);
        SyndFeedInput input = new SyndFeedInput();
        SyndFeed syndFeed = input.build(new XmlReader(feedUrl));
               
        System.out.println("----------------------- title ------------------------------");
        System.out.println(syndFeed.getTitle());
        System.out.println("-------------------------------------------------------------");
        System.out.println("-----------------  updatedAt -------------------------");
        System.out.println(syndFeed.getPublishedDate() );
        System.out.println("-------------------------------------------------------------");
       
        @SuppressWarnings("unchecked")
        List<SyndEntry> entries = syndFeed.getEntries();       
        SyndEntry entry = null;
           
        for(int i = 0; i < entries.size(); i++) {
            entry = entries.get(i);
           
            String title = entry.getTitle();
            String url = entry.getUri();
            String content = entry.getDescription().getValue();
            Date updatedAt = entry.getUpdatedDate();
            if(updatedAt == null)
                updatedAt = entry.getPublishedDate();
                           
            System.out.println("-----------------------------------------------"+i+"-----------------------------------------------------------------");
            System.out.println("title : " + title);
            System.out.println("------------------------------------------------------------------------------------------------------------------");
            System.out.println("url : " + url);
            System.out.println("------------------------------------------------------------------------------------------------------------------");
            System.out.println("data : "+ content);
            System.out.println("------------------------------------------------------------------------------------------------------------------");
            System.out.println("date : " + updatedAt.getTime());
            System.out.println("------------------------------------------------------------------------------------------------------------------");
        }       
    }

}

저작자 표시
헐.. 여태껏 이걸 모르고 있었네요.. ^^;;
저는 여태.. 클래스의 toString()를 Overriding 하면서, 일일이 손으로 아래와 같은 작업을 진행했습니다.
1. @Override 붙이기
2. 클래스의 property 값을 toString() 안에 기술하기..

지금은 eclipse editor에서 source->Generate toString()..를 통해서 위 과정이 쉽게 자동화 되네요.
eclipse를 사용하면서, 조금만 주의깊게 사용했으면, 개발 생산성이 20%증가했었을 텐데요..
아마도, Generate Getter/Setter에 너무 감명을 받아서 다른 건 눈에 안 들어온 거 같기도 하구요..

ㅜㅜ

이클립스 만쉐!!!!
저작자 표시
다국어를 쉽게 지원 할 수 있도록 지원하는 플러그인 입니다.
http://sourceforge.net/projects/eclipse-rbe/


저작자 표시

Hex Editor XVI32

from Tools 2010/07/22 17:59
무료의 헥사 에디터 입니다. 직관적이고 쉽네요.. ^^
배포버전은 http://www.chmaas.handshake.de/ 사이트에서 다운로드 받으세요.. ^^



저작자 표시

'Tools' 카테고리의 다른 글

eclipse에서 toString()을 자동으로 해 주네요.. ^^;;  (0) 2010/10/25
eclipse에서 다국어를 쉽게 지원하기..  (0) 2010/08/19
Hex Editor XVI32  (0) 2010/07/22
text 원하는 용량으로 잘라주기  (0) 2010/07/20
HTTP4e Rest Client  (0) 2010/07/15
Tag // hex editor, XVI32
어디서 받았는지는 기억도 없고.. 컴터 정리하다보니 눈길을 끌어서 저장해 봅니다. ^^
윈도용 입니다...

저작자 표시

'Tools' 카테고리의 다른 글

eclipse에서 다국어를 쉽게 지원하기..  (0) 2010/08/19
Hex Editor XVI32  (0) 2010/07/22
text 원하는 용량으로 잘라주기  (0) 2010/07/20
HTTP4e Rest Client  (0) 2010/07/15
rest framework 종류들..  (0) 2010/07/14

HTTP4e Rest Client

from Tools 2010/07/15 17:21
오..
지금 회사에서 인턴을 통해서 개발하려고 했던 테스팅 프레임웍의 형태를 플러그인으로 구현을 해 놨네요..
HTTP4e Rest Client
아래는 HTTP4e 웹 사이트에 있는 내용입니다.
좋네요. ^^

About

Eclipse HTTP Client (HTTP4e)  is an Eclipse plugin for making HTTP and RESTful calls. Build with user experience in mind, it simplifies the developer/QA job of testing Web Services, REST, JSON and HTTP. It is a useful tool for your daily job of  HTTP header tampering and hacking.

Features:

  • Making/Replaying an HTTP call directly from Eclipse IDE
  • Visual Editors for HTTP headers, parameters and body
  • Tabbed browsing (allowing replaying different RESTful, HTTP calls on separate tabs)
  • History support (persisting your valuable REST calls)
  • One-click  HTTP code generation to Java, PHP, C#, Flex/ActionScript, Cocoa/Objective-C, Ruby, Python and Visual Basic
  • One-click JMeter script generation
  • Import and export HTTP4e replay script
  • Export HTTP sessions as HTML report
  • Import raw HTTP packets and Firefox’s Live HTTP headers
  • Aesthetic UI, Code assist, Headers auto-suggest, Syntax coloring
  • “Raw”, “Pretty”, “Hex”, “Browser” and “JSON” views
  • Proxy Configuration
  • BASIC and DIGEST Authentication
  • SSL/HTTPS support
  • Unicode UTF8 support
  • HTTP tampering
  • Available on Windows, MacOS X, Linux, Solaris

저작자 표시

'Tools' 카테고리의 다른 글

Hex Editor XVI32  (0) 2010/07/22
text 원하는 용량으로 잘라주기  (0) 2010/07/20
HTTP4e Rest Client  (0) 2010/07/15
rest framework 종류들..  (0) 2010/07/14
web framework 종류들..  (0) 2010/07/14

rest framework 종류들..

from Tools 2010/07/14 16:08
rest 기반의 웹 서비스를 쉽게 만들기 위한 framework 도입을 위해서 대충 알아보니, 아래와 같은 framework들이 존재하네요.. 흠, 몰 써야 할까요?? 모르겠넹.. ^^;;

* Restlet is a lightweight REST framework for Java

* Jersey is the open source (under dual CDDL+GPL license), production quality, JAX-RS  (JSR 311) Reference Implementation for building RESTful Web services. But, it is also more than the Reference Implementation. Jersey provides an API  so that developers may extend Jersey to suite their needs.

* JAX-RS: CXF has an implementation of JAX-RS 1.0 (JSR-311): Java API for RESTful Web Services. This provides a more standard way to build RESTful services in JAVA.

JBoss RESTEasy is a JBoss project that provides various frameworks to help you build RESTful Web Services and RESTful Java applications. It strives to be standards based wherever possible, but to also innovate when appropriate.
저작자 표시

'Tools' 카테고리의 다른 글

text 원하는 용량으로 잘라주기  (0) 2010/07/20
HTTP4e Rest Client  (0) 2010/07/15
rest framework 종류들..  (0) 2010/07/14
web framework 종류들..  (0) 2010/07/14
Java Code Coverage Tool  (0) 2010/07/12

web framework 종류들..

from Tools 2010/07/14 15:46
위키에 언어별 web framework에 대한 내용에 대한 정리가 잘 되어 있습니다.
위 링크의 내용에서, 자바로 개발된 framework들에 대한 내용은 아래와 같습니다.
Apache 프로젝트의 프레임웍들이 많네요.. ^^

Project Current Stable Version Release Date License
Apache Click 2.1.0
Apache
Apache Cocoon 2.2.0
Apache
Apache Struts 2.1.8.1
Apache
Apache Wicket 1.4.5 2009-12-16 Apache
AppFuse 2.0.2
Apache
Aranea 1.0.10
Apache
Eclipse RAP 1.2.0
Eclipse Public License
FormEngine 1.6.2
MIT
Google Web Toolkit 2.0
Apache
Hamlets 1.6 2010-01-29 BSD
HybridJava 1.01 2010-05-16 Registration
IT Mill Toolkit 5.4.0
Apache
ItsNat

AGPL / Proprietary
JavaServer Faces 2.0

JBoss Seam 2.2.0 GA
LGPL
ManyDesigns Portofino 3.1.0
GPL v3
OpenLaszlo 4.1
Common Public License
OpenXava 3.1
LGPL
pirka 1.0.4

Play 1.0.3
Apache
RIFE 1.6.2
Apache
Shale 1.0.4
Apache
Sling

Apache 2.0
SmartClient

LGPL
Sofia 2.3
GPL
Spring 3.0.0
Apache
Stripes 1.5.3
Apache
Tapestry 4.1.6/5.1.0.5
Apache
ThinWire 1.2
GPL
Vaadin 6.3.0
Apache
WebObjects 5.4.3
Proprietary
WebWork 2.2.6
Apache
ZK 5.0
LGPL
ztemplates 0.9.9.6
Apache
그리고, 10 Best Java Web Development Framework에 대한 내용도 좋네요.. ^^
저작자 표시

'Tools' 카테고리의 다른 글

HTTP4e Rest Client  (0) 2010/07/15
rest framework 종류들..  (0) 2010/07/14
web framework 종류들..  (0) 2010/07/14
Java Code Coverage Tool  (0) 2010/07/12
repcached - add data replication feature to memcached 1.2.x  (0) 2010/07/06

Java Code Coverage Tool

from Tools 2010/07/12 11:13
코드를 개발하고 테스트를 하기 위해서 보통 xUnit 시리즈의 프레임웍을 많이 이용하고 있습니다..
추가로 테스트를 완료하고, 테스트한 범위가 개발한 코드의 몇 %를 했는지에 대한 척도도 매우 중요하겠지요.. 
Test Coverage 혹은 Code Coverage 라고 일컫는데요.. 
자바에서 Code를 테스트한 후에, 테스트한 범위(Coverage)에 대한 리포팅을 해주는 툴이 바로 Coverage Tool 인데요.. 
아래는 2개의 Coverage Tool에 대한 소개입니다. 

1. EclEmma(http://eclemma.org/)
EclEmma is a free Java code coverage tool for Eclipse, available under the Eclipse Public License.

EclEmma는 eclipse에서 plug-in 해서 버튼 실행으로도 쉽게 사용할 수 있고, JaCoCo Library를 다운로드 받아서 Ant로 리포팅(http://www.eclemma.org/jacoco/trunk/doc/ant.html)을 받을 수 있네요.. 라이브러리 보다는 어플리케이션에서 쉽게 사용하고 바이너리를 내보낼때 좋을듯 하네요..

2. Cobertura(http://cobertura.sourceforge.net/)
Cobertura is a free Java tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage. It is based on jcoverage.

Ant로 테스트를 해서 javadoc과 같은 report를 해주네요..
라이브러리는 Cobertura가 더 보기 좋게 리포팅을 하는 듯 합니다. 예제 : http://cobertura.sourceforge.net/sample/
저작자 표시

'Tools' 카테고리의 다른 글

rest framework 종류들..  (0) 2010/07/14
web framework 종류들..  (0) 2010/07/14
Java Code Coverage Tool  (0) 2010/07/12
repcached - add data replication feature to memcached 1.2.x  (0) 2010/07/06
CI(Continuous Integration) Feature Matrix  (0) 2010/07/05
서버/인프라를 지탱하는 기술이라는 책을 읽다 보니, 374 페이지에 memcached를 복제해서 다중화를 지원하는 repcached에 대한 내용이 나오네요..
흠.. memcached는 다중화 이슈로 고민이 많이 되는 캐시서버였는데, 고민을 한방에 훅 날려주네요..

* http://repcached.lab.klab.org/
* http://tinywolf.tistory.com/88/
* http://kerberosj.tistory.com/48/
* http://mix1009.net/entry/repcached-memcached-replication/

저작자 표시
CI를 지원하는 툴에 대해서 살펴보니, 오픈소스 그리고 상용으로 팔고 있는 툴이 상당히 많이 존재하더군요...
대표적으로 ThoughtWorks의 CruiseControl과 Hudson은 익히 많이 알려져 있는듯 하지만, 다른 툴들은 자세한 정보가 없어서 다른 툴도 고민을 해 봐야 하나 하고 있던차에..
ThoughtWorks의 위키에서 CI Feature Matrix 페이지를 봤습니다.. 오~~ 최고... ^^
아래는 CI툴에 대한 정리된 비교 분석 내용입니다.

* ThoughtWorks의 CI Feature Matrix
* Comparing TWO continuous build tools: Cruise Control and Hudson
* Choosing continuous integration (CI) tool. Comparison : CruiseControl, Hudson, Continuum vs. TeamCity

혹시 몰라서 CI Feature Matrix를 mht 포맷으로 저장해서 첨부하였습니다.

저작자 표시
MS에서 제공하는 JDBC Type 4 드라이버인 sqljdbc4.jar를 통해서 DB에 연결하기 위한 내용입니다.
아래는 mssql 2008의 db에 접근하기 위한 connection url string 입니다..
MS의 jdbc사용에 대한 내용은 http://msdn.microsoft.com/en-us/library/ms378526.aspx 에서 참고하시면 됩니다. 그리고, 아래의 4147포트는 SqlServer Configuration Manager를 통해서 TCP/IP 프로토콜에 할당된 포드입니다.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connUrl = "jdbc:sqlserver://HOST\\SQLEXPRESS:4147;databaseName=testdb;integratedSecurity=true;";
Connection connection = DriverManager.getConnection(connUrl, "id", "pw");
저작자 표시
아융..
DB 연결하기 위해서 Connection Url 세팅하는게 은근히 짜증나네요.. ^^;;
아래는 mssql 2008의 db에 접근하기 위한 connection url string 입니다..
그리고, 아래의 4147포트는 SqlServer Configuration Manager를 통해서 TCP/IP 프로토콜에 할당된 포드입니다.

Class.forName("net.sourceforge.jtds.jdbc.Driver");
String connUrl = "jdbc:sqlserver://HOST\\SQLEXPRESS:4147;databaseName=testdb;integratedSecurity=true;";
Connection connection = DriverManager.getConnection(connUrl, "id", "pw");
저작자 표시
Apache Ant 프로젝트의 서브 프로젝트로 Ivy 프로젝트(http://ant.apache.org/ivy/)가 있습니다.
 Ivy is a tool for managing (recording, tracking, resolving and reporting) project dependencies.
아래의 IvyTest 클래스, ivy.xml을 만들고 build.xml파일에서 resolve target을 실행하게 아래와 같은 결과를 얻을 수 있습니다.

IvyTest.java
package dev;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.lang.WordUtils;

import static java.lang.System.out;

public class IvyTest {

    /**
     * @param args
     */
    public static void main(String[] args) {
        try {
            Option msg = OptionBuilder.withArgName("msg").hasArg().withDescription("the message to capitalize").create("message");
           
            Options options = new Options();
            options.addOption(msg);
   
            CommandLineParser parser = new GnuParser();
            CommandLine line = parser.parse(options, args);
   
            String  message = line.getOptionValue("message", "default message");
            out.println("standard message : " + message);
            out.println("capitalized by " + WordUtils.class.getName() + " : " + WordUtils.capitalizeFully(message));
           
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
}


build.xml
<?xml version="1.0"?>
<project name="ivy-test" default="resolve" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
    <property name="project.name" value="ivy-test" />
     <property name="project.version" value="1.0.0" />
     <property name="project.owner" value="mcsong@gmail.com" />
   
    <!-- src -->
    <property name="src.dir" value="src" />
    <property name="src.main.dir" value="src/main" />
    <property name="src.test.dir" value="src/test" />
   
    <!-- build -->
    <property name="build.dir" value="build" />
    <property name="build.main.classes" value="${build.dir}/classes/main" />
    <property name="build.test.classes" value="${build.dir}/classes/test" />
   
    <!-- lib -->
    <property name="lib.dir" value="lib" />
    <property name="lib.ext.dir" value="lib-ext" />
   
    <!-- dist -->
    <property name="dist.dir" value="dist" />
   
    <!-- doc -->
    <property name="doc.dir" value="doc" />
   
    <!-- ivy -->
    <property name="ivy.install.version" value="2.1.0" />
    <property name="ivy.dir" value="ivy" />
    <property name="ivy.jar.file" value="${lib.dir}/ivy-2.1.0.jar" />
   
    <!-- test -->
    <property name="test.dir" value="test" />
   
    <tstamp>
        <format property="time" pattern="yyyyMMdd" />
    </tstamp>
   
    <!-- setting class path -->
    <path id="class.path">
        <pathelement location="${build.main.classes}"/>
        <pathelement location="${build.test.classes}"/>
        <pathelement location="${dist.dir}"/>
        <pathelement location="${lib.dir}"/>
 
        <pathelement location="${lib.dir}/junit.jar"/>
        <pathelement location="${lib.dir}/commons-cli-1.2.jar"/>
        <pathelement location="${lib.dir}/commons-lang-2.5.jar"/>
        <pathelement location="${lib.dir}/ivy-2.1.0.jar"/>
        <pathelement location="${ant.home}/lib"/>
    </path>   
   
    <!-- initialize -->
    <target name="init" description="--> create directories">
        <echo>init target started</echo>
        <mkdir dir="${doc.dir}"/>
        <mkdir dir="${build.dir}"/>
        <mkdir dir="${build.main.classes}"/>
        <mkdir dir="${build.test.classes}"/>
        <mkdir dir="${test.dir}"/>
        <!--mkdir dir="${test.result.dir}"/>
        <mkdir dir="${test.report.dir}"/-->
        <mkdir dir="${dist.dir}"/>
        <echo>init target completed</echo>
    </target>       
   
    <!-- clean -->
    <target name="clean" description="--> clean created directories">
        <echo>clean target started</echo>       
        <delete dir="${doc.dir}" />
        <delete dir="${build.dir}"/>
        <delete dir="${build.main.classes}"/>
        <delete dir="${build.test.classes}"/>
        <delete dir="${test.dir}"/>
        <!--delete dir="${test.result.dir}"/>
        <delete dir="${test.report.dir}"/-->
        <delete dir="${dist.dir}"/>
        <echo>clean target completed</echo>
    </target>       
   
    <macrodef name="compile_">
        <attribute name="srcdir" />
        <attribute name="destdir" />
        <sequential>
            <javac srcdir="@{srcdir}" destdir="@{destdir}">
                <classpath refid="class.path" />
            </javac>
        </sequential>
    </macrodef>   

       <!-- compile source -->
    <target name="compile" depends="clean, init" description="compile this project">
        <echo>compile target started</echo>
        <compile_ srcdir="${src.main.dir}" destdir="${build.main.classes}" />
        <compile_ srcdir="${src.test.dir}" destdir="${build.test.classes}" />
        <echo>compile target completed</echo>
    </target>   

    <!-- run -->
    <target name="run" depends="compile" description="run the project">
        <echo>run target started</echo>
        <property name="arg.01" value="ivy testing !"/>
        <java classpathref="class.path" classname="dev.IvyTest">
            <arg value="-message"/>
            <arg value="${arg.01}"/>
        </java>
        <echo>run target completed</echo>
    </target>
   
   
    <target name="resolve" depends="init" description="retreive dependencies with ivy">
        <ivy:retrieve />
    </target>       
   
    <target name="report" depends="resolve" description="generates a report of dependencies">
        <ivy:report todir="${build.dir}"/>
    </target>
  
    <target name="clean-cache" description="clean the ivy cache">
        <ivy:cleancache />
    </target>
       
</project>

ivy.xml
<ivy-module version="2.0">
    <info organisation="org.apache" module="hello-ivy"/>
    <dependencies>
        <dependency org="commons-lang" name="commons-lang" rev="2.5"/>
        <dependency org="commons-cli" name="commons-cli" rev="1.2"/>
    </dependencies>
</ivy-module>

결과
Buildfile: C:\dev\works\ivy_test\build.xml
init:
     [echo] init target started
     [echo] init target completed
resolve:
[ivy:retrieve] :: Ivy 2.1.0 - 20090925235825 :: http://ant.apache.org/ivy/ ::
[ivy:retrieve] :: loading settings :: url = jar:file:/C:/Program%20Files/eclipse/plugins/org.apache.ant_1.7.1.v20090120-1145/lib/ivy-2.1.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
[ivy:retrieve] :: resolving dependencies :: org.apache#hello-ivy;working@LENOVO-FAD74E43
[ivy:retrieve]     confs: [default]
[ivy:retrieve]     found commons-lang#commons-lang;2.5 in public
[ivy:retrieve]     found commons-cli#commons-cli;1.2 in public
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.5/commons-lang-2.5-javadoc.jar ...
[ivy:retrieve] ......
[ivy:retrieve] .......
[ivy:retrieve] .....
[ivy:retrieve] ........
[ivy:retrieve] ........
[ivy:retrieve] ..........
[ivy:retrieve] .........
[ivy:retrieve] ....
[ivy:retrieve] ...
[ivy:retrieve] ....
[ivy:retrieve] ......
[ivy:retrieve] .... (1557kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve]     [SUCCESSFUL ] commons-lang#commons-lang;2.5!commons-lang.jar(javadoc) (24578ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.5/commons-lang-2.5-sources.jar ...
[ivy:retrieve] ......
[ivy:retrieve] ...... (357kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve]     [SUCCESSFUL ] commons-lang#commons-lang;2.5!commons-lang.jar(source) (4109ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.5/commons-lang-2.5.jar ...
[ivy:retrieve] ........
[ivy:retrieve] ..... (272kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve]     [SUCCESSFUL ] commons-lang#commons-lang;2.5!commons-lang.jar (5313ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-cli/commons-cli/1.2/commons-cli-1.2-sources.jar ...
[ivy:retrieve] ... (47kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve]     [SUCCESSFUL ] commons-cli#commons-cli;1.2!commons-cli.jar(source) (2203ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-cli/commons-cli/1.2/commons-cli-1.2.jar ...
[ivy:retrieve] ... (40kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve]     [SUCCESSFUL ] commons-cli#commons-cli;1.2!commons-cli.jar (1610ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-cli/commons-cli/1.2/commons-cli-1.2-javadoc.jar ...
[ivy:retrieve] .....
[ivy:retrieve] .. (209kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve]     [SUCCESSFUL ] commons-cli#commons-cli;1.2!commons-cli.jar(javadoc) (3734ms)
[ivy:retrieve] :: resolution report :: resolve 12688ms :: artifacts dl 41562ms
    ---------------------------------------------------------------------
    |                  |            modules            ||   artifacts   |
    |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
    ---------------------------------------------------------------------
    |      default     |   2   |   2   |   2   |   0   ||   6   |   6   |
    ---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: org.apache#hello-ivy
[ivy:retrieve]     confs: [default]
[ivy:retrieve]     4 artifacts copied, 2 already retrieved (2171kB/47ms)
BUILD SUCCESSFUL

위의 내용을 통해서, 프로젝트의 의존성 있는 바이너리들을 쉽게 관리(?) 할 수 있을듯 합니다.
개발팀에서 적용하기에는 좀 귀찮은 작업일듯 하나, 개발팀의 모임인 개발실 급의 규모에서는 적용할 만한 기술인거 같네요..

참고로, Ivy 프로젝트의 설치는 아래와 같습니다.
1. 다운로드
2. ivy-2.1.0.jar를 ${ant.home}/lib에 카피를 합니다.
3. eclipse에서 window --> preference --> ant --> runtime --> classpath의 ant home entries에서 add external jars 버튼을 통해서 ivy-2.1.0.jar를 잡아주면 됩니다. 

위 데이타에 대한 리포팅 결과는 아래의 첨부파일을 참고하세요..

* 참고자료
 - 사람을 위한 자동화: Ivy로 의존성 관리하기
저작자 표시

무료 CAPTCHA 서비스

from Tools 2010/06/16 18:29
무료로 CAPTCHA 서비스를 이용할 수 있는 reCAPTCHA 라는 서비스가 있네요.. ^^
아래 그림과 같은 형태로, 웹에서 회원가입이나 스팸성 기능을 제한하기 위해서 사용하면 될거 같습니다.
http://www.recaptcha.net/resources.html에서 쉽게 사용할 수 있도록 대부분의 환경을 지원하고 있습니다. ^^


저작자 표시

'Tools' 카테고리의 다른 글

jtds를 이용해서 db 연결하기 with mssql 2008  (0) 2010/06/25
eclipse에서 apache ivy로 binary 의존성 확인  (0) 2010/06/22
무료 CAPTCHA 서비스  (0) 2010/06/16
json simple library  (0) 2010/05/18
java c/c++, c# 호출방식  (0) 2010/04/29

json simple library

from Tools 2010/05/18 17:13
헐 좋네용.. ^^
C#은 3.5버전부터 API 수준에서 json 포맷을 지원하니..
자바도 7부터는 지원을 했으면 좋겠네요.. ^^

http://code.google.com/p/json-simple/

'Tools' 카테고리의 다른 글

eclipse에서 apache ivy로 binary 의존성 확인  (0) 2010/06/22
무료 CAPTCHA 서비스  (0) 2010/06/16
json simple library  (0) 2010/05/18
java c/c++, c# 호출방식  (0) 2010/04/29
eclipse에서 java source 보기  (0) 2010/03/16
Tag // json, Library

java c/c++, c# 호출방식

from Tools 2010/04/29 13:36
c/c++ 호출
기본적으로 JNI를 이용해서 호출합니다.
JNI
를 쉽게 사용하기 위한 Wrapper들이 여러 개 존재하고 있습니다.
 -
HawtJNI(http://hawtjni.fusesource.org/documentation/index.html )
 -
JNIWrapper(http://www.teamdev.com/jniwrapper/)
 - 
JNIEasy(http://www.innowhere.com/webapp/index.jsp#st=products.jnieasy )

c# 호출
j-interop (Pure Java – Com Bridge) : http://j-interop.org/ , 라이센스 : LGPL 3.0[1]

java <-> c#
 - Jni4net : http://jni4net.sourceforge.net/ , bridge between Java and .NET (interprocess, fast, object oriented, open-source), 라이선스: opensource, GPL tools and LGPL runtime

using net.sf.jni4net;

public class Program
{
    private static void Main()
    {
        Bridge.CreateJVM(new BridgeSetup());
        java.lang.System.@out.println("Greetings from C# to Java world!");
    }
}


import net.sf.jni4net.Bridge;
import java.io.IOException;
import java.lang.String;

public class Program {
    public static void main(String[] args) throws IOException {
        Bridge.init();
        system.Console.WriteLine("Greetings from Java to .NET world!");
    }
}

 - ikvm.net : http://www.ikvm.net/, jar -> .dll, .dll -> .jar



'Tools' 카테고리의 다른 글

무료 CAPTCHA 서비스  (0) 2010/06/16
json simple library  (0) 2010/05/18
java c/c++, c# 호출방식  (0) 2010/04/29
eclipse에서 java source 보기  (0) 2010/03/16
build.xml refactoring using macrodef tag  (1) 2010/03/15

eclipse에서 java source 보기

from Tools 2010/03/16 16:01
eclipse에서 자바로 개발을 하다보면, 라이브러리나 API대상의 코드를 확인하기 위해서 f3키를 눌려서 확인을 합니다.
특히, java api source를 보기 위해서는 자바 소스를 간단하게 링크만 하면 됩니다.

아래의 이미지처럼, JRE System Library에서 rt.jar의 속성창에서 Java Source Attachment의 Location path에 src의 위치를 확인시켜 주면 소스가 잘 나오네요.. ^^


'Tools' 카테고리의 다른 글

json simple library  (0) 2010/05/18
java c/c++, c# 호출방식  (0) 2010/04/29
eclipse에서 java source 보기  (0) 2010/03/16
build.xml refactoring using macrodef tag  (1) 2010/03/15
staruml  (0) 2010/02/08
Tag // Eclipse, java, rt.jar
The ThoughtWorks Anthology 라는 책의 11 챕터의 빌드 아케텍트인 줄리안 심슨님의 내용은, build.xml 즉, ant 파일이 refactoring에 대한 내용입니다.  그 중에서, <macrodef> 태그를 이용한 build.xml 파일의 리펙토링 예제가 나오는데, 유용할것 같아서 개인적으로 사용하고 있는 dist target에 대해서 리펙토링을 적용해 봤습니다.

기존
<!-- distribute compiled binary to dist folder -->
    <target name="dist" depends="compile" description="distribute library">
        <echo>dist target started</echo>
        <jar destfile="${dist.dir}/${project.name}-${project.version}.jar">
            <fileset dir="${build.main.classes}"></fileset>
           
            <manifest id="MANIFEST.MF">
                 <attribute name="Built-By" value="${user.name}"/>
                 <!--attribute name="Class-Path" value="${class-path}" /-->   
             </manifest>
        </jar>
       
        <copy todir="${dist.dir}">
            <fileset dir="${lib.dir}">
                <exclude name="junit*.jar" />
            </fileset>
        </copy>
       
        <!-- compress binary -->
        <zip destfile="${dist.dir}/${project.name}-${project.version}.zip" >
            <fileset dir="${dist.dir}" includes="**" />
        </zip>
        <echo>dist target completed</echo>
    </target>   

리펙토링된 후
    <macrodef name="dist_jar">
        <sequential>
            <jar destfile="${dist.dir}/${project.name}-${project.version}.jar">
                <fileset dir="${build.main.classes}"></fileset>
                <manifest id="MANIFEST.MF">
                    <attribute name="Built-By" value="${user.name}"/>
                    <!--attribute name="Class-Path" value="${class-path}" /-->   
                </manifest>
            </jar>
        </sequential>
    </macrodef>
   
    <macrodef name="dist_copy">
        <sequential>
            <copy todir="${dist.dir}">
                <fileset dir="${lib.dir}">
                    <exclude name="junit*.jar" />
                </fileset>
            </copy>
        </sequential>
    </macrodef>
   
    <macrodef name="dist_zip">
        <sequential>
            <!-- compress binary -->
            <zip destfile="${dist.dir}/${project.name}-${project.version}.zip" >
                <fileset dir="${dist.dir}" includes="**" />
            </zip>       
        </sequential>
    </macrodef>
   
    <!-- distribute compiled binary to dist folder -->
    <target name="dist" depends="compile" description="distribute library">
        <echo>dist target started</echo>
        <dist_jar />
        <dist_copy />
        <dist_zip />
        <echo>dist target completed</echo>
    </target>   

위 예제처럼, 리펙토링된 내용을 살펴보면, <macrodef>태그를 통해서 기능에 대한 내용을 작게 쪼개서 빼고(<macrodef>) , 사용하는 <target>에서는 필요한 각 기능을 호출하는 템플릿 메쏘드(?)처럼 기술하게 됩니다. 어디서 많이 본 느낌인데.. 위는 기능을 작게 나눠서 메쏘드로 뽑는 extract method 리렉토링 기법과 동일하네요.. 역시 대가들에게서 많은 내용을 배우게 되는것 같습니다. ^^


'Tools' 카테고리의 다른 글

java c/c++, c# 호출방식  (0) 2010/04/29
eclipse에서 java source 보기  (0) 2010/03/16
build.xml refactoring using macrodef tag  (1) 2010/03/15
staruml  (0) 2010/02/08
FindBugs 사용하기..  (0) 2010/02/02
Tag // Ant, Refactoring