EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

org.eclipse.persistence.descriptors
Class TablePerMultitenantPolicy

java.lang.Object
  extended by org.eclipse.persistence.descriptors.TablePerMultitenantPolicy
All Implemented Interfaces:
java.lang.Cloneable, MultitenantPolicy

public class TablePerMultitenantPolicy
extends java.lang.Object
implements MultitenantPolicy, java.lang.Cloneable

A table per tenant multitenant policy. Tables can either be per schema or augmented with a prefix or suffix per tenant.

Author:
Guy Pelletier
Since:
EclipseLink 2.4

Field Summary
protected  java.lang.String contextProperty
           
protected  java.lang.String contextTenant
           
protected  ClassDescriptor descriptor
           
protected  java.util.Map<org.eclipse.persistence.internal.helper.DatabaseTable,org.eclipse.persistence.internal.helper.DatabaseTable> tablePerTenantTables
           
protected  TenantTableDiscriminatorType type
           
 
Constructor Summary
TablePerMultitenantPolicy(ClassDescriptor desc)
           
 
Method Summary
 void addFieldsToRow(org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL:
 void addToTableDefinition(TableDefinition tableDefinition)
          INTERNAL:
 MultitenantPolicy clone(ClassDescriptor descriptor)
          INTERNAL: Multitenant policies are cloned per inheritance subclass.
 java.lang.String getContextProperty()
          INTERNAL: Return the context property for this table per tenant policy.
 org.eclipse.persistence.internal.helper.DatabaseTable getTable(org.eclipse.persistence.internal.helper.DatabaseTable table)
          INTERNAL: Return the new database table associated with this tenant.
 org.eclipse.persistence.internal.helper.DatabaseTable getTable(java.lang.String tableName)
          INTERNAL: Return the new database table associated with this tenant.
protected  java.lang.String getTableName(org.eclipse.persistence.internal.helper.DatabaseTable table, java.lang.String tenant)
          INTERNAL: Return the tenant table name.
 boolean hasContextTenant()
          INTERNAL: Return true if the tenant has been set for this policy.
 void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL:
 boolean isPrefixPerTable()
          PUBLIC: Return true if this descriptor requires a prefix to the table per tenant.
 boolean isSchemaPerTable()
          PUBLIC: Return true if this descriptor requires a table schema per tenant.
 boolean isSingleTableMultitenantPolicy()
          INTERNAL:
 boolean isSuffixPerTable()
          PUBLIC: Return true if this descriptor requires a suffix to the table per tenant.
 boolean isTablePerMultitenantPolicy()
          INTERNAL:
 void postInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL:
 void preInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL:
 void setContextProperty(java.lang.String contextProperty)
          PUBLIC: Set the context property used to define the table per tenant.
 void setContextTenant(java.lang.String contextTenant)
          INTERNAL:
protected  void setTablePerTenant()
          INTERNAL: This method is used to update the table per tenant descriptor with a table per tenant prefix or suffix on its associated tables.
protected  void setTableSchemaPerTenant()
          INTERNAL: This method is used to update the table per tenant descriptor with a table per tenant schema.
 void setTenantTableDiscriminatorType(TenantTableDiscriminatorType type)
          PUBLIC: Set the tenant table discriminator type.
 boolean shouldInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: This method is called during regular descriptor initialization.
protected  org.eclipse.persistence.internal.helper.DatabaseTable updateTable(org.eclipse.persistence.internal.helper.DatabaseTable table)
          INTERNAL: This method will update the table by cloning it and setting a new name on it.
 boolean usesContextProperty(java.lang.String property)
          INTERNAL: Return true if this policy accepts the given property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

descriptor

protected ClassDescriptor descriptor

tablePerTenantTables

protected java.util.Map<org.eclipse.persistence.internal.helper.DatabaseTable,org.eclipse.persistence.internal.helper.DatabaseTable> tablePerTenantTables

type

protected TenantTableDiscriminatorType type

contextProperty

protected java.lang.String contextProperty

contextTenant

protected java.lang.String contextTenant
Constructor Detail

TablePerMultitenantPolicy

public TablePerMultitenantPolicy(ClassDescriptor desc)
Method Detail

addFieldsToRow

public void addFieldsToRow(org.eclipse.persistence.internal.sessions.AbstractRecord row,
                           org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:

Specified by:
addFieldsToRow in interface MultitenantPolicy

addToTableDefinition

public void addToTableDefinition(TableDefinition tableDefinition)
INTERNAL:

Specified by:
addToTableDefinition in interface MultitenantPolicy

clone

public MultitenantPolicy clone(ClassDescriptor descriptor)
INTERNAL: Multitenant policies are cloned per inheritance subclass.

Specified by:
clone in interface MultitenantPolicy

getContextProperty

public java.lang.String getContextProperty()
INTERNAL: Return the context property for this table per tenant policy.


getTable

public org.eclipse.persistence.internal.helper.DatabaseTable getTable(java.lang.String tableName)
INTERNAL: Return the new database table associated with this tenant.


getTable

public org.eclipse.persistence.internal.helper.DatabaseTable getTable(org.eclipse.persistence.internal.helper.DatabaseTable table)
INTERNAL: Return the new database table associated with this tenant.


getTableName

protected java.lang.String getTableName(org.eclipse.persistence.internal.helper.DatabaseTable table,
                                        java.lang.String tenant)
INTERNAL: Return the tenant table name.


hasContextTenant

public boolean hasContextTenant()
INTERNAL: Return true if the tenant has been set for this policy.


initialize

public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
                throws DescriptorException
INTERNAL:

Specified by:
initialize in interface MultitenantPolicy
Throws:
DescriptorException

isPrefixPerTable

public boolean isPrefixPerTable()
PUBLIC: Return true if this descriptor requires a prefix to the table per tenant.


isSchemaPerTable

public boolean isSchemaPerTable()
PUBLIC: Return true if this descriptor requires a table schema per tenant.


isSingleTableMultitenantPolicy

public boolean isSingleTableMultitenantPolicy()
INTERNAL:

Specified by:
isSingleTableMultitenantPolicy in interface MultitenantPolicy

isSuffixPerTable

public boolean isSuffixPerTable()
PUBLIC: Return true if this descriptor requires a suffix to the table per tenant.


isTablePerMultitenantPolicy

public boolean isTablePerMultitenantPolicy()
INTERNAL:

Specified by:
isTablePerMultitenantPolicy in interface MultitenantPolicy

postInitialize

public void postInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:

Specified by:
postInitialize in interface MultitenantPolicy

preInitialize

public void preInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
                   throws DescriptorException
INTERNAL:

Specified by:
preInitialize in interface MultitenantPolicy
Throws:
DescriptorException

setTenantTableDiscriminatorType

public void setTenantTableDiscriminatorType(TenantTableDiscriminatorType type)
PUBLIC: Set the tenant table discriminator type.


setContextProperty

public void setContextProperty(java.lang.String contextProperty)
PUBLIC: Set the context property used to define the table per tenant. If it is not set by the user, the policy defaults it to the multitenant property default of "eclipselink.tenant-id"


setTablePerTenant

protected void setTablePerTenant()
INTERNAL: This method is used to update the table per tenant descriptor with a table per tenant prefix or suffix on its associated tables. This includes any relation tables from mappings. If the given session is a client session than we must clone the tables. Outside of a client session, assume global usage and no cloning is needed. This method should only be called at the start of a client session lifecycle and should only be called once.


setTableSchemaPerTenant

protected void setTableSchemaPerTenant()
INTERNAL: This method is used to update the table per tenant descriptor with a table per tenant schema. This includes any relation tables from mappings. This will be done through the setting of a table qualifier on the tables. This method should only be called at the start of a client session lifecycle and should only be called once.


setContextTenant

public void setContextTenant(java.lang.String contextTenant)
INTERNAL:


shouldInitialize

public boolean shouldInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: This method is called during regular descriptor initialization. When initializing at that level no cloning should be done on when setting the context tenant.


updateTable

protected org.eclipse.persistence.internal.helper.DatabaseTable updateTable(org.eclipse.persistence.internal.helper.DatabaseTable table)
INTERNAL: This method will update the table by cloning it and setting a new name on it. The table association will be stored here as well for ease of future look up.


usesContextProperty

public boolean usesContextProperty(java.lang.String property)
INTERNAL: Return true if this policy accepts the given property.


EclipseLink 2.4.2, build 'v20130514-5956486' API Reference