Post on 18-Mar-2020
transcript
Introduction to business component technologies
Component definitions Szyperski:
A software component is a unit of composition with contractually specified interfaces and explicit context dependencies only. A software component can be deployed independently and is subject to composition by third parties
D'Souza and Wills: A software component is a coherent package of software artefacts
that can be independently developed and delivered as a unit and that can be composed, unchanged, with other components to build something larger
UML v2.4: A component represents a modular part of a system that
encapsulates its contents and whose manifestation is replaceablewithin its environment
More definitions: http://en.wikipedia.org/wiki/Software_componentry
Business components 2
Context dependencies Component may require security, transaction, logging and
other middleware services provided by component container (aka component framework)
Component may require other components to be made available (required interface)
Business components 3
Problem with these definitions Definitions above are correct, but they do not stress
differences between a component and a class:
public class Component implements Interface { ...
}
Business components 4
Essential characteristics of a componentComponent Oriented Development in OSGi with Declarative Services, Spring Dynamic Modules andApache iPOJO, Neil Bartlett, Heiko Seeberger, 2009
May provide services to other components and use services from other components
Have a life cycle
Active participants in the system
They need middleware services, such as transactions, security, logging, etc.
Characteristic of future component technologies:
Aware of and adapt to their environment
Business components 5
Old analogyComponent Oriented Development in OSGi with Declarative Services, Spring Dynamic Modules andApache iPOJO, Neil Bartlett, Heiko Seeberger, 2009
inactive
do not provide/use services
no life-cycle
do not adopt to environment
Business components 6
New analogyComponent Oriented Development in OSGi with Declarative Services, Spring Dynamic Modules andApache iPOJO, Neil Bartlett, Heiko Seeberger, 2009
Business components 7
How to distinguish a component from a class? Components cannot live without special environment
called container container instantiates components and controls their life-
cycle
container (not programmer!) binds components together (required interfaces with provided interfaces)
container provides services to components
Instances of a component are created by container, never by programmer itself (operator new is prohibited) Conversely, instances of classes are created by programmer
using operator new.
Later we will look at components in more details (slides about modules and components)
Business components 8
Concepts: business logic and middleware Business logic
models real life business objects (such as accounts, loan, and inventories)
prescribes how business objects interact with one another enforces the routes and the methods by which business
objects are accessed and updated is part of functional requirements creates essential added value that client is willing to pay for.
Middleware - software that provides services to applications beyond those available from the operating system For example: transactions, logging, security, messaging, etc. if is mentioned in requirements document then only as part
of non-functional requirements; often is assumed as matter-of-course and not documented at
all.Business components 9
Explicit middleware Money transfer between two accounts:
void transfer(Account account1, Account account2, long amount) {
1: Perform a security check2: Create audit log record3: Start a transaction4: Load data from the database5: account1 -= amount; account2 += amount;6: Store updated data to the database7: Commit the transaction
} Business logic is intertwined with the logic to call middleware
services Lowers developer productivity, difficult to write and maintain.
Business components 10
Implicit middleware Programmer writes only business logic:
void transfer(Account account1, Account account2, long amount){
account1 -= amount; account2 += amount;}
If middleware services are needed, we declare that, for example, in: XML file, annotations.
Middleware services are called by component container with the help of request interceptor.
Business components 11
The Essence of Component-oriented Technologies
Business components 12
Client - other component or some program
Request Interceptor
Component
Transaction Service
Security Service
My own middleware implementation
My APIMy API
Security API
Security API
Transaction API
Transaction API
Main Conclusions Component-based technologies enable us to separate
business logic from middleware services
Provide means to apply Separation-of-Concernsprinciple in practice
Client never communicates with component instance directly – there always will be an intermediary (request interceptor, proxy, etc.)
Sometimes even more than one intermediary
Business components 13
Modern business component technologies CDI (Contexts and Dependency Injection)
http://cdi-spec.org/
SpringFramework IoC container http://docs.spring.io/spring/docs/current/spring-framework-
reference/htmlsingle/#beans
EJB (Enterprise JavaBeans) https://java.net/projects/ejb-spec/
OSGi https://www.osgi.org/developer/downloads/
Microsoft Application Platform Book: Microsoft Application Architecture Guide, 2nd Edition
Component Guidelines
Designing Business Components
Business components 14