노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.



Spring Boot와 Vaadin의 full stack 어플리케이션 ( JPA, PostgreSQL )


- Vaadin은 무멋인가?



1. 프로젝트 생성 ( start.spring.io , SPRING INITIALIZR )후에 zip 해제 하기


Maven Project , 1.4.4 ( 1.5.x는 에러가 발생 )

Dependencies 선택 : Web, Vaadin, JPA, PostgreSQL

Artifact : todolistvaading


2. 프로젝트 불러오기


Eclipse에서 Import -> Project from Folder or Archive

Project(우측 마우스) ->Run AS -> Maven clean, Maven Install 실행

Project(우측 마우스) -> Maven -> Update Project선택


3. 생성할 예제



4. UI 클래스 생성하기


package com.example;


import com.vaadin.annotation.Theme;

import com.vaadin.server.VaadinRequest;

import com.vaadin.spring.annotation.SpringUI;

import com.vaadin.ui.UI;


@SpringUI
@Theme("valo")
public class TodoUI extends UI {


private VerticalLayout layout;


    @Override
    protected void init(VaadinRequest vaadinRequest) {


// 화면 구성 하기

setupLayout();

addHeader();

addForm();

addTodoList();

addActionButton();

}

}


private void setupLayout(){
layout = new VerticalLayout();
    setContent(layout);
}

private void addHeader(){
Label header = new Label("TODO");

layout.addComponent(header);
}

private void addForm(){
HorizontalLayout formLayout = new HorizontalLayout();

TextField taskField = new TextField();

Button addButton = new Button("Add"); // 나중에 icon으로 변경


formLayout.addComponent(taskField, addButton);

layout.addComponent(formLayout);
}

private void addTodoList(){

//@Autowired TodoList todoList 추가
layout.addComponent(todoList);
}

@Component
public class TodoList extends VerticalLayout {

}

private void addActionButton() {

Button deleteButton = new Button("Delete completed");

layout.addComponent(deleteButton);

}



원문 : 동영상 강좌

https://www.youtube.com/watch?v=tnVKN25dIm8


-- 추가 꾸미기

private void setupLayout() {
...
layout.setSpacing(true);
layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
...
}

private void addHeader() {
...
header.addStyleName(ValoTheme.LABEL_H1);
header.setSizeUndefined();
...
}

private void addForm() {
...
formLayout.setSpacing(true);
formLayout.setWidth("80%");
}

private void addTodoList() {
...
todoList.setWidth("80%");
}
private void addActionButton() {
...
deleteButton.addClickListener(click->todoList.deleteCompleted());
}


Todo.java

TodoChangeListener.java

TodoLayout.java

TodoList.java

TodoRepository.java

TodoUI.java

TolistvaadinApplication.java



* Vaadin Login Example

https://examples.javacodegeeks.com/enterprise-java/vaadin/vaadin-login-example/




블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Maven을 윈도우10에 설치하기


Apache Maven은 소프트웨어 프로젝트 관리 툴이다. POM(project object model)의 개념 위에서, Maven은 project의 build와 보고서 만들기나 문서화를 정보의 중앙관리를 통해 관리할 수 있다.


1. 다운로드 하기 & unzip으로 풀어 놓기


http://maven.apache.org/download.cgi 에서 Binary zip archive를 받아서, 원하는 위치에 풀어 놓는다.



2.  고급 시스템 설정 -> 환경변수


1) 시스템 변수에 MAVEN_HOME을 추가하고 설치된 경로로 설정

2) 시스템 변수 Path에 %MAVEN_HOME%\bin을 추가 한다.


* Maven 설치 이전에 Java가 설치되어 있어야 하며, JAVA_HOME도 환경 변수에 등록이 되어 있어야 한다.


3. CMD를 통해서 정상 설치를 확인

> mvn -version

> mvn -help


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Jenkins 설치, 빌드설정,Port변경



젠킨스는 규모에 관계 없이 대단한 (자동) 빌드  를 만들어 준다.



선도적인 오픈 소스 자동화 서버인 젠킨스는 수백 가지의 플러그인을 모든 프로젝트의 빌드하는 것과 배포하는 것 및 자동화 하는 것을 하도록 제공한다.



젠킨스는 자바 Runtime 환경이 설치된 곳에서 독립적으로 실행되고 운영된다.


- 최소 Java 7, 권장 Java 8

- 512 MB RAM이상을 권장



