'개발'에 해당되는 글 73건

  1. 2008.07.25 스프링 tutorial (5)
  2. 2008.07.17 스프링 tutorial (4)
  3. 2008.07.17 스프링 tutorial (3)
  4. 2008.07.16 스프링 tutorial (2)
  5. 2008.07.16 스프링 tutorial (1)
  6. 2008.06.30 용어설명
  7. 2008.06.25 방법론
  8. 2008.06.21 감리
  9. 2008.06.20 프로세스 테일러링
  10. 2008.06.17 실용주의 개발

2-4. ProductManager를 구현한 SimpleProductManager를 생성한다.

 

src/springapp/service/SimpleProductManager.java

 

package springapp.service;

 

import java.util.List;

 

import springapp.domain.Product;

 

public class SimpleProductManager implements ProductManager {

 

    public List<Product> getProducts() {

        throw new UnsupportedOperationException();

    }

 

    public void increasePrice(int percentage) {

        throw new UnsupportedOperationException();       

    }

 

    public void setProducts(List<Product> products) {

        throw new UnsupportedOperationException();       

    }

 

}


2-5. TDD는 좋은것이여. 따라서 SimpleProductManager를 테스트하기 위한

SimpleProductManagerTests를 생성한다.

 

test/springapp/service/SimpleProductManagerTests.java

 

package springapp.service;
 import junit.framework.TestCase;
 public class SimpleProductManagerTests extends TestCase {
   private SimpleProductManager productManager;
   protected void setUp() throws Exception {
        productManager = new SimpleProductManager();
    }
     public void testGetProductsWithNoProducts() {
        productManager = new SimpleProductManager();
        assertNull(productManager.getProducts());
    }

}






2-6. 테스트를 실행해보면 오류가 발생한다. 우선 SimpleProductManagerTestssetUp 메소드에
stub list를 선언하고 테스트 메소드를 추가한다.

 

test/springapp/service/SimpleProductManagerTests.java

 

package springapp.service;
 
import java.util.ArrayList;
import java.util.List;
 
import springapp.domain.Product;
 
import junit.framework.TestCase;
 
public class SimpleProductManagerTests extends TestCase {
 
    private SimpleProductManager productManager;
    private List<Product> products;
    
    private static int PRODUCT_COUNT = 2;
    
    private static Double CHAIR_PRICE = new Double(20.50);
    private static String CHAIR_DESCRIPTION = "Chair";
    
    private static String TABLE_DESCRIPTION = "Table";
    private static Double TABLE_PRICE = new Double(150.10);         
        
    protected void setUp() throws Exception {
        productManager = new SimpleProductManager();
        products = new ArrayList<Product>();
        
        // stub up a list of products
        Product product = new Product();
        product.setDescription("Chair");
        product.setPrice(CHAIR_PRICE);
        products.add(product);
        
        product = new Product();
        product.setDescription("Table");
        product.setPrice(TABLE_PRICE);
        products.add(product);
        
        productManager.setProducts(products);
    }
 
    public void testGetProductsWithNoProducts() {
        productManager = new SimpleProductManager();
        assertNull(productManager.getProducts());
    }
    
    public void testGetProducts() {
        List<Product> products = productManager.getProducts();
        assertNotNull(products);        
        assertEquals(PRODUCT_COUNT, productManager.getProducts().size());
    
        Product product = products.get(0);
        assertEquals(CHAIR_DESCRIPTION, product.getDescription());
        assertEquals(CHAIR_PRICE, product.getPrice());
        
        product = products.get(1);
        assertEquals(TABLE_DESCRIPTION, product.getDescription());
        assertEquals(TABLE_PRICE, product.getPrice());      
    }   
}
 

2-7. 다시 테스트를 실행하면 또 오류가 발생한다. ? SimpleProductManager가 무조건 Exception

리턴하므로. 따라서 SimpleProductManager의 메소드들을 구현한다.

 

src/springapp/service/SimpleProductManager.java

 

package springapp.service;
 
import java.util.ArrayList;
import java.util.List;
 
import springapp.domain.Product;
 
public class SimpleProductManager implements ProductManager {
 
    private List<Product> products;
    
    public List<Product> getProducts() {
        return products;
    }
 
    public void increasePrice(int percentage) {
        // TODO Auto-generated method stub      
    }
 
    public void setProducts(List<Product> products) {
        this.products = products;
    }
    
}
 

2-8. 테스트를 재실행하면 모두 통과한다.

    이후에 increasePrice()의 테스트를 위하여 아래 테스트를 구현한다.

product list null인 경우

