달력

52024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

[jersey] 1.0.2 릴리즈

자바 2009. 3. 1. 22:51
사내 인터페이스 작성을 위해 jersey를 사용하고 있는데 1.0.2 버전이 릴리즈되었습니다.
많은 버그를 수정했고 다음의 개선사항이 있었다고 합니다.

1. The JSON with JAXB "natural" convention
JAXB 모델을 사용해서 JSON 처리를 하거나 JSON을 다시 JAXB모델로 변경하는데 개선사항이 있다는 것으로 보입니다.
2. JSON with padding provider.
JSONP 에 대한 지원이 추가된 것입니다. JSONP 에 대해 검색을 해보니 다음처럼 설명을 하고 있군요.
JSONP(JSON with Padding)는 "Dynamic Script Tags" 혹은 "On Demend Javascript" 라고 불리는 기술을 이용하여 다른 웹사이트로 HTTP 요청을 보내고 자바스크립트 콜백 함수를 통해 실행결과를 통보 받는 방식으로 수행되는 JSON 기반 RPC 규약입니다. 이렇게 하면 브라우저의 보안 정책인 “Same Origin Policy” 제약을 넘어서서 원격 서버와의 통신이 가능해지는데, 야후의 일부 API들, 그리고 최근 개선된 Google Calendar API 등이 이미 이러한 방식을 사용하고 있습니다.
3. Resource method specific filters.
4. Atom Abdera support.
아파치의 atom 구현체인 Apache Abdera 프로젝트의 Atom 엔트리와 Feed 자바타입을 지원
5. Implicit produces.
6. Servlet as a filter.
7. Client using Apache HTTP client.
8. Pavel Bucek has added support for SSL configuration of the Client API when using HttpURLConnection

공부를 게을리 했더니 용어들이 모두 어렵습니다.
일단 내일 라이브러리 업데이트하고 API나 문서를 보면서 실제 내용을 파악해야 할 것으로 보입니다.

좀더 자세한 내용은 http://blogs.sun.com/sandoz/entry/jersey_1_0_2_is 를 참고하시면 됩니다.

'자바' 카테고리의 다른 글

[CI툴] hudson  (0) 2009.04.05
[JSON] Jackson JSON Processor  (0) 2009.03.01
[ibatis] 개발자 가이드 업데이트  (0) 2009.02.28
[ibatis] 메일링리스트를 통해서 본 3.0 소식  (2) 2009.02.15
[자바] 인코딩  (1) 2009.01.30
Posted by fromm0
|
ibatis 개발자 가이드는 ibatis 홈페이지에서도 한글 문서를 배포하고 있지만 수정시 매번 메일로 전달해야 되서 사실상 kldp.net 에서 배포하고 있습니다.
배포 페이지는 다음 링크를 참고하시면 됩니다.

http://kldp.net/frs/?group_id=827&release_id=2208

오늘 일부 내용을 수정했습니다.
내용이 추가되거나 큰 수정이 있었던 것은 아니고 어제 명신님이라는 분으로 부터 피드백 메일이 와서 해당 내용을 반영한 것입니다. 음 이렇게 성함을 밝혀도 되는지 모르겠네요. ^^

수정내용은 8페이지의 maxRequests 에 대한 내용입니다.

1. 원문
Different DBMS have different limits, but no database is without these limits. This should usually be at least 10 times maxTransactions (see below) and should always be greater than both maxSessions and maxTransactions.
 
2. 번역본
다른 DBMS는 다른 제한을 가진다. 이것은 최소한 10개의 maxTransactions이고 언제나 maxSessions과 maxTransactions보다 크다.
 
3. 고친 번역
다른 DBMS는 다른 제한을 가지지만, 이러한 제한이 없는 데이터베이스는 없다. 이러한 제한은 보통 최소한 maxTransaction의 10배이며(아래를 보라) 항상 maxSessions와 maxTransactions보다는 크다.

변명이지만 이 문서 번역은 거의 3년전인가 했던 내용이기도 하고 그 당시에는 번역하는데 미쳐 번역품질에 대해서는 그다지 고민을 못해서 오히려 없는게 나을것 같다고 불평하시는 분이 있을까 고민입니다.
너그럽게 봐주시길 바랍니다. ^^

