@Override
    protected StateFactory<WindowState> init(ExpressionExecutor[] attributeExpressionExecutors,
                                             ConfigReader configReader, boolean outputExpectsExpiredEvents,
                                             SiddhiQueryContext siddhiQueryContext) {
        if (attributeExpressionExecutors.length >= 1 && attributeExpressionExecutors.length <= 3) {

            if (attributeExpressionExecutors[0] instanceof ConstantExpressionExecutor) {
                if (attributeExpressionExecutors[0].getReturnType() == Attribute.Type.INT ||
                        attributeExpressionExecutors[0].getReturnType() == Attribute.Type.LONG) {
                    sessionGap = (Long) ((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue();
                } else {
                    throw new SiddhiAppValidationException("Session window's session gap parameter should be either "
                            + "int or long, but found " + attributeExpressionExecutors[0].getReturnType());
                }
            } else {
                throw new SiddhiAppValidationException("Session window's 1st parameter, session gap"
                        + " should be a constant parameter attribute but "
                        + "found a dynamic attribute " + attributeExpressionExecutors[0].getClass().getCanonicalName());
            }
            if (attributeExpressionExecutors.length == 3) {
                if (attributeExpressionExecutors[1] instanceof VariableExpressionExecutor) {
                    if (attributeExpressionExecutors[1].getReturnType() == Attribute.Type.STRING) {
                        sessionKeyExecutor = (VariableExpressionExecutor) attributeExpressionExecutors[1];
                    } else {
                        throw new SiddhiAppValidationException("Session window's session key parameter type"
                                + " should be string, but found " + attributeExpressionExecutors[1].getReturnType());
                    }
                } else {
                    throw new SiddhiAppValidationException("Session window's 2nd parameter, session key"
                            + " should be a dynamic parameter attribute but "
                            + "found a constant attribute "
                            + attributeExpressionExecutors[1].getClass().getCanonicalName());
                }

                if (attributeExpressionExecutors[2] instanceof ConstantExpressionExecutor) {
                    if (attributeExpressionExecutors[2].getReturnType() == Attribute.Type.INT ||
                            attributeExpressionExecutors[2].getReturnType() == Attribute.Type.LONG) {
                        allowedLatency = (Long) ((ConstantExpressionExecutor)
                                attributeExpressionExecutors[2]).getValue();
                        validateAllowedLatency(allowedLatency, sessionGap);
                    } else {
                        throw new SiddhiAppValidationException("Session window's allowedLatency parameter should be "
                                + "either int or long, but found " + attributeExpressionExecutors[2].getReturnType());
                    }
                } else {
                    throw new SiddhiAppValidationException("Session window's 3rd parameter, allowedLatency"
                            + " should be a constant parameter attribute but "
                            + "found a dynamic attribute "
                            + attributeExpressionExecutors[2].getClass().getCanonicalName());
                }
            }

            if (attributeExpressionExecutors.length == 2) {
                if (attributeExpressionExecutors[1] instanceof VariableExpressionExecutor) {
                    if (attributeExpressionExecutors[1].getReturnType() == Attribute.Type.STRING) {
                        sessionKeyExecutor = (VariableExpressionExecutor) attributeExpressionExecutors[1];
                    } else {
                        throw new SiddhiAppValidationException("Session window's session key parameter type"
                                + " should be string, but found " + attributeExpressionExecutors[1].getReturnType());
                    }
                } else {
                    if (attributeExpressionExecutors[1].getReturnType() == Attribute.Type.INT ||
                            attributeExpressionExecutors[1].getReturnType() == Attribute.Type.LONG) {
                        allowedLatency = (Long) ((ConstantExpressionExecutor)
                                attributeExpressionExecutors[1]).getValue();
                        validateAllowedLatency(allowedLatency, sessionGap);
                    } else {
                        throw new SiddhiAppValidationException("Session window's allowedLatency parameter should be "
                                + "either int or long, but found " + attributeExpressionExecutors[1].getReturnType());
                    }
                }
            }
        } else {
            throw new SiddhiAppValidationException("Session window should only have one to three parameters "
                    + "(<int|long|time> sessionGap, <String> sessionKey, <int|long|time> allowedLatency, "
                    + "but found " + attributeExpressionExecutors.length + " input attributes");

        }

        return () -> new WindowState();
    }
Implementation of {@link WindowProcessor} which represent a Window operating based on a session.
modules/siddhi-core/src/main/java/io/siddhi/core/query/processor/stream/window/SessionWindowProcessor.java