product list empty인 경우

10% 증가시 모든 product list에 반영되는지 여부

 

springapp/test/springapp/service/SimpleProductManagerTests.java


package springapp.service;
 
import java.util.ArrayList;
import java.util.List;
 
import springapp.domain.Product;
 
import junit.framework.TestCase;
 
public class SimpleProductManagerTests extends TestCase {
 
    private SimpleProductManager productManager;
 
    private List<Product> products;
    
    private static int PRODUCT_COUNT = 2;
    
    private static Double CHAIR_PRICE = new Double(20.50);
    private static String CHAIR_DESCRIPTION = "Chair";
    
    private static String TABLE_DESCRIPTION = "Table";
    private static Double TABLE_PRICE = new Double(150.10);         
    
    private static int POSITIVE_PRICE_INCREASE = 10;
    
    protected void setUp() throws Exception {
        productManager = new SimpleProductManager();
        products = new ArrayList<Product>();
        
        // stub up a list of products
        Product product = new Product();
        product.setDescription("Chair");
        product.setPrice(CHAIR_PRICE);
        products.add(product);
        
        product = new Product();
        product.setDescription("Table");
        product.setPrice(TABLE_PRICE);
        products.add(product);
        
        productManager.setProducts(products);
    }
 
    public void testGetProductsWithNoProducts() {
        productManager = new SimpleProductManager();
        assertNull(productManager.getProducts());
    }
    
    public void testGetProducts() {
        List<Product> products = productManager.getProducts();
        assertNotNull(products);        
        assertEquals(PRODUCT_COUNT, productManager.getProducts().size());
    
        Product product = products.get(0);
        assertEquals(CHAIR_DESCRIPTION, product.getDescription());
        assertEquals(CHAIR_PRICE, product.getPrice());
        
        product = products.get(1);
        assertEquals(TABLE_DESCRIPTION, product.getDescription());
        assertEquals(TABLE_PRICE, product.getPrice());      
    }   
    
    public void testIncreasePriceWithNullListOfProducts() {
        try {
            productManager = new SimpleProductManager();
            productManager.increasePrice(POSITIVE_PRICE_INCREASE);
        }
        catch(NullPointerException ex) {
            fail("Products list is null.");
        }
    }
    
    public void testIncreasePriceWithEmptyListOfProducts() {
        try {
            productManager = new SimpleProductManager();
            productManager.setProducts(new ArrayList<Product>());
            productManager.increasePrice(POSITIVE_PRICE_INCREASE);
        }
        catch(Exception ex) {
            fail("Products list is empty.");
        }           
    }
    
    public void testIncreasePriceWithPositivePercentage() {
        productManager.increasePrice(POSITIVE_PRICE_INCREASE);
        double expectedChairPriceWithIncrease = 22.55;
        double expectedTablePriceWithIncrease = 165.11;
        
        List<Product> products = productManager.getProducts();      
        Product product = products.get(0);
        assertEquals(expectedChairPriceWithIncrease, product.getPrice());
        
        product = products.get(1);      
        assertEquals(expectedTablePriceWithIncrease, product.getPrice());       
    }
        
}
 

2-9. 테스트를 작성했으면, 해당 Manager를 수정해야 한다. 가자..

 

src/springapp/service/SimpleProductManager.java

 

package springapp.service;
 
import java.util.List;
 
import springapp.domain.Product;
 
public class SimpleProductManager implements ProductManager {
 
    private List<Product> products;
    
    public List<Product> getProducts() {
        return products;
    }
 
    public void increasePrice(int percentage) {
        if (products != null) {
            for (Product product : products) {
                double newPrice = product.getPrice().doubleValue() * 
                                    (100 + percentage)/100;
                product.setPrice(newPrice);
            }
        }
    }
    
    public void setProducts(List<Product> products) {
        this.products = products;
    }
    
}
 
2-10. 테스트가 통과된다.



















'개발 > 스프링' 카테고리의 다른 글

스프링 tutorial (7)  (0) 2008.07.27
스프링 tutorial (6)  (0) 2008.07.26
스프링 tutorial (4)  (0) 2008.07.17
스프링 tutorial (3)  (0) 2008.07.17
스프링 tutorial (2)  (0) 2008.07.16
Posted by 무혹
,

비지니스 로직의 개발

1. Inventory Management System의 business case review

validation rule :

The maximum increase is limited to 50%.

The minimum increase must be greater than 0%.

클래스 다이어그램

사용자 삽입 이미지

2. 비즈니스 로직에 몇 개의 클래스를 추가

