SlideShare une entreprise Scribd logo
1  sur  74
김대우
젬플레이 이사
http://lekdw.blogspot.kr/
정도현(정개발)
나는 프로그래머다 MC
일본 Mamezou소속 컨설턴트
http://Iamprogrammer.io
http://moreagile.net
James Gosling
Patrick Naughton
https://en.wikipedia.org/wiki/Java_(programming_language)
https://en.wikipedia.org/wiki/Java_(programming_language)
J2SE 5.0
Java SE 7
Java SE 8
https://en.wikipedia.org/wiki/Java_version_history
연도별 언어 인기도
http://www.tiobe.com/index.p
hp/content/paperinfo/tpci/ind
ex.html
http://benchmarksgame.alioth.debian.org/u64/which-programs-are-fastest.html
http://www3.ntu.edu.sg/home/ehchua/programming/java/j5b_io.html
http://www.evanjones.ca/software/java-bytebuffers.html
http://netty.io/wiki/using-as-a-generic-library.html
http://terracotta.org/products/bigmemory
모바일 게임 서버와 같이 Life Cycle이 짧은 데이터(객체)를 주로 처리하
는 경우, 별다른 튜닝없이 -server, -d64, -Xms, -Xmx 옵션으로 충분.
http://www.drdobbs.com/jvm/the-comparative-productivity-of-programm/240005881
Language Hours Per Function Point
ASP* 06.1
Visual Basic 08.5
Java 10.6
SQL 10.8
C++ 12.4
C 13.0
C# 15.5
PL/1 14.2
COBOL 16.8
ABAP 19.9
Checkstyle
Error Prone
FindBugs
PMD
SonarQube
http://readwrite.com/2011/01/24/the-java-ecosystem-infographic
JUnit
SLF4J API Module
Scala Library
Logback Classic Module
Guava: Google Core Libraries for Java
Mockito
Google APIs Client Library for Java
Apache Log4j
Commons IO
SLF4J LOG4J-12 Binding
osgi.core
JavaServlet(TM) Specification
TestNG
ScalaTest
Commons Lang
Joda-Time
Spring Context
Mockito
H2 Database Engine
Java Servlet API
http://www.77dev.com/2014/05/java-trends-top-100-mostly-used.html
JCL 1.1.1 implemented over SLF4J
jackson-databind
SLF4J Simple Binding
Apache CommonsCodec
Apache HttpClient
Apache Commons Lang
Commons Logging
Spring Core
osgi.cmpn
Google Guice - Core Library
SpringTestContext Framework
Jetty :: Server Core
Maven Plugin API
FindBugs-jsr305
BeanValidation API
Spring Beans
Groovy
Jackson-core
EasyMock
Spock Framework - Core Module
Java8
http://www.slideshare.net/shintanimoto/from-old-java-to-modern-java
private List m_list=null;
private int process_file(String str_file_name){
String str_line;
List list_lines=new ArrayList();
int i_result=read_file(str_file_name,list_lines);
if(i_result==0){
List list_record=new ArrayList();
for(int i=0;i<list_lines.size();i++){
str_line=(String)list_lines.get(i);
Record record=new Record();
i_result=parse_line(str_line,record);
if(i_result!=0){
return i_result;
}
list_recordord.add(record);
}
m_list=list_record;
return 0;
}else{
return i_result;
}
}
http://www.slideshare.net/shintanimoto/from-old-java-to-modern-java
C-ish java
private List resultList;
private List processFile(String fileName)throws
SystemException {
List lines = readFile(fileName);
List recordList = new ArrayList();
for (int i = 0; i < lines.size(); i++) {
String line = (String) lines.get(i);
Record record = parseLine(line);
recordList.add(record);
}
return recordList;
}
http://www.slideshare.net/shintanimoto/from-old-java-to-modern-java
Java 1.4
private List<Record> processFile(String fileName)throws SystemException {
List<String> lines = readFile(fileName);
List<Record> recordList = new ArrayList();
for (String line : lines) {
Record record = parseLine(line);
recordList.add(record);
}
return recordList;
}
Java 1.7 generic + foreach
private List<String> readFile(String fileName) {
List<String> lines = new ArrayList<String>();
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(fileName));
String line;
while ((line = reader.readLine()) != null) {
lines.add(line);
}
} catch (FileNotFoundException ex) {
throw new SystemException(FILE_NOT_FOUND, ex);
} catch (IOException ex) {
throw new SystemException(FILE_READ_ERROR, ex);
}
finally {
try {
if (reader != null) {
reader.close();
}
} catch (IOException ex) {
// 이건 무시?
}
}
return lines;
}
private List<String> readFile(String fileName) {
List<String> lines = new ArrayList<>();
try (FileReader in = new FileReader(fileName);
BufferedReader reader = new BufferedReader(in)) {
String line;
while ((line = reader.readLine()) != null) {
lines.add(line);
}
} catch (FileNotFoundException ex) {
throw new SystemException(FILE_NOT_FOUND, ex);
} catch (IOException ex) {
throw new SystemException(FILE_READ_ERROR, ex);
}
return lines;
}
Java 7
private List<String> readFile(String fileName) {
try {
return Files.readAllLines(Paths.get(fileName), Charset.defaultCharset());
} catch (IOException ex) {
throw new SystemException(FILE_READ_ERROR, ex);
}
}
Java 7
https://ko.wikipedia.org/wiki/함수형_프로그래
밍
public static <E extends Comparable<? super E>>
List<E> quickSort(List<E> arr) {
if (!arr.isEmpty()) {
E pivot = arr.get(0); //This pivot can change
to get faster results
List<E> less = new LinkedList<E>();
List<E> pivotList = new LinkedList<E>();
List<E> more = new LinkedList<E>();
for (E i: arr) {
if (i.compareTo(pivot) < 0)
less.add(i);
else if (i.compareTo(pivot) > 0)
more.add(i);
else
pivotList.add(i);
}
less = quickSort(less);
more = quickSort(more);
less.addAll(pivotList);
less.addAll(more);
return less;
}
return arr;
}
http://rosettacode.org/wiki/Sorting_algorithms/Quicksort#Java
Java 7
public static <T> List<T> Quicksort(List<T> v, BiFunction<T, T,
Integer> comparer) {
if (v.size() < 2)
return v;
T pivot = v.get(v.size() / 2);
List<T> l = new LinkedList<T>(Quicksort(v.stream()
.filter(x -> comparer.apply(x, pivot) < 0)
.collect(Collectors.toList()), comparer));
l.addAll( v.stream().filter(x -> comparer
.apply(x, pivot) == 0).collect(Collectors.toList()) );
l.addAll( Quicksort(v.stream()
.filter(x -> comparer.apply(x, pivot) > 0)
.collect(Collectors.toList()), comparer) );
return l;
}
Java 8
qsort [] = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)
https://en.wikibooks.org/wiki/Algorithm_Implementation/Sorting/Quicksort#Haskell
Haskell
package org.ingini.spark.java8;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.TreeMap;
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.groupingBy;
public class WordsCounterJava {
public static final String REGEX = "s+";
public TreeMap<String, Long> count(String source) throws IOException {
return Files.lines(Paths.get(source))
.map(line -> line.split(REGEX))
.flatMap(Arrays::stream)
.collect(groupingBy(identity(), TreeMap::new, counting()));
}
}
-Djava.util.concurrent.ForkJoinPool.common.parallelism=1
SELECT * FROM BOOK
WHERE BOOK.PUBLISHED_IN = 2011
ORDER BY BOOK.TITLE
jOOQ
create.selectFrom(BOOK)
.where(BOOK.PUBLISHED_IN.eq(2011))
.orderBy(BOOK.TITLE)
http://www.jooq.org/
http://java2practice.com/2014/03/16/java-8-functional-interface-example/
Thread t =new Thread(new Runnable(){
public void run(){
System.out.println("Runnable implemented by using Lambda Expression");
}
});
Thread t = new Thread(()->{
System.out.println("Runnable implemented by using Lambda Expression");
});
Java 7
Java 8
interface DefaultInterfaceTest{
void show();
default void display(){
System.out.println("Default method from interface can have body..!");
}
}
public class DefaultInterfaceTestImpl implements DefaultInterfaceTest{
public void show(){
System.out.println("show method");
}
//we dont need to provide any implementation to default method.
public static void main(String[] args){
DefaultInterfaceTest obj = new DefaultInterfaceTestImpl();
obj.show();//out puts: show method
obj.display();//outputs : Default method from interface can have body..!
}
}
Default Method
•Function <T, R> - T를 입력으로 R을 출력으로 반환
•Predicate <T> - T를 입력으로 boolean을 출력으로 반환
•Consumer <T> - T를 입력으로 아무것도 반환하지 않는다
•Supplier <T> - 입력을 취하지 않고 T를 반환
•BinaryOperator <T> - 2 개의 T를 입력으로 하나의 T를 출력으로
반환
http://www.ibm.com/developerworks/library/j-jvmc2/index.html
Runnable task = () -> {
String threadName = Thread.currentThread().getName();
System.out.println("Hello " + threadName);
};
task.run();
Thread thread = new Thread(task);
thread.start();
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.submit(() -> {
String threadName = Thread.currentThread().getName();
System.out.println("Hello " + threadName);
});
try {
//attempt to shutdown executor
executor.shutdown();
executor.awaitTermination(5, TimeUnit.SECONDS);
}
catch (InterruptedException e) {
System.err.println("tasks interrupted");
}
finally {
if (!executor.isTerminated()) {
executor.shutdownNow();
}
System.out.println("shutdown finished");
}
Executors
http://winterbe.com/posts/2015/04/07/java8-concurrency-tutorial-thread-executor-examples/
http://ariya.ofilabs.com/2014/03/nashorn-the-new-rhino-on-the-block.html
interface CustomerRepository extends Repository<Customer, Long> {
@Query("select c from Customer c")
Stream<Customer> streamAllCustomers();
}
try (Stream<Customer> customers = repository.streamAllCustomers()) {
// use the stream here
}
Support for JDK 8' Stream in repository methods
interface CustomerRepository extends Repository<Customer, Long> {
@Async
CompletableFuture<List<Customer>> readAllBy();
}
CompletableFuture<List<Customer>> future =
repository.readAllBy().thenApply(this::doSomethingWithCustomers);
while (!future.isDone()) {
log.info("Waiting for the CompletableFuture to finish...");
TimeUnit.MILLISECONDS.sleep(500);
}
List<Customer> processedCustomers = future.get();
http://doc.akka.io/docs/akka/2.3.0-RC1/java/lambda-actors.html
import akka.actor.AbstractActor;
import akka.event.Logging;
import akka.event.LoggingAdapter;
import akka.japi.pf.ReceiveBuilder;
import scala.PartialFunction;
import scala.runtime.BoxedUnit;
public class MyActor extends AbstractActor {
private final LoggingAdapter log = Logging.getLogger(context().system(), this);
@Override
public PartialFunction<Object, BoxedUnit> receive() {
return ReceiveBuilder.
match(String.class, s -> s.equals("test"), s -> log.info("received test")).
matchAny(o -> log.info("received unknown message")).build();
}
}
https://blogs.oracle.com/javatraining/entry/announcing_jdk_8_mooc_lambdas
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습

