tdde41 software architectures architectural styles › ~tdde41 › lectures ›...

92
TDDE41 Software Architectures Architectural styles Lena Buffoni [email protected]

Upload: others

Post on 06-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

TDDE41SoftwareArchitecturesArchitecturalstyles

[email protected]

Page 2: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Lectureplan• Abstraction levels in architecture• Domain specific design• Architectural patterns• Architectural styles

Page 3: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Architecturevs.GenericComponentsMARCH31,2019 3

A specific place for every component

Generic building blocks

Comparable to top-down vs. bottom-up design strategy?

Page 4: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Reality?

MARCH31,2019 4

Page 5: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Atwhatabstractionleveldowestart?• Solving a more general problem?

• Solving a specific problem?

• Separation of concerns

Page 6: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Example

CarModel(inModelica)Truckmodel

Howcanwegeneralizetheconcepts?

Page 7: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Designprocess

Feasibility

Preliminary design

Detailed design

Planning

*DesignMethods(Architecture),Jones,1970

linear

cyclic

parallelIdentify feasible concepts

Select an alternative

Refine alternative

Adapt to production cycle

Page 8: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Domainspecificsoftwarearchitectures

Rarely start from scratch – eg. New car model

Referencearchitecture

Libraryofcomponents

Experience

A standard car decomposition layout

A library of automotive components

Knowing how to combine thing so they work

Page 9: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

DSSA:representingdomainknowledge

Example Represented

Domaindictionary Powertrain,gearchange,chassis

Informationmodel Avehiclehasasteeringwheeland1+wheels

ERdiagram,ContextInformationDiagrams

Featuremodel User canstartcar,usercanpressacceleratorpedal,usercangetcurrentspeed

Usecasediagrams,Feature relationshipdiagrams

Operationalmodel Carstartsatrest ->Engineisstarted->Gearischanged…

Data flow,controlflow,statetransitiondiagrams

Page 10: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

ArchitecturalpatternsReminder:

• Named collection of architectural design decisions• Applicable to recurring design problems• Parametrized for different contexts

Page 11: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

State-Logic-Display(Three-Tier)

WebshopGUI

Webserver+shopapplication

ProductDatabase state

UI

businesslogic

Webclient

Webtier

EJBtier

Backend

4tierbreakdown

Page 12: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Tierarchitecture

• Structure the system as groups of components organized based on type of component, runtime-purpose, execution environment, …

• Communications with components in the same or adjacent tier – may restrict kinds of communication

+ simplify modifiability+ easy to ensure security+ good for performance management

- high cost, high complexity

Page 13: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Model-View-Controller

ModelBuffers,textproperties,markers,overlays

Controller

Lispinterpreter,lispcode,lips

objects

Buffer access primitives

Buffer content rendering

Window manipulation

primitives

Keyboardinput,mousegestures,menuselections

Lisp-leveleventsView

Frames,windows,incrementaldisplay

updatelogic

Page 14: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Emacs andfeaturedrivendevelopment

• Easy to add a feature/extend the tool• Interactive• Safe – bugs will not crash the editor• Everything is on the same level of abstraction

(buffers, windows, your own extensions)

+ high cohesion, low coupling- Consistency and maintainability

Page 15: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Sensor-Controller-Actuator

Logic:Loop:

Read input valuesCompute outputsUpdate actuators

sensors

actuators

controller

Page 16: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Sensor-Controller-Actuator• Typically scheduled on a clock• Implicit interaction via the environment – a change

on the actuators will result in a change sensors will detect

Clock

Algorithm

Computer

A/D, Sample D/A, ZOH

Plant

Page 17: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

ArchitecturalStyles• An architectural style is a named collection of

architectural decisions that– Are applicable in a given development context– Constrain architectural design decisions that are

specific to a particular system within that context– Elicit beneficial qualities in each resulting system

Page 18: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

ProgramandSubroutines• From classical imperative programming• Small programs• Does not scale or adapt well

LunarLanderMain

Getburnratefromuser

Environmentsimulator

Displayvaluestouser

Procedurecall

Page 19: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Object-oriented• Good for complex dynamic data structures• Close coupling to real world entities• Harder to distribute• Needs additional structuring

GUI

Spacecraft Environmentsimulator

Procedurecall

Page 20: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Layered• Design separated into layers• Each layer obtains services from the layer beneath

– Virtual Machines– Client-Server

