2013의 게시물 표시

Application mornitoring tool - Spring Insight

[download] http://gopivotal.com/products/pivotal-tc-server [forum] http://forum.spring.io/forum/spring-projects/management/insight 개요 - What is Spring insight? http://www.youtube.com/watch?v=nA4SXDl2EFU http://www.youtube.com/watch?v=nBqSh7nVNzc 어플리케이션 모니터링 도구임. 설치 tcServer? Spring insight는 Pivotal의 tcServer에 내장되어 있다고 하며 tcServer는 Tomcat을 개선하여 기능을 추가한 것이라 함. 여기서 기능은 Spring 어플리케이션의 리로드, 모니터링 도구인 Spring insight 내장이라함.  리로드는 소스 수정후 서버재시작이 없이 반영하여 개발 효율성을 높인 것이라함.  발췌 [ Spring tc Server와 Spring Insight 소개 - Tistory ] tcServer에 내장됬다고 하는 Insight만을 뽑아서 익숙한 Tomcat에 설치하는 방법 tomcat에 설치        1. download            http://gopivotal.com/products/pivotal-tc-server  에 접속하여 간단한 회원가입후          Pivotal tc Server Developer Edition Runtime (zip) 파일을 다운받음        2. 압축을 풀고 아래 파일을 Tomcat이 설치된 폴더로 옮김            [tcServer]/templates/insight/bin/*.jar -> [tomcat]/bin/            [tcServer]/templates/insight/insight   -> [tomcat]/insight            [tcServer]/

How can I make a multipart/form-data POST request using Java?

@see http://stackoverflow.com/questions/1378920/how-can-i-make-a-multipart-form-data-post-request-using-java 1. maven dependancy org.apache.httpcomponents httpcore 4.2.5 org.apache.httpcomponents httpclient 4.2.5 org.apache.httpcomponents httpmime 4.2.5 2. source package sample; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.Charset; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.scheme.PlainSocketFactory; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; import org.apache.http.conn.ssl.SSLSocketFactory; imp

Hot Deploy - 3 ways to save development time ( spring-loaded , JRebel, DCEVM )

이미지
1. Auto Reload Set  "Enabled" to "Auto Reload" This is likely to occur more frequently memory leak, it takes more time to reload. 이 방법은 memory leak 이 더 자주 발생할 가능성이 크고, 리로딩 하는 시간이 더 많이 소요된다. 2. JRebel  Installation JRebel Config Center -> Activation Tab -> Free -> Login -> Install and Activate -> Copy License Code -> Paste license code on eclipse ->   Overview tab -> check JRebel Enabled /Server , Projects  Server Overview -> select "Never publish automatically" on  Publishing tab -> check "Enable JRebel agent" Project Left click -> JRebel -> Add Jebel nature JRebel free license version other than the cost should be paid. The installation process is a little complicated. But first, rather than memory leak may occur JRebel free license 버전이외는 비용지불을 해야 한다.  설치과정이 다소 복잡하다.  memory leak이 발생하지만 1번과 비교할 바는 아니다.  가장 안정된 솔루션 3. spring-loaded  Insta

ESAPI ( XSS, Sql Injection )

OWASP 에 ESAPI는 XSS  및 Sql Injection 방어를 위한 API [link]    https://www.owasp.org/index.php/Main_Page [youtube] http://www.youtube.com/watch?v=suphwAsb-To http://www.youtube.com/watch?v=13O9RyjuB3o http://www.youtube.com/watch?v=_B2kv2mSJhE http://www.youtube.com/watch?v=mMW4fiUI5kQ dependency 추가  org.owasp.esapi esapi 2.0.1     2. ESAPI.properties 파일을 만들어 아래 내용을 추가한 후 classpath에 넣는다. Authenticator.UsernameParameterName=userName Authenticator.PasswordParameterName=password ESAPI.Authenticator=com.esapi.authenticator.CustomAuthenticator Authenticator.IdleTimeoutDuration=100000 Authenticator.AbsoluteTimeoutDuration=100000   Test code import org.owasp.esapi.ESAPI; import org.owasp.esapi.Encoder; import org.owasp.esapi.codecs.Codec; import org.owasp.esapi.codecs.OracleCodec; public class EsapiTest { public static void main(String[] args) { String a = "<script>alert('dddd')</script>"; String b = ESAPI.encoder().encod

GZipUtils- gzip을 통한 압축시 charset처리

