레이블이 java인 게시물을 표시합니다. 모든 게시물 표시
레이블이 java인 게시물을 표시합니다. 모든 게시물 표시

2010년 5월 18일 화요일

How Will Java Technology Change My Life?

We can't promise you fame, fortune, or even a job if you learn the Java programming language. Still, it is likely to make your programs better and requires less effort than other languages. We believe that Java technology will help you do the following:

  • Get started quickly: Although the Java programming language is a powerful object-oriented language, it's easy to learn, especially for programmers already familiar with C or C++.
  • Write less code: Comparisons of program metrics (class counts, method counts, and so on) suggest that a program written in the Java programming language can be four times smaller than the same program written in C++.
  • Write better code: The Java programming language encourages good coding practices, and automatic garbage collection helps you avoid memory leaks. Its object orientation, its JavaBeansTM component architecture, and its wide-ranging, easily extendible API let you reuse existing, tested code and introduce fewer bugs.
  • Develop programs more quickly: The Java programming language is simpler than C++, and as such, your development time could be up to twice as fast when writing in it. Your programs will also require fewer lines of code.
  • Avoid platform dependencies: You can keep your program portable by avoiding the use of libraries written in other languages.
  • Write once, run anywhere: Because applications written in the Java programming language are compiled into machine-independent bytecodes, they run consistently on any Java platform.
  • Distribute software more easily: With Java Web Start software, users will be able to launch your applications with a single click of the mouse. An automatic version check at startup ensures that users are always up to date with the latest version of your software. If an update is available, the Java Web Start software will automatically update their installation.

2010년 5월 17일 월요일

Spring seucrity 2.0 태그 사용하기

<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<!-- 권한에 따라 페이지에서 보여주는 것을 달리하기 위해 authorize 태그를 사용할 수 있다. -->
<sec:authorize ifNotGranted="ROLE_USER">
<a href="<s:url value="/public/blog/login.jsp"/>">로그인</a>
</sec:authorize>
<sec:authorize ifAnyGranted="ROLE_USER, ROLE_ADMIN">
<b><sec:authentication property="principal.username"/></b>님 반갑습니다. <br>
<a href="<s:url value="/j_spring_security_logout"/>">로그아웃</a>
</sec:authorize>
 
수정 및 삭제 버튼도 위에서 사용한 authorize 태그를 사용해서 로그인 상태에 따라 보여주거나 보여주지 않을 수 있다.

authentication 태그를 사용하여 현재 로그인된 사용자의 정보를 확인할 수 있다.

* Spring Security Tag Library *
- authentication 태그
 property="principal.username" 설정으로 현재 로그인 된 사용자의 username을 확인 할 수 있다.
- authorize 태그
 현재 로그인 된 사용자가 해당되는 권한에 따라, 태그 안에 포함된 내용을 보여주거나 보여주지 않을 수 있다.
 
 ifAllGranted 속성: 사용자가 나열된 모든 권한에 해당할 경우 태그 안에 포함된 내용을 보여준다.
 ifAnyGranted 속성: 사용자가 나열된 권한 중 한가지에라도 해당할 경우 태그 안에 포함된 내용을 보여준다.
 ifNotGranted 속성: 사용자가 나열된 권한 중 한가지에라도 해당할 경우 태그 안에 포함된 내용을 보여주지 않는다.

Web Service 쉽게 구현하기 II - 웹서비스 프로그램 작성 예

1. 서버 프로그램 작성
 <웹서비스 구현 플로우>

2. 자바 Interface와 자바 Implement 클래스 작성
- c:\test\ 에 아래 2개의 파일을 생성한다.

// HelloIF.java
package hello;
public interface HelloIF extends java.rmi.Remote {
public String hello(java.lang.String name) throws java.rmi.RemoteException;
}

// HelloImpl.java
package hello;
public class HelloImpl implements HelloIF {
public HelloImpl() {}
public String hello(String name) {
System.out.println(name);
return "hi " + name;
}
}

- 컴파일 후 c:\test\webservice/hello 디렉토리 밑에 HelloImpl.class 와 HelloIF.class가 생성. 생성된 class파일을 C:\Tomcat\webapps\axis\WEB-INF\classes 디렉토리에 패키지 디렉토리를 포함해서 복사한다.

3. 구현된 클래스로부터 WSDL 생성 하기
 Ex) java org.apache.axis.wsdl.Java2WSDL -o C:\test\hello\Hello.wsdl
-l http://localhost:8080/axis/services/Hello
-n http://hello.webservice -pwebservice.Hello http://hello.webservice hello.Hello
- C:\test 밑에 hello.wsdl 파일이 생성되었는지 확인한다.

4. WSDL 파일로부터 deploy.wsdd 및 client-side 자바 클래스 생성
Ex) java org.apache.axis.wsdl.WSDL2Java -o C:\test\hello\ -d Application -s C:\test\hello\Hello.wsdl

