Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Panel
titleNative prism representation (Java)

Code Block
xml
xml
titleXML representationxml
<user oid="123456">
  <name>jack</name>
  <employeeType>Captain</employeeType>
  <employeeType>Pirate</employeeType>
  <activation>
    <enabled>true</enabled>
  <activation>
</user>
Code Block
javascript
javascript
titleJSON representationjavascript
{
  "_oid": "123456",
  "name": "jack",
  "employeeType": [ "Captain", "Pirate" ],
  "activation": {
    "enabled": true,
  }
}

...

Prism objects are more or less ordinary data structures in Java. They can be accessed using a native Prism interface (API), but the same data can also be accessed by variety of other interfaces (JAXB, DOM, ...). The unique feature of prism is that the data are not transformed to these formats but real live data are presented. For example if a bean property is set by invoking JAXB setter the change is immediately reflected to the underlying prism data model. The next call to DOM interface will return the new value of the property.

Code Block
java
java
titleLive data examplejava
// Set the "fullName" property using a JAXB interface
UserType userType = ....
userType.setFullName("Jack Sparrow");

// Invoking native Prism interface to read fullName, returns "Jack Sparrow"
PrismObject<UserType> userPrism = ....
String fullName = userPrism.findProperty(new QName(NS_C, "fullName").getValue().getValue();

// Invoking DOM interface to read the fullName, returns "Jack Sparrow"
Element fullnameElement = ....
String fullName = fullnameElement.getTextContent()

...

Each prism object has a pre-defined optional extension container. This container is supposed to hold custom extensions to each object. The extension container is expected to be dynamic by default therefore allowing any item to be stored there. However, there are mechanisms in prism to provide a (run-time) schema for this container. This constraints the possibilities of which items may be stored there and therefore creates a solid schema for the entire object.

Code Block
xml
xml
titleObject with extension (XML representation)xml
<user oid="123456">
  <name>jack</name>
  <extension>
    <pir:shipName>Black Pearl</pir:shipName>
  </extension>
  <employeeType>Captain</employeeType>
  <employeeType>Pirate</employeeType>
</user>

...

Prism object can be switched from one interface to the other. Methods to do that start with prefix as, e.g. asObjectable(). Such method return the same object represented by the mechanism of the other interface. The two objects still refer to the same data, therefore changing the content of one object is immediately reflected to the other.

Code Block
java
java
titleInterface switching examplejava
PrismObject<UserType> userPrism = ....;                                        // Native Prism API
UserType userType = userPrism.asObjectable();                                  // Switch to JAXB generated class

userType.setFullName("Jack Sparrow");                                          // Sets the "fullName" property

String fullName =
  userPrism.findProperty(new QName(NS_C, "fullName").getValue().getValue();    // Returns "Jack Sparrow"

...