import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.Reader; import java.io.Writer; import net.sf.jazzlib.GZIPInputStream; import net.sf.jazzlib.GZIPOutputStream; public class GZipUtils { /** * 지정된 폴더를 Zip 파일로 압축한다. * * @param sourceFileName * - 압축 대상 파일 * @param outputFileName * - 확장자가 gz * @param encoding 파일의 encoding EUC-KR, UTF-8 등.. * @throws Exception */ public static void zip(String sourceFileName, String outputFileName,String encoding) throws Exception { Reader reader = null; Writer writer = null; try { InputStream inputStream = new FileInputStream(sourceFileName); reader = new BufferedReader(new InputStreamReader(inputStrea

Open Source로 구성된 Deploy Management System-2

해결 과제들 trunk -> tag 이관 svn trunk에서 tag로 이관하는 작업은 비교적 쉽게 구현 가능 - svnkit.  Build svn tag로 이관된 소스를 build하는 것도 maven + jenkins 조합으로 완료 deployment build된 resource -> 개발 및 운영서버에 배포는 고려할 사항이 많이 존재. 과제 1. 다양한 종류  java파일 -> 컴파일된 class를 배포해야 함 공통 lib jar -> 각각의 서버에 , 각 업무별 WEB-INF/lib에 배포 exclude -> .svn, .classpath, pom.xml 과 같은 파일  include -> *.class, *.xml  2. 다양한 Target  다중 서버  다중 WAR   어떻게 해야 할까? <?xml version="1.0" encoding="UTF-8"?> <project default="svn" basedir="D:/workspace"> <svn rootUrl="svn://localhost/test" srcRootPath="/trunk" targetRootPath="/tag/1.0" userName="airlee" password="1111" startRevision="-1" endRevision="0" /> <target name="svn" > <ftp host="localhost" port="21" username=&q

Charset 변환 ( EUC-KR, UTF-8, MS949, CP933 )

1. 개요 국제화를 고려한 사이트이여야 하나 국내는 반드시 EUC-KR을 사용해야 함에 따라 아래 문제를 해결해야 함 1) EUC-KR을 UTF-8, MS949, CP933 으로 변환해야 한다.  2) 변환후 글자는 깨질수 있으나 byte length는 변하지 않아야 한다.  2. 변환 유틸 import java.io.ByteArrayOutputStream; import java.io.IOException; public class EncodingTest3 { static String convert(String str, String encoding) throws IOException { ByteArrayOutputStream requestOutputStream = new ByteArrayOutputStream(); requestOutputStream.write(str.getBytes(encoding)); return requestOutputStream.toString(encoding); } static String testEncoding(String str, String encoding) throws IOException { String result = convert(str, encoding); System.out.println(result + "=>encoding=" + encoding + ",length=(" + result.getBytes(encoding).length + ")"); return result; } public static void main(String args[]) throws Exception { System.out.println("==== file.encoding===" + System.getProperty("file.encoding")); String

JBoss WAS DataSource(jndi) 설정

JBoss WAS DataSource 설정 ~/conf/login-config.xml ~/deploy/oracle-ds.xml 두군데서 설정. login-config.xml 의 패스워드가 암호화 # java -cp client/jboss-logging-spi.jar:lib/jbosssx.jar org.jboss.resource.security.SecureIdentityLoginModule tiger Encoded password: -170dd0fbd8c13748 (참고URL http://cafe.naver.com/opensourcesw/11  )

Open Source로 구성된 Deploy Management System

이미지
해결과제   오픈 후 운영시점에 다수의 개발자가 유지보수를 한다.         (  모든소스를 Build & deploy(통배포) 할수 없게 된다. 배포 되면 않되는 소스를 commit           하지 않았다는 보장을 받을 수 없기에..)     상용 배포관리 시스템(clear case, harvest..)을 도입할 만한 예산이 없다. [그림 - deploy process] 배포절차 1. 이슈등록 설치된 Issue Management System인 jTrac 이나 redmine의 url로 접속하여 직접 이슈를 등록한다.  등록된 이슈는 Uniq한 이슈번호(Issue#) 가 생성된다. 이슈번호는 최종 배포시까지 적용될 소스들의 key word가 된다.   2. commit 개발자는 소스를 변경하고 svn에 commit 한다.  이때 commit comment에 이슈번호가 반드시 포함되도록, 입력한 이슈번호가 이슈관리 시스템에 등록된 번호인지 확인하는  설정이 있어야 한다. (이는  svn서버의 hook 디렉토리의 pre-commit 스크립트를 작성하면 가능하다)   또한, eclipse에는 mylyn plugin이 설치되어 있어야 한다. mylyn plugin은 자신에게 할당된 이슈리스트를 조회하고 적용할 이슈를 선택 할수 있게해준다.  commit시에 comment에 현재 선택한 이슈에 대한 이슈번호를 자동으로 추가해준다 현재 redmine은 plugin이 있으나 jTrac은 제작중이라 함. (기능은 redmine이 월등하게 앞서지만 jTrac보다 설치가 복잡하고 ruby on rail 이라는 생소한 환경에 익숙해야 한다. ) 3. 개발배포 이슈관리시스템의 리스트에서 개발배포를 실행(jTrac- remote jenkins api를 이용, redmine - jenkins_api_client를 이용)한다. 이부분은 이슈관리시스템customizing이 필요함 

Spring applicationContext hierarchy

[참고사이트] http://forum.spring.io/forum/spring-projects/container/124291-applicationcontext-hierarchy http://stackoverflow.com/questions/5132604/why-use-spring-applicationcontext-hierarchies Spring의 applicationContext는 다음과 같은 계층구조를 갖는다. ApplicationContext   :           Bean(ContextLoaderListerer-공유되는 bean)                                                                  ↗             ↖ WebApplicationContext:       dispatcherServlet-1       dispatchServlet-2 WebApplicationContext에서 ApplicationContext는 접근가능 그 반대는 불가능 ApplicationContext에서 WebApplicatonContext를 접근할려면 ServletContext에서 가져와야 한다. -> WebApplicationContext에는 자신의 context에 ApplicationContext를 parent로 등록하고 이를 ServletContext에 저장하기 때문. Why ? - 여러개의 dispatcherServlet을 구성하였을때 서로간에 독립성 유지 - 실제적인 모습은 하나의 war에 다수의 contextPath가 존재하도록 구성하고자 할때