'자바' 카테고리의 다른 글

[JSON] Jackson JSON Processor  (0) 2009.03.01
[jersey] 1.0.2 릴리즈  (0) 2009.03.01
[ibatis] 메일링리스트를 통해서 본 3.0 소식  (2) 2009.02.15
[자바] 인코딩  (1) 2009.01.30
[eclipse] 2008년 정리  (1) 2009.01.16
Posted by fromm0
|
원래 작년에 베타버전이 릴리즈되어야 할 터였는데.. 아직도 그다지 소식이 없습니다.
간혹 메일링리스트를 통해 한번씩 언급이 되기는 하지만 이 역시 .. 극히 적죠..
메일링리스트를 볼때.. 몇가지는 알수 있을듯 합니다.

▣ iBATIS 2.0
1. 계획했던 모든 기능이 완성되어 있어 더이상의 기능추가는 없다. 단 유지보수및 버그수정을 한 버전은 마이너로 릴리즈될수 있다.


▣ iBATIS 3.0
1. http://opensource.atlassian.com/confluence/oss/display/IBATIS/iBATIS+3.0+Whiteboard 를 통해 3.0에서 구현할 많은 아이디어를 받았는데, 현재 이 화이트보드 페이지는 너무 복잡해서 더이상 보지(?)않는다고 합니다. 하지만 3.0을 구현하기 위한 많은 아이디어는 충분히 모았다고 생각한다네요.
2. 조만간 베타버전을 릴리즈 할 예정이며 소스는 http://svn.apache.org/repos/asf/ibatis/trunk/java/ibatis-3/ 에서 받을수 있습니다.
3. 코어는 이미 완성되어는데, XML은 새로운 형태로 구현되었고 좀더 자세한 정보를 가진다고 합니다.
그외 매핑, 자동매핑, 조인매핑, 캐싱, 트랜잭션 관리, 배치처리, 자동커밋과 그외 최근에 도입된 많은 기술들이 구현되었습니다.
4. 구현이 남아 있는 부분은 다음과 같습니다.
* 인터페이스 바인딩
* 애노테이션으로 설정하기
* 새로운 동적 SQL

이 정도네요..

▣ 메서드명
기존에 2.0 버전은 com.ibatis.sqlmap.client.SqlMapClient 인터페이스의 delete, executeBatch, executeBatchDetailed, insert, queryForList, queryForMap, queryForObject,  queryForPaginatedList, queryWithRowHandler, startBatch, update 가 제공되었습니다만.
3.0에는 org.apache.ibatis.api.SqlSession 인터페이스가 메서드를 제공합니다.


▣ MapperConfig.xml
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE configuration
    PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN"
    "http://ibatis.apache.org/dtd/ibatis-config-3.dtd">

<configuration>

  <properties resource="org/apache/ibatis/parser/mapper.properties">
    <property name="driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
  </properties>

  <settings>
    <setting name="cacheEnabled" value="true"/>
    <setting name="lazyLoadingEnabled" value="true"/>
    <setting name="multipleResultSetsEnabled" value="true"/>
    <setting name="useColumnLabel" value="true"/>
    <setting name="enhancementEnabled" value="false"/>
    <setting name="generatedKeysEnabled" value="false"/>
    <setting name="defaultExecutorType" value="SIMPLE"/>
    <setting name="defaultStatementTimeout" value="25000"/>
  </settings>

  <typeAliases>
    <typeAlias alias="Author" type="domain.blog.Author"/>
  </typeAliases>

  <typeHandlers>
    <typeHandler javaType="String" jdbcType="VARCHAR" handler="org.apache.ibatis.parser.ExampleTypeHandler"/>
  </typeHandlers>

  <objectFactory type="org.apache.ibatis.parser.ExampleObjectFactory">
    <property name="objectFactoryProperty" value="100"/>
  </objectFactory>

  <plugins>
    <plugin interceptor="org.apache.ibatis.parser.ExamplePlugin">
      <property name="pluginProperty" value="100"/>
    </plugin>
  </plugins>

  <environments default="development">
    <environment id="development">
      <transactionManager type="JDBC">
        <property name="" value=""/>
      </transactionManager>
      <dataSource type="UNPOOLED">
        <property name="driver" value="${driver}"/>
        <property name="url" value="${url}"/>
        <property name="username" value="${username}"/>
        <property name="password" value="${password}"/>
      </dataSource>
    </environment>
  </environments>

  <mappers>
    <!-- mapperXML vs. mapperClass-->
    <mapper resource="org/apache/ibatis/parser/AuthorMapper.xml"/>
  </mappers>