2-1. 서비스 객체를 위해 service패키지를 도메인 객체를 위해 domain패키지를 생성한다.
src/springapp/domain
src/springapp/domain

2-1. 위의 클래스 다이어그램을 기준으로 product 클래스를 생성한다.

package springapp.domain;

import java.io.Serializable;

public class Product implements Serializable {

    private String description;
    private Double price;
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public Double getPrice() {
        return price;
    }
    
    public void setPrice(Double price) {
        this.price = price;
    }
    
    public String toString() {
        StringBuffer buffer = new StringBuffer();
        buffer.append("Description: " + description + ";");
        buffer.append("Price: " + price);
        return buffer.toString();
    }
}
2-2. 단위 테스트를 생성한다.

springapp/test/springapp/domain/ProductTests.java

package springapp.domain;

import junit.framework.TestCase;

public class ProductTests extends TestCase {

    private Product product;

    protected void setUp() throws Exception {
        product = new Product();
    }

    public void testSetAndGetDescription() {
        String testDescription = "aDescription";
        assertNull(product.getDescription());
        product.setDescription(testDescription);
        assertEquals(testDescription, product.getDescription());
    }

    public void testSetAndGetPrice() {
        double testPrice = 100.00;
        assertEquals(0, 0, 0);    
        product.setPrice(testPrice);
        assertEquals(testPrice, product.getPrice(), 0);
    }
  
}
2-3. Product 클래스를 취급하는 ProductManager를 생성한다.
      이 인터페이스는 가격을 증가시키는 increasePrice(), product를 getter하기 위한
      getProducts() 메소드를 가진다.

src/springapp/service/ProductManager.java

package springapp.service;

import java.io.Serializable;
import java.util.List;

import springapp.domain.Product;

public interface ProductManager extends Serializable{

    public void increasePrice(int percentage);
    
    public List<Product> getProducts();
    
}

다음으로 계속......



























'개발 > 스프링' 카테고리의 다른 글

스프링 tutorial (6)  (0) 2008.07.26
스프링 tutorial (5)  (0) 2008.07.25
스프링 tutorial (3)  (0) 2008.07.17
스프링 tutorial (2)  (0) 2008.07.16
스프링 tutorial (1)  (0) 2008.07.16
Posted by 무혹
,

View 와 controller의 개발과 설정

1. JSTL 설정과 JSP 헤더 파일 추가

1-1. war/WEB-INF/lib에 아래 파일을 추가한다.

spring-framework-2.5/lib/j2ee/jstl.jar
spring-framework-2.5/lib/jakarta-taglibs/standard.jar

1-2. jsp를 보관할 디렉토리를 war/WEB-INF/ 에 생성한다.

war/WEB-INF/jsp

1-3. header 파일이 될 include.jsp 파일을 생성한다.

war/WEB-INF/jsp/include.jsp

<%@ page session="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

1-4. index.jsp를 업데이트하여 모든 요청이 framework을 통하도록 한다.

<%@ include file="/WEB-INF/jsp/include.jsp" %>
<c:redirect url="/hello.htm"/>

1-5. hello.jsp를 war/WEB-INF/jsp/ 로 이동하고 수정한다.

war/WEB-INF/jsp/hello.jsp

<%@ include file="/WEB-INF/jsp/include.jsp" %>

<html>
  <head><title>Hello :: Spring Application</title></head>
  <body>
    <h1>Hello - Spring Application</h1>
    <p>Greetings, it is now <c:out value="${now}"/></p>
  </body>
</html>

2. controller를 수정한다.

2-1. 모델의 key를 "now"로 테스트를 수정한다.

package springapp.web;

import org.springframework.web.servlet.ModelAndView;

import springapp.web.HelloController;

import junit.framework.TestCase;

public class HelloControllerTests extends TestCase {

    public void testHandleRequestView() throws Exception{
        HelloController controller = new HelloController();
        ModelAndView modelAndView = controller.handleRequest(null, null);
        assertEquals("WEB-INF/jsp/hello.jsp", modelAndView.getViewName());
        assertNotNull(modelAndView.getModel());
        String nowValue = (String) modelAndView.getModel().get("now");
        assertNotNull(nowValue);
    }
}

2-2. tests 태스크를 실행한다.

now라는 key가 없으므로 에러가 발생한다.

2-3. HelloController에 날자를 기준으로 now key를 설정한다.

package springapp.web;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.IOException;
import java.util.Date;

public class HelloController implements Controller {

    protected final Log logger = LogFactory.getLog(getClass());

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        String now = (new Date()).toString();
        logger.info("Returning hello view with " + now);