Contenu connexe

Tendances

Tendances (20)

Java 8 Feature Preview
Java 8 Feature PreviewJava 8 Feature Preview
Java 8 Feature Preview
 
Code generation for alternative languages
Code generation for alternative languagesCode generation for alternative languages
Code generation for alternative languages
 
Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
 
Functional Thinking - Programming with Lambdas in Java 8
Functional Thinking - Programming with Lambdas in Java 8Functional Thinking - Programming with Lambdas in Java 8
Functional Thinking - Programming with Lambdas in Java 8
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Java 8: the good parts!
Java 8: the good parts!Java 8: the good parts!
Java 8: the good parts!
 
Sailing with Java 8 Streams
Sailing with Java 8 StreamsSailing with Java 8 Streams
Sailing with Java 8 Streams
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
 
Java 5 and 6 New Features
Java 5 and 6 New FeaturesJava 5 and 6 New Features
Java 5 and 6 New Features
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 
Basic Javascript
Basic JavascriptBasic Javascript
Basic Javascript
 
Oredev 2015 - Taming Java Agents
Oredev 2015 - Taming Java AgentsOredev 2015 - Taming Java Agents
Oredev 2015 - Taming Java Agents
 
Java SE 8 best practices
Java SE 8 best practicesJava SE 8 best practices
Java SE 8 best practices
 