</configuration>

▣ 다양한 ResultMap 설정
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE mapper
    PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
    "http://ibatis.apache.org/dtd/ibatis-mapper-3.dtd">

<mapper namespace="com.domain.BlogMapper">

  <resultMap id="blogWithPosts" type="Blog">
    <id property="id" column="id"/>
    <result property="title" column="title"/>
    <association property="author" column="author_id" select="com.domain.AuthorMapper.selectAuthorWithInlineParams"/>
    <collection property="posts" column="id" select="selectPostsForBlog"/>
  </resultMap>

  <resultMap id="joinedPost" type="domain.blog.Post">
    <id property="id" column="post_id"/>
    <result property="subject" column="post_subject"/>
    <association property="author" column="post_author_id" resultMap="joinedAuthor"/>
    <collection property="comments" column="post_id" resultMap="joinedComment"/>
    <collection property="tags" column="post_id" resultMap="joinedTag"/>
    <discriminator javaType="int" column="draft">
      <case value="1" resultMap="draftPost"/>
    </discriminator>
  </resultMap>

  <resultMap id="selectImmutableAuthor" type="domain.blog.ImmutableAuthor">
    <constructor>
      <id column="id" property="id"/>
      <result property="username" column="username"/>
      <result property="password" column="password"/>
      <result property="email" column="email"/>
      <result property="bio" column="bio"/>
      <result property="favouriteSection" column="favourite_section"/>
    </constructor>
  </resultMap>

</mapper>

관련 소식은 http://www.mail-archive.com/user-java@ibatis.apache.org/msg13225.html 에서 다시 확인하실수 있습니다.

'자바' 카테고리의 다른 글

[jersey] 1.0.2 릴리즈  (0) 2009.03.01
[ibatis] 개발자 가이드 업데이트  (0) 2009.02.28
[자바] 인코딩  (1) 2009.01.30
[eclipse] 2008년 정리  (1) 2009.01.16
[groovy] HTTPBuilder module 사용하기  (0) 2009.01.11
Posted by fromm0
|

[자바] 인코딩

자바 2009. 1. 30. 17:13
가장 중요하면서도 가장 무지한 것중에 하나가 인코딩에 관련된 사항입니다.
자바로 6년 가까이 벌어먹고 살면서도 자바가 내부적으로 인코딩을 어떻게 처리하는지 몰랐네요.

한글 위키피디어인 http://ko.wikipedia.org/wiki/UTF-8 에서는. 다음처럼 설명하고 있구요.

자바는 내부적으로 문자열을 UTF-16 인코딩으로 저장하며, 문자열 직렬화를 위하여 UTF-8을 변형하여 사용하고 있다. 이를 변형된 UTF-8이라 부른다.

표준 UTF-8과의 차이는 크게 두 가지로, 한 가지는 U+0000을 1바이트가 아니라 2바이트, 즉 11000000 10000000으로 표현하는 것이다. 따라서 수정된 UTF-8에서는 인코딩된 문자열에 널 문자가 나타나지 않게 되며, 따라서 널 문자를 문자열의 끝으로 사용하는 C와 같은 언어에서 처리할 때 문자열이 잘리는 것을 막을 수 있다.

