Passivate Activate Serialiazables bean home comp by nikeborome


									Passivate/Activate: Serialiazables, bean's home, comp. intrf., SessionContext,
  UserTransaction and res, manag. conn. fact. (i.e. javax.sql.Datasource), nulls
EB lifecycle: pooled=P, ready=R, not exists=NE - Not caused by client=Cont
  constructor{instance created}, setEntityContext NE->P, ejbFind P->P,
  ejbActivate P->R Cont, ejbCreate P->R, ejbHome P->?, bm R->R, ejbRemove R->P,
  ejbPassivate R->P, SB remove R->NE, unsetEntityContext P->NE, ejbStore ?->P
PrimaryKey: hashCode(), equals(), all fields CM public
SSB killed with no ejbRemove:
  [SE] in business method, time out when passivated, server crash
SE in SSB BMT bm:log Ex,mark trans for rollback,discard B,[RE]or[EJBE] to clt
SE in SSB CMT bm SessionSynchroniz.:afterBegin, business method, after Completion
AE in bm:clt chance to recover trans. if CMT and cont. started trans then
  if not marked for rollback then commit else rollback, rethrow AE
-get ref to Home and EJBObject
  SfullSB: ejbCr, ejbPass, ejbAct, ejbRem, bm
-get security client info
  SfullSB: ejbCr, ejbPass, ejbAct, ejbRem, bm
  EBMP: ejbCreate, ejbLoad, ejbPostCreate
-get User-Transaction refs for BMT
  SfullSB: ejbCr, ejbPass, ejbAct, ejbRem, bm
  SlessSB: bm
-access Resource Manager and JNDI env
  SfullSB: ejbCr, ejbPass, ejbAct, ejbRem, bm
  MDB: setMDC, ejbCr, ejbRem, onMess
-access other beans
  SfullSB: ejbCr, ejbPass, ejbAct, ejbRem, bm
  MDB: onMess
-rollback trans for CMT
  SfullSB: bm, no ejbCr, no ejbRem
-determine if transaction is rolled back for CMT
  SfullSB: bm, no ejbCr, no ejbRem

J2SE 1.3, EJB 2.0, JDBC 2.0, JNDI 1.2, JTA 1.0.1, JMS 1.0.2, JAVA mail 1.1, JAXP
The EB must not attempt to define a class in a package. Reserved for the EJB
Container this would create a security hole.


  <entity id="OrderIdGenerator">
    <ejb-name>req. unique among the names of the bean's in the same ejb-jar file
    <abstract-schema-name>req. OrderIdGenerator, unique within the ejb-jar file
    <persistence-type>Container, Bean?
    <primkey-field>or<prim-key-class>For ultiple fields, both optional
    <cmp-field>for all fields, Java primitive or serializa ble only
      <home>remote home
      <remote>remote comp intrf
    <env-entry>configurable data
      <env-entry-type> (only Wrappers: Character, Integer, Boolean, Double,
       Byte, Short, Long, Float)
      <role-name> req.
      <res-auth>Container(deployer), Application(bean sign -on)
      <res-sharing-scope>Shareable {Weather connections are shareable}

    <role-name> req.


<method-permission>assign the role required to have access to an EJB method
  <unchecked/>takes place of <role-name>
  <method>1 or more
    <method-intf>Home, Remote, LocalHome or Local
    <method-name>myMethod, *

<ejb-relation>relationship between two EB CMP
  <ejb-relationship-role>exactly TWO relationship role declarations
    <multiplicity> req.
    <(ejb-)relationship-role-source> req.
      <cmr-field-name> req.
      <cmr-field-type> req. Collection or Set

      <method-name>myMethod, *


<cascade-delete>The other role has multiplicity One
<exclude-list>Methods client never invokes

BMT does NOT inherit client transactional context
  -SB CMT: All business method in component intrf
  -EB CMT(only!): All business method in component intrf
                  All Bean Provider method in Home intrf
                  Any remove() method the client can acess
unspecified, no transaction assoc:constructor(SB), ejbPassivate, ajbActivate,
  setSessionContext, ejbRemove, and afterCompletion, ejbCreate(SB),
UserTransaction available, caller transaction context: ejbLoad, ejbRemove?,
  ejbStore, onMessage,afterBegin,beforeCompletion, ejbCreate(EB)
Tr. Attr.           Client’s T Tr. with business method
NotSupported(MDB)   none        none
                    T1          none
Required(MDB)       none        T2
                    T1          T1
Supports            none        none
                    T1          T1
RequiresNew         none        T2
                    T1          T2
Mandatory           none        error N/A (TransactionRequiredException)
                    T1          T1