5. deploy.wsdd 파일 수정
wsdd 파일은 wsdl 파일만 가지고 생성되었기 때문에 실제 구현클래스가 무엇인지 제대로
설정이 안되어 있으므로 그부분을 수정해 주어야한다.
붉은색 부분으로 해당 부분을 수정해주면 된다.

xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
...
...생략...
...
hello.HelloImpl"/>  <- 실제 구현 클래스 명칭 및 패키지 경로를 수정한다.
...
...생략...

6. 서비스 디플로이먼트 하기
Ex) java org.apache.axis.client.AdminClient -lhttp://localhost:8080/axis/services/AdminService deploy.wsdd

[디플로이먼트 확인하기]
http://localhost:8080/axis/servlet/AxisServlet
'Hello' 라는 서비스가 설치된 것을 확인할 수 있다.

7. 서비스 언디플로이먼트 하기
Ex) java org.apache.axis.client.AdminClient -lhttp://localhost:8080/axis/services/AdminService undeploy.wsdd

[언디플로이먼트 확인하기]
http://localhost:8080/axis/servlet/AxisServlet
'Hello' 라는 서비스가 삭제된 것을 확인할 수 있다.

Web Service 쉽게 구현하기 I - 환경설정

본 강좌는 Axis를 이용한 웹서비스 구축 및 클라이언트 구현 방법을 소개한다.

I. 환경설정
1. JDK 설치
- http://java.sun.com 에서 jdk1.5 버전을 다운받아 설치한다.
- 설치 후 CLASSPATH 를 설정한다.
- set CLASSPATH=.;C:\jdk15\lib\tools.jar;C:\tomcat\common\lib\servlet-api.jar;
- set JAVA_HOME=C:\jdk15
- set PATH=C:\jdk15\bin; 을 기존 PATH에 추가한다.

2. Apache Tomcat 설치
- http://tomcat.apache.org/ 에서 Tomcat 5.5 다운로드
- set CATALINA_HOME=tomcat 설치폴더 ex) C:\tomcat
- 설치 후 CATALINA_HOME\bin\startup.bat 를 실행한다.
- 웹 브라우저에서 http://localhost:8080으로 확인한다.

3. AXIS 설치
- http://ws.apache.org/axis/ 에서 1.4 버전을 다운로드 한다.
- set AXIS_HOME=C:\axis
- set AXIS_LIB=%AXIS_HOME%\lib
- set AXISCLASSPATH=%AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery.jar;
- %AXIS_LIB%\commons-logging.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB%\saaj.jar;
- %AXIS_LIB%\log4j-1.2.8.jar;%AXIS_LIB%\xml-apis.jar;%AXIS_LIB%\xercesImpl.jar;
- %AXIS_LIB%\wsdl4j.jar
- set CLASSPATH=%CLASSPATH%;%AXISCLASSPATH% 으로 기존 CLASSPATH 에 추가한다.
- CLASSPATH에 있는 xml-apis.jar 파일과 xercesImpl.jar 파일은http://xml.apache.org/ 에서 받으면 된다.

4. AXIS를 Tomcat에 연동하기
- C:\axis\webapps\axis\ 에서 axis디렉토리를 C:\tomcat\webapps\axis로 복사하면 된다. 즉, 톰캣 webapps디렉토리에 axis 컨텍스트가 추가 되었다고 이해해도 되겠다.
- 웹 브라우저에서 http://localhost:8080으로 확인한다.

5. AXIS 테스트
- tomcat을 실행하고 연결테스트를 해본다. (http://localhost:8080/axis)
- 라이브러리 테스트 : http://localhost:8080/axis/happyaxis.jsp 에서 필요하거나 필수적인 추가 라이브러리를 설치하라는 경고 메시지를 보여주기 때문에 이때 필요한 라이브러리를 다운받아서 C:\tomcat\webapps\axis\lib\ 에 복사해주고 다시 테스트를 해본다.

maven

1. maven 다운로드 및 설치

1) 다운로드
  maven 최신버전을 다운로드 한다

2) 설치
  압축을 적당한 경로에 풀고 path를 설정한다.
  path : C:\apache-maven-2.0.10\bin
  확인 : mvn --version
           Maven version: 2.0.10
           Java version: 1.5.0_17
           OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"

3) Maven Integration for Eclipse
  Help -> Software Update and add-ons -> Available Software 선택
  Add Site 버튼선택 후 http://m2eclipse.sonatype.org/update/ 를 추가

2010년 4월 2일 금요일

