T
- type of service configurerV
- type of service contextpublic abstract class AbstractService<T extends ServiceConfigurer,V extends ServiceContext> extends AbstractPluginConfigurable<T> implements Service<T,V>
Constructor and Description |
---|
AbstractService() |
Modifier and Type | Method and Description |
---|---|
protected void |
addHandler(HttpServiceHandler handler)
Add handler to the Service.
|
protected void |
addHandlers(Iterable<? extends HttpServiceHandler> handlers)
Add a list of handlers to the Service.
|
protected abstract void |
configure()
Implements this method to configure this Service.
|
void |
configure(T serviceConfigurer)
Configure the Service by adding
HttpServiceHandler s to handle requests. |
protected T |
getConfigurer()
Returns the
ServiceConfigurer , only available at configuration time. |
protected V |
getContext() |
void |
initialize(V context)
Initialize the
Service . |
protected void |
setDescription(String description)
Set the description of the Service.
|
protected void |
setInstances(int instances)
Sets the number of instances needed for the server that runs all
HttpServiceHandler s of
this Service. |
protected void |
setName(String name)
Set the name for the Service.
|
protected void |
setProperties(Map<String,String> properties)
Sets a set of properties that will be available through the
ServiceSpecification.getProperties() at runtime. |
protected void |
setResources(Resources resources)
Sets the resources requirements for the server that runs all
HttpServiceHandler s of
this Service. |
usePlugin, usePlugin, usePluginClass, usePluginClass
addDatasetModule, addDatasetType, createDataset, createDataset, createDataset, createDataset
public final void configure(T serviceConfigurer)
Service
HttpServiceHandler
s to handle requests.configure
in interface Service<T extends ServiceConfigurer,V extends ServiceContext>
serviceConfigurer
- to use to add handlers to the Service.protected void setName(String name)
name
- of the service.protected void setDescription(String description)
description
- of the service.protected void addHandler(HttpServiceHandler handler)
handler
- to serve requests with.protected void addHandlers(Iterable<? extends HttpServiceHandler> handlers)
handlers
- to service requests with.protected void setInstances(int instances)
HttpServiceHandler
s of
this Service.instances
- Number of instances, must be > 0.protected void setResources(Resources resources)
HttpServiceHandler
s of
this Service.resources
- The requirements.protected void setProperties(Map<String,String> properties)
ServiceSpecification.getProperties()
at runtime.properties
- the properties to setprotected final T getConfigurer()
ServiceConfigurer
, only available at configuration time.getConfigurer
in class AbstractPluginConfigurable<T extends ServiceConfigurer>
protected abstract void configure()
protected V getContext()
public void initialize(V context) throws Exception
Service
Service
. This method will be called before the service starts up. This
method will be called before each service instance starts up. If there is more than one
instance of the service, it will be called more than once.
Note that unlike most program types, this method is not called within an implicit transaction,
but instead it can start its own transactions using Transactional.execute(TxRunnable)
.
methods.initialize
in interface ProgramLifecycle<V extends ServiceContext>
initialize
in interface Service<T extends ServiceConfigurer,V extends ServiceContext>
context
- An instance of RuntimeContext
Exception
- If there is any error during initialization.Copyright © 2024 Cask Data, Inc. Licensed under the Apache License, Version 2.0.