Class ServiceImp
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- All Implemented Interfaces:
AdaptrisComponent,ComponentLifecycle,ComponentLifecycleExtension,MessageEventGenerator,Service,StateManagedComponent
- Direct Known Subclasses:
AddExtendedLoggingContext,AddFormattedMetadataService,AddLoggingContext,AddNamespaceObjectMetadata,AddPayloadService,AddTimestampMetadataService,AggregatingConsumeServiceImpl,AlwaysFailService,Base64Service,BranchingServiceImp,CacheServiceImpl,ChangeCharEncodingService,ClearLoggingContext,CoreSecurityService,DuplicateMessageRoutingService,DuplicateMetadataValueService,DynamicServiceExecutor,ExceptionHandlingServiceWrapper,ExceptionReportService,FindAndReplaceService,FlattenMimeParts,ForEach,FormDataToMetadata,GunzipService,GzipService,HttpRequestServiceImpl,IfElse,InputOutputService,JdbcService,JettyResponseService,JmxOperationImpl,LoggingServiceImpl,MessageSplitterServiceImp,MetadataComparisonService,MetadataServiceImpl,MetadataToPayloadService,MimePartSelector,MultipartMessageBuilder,NullService,OauthTokenGetter,PayloadFromTemplateService,PayloadHashingService,PayloadToMetadataService,PooledSplitJoinService,ReadFileService,RegexpService,RemoveLoggingContext,RetryingServiceWrapper,RetryStoreServiceImpl,ScriptingServiceImp,ShortCutJettyResponse,SimpleSequenceNumberService,StandaloneProducer,StatelessServiceWrapper,StopProcessingService,Switch,SwitchPayloadService,SymmetricKeyCryptographyService,SyntaxRoutingService,SystemCommandExecutorService,ThrowExceptionService,TranscodingService,UrlEncodedMetadataValues,UseXmlCharsetAsEncodingService,Utf8BomRemover,ValidateMetadataService,VerifyIdentityService,WaitService,While,WriteMetadataToFilesystem,XmlTransformService,XmlValidationService,XpathObjectMetadataService,XPathService
public abstract class ServiceImp extends java.lang.Object implements Service
Implementation of default / common behaviour for
Services. Includes basic implementation ofMessageEventGeneratorwhich returns the fully qualified name of the class.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Loggerlog
-
Constructor Summary
Constructors Constructor Description ServiceImp()Creates a new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidchangeState(ComponentState newState)Updates the state for the componentComponentState.voidclose()Closes the component.protected abstract voidcloseService()booleancontinueOnFailure()If true containers should continue and apply the next configuredServiceeven if thisServicethrows anException.java.lang.StringcreateName()Create a name for anyMleMarkerthat is generated.java.lang.StringcreateQualifier()Create a qualifier for anyMleMarkerthat is generated.java.lang.BooleangetContinueOnFail()java.lang.BooleangetIsTrackingEndpoint()java.lang.StringgetUniqueId()Get the unique-id that is associated with this component.voidinit()Initialises the component.protected abstract voidinitService()booleanisBranching()Returns true if the implementation supports branching.booleanisTrackingEndpoint()Returns true if this should be considered an 'end-point' for tracking purposes, otherwise false.voidrequestClose()Request this component is closed.voidrequestInit()Request this component is init'd.voidrequestStart()Request this component is started.voidrequestStop()Request this component is stopped.ComponentStateretrieveComponentState()Returns the last recordComponentState.voidsetContinueOnFail(java.lang.Boolean b)whether or not this service is configured to continue on failure.voidsetIsTrackingEndpoint(java.lang.Boolean b)whether or not this service is is a tracking endpoint.voidsetUniqueId(java.lang.String s)Sets the unique identifier for thisService.voidstart()Starts the component.voidstop()Stop the component-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.ComponentLifecycleExtension
prepare
-
-
-
-
Constructor Detail
-
ServiceImp
public ServiceImp()
Creates a new instance. Default unique ID is autogenerated using
GuidGenerator.getUUID().
-
-
Method Detail
-
init
public final void init() throws CoreExceptionDescription copied from interface:ComponentLifecycleInitialises the component.Component initialisation includes config verification, creation of connections etc.
- Specified by:
initin interfaceComponentLifecycle- Throws:
CoreException- wrapping any underlyingExceptions
-
initService
protected abstract void initService() throws CoreException- Throws:
CoreException
-
close
public final void close()
Description copied from interface:ComponentLifecycleCloses the component.A closed component should release any connections it uses, etc. and clean up completely. Throwing a
RuntimeExceptionmay cause unintended consequences- Specified by:
closein interfaceComponentLifecycle
-
closeService
protected abstract void closeService()
-
stop
public void stop()
Description copied from interface:ComponentLifecycleStop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer, calling stop will pause message delivery. Throwing aRuntimeExceptionmay cause unintended consequences- Specified by:
stopin interfaceComponentLifecycle
-
start
public void start() throws CoreExceptionDescription copied from interface:ComponentLifecycleStarts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer, calling start will begin message delivery.- Specified by:
startin interfaceComponentLifecycle- Throws:
CoreException- wrapping any underlyingExceptions
-
createName
public java.lang.String createName()
Description copied from interface:MessageEventGeneratorCreate a name for anyMleMarkerthat is generated.The default implementation is to return the classname of the component in question.
* @return the name for anyMleMarkerthat is generated.- Specified by:
createNamein interfaceMessageEventGenerator
-
createQualifier
public java.lang.String createQualifier()
Description copied from interface:MessageEventGeneratorCreate a qualifier for anyMleMarkerthat is generated.The default implementation is to return the unique-id of the component in question, or the empty string if not configured
- Specified by:
createQualifierin interfaceMessageEventGenerator- Returns:
- the qualifier for any
MleMarkerthat is generated.
-
getUniqueId
public java.lang.String getUniqueId()
Description copied from interface:AdaptrisComponentGet the unique-id that is associated with this component.- Specified by:
getUniqueIdin interfaceAdaptrisComponent- Returns:
- the unique-id
-
setUniqueId
public void setUniqueId(java.lang.String s)
Description copied from interface:ServiceSets the unique identifier for this
Service. These unique identifiers are optional but maybe required by some implementations ofServiceCollection.- Specified by:
setUniqueIdin interfaceService- Parameters:
s- thisService's unique identifier
-
isBranching
public boolean isBranching()
Description copied from interface:ServiceReturns true if the implementation supports branching.
- Specified by:
isBranchingin interfaceService- Returns:
- true if the implementation supports branching
- See Also:
BranchingServiceCollection
-
continueOnFailure
public boolean continueOnFailure()
Description copied from interface:ServiceIf true containers should continue and apply the next configured
Serviceeven if thisServicethrows anException.- Specified by:
continueOnFailurein interfaceService- Returns:
- continueOnFail
-
getContinueOnFail
public java.lang.Boolean getContinueOnFail()
- Returns:
- whether or not this service is configured to continue on failure.
- See Also:
continueOnFailure()
-
setContinueOnFail
public void setContinueOnFail(java.lang.Boolean b)
whether or not this service is configured to continue on failure.- Parameters:
b- true/false, default if not specified is false.
-
getIsTrackingEndpoint
public java.lang.Boolean getIsTrackingEndpoint()
-
setIsTrackingEndpoint
public void setIsTrackingEndpoint(java.lang.Boolean b)
whether or not this service is is a tracking endpoint.- Parameters:
b- true/false, default if not specified is false.
-
isTrackingEndpoint
public boolean isTrackingEndpoint()
Description copied from interface:MessageEventGeneratorReturns true if this should be considered an 'end-point' for tracking purposes, otherwise false.
- Specified by:
isTrackingEndpointin interfaceMessageEventGenerator- Returns:
- true if this should be considered an 'end-point' for tracking purposes, otherwise false
-
changeState
public void changeState(ComponentState newState)
Updates the state for the component
ComponentState.- Specified by:
changeStatein interfaceStateManagedComponent
-
retrieveComponentState
public ComponentState retrieveComponentState()
Returns the last record
ComponentState.- Specified by:
retrieveComponentStatein interfaceStateManagedComponent- Returns:
- the current
ComponentState
-
requestInit
public void requestInit() throws CoreExceptionRequest this component is init'd.
- Specified by:
requestInitin interfaceStateManagedComponent- Throws:
CoreException- wrapping any underlying Exceptions
-
requestStart
public void requestStart() throws CoreExceptionRequest this component is started.
- Specified by:
requestStartin interfaceStateManagedComponent- Throws:
CoreException- wrapping any underlying Exceptions
-
requestStop
public void requestStop()
Request this component is stopped.
- Specified by:
requestStopin interfaceStateManagedComponent
-
requestClose
public void requestClose()
Request this component is closed.
- Specified by:
requestClosein interfaceStateManagedComponent
-
-