What Can Java Technology Do?

 
 Java 프로그래밍 언어는 강력한 소프트웨어 플랫폼으로써, 다음과 같은 기능을 제공한다.

  • Development Tools : 개발 도구(Development Tools)를 사용하면 컴파일, 실행하는 데 필요한 모니터링, 디버깅 등을 제공하고, javadoc 문서 도구를 이용해 응용 프로그램을 문서화 할 수 있다.
  • Application Programming Interface (API) : API는 Java 프로그래밍 언어의 핵심 기능을 제공한다. 이는 XML 생성 및 데이터베이스 액세스, 네트워킹 및 보안 등 다양한 기능을 자신의 어플리케이션에서 사용하기 위해 제공된다. 더 자세한 내용은 Java SE Development Kit 6 (JDKTM 6) Documentation 참조.
  • Deployment Technologies : JDK의 소프트웨어는 Java Web Start 혹은 Java Plug-In 소프트웨어와 같은 표준 메카니즘(Mechanisms)을 제공하고, 최종 사용자에게 응용 프로그램을 배포하기 위한 소프트웨어를 제공한다.
  • User Interface Toolkits : 스윙(Swing)과 Java 2D toolkits 은 정교한 그래픽 사용자 인터페이스(GUIs)를 만들 수 있다.
  • Integration Libraries : Java IDL API, JDBCTM API, JNDI API, Java RMI, Java RMI-IIOP Technology 등 Integration Libraries 는 데이터베이스 액세스 및 원격 개체의 조작을 가능하게 한다.

About the Java Technology

 Java technology is both a programming language and a platform.


 자바 프로그래밍 언어는 다음과 같은 특징을 가진 높은 수준의 언어다.

  • Simple
  • Architecture neutral
  • Object oriented                  
  • Portable
  • Distributed
  • High performance
  • Multithreaded
  • Robust
  • Dynamic
  • Secure

  •  자바 프로그래밍 언어에서 모든 소스 코드가 .java 확장자로 끝나는 일반 텍스트 파일에 기록된다. 그 소스 파일은 javac 컴파일러에 의해 컴파일 되어 바이트 코드로 된 .class 파일을 생성한다. Java launcher tool은 Java 가상 머신의 인스턴스와 함께 응용 프로그램을 실행한다.


    Software Development process


     자바 플랫폼은 두 가지 구성 요소가 있다.

    • The Java Virtual Machine
    • The Java Application Programming Interface (API) [1.6|1.5|1.4.2]

     API는 많은 유용한 기능을 제공하는 컴포넌트의 모음이다. 이것은 관련 클래스와 인터페이스의 라이브러리로 그룹화하고, 이러한 라이브러리는 패키지로 알려져 있다.

    2010년 4월 1일 목요일

    Spring Roo Getting Started

    1. Spring Roo 다운
    springsource.org(http://www.springsource.org/download) 를 방문하여
    Spring Roo 최신버전(Spring Roo 1.0.2)을 다운받는다.

    2. 다운받은 spring-roo-1.0.2.RELEASE.zip 화일을 압축을 푼다.

    3. 압축을 푼 경로 클래스 패스 추가
     ex) C:\spring-roo-1.0.2.RELEASE\bin

    4. 콘솔창에서 roo 입력

    5. 테스트 프로젝트 실행
    1) sample 폴더의 wedding.roo 파일을 참고하여 프로젝트를 생성한다.
    2) perform eclipse 까지 실행하고 나면 eclipse를 열고, 생성된 프로젝트 import 한다.

    6. eclipse 프로젝트에서 톰켓 서버를 설정하고, 실행하면 다음과 같은 화면이 뜬다.


    2009년 10월 7일 수요일

    [AOP] pointcut을 이용한 parameter 전달 메소드 실행

    <aop:config>
        <aop:aspect id="beanServiceAspect" ref="beanService">
            <aop:after                
                 method="insertMethod"
                 pointcut="execution(public * package.UseController.method(..)) and args(arg1, ..)" />
        </aop:aspect>
    </aop:config>

    UseController 의 method() 가 호출되고 나면 beanService에 정의된 insertMethod() 가 실행된다.

    이때 insertMethod() 의 argument 인 arg1은 method()이 호출될 당시의 값으로 전달받는다.

    2009년 8월 20일 목요일

    SpringSource.org를 VMware가 인수

    SpringSource Joins Forces with VMware

    Today SpringSource announced that it is being acquired by VMware, the global leader in virtualization solutions from the desktop to the datacenter. Rod Johnson covers the details of the acquisition in his blog post: SpringSource: Chapter Two. In particular, he gives a special message to the community:

    Sleep easy – our commitment to open source practices, licenses and traditions will remain unchanged. We expect our contributions to open source to increase. Our open source projects will retain their commitment to enabling user choice. Spring will retain the portability between deployment environments that empowers users.

    The combination of the two companies will provide some incredibly exciting technology and make development for cloud based solutions even easier. Congratulations to Rod and all the SpringSource technologists that have worked so hard to deliver great technology and build a successful business. Feel free to discuss the news in the community forums.