Page 21: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Virtualization

MARCH31,2019 21

• Abstract the hardware and infrastructure• Allow a unified user experience• Energy saving• SecureBut:• Overhead• Compatibility limitations• Shared resources

VMWare,VirtualBox,Xen…

Page 22: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Virtualization:Portabilityonmachinelevel

MARCH31,2019 22

Hardware

HostOS

Hypervisor(type2)

GuestOS

GuestOS

GuestOS

AppA AppB AppC

Managing resource virtualization and distribution

Page 23: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Virtualization:XenArchitecturefordistributedcomputing

MARCH31,2019 23

Highestprivilegelevel,weseparatethemanagementlogic,toreduceimpactoferrors

Page 24: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Paravirtualization• Making changes to the program or operating system

to optimize its performance• Remove features that are difficult to virtualize and

replace them with paravirtual features

• Eg: memory handling Frontenddriver

Backenddriver

Ringbuffer

Implementfamiliarinterfaceforoperatingsystem

Connectstorealhardware

Page 25: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Containerization:PortabilityonOS/applicationlevel

MARCH31,2019 25

Hardware

HostOS

ContainerEngine

AppA AppB AppC

Page 26: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Containerization

MARCH31,2019 26

• Lightweight• Portability• Less overhead• Breakdown into smaller chunksBut• Less isolation• No hardware virtualization• Still… overhead Docker,Rocket…

Complementary approaches?

Page 27: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Emulationvsvirtualization

• Virtualized instructions run directly on the processor• Emulated instructions are translated before

execution

Page 28: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Client-server:aformofvirtualization

Server:GameState,GameLogic,EnvironmentSImulation

RPC(procedurecall+distributor)

Client1:GetInfo,SendActions,GraphicsProcessing

RPC(procedurecall+distributor)

Client2:GetInfo,SendActions,GraphicsProcessing

RPC(procedurecall+distributor)

Client3:GetInfo,SendActions,GraphicsProcessing

Page 29: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Data-flow• Batch-Sequential• Pipe and filter• Rule-based

Knowledgebase

InferenceEngine

UserInterfaces

Procedurecall

Dataaccess

Page 30: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

InterpreterDynamic parsing and execution of commands (eg: Excel)Mobile codeUsed for distributed data processing+ Dynamic+ Evolutive- Overhead- Memory management

Page 31: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Peer-to-peer

• Network of peers• Loosely coupled• Autonomous• Decentralized resources• Requests propagate until information is discovered

or threshold is reached

+ Scalable+ Robust- Latency- Security

Page 32: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Peer-to-peerarchitecture

SupernodeA

SupernodeC

SupernodeB

P7

P8

P1

P2

P3P4

P6

P5

Page 33: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Skype- mixedclient/serverandP2P• Download a Skype client• Register and log in to server• Get provided with a supernode address• Queries and voice calls over the supernode• Location of supernodes determined based on

topology and machine characteristics• Any peer can become a supernode

Page 34: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Skype– architectureproperties• Mixed model handles the discovery problem• Scalable and robust• Supernodes are chosen to maximize performance• As many supernodes can be created as necessary• Encryption protocol to ensure privacy• Restriction to Skype controlled clients reduces risk

for malaware

Page 35: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Distributedparadigms• Distributed objects• CORBA• MOM

Page 36: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Thestub&skeletonproxypattern

MARCH31,2019 36

Stub Skeleton

ApplicationInC++

Client1inJava

Stub

Client2InPython

Call

Client-side proxy of the component

Language adaptationlocal version

Page 37: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Proxypattern

MARCH31,2019 37

Client <<interface>>Application

+ call(Data)

ApplicationImpl

+ call(Data)

Proxy

+ call(Data)

implements

calls

represents

Page 38: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Distributedcomponentsystems

MARCH31,2019 38

Stub Skeleton

ApplicationInC++

Client1inJava

Stub

Client2InPython

RemoteCall

On another machine

LocalCall

Now need to: handle data transportation, remote procedure calls…

Page 39: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Referenceproblem

MARCH31,2019 39

• How to keep references across multiple platforms?• References in composite parameters and results• Scope of references?• Target of calls

Page 40: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Uniquenamingconventions

MARCH31,2019 40

• World-wide unique addresses E.g. computer address + local address URL, URI (uniform resource identifiers) • Mapping tables for local references

– Logical-to-physicalConsistent change of local references possible

