示例#1
0
    /**
     * Constructor.
     * @param[in] module The IronBee++ module.
     */
    explicit EngineShutdownModule(IronBee::Module module) :
        IronBee::ModuleDelegate(module),
        m_mode(RUNNING)
    {
        assert(module);

        module.engine().register_hooks()
            .transaction_started(
                boost::bind(
                    &EngineShutdownModule::on_transaction_started,
                    this,
                    _1,
                    _2
                )
            )
            .response_header_data(
                boost::bind(
                    &EngineShutdownModule::on_response_header_data,
                    this,
                    _1,
                    _2,
                    _3,
                    _4
                )
            )
            .connection_opened(
                boost::bind(
                    &EngineShutdownModule::on_connection_opened,
                    this,
                    _1,
                    _2
                )
            )
            .engine_shutdown_initiated(
                boost::bind(
                    &EngineShutdownModule::on_engine_shutdown_initiated,
                    this,
                    _1
                )
            );

            ib_log_info(
                module.engine().ib(),
                "The engine_shutdown module is deprecated. "
                "Use the new graceful_shutdown module instead."
            );
    }
示例#2
0
 void operator()(IronBee::Module module)
 {
     m_out_ib_module  = module.ib();
     m_out_ib_context = NULL;
     test_callback_helper(ExceptionClass());
 }
示例#3
0
Delegate::Delegate(IB::Module module) :
    IB::ModuleDelegate(module),
    m_graph(new P::MergeGraph()),
    m_write_debug_report(false)
{
    assert(module);

    // Call factory.
    P::Standard::load(m_call_factory);

    // Configuration data.
    PerContext base(*this);
    module.set_configuration_data<PerContext>(base);

    // Ownership Function.
    pair<ib_rule_ownership_fn_t, void*> owner =
        IB::make_c_trampoline<
            ib_status_t(
                const ib_engine_t*,
                const ib_rule_t*
            )
        >(bind(&Delegate::ownership, this, _1, _2));
    register_trampoline_data(owner.second);

    IB::throw_if_error(
        ib_rule_register_ownership_fn(
            module.engine().ib(),
            "predicate",
            owner.first, owner.second
        )
    );

    // Injection Functions.
    for (unsigned int i = 0; i < c_num_phases; ++i) {
        ib_rule_phase_num_t phase = c_phases[i];

        pair<ib_rule_injection_fn_t, void*> injection =
            IB::make_c_trampoline<
                ib_status_t(
                    const ib_engine_t*,
                    const ib_rule_exec_t*,
                    ib_list_t*
                )
            >(bind(&Delegate::injection, this, _2, _3));

        register_trampoline_data(injection.second);

        IB::throw_if_error(
            ib_rule_register_injection_fn(
                module.engine().ib(),
                c_module_name,
                phase,
                injection.first, injection.second
            )
        );
    }

    // 'predicate' action.
    pair<ib_action_create_fn_t, void*> action_create =
        IB::make_c_trampoline<
            ib_status_t(
                ib_engine_t*,
                ib_context_t*,
                ib_mpool_t*,
                const char*,
                ib_action_inst_t*
            )
        >(bind(&Delegate::action_create, this, _3, _4, _5));

    register_trampoline_data(action_create.second);

    IB::throw_if_error(
        ib_action_register(
            module.engine().ib(),
            c_predicate_action,
            IB_ACT_FLAG_NONE,
            action_create.first, action_create.second,
            NULL, NULL,
            NULL, NULL
        )
    );

    // Hooks
    module.engine().register_hooks()
        .request_started(
            boost::bind(&Delegate::request_started, this, _2)
        )
        .context_close(
            boost::bind(&Delegate::context_close, this, _2)
        )
        ;

    // Introspection directives.
    module.engine().register_configuration_directives()
        .param1(
            c_assert_valid_directive,
            bind(&Delegate::assert_valid, this, _1, _3)
        )
        .param1(
            c_debug_report_directive,
            bind(&Delegate::debug_report, this, _1, _3)
        )
        ;
}
 Delegate(IronBee::Module m)
 {
     s_delegate_constructed = true;
     s_ib_module = m.ib();
 }