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 protectedDefaultGridgoContext(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 GridgoContextattachComponent(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.StringgenerateName()java.util.List<ContextAwareComponent>getComponents()io.gridgo.connector.ConnectorFactorygetConnectorFactory()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.RegistrygetRegistry()protected voidonStart()protected voidonStop()GatewaySubscriptionopenGateway(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:GatewayContainerOpen a new gateway with a specific producer template.- Specified by:
openGatewayin 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:GatewayContainerClose a gateway, stopping it from accepting or sending messages.- Specified by:
closeGatewayin 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:GatewayContainerFind a gateway by name.- Specified by:
findGatewayin interfaceGatewayContainer- Parameters:
name- the gateway name- Returns:
- the gateway, wrapped in Optional
-
onStart
protected void onStart()
- Specified by:
onStartin classio.gridgo.framework.impl.AbstractComponentLifecycle
-
onStop
protected void onStop()
- Specified by:
onStopin classio.gridgo.framework.impl.AbstractComponentLifecycle
-
getGateways
public java.util.Collection<GatewaySubscription> getGateways()
Description copied from interface:GatewayContainerGet the list of opened gateways.- Specified by:
getGatewaysin interfaceGatewayContainer- Returns:
- the list of opened gateways
-
getGatewaysWithNames
public java.util.Map<java.lang.String,GatewaySubscription> getGatewaysWithNames()
Description copied from interface:GatewayContainerGet all opened gateways with name.- Specified by:
getGatewaysWithNamesin interfaceGatewayContainer- Returns:
- opened gateways with name
-
getGatewaySubscription
public java.util.Optional<GatewaySubscription> getGatewaySubscription(java.lang.String name)
- Specified by:
getGatewaySubscriptionin interfaceGridgoContext
-
attachComponent
public GridgoContext attachComponent(ContextAwareComponent component)
Description copied from interface:GridgoContextAttach a io.gridgo.core.support.ContextAwareComponent to this context.- Specified by:
attachComponentin interfaceGridgoContext- Parameters:
component- the component to be attached- Returns:
- this context
-
generateName
protected java.lang.String generateName()
- Specified by:
generateNamein classio.gridgo.framework.impl.AbstractComponentLifecycle
-
getConnectorFactory
public io.gridgo.connector.ConnectorFactory getConnectorFactory()
- Specified by:
getConnectorFactoryin interfaceGridgoContext
-
getRegistry
public io.gridgo.framework.support.Registry getRegistry()
- Specified by:
getRegistryin interfaceGridgoContext
-
getExceptionHandler
public java.util.function.Consumer<java.lang.Throwable> getExceptionHandler()
- Specified by:
getExceptionHandlerin interfaceGridgoContext
-
getComponents
public java.util.List<ContextAwareComponent> getComponents()
- Specified by:
getComponentsin interfaceGridgoContext
-
-