Java8 features
Java8 featuresJava8 features
Java8 features
 
Getting started with Java 9 modules
Getting started with Java 9 modulesGetting started with Java 9 modules
Getting started with Java 9 modules
 
Voxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistVoxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with Javassist
 
Smart Migration to JDK 8
Smart Migration to JDK 8Smart Migration to JDK 8
Smart Migration to JDK 8
 

En vedette

9주 dom & event advanced 실습
9주  dom & event advanced 실습9주  dom & event advanced 실습
9주 dom & event advanced 실습
지수 윤
 

En vedette (20)

Java9 특징 훑어보기
Java9 특징 훑어보기Java9 특징 훑어보기
Java9 특징 훑어보기
 
자바9 특징 (Java9 Features)
자바9 특징 (Java9 Features)자바9 특징 (Java9 Features)
자바9 특징 (Java9 Features)
 
java 8 람다식 소개와 의미 고찰
java 8 람다식 소개와 의미 고찰java 8 람다식 소개와 의미 고찰
java 8 람다식 소개와 의미 고찰
 
발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기
발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기
발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기
 
우리가 모르는 노드로 할 수 있는 몇가지
우리가 모르는 노드로 할 수 있는 몇가지우리가 모르는 노드로 할 수 있는 몇가지
우리가 모르는 노드로 할 수 있는 몇가지
 
