Architecture

System consists of one or more instance types. For each instance type, one or many instances can be created except the system instance type for which only one instance will be created by system. Only system instance type is required. Each instance is a tenant in the multitenant system.
|--------------------------------------------------------------------------------------|
| System                                                                               |
|                                                                                      |
|      |---------------------|                   |-----------------------------|       |
|      |                     |                   |  InstanceType A             |       |
|      | InstanceType System |                   |  (DataSource_Per_Instance)  |       |
|      |     (singleton)     |                   |                             |       |
|      |                     |                   |  Instance A1                |       |
|      |---------------------|                   |  Instance A2                |       |
|                                                |-----------------------------|       |
|                                                                                      |
|                           |----------------------|                                   |
|                           |  InstanceType B      |                                   |
|                           |  (Shared_DataSource) |                                   |
|                           |                      |                                   |
|                           |  Instance B1         |                                   |
|                           |  Instance B2         |                                   |
|                           |----------------------|                                   |
|                                                                                      |
|--------------------------------------------------------------------------------------|

Instance Type

An instance type can define a number of modules, each of which defines data, session beans and view backing beans that implements application logic, model, logical view and controller.
|-----------------------------------------------------------------------|
| InstanceType                                                          |
|                                                                       |
|      |-----------------------|        |-----------------------|       |
|      | Module A              |        | Module B              |       |
|      |    Data (entities)    |        |    Data (entities)    |       |
|      |    Session Beans      |        |    Session Beans      |       |
|      |    View Backing Beans |        |    View Backing Beans |       |
|      |    (app logic, MVC)   |        |    (app logic, MVC)   |       |
|      |-----------------------|        |-----------------------|       |
|                                                                       |
|-----------------------------------------------------------------------|
Entities of all the modules in an instance are associated with the same data source of the instance.
InstanceType System: (System_DataSource) InstanceType A: (DataSource_Per_Instance) InstanceType B: (Shared_DataSource)
Multiple instances No. Singleton called "system instance". Instance metadata entities, User entities. Yes. e.g., Instance A1, Instance A2 Yes. e.g., Instance B1, Instance B2
Multitenancy One instance: one dataSource. Instance type itself and each instance has its own dataSource. Instance type itself and all its instances share one dataSource. Sharing tables using tenant discriminator column. If a discriminator column is null, the corresponding entity is associated with the instance type. e.g, a Role entity for accessing data of all instances.
Query Data Scope One instance InstanceType itself or one instance. Can not query data of all instances. InstanceType itself, one instance or all instances.

User Entity Sharing

The system instance contains Instance metadata entities and User entities. Other instances can have their own separate User entities, share the User entities of the system instance, or share User entities within the scope of their instance types.

Each instance can create Role entities for either shared or non-shared User entities. When a user logins into an instance, the User will be assigned its roles defined by the instance. When a user logins into an instance type(not a specific instance) with shared dataSource, the User will be assigned its roles defined by the instance type for accessing data of all instances of the instance type.

Example 1: Shared user accounts for all instances (User entity is not multitenant enabled).

       |-------------------------|
       | System Instance         |
       |                         |
       |   |------|    |------|  |
       |   | User |----| Role |  |
       |   |------|    |------|  |
       |------|------------------|(DS_System)
              |                   
              \-------------------------------------------\
              |                                           |
              |              |-----------------|          |              |-----------------|
              |              |  InstanceType B |          |              |  InstanceType A |
              |              |                 |          |              |                 |
              |              |    |------|     |          |              |    |------|     |
              \--------------|----| Role |     |          \--------------|----| Role |     |
              |              |    |------|     |          |              |    |------|     |
              |              |-----------------|(DS_B)    |              |-----------------|(DS_A)
              |                                           |                                 
              |                                           |                                 
              |              |-----------------|          |              |-----------------|
              |              |  Instance B1    |          |              |  Instance A1    |
              |              |                 |          |              |                 |
              |              |    |------|     |          |              |    |------|     |
              \--------------|----| Role |     |          \--------------|----| Role |     |
              |              |    |------|     |          |              |    |------|     |
              |              |-----------------|(DS_B)    |              |-----------------|(DS_A1)
              |                                           |                                 
              |                                           |                                 
              |              |-----------------|          |              |-----------------|
              |              |  Instance B2    |          |              |  Instance A2    |
              |              |                 |          |              |                 |
              |              |    |------|     |          |              |    |------|     |
              \--------------|----| Role |     |          \--------------|----| Role |     |
                             |    |------|     |                         |    |------|     |
                             |-----------------|(DS_B)                   |-----------------|(DS_A2)

