POJO Lifecycle in Service Grid

  GigaSpaces 5.X

Documentation Home
Quick Start Guide
Release Notes

Previous release

  Search Here
Searching GigaSpaces Platform 5.X Documentation

                                               

Summary: POJO support allows invoking lifecycle methods on the bean, if it has several methods defined.

Overview

POJO support includes the capability to invoke lifecycle methods on the bean if the bean has the following methods defined. There are no interfaces to implement, if any of these methods are defined, they are invoked by the bean infrastructure.

public void initialized();
public void started();
public void advertised();
public void unadvertised();
public void destroyed();

Example

Below is a POJO that includes the lifecycle methods implemented:

package example;

import net.jini.space.JavaSpace;
import java.util.Date;

public class HelloImpl implements Hello {
    public String sayHello(String greetings) 
	{
        System.out.println("["+new Date()+"] Greeter says : "+greetings);
        return("Hello!");
    }

	public void initialized()
	{
		System.out.println("**** initialized ****");
	}

	public void started()
	{
		System.out.println("**** started ****");
	}

	public void advertised()
	{
		System.out.println("**** advertised ****");
	}

	public void unadvertised()
	{
		System.out.println("**** unadvertised ****");
	}

	public void destroyed()
	{
		System.out.println("**** destroyed ****");
	}
}

When deploying and un-deploying the bean, the following output is displayed in the GSC console hosting the bean:

INFO: Allocating [Hello] to 192.1.1.33
**** initialized ****
**** started ****
**** advertised ****
Mar 31, 2007 1:52:05 PM org.jini.rio.monitor.ServiceProvisioner$ProvisionTask doProvision
INFO: Allocated [Hello] to 192.1.1.33
Mar 31, 2007 1:52:05 PM org.jini.rio.monitor.ServiceElementManager$JSBProvisionListener serviceProvisioned
FINE: [Hello World Example:Hello] service provisioned, instance=Instance=[1] Proxy=[$Proxy32] ID=[72f8d157-31e1-43fa-97a
0-d0f8ca82e364] HostAddress=[192.1.1.33]
Mar 31, 2007 1:52:05 PM org.jini.rio.monitor.ServiceElementManager addServiceBeanInstance
FINEST: [Hello World Example:Hello] Added SBI = 1, 72f8d157-31e1-43fa-97a0-d0f8ca82e364
     Instance ID list [1]
     ServiceBeanInstance List:
     Instance=[1] Proxy=[$Proxy32] ID=[72f8d157-31e1-43fa-97a0-d0f8ca82e364] HostAddress=[192.1.1.33]
Mar 31, 2007 1:52:13 PM org.jini.rio.monitor.ServiceElementManager destroyServices
FINE: Terminating [1] instances of "example.Hello" ...
Mar 31, 2007 1:52:13 PM org.jini.rio.monitor.ServiceElementManager destroyServices
FINE: Destroying [1] of [1] "example.Hello" instances ...
**** unadvertised ****
Mar 31, 2007 1:52:13 PM org.jini.rio.cybernode.TransientServiceStatementManager remove
INFO: Hello is Inactive, Removed Records.
**** destroyed ****
Mar 31, 2007 1:52:13 PM org.jini.rio.monitor.ServiceElementManager removeInstanceID
FINEST: [Hello World Example:Hello] Removed [Hello] Instance ID=1, Action=[clean]
     ServiceBeanInstance List: {empty}
Mar 31, 2007 1:52:13 PM org.jini.rio.monitor.ServiceElementManager destroyServices
FINE: Completed "example.Hello" service termination
Mar 31, 2007 1:52:13 PM org.jini.rio.monitor.ProvisionMonitorImpl$OpStringManager terminate
FINE: OpStringManager [GS6:OpenSpaces Hello World Example] terminated

POJO Lifecycle Flow

RELATED TOPICS

Declaring Elements Globally in Deployment Descriptor
Declaring Service UI in Deployment Descriptor
Deployment Descriptor Codebase Element
Deployment Descriptor DeploymentSchedule Element
Deployment Descriptor Parameters and Configuration Elements
Deployment Descriptor SharedComponent Element
Deployment Descriptor SLA Element
deploy - Service Grid CLI
Fixed and Dynamic ServiceBean ProvisionType
Injecting Deployment Descriptor Properties into POJOs
POJO Lifecycle in Service Grid
Proactive Cache
redeploy - Service Grid CLI
Rio OperationalString
Service Associations
Service Deployment Descriptor
Service Grid ClassLoader Hierarchy
undeploy - Service Grid CLI
Using Service Grid to Deploy Partitioned Space
Using Service Grid to Deploy Partitioned Space with Backup
Using Service Grid to Deploy Replicated Space
Using Service Grid to Deploy Space
Using Service Grid to Deploy Spring Applications
Using System Properties for Deployment Descriptor Element Values

Wiki Content Tree


Your Feedback Needed!

We need your help to improve this wiki site. If you have any suggestions or corrections, write to us at techw@gigaspaces.com. Please provide a link to the wiki page you are referring to.

Labels