        return new ModelAndView("WEB-INF/jsp/hello.jsp", "now", now);
    }

}


2-4. tests 태스크를 재실행하여 성공한다.

2-5. http://localhost:8080/springapp/ 을 웹 브라우저에 입력하여 아래와 같은 정상적인 화면을 본다.

사용자 삽입 이미지

http://localhost:8080/springapp/을 입력하는 경우 위의 화면이 보여지는 원인은 다음과 같다.

web.xml에 welcome-file을 index.jsp로 설정했으므로 index.jsp를 호출한다.
index.jsp에서는 hello.htm으로 redirect하라고 했다.
web.xml에 설정한 바에 따르면 *.htm=> springapp => org.springframework.web.servlet.DispatcherServlet의 순서로 호출한다.
DispatcherServlet은 spring의 servlet이므로 springapp_servlet.xml을 읽는다.
springapp_servlet.xml의 설정에 hello.htm은 springapp.web.HelloController로 되어 있으므로 HelloController를 호출한다.
그 후에 HelloController에서 hello.jsp view를 호출하므로 화면이 보여진다.

3. controller와 view의 결합을 제거

3-1. view에 대한 설정을 한다.

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

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
   
    <!-- the application context definition for the springapp DispatcherServlet -->
   
    <bean name="/hello.htm" class="springapp.web.HelloController"/>
   
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
        <property name="prefix" value="/WEB-INF/jsp/"></property>
        <property name="suffix" value=".jsp"></property>       
    </bean>
           
</beans>

3-2. controller 테스트에서 view name을 변경한 후에 테스트를 실행하여 실패를 확인한다.

package springapp.web;

import org.springframework.web.servlet.ModelAndView;

import springapp.web.HelloController;

import junit.framework.TestCase;

public class HelloControllerTests extends TestCase {

    public void testHandleRequestView() throws Exception{
        HelloController controller = new HelloController();
        ModelAndView modelAndView = controller.handleRequest(null, null);
        assertEquals("hello", modelAndView.getViewName());
        assertNotNull(modelAndView.getModel());
        String nowValue = (String) modelAndView.getModel().get("now");
        assertNotNull(nowValue);
    }
}

3-3. controller소스안의 view 이름을 logical명으로 변경한 후에 재테스트하면 성공한다.

package springapp.web;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.IOException;
import java.util.Date;

public class HelloController implements Controller {

    protected final Log logger = LogFactory.getLog(getClass());

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        String now = (new Date()).toString();
        logger.info("Returning hello view with " + now);

        return new ModelAndView("hello", "now", now);
    }

}

  • 현 시점의 디렉토리 구조

사용자 삽입 이미지


'개발 > 스프링' 카테고리의 다른 글

스프링 tutorial (6)  (0) 2008.07.26
스프링 tutorial (5)  (0) 2008.07.25
스프링 tutorial (4)  (0) 2008.07.17
스프링 tutorial (2)  (0) 2008.07.16
스프링 tutorial (1)  (0) 2008.07.16
Posted by 무혹
,

기본 application의 설정

1. 스프링 프레임워크를 다운받아서 임의의 위치에 압축해제한다.

2. web.xml을 수정한다.

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

<web-app version="2.4"
         xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >

  <servlet>
    <servlet-name>springapp</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>springapp</servlet-name>
    <url-pattern>*.htm</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>
      index.jsp
    </welcome-file>
  </welcome-file-list>

</web-app>

3. WEB-INF 하위에 springapp-servlet.xml을 생성한다.

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

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

  <!-- the application context definition for the springapp DispatcherServlet -->

  <bean name="/hello.htm" class="springapp.web.HelloController"/>

</beans>

4. WEB-INF 하위에 lib 디렉토리를 생성하고 아래의 파일들을 복사한다.

spring-framework-2.5/dist/spring.jar
spring-framework-2.5/dist/modules/spring-webmvc.jar
spring-framework-2.5/lib/jakarta-commons/commons-logging.jar

5. 테스트하기 위한 controller를 생성한다.

src/springapp/web/HelloController.java

package springapp.web;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.IOException;

public class HelloController implements Controller {

    protected final Log logger = LogFactory.getLog(getClass());

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        logger.info("Returning hello view");

        return new ModelAndView("hello.jsp");
    }

}

6. controller 테스트를 위한 TestCase를 작성한다.

test/springapp/web/HelloControllerTests.java

package springapp.web;

import org.springframework.web.servlet.ModelAndView;

import springapp.web.HelloController;

import junit.framework.TestCase;