– (In principle) one adapter per computer manages references

Page 41: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Stubs,Skeletons,andAdapters

MARCH31,2019 41

Stub Skeleton

ApplicationInC++

Client1inJava

RemoteCall

Groups everything need to handlecommunication protocols, identification, referencing…

Client2InPython

Stub

Adapter Adapter

ApplicationInC++

Skeleton

Page 42: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

WhoimplementsStubsandSkeletons?

MARCH31,2019 42

• Stubs and Skeletons are– Component interface dependent– Implementation language dependent

• Manually – error prone, time consuming• Automatically?

Page 43: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

InterfaceDefinitionLanguage(IDL)

MARCH31,2019 43

• A language to define the interfaces of components• IDL interfaces can be used to automatically generate

stubs and skeletons (OMG IDL, MIDL…)

Definecomponentinterface

AutomaticallygenerateStubandSkeleton

Implementthe

component

Page 44: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Persistenceofobjects

MARCH31,2019 44

• The ability of an object to survive the lifetime of the OS process in which it resides.

• The object state needs to be retained• Store and load the objectPersistent storage can be

– File system – Relational Database – Object-Database – Flash-RAM

• •

Page 45: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

CommonObjectRequestBrokerArchitecture(CORBA)

MARCH31,2019 45

The OMG way: CORBA, CCM, OMA, and MDA

OMG never settled on “binary” standards (standards at the level of deployableexecutables) – everything is carefully standardized to allow for many differentimplementations and for individual vendors of CORBA-compliant products toadd value. The downside of this very open approach is that individualCORBA-compliant products cannot interoperate on an efficient binary level,but must engage instead in costly high-level protocols. The most prominent,although only moderately efficient, interoperability protocol is OMG’s inter-net inter-ORB protocol (IIOP), standardized with CORBA 2.0 in July 1995.Any ORB claiming interoperability compliance has to support IIOP. In theJuly 1996 update of the CORBA 2.0 standard, an interworking standard wasadded, which specifies the interworking of CORBA-based systems with sys-tems based on Microsoft’s COM (see Chapter 15).

CORBA essentially has three parts: a set of invocation interfaces, the objectrequest broker (ORB), and a set of object adapters. Invocations of object-ori-ented operations – also called method invocations – require late binding of theimplementation. The method implementing the invoked operation is selectedbased on the object implementation to which the receiving object’s referencerefers. Invocation interfaces enable various degrees of late binding. They alsomarshal an invocation’s arguments such that the ORB core can locate the receiverobject and the invoked method and transport the arguments. At the receivingend, an object adapter unmarshals the arguments and invokes the requestedmethod on the receiver object. Figure 13.1 illustrates the basic CORBA struc-ture in simplified form.

For invocation interfaces and object adapters to work, two essential require-ments need to be met. First, all object interfaces need to be described in acommon language. Second, all languages used must have bindings to thecommon language. The first condition enables construction of generic mar-shaling and unmarshaling mechanisms. The second allows calls from or to aparticular language to be related to the common language. This common lan-guage formed an essential part of CORBA from the beginning and is calledOMG interface definition language (OMG IDL). Here is an example of anOMG IDL specification:

232

Figure 13.1 Simplified structure of an ORB-based system.

Language/implementation/platformbarrier

obj.m(args)

Invocationinterface

ORBinterface

Objectadapter

ORBinterface

ObjectMethod 1Method n

8557 Chapter 13 p231-260 8/10/02 12:24 pm Page 232

Page 46: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

OMGInterfaceDefinitionLanguage

MARCH31,2019 46

• Compiled and deposited in interface repository• Used for automatic stub and skeleton generation

module Example { struct Date {unsigned short Day; unsigned short Month; unsigned short Year;}interface Ufo {readonly attribute unsigned long ID; readonly attribute string Name; readonlyattribute Date FirstContact; unsigned long Contacts ();void RegisterContact (Date dateOfContact); }}

Page 47: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

APRIL2,2019 47

Clientprogram Objectinstance

Clientprogram

Objectstub

ObjectRequestBrokerObjectinstance

Objectskeleton

Clientprogram

Objectstub

Objectinstance

Objectskeleton

ClientORBfragment

ServerORBfragment

implementation

Method call

IDL interface

conceptual

Page 48: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

InteroperableObjectReference(IOR)MARCH31,2019 48