SOSCON2015 SI이노베이션
SOSCON2015 SI이노베이션SOSCON2015 SI이노베이션
SOSCON2015 SI이노베이션
 
JavaScript Debugging (수업자료)
JavaScript Debugging (수업자료)JavaScript Debugging (수업자료)
JavaScript Debugging (수업자료)
 
현재 자바스크립트 표준은 어디쯤
현재 자바스크립트 표준은 어디쯤 현재 자바스크립트 표준은 어디쯤
현재 자바스크립트 표준은 어디쯤
 
자바8 나머지 공개
자바8 나머지 공개자바8 나머지 공개
자바8 나머지 공개
 
Electron 개발하기
Electron 개발하기Electron 개발하기
Electron 개발하기
 
9주 dom & event advanced 실습
9주  dom & event advanced 실습9주  dom & event advanced 실습
9주 dom & event advanced 실습
 
VAADIN으로 스크립트 없는 자바 웹 애플리케이션 만들기
VAADIN으로 스크립트 없는 자바 웹 애플리케이션 만들기 VAADIN으로 스크립트 없는 자바 웹 애플리케이션 만들기
VAADIN으로 스크립트 없는 자바 웹 애플리케이션 만들기
 
At Your Service: Using Jenkins in Operations
At Your Service: Using Jenkins in OperationsAt Your Service: Using Jenkins in Operations
At Your Service: Using Jenkins in Operations
 
차세대 웹 플랫폼과 HTML5 기술 동향
차세대 웹 플랫폼과 HTML5 기술 동향차세대 웹 플랫폼과 HTML5 기술 동향
차세대 웹 플랫폼과 HTML5 기술 동향
 
Javascript Test Double Sinon.js
Javascript Test Double Sinon.jsJavascript Test Double Sinon.js
Javascript Test Double Sinon.js
 
Akka라이브러리를 이용해 구현하는 결함 내성 (발렌타인 발표자료)
Akka라이브러리를 이용해 구현하는 결함 내성 (발렌타인 발표자료)Akka라이브러리를 이용해 구현하는 결함 내성 (발렌타인 발표자료)
Akka라이브러리를 이용해 구현하는 결함 내성 (발렌타인 발표자료)
 
DDD 준비 서문래
DDD 준비 서문래DDD 준비 서문래
DDD 준비 서문래
 
Spring 4.x Web Application 살펴보기
Spring 4.x Web Application  살펴보기Spring 4.x Web Application  살펴보기
Spring 4.x Web Application 살펴보기
 
