Xcalia Intermediation
13 décembre 2007Eric SAMSON, CTO - XCALIAStève SFARTZ, MICROSOFT France
Service Data Objects (SDO) and Data Access Service (DAS)
Xcalia SDO support
Support for SDO 1 since XIC 4.0 (June 2005)Support for SDO 2 since XIC 5.0
Java SDO2 client with dirty trackingSupport for SDO2 APIs, metadata and XML data transferSDO2 / JDO2 interoperability
SDO2 used as an alternate format to attach/detach
Efficient implementation not based on Eclipse EMFAdditional APIs to create SDOsAdditional APIs to associate static types with dynamic SDOs
Support for .Net SDO 2 clientIntegration with LINQIntegration with ASP .Net data sources
Microsoft & Xcalia
Selected by Microsoft EBT as part of their IDEES programFounding member of the Interop Vendor AllianceOne of the 5 companies selected worldwide for the new MS Tool program
Support for .Net 3.x, LINQ, ASP .Net Data Sources CardSpace…
Visual Studio 2008 and .Net 3.5 PRhttp://www.microsoft.com/presspass/features/2007/nov07/11-19developerqa.mspxhttp://www.microsoft.com/casestudies/casestudy.aspx?casestudyid=4000000963
LinQ to JDOQL
Xcalia DAS server only understood JDOQL
.NET developers want to benefit from upcoming LINQ capabilities
Relies on Visual Studio 2008
Convert LinQ expressions to JDOQL queriesIntense Lab-Lab relationships between Xcalia and MS
4
LINQ and XIC SDO DAS
Xcalia SDO DAS uses JDOQL in standard
5
Xcalia SDO DAS can now alternately use LINQ
Example with fetch groups
ILinqDataAccessService linqDas = LinqDataAccessService.Decorate (das);linqDas.FetchGroups.Add("full");linqDas.FetchGroups.Add("customer");
var fetchResult = from c in linqDas.GetInstances<Customer>() where c.Lastname.StartsWith ("Killian") select c;
foreach (Customer customer in fetchResult){ Address address = customer.Address;
resultView.Add("Result is " + customer.Firstname + " " + customer.Lastname + " " + address.Street );
((IDataObject) customer).ChangeSummary.BeginLogging(); customer.Comment = customer.Comment + "-c#(linq)"; das.ApplyChanges(customer);}
6
LINQ To JDOQL
LINQ to JDOQLConversion of LINQ query to JDOQLKey aspects:
Visitor for the LinQ Expressions Structures.Translates LINQ queries to JDOQL using visitors.Send JDOQL query to a DAS implementation and return strongly typed results.
LINQ to JDOQL – Basic samples
var results = from u in userswhere u.Age >= 30 && u.Age < 40 select u;
select this from User where (age >= 30 && age < 40)
var results = from u in userswhere (((u.Age >= 30 && u.Age < 40) || (u.Id == 123 &&
u.FirstName == "test")) || u.Name == "ok")select u;
select this from User where (((age >= 30 && age < 40) || (id == 123 && firstName == "test")) || name == "ok")
8
A condition on the User’s age property…
… translated into a Java property name (note the lower case ‘age’).
A more complex condition…
… translated in JDO QL.
LINQ to JDOQL – Java / .NET conversionsvar results = from u in userswhere u.Name.Substring(3, 4) == param.Substring(2,4)select u;
select this from User where name.substring(3, 7) == "test"
9
The ‘substring’ method in .NET is different from Java …
… but translated to Java.
Please note that an optimization has been performed on the condition’s right operand.
LINQ to JDOQL – Constant evaluation
var results = from u in userswhere Math.Abs(-10) == u.Ageselect u;
select this from User where 10 == age
var results = from u in userswhere u.Name.ToUpper() == "abcdtest".Substring(Math.Abs(1 * "abcdef".IndexOf("e"))).ToUpper()select u;
select this from User where name.toUpperCase() == "TEST“
10
‘Math.Abs(-10)’ is constant expression…
… that is directly evaluated for the LINQ to JDOQL translation.
With a more complex expression…
… the result can still be correcly optimized.
LINQ to JDOQL - Ordering
var results = from u in userswhere u.Name == "test“orderby u.Age ascendingselect u;
select this from User where name == "test" order by agevar results = from u in userswhere u.Name == "test“orderby u.Age descendingselect u;
select this from User where name == "test" order by age descending
11
The ascending ordering…
… is the default ordering in JDOQL.
But the descending ordering…
… has to be explicitely declared.
LINQ to JDOQL - Navigation
var results = from u in userswhere u.Address.Street == u.Address.Street2 &&
(u.Id.IndexOf(u.Address.ZipCode) > 0)select u;
select this from User where (address.street == address.street2 && (id.indexOf(address.zipCode) > 0)
var results = from u in usersfrom p in u.Policieswhere p.Name == "test“select u;
select this from User where policies.contains(gen_var1) && p.name == "test" variables Policy gen_var1
12
LINQ to JDOQL also supports navigation in the model…
… that are translated in «. » notation.
For queries against multivalued collections…
… the translator generates variables in order to match the JDOQL language.
ASP.NET data source
Create a .Net Data Source from a XIC DAS requestProvides easy integration of Xcalia DAS within ASP.NET
Drag & Drop this XIC DAS Data Source onto the ASP Page
Use regular Visual Studio widgets to design the pageConnect the Visual Studio widgets (Grid View, Forms, etc.) to the XIC DAS Data SourceProvides a fully introspectable model, based on SDO.Can manage connection and reconnection to a Data Access Service.
This already works with Visual Studio 2005Will be soon available in XIC 5.3
13
ASP.NET data source
14
XIC Data Access Service data source
Full integration in the ASP.NET editor
ASP.NET Datasource
15
A configured data source is defined…
And different standard ASP.NET controls are bound to this data source
ASP.NET data source
16
At runtime, the data source can provide the data model and generate the appropriate columns.
The data source supports basic CRUD operations.
Data is shared accross the different components and update in one component is reflected on every component that shares the same data source
Fetch graphs
Fetch graphsSomewhat equivalent to DataShapes in System.Data.Linq…
…but not limited to relational databases
Defines what parts of the model (which classes / attributes) should be loaded when a query is executed on the DASOrcas related aspects:
Use .NET expressions to express fetch plansUse LINQ expressions on data structures
Fetch graphs are optional in a connected model but required in a disconnected model (SOA), because lazy loading over SOAP is not suitable
Fetch graphs – SampleSimple model with two main particularities:
IPerson interface contains a one to many relationship to IPerson (« Friends »)Address introduces a cycle with relationship to IPerson (« President »).
IPerson will be used for the next examples
18
Fetch graphs
Express fetch graphs using expressionsDefines what parts of the model should be included with condition .NET expressions.A condition is a Func<> typed as:
Condition examplesfgf => ! fgf.Value.PropertyType.Namespace.StartsWith("System")fgf => fgf.Value.PropertyType != typeof(string)fgf => typeof(IEnumerable).IsAssignableFrom(fgf.Value.PropertyType)
19
Func<TCandidate, bool>(Where TCandidate can be a System.Type, System.Reflection.PropertyInfo…)
Fetch graphs – Condition
fgf => fgf.Value.PropertyType != typeof(string)
20
[FetchPlansTests.Model.IPerson][Age] (System.Int32)[HomeAddress] (FetchPlansTests.Model.IAddress)[WorkAddress] (FetchPlansTests.Model.IAddress)[Friends] (System.Collections.Generic.IList`1[FetchPlansTests.Model.IPerson])
[FetchPlansTests.Model.IPerson][Name] (System.String)[FirstName] (System.String)[Age] (System.Int32)[HomeAddress] (FetchPlansTests.Model.IAddress)[WorkAddress] (FetchPlansTests.Model.IAddress)[Friends] (System.Collections.Generic.IList`1[FetchPlansTests.Model.IPerson])
• Example of fetch group creation for the IPerson type• fgf => true (No Condition)
Fetch graphs – Multiple Conditions
Fetch groups can « combine » conditions.A fetch group can be created with more than one condition.
The result of C1 + C2 on IPerson is:
21
C1: fgf => fgf.Value.PropertyType != typeof(string)C2 : fgf => typeof(IEnumerable).IsAssignableFrom(fgf.Value.PropertyType)
[FetchPlansTests.Model.IPerson][Age] (System.Int32)[HomeAddress] (FetchPlansTests.Model.IAddress)[WorkAddress] (FetchPlansTests.Model.IAddress)
Use Cases
Use CasesDefines « scopes » in code where a particular context is active.Developers enter and leave programmatically use cases in code.Allows flexibility for developer: developer can define additional data (even data not included in the product).Orcas related aspects:
Extensive use of LINQ query on data structures.
Use Cases – Example (1/2)
Enter use case / Leave use case
US0 + US1
US0
Use Cases – Example (1/2)
Support for overrides (use case that defines twice the same value)
Use Cases – Example (2/2)
This method call gets the active configuration (eventually with merges if multiple data instances were found)
Use Cases – Scenarios (1/2)
Data Access Service configurationEases configurationPerforms common administrative tasks to initialize and configure a Data Access Service.
26
Use Cases – Scenarios (2/2)
LINQ DASCan also predefined LINQ queriesAutomatically register SDO static types
27
Xcalia DAS
Architecture
Local mode
29
JavaApplication
Xcalia DAS Datastore
Service oriented mode
Java or .Net
ApplicationXcalia DAS Datastore
Same JVM
Web Services
Xcalia DAS Main APIs
DataAccessServiceFactoryBootstrap objectCreates « manager » and « das » instances
DataAccessServiceManagerProvides management tasks for a DAS
DataAccessServiceRetrieve SDO data graphs from the data sourcesApply changed SDO to the data sources
30
DataAccessServiceFactory
public interface DataAccessServiceFactory {
DataAccessServiceManager getManager(Map<String, Object> options);
DataAccessService getDataAccessService(Map<String, Object> options);
}
31
DataAccessServiceManager
public interface DataAccessServiceManager {
void start();
void setupDataSource();
void stop();
void close();}
32
DataAccessService
public interface DataAccessService {
Object fetch(String queryText, String fetchGroups);
Object fetch(String queryText, String fetchGroups, Map<String, Object>
options);
void applyChanges(Object dataObject);
void applyChanges(Object dataObject, Map<String, Object> options);
...}
33
Sample
DataAccessServiceFactory factory = DataAccessServiceFactory.INSTANCE;
DataAccessServiceManager dasManager = factory.getManager(options);dasManager.start();
DataAccessService das = factory.getDataAccessService(options);
Collection<DataObject> fetchResult;fetchResult = (Collection<DataObject>) das.fetch("query", "default");
for (DataObject dataObject : fetchResult) {dataObject.setString("MyProperty", "new value");das.applyChanges(dataObject);
}...
34
Fetch examples
Any JDO2 QL query, with navigation, contains, aggregates, projections, in heritance, etc.Query with parameters
das.fetch("select this from bom.Customer where name==myName parameters String myName", "default", new Object[]{“Christophe”});
Named Querydas.fetch("named into bom.Customer:queryName", "default", new Object[]{christophe});
Direct SQLdas.fetch("sql:SELECT NAME, AGE, ADDRESS FROM QCUSTOMER ORDER BY AGE", null);
In .Net JDOQL can be replaced by LINQ
35
Xcalia DAS support
First support of DAS in XIC 5.1 (Q2 2007)XIC DAS interface returns SDO 2 data graphs
Generic CRUD Web Service interface
Optimized client-server implementation (metadata exchange)Both Java and .Net clientsBased on the full featured XIC
MappingCachingTransactionMultiple data sources supportAdmin through JMX
Apache Tuscany
Tuscany is an open source DAS, SDO, SCA implementation
Hosted by the well-respected Apache communityFunded by IBM
37
Client
ChangeSummary
Data GraphDataObject JDBC
XPath / XQuery
Local
XML/HTTP
CCI / Proprietary
JCA
Web Service
RDB
XML DB
EJBCustomer
Data Access Service
Right vision The DAS, an universal “Data as a Service” provider
Market requirements
Java / .Net interoperabilityScalability caches, transactionsAgility client apps isolated from back ends
38
Client
Java.NetC++ ?
ChangeSummary
Data GraphDataObject
JDBC
/ XPathXQuery
Local
XML / HTTP
CCI / Proprietary
JCA
Web Service
RDB
XML DB
EJBCustomer
Data Access Service
Mapping with Logical Business ModelCaching & Dynamic tuningDistributed transactions, queries …
What Tuscany has today…
A limited DAS implementation. Rather a PoC.
39
Client
Java
C++
ChangeSummary
Data GraphDataObject
JDBC
Web Service
RDB
Data Access Service
- Just RDBMS Straight SQL from SDO client to database- No mapping, no cache Low value for developers, low scalability in production.
What XIC offers today
A DAS implementation built on top of the mature Xcalia Intermediation technology
40
Client
Java.Net
ChangeSummary
Data GraphDataObject
JDBC
/ Xpath XQuery
Local
XML / HTTP
CCI /MainframePackaged applications…
Proprietary
JCA
Web Service
RDB
XML
EJBCustomer
XIC Data Access Service
Xcalia Intermediation Core• Mapping with Logical
Business Model• Caching & Dynamic tuning• Distributed transactions• Extensibility kit
The DAS vision implemented with respect of market requirements.
© 2007 Microsoft France
Votre potentiel, notre passion TM