• A unique ID used to locate the object

• Object reference shipped by server to clients and stored in the proxy

• Contains– Type name– Protocol and address details– Object key

module CORBA {pseudo interface ORB {string object_to_string (in Object obj);Object string_to_object (in String ior);};

}

Page 49: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Message-OrientedMiddleware(MOM)• Loosely coupled• Asynchronous• Used to connect independent applications

Sender ReceiverQueueReceiverSender

Messagehandlingservices

• Besteffort• Persistent• Transactional+Clustering+Two-waymessaging

Page 50: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Publish-subscribeJMS – Java Message Service• Subscribers register to receive specific messages• Publishers maintain a subscription list

MessageConsumer consumer = session.createConsumer(queue);

synchronous

Listener myListener = new Listener(); consumer.setMessageListener(myListener);

asynchronous

Message m = consumer.receive();

Page 51: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Event-based

• Independent• Concurrent+ scalable+ distributed+ supports heterogeneity- no guarantee events will be processed

Page 52: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Javabeans– mainaspects

APRIL2,2019 52

• Events Beans can announce that their instances are potential sources or listeners of specific types of events. An assembly tool can then connect listeners to sources.

• Properties Beans expose a set of instance properties by means of pairs of getter and setter methods.

• Introspection An assembly tool can inspect a bean to find out about the properties, events, and methods that a particular bean supports.

• Customization Using the assembly tool, a bean instance can be customized by setting its properties.

• Persistence Customized and connected bean instances need to be saved for reloading at the time of application use.

Page 53: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Events

APRIL2,2019 53

• Event (MouseOver)

• Event source – generates an event (mouse hoovers over a button)

• Event listener - triggers some behavior when an event is detected (button is highlighted)

publicvoidadd<Event>Listener(<Event>Listenera)

Page 54: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Events- issues

APRIL2,2019 54

• Exceptions—an exception in a bean can propagate up to unrelated beans that just happened to be on the call stack.

• Security—JVM grants any function the least privileges of all functions on the call stack.

• Concurrency—JavaBeans neither enforces nor encourages any global synchronization

Page 55: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

ServiceOrientedArchitecturesA form of application integration middlewareGoals:• Interoperability• Distributed systems• Standardization (?)

Page 56: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Webserver

Onlineclothingstore

(J2EE/IOP/JMS)

Supplier1(Linux/EJB)

Merchant1(Linux/EJB)

Supplier2(Windows

Server/.NET)

Shipper1(VMS)

Chromeclient

IPhoneappclient

…… …

… …

…Shipper2

(Solaris/CORBA)

UserAutentification

Bank1(mVS/CICS)

Paypal(Braintree)

Page 57: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Encapsulation

MARCH31,2019 57

• All access through API• Explicit API definitions• No hidden interactions• Explicit data passing• Context-free calls

API

Service logic

Page 58: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Autonomy

MARCH31,2019 58

• Replaced, managed and deployed independently• Responsible for their own security

API

Service logicAPI

Service logic

Page 59: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Loosecoupling

MARCH31,2019 59

Low dependency/connection level in terms of– Time– Location– Type– Version– Cardinality– Lookup– Interface

Page 60: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Contractdriven

MARCH31,2019 60

• Not class driven• Description based• Loose coupling = few

assumptions on implementation

ServiceImplementation

API

ex: RMI is implementation dependent – not SO

Page 61: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Interoperabilityandstandards

MARCH31,2019 61

• Relies on open standards not proprietary APIs• All message formats are described using an open

standard, or a human readable description• The semantics and syntax for additional information

necessary for successful communication, such as headers for purposes such as security or reliability, follow a public specification or standard

• At least one of the transport (or transfer) protocols used to interact with the service is a (or is accessible via a) standard network protocol

Page 62: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Vendor&Technologyindependent

MARCH31,2019 62

To ensure the utmost accessibility (and therefore, long-term usability), a service must be accessible from any platform that supports the exchange of messages adhering to the service interface as long as the interaction conforms to the policy defined for the service.

Page 63: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Web-services

MARCH31,2019 63

• A realization of the SOA paradigm• Relies on XML and the Web for implementation• Attention: a web service is not necessarily SOA

compliant!

client

Service provider

Page 64: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

XMLformat

MARCH31,2019 64

• W3C standard• Open & extensible• Structured• Readable

But• Heavy• No semantics

Page 65: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