다른 한 가지 차이는 BMP 바깥의 문자를 인코딩하는 방법이다. 표준 UTF-8에서는 이 문자들은 위와 같이 4바이트로 인코딩되지만, 수정된 UTF-8에서는 이 문자들을 surrogate pair로 표시하여 두 문자로 나눈 뒤 같은 방법으로 인코딩한다. (이는 CESU-8과 동일하다) 이러한 방법은 자바의 문자 형이 16비트 크기이며, 따라서 U+10000 이상의 영역에 속한 유니코드 문자는 항상 두 개의 자바 문자로 표현되어야 한다는 것에서 유래하였다. 하지만 이 방법은 BMP 바깥의 문자를 UTF-8보다 더 긴 6바이트로 인코딩해야 한다.

이러한 차이 때문에 이 인코딩은 UTF-8과 엄격하게 구별해야 하며, 자바에서 내부적인 처리에만 사용하도록 권장된다. 또한 UTF-8과는 달리 IANA에 정식으로 등록된 문자 인코딩이 아니므로 인터넷 상의 정보 교환을 위해 사용하지 않아야 한다.

영문페이지인 http://en.wikipedia.org/wiki/UTF-8 에서는.. 다음처럼 설명하고 있습니다.

The following implementations are slight differences from the UTF-8 specification. They are incompatible with the UTF-8 specification.

[edit] CESU-8

Main article: CESU-8

Many pieces of software added UTF-8 conversions for UCS-2 data and did not alter their UTF-8 conversion when UCS-2 was replaced with the surrogate-pair supporting UTF-16. The result is that each half of a UTF-16 surrogate pair is encoded as its own 3-byte UTF-8 encoding, resulting in 6 bytes rather than 4 for characters outside the Basic Multilingual Plane. Oracle databases use this, as well as Java and Tcl as described below, and probably a great deal of other Windows software where the programmers were unaware of the complexities of UTF-16. Although most usage is by accident, a supposed benefit is that this preserves UTF-16 binary sorting order when CESU-8 is binary sorted.

[edit] Modified UTF-8

In Modified UTF-8 the null character (U+0000) is encoded as 0xc0,0x80 rather than 0x00. (0xc0,0x80 is not valid UTF-8 because it is not the shortest possible representation.) This means that the encoding of an array of Unicode containing the null character will not have a null byte in it, and thus will not be truncated if processed in a language such as C using traditional ASCIIZ string functions.

All known Modified UTF-8 implementations also treat the surrogate pairs as in CESU-8.

In normal usage, the Java programming language supports standard UTF-8 when reading and writing strings through InputStreamReader and OutputStreamWriter. However it uses modified UTF-8 for object serialization, for the Java Native Interface, and for embedding constants in class files. Tcl also uses the same modified UTF-8 as Java for internal representation of Unicode data.

어렵네요. 정리해야 겠습니다.

중요한 건 자바가 내부적으로 UTF-8 이 아닌 변형된 형태로 사용한다는 것이라고 볼수 있겠습니다.
이런 글에 .. 인코딩에 대해 명확하신 분이.. 덧글을 달아주시면 좋겠네요.
Posted by fromm0
|

[eclipse] 2008년 정리

자바 2009. 1. 16. 13:52
2009년도 어느덧 보름이나 지났습니다.
eclipse프로젝트에서 2008년을 빛낸 사람과 관련 툴등에 대한 설문조사가 있었던 듯 합니다.
결과는 크게 사람에 대한 부분과 기술에 대한 부분으로 나누어 발표되었습니다.

일부만 공개된 것으로 보이며 일단 공개된 부분은
사람쪽은
  1. Top Ambassador
  2. Top Committer
  3. Top Contributor
  4. Top Newcomer Evangelist 
기술에 대해서는
  1. Best Commerical Eclipse-Based Developer Tool
  2. Best Open Source Eclipse-Based Developer Tool
  3. Best Commercial Equinox Application
  4. Best Commercial RCP Application
  5. Best Open Source RCP Application

기술만 보면 Best Open Source Eclipse-Based Developer Tool 부분에서 EclEmma 와 Spring IDE 가 맞붙은 것으로 보이는데 EclEmma라는 소스커버리지 툴이 이겼습니다.
RCP라던가 다른 부분에 대해서는 개인적으로 알지 못해.. 뭐라고 하기가 어렵네요.

