Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

02 TA80 INTG020 GosuForIntegration

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 30

Gosu for Integration

October 15, 2013

© Guidewire Software, Inc. 2001-2013. All rights reserved.


Do not distribute without permission.
Lesson objectives
• By the end of this lesson, you should be able to:
- Describe the places where an integration developer uses Gosu
- Create Gosu classes
- Use blocks as input parameters
- Generate unique, sequential numbers

This lesson uses the notes section for additional explanation and information.
To view the notes in PowerPoint, select View  Normal or View  Notes Page.
When printing notes, select Note Pages and Print hidden slides.
© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 2
Lesson outline

• Overview of Gosu for integration

• Gosu classes

• Blocks

• Sequential numbers

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 3
Review: Guidewire Gosu
• Gosu is Guidewire’s open-source, publicly available
programming language
- Has elements of both procedural and object-oriented programming
languages
- Similar to JavaScript and Java

• Gosu specifies runtime business logic that:


- Executes fundamental application behavior
- Manages complex business processes
- Specifies dynamic client-side behavior

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 4
Where is Gosu used for integration? (1)
• Predefined plugins
- Executes fundamental application
behavior, such as authentication
• Startable plugins
- Specifies how to listen for incoming
messages initiated by external systems
and how to reply to them
• Messaging plugins
- Asynchronously sends messages and
processes acknowledgements
• Messaging
- Event Fired rules
- Creates messages and generates payloads

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 5
Where is Gosu used for integration? (2)
• Batch processes
- Specifies logic to run on a periodic basis

• Web services
- Specifies methods made available to
external applications for synchronous web WS-I
service calls

• Integration logic triggers include:


- Non-messaging business rules
- PCF actions (such as button clicks)
- Workflows

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 6
Gosu features and benefits
• Code is more compact
- Direct access to Guidewire data model

• Development time is shorter


- Reload Classes or Make Project

• Guidewire Studio supports Gosu coding


- Code completion
- Syntax checking
- Navigable links

• Robust interaction with Java


- Easy to learn by Java programmers
- Has access to all Java types and can reference Java classes

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 7
Gosu skills fundamental for integration
• Integration points involve these skills:
- Creating and modifying classes, including:
- Declaring and referencing properties and
methods
- Extending classes
- Creating and implementing interfaces
- Using blocks as input parameters
- Generating unique or sequential numbers
- Writing queries to retrieve data from the
Guidewire database
- Manually committing data to the database
- Using existing Java types and classes

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 8
Additional Gosu features
• Advanced • Data • Testing
object-oriented transformation - Entity builders
design - The XmlElement - GUnit tests
- Enums class (to import,
- Generics modify, and/or
export XML)
- Custom
- The typecode
annotations
mapper (to map
- Numeric literals
Guidewire
- Intervals typecodes to
- Null-safe external system
operators typecodes and
vice versa)

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 9
Lesson outline

• Overview of Gosu for integration

• Gosu classes

• Blocks

• Sequential numbers

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 10
Gosu class features
• Gosu classes are similar to classes in other object-oriented
language, such as Java
• Classes are organized in packages
• Classes can define:
- Constructors
- Properties (with private and public access)
- Methods (with private and public access)

• Classes can:
- Extend other classes
- Implement interfaces
- Override methods

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 11
Creating Gosu packages
• /configuration/gsrc/
- Create package
- New  Package

• Guidewire naming convention recommendation


- <company>.<app_code>.mechanism.<functional_area>
- mechanism is typically batch, messaging, plugin, startable,
webservice, and of none of the others apply, then use class
© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 12
Creating Gosu classes

• Naming convention
for a class:
- <meaningfulName>API

• New class file has empty


constructor
© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 14
Methods

• Methods are declared using the keyword function


- Methods can be private or public

• Like Java, methods can refer to the instance from which


the method is called using the key word this
© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 16
Properties

• In Gosu, a property is a private variable whose value is


manipulated publicly through getters and setters
• Shorthand is to declare the property with the as keyword
- private var _label: String as Label

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 17
Extending a class
• To extend a class
- add extends
superClass to the class
declaration
• Super keyword gives
you access to aspects
of the superclass
• Override keyword lets
you override methods
Access to declared in the super
inherited
properties class

• As declared in the superclass, the class can access


non-private properties and methods
© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 18
Logging