ExampleMARCH31,2019 65

<breakfast-menu><food>

<name>Belgian Waffles</name><price>$5.95</price><description>

two of our famous Belgian Waffles

with plenty of real maple syrup</description><calories>650</calories>

</food><food>

<name>Strawberry Belgian Waffles</name>

<price>$7.95</price><description>

light Belgian waffles covered with strawberries and whipped cream

</description><calories>900</calories>

</food></breakfast-menu>

We need some way to define XML structure

Page 66: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

XMLSchema:typedefinition

MARCH31,2019 66

<xs:element name="item" maxOccurs="unbounded"><xs:complexType><xs:sequence><xs:element name="title" type="xs:string"/><xs:element name="note" type="xs:string"

minOccurs="0"/><xs:element name="quantity"

type="xs:positiveInteger"/><xs:element name="price" type="xs:decimal"/>

</xs:sequence></xs:complexType>

</xs:element>

<item><title>Empire Burlesque</title><note>Special Edition</note><quantity>1</quantity><price>10.90</price>

</item>

Item instance

Item type definition

Page 67: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

SimpleObjectAccessProtocol (SOAP)

MARCH31,2019 67

• XML based message exchange protocol• Used for remote procedure calls (RPC)• Platform and language independent• Uses predefined channels (HTTP, SMTP, TPC)

Page 68: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

SOAPmessagestructureMARCH31,2019 68

<?xml version="1.0"?>

<soap:Envelopexmlns:soap="http://www.w3.org/2003/05/soap-envelope/"soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">

<soap:Header>...</soap:Header>

<soap:Body>...<soap:Fault>...</soap:Fault>

</soap:Body>

</soap:Envelope>

Optional, application specific information

Mandatory, define the message as a soap envelope

Optional, contains the actual message, can contain error information

Page 69: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

SOAPexample

MARCH31,2019 69

<?xml version="1.0"?>

<soap:Envelopexmlns:soap="http://www.w3.org/2003/05/soap-envelope/"soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">

<soap:Body><m:GetPrice

xmlns:m="http://www.w3schools.com/prices"><m:Item>Apples</m:Item>

</m:GetPrice></soap:Body>

</soap:Envelope>

Page 70: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

SOAPPros&Cons

MARCH31,2019 70

+W3C Recommendation (standard) + Implements RPC+ Lightweight, extensible, neutral

- Untyped user data, types to encode in the message -Interpretation of SOAP messages required- High overhead / low performance- Serialization by value and not by reference

Page 71: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

WSDL(WebServicesDescriptionLanguage)

71

• WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information.

• Used to describe:– a service for its clients – a standard service for WS implementers

• W3C standard

Page 72: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

WSDLInterfaceDefinition

72

• defines services as collections of network endpoints, or ports

• the abstract definition of endpoints and messages is separated from their concrete network deployment or data format bindings

• messages, which are abstract descriptions of the data being exchanged, and port types which are abstract collections of operations

Page 73: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

73

WSDLinterfacestructure<definitions>

<types>data type definitions........

</types>

<message>definition of the data being

communicated....</message>

<portType>set of operations......

</portType>

<binding>protocol and data format

specification....</binding>

</definitions>

Page 74: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

MARCH31,2019 74Title/Lecturer

WSDLexample:Glossary

<message name="getTermRequest"><part name="term" type="xs:string"/>

</message>

<message name="getTermResponse"><part name="value" type="xs:string"/>

</message>

<portType name="glossaryTerms"><operation name="getTerm"><input message="getTermRequest"/><output message="getTermResponse"/>

</operation></portType>

Page 75: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

WSDLBindingtoSOAP

MARCH31,2019 75Title/Lecturer

• binding = associating protocol or data format information with an abstract entity like a message, operation, or portType

• SOAP specific elements include:– soap:binding– soap:operation– soap:body

Page 76: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Bindingexample

MARCH31,2019 76Title/Lecturer

bindingofone-wayoperationoverSMTPusingaSOAPHeader

<binding type="glossaryTerms" name="b1"><soap:binding style="document"transport="http://schemas.xmlsoap.org/soap/

http" /><operation><soap:operation

soapAction="http://example.com/getTerm"/><input><soap:body use="literal"/></input><output><soap:body

use="literal"/></output></operation>

</binding>

Page 77: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

WSDLPros&Cons

MARCH31,2019 77Title/Lecturer