Never               none        none
                    T1          error

*** EJB-QL ***
_ one; % any; no comments; no *; ?1; Every expression in EJB QL has a type.
Data model for CMP does not support inheritance. Case insensitive
- select object(o) from order o, in(o.lineitems) li where li.item_type = 'HDTV'
Exception - checked must be handled
    ObjectNotFoundException{AE}(check)[ONFE] - thr by single finders
    RemoteException[RE](java.rmi)(check) {Method failed due to a system failure
        client no allowed to call bm}
      TransactionRolledbackException(javax.transaction) When non AE, and in trans
    NoSuchObjectException(java.rmi)[NSOE] - {Object called from remote no longer
      exists in the remote vm}
  RemoveException[REME](check){AE} -
    - {Container does not allow the EJB object to be removed}
RuntimeException **UNCHECK**
  IllegalStateException{System Ex.}[ISE] -
    {Instance not allowed to call method. Modify pk fields after ejbCreate}
  EJBException[EJBE]{System Ex.} -
    - {Unexpected error(e.g:: db connection down), system failure}
    NoSuchEntityException{EB removed from db;Thrw ejbLoad,ejbStore,bsnss mthods}
    NoSuchObjectLocalException{System Ex.} - {Object called from local no longer
      exists in the local vm}
    TransactionRequiredLocalException{System Ex.}
    TransactionRolledbackLocalException(javax.ejb)- Trans definitely rolled back