• Write to the log using the logger class


- gw.api.util.Logger.logTypeXX("logString")
- TypeXXX is for
- Trace, Debug, Info, Warn,
- Error

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 19
Exception handling

• Gosu can make use of try...catch...finally blocks


• Gosu code can throw Gosu and Java exceptions

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 21
Gosu classes support annotations

• An annotation is an expression starting with an "@" that


provides metadata about a Gosu element
• Gosu provides four annotations for general class and
method documentation (as shown above)

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 22
Lesson outline

• Overview of Gosu for integration

• Gosu classes

• Blocks

• Sequential numbers

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 23
Blocks
• A block is an unnamed method that is typically created as
an input parameter for another method
- For example, an array's where() method takes a block that specifies
a certain criteria and returns the elements in the array that match
that criteria

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 24
Block syntax
• Syntax: (\argument(s) -> logicToExecute)

var generalNotes =
aContact.ContactNotes.where(\note ->

note.ContactNoteType == "general")
• In most cases, the object is iterable
• "note" is a placeholder name for elements from the array
• The where method returns all members of the array where
the block's Boolean condition is true

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 25
Lesson outline

• Overview of Gosu for integration

• Gosu classes

• Blocks

• Sequential numbers

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 26
The sequence utility
• The sequence utility is a Guidewire class that is used to
generate unique, sequential numbers
- Useful for business cases requiring numbers that are sequential or
unique
• The Guidewire database stores sequence information
- For each sequence, it maintains a record of the last number
provided
• The next() method is used to request numbers
- The database provides the next number in the given sequence

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 27
Using the sequence utility
• Syntax: gw.api.system.database.
SequenceUtil.next(minVal, seqKey)

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 28
SequenceUtil in action

• Gosu Scratchpad
- Line 3:
- First call "abc"
- Line 4: Call "abc"
- Second call "abc"
Call "abc"
- Line 5:
Call "xyz"
- Third call with "xyz"

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 30
Lesson objectives review
• You should now be able to:
- Describe the places where an integration developer uses Gosu
- Create Gosu classes
- Use blocks as input parameters
- Generate unique, sequential numbers

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 31
Review questions
1. A Gosu class is named Circle. Each instance must have a
property for the circle's radius. (This value can be
accessed and modified by methods in the Circle class, but
not by methods in other classes). How many elements
must you create to implement this?
2. The Circle class extends the Oval class and implements
the ICurveLine interface.
- Can Circle override methods from Oval?
- Can Circle override methods from ICurveLine?

3. What is the purpose of an annotation?


4. What types of methods make use of blocks?
5. (continued)

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 32
Review questions
5. If the only sequence in the database has a key of "abc"
and the last number issued for sequence "abc" was 7,
what will be the return value of the following:
- SequenceUtil.next(1, "abc")
- SequenceUtil.next(15, "abc")
- SequenceUtil.next(1, "cba")

© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 33
Notices
Copyright © 2001-2013 Guidewire Software, Inc. All rights reserved.

Guidewire, Guidewire Software, Guidewire ClaimCenter, Guidewire PolicyCenter,


Guidewire BillingCenter, Guidewire Reinsurance Management, Guidewire
ContactManager, Guidewire Vendor Data Management, Guidewire Client Data
Management, Guidewire Rating Management, Guidewire InsuranceSuite, Guidewire
ContactCenter, Guidewire Studio, Guidewire Product Designer, Guidewire Live, Guidewire
ExampleCenter, Gosu, Deliver Insurance Your Way, and the Guidewire logo are
trademarks, service marks, or registered trademarks of Guidewire Software, Inc. in the
United States and/or other countries. Guidewire products are protected by one or more
United States patents.

This material is Guidewire proprietary and confidential. The contents of this material,
including product architecture details and APIs, are considered confidential and are fully
protected by customer licensing confidentiality agreements and signed Non-Disclosure
Agreements (NDAs).

This file and the contents herein are the property of Guidewire Software, Inc. Use of this
course material is restricted to students officially registered in this specific Guidewire-
instructed course, or for other use expressly authorized by Guidewire. Replication or
distribution of this course material in electronic, paper, or other format is prohibited without
express permission from Guidewire.
© Guidewire Software, Inc. 2001-2013. All rights reserved. Do not distribute without permission. 34

You might also like