com.gigaspaces.converter.pojo
Class Pojo2ExternalEntryConverter

java.lang.Object
  extended by com.gigaspaces.converter.pojo.ConverterHelper
      extended by com.gigaspaces.converter.pojo.Pojo2ExternalEntryConverter
All Implemented Interfaces:
IPojoToEntryConverter

public class Pojo2ExternalEntryConverter
extends ConverterHelper
implements IPojoToEntryConverter

This class is the implementation of the interface IPojoToEntryConverter. It has two major public methods: toEntry(Object POJO), and toPojo(Entry entry). The method toEntry(Object POJO) converts the POJO(java bean) into a GigaSpaces ExternalEntry object. The method toPojo(Entry entry) transforms the GigaSpaces ExternalEntry object into a POJO. This class extends the ConverterHelper.java class, which initiates the POJODescription object for each POJO. The POJODescriptor is initiated by parsing a gs.xml file, or by an annotation if the gs.xml file does not exist which describes the map values of the * POJO to the Entry.


Constructor Summary
Pojo2ExternalEntryConverter()
          Empty constructor
Pojo2ExternalEntryConverter(boolean isInvokePropSet)
          Constructor
 
Method Summary
 void clean()
          Clean all the caching data from the converter
 com.gigaspaces.converter.pojo.POJODescription getPOJODescription(Class pojoClass, String className)
          Gets the correct POJODescription object that describes the POJO class name.
static String getterNameFromPropertyName(String propName)
           
static String setterNameFromPropertyName(String propName)
           
 IGSEntry toEntry(Object pojo)
          Transforms the supplied POJO (Plain Old Java Object) into an ExternalEntry object, using the POJODescription object, which maps the POJO fields into the space Entry.
 IGSEntry toEntry(Object pojo, boolean isIgnoreGenerateAutoPK)
          Converts a POJO that has a primary key and auto-generator declared, and you don't want to generate the primary key.
 Object toPojoFromIGSEntry(IGSEntry igsEntry)
          Transforms the supplied IGSEntry into a POJO (Plain Old Java Object).
 
Methods inherited from class com.gigaspaces.converter.pojo.ConverterHelper
afterPropertiesSet, getConfiguration, getFile, getInputStream, getURL, setMappingDirectoryLocations, setMappingJarLocations, setMappingResources
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pojo2ExternalEntryConverter

public Pojo2ExternalEntryConverter()
Empty constructor


Pojo2ExternalEntryConverter

public Pojo2ExternalEntryConverter(boolean isInvokePropSet)
Constructor

Parameters:
isInvokePropSet - indicate if to invoke the method afterProertiesSet() after setMapping..() methods
Method Detail

toEntry

public IGSEntry toEntry(Object pojo)
Transforms the supplied POJO (Plain Old Java Object) into an ExternalEntry object, using the POJODescription object, which maps the POJO fields into the space Entry. If there is no POJODescriptor object, a default one is created. The boolean isIgnoreGenerateAutoPK is set to false.

Specified by:
toEntry in interface IPojoToEntryConverter
Parameters:
pojo - The POJO that is converted.
Returns:
The IGSEntry implementation. TODO: Add operation type to method signature: read, write, update, etc.

toEntry

public IGSEntry toEntry(Object pojo,
                        boolean isIgnoreGenerateAutoPK)
Converts a POJO that has a primary key and auto-generator declared, and you don't want to generate the primary key. This method transforms the supplied POJO (Plain Old Java Object) into an Entry implementation, according to some specific policy or implementation. The boolean isIgnoreGenerateAutoPK method indicates if to generate a primary key when at least one of the POJO's fields is declared as primary key, auto-generated, and has a null value. When IgnoreGenerateAutoPK is true, it does not create a new UID, and the POJO's field is not updated with the new primary key. When false, IgnoreGenerateAutoPK does create a UID. The default of the toEntry(Object pojo) method is false.

Specified by:
toEntry in interface IPojoToEntryConverter
Parameters:
pojo - the POJO
isIgnoreGenerateAutoPK - boolean Indicates that the POJO has a primary key and an auto-generator declared, and you don't want to generate the primary key.
Returns:
The Entry's implementation.
Throws:
InvocationTargetException
IllegalAccessException
IllegalArgumentException

setterNameFromPropertyName

public static String setterNameFromPropertyName(String propName)

getterNameFromPropertyName

public static String getterNameFromPropertyName(String propName)

toPojoFromIGSEntry

public Object toPojoFromIGSEntry(IGSEntry igsEntry)
Transforms the supplied IGSEntry into a POJO (Plain Old Java Object). This method converts the ExternalEntry object to a POJO, using the POJODescription object.

Specified by:
toPojoFromIGSEntry in interface IPojoToEntryConverter
Parameters:
igsEntry - - The IGSEntry.
Returns:
The POJO.
Throws:
InvocationTargetException
IllegalAccessException
IllegalArgumentException
IllegalAccessException
InstantiationException

getPOJODescription

public com.gigaspaces.converter.pojo.POJODescription getPOJODescription(Class pojoClass,
                                                                        String className)
Gets the correct POJODescription object that describes the POJO class name. If there is no POJODescriptor, a default POJODescriptor is created.

Specified by:
getPOJODescription in interface IPojoToEntryConverter
Parameters:
className - - The class name.
Returns:
The POJODescription of the class.

clean

public void clean()
Clean all the caching data from the converter

Specified by:
clean in interface IPojoToEntryConverter