1. 다운로드 ( https://jenkins.io/ )


- 9가지 종류에서 필요한 것을 선택




2. 실행

$ java -jar Jenkins.jar



3. 브라우저를 통한 연결


http://localhost:8080



* Windows 설치

- msi 실행



- 완료후 자동 접속 : 설치 폴더의 initialAdminPassword를 참조



plugin 설치 : Install suggested plugins 선택




- 설치 화면



- 관리자 계정 생성





- 설치 완료 메시지




* 접속 화



- 설치가 완료되면, Pipeline을 생성해야 한다.

Pipeline은 Code로써 Jenkinsfile로 쓰여진다.


Jenkinsfile (Declarative Pipeline)
pipeline {
    agent any 

    stages {
        stage('Build') { 
            steps { 
                sh 'make' 
            }
        }
        stage('Test'){
            steps {
                sh 'make check'
                junit 'reports/**/*.xml' 
            }
        }
        stage('Deploy') {
            steps {
                sh 'make publish'
            }
        }
    }
}

- Jenkins 글로벌 설정 : JDK(설치본 사용) , Ant(자동 설치 선택)






* 2부 Jenkins + SVN + Ant Build 구성하기

http://pseg.or.kr/pseg/index.php?mid=inforeview&document_srl=7617&listStyle=viewer


- 소스코드 관리 설정 ( Repository URL, Credentials ) -> 빌드 유발(Poll SCM) -> 빌드 (Ant)등을 설정 한다.

- #9 (빌드 순번)을 선택후에 해당 화면에서 Console Output를 선택하면, 자동 Build결과를 확인 할 수 있다. ( Default 위치는 c:\Jenkins\jobs\[Item이름]\builds\[빌드순번]\log 파일 )




* Jenkins port 변경


- 수정 파일 위치 : [설치폴더]\Jenkins.xml ( httpPort를 변경 )





- 서비스 재시작 : 제어판->관리도구->서비스->Jenkins


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


60초안에 리눅스 성능 분석하기


리눅스 서버에 성능 문제로 접속을 한다면, 최초 1분안에 어떤 부분을 체크 하나요?

You login to a Linux server with a performance issue: what do you check in the first minute?


시스템 리소스 사용량의 정도와 실행중인 프로그램을 아래 10개의 명령어를 통해서 정보를 얻을 수  있다.

uptime
dmesg | tail
vmstat 1
mpstat -P ALL 1
pidstat 1
iostat -xz 1
free -m
sar -n DEV 1
sar -n TCP,ETCP 1
top


1. uptime

$ uptime
 23:51:26 up 21:31,  1 user,  load average: 30.02, 26.43, 19.02

This is a quick way to view the load averages, which indicate the number of tasks (processes) wanting to run.


2. dmesg | tail

$ dmesg | tail
[1880957.563150] perl invoked oom-killer: gfp_mask=0x280da, order=0, oom_score_adj=0
[...]
[1880957.563400] Out of memory: Kill process 18694 (perl) score 246 or sacrifice child
[1880957.563408] Killed process 18694 (perl) total-vm:1972392kB, anon-rss:1953348kB, file-rss:0kB
[2320864.954447] TCP: Possible SYN flooding on port 7001. Dropping request.  Check SNMP counters.

This views the last 10 system messages, if there are any.

3. vmstat 1

$ vmstat 1
procs ---------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
34  0    0 200889792  73708 591828    0    0     0     5    6   10 96  1  3  0  0
32  0    0 200889920  73708 591860    0    0     0   592 13284 4282 98  1  1  0  0
32  0    0 200890112  73708 591860    0    0     0     0 9501 2154 99  1  0  0  0
32  0    0 200889568  73712 591856    0    0     0    48 11900 2459 99  0  0  0  0
32  0    0 200890208  73712 591860    0    0     0     0 15898 4840 98  1  1  0  0
^C

Short for virtual memory stat, vmstat(8) is a commonly available tool (first created for BSD decades ago).

4. mpstat -P ALL 1

$ mpstat -P ALL 1
Linux 3.13.0-49-generic (titanclusters-xxxxx)  07/14/2015  _x86_64_ (32 CPU)

07:38:49 PM  CPU   %usr  %nice   %sys %iowait   %irq  %soft  %steal  %guest  %gnice  %idle
07:38:50 PM  all  98.47   0.00   0.75    0.00   0.00   0.00    0.00    0.00    0.00   0.78
07:38:50 PM    0  96.04   0.00   2.97    0.00   0.00   0.00    0.00    0.00    0.00   0.99
07:38:50 PM    1  97.00   0.00   1.00    0.00   0.00   0.00    0.00    0.00    0.00   2.00
07:38:50 PM    2  98.00   0.00   1.00    0.00   0.00   0.00    0.00    0.00    0.00   1.00
07:38:50 PM    3  96.97   0.00   0.00    0.00   0.00   0.00    0.00    0.00    0.00   3.03
[...]

This command prints CPU time breakdowns per CPU, which can be used to check for an imbalance.

5. pidstat 1

$ pidstat 1
Linux 3.13.0-49-generic (titanclusters-xxxxx)  07/14/2015    _x86_64_    (32 CPU)

07:41:02 PM   UID       PID    %usr %system  %guest    %CPU   CPU  Command
07:41:03 PM     0         9    0.00    0.94    0.00    0.94     1  rcuos/0
07:41:03 PM     0      4214    5.66    5.66    0.00   11.32    15  mesos-slave
07:41:03 PM     0      4354    0.94    0.94    0.00    1.89     8  java
07:41:03 PM     0      6521 1596.23    1.89    0.00 1598.11    27  java
07:41:03 PM     0      6564 1571.70    7.55    0.00 1579.25    28  java
07:41:03 PM 60004     60154    0.94    4.72    0.00    5.66     9  pidstat

07:41:03 PM   UID       PID    %usr %system  %guest    %CPU   CPU  Command
07:41:04 PM     0      4214    6.00    2.00    0.00    8.00    15  mesos-slave
07:41:04 PM     0      6521 1590.00    1.00    0.00 1591.00    27  java
07:41:04 PM     0      6564 1573.00   10.00    0.00 1583.00    28  java
07:41:04 PM   108      6718    1.00    0.00    0.00    1.00     0  snmp-pass
07:41:04 PM 60004     60154    1.00    4.00    0.00    5.00     9  pidstat
^C

Pidstat is a little like top’s per-process summary, but prints a rolling summary instead of clearing the screen.


6. iostat -xz 1

$ iostat -xz 1
Linux 3.13.0-49-generic (titanclusters-xxxxx)  07/14/2015  _x86_64_ (32 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          73.96    0.00    3.73    0.03    0.06   22.21

Device:   rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
xvda        0.00     0.23    0.21    0.18     4.52     2.08    34.37     0.00    9.98   13.80    5.42   2.44   0.09
xvdb        0.01     0.00    1.02    8.94   127.97   598.53   145.79     0.00    0.43    1.78    0.28   0.25   0.25
xvdc        0.01     0.00    1.02    8.86   127.79   595.94   146.50     0.00    0.45    1.82    0.30   0.27   0.26
dm-0        0.00     0.00    0.69    2.32    10.47    31.69    28.01     0.01    3.23    0.71    3.98   0.13   0.04
dm-1        0.00     0.00    0.00    0.94     0.01     3.78     8.00     0.33  345.84    0.04  346.81   0.01   0.00
dm-2        0.00     0.00    0.09    0.07     1.35     0.36    22.50     0.00    2.55    0.23    5.62   1.78   0.03
[...]
^C

This is a great tool for understanding block devices (disks), both the workload applied and the resulting performance.

7. free -m

$ free -m
             total       used       free     shared    buffers     cached
Mem:        245998      24545     221453         83         59        541
-/+ buffers/cache:      23944     222053
Swap:            0          0          0

The right two columns show:

  • buffers: For the buffer cache, used for block device I/O.
  • cached: For the page cache, used by file systems.

8. sar -n DEV 1

$ sar -n DEV 1
Linux 3.13.0-49-generic (titanclusters-xxxxx)  07/14/2015     _x86_64_    (32 CPU)

12:16:48 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
12:16:49 AM      eth0  18763.00   5032.00  20686.42    478.30      0.00      0.00      0.00      0.00
12:16:49 AM        lo     14.00     14.00      1.36      1.36      0.00      0.00      0.00      0.00
12:16:49 AM   docker0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

12:16:49 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
12:16:50 AM      eth0  19763.00   5101.00  21999.10    482.56      0.00      0.00      0.00      0.00
12:16:50 AM        lo     20.00     20.00      3.25      3.25      0.00      0.00      0.00      0.00
12:16:50 AM   docker0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
^C
Use this tool to check network interface throughput: rxkB/s and txkB/s, as a measure of workload, and also to check if any limit has been reached.

9. sar -n TCP,ETCP 1

$ sar -n TCP,ETCP 1
Linux 3.13.0-49-generic (titanclusters-xxxxx)  07/14/2015    _x86_64_    (32 CPU)

12:17:19 AM  active/s passive/s    iseg/s    oseg/s
12:17:20 AM      1.00      0.00  10233.00  18846.00

12:17:19 AM  atmptf/s  estres/s retrans/s isegerr/s   orsts/s
12:17:20 AM      0.00      0.00      0.00      0.00      0.00

12:17:20 AM  active/s passive/s    iseg/s    oseg/s
12:17:21 AM      1.00      0.00   8359.00   6039.00

12:17:20 AM  atmptf/s  estres/s retrans/s isegerr/s   orsts/s
12:17:21 AM      0.00      0.00      0.00      0.00      0.00
^C
This is a summarized view of some key TCP metrics. These include:
  • active/s: Number of locally-initiated TCP connections per second (e.g., via connect()).
  • passive/s: Number of remotely-initiated TCP connections per second (e.g., via accept()).
  • retrans/s: Number of TCP retransmits per second.
 

10. top

$ top
top - 00:15:40 up 21:56,  1 user,  load average: 31.09, 29.87, 29.92
Tasks: 871 total,   1 running, 868 sleeping,   0 stopped,   2 zombie
%Cpu(s): 96.8 us,  0.4 sy,  0.0 ni,  2.7 id,  0.1 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:  25190241+total, 24921688 used, 22698073+free,    60448 buffers
KiB Swap:        0 total,        0 used,        0 free.   554208 cached Mem

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 20248 root      20   0  0.227t 0.012t  18748 S  3090  5.2  29812:58 java
  4213 root      20   0 2722544  64640  44232 S  23.5  0.0 233:35.37 mesos-slave
 66128 titancl+  20   0   24344   2332   1172 R   1.0  0.0   0:00.07 top
  5235 root      20   0 38.227g 547004  49996 S   0.7  0.2   2:02.74 java
  4299 root      20   0 20.015g 2.682g  16836 S   0.3  1.1  33:14.42 java
     1 root      20   0   33620   2920   1496 S   0.0  0.0   0:03.82 init
     2 root      20   0       0      0      0 S   0.0  0.0   0:00.02 kthreadd
     3 root      20   0       0      0      0 S   0.0  0.0   0:05.35 ksoftirqd/0
     5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H
     6 root      20   0       0      0      0 S   0.0  0.0   0:06.94 kworker/u256:0
     8 root      20   0       0      0      0 S   0.0  0.0   2:38.05 rcu_sched

The top command includes many of the metrics we checked earlier. It can be handy to run it to see if anything looks wildly different from the earlier commands, which would indicate that load is variable.


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.

 

톰캣 버전과 지원가능한 서블릿 버전 목록

Servlet

JSP Spec

Tomcat

Min. Java

3.0

2.2

7.0.x

1.6

2.5

2.1

6.0.x

1.5

2.4

2

5.5.x

1.4

2.3

1.2

4.1.x

1.3

2.2

1.1

3.3.x

1.1


http://help.eclipse.org/kepler/index.jsp


* Web application overview

The Web development environment provides the tools you need to develop Web applications as defined in the Sun Microsystems Java™ Servlet 2.3 Specification and the Sun Microsystems JSP 1.2 Specification. Web applications can be simple (consisting of only static Web pages) or they can be more advanced and include JavaServer Pages (JSP) files and Java servlets.

웹 개발 환경은 Sun Microsystems Java ™ Servlet 2.3 사양 및 Sun Microsystems JSP 1.2 사양에 정의 된대로 웹 응용 프로그램을 개발하는 데 필요한 도구를 제공 합니다. 웹 응용 프로그램은 단순한 웹 페이지 (정적 웹 페이지만으로 구성 될 수 있음) 또는 Java 웹 페이지 (JavaServer Pages) 파일 및 Java 서블릿을 포함하는 고급 기능을 제공 할 수 있습니다.


* Web projects

Web projects hold all of the Web resources that are created and used when developing your Web application. The first step to creating or importing a Web application is to create either a static or a dynamic Web project. Static Web projects are meant to contain only simple Web site resources, such as HTML files. Dynamic Web projects are used to structure Web applications that will use more complicated, dynamic Web technologies, such as JavaServer Pages files, and possibly data access resources.

웹 프로젝트는 웹 응용 프로그램을 개발할 때 만들어지고 사용되는 모든 웹 자원을 보유합니다. 웹 응용 프로그램을 만들거나 가져 오는 첫 번째 단계는 정적 또는 동적 웹 프로젝트를 만드는 것입니다. 정적 웹 프로젝트에는 HTML 파일과 같은 간단한 웹 사이트 리소스 만 포함됩니다. 동적 웹 프로젝트는 JavaServer Pages 파일 및 데이터 액세스 리소스와 같이보다 복잡하고 동적 인 웹 기술을 사용하는 웹 응용 프로그램을 구조화하는 데 사용됩니다.


* Dynamic Web projects and applications

There are two types of Web projects: dynamic and static. Dynamic web projects can contain dynamic Java EE resources such as servlets, JSP files, filters, and associated metadata, in addition to static resources such as images and HTML files. Static web projects only contains static resources. When you create Web projects, you can include cascading style sheets and JSP tag libraries (for dynamic Web projects), so that you can begin development with a richer set of project resources.

웹 프로젝트에는 동적 및 정적의 두 가지 유형이 있습니다. 동적 웹 프로젝트에는 이미지 및 HTML 파일과 같은 정적 리소스 이외에 서블릿, JSP 파일, 필터 및 관련 메타 데이터와 같은 동적 Java EE 리소스가 포함될 수 있습니다. 정적 웹 프로젝트에는 정적 리소스 만 포함됩니다. 웹 프로젝트를 생성 할 때 동적 웹 프로젝트를위한 CSS 스타일 라이브러리와 CSS 태그 라이브러리를 포함 할 수 있으므로 더 많은 프로젝트 리소스 세트로 개발을 시작할 수 있습니다.

블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.
Log4j 사용하기 ( in MVC controller )  

1. Log4j Library 프로젝트에 추가하기

1) Log4j-1.x.x.jar를 libray에 복사

2) Maven을 사용해서 자동 다운로드 ,  pom.xml
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>
2. log4j.properties구성
 # LOG4J configuration
