Show/Hide Toolbars

TMS XData Documentation

Navigation: Entity Model

Multiple servers and models

Scroll Prev Top Next More

You can create multiple XData servers (TXDataServerModule instances), at different addresses. This makes more sense if you use different entity models for each of those XData modules. It's very easy to do so in XData if you are using the Aurelius multi-model design. When defining different models with different classes (and service operations), you can easily create different XData modules in a single server application.


To specify the different models in each server module, you just need to provide an instance of a TXDataAureliusModel that represents the desired entity model. And you can easily retrieve the correct instance by using the TXDataAureliusModel.Get class method, passing the model name to the function. The entity model will then only consider entity types and service operations that belongs to that model.


For example, the following code creates two different TXDataServerModule modules, using two different entity models:


XDataSampleModule := TXDataServerModule.Create('http://server:2001/tms/xdata/sample'
  SampleConnectionPool, TXDataAureliusModel.Get('Sample'));
XDataSecurityModule := TXDataServerModule.Create('http://server:2001/tms/xdata/security'
  SecurityConnectionPool, TXDataAureliusModel.Get('Security'));





Note that this approach will filter all classes (entity types) belonging that specific model (for example, XDataSampleModule will only publish entity types which classes are marked with Model('Sample') attribute:




It will also filter the service operations according to the model name. So XDataSampleModule will only have services operations which service interfaces are marked with the Model('Sample') attribute.