public class HelloControllerTests extends TestCase {

    public void testHandleRequestView() throws Exception{  
        HelloController controller = new HelloController();
        ModelAndView modelAndView = controller.handleRequest(null, null);  
        assertEquals("hello.jsp", modelAndView.getViewName());
    }
}

7. build.xml에 테스트에 관한 task를 추가한다.

<property name="test.dir" value="test"/>
       
    <target name="buildtests" description="Compile test tree java files">
        <mkdir dir="${build.dir}"/>
        <javac destdir="${build.dir}" source="1.5" target="1.5" debug="true"
            deprecation="false" optimize="false" failonerror="true">
            <src path="${test.dir}"/>
            <classpath refid="master-classpath"/>
        </javac>
    </target>
   
    <target name="tests" depends="build, buildtests" description="Run tests">
        <junit printsummary="on"
            fork="false"
            haltonfailure="false"
            failureproperty="tests.failed"
            showoutput="true">
            <classpath refid="master-classpath"/>
            <formatter type="brief" usefile="false"/>
           
            <batchtest>
                <fileset dir="${build.dir}">
                    <include name="**/*Tests.*"/>
                </fileset>
            </batchtest>
           
        </junit>
       
        <fail if="tests.failed">
            tests.failed=${tests.failed}
            ***********************************************************
            ***********************************************************
            ****  One or more tests failed!  Check the output ...  ****
            ***********************************************************
            ***********************************************************
        </fail>
    </target>

8. tests 태스크를 실행하여 통과여부를 확인한다.

9. war 디렉토리 하위에 hello.jsp를 생성한다.

<html>
  <head><title>Hello :: Spring Application</title></head>
  <body>
    <h1>Hello - Spring Application</h1>
    <p>Greetings.</p>
  </body>
</html>

10. build.xml의 deploy 태스크를 실행한다.

11. 아래 주소를 실행하여 화면이 정상적으로 나오는것을 확인한다.

http://localhost:8080/springapp/hello.htm




 

'개발 > 스프링' 카테고리의 다른 글

스프링 tutorial (6)  (0) 2008.07.26
스프링 tutorial (5)  (0) 2008.07.25
스프링 tutorial (4)  (0) 2008.07.17
스프링 tutorial (3)  (0) 2008.07.17
스프링 tutorial (1)  (0) 2008.07.16
Posted by 무혹
,

1. 필요 소프트웨어

Java SDK 1.5 : 자바 컴파일
Ant 1.7 : 빌드 스크립트
Apache Tomcat 6.0.14 : JSP container
Eclipse 3.3 : IDE Tool (있으면 좋지만 꼭 필요하지는 않다.)

2. Eclipse 프로젝트를 생성하고 src, war 디렉토리를 생성한다.
-- WTP에서 web project를 생성하는 경우는 설정만 변경하면 됨.
     디렉토리 생성 필요없슴

3. 3. war 디렉토리에 index.jsp파일을 생성한다.

  • index.jsp

<%@ page contentType="text/html; charset=euc-kr"%>
<html>
  <head><title>스프링 애플리케이션</title></head>
  <body>
    <h1>예제 - 스프링 애플리케이션</h1>
    <p>테스트.</p>
  </body>
</html>


4. war 디렉토리 하위에 WEB-INF 디렉토리를 생성하고 web.xml 파일을 위치시킨다.

  • web.xml

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

<web-app version="2.4"
         xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >

  <welcome-file-list>
    <welcome-file>
      index.jsp
    </welcome-file>
  </welcome-file-list>

</web-app>

5. tomcat에 배치하기 위한 build.xml을 프로젝트 root에 생성한다.


 

<?xml version="1.0"?>

