Default passivation time of JBoss

Source: Internet
Author: User

D: \ developtool \ jboss-4.2.2.GA \ Server \ Default \ conf \ standardjboss. xml

Find the standard stateful sessionbean as follows:

 <  Container - Configuration  >        <  Container - Name  > Standard stateful sessionbean </  Container -Name >        <  Call -Logging  > False </  Call -Logging >        <  Invoker - Proxy - Binding - Name  > Stateful-unified-invoker </  Invoker -Proxy-binding-name >        < Container - Interceptors  >          <  Interceptor  > Org. JBoss. EJB. plugins. proxyfactoryfinderinterceptor </  Interceptor  >          <  Interceptor  > Org. JBoss. EJB. plugins. loginterceptor </  Interceptor  >         <! -- CMT -->          <  Interceptor   Transaction = "Container"  > Org. JBoss. EJB. plugins. txinterceptorcmt </  Interceptor  >          <  Interceptor   Transaction = "Container"  > Org. JBoss. EJB. plugins. callvalidationinterceptor</  Interceptor  >          <  Interceptor   Transaction = "Container"  > Org. JBoss. EJB. plugins. statefulsessioninstanceinterceptor </  Interceptor  >          <! -- BMT -->          <  Interceptor   Transaction ="Bean"  > Org. JBoss. EJB. plugins. statefulsessioninstanceinterceptor </  Interceptor  >          <  Interceptor   Transaction = "Bean"  > Org. JBoss. EJB. plugins. txinterceptorbmt </  Interceptor  >          <  Interceptor  Transaction = "Bean"  > Org. JBoss. EJB. plugins. callvalidationinterceptor </  Interceptor  >          <  Interceptor  > Org. JBoss. Resource. connectionmanager. cachedconnectioninterceptor </  Interceptor  >          <  Interceptor > Org. JBoss. EJB. plugins. securityinterceptor </  Interceptor  >        </  Container -Interceptors >        <  Instance - Cache  > Org. JBoss. EJB. plugins. statefulsessioninstancecache </  Instance -Cache >       <  Persistence - Manager  > Org. JBoss. EJB. plugins. statefulsessionfilepersistencemanager </  Persistence -Manager >        <  Container - Cache - Conf  >          <  Cache - Policy > Org. JBoss. EJB. plugins. lrustatefulcontextcachepolicy </  Cache -Policy >          <  Cache - Policy - Conf  >            <  Min - Capacity  > 50 </  Min -Capacity>            <  Max - Capacity  > 1000000 </  Max -Capacity >            <  Remover - Period  > 1800 </  Remover -Period >            < Max - Bean - Life  > 1800 </  Max -Bean-life >            <  Overager - Period  > 300 </  Overager -Period >            < Max - Bean - Age  > 600 </  Max -Bean-age >            <  Resizer - Period  > 400 </  Resizer -Period >            < Max - Cache - Miss - Period  > 60 </  Max -Cache-miss-Period >            <  Min - Cache - Miss - Period  > 1 </ Min -Cache-miss-Period >            <  Cache - Load - Factor  > 0.75 </  Cache -Load-Factor >          </  Cache -Policy-Conf >        </  Container -Cache-Conf>        <  Container - Pool - Conf  >          <  Maximumsize  > 100 </  Maximumsize  >        </  Container -Pool-Conf >      </ Container -Configuration > 
 
 
 
Where<Max-Bean-Age>600</Max-Bean-age>It is the default JBoss time and can be modified by yourself.
 
 
 
EJB ServerCode:
 Package Com. Persia. EJB; Import Javax. annotation. postconstruct;Import Javax. annotation. predestroy; Import Javax. EJB. init; Import Javax. EJB. postactivate; Import Javax. EJB. prepassivate; Import Javax. EJB. Remote; Import Javax. EJB. Remove; Import Javax. EJB. stateful; @ stateful @ remote ({lifecycle. Class }) Public   Class Lifecyclebean Implements Lifecycle {Public String say (){ Try {Thread. Sleep (1000*30 );} Catch (Interruptedexception e) {e. printstacktrace ();} Return " This is an example of the life cycle of the Session Bean -- call the sleep method ";}@ Init Public   Void Initialize () {system. Out. println (" @ Init -- initialize method called ") ;}@ Postconstruct Public   Void Construct () {system. Out. println (" @ Postconstruct -- the Construct method is called. ") ;}@ PredestroyPublic   Void Exit () {system. Out. println (" @ Predestroy -- the exit method is called. ") ;}@ Prepassivate Public   Void Serialize () {system. Out. println (" @ Prepassive -- The serialize method is called. ");} @ Postactivate Public   Void Activate () {system. Out. println (" @ Postactivate -- the activate method is called. ") ;}@ Remove Public   Void Stopsession (){// Todo auto-generated method stub System. Out. println (" @ Remove --- stopsession () called ");}}

Client code:

<% Properties props = New Properties (); props. setproperty (" Java. Naming. Factory. Initial "," Org. jnp. Interfaces. namingcontextfactory "); Props. setproperty (" Java. Naming. provider. url "," Localhost: 1099 "); Props. setproperty (" Java. Naming. Factory. url. pkgs "," Org. JBoss. Naming "); Initialcontext CTX; CTX = New Initialcontext (props ); Try {Lifecycle LF = (lifecycle) Session. getattribute (" Lifecycle "); If (LF = Null ) {LF = (lifecycle) CTX. Lookup (" Lifecyclebean/remote "); Session. setattribute (" Lifecycle ", LF);} Out. println (" The client calls the say method. "); Out. println (LF. Say (); Out. println ("After 10 minutes, the container will deactivate the session bean, and the prepassivate serialize will be called. "); Out. println (" You can execute stopsession to notify the container to destroy the bean instance. The @ predestroy exit method will be called before destruction. ");} Catch (Exception e) {out. println (E. getmessage () ;}%>
 
 

JBoss console output:

11:08:17, 625 info [http11protocol] Starting coyote HTTP/1.1 on http-127.0.0.1-808011: 08: 17,656 info [ajpprotocol] Starting coyote AJP/1.3 on ajp-127.0.0.1-800911: 08: 17,671 info [server] JBoss (MX microkernel) [4.2.2.ga (Build: svntag = jboss_4_2_ga date = 200710221139)] started in 24 s: 421ms11: 09: 22,703 info [tomcatdeployer] deploy, ctxpath =/lifecycleclient, warurl =... /deploy/lifecycleclient. war/11:09:27, 796 info [tomcatdeployer] undeploy, ctxpath =/lifecycleclient, warurl =... /deploy/lifecycleclient. war/11:09:27, 843 info [tomcatdeployer] deploy, ctxpath =/lifecycleclient, warurl =... /deploy/lifecycleclient. war/11:09:48, 312 info [stdout] @ init -- initialize method called 11:09:48, 328 info [stdout] @ postconstruct -- Construct method called 11:17:46, 250 error [ajpmessage] Invalid Message recieved with signature 1824511: 18: 11,875 info [stdout] @ prepassive -- The serialize method is called.

After lunch, it is now and has not been destroyed. Do you need to manually call the @ remove method or destroy it for a long time?

If you look at <remover-period> 1800 </remover-period>, it should be 30 minutes, but it is too early.

 

 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.