Interface EnterpriseBean {client don't call this directly}
    Interface EntityBean
    v ejbActivate[EJBE,RE]; v ejbLoad[EJBE,RE](container impl.);
    v ejbPassivate[EJBE,RE]; v ejbRemove[EJBE,RE,REME](ejbLoad is called before)
    v ejbStore[EJBE,RE](container impl.);
    v setEntityContext(EntityContext ctx)[EJBE,RE];
    v unsetEntityContext[EJBE,RE];
    Interface MessageDrivenBean
    v ejbRemove[EJBE];
    v setMessageDrivenContext(MessageDrivenContext ctx)[EJBE];
    Interface SessionBean
    v ejbActivate[EJBE,RE](no SlessSB); v ejbPassivate[EJBE,RE](no SlessSB);
    v ejbRemove[EJBE,REME];
    v setSessionContext(SessionContext ctx)[EJBE,RE];
  constructor {EB must have a no args}
  create(){EB opt.: insert a row to db};
  {SB,MDB: v} ejbCreate<>{
       -SB can retrieve ref to EJBObject and home
       -SlessB exactly one no-args & no clt security info & no trans
       -SfullB at least one & see above
    -ex defined only in home};
  ejbFind<>; ejbHome(EB req); ejbPostCreate() set values of CMR fields;
  ejbSelect<> internal query

Interface javax.transaction.UserTransaction (BMT only)
  {UserTransaction t = (UserTransaction)ic.lookup(“java:comp/UserTransaction”)}
  v begin[NSE,SE]; v commit[ROLLE,HME,HRE,SECE,ISE,SE];
  int getStatus[SE]; v rollback[SE,SECE,ISE];
  v setRollbackOnly[ISE,SE]; v setTransactionTimeout(int seconds)[SE];

Interface EJBContext
  Identity getCallerIdentity(depr); Principal getCallerPrincipal(no MDB,
    no SSB.setSessionContenxt, no EB ejbAct ejbPass, security context req,
    no trans req)[ISE]{get security client info}
  EJBHome getEJBHome[ISE](no MDB); EJBLocalHome getEJBLocalHome[ISE];
  boolean getRollbackOnly(MDB, CMT - Req,ReqNew,Mand)[ISE];
  TimerService getTimerService[ISE];
  UserTransaction getUserTransaction[ISE](no EB, BMT only SessBeans or MDB);
  boolean isCallerInRole(String roleName)[ISE](no MDB){
    HttpServletRequest.isUserInRole for Web Cmponents}
  v setRollbackOnly(MDB, CMT - Req,ReqNew,Mand)[ISE];
    Interface SessionContext
    EJBLocalObject getEJBLocalObject[ISE]; EJBObject getEJBObject[ISE];
    MessageContext getMessageContext[ISE]
    Interface EntityContext
    EJBLocalObject getEJBLocalObject[ISE]; EJBObject getEJBObject[ISE](no EB
      ejbCreate); Object getPrimaryKey[ISE];
    Interface MessageDrivenContext

Interface EJBHome
  (business method cannot begin with remove, find, create (both Intrfs))
  EJBMetaData getEJBMetaData[RE]; HomeHandle getHomeHandle[RE];
  v remove(Handle handle)[RE,REME]; v remove(Object primaryKey)[RE,REME];
Interface EJBLocalHome
  v remove(Object primaryKey)[EJBE,REME]
  {SB: comp intrf} create<> [CE,RE]; {EB opt. client may not be allowed}
  findByPrimaryKey[FE](EB req., when no EB found throws [ONFE]);
  ejbHome<> not specific to an instance
  find<>; remove{EB remote reference client stub is invalidated, delete from db,
    EJB back to pool}

Interface EJBObject {component interface, this is what client see}
  EJBHome getEJBHome[RE]; Handle getHandle[RE]; Object getPrimaryKey[RE];
  boolean isIdentical(EJBObject obj)[RE]{SfullSB false,SlessB true if same home}
  v remove[RE,REME];
Interface EJBLocalObject
  EJBLocalHome getEJBLocalHome[EJBE]; Object getPrimaryKey[EJBE];
  boolean isIdentical(EJBLocalObject obj)[EJBE]{SfullSB false,SlessB true if
    same home}; v remove[RME,EJBE] {EJBE thrown when double called};
       EB: no accessor method defined

PrimaryKey implementation
  Public constructor no parameters. All fields public and subset of the names of
  cmp fields.

Interface Handle
  ejbObject getEJBObject[RE]

Interface SessionSynchronization (no SlessSB)
  o-->(CMT only)<--o
  v afterBegin[EJBE,RE]; v afterCompletion(boolean committed)[EJBE,RE];
  v beforeCompletion[EJBE,RE];

*** MESSAGE DRIVEN BEANS *** does not throw AE
Cannot throw checked exceptions, no component intrf, no conversational state,
no client-visible identity
Message aknowledge auto handled by cont for BMT & CMT.
  If CMT is part of trans commit.
Durable Subscription - Topic only no Queue, defined in DD
newInstance(), setMessageDrivenContext(), ejbCreate()
SE in MDB: log, no ex to client, discard ins,if CMT and in trans. then rollback,
  if BMT mark trans for rollback A mex is placed back on the mex queue if the tr
rolls back for CMT
May not be in ejb-jar file
Interface MessageDrivenBean
  v ejbRemove[EJBE];
  v setMessageDrivenContext(MessageDrivenContext ctx)[EJBE];
Interface MessageListener(javax.jms)
  v onMessage(Message message)

Bean Provider: produces an ejb-jar file whit EB
  Finder EJB-QL in depl. descr.
  Declares the references(EJB and resource connection factory) in the DD
  Declares all env entries that can be accessed from bean's code.
  if <res-auth>Application</res-auth> supply the principle mapping information
Bean Provider & Application Assembler
  descr. all the req. for the caller's principal management of B invocations
Application Assembler
  Defines security roles and method permiss. Assemble beans.
  Modify the relationship names defined in the ejb -relation-name elements.
  Links an EJB reference to a target enterprise bean.
  Ensures the target enterp method is type-compatible with the declared EJB ref.
  if <res-auth>Container</res-auth> supply the principle mapping information
Application Assembler & Deployer
  Define appropriate security policies for the application
       Set up appropriate security policies for the application
  Assign principals to security roles and "run-as" identities in depl. descr.
  Assign security domain and principal realm to the application.
  Binds the existnig homes in the target operational environment.
  Ensures that all the declared EJB references are bound to the homes
System administrator

  add, removes and configures resource managers in the EJB environment.
  Provides tools that notify that there are unresolved EJB references
EJB Server provider
  Specialist in distributed transaction management, distribute objects, and
  other lower-level system-level services. A typical EJB Server Provider is an
  OS vendor, middleware vendor, or database vendor.

NEW specification: MDB, Local client view, EJB-QL
architecture goals: provide a standard component architecture for building
  distributed business applicat., compatible with the CORBA protocols, no tcp/ip
GOALS: Integration of EJB with the Java Message Service.
  Local client view and support for efficient access to EB from local clients.
  Improved support for the persistence of entity beans.
  Improved support for the management of relationships among entity beans.
  Query syntax for entity bean finder methods.
  Support for additional methods in the home interface.
  Network interoperability among EJB servers.


EJB client call bm on SB removed [RE], [ONFE]
clt call remove() on remote bean, if clt remote [RE], if clt local [EJBE]
clt call ejbLocalHome.remove(Object primaryKey) on SSB [REME]
clt call accessor method on removed EB or
  invoke method on SB removed,if clt remote [NSOE], if clt local[NSOLE]clt
local/remote call home.remove(java.lang.Object primaryKey) on SB [REME]
clt invokes a session object that does not exist, if clt loc[NSOLE],if rem[NSOE]

To top