Skip to content

Client Libraries

The Common Information Model (CIM) is a comprehensive and complex model. Generating Java classes directly from the XSD files can therefore be challenging. The repository eddie-energy/eddie provides a Maven artifact that already contains the relevant CIM classes. Find the latest version on the Maven Central Repository.

Getting started

The library contains a large number of classes. The following envelope classes are the most important entry points:

These classes can be used to:

  • Parse incoming XML messages
  • Create messages that are sent to the EDDIE framework

The following example demonstrates how to deserialize an XML message from a string. This approach can be used in Kafka or AMQP deserializers.

The example requires:

Versions

The CIM library uses semantic versioning. The changelog can be found in the GitHub repository here: https://github.com/eddie-energy/eddie/blob/main/cim/CHANGELOG.md

Importing the library

INFO

You can find the CIM package in the EDDIE repository here: https://central.sonatype.com/artifact/energy.eddie/cim.

xml
<dependency>
    <groupId>energy.eddie</groupId>
    <artifactId>cim</artifactId>
    <version>1.0.0</version> <!-- Use the desired version from Maven Central -->
</dependency>
kotlin
// Use the desired version from Maven Central
implementation("energy.eddie:cim:1.0.0")
kotlin
// Use the desired version from Maven Central
implementation 'energy.eddie:cim:1.0.0'

Example code

java
import energy.eddie.cim.serde.DeserializationException;
import energy.eddie.cim.serde.SerdeFactory;
import energy.eddie.cim.serde.SerdeInitializationException;
import energy.eddie.cim.serde.SerializationException;
import energy.eddie.cim.v1_12.rtd.RTDEnvelope;

import java.nio.charset.StandardCharsets;

public class MyClass {
    public void serdeExample() throws SerdeInitializationException, SerializationException, DeserializationException {
        var serdeFactory = SerdeFactory.getInstance();
        var serde = serdeFactory.create("xml");
        // var serde = serdeFactory.create("json"); // also works for JSON

        var rtdEnvelope = new RTDEnvelope();

        // SERIALIZATION
        var payloadBytes = serde.serialize(rtdEnvelope);
        var payload = new String(payloadBytes, StandardCharsets.UTF_8);

        // DESERIALIZATION
        rtdEnvelope = serde.deserialize(payload.getBytes(StandardCharsets.UTF_8), RTDEnvelope.class);
    }
}