.NET-Java Interoperability

  Search Here
Searching XAP 6.0 Documentation

                                               

Summary: Enabling interoperability between Java and .NET - creating interoperable class, supported types for matching and interoperability.

Overview

Even though the space is implemented in Java, you can use a .NET proxy to read and write .NET objects from/to the space. Under the hood, the proxy serializes the object in a special cross-platform format, thus allowing the space to recognize the fields in your object whose type is cross-platform. This enables the space to perform queries and return matching results.

This implementation enables a powerful feature - if you implement a matching class in Java with the same name and fields, you can use a Java proxy to read an object written from the .NET proxy (or vice versa). So in fact, the space can be used as an integration platform between .NET and Java.

The .NET-Java example demonstrates many .NET-Java interoperability fetaures. For more details, see GigaSpaces Starter Examples; .NET; DotNetJava

Creating Interoperable Class

The following guidelines and restrictions should be followed in order to enable platform interoperability:

  • The full class name (including package\namespace) in .NET and Java must be identical.

    Java packages use a different naming convention than .NET namespaces.

  • Both classes should have the exact same fields, with matching types.

    In Java, only properties are serialized into the space. In .NET, both fields and properties are serialized, so you can mix and match them.

    Java properties usually start with a lowercase letter, whereas .NET properties usually start with an uppercase letter.

  • Only the types listed in the table below are supported. If one of your fields uses a different type, you can use the class only in a homogeneous environment.

    Arrays are supported using the Java primitive equivalent of each type listed in the table below. For example, the equivalent of java.lang.Byte is byte. ( See how this is demostrated in the DotNetJava example.)

    Guid/UUID arrays are supported in GigaSpaces 6.0.1 and onwards.


    You can also use .NET enumerations, which are treated as their underlying .NET type. Java enums are not supported.

    If your class contains a field whose type is not in the table, you can use SpaceExclude to exclude it from the space.

    Some of the types have different charactaristics in .NET and Java (signed\unsigned, nullable\not nullable, precision, etc.) This can lead to runtime exceptions (e.g. trying to store null in a .NET structure) or unexpected results (e.g. copying values between signed and unsigned fields).

Supported Types for Matching and Interoperability

The following types are supported by the space for matching and interoperability:

Java type Null Description CLR type Null Description
java.lang.Byte Yes 8 bits signed whole number System.Byte No 8 bits unsigned whole number
java.lang.Short Yes 16 bits signed whole number System.Int16 No 16 bits signed whole number
java.lang.Integer Yes 32 bits signed whole number System.Int32 No 32 bits signed whole number
java.lang.Long Yes 64 bits signed whole number System.Int64 No 64 bits signed whole number
java.lang.Float Yes 32 bits signed single precision floating number System.Single No 32 bits signed single precision floating number
java.lang.Double Yes 64 bits signed double precision floating number System.Double No 64 bits signed double precision floating number
java.math.BigDecimal Yes Arbitrary-precision signed decimal number System.Decimal No Decimal number composed of 1 sign bit, 96 bits integer and 0-28 scaling factor
java.lang.Boolean Yes Boolean value (true/false) System.Boolean No Boolean value (true/false)
java.lang.Character Yes 16-bit numeric value representing a Unicode character System.Char No 16-bit numeric value representing a Unicode character
java.lang.String Yes Represents text as a series of Unicode characters System.String Yes Represents text as a series of Unicode characters
java.util.Date Yes A date & time value measured in milliseconds since 01/01/1970 System.DateTime No A date & time value measured in ticks (=100 nanoseconds) since 01/01/0001
java.uitl.UUID Yes A 128-bit integer representing a unique identifier System.Guid No A 128-bit integer representing a unique identifier
byte[] Yes Array of primitive bytes System.Byte[] Yes Array of bytes
short[] Yes Array of primitive shorts System.Int16[] Yes Array of shorts
int[] Yes Array of primitive integers System.Int32[] Yes Array of integers
long[] Yes Array of primitive longs System.Int64[] Yes Array of longs
float[] Yes Array of primitive floats System.Single[] Yes Array of singles
double[] Yes Array of primitive doubles System.Double[] Yes Array of doubles
java.math.BigDecimal[] Yes Array of BigDecimals System.Decimal[] Yes Array of decimals
bool[] Yes Array of primitive booleans System.Boolean[] Yes Array of booleans
char[] Yes Array of primitive characters System.Char[] Yes Array of characters
java.lang.String[] Yes Array of Strings System.String[] Yes Array of strings
java.util.Date[] Yes Array of Dates System.DateTime[] Yes Array of DateTimes
java.uitl.UUID[] Yes Array of UUIDs System.Guid[] Yes Array of Guids


GigaSpaces 6.0 Documentation Contents (Current Page in Bold)

    Java

    C++

    .NET

    Middleware Capabilities

    Configuration and Management

Add GigaSpaces wiki search to your browser search engines!
(works on Firefox 2 and Internet Explorer 7)

Labels

 
(None)