관련 페이지는
http://www.eclipse.org/org/foundation/eclipseawards/index.php
http://www.eclipse.org/org/foundation/eclipseawards/winners08.php
http://www.eclipse.org/org/foundation/eclipseawards/technology_nominations.php <- 이건 아직 페이지가 만들어지지 않았나 봅니다.
Posted by fromm0
|
앞서 "[생각] 자바는 참 어려운 언어.." 라는 글에도 봤지만 JVM위에 올라가는 언어들은 JDK가 기본적으로 제공하는 그리고 Java쪽의 관련 라이브러리들이 제공하는 기능을 좀더 사용하기 쉽게 래피하는 형태가 많습니다.
그 중 하나가 HTTPBuilder 입니다.

Apache의 HttpClient 를 한번 더 래핑했습니다. 그리고 Prototype.js의 Ajax.Request 개념을 사용했기 때문에 비동기 호출이 가능합니다.

import groovyx.net.http.*;
import static groovyx.net.http.ContentType.TEXT

def http = new HTTPBuilder('http://www.google.com')

http.get( path : '/search',
          contentType : TEXT,
          query : [q:'Groovy'] ) { resp, reader ->

  println "response status: ${resp.statusLine}"
  println 'Response data: -----'
  System.out << reader
  println '\n--------------------'
}

http://openframework.or.kr/Wiki.jsp?page=Using_Groovy_HTTPBuilder 에 간단히 정리해봤습니다.

'자바' 카테고리의 다른 글

[자바] 인코딩  (1) 2009.01.30
[eclipse] 2008년 정리  (1) 2009.01.16
[메모] 웹애플리케이션의 실제 경로 가져오기  (0) 2009.01.08
[Ant] Ant로 SVN 작업 처리하기  (0) 2008.12.26
[일상] 일요일 위키에 추가한 내용  (0) 2008.12.21
Posted by fromm0
|
webwork를 사용중입니다.
프로젝트 특성상 웹애플리케이션의 가장 상위 경로를 동적으로 가져와야 합니다.
잘 해보지 않아서 또는 API를 주의깊게 보지 않아서 어떻게 가져오지..? 를 다른 팀원과 함께 찾아봤습니다.

ServletActionContext.getServletContext().getRealPath("");

방법은 의외로 간단합니다.
메모입니다. ^^
Posted by fromm0
|

업무상 프로젝트 간의 의존성이 있을 경우 다른 SVN에 등록된 프로젝트의 소스를 가져와서 사용해야할 필요가 있었는데, Ant로 SVN작업을 처리하는 방법이 있네요.

먼저 svnant가 필요합니다. svnant는 subclipse 프로젝트에서 제공하고 있습니다. 다운로드는 다음 URL에서 하시면 됩니다.
http://subclipse.tigris.org/svnant.html

# build.properties파일
# -----------------------------------------------------------------------------
# build.properties
# 이 파일은 svnant에서 제공하는 기본 build.xml 파일을 참고해서 다시 만든것입니다.
# -----------------------------------------------------------------------------
svnant.version=1.2.1

# -----------------------------------------------------------------------------
# 필요한 모든 jar파일
# -----------------------------------------------------------------------------
lib.dir=lib

####실제로 필요한 SVN 프로퍼티들 ####
svn.repository.url=https://ksug.googlecode.com/svn/trunk/
svn.project.base.path=SpringReference
svn.username=fromm0
svn.password=1111
# 태그명, 빌드전에 반드시 수정되어야 하는 값
# export하기 위해 사용됨
tag.name=SOME_TAG_NAME_12222008
# 새로운 브랜치명
# 브랜치를 새롭게 생성할 때만 사용됨
new.branch.name=NEW_BRANCH_12222008
####실제로 필요한 SVN 프로퍼티들 ####

