Passivate Activate Serialiazables bean home comp by nikeborome

VIEWS: 1 PAGES: 5

									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

PORTABILITY
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.

<transaction-type>Bean</transaction-type>
<transaction-type>Container</transaction-type>

<enterprise-beans>
  <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
    <ejb-class>
    <local-home>
    <local>
    <persistence-type>Container, Bean?
    <primkey-field>or<prim-key-class>For ultiple fields, both optional
    <reentrant>
    <cmp-field>for all fields, Java primitive or serializa ble only
      <field-name>
    <ejb-ref>
     <ejb-ref-name>
      <ejb-ref-type>
      <home>remote home
      <remote>remote comp intrf
    <env-entry>configurable data
      <description>
      <env-entry-name>
      <env-entry-type> (only Wrappers: Character, Integer, Boolean, Double,
       Byte, Short, Long, Float)
      <env-entry-value>
    <security-role-ref>
      <role-link>
      <role-name> req.
  <session>
    <ejb-name>WashingService
    <ejb-class>com.ejbcertificate.laundry.WashingServiceBean
    <resource-ref>
      <res-ref-name>jdbc/laundryDB
      <res-type>javax.sql.DataSource
      <res-auth>Container(deployer), Application(bean sign -on)
      <res-sharing-scope>Shareable {Weather connections are shareable}

<assempbly-descriptor>
  <security-role>
    <description>
    <role-name> req.

<run-as>
  <role-name>

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

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

<assembly-descriptor>
  <container-transaction>
    <method>s
      <description>
      <ejb-name>
      <method-name>myMethod, *
      <method-params>
        <method-param>
    <trans-attribute>NotSupp,Req,Supp,ReqNew,Mand,Nev

<resource-ref>
  <res-ref-name>jdbc/catalogDB
  <res-type>javax.sql.DataSource
  <res-auth>Container
  <res-sharing-scope>Shareable

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

BMT does NOT inherit client transactional context
TRANSACTION ATTRIBUTES obligatory:
  -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),
  ejbRemove(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
Reserved words: SELECT, FROM, WHERE, DISTINCT, OBJECT, NULL, TRUE, FALSE, NOT,
AND, OR, BETWEEN, LIKE, IN, AS, UNKNOWN, EMPTY, MEMBER, OF and IS
- select object(o) from order o, in(o.lineitems) li where li.item_type = 'HDTV'
Exception - checked must be handled
  CreateException{AE}(check)[CE]
    DuplicateKeyException{AE}(check)
  FinderException{AE}(check)[FE]
    ObjectNotFoundException{AE}(check)[ONFE] - thr by single finders
  HeuristicMixedException(javax.transaction)[HME]
  HeuristicRollbackException(javax.transaction)[HRE]
  IOException
    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}
  NotSupportedException(javax.transaction)[NSE]
  RemoveException[REME](check){AE} -
    - {Container does not allow the EJB object to be removed}
  RollbackException(javax.transaction)[ROLLE]
  SystemException(javax.transaction)[SE]
RuntimeException **UNCHECK**
  IllegalStateException{System Ex.}[ISE] -
    {Instance not allowed to call method. Modify pk fields after ejbCreate}
  SecurityException[SECE]
  EJBException[EJBE]{System Ex.} -
    - {Unexpected error(e.g:: db connection down), system failure}
    AccessLocalException
    EJBException
    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];
BeanImplementation
  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]
HomeImplementation
  {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};
Implementation
       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.
  If BMT <acknowledge-mode>JMS_AUTO_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE is used
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
Deployer
       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.
Container
  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.

persone(one)->telefoni(many)

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