class ObservedContextFactory extends ContextFactory {

    @Override
    protected void observeInstructionCount(Context cx, int instructionCount) {
        final ObservedJavaScriptContext context = (ObservedJavaScriptContext) cx;
        final long timeout = TimeUnit.MILLISECONDS.convert(manager.getConfiguration().getScriptExecutionTimeout(),
                TimeUnit.SECONDS);
        if (timeout > 0 && currentTimeMillis() - context.getStartTime() > timeout) {
            throw new Error("Interrupt.");
        }
    }

    public  ObservedContextFactory(StandardScriptEngineManager manager);

}