WSDL abstracts from underlying – Protocol (Binding to HTTP, SOAP, MIME, IIOP…) – Component model (Mappings to CORBA, EJB,

DCOM, .NET …) – Supported by many tools (Visual Studio, Eclipse,

…)But:• No inheritance on WSDL • Not recursively composable

Page 78: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

JAX-WS• No need to manually format SOAP messages• Converts API calls and responses from/to SOAP• Provides WSDL mappings

@WebServicepublic class Hello {private String message = new String("Hello, ");@WebMethodpublic String sayHello(String name) {return message + name + ".";}}

Page 79: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Categorizationanddiscovery

MARCH31,2019 79Title/Lecturer

• Providers need a way to propose their services• Clients need a way to find available services

• UDDI (Universal Description, Discovery, and Integration) is an XML-based registry for businesses worldwide to list themselves on the Internet

• Like a telephone book for services

Page 80: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

UDDI

MARCH31,2019 80Title/Lecturer

• a specification for a distributed registry of web services.

• platform-independent, open framework.• can communicate via SOAP, CORBA, Java RMI

Protocol.• Uses WSDL to describe interfaces to web

services.

Page 81: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

MARCH31,2019 81Title/Lecturer

Page 82: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

UDDIExample82

<tModel authorizedName="..." operator="..." tModelKey="..."><name>HertzReserveService</name><description xml:lang="en">

WSDL description of the Hertz reservation service interface</description>

<overviewDoc><description xml:lang="en">

WSDL source document.</description><overviewURL>

http://mach3.ebphost.net/wsdl/hertz_reserve.wsdl</overviewURL>

</overviewDoc>

<categoryBag><keyedReference tModelKey="uuid:C1ACF26D-9672-4404-9D70-

39B756E62AB4"keyName="uddi-org:types" keyValue="wsdlSpec"/>

</categoryBag></tModel>

Page 83: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

SOAandSecurity

APRIL1,2019 83Title/Lecturer

• Confidentiality, Integrity, Authenticity: XML Encryption, XML Signature.

• Message-Level Security: WS-Security. • Secure Message Delivery: WS-Addressing, WS-

ReliableMessaging. • Metadata: WS-Policy, WS-SecurityPolicy. • Trust Management: SAML, WS-Trust, WS-

SecureConversation, WS- Federation. • Public Key Infrastructure: PKCS, PKIX, XKMS

Page 84: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

SummaryandContext

APRIL1,2019 84Title/Lecturer

Page 85: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

SummaryofWebservicestandards

XML

Messaging

Reliablemessaging Security Transactions

Metadata

Page 86: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Useofstylesandpatterns

• Styles restrict focus -> reduce areas of concern• Easier to use code generation and frameworks (eg:

IDL)• Communication is more efficient• Combining patterns - multiple benefits of several

patternseg: RESTful services

Page 87: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

SOAPvsRESTfulwebservices• Key abstraction of information is a resource, named

by a URL• Resources = sequence of bytes + metadata to

interpret the bytes• Context-free• Components perform only a small set of well defined

methods• Replication and caching• Intermediaries

Page 88: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Facebookcase-study

AppData

FBData

AppLogic

AppDisplay Browser

FBIAPI

Privacy

S_REQUEST

AppInfrastructure

FBInfrastructure

ProvidingFBintegrationwiththirdpartyapplications

FBasaservice

HTLM,JS,CCS

Page 89: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Facebookcase-study• Data-centric application• FB provides a standard API• Accessing data -> multiple requests -> overhead• FQL : a Facebook query language

Page 90: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Facebookcase-study

AppData

FBData

AppLogic

AppDisplay Browser

FBIAPI

PrivacyS_REQUEST

AppInfrastructure

FBInfrastructure

Integrating3rd partyappintotheFBplatform

- Interpretinginstructions- UsingFBdatawithout

accessingit

FBMLinterpreter

FBLogic FBDisplay

FBML

ReceiverHTLM,JS,CCS

Page 91: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Unprecedenteddesign

How do we model in new contexts?

Page 92: TDDE41 Software Architectures Architectural styles › ~TDDE41 › lectures › Lecture_3_styles.pdf · Java beans –main aspects APRIL 2, 2019 52 • Events Beans can announce that

Summary

DesignPatterns

Styles

ArchitecturalPatterns

DomainSpecificSWArchitectures

scope

deep

shallow

domain