|
|
 | Summary: What's new in GigaSpaces XAP 6.0 .NET
|
Overview
The full list of features in GigaSpaces 6.0 .NET can be found in the GigaSpaces Release Notes section.
If you are upgrading GigaSpaces 5.2 to GigaSpaces 6.0, see the .NET migration document.
Or, see the .NET documentation.
Development and Deployment
Library files
- Some changes have been made to library names and metadata, in order to align the product with .NET standards and practices, and simplify development and deployment.
- To use the space API in your assembly, you need to reference only one file: GigaSpaces.Core.dll (replacing GsSerializer.dll in previous versions). This assembly encapsulates the core API required to query and manipulate the space. GigaSpaces.Core.dll is strong-named, so you can reference it from both plain or strong-named assemblies, place it in the GAC (Global Assembly Cache), etc.
- GigaSpaces.Core.dll has 2 dependencies:
- GigaSpaces.Core.Interop.Java.dll (formerly gss52.dll) contains generated wrappers for Java classes. The core assembly uses it internally to interoperate with Java, so you do not need to reference it explicitly.
- netrtsn.dll is the runtime library for the Java interoperability engine (CodeMesh). The core assembly uses it internally to interoperate with Java, so you do not need to reference it explicitly.
- xmogrt.dll is an unmanaged library, used by netrtsn.dll. Since it's unmanaged, the .NET dependency engine does not handle it, so you need to make sure it's available at runtime. Two common solutions are to write a post-build event which copies it to the output target, or simply to add it to the machine's path.
Configuration
- In previous versions, there was only one setting which could be configured for the .NET proxy: the serialization mode. In fact, it had to be configured, and you could not change it via code.
- This configuration has been removed, and instead it has been added as a property you can get/set in the factory prior to creating a proxy.
- You can still use the app.config/web.config to configure the JVM and logging settings see .NET API Configuration.
API Changes
- API has undergone complete redesign and has been changed considerably in version 6.0.
- The main goal of this redesign was to decouple the API from the (current) Java implementation, to be able to freely improve the implementation without changing the API in hte future, without forcing users to change their code accordingly.
- The new API is native .NET, mostly based on the provider design pattern, allowing us to supply different implementations of providers in the future, where the user can switch between providers by changing a single line of code.
Notifications and Events
- The notification API has changed considerably in version 6.0. The major changes are the seperation of event configuration from event session, and the shift from interface-based callbacks to delegates.
- Subscribing to an event is comprised of 3 steps:
- Create an EventSessionConfig instance. If required, configure it (e.g. Fifo=true).
- Use the CreateDataEventSession method on the proxy you want to monitor to create a IDataEventSession instance using the EventSessionConfig you created (and, optionally, an ITransaction).
- Use the AddListener method on the IDataEventSession you created to subscribe a delegate to notifications on a specified template (with optional lease time and notification types).
You can use the proxy's DefaultEventSessionConfig to skip the first step, or DefaultDataEventSession to skip both steps, and directly subscribe to an event from the proxy. For example, suppose we want to subscribe to any change in Person:
public class program
{
public void DoStuff(ISpaceProxy proxy)
{
proxy.DefaultDataEventSession.AddListener<Person>(new Person(), PersonChangedHandler);
}
private void PersonChangedHandler(object sender, SpaceDataEventArgs<Person> e)
{
}
}
Serialization and Metadata Enhancements
- PONO functionality has been modified and enhanced to be aligned with POJO (Plain Old Java Object) functionality.
- Existing attributes have been modified (for example, [Key] is now [SpaceID]), new attributes were added (for example: [SpaceExclude]), new features were added (for example, gs.xml support), and more.
Properties Support
- In previous versions, only fields were serialized and stored in space.
- In version 6.0, properties are serialized as well.
Non-Public Members Serialization, Explicit Member Inclusion/Exclusion.
- In previous versions, all public members (fields an properties) were serialized, and non-public members were ignored.
- In Version 6.0, you can use the [SpaceClass] attribute to change this behaviour.
- The example below shows the Person class, where no properties are serialized, and on the other hand, all fields (including non-public fields) are serialized:
[SpaceClass(IncludeProperties=IncludeMembers.None, IncludeFields=IncludeMembers.All)]
public class Person
{
}
- Furthermore, you can override the class-level settings and explicitly include/exclude members. For example:
[SpaceClass(IncludeProperties=IncludeMembers.None, IncludeFields=IncludeMembers.All)]
public class Person
{
[SpaceExclude]
private string _firstName;
[SpaceProperty]
public string FirstName
{
get { return _firstName; }
set { _firstName = value; }
}
}
Metadata Inheritance Support
- In previous versions, there was no explicit support for space metadata and object inheritence.
- Simple scenarios worked fine, but more complex scenarios had bugs or were inconsistent (e.g. an extending class declaring a different SpaceID than its base class).
- In version 6.0, the process of loading the metadata has been reviewed and modified.
Extra-Code Metadata (gs.xml)
- In previous versions, the only way to specify space metadata was using attributes. This approach had some drawbacks (for example, when wanting to store third party PONOs, which could not be changed).
- In version 6.0, you can specify the metadata in an external XML file instead. This decoupling of the code (data) from the metadata allows you to change metadata without recompiling the code.
- This feature is sometimes referred to as gs.xml, which is the suffix of the metadata files. For example, let's look at a gs.xml file describing the previous Person class:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE gigaspaces-mapping PUBLIC "-//GIGASPACES//DTD GS//EN" "http://www.gigaspaces.com/dtd/6_0/gigaspaces-metadata.dtd">
<gigaspaces-mapping>
<class name="MyCompany.MyProject.Person" include-properties="none" include-fields="all" mapping-type="space">
<exclude name="_firstName"/>
<property name="FirstName"/>
</class>
</gigaspaces-mapping>
For details about schemas, see the .NET documentation
|