log4j.rootLogger=INFO, console, file

# Console Logger
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%p] %d %c %x - %m%n

# File Logger
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.File=${catalina.home}/logs/oes
log4j.appender.file.DatePattern='-'yyyy-MM-dd'.log'
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%p] %d %c %x - %m%n
  3. 호출(사용법)
// Controller
public class AAAController 
{
    private Logger logger = Logger.getLogger(AAAController.class);
    public loginAction()
    {
        logger.info( String.format("name[%s]",new Object[] {name} );
    }
}
출처 :  http://zjhzxhz.com/2014/06/integrate-spring-mvc-with-log4j/


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.



Workingset를 Eclipse에 추가 하기


1. eclipse설정를 통해서

1) workspace
2) Open Perspective, Show View
3) Project Explorer부분에  Package Explorer를 추가 하기


참조 : http://sessionk.tistory.com/16



2. WorkingSet 추가하는 과정

0. Show View - Package Explorer


1) Package Explorer에서 Top Level Element를 Working Sets로 변경


2) Configure Working Sets로 추가 하기

참조 : http://whiteship.tistory.com/1441


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Java,  Ip Address 가져오기


- 다중 Network Interface를 갖고 있는 경우에 생기는  문제 


1. 일반적인 접근

  InetAddress ip;
  String hostname;
  String ipString ;
  
  ip = InetAddress.getLocalHost();
  hostname = ip.getHostName();
  ipString = ip.toString();

 System.out.println("is contain?  " + ipString.contains("192.168.") );