<project name="springapp" basedir="." default="usage">
    <property file="build.properties"/>

    <property name="src.dir" value="${project.home}/src"/>
    <property name="web.dir" value="${project.home}/war"/>
    <property name="build.dir" value="${web.dir}/WEB-INF/classes"/>
    <property name="name" value="springapp"/>

    <path id="master-classpath">
        <fileset dir="${web.dir}/WEB-INF/lib">
            <include name="*.jar"/>
        </fileset>
        <!-- We need the servlet API classes: -->
        <!--  * for Tomcat 5/6 use servlet-api.jar -->
        <!--  * for other app servers - check the docs -->
        <fileset dir="${appserver.lib}">
            <include name="servlet*.jar"/>
        </fileset>
        <pathelement path="${build.dir}"/>
    </path>

    <target name="usage">
        <echo message=""/>
        <echo message="${name} build file"/>
        <echo message="-----------------------------------"/>
        <echo message=""/>
        <echo message="Available targets are:"/>
        <echo message=""/>
        <echo message="build     --> Build the application"/>
        <echo message="deploy    --> Deploy application as directory"/>
        <echo message="deploywar --> Deploy application as a WAR file"/>
        <echo message="install   --> Install application in Tomcat"/>
        <echo message="reload    --> Reload application in Tomcat"/>
        <echo message="start     --> Start Tomcat application"/>
        <echo message="stop      --> Stop Tomcat application"/>
        <echo message="list      --> List Tomcat applications"/>
        <echo message=""/>
    </target>

    <target name="build" description="Compile main source tree java files">
        <mkdir dir="${build.dir}"/>
        <javac destdir="${build.dir}" source="1.5" target="1.5" debug="true"
               deprecation="false" optimize="false" failonerror="true">
            <src path="${src.dir}"/>
            <classpath refid="master-classpath"/>
        </javac>
    </target>

    <target name="deploy" depends="build" description="Deploy application">
        <copy todir="${deploy.path}/${name}" preservelastmodified="true">
            <fileset dir="${web.dir}">
                <include name="**/*.*"/>
            </fileset>
        </copy>
    </target>

    <target name="deploywar" depends="build" description="Deploy application as a WAR file">
        <war destfile="${name}.war"
             webxml="${web.dir}/WEB-INF/web.xml">
            <fileset dir="${web.dir}">
                <include name="**/*.*"/>
            </fileset>
        </war>
        <copy todir="${deploy.path}" preservelastmodified="true">
            <fileset dir=".">
                <include name="*.war"/>
            </fileset>
        </copy>
    </target>
   
<!-- ============================================================== -->
<!-- Tomcat tasks - remove these if you don't have Tomcat installed -->
<!-- ============================================================== -->

    <path id="catalina-ant-classpath">
        <!-- We need the Catalina jars for Tomcat -->
        <!--  * for other app servers - check the docs -->
        <fileset dir="${appserver.lib}">
            <include name="catalina-ant.jar"/>
        </fileset>
    </path>

    <taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
        <classpath refid="catalina-ant-classpath"/>
    </taskdef>
    <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
        <classpath refid="catalina-ant-classpath"/>
    </taskdef>
    <taskdef name="list" classname="org.apache.catalina.ant.ListTask">
        <classpath refid="catalina-ant-classpath"/>
    </taskdef>
    <taskdef name="start" classname="org.apache.catalina.ant.StartTask">
        <classpath refid="catalina-ant-classpath"/>
    </taskdef>
    <taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
        <classpath refid="catalina-ant-classpath"/>
    </taskdef>

    <target name="install" description="Install application in Tomcat">
        <install url="${tomcat.manager.url}"
                 username="${tomcat.manager.username}"
                 password="${tomcat.manager.password}"
                 path="/${name}"
                 war="${name}"/>
    </target>

    <target name="reload" description="Reload application in Tomcat">
        <reload url="${tomcat.manager.url}"
                 username="${tomcat.manager.username}"
                 password="${tomcat.manager.password}"
                 path="/${name}"/>
    </target>

    <target name="start" description="Start Tomcat application">
        <start url="${tomcat.manager.url}"
                 username="${tomcat.manager.username}"
                 password="${tomcat.manager.password}"
                 path="/${name}"/>
    </target>

    <target name="stop" description="Stop Tomcat application">
        <stop url="${tomcat.manager.url}"
                 username="${tomcat.manager.username}"
                 password="${tomcat.manager.password}"
                 path="/${name}"/>
    </target>

    <target name="list" description="List Tomcat applications">
        <list url="${tomcat.manager.url}"
                 username="${tomcat.manager.username}"
                 password="${tomcat.manager.password}"/>
    </target>

<!-- End Tomcat tasks -->

</project>

6. 아래의 build.properties를 본인의 환경에 맞게 수정하여 프로젝트의 root 디렉토리에
위치시킨다.

# Ant properties for building the springapp

appserver.home=${user.home}/apache-tomcat-6.0.14
# for Tomcat 5 use $appserver.home}/server/lib
# for Tomcat 6 use $appserver.home}/lib
appserver.lib=${appserver.home}/lib

deploy.path=${appserver.home}/webapps

project.home=K:/myPrj/springapp/

tomcat.manager.url=http://localhost:8080/manager
tomcat.manager.username=tomcat
tomcat.manager.password=s3cret

7. build.xml을 실행하여 에러여부를 확인한다.

$ ant
Buildfile: build.xml

