Package io.gridgo.core.impl
Class DefaultGridgoContext
- java.lang.Object
-
- io.gridgo.framework.impl.AbstractComponentLifecycle
-
- io.gridgo.core.impl.DefaultGridgoContext
-
- All Implemented Interfaces:
GridgoContext
,GatewayContainer
,io.gridgo.framework.ComponentLifecycle
,io.gridgo.framework.NamedComponent
,io.gridgo.utils.helper.Loggable
public class DefaultGridgoContext extends io.gridgo.framework.impl.AbstractComponentLifecycle implements GridgoContext
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultGridgoContext(java.lang.String name, io.gridgo.connector.ConnectorFactory connectorFactory, io.gridgo.framework.support.Registry registry, java.util.function.Consumer<java.lang.Throwable> exceptionHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GridgoContext
attachComponent(ContextAwareComponent component)
Attach a io.gridgo.core.support.ContextAwareComponent to this context.java.util.Optional<Gateway>
closeGateway(java.lang.String name)
Close a gateway, stopping it from accepting or sending messages.java.util.Optional<Gateway>
findGateway(java.lang.String name)
Find a gateway by name.protected java.lang.String
generateName()
java.util.List<ContextAwareComponent>
getComponents()
io.gridgo.connector.ConnectorFactory
getConnectorFactory()
java.util.function.Consumer<java.lang.Throwable>
getExceptionHandler()
java.util.Collection<GatewaySubscription>
getGateways()
Get the list of opened gateways.java.util.Optional<GatewaySubscription>
getGatewaySubscription(java.lang.String name)
java.util.Map<java.lang.String,GatewaySubscription>
getGatewaysWithNames()
Get all opened gateways with name.io.gridgo.framework.support.Registry
getRegistry()
protected void
onStart()
protected void
onStop()
GatewaySubscription
openGateway(java.lang.String name, ProducerTemplate producerTemplate)
Open a new gateway with a specific producer template.-
Methods inherited from class io.gridgo.framework.impl.AbstractComponentLifecycle
getName, isStarted, start, stop, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.gridgo.core.support.GatewayContainer
openGateway, openGateway
-
Methods inherited from interface io.gridgo.core.GridgoContext
findGatewayMandatory, startGateway, stopGateway
-
-
-
-
Method Detail
-
openGateway
public GatewaySubscription openGateway(java.lang.String name, ProducerTemplate producerTemplate)
Description copied from interface:GatewayContainer
Open a new gateway with a specific producer template.- Specified by:
openGateway
in interfaceGatewayContainer
- Parameters:
name
- the gateway nameproducerTemplate
- the producer template- Returns:
- the gateway subscription
-
closeGateway
public java.util.Optional<Gateway> closeGateway(java.lang.String name)
Description copied from interface:GatewayContainer
Close a gateway, stopping it from accepting or sending messages.- Specified by:
closeGateway
in interfaceGatewayContainer
- Parameters:
name
- the gateway name to be closed- Returns:
- the closed gateway, wrapped in Optional
-
findGateway
public java.util.Optional<Gateway> findGateway(java.lang.String name)
Description copied from interface:GatewayContainer
Find a gateway by name.- Specified by:
findGateway
in interfaceGatewayContainer
- Parameters:
name
- the gateway name- Returns:
- the gateway, wrapped in Optional
-
onStart
protected void onStart()
- Specified by:
onStart
in classio.gridgo.framework.impl.AbstractComponentLifecycle
-
onStop
protected void onStop()
- Specified by:
onStop
in classio.gridgo.framework.impl.AbstractComponentLifecycle
-
getGateways
public java.util.Collection<GatewaySubscription> getGateways()
Description copied from interface:GatewayContainer
Get the list of opened gateways.- Specified by:
getGateways
in interfaceGatewayContainer
- Returns:
- the list of opened gateways
-
getGatewaysWithNames
public java.util.Map<java.lang.String,GatewaySubscription> getGatewaysWithNames()
Description copied from interface:GatewayContainer
Get all opened gateways with name.- Specified by:
getGatewaysWithNames
in interfaceGatewayContainer
- Returns:
- opened gateways with name
-
getGatewaySubscription
public java.util.Optional<GatewaySubscription> getGatewaySubscription(java.lang.String name)
- Specified by:
getGatewaySubscription
in interfaceGridgoContext
-
attachComponent
public GridgoContext attachComponent(ContextAwareComponent component)
Description copied from interface:GridgoContext
Attach a io.gridgo.core.support.ContextAwareComponent to this context.- Specified by:
attachComponent
in interfaceGridgoContext
- Parameters:
component
- the component to be attached- Returns:
- this context
-
generateName
protected java.lang.String generateName()
- Specified by:
generateName
in classio.gridgo.framework.impl.AbstractComponentLifecycle
-
getConnectorFactory
public io.gridgo.connector.ConnectorFactory getConnectorFactory()
- Specified by:
getConnectorFactory
in interfaceGridgoContext
-
getRegistry
public io.gridgo.framework.support.Registry getRegistry()
- Specified by:
getRegistry
in interfaceGridgoContext
-
getExceptionHandler
public java.util.function.Consumer<java.lang.Throwable> getExceptionHandler()
- Specified by:
getExceptionHandler
in interfaceGridgoContext
-
getComponents
public java.util.List<ContextAwareComponent> getComponents()
- Specified by:
getComponents
in interfaceGridgoContext
-
-