비전공자의 자바스크립트 도전기
비전공자의 자바스크립트 도전기비전공자의 자바스크립트 도전기
비전공자의 자바스크립트 도전기
 
RESTful Java
RESTful JavaRESTful Java
RESTful Java
 

Similaire à 모던자바의 역습

Jersey framework
Jersey frameworkJersey framework
Jersey framework
knight1128
 

Similaire à 모던자바의 역습 (20)

201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing
 
Java 7 & 8 New Features
Java 7 & 8 New FeaturesJava 7 & 8 New Features
Java 7 & 8 New Features
 
Server1
Server1Server1
Server1
 
3 j unit
3 j unit3 j unit
3 j unit
 
Modern Java Development
Modern Java DevelopmentModern Java Development
Modern Java Development
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
 
DevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaDevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern Java
 
JavaOne 2016 - Learn Lambda and functional programming
JavaOne 2016 - Learn Lambda and functional programmingJavaOne 2016 - Learn Lambda and functional programming
JavaOne 2016 - Learn Lambda and functional programming
 
Xopus Application Framework
Xopus Application FrameworkXopus Application Framework
Xopus Application Framework
 
JUnit 5
JUnit 5JUnit 5
JUnit 5
 
Pimp My Java LavaJUG
Pimp My Java LavaJUGPimp My Java LavaJUG
Pimp My Java LavaJUG
 
Slides
SlidesSlides
Slides
 
Java API, Exceptions and IO
Java API, Exceptions and IOJava API, Exceptions and IO
Java API, Exceptions and IO
 
Atlassian Groovy Plugins
Atlassian Groovy PluginsAtlassian Groovy Plugins
Atlassian Groovy Plugins
 
Java and SPARQL
Java and SPARQLJava and SPARQL
Java and SPARQL
 
Jersey framework
Jersey frameworkJersey framework
Jersey framework
 
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitFighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnit
 
My java file
My java fileMy java file
My java file
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Nantes Jug - Java 7
Nantes Jug - Java 7Nantes Jug - Java 7
Nantes Jug - Java 7
 

Dernier

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Dernier (20)

WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 

