Presentation is loading. Please wait.

Presentation is loading. Please wait.

SIF3: First Consumer - Java

Similar presentations


Presentation on theme: "SIF3: First Consumer - Java"— Presentation transcript:

1 SIF3: First Consumer - Java
SIF3 Consumer: Get Students Exercise Joerg Huber

2 How to develop a Consumer
What is a Consumer Initial Considerations Data Model Classes Consumer Classes Steps developing a consumer Get Student & Get Students Exercise Develop Basic Consumer and Run it… Ensure Demo Provider returns data Training Course SIF3: First Consumer January 19

3 What is a Consumer A Client in the traditional sense.
Can be standalone executable or part of a larger web- and/or mobile application. It typically requests CRUD operations: Create, Read/Get, Update & Delete Objects (i.e. Students) It can subscribe to Events if events are supported by the provider of data. A consumer is not considered the “source of truth”, meaning CRUD requests might be rejected by the provider! Training Course SIF3: First Consumer January 19

4 Initial Considerations
What Data Model to use (i.e. SIF NA 3.3)? What SIF Objects do I need to deal with? What CRUD request do I need to deal with? Do I need to deal with SIF Events? Most likely only available in brokered environment Might be shown during this training course as part of a Live Demo. Are delayed request/responses required? Outside the scope of this training Training Course SIF3: First Consumer January 19

5 Data Model Classes The SIF3 Framework has a library with the SIF NA 3.3 data model (sifDataModel_us3.3.jar). Generated based on SIF NA 3.3 XSD. Has methods to marshal/unmarshal to/from XML Classes are named as the SIF Object: Single Student: XStudentType Student List: XStudentCollectionType If another data model is required you can: Generate it using the data model’s XSD if available. Manually develop it. Get hold of 3rd party library that encapsulates the data model. Ensure marshal/unmarshal to/from XML is available or you need to implement this. Training Course SIF3: First Consumer January 19

6 Core Consumer Classes The following is a list of core classes required for developing a consumer. Details will follow as part of the exercise. ConsumerLoader initialise: Initialises a Consumer and allocates resources shutdown: Releases resources allocated with consumer. AbstractConsumer (CRUD) or AbstractEventConsumer (CRUD & Events) Each SIF Object used in the final consumer must extend one of these two classes. Forces a number of methods to be implemented Training Course SIF3: First Consumer January 19

7 Steps developing a consumer
For each SIF Object used in the consumer write a separate class extending AbstractConsumer or AbstractEventConsumer Implement abstract and/or interface methods Link marshal/unmarshal with consumer Ensures that SIF3 Framework produces correct XML Use DataModelUnmarshalFactory & DataModelMarshalFactory from sifDataModel_us3.3.jar! Link SIF Object Class with each consumer Implement getSingleObjectClassInfo and getMultiObjectClassInfo methods to return appropriate ModelObjectInfo (see demo code) Use predefined constants Training Course SIF3: First Consumer January 19

8 Steps developing a consumer (cont.)
Configure the following in the consumer.properties file: List each consumer class as a comma separated list in the “consumer.classes” property Set the package name of the consumer classes in the “consumer.basePackageName” property. As part of this training most of the above should be pre-set. Refer to Developer’s Guide for much more details on how to develop a consumer. Training Course SIF3: First Consumer January 19

9 Exercise – xStudent Consumer
As part of this exercise we only use AbstractConsumer (we don’t do events) Implement StudentConsumer in sif3demo.consumer package Note what class it extends! Note it only requires methods related to data model and mapping to internal model classes. Implement DemoConsumer (executable) in sif3demo.service package: getStudent (get Single Students) getStudents(Get list of Students) Note where the ConsumerLoader methods are used. Also refer to javadoc of the SIF3 Framework for details about classes. Training Course SIF3: First Consumer January 19

10 Exercise – Run DemoConsumer
Ensure your provider is running in your web- or application container. Ensure that the provider has loaded the students. At start-up you should see a log entry indicating 100 students are loaded. If not check weather the property provider.student.file.location in the provider.properties file points to a valid location. Within your IDE you should be able to run the DemoConsumer class. It is an executable. Observe the output on the command line… Training Course SIF3: First Consumer January 19


Download ppt "SIF3: First Consumer - Java"

Similar presentations


Ads by Google