Java Reference
In-Depth Information
The
Provider
implements the
IOperation
interface to fulfill the unit of
work that the
Service
is designed to provide. The
Service
invokes the
IOperation
's
execute()
method on its
Provider
s using the
ExecutionStrategy
. The
Service
can provide the functionality if any of its
registered
Provider
s return
true
to the
provides()
operation when passed
the
IOperation
instance.
Elements declared in the
Service
extension-point schema are populated by
Provider
s and loaded using a configuration class. Not shown on the diagram
is the
AbstractProviderConfiguration
class, which is intended to be sub-
classed to parse service provider descriptors. The
ProviderDescriptor
typi-
cally maintains an instance of the configuration that is initialized when the
Provider
is configured. The
Service
loads the
Provider
plug-ins when
required, where its
startup()
method contains the required static initialization
code.
You also can configure a
Service
with performance options, such as by
using the
Service(boolean optimized)
constructor. Passing
true
causes the
Service
to cache providers when first retrieved for a given operation.
Otherwise, the default behavior is to consider all
Provider
s each time an
operation is executed. Another
Service(boolean optimized, boolean
optimistic)
constructor takes an additional optimistic Boolean parameter
that, if
true
, causes the
Service
to trust its cache of
Providers
. Otherwise, it
validates that the cache contents are still valid for the operation.
The
Service-Provider
infrastructure that GMF provides is used by many
of its extension-points, as documented shortly. Note that you can use this infra-
structure to create new services for your applications.
10.4.1 ViewService
Recall from the description of the notation model that
View
was the central ele-
ment that contains the reference for the associated domain element. The
ViewService
is responsible for constructing
View
elements (
Diagram
,
Node
,
Edge
), typically by returning a
ViewFactory
class. This factory is responsible
for creating notation view elements, setting
Style
elements, layout constraints,
child views, and so on. In a similar recursive manner described for diagram cre-
ation in GEF, the
ViewService
is called with a
hint
to obtain the proper
provider and factory for element creation.
As shown in Figure 10-25, the
ViewService
has a corresponding
AbstractViewProvider
that provides for a number of operations, including
those used to create diagrams, nodes, and edges. Each diagram requires a view
Search WWH ::
Custom Search