모던자바의 역습

  • 1.
  • 2. 김대우 젬플레이 이사 http://lekdw.blogspot.kr/ 정도현(정개발) 나는 프로그래머다 MC 일본 Mamezou소속 컨설턴트 http://Iamprogrammer.io http://moreagile.net
  • 3.
  • 6. J2SE 5.0 Java SE 7 Java SE 8 https://en.wikipedia.org/wiki/Java_version_history
  • 7.
  • 8.
  • 9.
  • 10.
  • 12.
  • 18. 모바일 게임 서버와 같이 Life Cycle이 짧은 데이터(객체)를 주로 처리하 는 경우, 별다른 튜닝없이 -server, -d64, -Xms, -Xmx 옵션으로 충분.
  • 19.
  • 20.
  • 21.
  • 22. http://www.drdobbs.com/jvm/the-comparative-productivity-of-programm/240005881 Language Hours Per Function Point ASP* 06.1 Visual Basic 08.5 Java 10.6 SQL 10.8 C++ 12.4 C 13.0 C# 15.5 PL/1 14.2 COBOL 16.8 ABAP 19.9
  • 23.
  • 25.
  • 26.
  • 28. JUnit SLF4J API Module Scala Library Logback Classic Module Guava: Google Core Libraries for Java Mockito Google APIs Client Library for Java Apache Log4j Commons IO SLF4J LOG4J-12 Binding osgi.core JavaServlet(TM) Specification TestNG ScalaTest Commons Lang Joda-Time Spring Context Mockito H2 Database Engine Java Servlet API http://www.77dev.com/2014/05/java-trends-top-100-mostly-used.html
  • 29. JCL 1.1.1 implemented over SLF4J jackson-databind SLF4J Simple Binding Apache CommonsCodec Apache HttpClient Apache Commons Lang Commons Logging Spring Core osgi.cmpn Google Guice - Core Library SpringTestContext Framework Jetty :: Server Core Maven Plugin API FindBugs-jsr305 BeanValidation API Spring Beans Groovy Jackson-core EasyMock Spock Framework - Core Module
  • 30.
  • 31. Java8
  • 32.
  • 34. private List m_list=null; private int process_file(String str_file_name){ String str_line; List list_lines=new ArrayList(); int i_result=read_file(str_file_name,list_lines); if(i_result==0){ List list_record=new ArrayList(); for(int i=0;i<list_lines.size();i++){ str_line=(String)list_lines.get(i); Record record=new Record(); i_result=parse_line(str_line,record); if(i_result!=0){ return i_result; } list_recordord.add(record); } m_list=list_record; return 0; }else{ return i_result; } } http://www.slideshare.net/shintanimoto/from-old-java-to-modern-java C-ish java
  • 35. private List resultList; private List processFile(String fileName)throws SystemException { List lines = readFile(fileName); List recordList = new ArrayList(); for (int i = 0; i < lines.size(); i++) { String line = (String) lines.get(i); Record record = parseLine(line); recordList.add(record); } return recordList; } http://www.slideshare.net/shintanimoto/from-old-java-to-modern-java Java 1.4
  • 36. private List<Record> processFile(String fileName)throws SystemException { List<String> lines = readFile(fileName); List<Record> recordList = new ArrayList(); for (String line : lines) { Record record = parseLine(line); recordList.add(record); } return recordList; } Java 1.7 generic + foreach
  • 37.
  • 38. private List<String> readFile(String fileName) { List<String> lines = new ArrayList<String>(); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(fileName)); String line; while ((line = reader.readLine()) != null) { lines.add(line); } } catch (FileNotFoundException ex) { throw new SystemException(FILE_NOT_FOUND, ex); } catch (IOException ex) { throw new SystemException(FILE_READ_ERROR, ex); } finally { try { if (reader != null) { reader.close(); } } catch (IOException ex) { // 이건 무시? } } return lines; }
  • 39. private List<String> readFile(String fileName) { List<String> lines = new ArrayList<>(); try (FileReader in = new FileReader(fileName); BufferedReader reader = new BufferedReader(in)) { String line; while ((line = reader.readLine()) != null) { lines.add(line); } } catch (FileNotFoundException ex) { throw new SystemException(FILE_NOT_FOUND, ex); } catch (IOException ex) { throw new SystemException(FILE_READ_ERROR, ex); } return lines; } Java 7
  • 40. private List<String> readFile(String fileName) { try { return Files.readAllLines(Paths.get(fileName), Charset.defaultCharset()); } catch (IOException ex) { throw new SystemException(FILE_READ_ERROR, ex); } } Java 7
  • 42.
  • 43. public static <E extends Comparable<? super E>> List<E> quickSort(List<E> arr) { if (!arr.isEmpty()) { E pivot = arr.get(0); //This pivot can change to get faster results List<E> less = new LinkedList<E>(); List<E> pivotList = new LinkedList<E>(); List<E> more = new LinkedList<E>(); for (E i: arr) { if (i.compareTo(pivot) < 0) less.add(i); else if (i.compareTo(pivot) > 0) more.add(i); else pivotList.add(i); } less = quickSort(less); more = quickSort(more); less.addAll(pivotList); less.addAll(more); return less; } return arr; } http://rosettacode.org/wiki/Sorting_algorithms/Quicksort#Java Java 7
  • 44. public static <T> List<T> Quicksort(List<T> v, BiFunction<T, T, Integer> comparer) { if (v.size() < 2) return v; T pivot = v.get(v.size() / 2); List<T> l = new LinkedList<T>(Quicksort(v.stream() .filter(x -> comparer.apply(x, pivot) < 0) .collect(Collectors.toList()), comparer)); l.addAll( v.stream().filter(x -> comparer .apply(x, pivot) == 0).collect(Collectors.toList()) ); l.addAll( Quicksort(v.stream() .filter(x -> comparer.apply(x, pivot) > 0) .collect(Collectors.toList()), comparer) ); return l; } Java 8
  • 45. qsort [] = [] qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs) https://en.wikibooks.org/wiki/Algorithm_Implementation/Sorting/Quicksort#Haskell Haskell
  • 46.
  • 47. package org.ingini.spark.java8; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Arrays; import java.util.TreeMap; import static java.util.function.Function.identity; import static java.util.stream.Collectors.counting; import static java.util.stream.Collectors.groupingBy; public class WordsCounterJava { public static final String REGEX = "s+"; public TreeMap<String, Long> count(String source) throws IOException { return Files.lines(Paths.get(source)) .map(line -> line.split(REGEX)) .flatMap(Arrays::stream) .collect(groupingBy(identity(), TreeMap::new, counting())); } }
  • 49. SELECT * FROM BOOK WHERE BOOK.PUBLISHED_IN = 2011 ORDER BY BOOK.TITLE jOOQ create.selectFrom(BOOK) .where(BOOK.PUBLISHED_IN.eq(2011)) .orderBy(BOOK.TITLE) http://www.jooq.org/
  • 50.
  • 51. http://java2practice.com/2014/03/16/java-8-functional-interface-example/ Thread t =new Thread(new Runnable(){ public void run(){ System.out.println("Runnable implemented by using Lambda Expression"); } }); Thread t = new Thread(()->{ System.out.println("Runnable implemented by using Lambda Expression"); }); Java 7 Java 8
  • 52. interface DefaultInterfaceTest{ void show(); default void display(){ System.out.println("Default method from interface can have body..!"); } } public class DefaultInterfaceTestImpl implements DefaultInterfaceTest{ public void show(){ System.out.println("show method"); } //we dont need to provide any implementation to default method. public static void main(String[] args){ DefaultInterfaceTest obj = new DefaultInterfaceTestImpl(); obj.show();//out puts: show method obj.display();//outputs : Default method from interface can have body..! } } Default Method
  • 53.
  • 54. •Function <T, R> - T를 입력으로 R을 출력으로 반환 •Predicate <T> - T를 입력으로 boolean을 출력으로 반환 •Consumer <T> - T를 입력으로 아무것도 반환하지 않는다 •Supplier <T> - 입력을 취하지 않고 T를 반환 •BinaryOperator <T> - 2 개의 T를 입력으로 하나의 T를 출력으로 반환
  • 56. Runnable task = () -> { String threadName = Thread.currentThread().getName(); System.out.println("Hello " + threadName); }; task.run(); Thread thread = new Thread(task); thread.start();
  • 57. ExecutorService executor = Executors.newSingleThreadExecutor(); executor.submit(() -> { String threadName = Thread.currentThread().getName(); System.out.println("Hello " + threadName); }); try { //attempt to shutdown executor executor.shutdown(); executor.awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException e) { System.err.println("tasks interrupted"); } finally { if (!executor.isTerminated()) { executor.shutdownNow(); } System.out.println("shutdown finished"); } Executors http://winterbe.com/posts/2015/04/07/java8-concurrency-tutorial-thread-executor-examples/
  • 59. interface CustomerRepository extends Repository<Customer, Long> { @Query("select c from Customer c") Stream<Customer> streamAllCustomers(); } try (Stream<Customer> customers = repository.streamAllCustomers()) { // use the stream here } Support for JDK 8' Stream in repository methods
  • 60. interface CustomerRepository extends Repository<Customer, Long> { @Async CompletableFuture<List<Customer>> readAllBy(); } CompletableFuture<List<Customer>> future = repository.readAllBy().thenApply(this::doSomethingWithCustomers); while (!future.isDone()) { log.info("Waiting for the CompletableFuture to finish..."); TimeUnit.MILLISECONDS.sleep(500); } List<Customer> processedCustomers = future.get();
  • 61. http://doc.akka.io/docs/akka/2.3.0-RC1/java/lambda-actors.html import akka.actor.AbstractActor; import akka.event.Logging; import akka.event.LoggingAdapter; import akka.japi.pf.ReceiveBuilder; import scala.PartialFunction; import scala.runtime.BoxedUnit; public class MyActor extends AbstractActor { private final LoggingAdapter log = Logging.getLogger(context().system(), this); @Override public PartialFunction<Object, BoxedUnit> receive() { return ReceiveBuilder. match(String.class, s -> s.equals("test"), s -> log.info("received test")). matchAny(o -> log.info("received unknown message")).build(); } }