Example 2: Instances of an InstanceType share user accounts (User entity is not multitenant enabled)

       |-------------------------|
       | System Instance         |
       |                         |
       |   |------|    |------|  |
       |   | User |----| Role |  |
       |   |------|    |------|  |
       |-------------------------|(DS_system)
                                                                      
                                                                      
                                |-------------------------|                         |-------------------------|                    
                                |  InstanceType B         |                         |  InstanceType A         |                   
                                |                         |                         |                         |                   
                                |   |------|    |------|  |                         |   |------|    |------|  |                   
                 |--------------|---| User |----| Role |  |          |--------------|---| User |----| Role |  |
                 |              |   |------|    |------|  |          |              |   |------|    |------|  |           
                 |              |-------------------------|(DS_B)    |              |-------------------------|(DS_A)
                 |                                                   |                                                
                 |                                                   |                                                
                 |              |-----------------|                  |              |-----------------|
                 |              |  Instance B1    |                  |              |  Instance A1    |
                 |              |                 |                  |              |                 |
                 |              |    |------|     |                  |              |    |------|     |
                 \--------------|----| Role |     |                  \--------------|----| Role |     |
                 |              |    |------|     |                  |              |    |------|     |
                 |              |-----------------|(DS_B)            |              |-----------------|(DS_A1)
                 |                                                   |
                 |                                                   |
                 |              |-----------------|                  |              |-----------------|
                 |              |  Instance B1    |                  |              |  Instance A2    |
                 |              |                 |                  |              |                 |
                 |              |    |------|     |                  |              |    |------|     |
                 \--------------|----| Role |     |                  \--------------|----| Role |     |
                                |    |------|     |                                 |    |------|     |
                                |-----------------|(DS_B)                           |-----------------|(DS_A2)
For InstanceType A with data source for each instance, shared User entities can be stored in the same database schema of the instance type or a separated database schema.

Example 3: each instance has its own User accounts.

       |-------------------------|
       | System Instance         |
       |                         |
       |   |------|    |------|  |
       |   | User |----| Role |  |
       |   |------|    |------|  |
       |-------------------------|(DS_system)
              
                             
                             |-------------------------|                  |-------------------------|
                             | InstanceType B          |                  | InstanceType A          |
                             |                         |                  |                         |
                             |   |------|    |------|  |                  |   |------|    |------|  |
                             |   | User |----| Role |  |                  |   | User |----| Role |  |
                             |   |------|    |------|  |                  |   |------|    |------|  |
                             |-------------------------|(DS_B)            |-------------------------|(DS_A)
                             
                             
                             |-------------------------|                  |-------------------------|
                             | Instance B1             |                  | Instance A1             |
                             |                         |                  |                         |
                             |   |------|    |------|  |                  |   |------|    |------|  |
                             |   | User |----| Role |  |                  |   | User |----| Role |  |
                             |   |------|    |------|  |                  |   |------|    |------|  |
                             |-------------------------|(DS_B)            |-------------------------|(DS_A1)
                             
                             
                             |-------------------------|                  |-------------------------|
                             | Instance B2             |                  | Instance A2             |
                             |                         |                  |                         |
                             |   |------|    |------|  |                  |   |------|    |------|  |
                             |   | User |----| Role |  |                  |   | User |----| Role |  |
                             |   |------|    |------|  |                  |   |------|    |------|  |
                             |-------------------------|(DS_B)            |-------------------------|(DS_A2)
For InstanceType B with shared data source, User entities are multitenant enabled. A user account accessing InstanceType B can not access any of its instances.

For system XML configuration, see System Configuration.

Directory Structure

In addition to data persisted in database, certain data such as large objects are persisted in file system.
[cmobilecom.home]
     |-- files/
           |-- www/
           |     |-- main/
           |
           |-- system/
           |      |-- www/
           |      |     |-- main/
           |      |
           |      |-- modules/
           |
           |-- InstanceType1/
                 |-- www/
                 |     |-- main/
                 |
                 |-- instances/
                            |-- www/
                            |     |-- main/
                            |
                            |-- 18/
                                 |-- www/
                                 |     |-- main/
                                 |
                                 |-- modules/
For an instance, module large objects(e.g., images, videos) are stored under its modules directory. Inheritable web sites can be built under various www directories. See website module for detail.