2. 다중 Network Interface 찾기

public class GetIpAddress {

    public static void main(String args[]) throws SocketException  {

    	System.out.println( "isSame = " + isSame("192.168.0.13") ); 
    	
    }

    static boolean isSame(String checkIp) throws SocketException {
    	
    	String interfaceIp=null;

    	// NetworkInterface.getNetoworkInterfaces()
        Enumeration nets = NetworkInterface.getNetworkInterfaces();
        
        for (NetworkInterface netint : Collections.list(nets)) {
            interfaceIp = displayInterfaceInformation(netint);
            if ( interfaceIp != null ) {
            	if( interfaceIp.contains(checkIp) )
            		return true;
            }
        }
        return false;
    }

    // NetworkInterface : getDisplayName(), getInetAddresses()
    static String displayInterfaceInformation(NetworkInterface netint) throws SocketException {

    	System.out.printf("Display name: %s \n", netint.getDisplayName());
    	//System.out.printf("Name: %s\n", netint.getName());

        Enumeration inetAddresses = netint.getInetAddresses();
        for (InetAddress inetAddress : Collections.list(inetAddresses)) {
        	
        	// only ipv4
        	if ( inetAddress instanceof Inet4Address ) {
        		System.out.printf("InetAddress: %s\n", inetAddress);
        		return inetAddress.toString();
        	}
        }
        return null;
     }

}


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


