SIF 3 First Consumer Java SIF 3 Consumer

  • Slides: 10
Download presentation
SIF 3: First Consumer - Java SIF 3 Consumer: Get Students Exercise Presented by:

SIF 3: First Consumer - Java SIF 3 Consumer: Get Students Exercise Presented by: Joerg Huber

2 How to develop a Consumer ¡ ¡ ¡ What is a Consumer Initial

2 How to develop a Consumer ¡ ¡ ¡ What is a Consumer Initial Considerations Data Model Classes Consumer Classes Steps developing a consumer l ¡ Get Student & Get Students Exercise l l Develop Basic Consumer and Run it… Ensure Demo Provider returns data Training Course SIF 3: First Consumer September 20 © Systemic Pty Ltd

3 What is a Consumer ¡ ¡ ¡ A Client in the traditional sense.

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: l ¡ ¡ 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 SIF 3: First Consumer September 20 © Systemic Pty Ltd

4 Initial Considerations ¡ ¡ What Data Model to use (i. e. SIF NA

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? l l ¡ 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? l l Most likely only available in brokered environment Outside the scope of this training Training Course SIF 3: First Consumer September 20 © Systemic Pty Ltd

5 Data Model Classes ¡ The SIF 3 Framework has a library with the

5 Data Model Classes ¡ The SIF 3 Framework has a library with the SIF NA 3. 3 data model (sif. Data. Model_us 3. 3. jar). l l ¡ Classes are named as the SIF Object: l l ¡ Generated based on SIF NA 3. 3 XSD. Has methods to marshal/unmarshal to/from XML Single Student: XStudent. Type Student List: XStudent. Collection. Type If another data model is required you can: l l Generate it using the data model’s XSD if available. Manually develop it. Get hold of 3 rd party library that encapsulates the data model. Ensure marshal/unmarshal to/from XML is available or you need to implement this. Training Course SIF 3: First Consumer September 20 © Systemic Pty Ltd

6 Core Consumer Classes The following is a list of core classes required for

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. ¡ Consumer. Loader l l ¡ initialise: Initialises a Consumer and allocates resources shutdown: Releases resources allocated with consumer. Abstract. Consumer (CRUD) or Abstract. Event. Consumer (CRUD & Events) l l 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 SIF 3: First Consumer September 20 © Systemic Pty Ltd

7 Steps developing a consumer ¡ For each SIF Object used in the consumer

7 Steps developing a consumer ¡ For each SIF Object used in the consumer write a separate class extending Abstract. Consumer or Abstract. Event. Consumer Implement abstract and/or interface methods ¡ Link marshal/unmarshal with consumer ¡ l l ¡ Ensures that SIF 3 Framework produces correct XML Use Data. Model. Unmarshal. Factory & Data. Model. Marshal. Factory from sif. Data. Model_us 3. 3. jar! Link SIF Object Class with each consumer l l Implement get. Single. Object. Class. Info and get. Multi. Object. Class. Info methods to return appropriate Model. Object. Info (see demo code) Use predefined constants Training Course SIF 3: First Consumer September 20 © Systemic Pty Ltd

8 Steps developing a consumer (cont. ) Configure the following in the consumer. properties

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. base. Package. Name” 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 SIF 3: First Consumer September 20 © Systemic Pty Ltd

Exercise – x. Student Consumer 9 As part of this exercise we only use

Exercise – x. Student Consumer 9 As part of this exercise we only use Abstract. Consumer (we don’t do events) ¡ Implement Student. Consumer in sif 3 demo. consumer package l l ¡ Note what class it extends! Note it only requires methods related to data model and mapping to internal model classes. Implement Demo. Consumer (executable) in sif 3 demo. service package: l l l get. Student (get Single Students) get. Students(Get list of Students) Note where the Consumer. Loader methods are used. Also refer to javadoc of the SIF 3 Framework for details about classes. Training Course SIF 3: First Consumer September 20 © Systemic Pty Ltd

1 0 Exercise – Run Demo. Consumer ¡ Ensure your provider is running in

1 0 Exercise – Run Demo. Consumer ¡ Ensure your provider is running in your web- or application container. l l 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 Demo. Consumer class. It is an executable. ¡ Observe the output on the command line… Training Course SIF 3: First Consumer September 20 © Systemic Pty Ltd