# build.xml파일
<?xml version="1.0"?>
<!-- Sample build file used to retrieve svnant's sources -->
<project name="svnant" basedir="." default="checkoutLatest">

    <!--  all properties are in build.properties -->
    <property file="build.properties" />

    <!-- SVN and SVN-ANT Tasks properties -->
    <property name="svn.repository.url" value="${svn.repository.url}" />
    <property name="svn.project.base.path" value="${svn.project.base.path}" />
    <property name="svn.base.url" value="${svn.repository.url}/${svn.project.base.path}" />
    <property name="svnant.javahl" value="false" />
    <property name="svnant.svnkit" value="true" />
    <!-- SVN and SVN-ANT Tasks properties -->


    <!-- path to the svnant libraries. Usually they will be located in ANT_HOME/lib -->
    <path id="svnant.classpath">
        <fileset dir="${lib.dir}">
            <include name="**/*.jar" />
        </fileset>
    </path>

    <!-- load the svn task -->
    <typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.classpath" />

    <target name="clean">
        <delete dir="src_latest" />
    </target>

    <target name="checkoutLatest">
        <svn username="${svn.username}" password="${svn.password}">
            <checkout url="${svn.base.url}" revision="HEAD" destPath="src_latest" />
        </svn>
    </target>

    <!-- *************************************************************** -->
    <!-- tool-availability: Determine if SVN-ANT is available.           -->
    <!-- *************************************************************** -->
    <target name="tool-availability">
        <available resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.classpath" property="available.svnant" />
        <echo message="SVN-ANT is available = ${available.svnant}" />
    </target>


    <!-- **************************************************************** -->
    <!-- does-svnant-exist: depends on tool-availablility and     -->
    <!--                    displays error message                                   -->
    <!-- ***************************************************************** -->
    <target name="does-svnant-exist" depends="tool-availability">
        <fail unless="available.svnant">
      SVN-ANT is not available, cannot perform tagging or checkout/export svn ant task.
     </fail>
    </target>


    <!-- ****************************************************************** -->
    <!-- svntag: performs tagging using properties from                              -->
    <!--         build.properties and uses SVNANT tasks                              -->
    <!-- ******************************************************************* -->
    <target name="svntag" description="tags individual project using svnant task">
        <property name="svn.tag.message" value="Tagging Project ${project.name} with tag name ${tag.name} from trunk " />
        <property name="src.url" value="${svn.base.url}/${project.name}/trunk/" />
        <property name="dest.url" value="${svn.base.url}/${project.name}/tags/${tag.name}" />

        <echo message="${svn.tag.message}" />
        <echo message="${src.url}" />
        <echo message="${dest.url}" />

        <svn javahl="${svnant.javahl}" svnkit="${svnant.svnkit}" username="${svn.username}" password="${svn.password}">
            <copy srcUrl="${src.url}" destUrl="${dest.url}" message="${svn.tag.message}" />
        </svn>
    </target>


    <!-- ****************************************************************** -->
    <!-- svnexport: performs export using properties from                            -->
    <!--            build.properties and uses SVNANT tasks                           -->
    <!-- ****************************************************************** -->
    <target name="svnexport" description="exports individual project using svnant task">
        <property name="svn.tag.message" value="Exporting Project ${project.name} with tag name ${tag.name}" />
        <property name="src.url" value="${svn.base.url}/${project.name}/tags/${tag.name}" />
        <property name="destPath" value="${dest.path}" />
        <echo message="${svn.tag.message}" />
        <svn javahl="${svnant.javahl}" svnkit="${svnant.svnkit}" username="${svn.username}" password="${svn.password}">
            <export srcUrl="${src.url}" destPath="${destPath}/${project.name}" />
        </svn>
    </target>

    <!-- ****************************************************************** -->
    <!-- svnbranch: creates a new branch using properties from                       -->
    <!--            build.properties and uses SVNANT tasks                           -->
    <!-- ****************************************************************** -->
    <target name="svnbranch" description="creates a new branch for individual project using svnant task">

        <property name="svn.branch.message" value="Creating new branch for
    Project ${project.name} with new branch name ${new.branch.name} from
    trunk" />
        <property name="src.url" value="${svn.base.url}/${project.name}/trunk/" />
        <property name="dest.url" value="${svn.base.url}/${project.name}/branches/${new.branch.name}" />

        <echo message="${svn.branch.message}" />
        <echo message="${src.url}" />
        <echo message="${dest.url}" />

        <svn javahl="${svnant.javahl}" svnkit="${svnant.svnkit}" username="${svn.username}" password="${svn.password}">
            <copy srcUrl="${src.url}" destUrl="${dest.url}" message="${svn.branch.message}" />
        </svn>
    </target>
