Class ServiceContextImpl<S>
- java.lang.Object
-
- com.devonfw.module.service.common.base.context.AbstractServiceContext<S>
-
- com.devonfw.module.service.common.base.context.ServiceContextImpl<S>
-
- Type Parameters:
S- the generic type of theservice API.
- All Implemented Interfaces:
ServiceContext<S>,ServiceDiscoveryContext<S>,ServiceHeaderContext<S>
public class ServiceContextImpl<S> extends AbstractServiceContext<S> implements ServiceHeaderContext<S>, ServiceDiscoveryContext<S>
Implementation ofServiceContext.- Since:
- 3.0.0
-
-
Field Summary
Fields Modifier and Type Field Description private ConfigPropertiesconfigPropertiesprivate Collection<String>headerNamesprivate Map<String,String>headers
-
Constructor Summary
Constructors Constructor Description ServiceContextImpl(Class<S> api, ConfigProperties configProperties)The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigPropertiesgetConfig()StringgetHeader(String name)Collection<String>getHeaderNames()StringgetUrl()voidsetConfig(ConfigProperties configProperties)voidsetHeader(String key, String value)Adds a header to underlying network invocations (e.g.-
Methods inherited from class com.devonfw.module.service.common.base.context.AbstractServiceContext
getApi
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.devonfw.module.service.common.api.client.context.ServiceContext
getApi
-
-
-
-
Field Detail
-
headerNames
private final Collection<String> headerNames
-
configProperties
private ConfigProperties configProperties
-
-
Constructor Detail
-
ServiceContextImpl
public ServiceContextImpl(Class<S> api, ConfigProperties configProperties)
The constructor.- Parameters:
api- theAPI.configProperties- the initialConfigProperties. May beempty.
-
-
Method Detail
-
getUrl
public String getUrl()
- Specified by:
getUrlin interfaceServiceContext<S>- Returns:
- the URL (or URI) of the remote service.
-
getHeaderNames
public Collection<String> getHeaderNames()
- Specified by:
getHeaderNamesin interfaceServiceContext<S>- Returns:
- a
Collectionwith the availableheadernames (keys).
-
getHeader
public String getHeader(String name)
- Specified by:
getHeaderin interfaceServiceContext<S>- Parameters:
name- the name (key) of the header to get.- Returns:
- the value of the requested header or
nullif undefined.
-
setHeader
public void setHeader(String key, String value)
Description copied from interface:ServiceHeaderContextAdds a header to underlying network invocations (e.g. HTTP) triggered by aservice client.- Specified by:
setHeaderin interfaceServiceHeaderContext<S>- Parameters:
key- the name of the header to set.value- the value of the header to set.
-
getConfig
public ConfigProperties getConfig()
- Specified by:
getConfigin interfaceServiceContext<S>- Returns:
- the
ConfigPropertieswith configuration metadata. - See Also:
ServiceClientFactory.create(Class, java.util.Map)
-
setConfig
public void setConfig(ConfigProperties configProperties)
- Specified by:
setConfigin interfaceServiceDiscoveryContext<S>- Parameters:
configProperties- thediscoveredServiceconfiguration such asURL. Has to beinheritedfromexisting configuration properties.
-
-