usage:
     [echo]
     [echo] springapp build file
     [echo] -----------------------------------
     [echo]
     [echo] Available targets are:
     [echo]
     [echo] build     --> Build the application
     [echo] deploy    --> Deploy application as directory
     [echo] deploywar --> Deploy application as a WAR file
     [echo] install   --> Install application in Tomcat
     [echo] reload    --> Reload application in Tomcat
     [echo] start     --> Start Tomcat application
     [echo] stop      --> Stop Tomcat application
     [echo] list      --> List Tomcat applications
     [echo]

BUILD SUCCESSFUL
Total time: 2 seconds

8. deploy나 deploywar를 실행한다.

9. tomcat을 기동한후에 아래 페이지를 입력한다.
http://localhost:8080/springapp/index.jsp


여기까지 jsp실행을 위한 환경 완료됨




 

'개발 > 스프링' 카테고리의 다른 글

스프링 tutorial (6)  (0) 2008.07.26
스프링 tutorial (5)  (0) 2008.07.25
스프링 tutorial (4)  (0) 2008.07.17
스프링 tutorial (3)  (0) 2008.07.17
스프링 tutorial (2)  (0) 2008.07.16
Posted by 무혹
,

용어설명

개발 2008. 6. 30. 09:14

개발관련하여 용어도 많다.
난 기억력도 안 좋아서 틈나는대로, 혹은 필요한대로 정리하자.
필요한 용어설명은 사실 텀즈에서 다 찾을수 있지만.

1.EA 기반 ISP 수행을 위한 프로젝트 구성방안

2. BPR (Business Process Reengineering) : 업무프로세스재설계

3. EAI
기업내의 컴퓨터 애플리케이션들을 현대화하고, 통합하고, 조정하는 것을 목표로 세운 계획, 방법 및 도구 등을
일컫는 비즈니스 컴퓨팅 용어이다. 대체로, 기업들은 오래 전부터 사용해오는 기존의 응용프로그램들과 데이터베이스를 가지고 있으며,
여기에 기능을 추가하거나, 또는 인터넷, 전자상거래, 엑스트라넷 및 기타 다른 기술들을 이용하는 새로운 애플리케이션으로 바꾸어나가는 동안,
기존의 것들을 계속해서 사용하기 원한다. EAI는 기업의 비즈니스와 애플리케이션의 새롭고 통합적인 시각을 개발하고,
기존의 애플리케이션들이 새로운 시각 내에 어떻게 맞추어지는지를 확인하고, 또 새로운 애플리케이션과 데이터를 추가하는 동안
이미 존재하는 것들을 효과적으로 재 사용할 수 있는 방법을 고안하는 등의 활동을 포함할 수 있다.

객체지향 프로그래밍, 분산처리, CORBA나 COM+와 같은 메시지 브로커 등을 사용한 다중 플랫폼 프로그램 교신,
새로운 목표에 맞추기 위한 ERP의 수정, 공통 데이터베이스를 이용한 기업내의 콘텐츠와 XML로 구현된 데이터 표준의 배포, 미들웨어, 메시지 큐잉,
그리고 기타의 접근방법 등과 같은 방법론들을 포함한다.

이건 거창하게 얘기하지만 내가 경험한 바로는 인터페이스를 맞춰주는 역할을 한다.
서로 인터페이스가 틀린 경우 중간에서 양쪽 송수신에 맞추어서 처리해준다.


4. SI (System Integration)
시스템 구성 요소들을 순차적으로 결합하여 하나의 전체 시스템을 구축하는 과정으
로 일반적인 전산 시스템 개발.

5. SM (System Management)
이미 만들어진 시스템을 유지보수 하는 일.

6.정보 엔트로피

'개발' 카테고리의 다른 글

애자일 컨퍼런스  (0) 2013.11.10
슈퍼 개발자  (0) 2012.11.23
방법론  (0) 2008.06.25
감리  (0) 2008.06.21
프로세스 테일러링  (0) 2008.06.20
Posted by 무혹
,

방법론

개발 2008. 6. 25. 17:02
개발 방법론에는 여러가지가 있다.
전통적인 분석->설계->구현->테스트등을 아직도
많이 사용하는것 같은데, 실제로 SI업체가 진행하는
프로젝트에 가 보면 산출물도 다 여기에 맞추어져 있다.
객체지향 방법론이라고 해도 큰 틀은 동일하다.
본인이 PM으로 개발한다고 하면 마르미를 적용해도 되겠다.
주목받는 SW 개발방법론「비교 분석」, 프로젝트 매니저를 위한 방법론「FAQ 18선」
같은 기사도 있고 시스템 설계단계의 방법론도 있다.
내가 끌리는것은 애자일이다. 혹자는 방법론이 아니라고 하지만, 나는 훌륭한 방법론이면서
가장 합리적인 개발방향이라고 본다. (현재까지는)
공공 프로젝트같은 경우는 감리때문이라도 애자일로 개발하는것은 불가능하겠지.

