summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/qpid/broker/Plugin.h
blob: 8c794b86a0f987d99e5eacee5ad8ae9371c92afa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef QPID_BROKER_PLUGIN_H
#define QPID_BROKER_PLUGIN_H

/*
 *
 * Copyright (c) 2006 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

#include "qpid/Options.h"
#include "qpid/broker/Broker.h"
#include <boost/noncopyable.hpp>
#include <vector>

namespace qpid {
namespace broker {

/**
 * Inherit broker plug-ins from this class, override the virtual
 * functions and create a global (or class static member) instance in
 * a shared library. When the library is loaded your plug-in will be
 * registered.
 */
class Plugin : boost::noncopyable
{
  public:
    /** Constructor registers the plugin to appear in getPlugins().
     * Note: Plugin subclasses should only be constructed during
     * static initialization, i.e. they should only be declared
     * as global or static member variables.
     */
    Plugin();
    
    virtual ~Plugin();

    /**
     * Override if your plugin has configuration options.
     * They will be included in options parsing prior to broker
     * creation setup.
     *@return An options group or 0. Default returns 0.
     */
    virtual Options* getOptions();

    /** Called immediately after broker creation to allow plug-ins
     * to do whatever they do to the broker, e.g. add handler chain
     * manipulators.
     */
    virtual void start(Broker& b);

    /** Called just before broker shutdown. Default does nothing */
    virtual void finish(Broker& b);

    /** Get the list of registered plug-ins. */
    static const std::vector<Plugin*>& getPlugins();

    /** Load a shared library (that contains plugins presumably!) */
    static void dlopen(const std::string& libname);
    
  private:
    static std::vector<Plugin*> plugins;
};
    
}} // namespace qpid::broker




#endif  /*!QPID_BROKER_PLUGIN_H*/