GatewayContext Tag Manager?

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

IgnitionGateway context = IgnitionGateway.get();
    GatewayTagManager tagManager = context.getTagManager();
    TagProvider provider = tagManager.getTagProvider("default");
public class IgnitionGateway extends GatewayContext {
    private GatewayContext context;
    public IgnitionGateway(GatewayContext context) {
        this.context = context;
    }

    public IgnitionGateway get()
    {
        return this;
    }
}

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.

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

So something like this?

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?

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.

2 Likes

Thanks. That works.