javaee-azrulmadisa

Upload: mosc2010

Post on 30-May-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 JavaEE-AzrulMadisa

    1/41

    Java EE Midlife Crisis

    ByAzrul [email protected]

    1

  • 8/9/2019 JavaEE-AzrulMadisa

    2/41

    2

  • 8/9/2019 JavaEE-AzrulMadisa

    3/41

    3

  • 8/9/2019 JavaEE-AzrulMadisa

    4/41

    at s appen ng o ate

    4

  • 8/9/2019 JavaEE-AzrulMadisa

    5/41

    Oracle acquisition of Sun The pathetic prophets

    Would somebody please think of thechildren!!

    Onslaught of new languages/technologies Is Java in midlife crisis?

    5

  • 8/9/2019 JavaEE-AzrulMadisa

    6/41

    a s ory eac es us

    6

  • 8/9/2019 JavaEE-AzrulMadisa

    7/41

    Java will always adapt

    7

  • 8/9/2019 JavaEE-AzrulMadisa

    8/41

    The simple fact remains, then: Java, theplatform, the ecosystem, the environment and

    ,far from the Abyss of Irrelevancy as any of theother languages or platforms currently in usetoday Ted Neward

    8

  • 8/9/2019 JavaEE-AzrulMadisa

    9/41

    9

  • 8/9/2019 JavaEE-AzrulMadisa

    10/41

    Old and reliable Patterns Distributed computing

    Transactionmanagement

    Load balancing

    10

  • 8/9/2019 JavaEE-AzrulMadisa

    11/41

    New

    Contexts and DependencyInjection (CDI)

    Java EE + Other JVM languages

    11

  • 8/9/2019 JavaEE-AzrulMadisa

    12/41

    Context and De endenc

    Injection

    12

  • 8/9/2019 JavaEE-AzrulMadisa

    13/41

    Contexts and DependencyInject - CDI

    JSR-299

    e-safe DI AOP

    and Eventing Use annotation a

    whole lot to achievea whole lot more

    13

  • 8/9/2019 JavaEE-AzrulMadisa

    14/41

    CDI vs. the world

    more typesafe than Seam, morestateful and less XML-centric than

    ,application capable than Guice Gavin

    King, JSR-299 spec lead

    14

  • 8/9/2019 JavaEE-AzrulMadisa

    15/41

    CDI Dependency Injection (DI) Typesafe DI with qualifier

    15

  • 8/9/2019 JavaEE-AzrulMadisa

    16/41

    CDI DI example

    @MyService(PRODUCTION)public class ProductionShoppingCart implements

    ShoppingCart{}

    @MyService(MOCK)

    public class MockShoppingCart implementsShoppingCart{}

    16

  • 8/9/2019 JavaEE-AzrulMadisa

    17/41

    CDI DI example Injecting a shopping cart to a servlet

    public class Ecommerce extends HttpServlet {

    @Inject @MyService(MOCK) ShoppingCart shoppingCart;protected void doGet( ){

    //use shopping cart

    }}

    17

  • 8/9/2019 JavaEE-AzrulMadisa

    18/41

    CDI Eventing Light weight eventing Decouple sender and recipient

    Can use JMS as a broker

    POJO POJO

    POJO

    18

  • 8/9/2019 JavaEE-AzrulMadisa

    19/41

    CDI Eventing Create the object to be send

    private String content=Yap! Yap! Yap!;

    }

    19

  • 8/9/2019 JavaEE-AzrulMadisa

    20/41

    CDI Eventing Create a sender

    public class Women {

    @Inject Event eventUtility;public void say(){

    MyMessage myMessage = new MyMessage();

    eventUtility.fire(myMessage);

    }}

    20

  • 8/9/2019 JavaEE-AzrulMadisa

    21/41

    CDI Eventing

    Create a listener

    public class Men {

    public void listen( @Observes MyMessage myMessage){Logger.log(Message:"+myMessage.getContent());

    }

    }

    21

  • 8/9/2019 JavaEE-AzrulMadisa

    22/41

    Challenge

    22

  • 8/9/2019 JavaEE-AzrulMadisa

    23/41

    Java Enterprise Application In 1 week

    Make it work

    23

  • 8/9/2019 JavaEE-AzrulMadisa

    24/41

    Problem

    24

  • 8/9/2019 JavaEE-AzrulMadisa

    25/41

    Enterprise Job Scheduling App

    At a scheduled time

    25

  • 8/9/2019 JavaEE-AzrulMadisa

    26/41

    Enterprise Job Scheduling App Examples:

    Telcos

    Every week, all usage data need to be processed.

    Banks

    Every night, all credit card applications for the day needto be processed

    Insurance Underwriting for new applications need to be done every

    3 working days

    26

  • 8/9/2019 JavaEE-AzrulMadisa

    27/41

    27

  • 8/9/2019 JavaEE-AzrulMadisa

    28/41

    How it works Telco example

    Step1Aggregate all usage data

    for this month

    Scheduler

    Business Process

    Step2

    Step3

    For each user, create aninvoice

    Send all invoices for printing

    At 12:00 midnightEvery 15th of a month

    28

  • 8/9/2019 JavaEE-AzrulMadisa

    29/41

    Challenges in creating a scheduler

    Scheduler need an interface Preferable web

    Scheduler should be loosely coupled from the

    BP BP can change without affecting the scheduler Vice-versa

    Scheduler should use standards as much aspossible Standard scheduling expression

    29

  • 8/9/2019 JavaEE-AzrulMadisa

    30/41

    Challenges in creating abusiness process BP needs to be scalable

    but cannot be truly stateless since BP arestateful by nature

    BP needs to be somewhat standard The standard, BPEL, is too web-services centric

    BP needs a decent tool BP is loosely coupled from jobs

    Jobs can change without affecting BP BP can change without affecting jobs

    30

  • 8/9/2019 JavaEE-AzrulMadisa

    31/41

    Challenges in creating a job

    Job need to be asynchronous but need to be chained i.e. fire and forget cannot be

    used here

    Job need to be simple to create

    Tool support is needed Job need to be a standard artefact

    Easier to recruit people who knows standard stuff

    Testability of a job is crucial

    Job need to be as POJO as possible Job contain business logic

    Transaction is crucial

    31

  • 8/9/2019 JavaEE-AzrulMadisa

    32/41

    Challenges in the system as awhole Load-balancing capable

    Transactional

    Rollback / redo Use standard solution wherever possible

    32

  • 8/9/2019 JavaEE-AzrulMadisa

    33/41

    Answering the challenge

    ----------------Scheduler

    -------------------------------------BusinessProcess-------------------------------------my_business_process.jpdl.xml

    Web

    HTTP

    33

  • 8/9/2019 JavaEE-AzrulMadisa

    34/41

    Answering the challenge transactional jobs

    -------------------BusinessProcess

    ---------------

    JMS

    Step1

    Step2

    Step3

    ---------------Delegate

    BusinessLogic

    JMS

    CDI Event

    34

  • 8/9/2019 JavaEE-AzrulMadisa

    35/41

    Answering the challenge lightweight jobs

    -------------------BusinessProcess

    ---------------

    Step1

    Step2

    Step3

    BusinessLogic

    CDI Event

    35

  • 8/9/2019 JavaEE-AzrulMadisa

    36/41

    Answering the challenge

    A job:

    public void handleEvent(@Observes@CDIEventSource("MyBusinessLogic") CDIEvent event) {

    Map token = event.getToken();

    //token = Input/Output

    //do some business logic}

    }

    36

  • 8/9/2019 JavaEE-AzrulMadisa

    37/41

    Delivering promises

    Simplicity Jobs a POJO

    Business process is a plain old JPDL

    Scalability

    JMS and asynchronous, event based framework

    Lightweight

    CDI eventing

    Statefulness

    JBPM + Request-response pattern

    37

  • 8/9/2019 JavaEE-AzrulMadisa

    38/41

    Delivering promises

    Reliability Transaction all the way even in

    li htwei ht mode

    Java EE provided clustering/fallback JMS provided load-balancing

    Scheduler

    MyBP MyBP MyBP

    38

  • 8/9/2019 JavaEE-AzrulMadisa

    39/41

    Delivering promises

    Loose coupling CDI Event JMS exchangability without

    modif in the Business Lo ic

    39

  • 8/9/2019 JavaEE-AzrulMadisa

    40/41

    Conclusion

    Java is old and reliable and yet new andexciting

    Dont want to use the Java language,

    Scala

    Groovy

    Anything

    Java is well, alive and kicking butts really hard!

    40

  • 8/9/2019 JavaEE-AzrulMadisa

    41/41

    Thanks for listening to someonewho is not yet on a midlife crisis

    Azrul MADISA

    [email protected]

    41