public abstract class AbstractCamelClusterService<T extends CamelClusterView> extends ServiceSupport implements CamelClusterService
CamelClusterService.Selector
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
Modifier | Constructor and Description |
---|---|
protected |
AbstractCamelClusterService() |
protected |
AbstractCamelClusterService(String id) |
protected |
AbstractCamelClusterService(String id,
CamelContext camelContext) |
Modifier and Type | Method and Description |
---|---|
protected abstract T |
createView(String namespace) |
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
Map<String,Object> |
getAttributes()
Attributes associated to the service.
|
CamelContext |
getCamelContext()
Get the
CamelContext |
String |
getId()
Returns the id
|
Collection<String> |
getNamespaces()
Return the namespaces handled by this service.
|
int |
getOrder()
Gets the order.
|
CamelClusterView |
getView(String namespace)
Get a view of the cluster bound to a namespace creating it if needed.
|
boolean |
isLeader(String namespace)
Check if the service is the leader on the given namespace.
|
void |
releaseView(CamelClusterView view)
Release a view if it has no references.
|
void |
setAttribute(String key,
Object value) |
void |
setAttributes(Map<String,Object> attributes) |
void |
setCamelContext(CamelContext camelContext)
Injects the
CamelContext |
void |
setId(String id)
Sets the id
|
void |
setOrder(int order) |
void |
startView(String namespace)
Force start of the view associated to the give namespace.
|
void |
stopView(String namespace)
Force stop of the view associated to the give namespace.
|
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
unwrap
protected AbstractCamelClusterService()
protected AbstractCamelClusterService(String id)
protected AbstractCamelClusterService(String id, CamelContext camelContext)
public int getOrder()
Ordered
Integer.MAX_VALUE
or eg Ordered.LOWEST
.getOrder
in interface CamelClusterService
getOrder
in interface Ordered
public void setOrder(int order)
public void setCamelContext(CamelContext camelContext)
CamelContextAware
CamelContext
setCamelContext
in interface CamelContextAware
camelContext
- the Camel contextpublic CamelContext getCamelContext()
CamelContextAware
CamelContext
getCamelContext
in interface CamelContextAware
public void setAttributes(Map<String,Object> attributes)
public void setAttribute(String key, Object value)
public Map<String,Object> getAttributes()
CamelClusterService
getAttributes
in interface CamelClusterService
protected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.doStart
in class ServiceSupport
Exception
ServiceSupport.doStop()
protected void doStop() throws Exception
ServiceSupport
ServiceSupport.doStop()
method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext
is shutting down.doStop
in class ServiceSupport
Exception
ServiceSupport.doStart()
public CamelClusterView getView(String namespace) throws Exception
CamelClusterService
getView
in interface CamelClusterService
namespace
- the namespace the view refer to.Exception
- if the view can't be created.public void releaseView(CamelClusterView view) throws Exception
CamelClusterService
releaseView
in interface CamelClusterService
view
- the view.Exception
public Collection<String> getNamespaces()
CamelClusterService
getNamespaces
in interface CamelClusterService
public void startView(String namespace) throws Exception
CamelClusterService
startView
in interface CamelClusterService
Exception
public void stopView(String namespace) throws Exception
CamelClusterService
stopView
in interface CamelClusterService
Exception
public boolean isLeader(String namespace)
CamelClusterService
isLeader
in interface CamelClusterService
namespace
- the namespace.protected abstract T createView(String namespace) throws Exception
Exception
Apache Camel