# GatewayContext Tag Manager?

**URL:** <https://forum.inductiveautomation.com/t/gatewaycontext-tag-manager/48953>\
**Category:** Module Development\
**Created:** [July 19, 2021, 4:38pm UTC](https://forum.inductiveautomation.com/t/gatewaycontext-tag-manager/48953 "2021-07-19T16:38:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![son122](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@son122](https://forum.inductiveautomation.com/u/son122)\
**Post date:** [July 19, 2021, 4:38pm UTC](https://forum.inductiveautomation.com/t/gatewaycontext-tag-manager/48953/1 "2021-07-19T16:38:40Z")

</div>

I’m having trouble understanding the IgnitionGateway context object. Is this a just a class that is extended from the GatewayContext object?

```auto
IgnitionGateway context = IgnitionGateway.get();
    GatewayTagManager tagManager = context.getTagManager();
    TagProvider provider = tagManager.getTagProvider("default");

```

```auto
public class IgnitionGateway extends GatewayContext {
    private GatewayContext context;
    public IgnitionGateway(GatewayContext context) {
        this.context = context;
    }

    public IgnitionGateway get()
    {
        return this;
    }
}

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 19, 2021, 4:43pm UTC](https://forum.inductiveautomation.com/t/gatewaycontext-tag-manager/48953/2 "2021-07-19T16:43:48Z")

</div>

`IgnitionGateway` is the ‘implementation’ class of `GatewayContext`. It’s a singleton purely for coding convenience - by definition, if you’re running code on the gateway scope, an instance of the gateway is available.  
However, methods that are defined on `IgnitionGateway` but _not_ `GatewayContext` are considered implementation details and should not be used or relied upon. Code against the interface, not the implementation, as the saying goes.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 19, 2021, 4:45pm UTC](https://forum.inductiveautomation.com/t/gatewaycontext-tag-manager/48953/3 "2021-07-19T16:45:28Z")

</div>

> [@paul-griffith](#):
>
> Code against the interface, not the implementation, as the saying goes.

It shouldn't even be possible to code against the implementation because it's not part of the SDK API.

---

<div class="post-metadata">

**Author:** ![son122](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@son122](https://forum.inductiveautomation.com/u/son122)\
**Post date:** [July 19, 2021, 5:40pm UTC](https://forum.inductiveautomation.com/t/gatewaycontext-tag-manager/48953/4 "2021-07-19T17:40:32Z")

</div>

So something like this?

```auto
public abstract class IgnitionGateway implements GatewayContext {
    private static IgnitionGateway instance = null;
    private IgnitionGateway() {
    }
    public static synchronized IgnitionGateway get()
    {
        if (instance == null) {
            instance = new IgnitionGateway() {....};
        }
        return instance;
    }
}

```

From the GatewayHook, how do you initialize the IgnitionGateway object so that it clones the GatewayContext?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 19, 2021, 5:42pm UTC](https://forum.inductiveautomation.com/t/gatewaycontext-tag-manager/48953/5 "2021-07-19T17:42:25Z")

</div>

You _don’t_ implement (or even care about) `IgnitionGateway`. In your module’s `GatewayHook`, the `setup` method will be invoked with a `GatewayContext`. If you need to reuse the gateway context elsewhere in your module, store it in a field and give your other classes access to your hook class.

---

<div class="post-metadata">

**Author:** ![son122](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@son122](https://forum.inductiveautomation.com/u/son122)\
**Post date:** [July 20, 2021, 1:58pm UTC](https://forum.inductiveautomation.com/t/gatewaycontext-tag-manager/48953/6 "2021-07-20T13:58:26Z")

</div>

Thanks. That works.
