Download Diffusion 5.5 User Guide - Documentation

Transcript
Note: Where there notation c.p.d is used in class or package names, it indicates
com.pushtechnology.diffusion.
Procedure
1. Define the metadata structure.
a) Import c.p.d.client.Diffusion and the following classes from the
c.p.d.client.content.metadata package:
• MetadataFactory
• MContent
• MRecord
• MField
• MString
• MIntegerString
• MDecimalString
• MCustomString
b) Use the Diffusion.metadata method to get a MetadataFactory.
private final MetadataFactory factory =
Diffusion.metadata();
c) Use the methods on the MetadataFactory to specify the content, record, and field
definitions that make up the metadata structure.
For example, the following code uses a content builder to create content metadata with
a single record type that can occur zero to n times.
public MContent createContentRepeating() {
return
factory.contentBuilder("Content").
add(
factory.record(
"Rec1",
factory.string("A"),
factory.string("B")),
0,
-1).
build();
}
For more information, see Java Unified API documentation.
2. Create a record topic and apply the metadata definition to it.
a) Import the TopicControl feature, Session class, and RecordTopicDetails class.
import
com.pushtechnology.diffusion.client.features.control.topics.TopicContr
import com.pushtechnology.diffusion.client.session.Session;
import
com.pushtechnology.diffusion.client.topics.details.RecordTopicDetails;
b) Create a Session instance and use it to get the TopicControl feature.
final Session session = Diffusion.sessions().open("ws://
diffusion.example.com:80");
final TopicControl tc =
session.feature(TopicControl.class);
Diffusion | 223