IS2103 - Summary

  • Upload
    jiebo

  • View
    214

  • Download
    0

Embed Size (px)

Citation preview

  • 7/25/2019 IS2103 - Summary

    1/22

    QUICK REFERENCE GUIDE

    Chapter 2 Distributed Computing

    Remote Method Invocation (RMI)

    Use: RMI is a mechanism for enabin! an ob"ect in one #$M to comm%nicate remote&'ith an ob"ect in another #$M ith RMI* ob"ects can be caed remote&* reso%rces can

    be shared and +rocessin! oad distrib%ted over a n%mber of com+%ters RMI aso+romotes location transparency

    E,ec%tion:

    - .erver binds an ob"ect to a name via Naming.rebind(AddServer,addServerImpl!

    / Generate stuband s"eleton(de0nitions in 1ect%re - +! -2)3 .tart RMI re!istr& via start rmiregistr#in the command +rom+t$. Cient oo4s %+AddServerin re!istr& via

    Naming.loo"up(rmi%&&'I o) server, *2+...* )or lo-al&AddServer!

    Im+orts

    "avarmiNamin! 5o ca Namin! cass methods

    "avarmiRemote publi- inter)a-e AddServer e/tends 0emote 16

    "avarmiRemoteE,ce+tion 5o ao' thro'in! of RemoteE,ce+tion

    #avarmiserverUnicastRemote7b"ect

    De0nes a non8re+icated remote ob"ect 'hosereferences are vaid on& 'hie server +rocess is aivepubli- -lass AddServerImpl e/tendsni-ast0emote3b4e-t implements AddServer 1

    Reference: 5e,tboo4 +! -9 -;

    #ava Namin! Director& Interface (#NDI)

    Use:

  • 7/25/2019 IS2103 - Summary

    2/22

    QUICK REFERENCE GUIDE

    "ava%ti=ro+erties 5o set +ath %r

    "ava,namin!Namin!En%meration

    "ava,rmi=ortabeRemote7b"ect

    Used instead of UnicastRemote7b"ect in rmi

    Reference: 5e,tboo4 +! /? /@

    /

  • 7/25/2019 IS2103 - Summary

    3/22

    QUICK REFERENCE GUIDE

    Chapter ? 0;I@II3

    De0nitions:

    8 C7R>< (Common 7b"ect ReA%est >ro4er

  • 7/25/2019 IS2103 - Summary

    4/22

    QUICK REFERENCE GUIDE

    Chapter $ eans +! 3

    Midde'are ta4es care of other services that are essentia for the e,ec%tion of beans5hese services inc%de database inte!rit& chec4s* sec%rit&* transactions* etc 'ithmidde'are* the desi!n of enter+rise beans does not have to e,+icit& ta4e care ofthese services since the& are no' dee!ated to the midde'are

    8 Im+icit: Usa!e of midde'are services is decared thro%!h a separate descriptortext-fle* or coded 'ithin an enter+rise bean %sin! annotation

    8 E,+icit: rite ever& midde'are &o%rsef

    F%rther e,am+es 5e,tboo4 +! 2

    E#> Com+onent 5&+es:

    - Cient 7b"ects e! servets* #.= +a!es/ .erver 7b"ects e! messa!e driven beans* mana!er beans* session beans

    coective& Enterprise Beans3 E#> Container: res+onsibe for mana!in! enter+rise beans

    o Does a ot of midde'are services for the beanso .ec%rit&o 5ransaction mana!emento Remote accessibiit&o Reso%rce and ife c&ce mana!emento C%sterin! and oad baancin!o Conc%rrent reA%ests s%++ort

    RMI8II7= vs E#>

    Remote interface for the server

    ob"ect

    1ocaRemote b%siness interface for enter+rise

    beanIm+ement remote interface rite a de+o&ment annotated enter+rise bean

    cass that im+ements b%siness interfaceInterface and enter+rise bean cass forms E#>com+onent

    Cient a++ to invo4e server ob"ectsmethods

    Cient a++ to invo4e enter+rise beans methods

    Generate st%b and s4eetons Container +rovides midde'are service thatcreates st%b and s4eeton

    .erver a++ication Com+onent deveo+ed forms server a++ication

    .tart re!istr& Start com+onent in the

  • 7/25/2019 IS2103 - Summary

    5/22

    QUICK REFERENCE GUIDE

    .erver

    R%n Cient a++ication 0unCient a++ication

    Refer to 5e,tboo4 pg *2 for im+ementation ofNDI loo"up in

  • 7/25/2019 IS2103 - Summary

    6/22

    QUICK REFERENCE GUIDE

    Chapter E Session Beans or eans: In sit%ations 'here memor& is imited*the +%shin! aside of session beans to secondar& memor& is 4no'n as

    passivation@ >%siness interface: eans< session bean is a server8side ob"ect re+resentin! 'or4 to be done on behaf of thecient cain! it It im+ements b%siness o!ic* a!orithm* b%siness r%es or 'or4o'For e,am+e* +erformin! order entr&* 'ithdra'in! f%nds from ban4 acco%nt*

    +rod%cin! +rice A%otes* etc are t&+ica b%siness +rocesses that 'e can %se sessionbeans for.tatef%

    Kee+ the data s+eci0c to the cient the& are servin! and ao' the +assin! ofdata bet'een method cas

    .tateess

    Do not maintain an& data associated 'ith cients the& are servin! interna&*no +assin! of +arameters across method cas therefore a stateess sessionbeans instances are eA%ivaent and indistin!%ishabe to an& cient

    Messa!e Driven >eansMessa!e driven beans can on& be caed to send messa!es MD> doesnt have aninterface* hence* cannot be caed i4e in a session bean 5&+ica %se issendin!recei+t of trade messa!es s%ch as credit card info

    MD> ma& send messa!es to other MD> or invo4e methods direct& on E#>s 'hen amessa!e is received

    E,ec%tion:

    - rite the (oca or remote) b%siness interface for the enter+rise beansF0emote+%bic interface eanRemote H

    / rite a de+o&ment annotated enter+rise bean cass that im+ements theb%siness interface

    FStateless

    +%bic cass ean im+ements eanRemote H3 rite a cient a++ication that invo4es the enter+rise beans methods

    +%bic cass

  • 7/25/2019 IS2103 - Summary

    7/22

    QUICK REFERENCE GUIDE

    "ava,e"b.tatef% .tatef%

    "ava,e"bE#> E#>

    Reference: 5e,tboo4 +! 2?

    ?

  • 7/25/2019 IS2103 - Summary

    8/22

    QUICK REFERENCE GUIDE

    1ife C&ce of .ession >eans

    1ife C&ce Cabac4 Methodsimitations o) State)ul Session Beans

    hen a ne' a++ication cient is e,ec%ted* a ne' session bean is instantiated and+revio%s& created c%stomer is no on!er avaiabe ence .tatef% session beans arenot s%itabe for +ersistin! ob"ect data be&ond an a++ication r%n

    Usin! a .tatef% session bean to re+resent a c%stomer mere& stores the c%stomersdata in com+%ter memor& hen the session is terminated* the b%siness data are asodestro&ed

    ;

  • 7/25/2019 IS2103 - Summary

    9/22

    QUICK REFERENCE GUIDE

    Chapter G ersisten-e ;anagement

    Entities:

    8 =ersistent data ob"ect in the #ava =ersistence s+eci0cation8 Entit& casses are Plain Old Java Objects not enter+rise beans

    8 Entities are oca ob"ects that cannot be direct& accessed from a remote ocation session beans

    8 Entities +ossess =ersistent identit& that distin!%ishes one entit& from another8 Entit& is an in8memor& #ava ob"ect that re+resents +ersistent data stored in

    +ermanent data stora!e

    Entit& Instance .tate

    8 Mana!ed: 5he mana!er trac4s state chan!es to the entit& and s&nchroniesthose chan!es to the database 'henever the entit& mana!er decides to %sh itsstate

    8 Unmana!ed:

    o %sh() : void .&nchronie chan!es done on entit& instance in

    +ersistence conte,t 'ith D>createQ%er&(.trin! name) :Q%er&

    Create an instance of Q%er&

    Im+orts

    @

  • 7/25/2019 IS2103 - Summary

    10/22

    QUICK REFERENCE GUIDE

    "ava,+ersistenceEntit& Entit&(name Osomethin!P

    "ava,+ersistencetabe 5abe(name Otabe nameP

    "ava,+ersistenceEntit&Mana!er

    =ersistenceConte,tEntit&Mana!er emS

    "ava,+ersistence=ersistenceConte,t

    Chapter + Implementing Business 3b4e-t ersisten-e

    Im+orts:

    "avaio.eriaiabe +%bic cass GiftEntit& im+ements SerialiHableH

    "ava,+ersistenceEntit& Entit&

    "ava,+ersistenceEntit&1isteners

    Entit&1isteners (38I3NA>

    "ava,+ersistenceGenerated$a

    %e

    Generated$a%e(strate!&Generation5&+eac4cassim+ementation

  • 7/25/2019 IS2103 - Summary

    11/22

    QUICK REFERENCE GUIDE

    DD> to ava

    import javax.persistence.(olumn;

    import javax.persistence.Entity;

    import javax.persistence.d;

    import javax.persistence.Table;

    "Entity

    @Table(name="CUSTOMER_TABLE")

    public class (ustomerEntity implements java.io.Serializable ,

    private Long d;

    private String name;

    private String title;

    "d

    @Column(name="PASSENGER_ID", nullable=!ale, #olumnDe!$n$%$on="$n%e&'e&")

    public Long getd#' , return d; 1

    public void setd#Long d' , t2is.d $ d; 1

    @Column(name="PASSENGER_NAME", len'%=*, nullable=!ale)

    public String get0ame#' , return name; 1

    public void set0ame#String name' , t2is.name $ name; 1

    @Column(len'%=+*)

    public String getTitle#' , return title; 1

    public void setTitle#String title' , t2is.title $ title; 1

    Finter)a-e Column

    public @$n%e&!a#e(olumn , String name#' de&ault %%;

    String table#' de&ault %%;

    boolean uni!ue#' de&ault &alse;

    boolean nullable#' de&ault true;

    boolean insertable#' de&ault true;

    boolean updatable#' de&ault true;

    String columne&inition#' de&ault %%;

    int lengt2#' de&ault 344;

    int precision#' de&ault +;

    int scale#' de&ault +;1

    --

    Chan!e tabe name fromC%stomerEntit& (defa%t) to

    - Rename co%mn Id to =

  • 7/25/2019 IS2103 - Summary

    12/22

    QUICK REFERENCE GUIDE

    "ava,+ersistenceIdCass "ava,+ersistenceE"ava,+ersistence

    =rimar&

    s

    +%bic cass =assen!er=K im+ements .eriaiabe H+rivate .trin! nameS+rivate .trin! +ass+ortNoS

    F

  • 7/25/2019 IS2103 - Summary

    13/22

    QUICK REFERENCE GUIDE

    Chapter J 8ransa-tions

    < transaction m%st be atomi-* -onsistent* isolated and durable ( is in harmon& 'ith the rea 'ord it re+resents

    Isoated: 5ransaction ao'ed to e,ec%te 'itho%t interference from other +rocessesor transaction

    D%rabe:

  • 7/25/2019 IS2103 - Summary

    14/22

    QUICK REFERENCE GUIDE

    Chapter ravoEntit&P()S

    6

    +%bic cass >ravoEntit& HONothin! .+eciaP6

    M8- -8M>i

    =!-3

    +%bic cass ravoEntit& bS6

    8he ;an# side is theo6ning side

    +%bic cass >ravoEntit& H7ne5oMan&(ma++ed>&b*cascadeHV)+rivate .etOravoEntit&P()S

    6

    +%bic cass >ravoEntit& HONothin! .+eciaP6

    M8M>i

    =!-;@

    +%bic cass ravoEntit&P b

    ne'ash.etO>ravoEntit&P()S

    6

    +%bic cass >ravoEntit& HMan&5oMan&(ma++ed>&b*cascadeHV)+rivate .etO

  • 7/25/2019 IS2103 - Summary

    15/22

    QUICK REFERENCE GUIDE

    Im+orts:

    "ava,+ersistence7ne5o7ne

    7ne5o7ne

    "ava,+ersistence7ne5oMan&

    7ne5oMan&

    "ava,+ersistenceMan&5oMan&

    Man&5oMan&

    "ava,+ersistenceMan&5o7ne

    Man&5o7ne

    "ava,+ersistenceCascade5&+e

    cascadeHCascade5&+e=ER.I.5VV MERGE REM7$E REFRE.

  • 7/25/2019 IS2103 - Summary

    16/22

    QUICK REFERENCE GUIDE

    Im+orts in servet

    "ava,servetReA%estDis+atcher

    ReA%estDis+atcher dis+atcherS.ervetConte,t servetConte,t !et.ervetConte,t()S

    dis+atcher servetConte,t!etNamedDis+atcher(+a!e)"ava,servet.ervetConte,t

    "ava,servet.ervetE,ce+tion ReA%ired for doGet and do=ost 'hich are defa%tmethods

    "ava,servethtt+tt+.ervet +%bic cass >R..ervet e,tends tt+.ervet H

    "ava,servethtt+tt+.ervetReA%est

    "ava,servethtt+tt+.ervetRes+onse

    ;ust al6a#s import 0emote inter)a-e -lass i) 6e need to -all manager bean

    "s+

    -9

    78

    5rrayList bookList $ #5rrayList're!uest.get5ttribute#%data%';

    &or#6bject o9 bookList' ,

    String book $ #String'o;

    StringTokenizer st $ ne: StringTokenizer#book) %%';

    8istener 5 ne6 Mueue>istener(!Consumer.set;essage>istener(ueue>istener!

    5'o t&+es of messa!in! domains:

    8 =oint8to8+oint: Q%e%e

    8 =%bish.%bscribe: 5o+icMessa!es can be cons%med in t'o 'a&s:

    8 .&nchrono%s&: < receiver e,+icit& fetches the messa!e from the destination b&cain! the receive() method 5he receive() method can boc4 %nti a messa!earrives or can time o%t if a messa!e does not arrive 'ithin a s+eci0ed time imit

    8

  • 7/25/2019 IS2103 - Summary

    18/22

    QUICK REFERENCE GUIDE

    Chapter *2 ;essage Driven Beans

    < messa!e driven bean is a stateess* server8side enter+rise bean ca+abe of +rocessin!messa!es based on the #M. eanRefer to +rinted sam+e

    Messa!eDriven>ean

    Refer to +rinted sam+e

    Im+orts for .ession >ean

    "ava,annotationReso%rce

    Reso%rce(ma++edName W"ms5o+icConnectionFactor&W)+rivate ConnectionFactor& to+icConnectionFactor&Sto+icConnection

    to+icConnectionFactor&createConnection()S

    "ava,"msConnectionFac

    tor&"ava,"msConnection

    "ava,"ms.ession .ession session to+icConnectioncreate.ession(fase*.essionean

    "ava,e"bMessa!eDriven Messa!eDriven

    "ava,e"b

  • 7/25/2019 IS2103 - Summary

    19/22

    QUICK REFERENCE GUIDE

    -@

  • 7/25/2019 IS2103 - Summary

    20/22

    QUICK REFERENCE GUIDE

    Se-urit#Invoves:

    - &Credit(C%stomer c%stomer* CreditCardD7card* do%be amo%nt) thro's =a&mentE,ce+tion H VV

    Refer to sides

    im+ort "avaan!annotationRetentionSim+ort "avaan!annotation5ar!etS

    5ar!et(H5L=E* ME57DV) Retention(RUN5IME)

    +%bic interface Roes

  • 7/25/2019 IS2103 - Summary

    21/22

    QUICK REFERENCE GUIDE

    ort Number

    RMI Defa%t =ort: -@@

    #NDI 5ransient Name .erver: @

    55= (&+erte,t 5ransfer =rotoco): ;

    55= oo4Entit&P b ne'CoectionO>oo4Entit&P()

    "ava%tiash.etS ash.etO>oo4Entit&P b ne' .etO>oo4Entit&P()

    "ava%ti.etS"ava%tiDate Date d ne' Date()DateFormat df ne'.im+eDateFormat(WMMdd&&&&W)S.trin! str dfformat(d)S

    "avate,tDateFormat

    "avate,t.im+eDateFormat

    "ava%ti5em+ora 5em+ora(va%e 5em+ora5&+eDased on the .e+aration of Concerns +rinci+e .e+arate the cient tier* b%siness o!ictier and data tier from each other 5his enhances maintainabiit& of individ%acom+onents so chan!es to one 'o%dnt aBect others

    Mode: Inc%des data and b%siness o!ic com+onents E! enter+rise beans and entities

    $ie': Dis+a& of b%siness data #.= +a!es

    Controer: >rain of the 'eb a++ication Receives cient reA%ests* +rocesses them*for'ards them to com+onents that +rocess data* and directs res%ts of the +rocessin!to View com+onents E! servets

    3b4e-t@0elational ;apping

    /-

    http://en.wikipedia.org/wiki/Domain_Name_Systemhttp://en.wikipedia.org/wiki/Domain_Name_System
  • 7/25/2019 IS2103 - Summary

    22/22

    QUICK REFERENCE GUIDE

    7R Ma++in! refers to the ma++in! of an entit&s state to reationa database tabe andco%mns

    S#stem In)rastru-ture Considerations

    Refer to 5e,tboo4 +! /

    //