awk print



':'를 구분자로 첫번째 파일명을 출력

$ file * | grep HTML | grep -v jpg | awk -F: '{print $1}'



print문장에 명령어를 추가하고 shell로 저장

$ file * | grep HTML | grep -v jpg | awk -F: '{print "mv " $1 " " $1".old" }' > a.sh



참조 : http://www.commandlinefu.com/commands/view/1138/ps-ef-grep-process-grep-v-grep-awk-print-2-xargs-kill-9


$ ps -ef | grep PROCESS | grep -v grep | awk '{system "kill -9" $2}


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Upload Fake Image(가짜 이미지, 피싱스크립트) 의 검증


단순히 업로드 파일의 확장자로 구분되지 않는 phishing(피싱)파일을 제거하기 위해서 사용 가능


수천가지 다른 종류의 file type으로 부터 문자열,메타정보와 종류를 판별하는 프로젝트

https://tika.apache.org/ , a content analysis toolkit.

tika-app1.14.jar Library를 다운로드 ( https://tika.apache.org/download.html )


예제 소스

import java.io.File; import java.io.FileInputStream; import java.io.IOException; import org.apache.tika.Tika; public class TestMain { public static void main(String[] args) throws Exception { //File f = new File("fakeTest.png"); // text/html //File f = new File("jpgTest.jpg"); // image/jpeg File f = new File("pngTest.png"); // image/png //File f = new File("gifTest.gif"); // image/gif System.out.println( f.toString()); System.out.println( f.getAbsolutePath() ); String allowFileExt = "image/jpg;image/jpeg;image/png;image/gif;"; if ( f.isFile() ) { Tika tika = new Tika(); try { String detectedType = tika.detect( new FileInputStream(f) ); System.out.println("Type : " + detectedType ); if (allowFileExt.indexOf(detectedType) == -1) { throw new Exception("Use only Type : JPG, JPEG, PNG, GIF"); } } catch (IOException e) { e.printStackTrace(); } } else { System.out.println("-not-" ); } } }




'Web Tech. > Spring Framework' 카테고리의 다른 글

Java,  Ip Address 가져오기  (0) 2017.02.07
awk print  (0) 2017.02.01
2개의 war 비교하기  (0) 2017.01.25
2017년 1월 스타트업에서 구인할때 주로 원하는 개발 기술  (0) 2017.01.24
HMAC SHA-256 이해  (0) 2017.01.24
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.



2개의 war 비교하기




1. war 상태에서 비교 하기


$ diff 01.war 02.war
Binary files 01.war and 02.war differ



2. war 풀기 ( 특정 디렉토리로 이동해서 )


$ mkdir 01
$ cp 01.war 01
$ cd 01
$ jar xvf 01.war
 ▒▒▒▒▒▒: META-INF/MANIFEST.MF



3. Directory 비교하기


$ diff -r 01 02
* diff 결과

<는 a(file1)에만 있는 내용, >는 b(file2)에만 있는 내용을 의미




4. class를 decompile후에 Directory 비교 하기

하위 디렉토리의 class파일(-r **/*.class)을 원하는 디렉토리(-d .)에 확장자 .java( -s java)로 풀기
$ jad -d . -s java -r **/*.class 



* Ubuntu Java/Jar 설치하기

- 특정 버젼 설치하기
$ sudo apt-get install openjdk-7-jdk
- 가능 버젼 검색하기
$ apt-cache search jdk

http://stackoverflow.com/questions/14788345/how-to-install-jdk-on-ubuntu-linux



* Vim VI에서 ^M 지우기

:%s/^M$//g

* 주의! 그런데 위의 정규식에서 빨간색으로 된 ^M 이라는 문자열을 직접 글자 그대로 타이핑하면 안됩니다. 반드시 키보드의 Ctrl+V 키와 Ctrl+M 키를 눌러서 간접적으로 입력해야 합니다.


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.





2017년 1월 스타트업에서 구인(채용)시 원하는 개발관련 기술





개발 언어, DBMS/noSQL, Cloud등의 서비스 Flatform, Software등을 살펴 보면,




1th 그룹 : Java, NodeJS, Android, Python, JQuery, Amazon


2nd 그룹 : Redis, AWS, AngularJs, iOS, PostgreSQL, Nginx, Django , MongoDB




최신 기술의 동향일 수도 있지만, 이직 또는 구직을 위해서 학습을 해야 한다면, 참고 할 만 하다.





* 자료는 개발자 채용 정보 제공 사이트 rocketpunch.com의 


인기 채용 공고 40건 참조



* 채용시 사용된 keyword 리스트 추출




php
mysql
linux
android
git
kotlin
gcm/fcm
python
mssql
mongodb
amazon aws
ios
objective-c
swift
github
python
c++
django
python
postgresql
amazon aws
html5/css3/javascript
android
java
mysql
python
c++
c#
java
aws
cloud-server
dbms
node.js
postgresql
redis
nginx
react.js
hapi.js
amazon aws
restful-api
angularJS
jQuery
html5/css3/javascript
android
firebase
custom ui component
restful-api
asp.net
c#
html 
css
javascript
bootstrap
angularjs
node.js
php
mongodb
redis
프론트엔드 주요 기술
javascript
jquery
ajax
angularjs
wbesocket
html5/css3/javascript
android
ios
java
xcode
node.js
coffeescript
mysql
amazon ec2
amazon es3
android
ios
node.js
php
python
java
ios
php
mysql
apache
python
android
redis
node.js
jquery
msa
node.js
java
restful-api
linux
nosql
golang
redis
nginx
mysql
expressjs
c++
php
mysql
node.js
mongodb
android
ios
git
jira
c++
java
lucene
soir
elasticsearch
indexing
search-engine
web scraping(web crawling)
java
jsp
mysql
unity3d
cocos2d-x
c#
java
mahout-recommender
aws emr
text-mining
hadoop
elasticsearch
node.js
mongodb
nginx
redis
restful-api
amazon aws
java
python
node.js
jquery
java
python
android
ios
java
node.js
angularjs
mysql
android
java
php
jsp
jquery
mysql
html5/css3/javascript
jquery
java
python
django
html5/css3/javascript
node.js
android
mongodb
jquery
meteor
nginx
amazon aws
cordova
lamport
java
android
java
android studio
python
django
mariadb
rest API
docker
jenkins
django template engine 
cbv
javascript
html
css
angularjs
jquery
bootstrap
html/css/javascript
mysql
node.js
redis
amazon aws
php
jquery
mysql
java
python
node.js
amazon aws
codeigniter
nosql
elasticsearch
python
postgresql
redis
mongodb
flask
django
nginx
apache
sqlalchemy
oracle
python
angularjs
jquery
postgresql
nginx
redis
django
asana
slack


'Web Tech. > Spring Framework' 카테고리의 다른 글

Upload Fake Image(가짜 이미지, 피싱스크립트) 의 검증  (0) 2017.01.31
2개의 war 비교하기  (0) 2017.01.25
HMAC SHA-256 이해  (0) 2017.01.24
Tomcat JDBC Connection Pool  (0) 2016.12.20
SVN 연결 해제, 재연결  (0) 2016.12.15
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.

SHA-256 해시(Hash) 이해

 

# SHA-256 Hash Calculator(계산기)를 통한 변환

 

# 해시(Hash)?

많은 용량의 데이타를 고정된 크기의 고유값으로 만드는 것이다. 데이타 값이 약간만 달려져도 해시에는 예측할 수 없는 큰 변화가 발행하며 전형 다른 값이 되며, 이를 일명 눈사태 효과라고 부른다.

 

# HMAC(해시 메시지 인증 코드)?

해시는 데이터의 수정 또는 변경은 검출 할 수 있으나, 거짓 행세는 찾을 수 없기 때문에

인증이 필요해 진다.

 

송신자와 수신자만이 공유하고 있는 Key와 Data(메시지)를 혼합해서 해시값을 만드는 것이다. 이를 HMAC(Hash-based Message Authentication Code)이라고 한다.

 

 

SHA-256 ?

Secure Hash Algorithm(SHA)-256약자의 조합으로 생성된 고유의 값이 256비트이다. ( 하지만, SHA-1은 1비트가 아니고, ver.1을 뜻한다. )

SHA-2기반으로 SHA-224, SHA-256,SHA-384, SHA-512가 만들어 졌다. ( 뒤에 숫자는 비트수를 의미한다. )

SHA-1(160비트)은 2008년에 보안에 심각한 결함이 발견

 

 

# 해쉬함수별 출력값(해쉬값) 길이 비교

Hash 함수

출력값 길이

16진수

md5

128 bits

32 bytes

ex) 8380482228e75045a7d14e063bde014b

sha-1

160 bits

40 bytes

ex) 764C46AE8BC50C4823E50F18DA45B9A21E8DD10B

sha-256

256 bits

64 bytes

ex) be178c0543eb17f5f3043021c9e5fcf30285e557a4fc309cce97ff9ca6182912


 

# 참조 :

http://sunphiz.me/wp/archives/1104?ckattempt=1

http://www.xorbin.com/tools/sha256-hash-calculator

https://www.jokecamp.com/blog/examples-of-creating-base64-hashes-using-hmac-sha256-in-different-languages/

 

 

# Message Digest 만들기

StringBuffer hexString = new StringBuffer();
MessageDigest md = MessageDigest.getInstance("SHA-256");
byte[] hash = md.digest();

for (int i = 0; i < hash.length; i++) {
    if ((0xff & hash[i]) < 0x10) {
        hexString.append("0"
                + Integer.toHexString((0xFF & hash[i])));
    } else {
        hexString.append(Integer.toHexString(0xFF & hash[i]));
    }
}

 

출처 : https://stackoverflow.com/questions/5470219/get-md5-string-from-message-digest

블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Tomcat JDBC Connection Pool의 

일반 속성 ( Common Attributes )을 사용 하기




JDBC 연결하고 사용중(서비스중)에 갑자기 발생하는 단절 현상과 같이 Query시에 발생하는 PSQLException 중에서 에러 메시지 종류가 1. ERROR : could not establish connection,2. Detail : could not connect to server 인 경우에 testOnBorrow, validationQuery를 사용하면, 연결 단절시에 대한 조치를 할 수 있다. 




설정하는 옵션에 대한 설명은 아래 표를 참고 한다.

Attribute Description
defaultAutoCommit

(boolean) The default auto-commit state of connections created by this pool. If not set, default is JDBC driver default (If not set then the setAutoCommit method will not be called.)

testOnBorrow

(boolean) The indication of whether objects will be validated before being borrowed from the pool. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another. NOTE - for a true value to have any effect, the validationQuery or validatorClassName parameter must be set to a non-null string. In order to have a more efficient validation, see validationInterval. Default value is false

validationQuery

(String) The SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this query does not have to return any data, it just can't throw a SQLException. The default value is null. Example values are SELECT 1(mysql), select 1 from dual(oracle), SELECT 1(MS Sql Server)

validationQueryTimeout

(int) The timeout in seconds before a connection validation queries fail. This works by calling java.sql.Statement.setQueryTimeout(seconds) on the statement that executes the validationQuery. The pool itself doesn't timeout the query, it is still up to the JDBC driver to enforce query timeouts. A value less than or equal to zero will disable this feature. The default value is -1.

validatorClassName

(String) The name of a class which implements the org.apache.tomcat.jdbc.pool.Validator interface and provides a no-arg constructor (may be implicit). If specified, the class will be used to create a Validator instance which is then used instead of any validation query to validate connections. The default value is null. An example value iscom.mycompany.project.SimpleValidator.

참조 원문 : https://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html



for high-concurrency (높은 동시성)


Validating Connections

데이타베이스 풀링은 문제점을 갖고 있고, 이는 연결된 풀들이 끊어질 수(신선하지 않은) 있다.

<Resource type="javax.sql.DataSource"
            name="jdbc/TestDB"
            factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
            driverClassName="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost:3306/mysql"
            username="mysql_user"
            password="mypassword123"
            testOnBorrow="true"
            validationQuery="SELECT 1"
            />

Validation Queries는 몇가지 단점도 있다.


1. 자주 사용하면, 시스템의 성능을 저하시킨다.

2. 멀리 떨어져 있는 상태에서 호출하면, 결과는 실패일 수있다

 

http://www.tomcatexpert.com/blog/2010/04/01/configuring-jdbc-pool-high-concurrency



자바에서 사용하는 경우를 예로 들면 아래와 같다.

Code Example - Plain Java

import java.sql.Connection;
  import java.sql.ResultSet;
  import java.sql.Statement;

  import org.apache.tomcat.jdbc.pool.DataSource;
  import org.apache.tomcat.jdbc.pool.PoolProperties;

  public class SimplePOJOExample {

      public static void main(String[] args) throws Exception {
          PoolProperties p = new PoolProperties();
          p.setUrl("jdbc:mysql://localhost:3306/mysql");
          p.setDriverClassName("com.mysql.jdbc.Driver");
          p.setUsername("root");
          p.setPassword("password");
          p.setJmxEnabled(true);
          p.setTestWhileIdle(false);
          p.setTestOnBorrow(true);
          p.setValidationQuery("SELECT 1");
          p.setTestOnReturn(false);
          p.setValidationInterval(30000);
          p.setTimeBetweenEvictionRunsMillis(30000);
          p.setMaxActive(100);
          p.setInitialSize(10);
          p.setMaxWait(10000);
          p.setRemoveAbandonedTimeout(60);
          p.setMinEvictableIdleTimeMillis(30000);
          p.setMinIdle(10);
          p.setLogAbandoned(true);
          p.setRemoveAbandoned(true);
          p.setJdbcInterceptors(
            "org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"+
            "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
          DataSource datasource = new DataSource();
          datasource.setPoolProperties(p);

          Connection con = null;
          try {
            con = datasource.getConnection();
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery("select * from user");
            int cnt = 1;
            while (rs.next()) {
                System.out.println((cnt++)+". Host:" +rs.getString("Host")+
                  " User:"+rs.getString("User")+" Password:"+rs.getString("Password"));
            }
            rs.close();
            st.close();
          } finally {
            if (con!=null) try {con.close();}catch (Exception ignore) {}
          }
      }

  }



블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.



SVN 연결 해제, 재연결 in Eclipse



eclipse 프로젝트 트리에서 ( 즉, project or package explorer )




1. 연결 해제


-해당 프로젝트 위에서 우측 마우스 클릭


- team ->disconnect 선택



* 재연결을 위해서는 삭제 안하기를 선택




2. 재연결


-해당 프로젝트 위에서 우측 마우스 클릭


- team ->share project 선택





http://www.thinkplexx.com/learn/howto/scm/svn/disconnect-and-reconnect-svn-project-to-another-location-subclipse-version

'Web Tech. > Spring Framework' 카테고리의 다른 글

HMAC SHA-256 이해  (0) 2017.01.24
Tomcat JDBC Connection Pool  (0) 2016.12.20
eclipse(이클립스), 색상 테마 (color theme) 변경  (0) 2016.12.06
Ramda 표현식  (0) 2016.11.15
Java IO Package  (0) 2016.11.15
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,