'개발' 카테고리의 다른 글

슈퍼 개발자  (0) 2012.11.23
용어설명  (0) 2008.06.30
감리  (0) 2008.06.21
프로세스 테일러링  (0) 2008.06.20
실용주의 개발  (0) 2008.06.17
Posted by 무혹
,

감리

개발 2008. 6. 21. 10:14
이전에 프로젝트 참여자로 감리를 받은적은 있지만
PM으로 감리를 받기는 모공사 프로젝트가 첨이었다.
힘들었지만 지금 생각함 나쁘지는 않았던것 같다.

감리기준점검해설서를 미리 알았다면 더 좋은 결과가 있었을까?

흔히 말하는 2가지 사항에 대해서 남긴다. (감리와도 연관있지..)

1. M/M : 한사람이 한달동안(working day 기준) 일하면 1M/M

보통 한달의 working day는 22.43일 기준.
(어디서 봤더라. 토요일 근무 기준이라고 했는데)

2. SPM : 표준 및 절차 메뉴얼 (Standard and Procedure Manual)

프로젝트 수행과정에 필요한 작업표준, 절차를 기술한 것으로
업무 추진시에 중요한 Guide 역할을 함.


'개발' 카테고리의 다른 글

용어설명  (0) 2008.06.30
방법론  (0) 2008.06.25
프로세스 테일러링  (0) 2008.06.20
실용주의 개발  (0) 2008.06.17
오픈소스 라이선스  (0) 2008.06.11
Posted by 무혹
,

프로세스 테일러링

개발 2008. 6. 20. 14:39

테일러링이란 무엇인가?

- 프로젝트의 특성에 따라 각 산출물의 적용여부 및 변경여부를 체크하고 변경시에는
사유와 변경 문서명을 기재하는 작업을 말한다.

 

예전에 모 프로젝트 PM을 할 때 고생한적이 있었다.

프로세스별 문서를 추려서 테일러링을 했다고 하고 감리를 받았는데

테일러링 근거를 내 놓으란다. 실제로 감리기준에 보면 테일러링 근거를 제시해야 한단다.

난 그런게 없었다. 그냥 필요하다고 생각되는 문서는 사용, 아닌 문서는 미사용..

첨부된 문서를 기준으로 근거를 만들어보려고 했지만 결국 최종감리 때까지 되지 않았다.

어떻게 넘어가긴 했지만 힘들었던 프로젝트이다.

또 다른 프로젝트에서 테일러링 근거를 만들라고 하면 잘 만들 수 있을까?

'개발' 카테고리의 다른 글

용어설명  (0) 2008.06.30
방법론  (0) 2008.06.25
감리  (0) 2008.06.21
실용주의 개발  (0) 2008.06.17
오픈소스 라이선스  (0) 2008.06.11
Posted by 무혹
,

실용주의 개발

개발 2008. 6. 17. 13:17
실용주의 개발이라는 주제로 책도 많고 가끔 세미나도 한다.
(보통 한발 늦어서 세미나에 참석못한다.)
애자일이나 실용주의나 좀 더 개발을 편하게 하고 삽질하지
말자는 의미라 보인다.

1. 유용한 책, 사이트 등

오픈소스에 관심많은 개발자 블로그 (유명한 분인것 같다.)
한국스프링사용자모임
사용자 스토리 ( 마이크 콘 지음/한주영,심우곤,송인철 공역, 2006, 인사이트 )
서브버전을 이용한 실용적인 버전관리 (정보문화사)
서브버전 : 실무자가 꼭 알아두어야 할 차세대 버전관리 시스템

2. 이슈관리 시스템

지라, 버그질라, 트랙

3.  task management

Eclipse Mylyn

4. 버전관리 시스템

CVS , suversion HOW-TO(한글), subclipse, subversive,
subversive 이클립스 업데이트, tortoiseSVN

'개발' 카테고리의 다른 글

용어설명  (0) 2008.06.30
방법론  (0) 2008.06.25
감리  (0) 2008.06.21
프로세스 테일러링  (0) 2008.06.20
오픈소스 라이선스  (0) 2008.06.11
Posted by 무혹
,