</project>

현재 필요한 기능은 실제 최신 버전의 체크아웃이라 checkoutLatest만 해봤는데 잘됩니다. ^^
Posted by fromm0
|
토요일은 돌잔치를 가느라 공부를 못했고 오늘은 groovy를 좀 보고 있습니다. 자바외 다른 언어를 한번 해볼려고 Ruby로 손대보고 Python도 손대보고 했는데 제대로 손이 가는 놈은 하나도 없네요. 그나마 groovy는 좀 손이 더 가서 간혹 자료를 정리하곤 합니다. 업무에서 사용해야 제대로 공부가 될텐데.. 이건 사용할 기회가 없다보니 매번 이렇게 되네요. ^^

1. Groovy JDBC - Groovy를 이용한 JDBC프로그래밍
2. Grails Start - Grails 시작하기
3. Groovlet과 GSP - Groovlet과 GSP를 이용한 웹개발

오늘 추가한 내용은 위 3가지 입니다. 주로 보는 글은 Groovy홈페이지의 문서 페이지IBM developerWorks의 Groovy관련 글입니다.

참고할만한 사이트는 한국 Groovy & Grails 사용자 그룹 이 있습니다.
Posted by fromm0
|
제목이 좀 그렇긴 한데 정확하게 쓰자면 "groovy 로 작성한 코드를 java애플리케이션에서 사용하기" 가 될 것 같습니다. JVM위에서 돌아가는 많은 언어가 나왔습니다. 예를 들면 groovy, JRuby, Jython 등등 많죠. JVM에서 돌아가기때문에 즉 JVM이 그 각각의 코드를 알아볼수 있다면 당연히 java애플리케이션에서 사용할 수 있으리라는 짐작이 갑니다. 그래서 한번 해봤습니다. ^^

# groovy 코드(builder를 이용해서 XML생성)
package openframework.groovy

import groovy.xml.*
import java.io.*

class XMLBuilder{
    def getXML() {
        def writer = new StringWriter()
        def builder = new MarkupBuilder(writer)
        def friendnames = [ "Julie", "Joey", "Hannah"]

        builder.person() {
            name(first:"Megan", last:"Smith") {
                age("33")
                gender("female")
            }
            friends() {
                for (e in friendnames) { friend(e) }
            }
        }
        return writer.toString()
    }
}

groovyc 명령어를 통해 컴파일을 합니다. 그럼 당연히 openframework.groovy 패키지 아래 XMLBuilder.class라는 파일이 생성됩니다. 실제로는 아래처럼 다양한 클래스 파일이 생성됩니다.
무려 4개나 생성되네요. ^^

자바코드를 만들어봅니다.

# java 코드(groovy코드를 통해 xml을 생성)
package openframework;

import openframework.groovy.XMLBuilder;

public class Test {
    public static void main(String[] args) {
        XMLBuilder builder = new XMLBuilder();
        System.out.println(builder.getXML());
    }
}

# 결과물
<person>
  <name first='Megan' last='Smith'>
    <age>33</age>
    <gender>female</gender>
  </name>
  <friends>
    <friend>Julie</friend>
    <friend>Joey</friend>
    <friend>Hannah</friend>
  </friends>
</person>

순수 자바에 비하면 좀더 간단하게 기능을 구현할 수 있는 방법은 JVM위에 돌아가는 많은 스크립트 언어가 아닐까 하는 생각으로 테스트 해봤습니다. 단점도 있겠죠..?? 유지보수라고 할수도 있겠지만. 글쎄요.. ^^
다양한 생각을 해보고 싶어서 해본 테스트 결과였습니다.

'자바' 카테고리의 다른 글

[Ant] Ant로 SVN 작업 처리하기  (0) 2008.12.26
[일상] 일요일 위키에 추가한 내용  (0) 2008.12.21
[생각] 자바는 참 어려운 언어..  (17) 2008.12.21
[JDK] JDK 7의 변경사항  (4) 2008.12.20
[REST] jersey로 REST구현하기  (2) 2008.12.16
Posted by fromm0
|