]> granicus.if.org Git - icinga2/commitdiff
Eliminate the Component class.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 12 Mar 2013 12:45:54 +0000 (13:45 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 12 Mar 2013 12:45:54 +0000 (13:45 +0100)
Fixes #3832
Fixes #3840

61 files changed:
Makefile.am
components/checker/.gitignore [new file with mode: 0644]
components/checker/Makefile.am
components/checker/checker-type.conf [new file with mode: 0644]
components/checker/checkercomponent.cpp
components/checker/checkercomponent.h
components/compat/.gitignore [new file with mode: 0644]
components/compat/Makefile.am
components/compat/compat-type.conf [new file with mode: 0644]
components/compat/compatcomponent.cpp
components/compat/compatcomponent.h
components/delegation/.gitignore [new file with mode: 0644]
components/delegation/Makefile.am
components/delegation/delegation-type.conf [new file with mode: 0644]
components/delegation/delegationcomponent.cpp
components/delegation/delegationcomponent.h
components/demo/.gitignore [new file with mode: 0644]
components/demo/Makefile.am
components/demo/demo-type.conf [new file with mode: 0644]
components/demo/democomponent.cpp
components/demo/democomponent.h
components/livestatus/.gitignore [new file with mode: 0644]
components/livestatus/Makefile.am
components/livestatus/component.cpp
components/livestatus/component.h
components/livestatus/livestatus-type.conf [new file with mode: 0644]
components/notification/.gitignore [new file with mode: 0644]
components/notification/Makefile.am
components/notification/notification-type.conf [new file with mode: 0644]
components/notification/notificationcomponent.cpp
components/notification/notificationcomponent.h
components/replication/.gitignore [new file with mode: 0644]
components/replication/Makefile.am
components/replication/replication-type.conf [new file with mode: 0644]
components/replication/replicationcomponent.cpp
components/replication/replicationcomponent.h
configure.ac
icinga-app/Makefile.am
icinga-app/icinga.cpp
itl/Makefile.am
itl/itl.conf
itl/standalone.conf
lib/base/Makefile.am
lib/base/component.cpp [deleted file]
lib/base/component.h [deleted file]
lib/base/dynamictype.h
lib/base/i2-base.h
lib/base/scriptfunction.h
lib/base/utility.cpp
lib/base/utility.h
lib/config/.gitignore [new file with mode: 0644]
lib/config/Makefile.am
lib/config/base-type.conf [new file with mode: 0644]
lib/config/configcompiler.cpp
lib/config/configcompiler.h
lib/icinga/.gitignore [new file with mode: 0644]
lib/icinga/Makefile.am
lib/icinga/icinga-type.conf [moved from itl/types.conf with 91% similarity]
lib/remoting/.gitignore [new file with mode: 0644]
lib/remoting/Makefile.am
lib/remoting/remoting-type.conf [new file with mode: 0644]

index 9a1554db61203c0fd63d0dc7b8989dedd136ae6d..ca8dc863cfee0aad618f860ba4d04dc2d88e4c63 100644 (file)
@@ -5,6 +5,7 @@ include aminclude.am
 
 SUBDIRS = \
        third-party \
+       tools \
        lib \
        components \
        icinga-app \
diff --git a/components/checker/.gitignore b/components/checker/.gitignore
new file mode 100644 (file)
index 0000000..786efde
--- /dev/null
@@ -0,0 +1 @@
+checker-type.cpp
index 3b8ff6c8536480de26a2d2ea597cdf3f1377b087..e4e00dc278561017ab63b16398440eed5d2169be 100644 (file)
@@ -1,28 +1,35 @@
 ## Process this file with automake to produce Makefile.in
 
 pkglib_LTLIBRARIES = \
-       checker.la
+       libchecker.la
 
-checker_la_SOURCES = \
+EXTRA_DIST = \
+       checker-type.conf
+
+.conf.cpp:
+       $(top_builddir)/tools/mkembedconfig $< $@
+
+libchecker_la_SOURCES = \
        checkercomponent.cpp \
        checkercomponent.h \
+       checker-type.cpp \
        i2-checker.h
 
-checker_la_CPPFLAGS = \
+libchecker_la_CPPFLAGS = \
        $(BOOST_CPPFLAGS) \
        -I${top_srcdir}/lib/base \
        -I${top_srcdir}/lib/config \
        -I${top_srcdir}/lib/remoting \
        -I${top_srcdir}/lib/icinga
 
-checker_la_LDFLAGS = \
+libchecker_la_LDFLAGS = \
        $(BOOST_LDFLAGS) \
        -module \
        -no-undefined \
        @RELEASE_INFO@ \
        @VERSION_INFO@
 
-checker_la_LIBADD = \
+libchecker_la_LIBADD = \
        $(BOOST_SIGNALS_LIB) \
        $(BOOST_THREAD_LIB) \
        ${top_builddir}/lib/base/libbase.la \
diff --git a/components/checker/checker-type.conf b/components/checker/checker-type.conf
new file mode 100644 (file)
index 0000000..095492e
--- /dev/null
@@ -0,0 +1,21 @@
+/******************************************************************************
+ * Icinga 2                                                                   *
+ * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
+ *                                                                            *
+ * This program is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU General Public License                *
+ * as published by the Free Software Foundation; either version 2             *
+ * of the License, or (at your option) any later version.                     *
+ *                                                                            *
+ * This program is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
+ * GNU General Public License for more details.                               *
+ *                                                                            *
+ * You should have received a copy of the GNU General Public License          *
+ * along with this program; if not, write to the Free Software Foundation     *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
+ ******************************************************************************/
+
+type CheckerComponent {
+}
index 8a91394926e0d26a616729e6d71582f385d499a9..f35fcca44d031a620cd610ac2e7ede1212e24225 100644 (file)
 
 using namespace icinga;
 
-REGISTER_COMPONENT("checker", CheckerComponent);
+REGISTER_TYPE(CheckerComponent);
+
+CheckerComponent::CheckerComponent(const Dictionary::Ptr& serializedUpdate)
+       : DynamicObject(serializedUpdate)
+{ }
 
 void CheckerComponent::Start(void)
 {
index da38e84c90009b85d65928d3f2f5cae493f24e6c..f93d4f343ddf552a82fd83242738e3e353b46439 100644 (file)
@@ -49,7 +49,7 @@ struct ServiceNextCheckExtractor
 /**
  * @ingroup checker
  */
-class CheckerComponent : public IComponent
+class CheckerComponent : public DynamicObject
 {
 public:
        typedef shared_ptr<CheckerComponent> Ptr;
@@ -63,6 +63,8 @@ public:
                >
        > ServiceSet;
 
+       CheckerComponent(const Dictionary::Ptr& serializedUpdate);
+
        virtual void Start(void);
        virtual void Stop(void);
 
diff --git a/components/compat/.gitignore b/components/compat/.gitignore
new file mode 100644 (file)
index 0000000..a3c1584
--- /dev/null
@@ -0,0 +1 @@
+compat-type.cpp
index 830d100de32d2cf3e8d24528a60a2234f2564029..8896fde1bc3090ba9ce2e4a0a25533499d94cb5b 100644 (file)
@@ -1,28 +1,35 @@
 ## Process this file with automake to produce Makefile.in
 
 pkglib_LTLIBRARIES = \
-       compat.la
+       libcompat.la
 
-compat_la_SOURCES = \
+EXTRA_DIST = \
+       compat-type.conf
+
+.conf.cpp:
+       $(top_builddir)/tools/mkembedconfig $< $@
+
+libcompat_la_SOURCES = \
        compatcomponent.cpp \
        compatcomponent.h \
+       compat-type.cpp \
        i2-compat.h
 
-compat_la_CPPFLAGS = \
+libcompat_la_CPPFLAGS = \
        $(BOOST_CPPFLAGS) \
        -I${top_srcdir}/lib/base \
        -I${top_srcdir}/lib/config \
        -I${top_srcdir}/lib/remoting \
        -I${top_srcdir}/lib/icinga
 
-compat_la_LDFLAGS = \
+libcompat_la_LDFLAGS = \
        $(BOOST_LDFLAGS) \
        -module \
        -no-undefined \
        @RELEASE_INFO@ \
        @VERSION_INFO@
 
-compat_la_LIBADD = \
+libcompat_la_LIBADD = \
        $(BOOST_SIGNALS_LIB) \
        $(BOOST_THREAD_LIB) \
        ${top_builddir}/lib/base/libbase.la \
diff --git a/components/compat/compat-type.conf b/components/compat/compat-type.conf
new file mode 100644 (file)
index 0000000..56e1fd8
--- /dev/null
@@ -0,0 +1,25 @@
+/******************************************************************************
+ * Icinga 2                                                                   *
+ * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
+ *                                                                            *
+ * This program is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU General Public License                *
+ * as published by the Free Software Foundation; either version 2             *
+ * of the License, or (at your option) any later version.                     *
+ *                                                                            *
+ * This program is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
+ * GNU General Public License for more details.                               *
+ *                                                                            *
+ * You should have received a copy of the GNU General Public License          *
+ * along with this program; if not, write to the Free Software Foundation     *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
+ ******************************************************************************/
+
+type CompatComponent {
+       %attribute string "status_path",
+       %attribute string "objects_path",
+       %attribute string "log_path",
+       %attribute string "command_path"
+}
index c5e3f24f61407dbdd38312d9c5639772465c9568..7c06d63152540c5994546cf25f18f4b3c74fec37 100644 (file)
@@ -21,7 +21,7 @@
 
 using namespace icinga;
 
-REGISTER_COMPONENT("compat", CompatComponent);
+REGISTER_TYPE(CompatComponent);
 
 /**
  * Hint: The reason why we're using "\n" rather than std::endl is because
@@ -29,6 +29,23 @@ REGISTER_COMPONENT("compat", CompatComponent);
  * performance (see http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html).
  */
 
+/**
+ * Starts the component.
+ */
+void CompatComponent::Start(void)
+{
+       m_StatusTimer = boost::make_shared<Timer>();
+       m_StatusTimer->SetInterval(15);
+       m_StatusTimer->OnTimerExpired.connect(boost::bind(&CompatComponent::StatusTimerHandler, this));
+       m_StatusTimer->Start();
+       m_StatusTimer->Reschedule(0);
+
+#ifndef _WIN32
+       m_CommandThread = thread(boost::bind(&CompatComponent::CommandPipeThread, this, GetCommandPath()));
+       m_CommandThread.detach();
+#endif /* _WIN32 */
+}
+
 /**
  * Retrieves the status.dat path.
  *
@@ -36,9 +53,7 @@ REGISTER_COMPONENT("compat", CompatComponent);
  */
 String CompatComponent::GetStatusPath(void) const
 {
-       DynamicObject::Ptr config = GetConfig();
-
-       Value statusPath = config->Get("status_path");
+       Value statusPath = m_StatusPath;
        if (statusPath.IsEmpty())
                return Application::GetLocalStateDir() + "/cache/icinga2/status.dat";
        else
@@ -52,9 +67,7 @@ String CompatComponent::GetStatusPath(void) const
  */
 String CompatComponent::GetObjectsPath(void) const
 {
-       DynamicObject::Ptr config = GetConfig();
-
-       Value objectsPath = config->Get("objects_path");
+       Value objectsPath = m_ObjectsPath;
        if (objectsPath.IsEmpty())
                return Application::GetLocalStateDir() + "/cache/icinga2/objects.cache";
        else
@@ -68,9 +81,7 @@ String CompatComponent::GetObjectsPath(void) const
  */
 String CompatComponent::GetLogPath(void) const
 {
-       DynamicObject::Ptr config = GetConfig();
-
-       Value logPath = config->Get("log_path");
+       Value logPath = m_LogPath;
        if (logPath.IsEmpty())
                return Application::GetLocalStateDir() + "/log/icinga2/compat";
        else
@@ -84,37 +95,20 @@ String CompatComponent::GetLogPath(void) const
  */
 String CompatComponent::GetCommandPath(void) const
 {
-       DynamicObject::Ptr config = GetConfig();
-
-       Value commandPath = config->Get("command_path");
+       Value commandPath = m_CommandPath;
        if (commandPath.IsEmpty())
                return Application::GetLocalStateDir() + "/run/icinga2/icinga2.cmd";
        else
                return commandPath;
 }
 
-/**
- * Starts the component.
- */
-void CompatComponent::Start(void)
-{
-       m_StatusTimer = boost::make_shared<Timer>();
-       m_StatusTimer->SetInterval(15);
-       m_StatusTimer->OnTimerExpired.connect(boost::bind(&CompatComponent::StatusTimerHandler, this));
-       m_StatusTimer->Start();
-       m_StatusTimer->Reschedule(0);
-
-#ifndef _WIN32
-       m_CommandThread = thread(boost::bind(&CompatComponent::CommandPipeThread, this, GetCommandPath()));
-       m_CommandThread.detach();
-#endif /* _WIN32 */
-}
-
-/**
- * Stops the component.
- */
-void CompatComponent::Stop(void)
+CompatComponent::CompatComponent(const Dictionary::Ptr& serializedUpdate)
+       : DynamicObject(serializedUpdate)
 {
+       RegisterAttribute("status_path", Attribute_Config, &m_StatusPath);
+       RegisterAttribute("objects_path", Attribute_Config, &m_ObjectsPath);
+       RegisterAttribute("log_path", Attribute_Config, &m_LogPath);
+       RegisterAttribute("command_path", Attribute_Config, &m_CommandPath);
 }
 
 #ifndef _WIN32
index 3c9e1a9e0c5ecfa645eec25436dc9436fa164650..4da7e826fbd4a652e5f48aaae12ab0748daad93b 100644 (file)
@@ -32,13 +32,19 @@ enum CompatObjectType
 /**
  * @ingroup compat
  */
-class CompatComponent : public IComponent
+class CompatComponent : public DynamicObject
 {
 public:
+       CompatComponent(const Dictionary::Ptr& serializedUpdate);
+
        virtual void Start(void);
-       virtual void Stop(void);
 
 private:
+       Attribute<String> m_StatusPath;
+       Attribute<String> m_ObjectsPath;
+       Attribute<String> m_LogPath;
+       Attribute<String> m_CommandPath;
+
 #ifndef _WIN32
        thread m_CommandThread;
 
diff --git a/components/delegation/.gitignore b/components/delegation/.gitignore
new file mode 100644 (file)
index 0000000..90edee3
--- /dev/null
@@ -0,0 +1 @@
+delegation-type.cpp
index 9411e0e93b75e8a9409c6a2a6d151464b6049453..c51c691905a4bfb2bde3f0fd46abf4cec82d17a6 100644 (file)
@@ -1,28 +1,35 @@
 ## Process this file with automake to produce Makefile.in
 
 pkglib_LTLIBRARIES = \
-       delegation.la
+       libdelegation.la
 
-delegation_la_SOURCES = \
+EXTRA_DIST = \
+       delegation-type.conf
+
+.conf.cpp:
+       $(top_builddir)/tools/mkembedconfig $< $@
+
+libdelegation_la_SOURCES = \
        delegationcomponent.cpp \
        delegationcomponent.h \
+       delegation-type.cpp \
        i2-delegation.h
 
-delegation_la_CPPFLAGS = \
+libdelegation_la_CPPFLAGS = \
        $(BOOST_CPPFLAGS) \
        -I${top_srcdir}/lib/base \
        -I${top_srcdir}/lib/config \
        -I${top_srcdir}/lib/remoting \
        -I${top_srcdir}/lib/icinga
 
-delegation_la_LDFLAGS = \
+libdelegation_la_LDFLAGS = \
        $(BOOST_LDFLAGS) \
        -module \
        -no-undefined \
        @RELEASE_INFO@ \
        @VERSION_INFO@
 
-delegation_la_LIBADD = \
+libdelegation_la_LIBADD = \
        $(BOOST_SIGNALS_LIB) \
        $(BOOST_THREAD_LIB) \
        ${top_builddir}/lib/base/libbase.la \
diff --git a/components/delegation/delegation-type.conf b/components/delegation/delegation-type.conf
new file mode 100644 (file)
index 0000000..bd9df37
--- /dev/null
@@ -0,0 +1,21 @@
+/******************************************************************************
+ * Icinga 2                                                                   *
+ * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
+ *                                                                            *
+ * This program is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU General Public License                *
+ * as published by the Free Software Foundation; either version 2             *
+ * of the License, or (at your option) any later version.                     *
+ *                                                                            *
+ * This program is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
+ * GNU General Public License for more details.                               *
+ *                                                                            *
+ * You should have received a copy of the GNU General Public License          *
+ * along with this program; if not, write to the Free Software Foundation     *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
+ ******************************************************************************/
+
+type DelegationComponent {
+}
index 1b5fd1792c851a76981db4ff1490617181993ea9..f7d51db74913d2770b3ecb0cc7d45e4dce27d9ad 100644 (file)
 
 using namespace icinga;
 
-REGISTER_COMPONENT("delegation", DelegationComponent);
+REGISTER_TYPE(DelegationComponent);
+
+DelegationComponent::DelegationComponent(const Dictionary::Ptr& serializedUpdate)
+       : DynamicObject(serializedUpdate)
+{ }
 
 void DelegationComponent::Start(void)
 {
        m_DelegationTimer = boost::make_shared<Timer>();
 
-       // TODO: implement a handler for config changes for the delegation_interval variable
        m_DelegationTimer->SetInterval(30);
        m_DelegationTimer->OnTimerExpired.connect(boost::bind(&DelegationComponent::DelegationTimerHandler, this));
        m_DelegationTimer->Start();
index c42556df5a836eb99b8d12cc9092400e8c8ce1ec..2bbf9fa72790b141e226c57f7c1d04da3aedc939 100644 (file)
@@ -26,9 +26,11 @@ namespace icinga
 /**
  * @ingroup delegation
  */
-class DelegationComponent : public IComponent
+class DelegationComponent : public DynamicObject
 {
 public:
+       DelegationComponent(const Dictionary::Ptr& serializedUpdate);
+
        virtual void Start(void);
 
 private:
diff --git a/components/demo/.gitignore b/components/demo/.gitignore
new file mode 100644 (file)
index 0000000..a8e7da8
--- /dev/null
@@ -0,0 +1 @@
+demo-type.cpp
index aaba36d16f2b741e6ecc4bee50e5f98cd839b058..3b5d6593f0d00a92f62138b0903a170f09f5f066 100644 (file)
@@ -1,28 +1,35 @@
 ## Process this file with automake to produce Makefile.in
 
 pkglib_LTLIBRARIES = \
-       demo.la
+       libdemo.la
 
-demo_la_SOURCES = \
+EXTRA_DIST = \
+       demo-type.conf
+
+.conf.cpp:
+       $(top_builddir)/tools/mkembedconfig $< $@
+
+libdemo_la_SOURCES = \
        democomponent.cpp \
        democomponent.h \
+       demo-type.cpp \
        i2-demo.h
 
-demo_la_CPPFLAGS = \
+libdemo_la_CPPFLAGS = \
        $(BOOST_CPPFLAGS) \
        -I${top_srcdir}/lib/base \
        -I${top_srcdir}/lib/config \
        -I${top_srcdir}/lib/remoting \
        -I${top_srcdir}/lib/icinga
 
-demo_la_LDFLAGS = \
+libdemo_la_LDFLAGS = \
        $(BOOST_LDFLAGS) \
        -module \
        -no-undefined \
        @RELEASE_INFO@ \
        @VERSION_INFO@
 
-demo_la_LIBADD = \
+libdemo_la_LIBADD = \
        $(BOOST_SIGNALS_LIB) \
        $(BOOST_THREAD_LIB) \
        ${top_builddir}/lib/base/libbase.la \
diff --git a/components/demo/demo-type.conf b/components/demo/demo-type.conf
new file mode 100644 (file)
index 0000000..3704d1f
--- /dev/null
@@ -0,0 +1,21 @@
+/******************************************************************************
+ * Icinga 2                                                                   *
+ * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
+ *                                                                            *
+ * This program is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU General Public License                *
+ * as published by the Free Software Foundation; either version 2             *
+ * of the License, or (at your option) any later version.                     *
+ *                                                                            *
+ * This program is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
+ * GNU General Public License for more details.                               *
+ *                                                                            *
+ * You should have received a copy of the GNU General Public License          *
+ * along with this program; if not, write to the Free Software Foundation     *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
+ ******************************************************************************/
+
+type DemoComponent {
+}
index a974f832f1f469aaec3c5b2bf189b2c4aaf79b4c..d9f7dbf270963a2a60a7c8ce8417f6a9bd40a530 100644 (file)
 
 using namespace icinga;
 
-REGISTER_COMPONENT("demo", DemoComponent);
+REGISTER_TYPE(DemoComponent);
+
+DemoComponent::DemoComponent(const Dictionary::Ptr& serializedUpdate)
+       : DynamicObject(serializedUpdate)
+{ }
 
 /**
  * Starts the component.
index 181c8ae09bcf4afec873dde5ee145b34c71a2fca..c832ba9bd2bb86ba1a80bbc6da79899a19cb3dac 100644 (file)
@@ -26,9 +26,11 @@ namespace icinga
 /**
  * @ingroup demo
  */
-class DemoComponent : public IComponent
+class DemoComponent : public DynamicObject
 {
 public:
+       DemoComponent(const Dictionary::Ptr& serializedUpdate);
+
        virtual void Start(void);
        virtual void Stop(void);
 
diff --git a/components/livestatus/.gitignore b/components/livestatus/.gitignore
new file mode 100644 (file)
index 0000000..8068456
--- /dev/null
@@ -0,0 +1 @@
+livestatus-type.cpp
index c8917c11cd406cec036a5fdb8754aff24c0148d7..a94b098ee80d0922be80746f1e8c358e8785fea5 100644 (file)
@@ -1,9 +1,15 @@
 ## Process this file with automake to produce Makefile.in
 
 pkglib_LTLIBRARIES = \
-       livestatus.la
+       liblivestatus.la
 
-livestatus_la_SOURCES = \
+EXTRA_DIST = \
+       livestatus-type.conf
+
+.conf.cpp:
+       $(top_builddir)/tools/mkembedconfig $< $@
+
+liblivestatus_la_SOURCES = \
        attributefilter.cpp \
        attributefilter.h \
        andfilter.cpp \
@@ -28,6 +34,7 @@ livestatus_la_SOURCES = \
        filter.h \
        hoststable.cpp \
        hoststable.h \
+       livestatus-type.cpp \
        negatefilter.cpp \
        negatefilter.h \
        orfilter.cpp \
@@ -42,21 +49,21 @@ livestatus_la_SOURCES = \
        table.h \
        i2-livestatus.h
 
-livestatus_la_CPPFLAGS = \
+liblivestatus_la_CPPFLAGS = \
        $(BOOST_CPPFLAGS) \
        -I${top_srcdir}/lib/base \
        -I${top_srcdir}/lib/config \
        -I${top_srcdir}/lib/remoting \
        -I${top_srcdir}/lib/icinga
 
-livestatus_la_LDFLAGS = \
+liblivestatus_la_LDFLAGS = \
        $(BOOST_LDFLAGS) \
        -module \
        -no-undefined \
        @RELEASE_INFO@ \
        @VERSION_INFO@
 
-livestatus_la_LIBADD = \
+liblivestatus_la_LIBADD = \
        $(BOOST_SIGNALS_LIB) \
        $(BOOST_THREAD_LIB) \
        ${top_builddir}/lib/base/libbase.la \
index 83c164833e583f316f0244b17b7e0c7d2680444c..b08a08ea859b128edcc94b6067d9ae48737b012a 100644 (file)
 using namespace icinga;
 using namespace livestatus;
 
-REGISTER_COMPONENT("livestatus", LivestatusComponent);
+REGISTER_TYPE(LivestatusComponent);
+
+LivestatusComponent::LivestatusComponent(const Dictionary::Ptr& serializedUpdate)
+       : DynamicObject(serializedUpdate)
+{
+       RegisterAttribute("socket_path", Attribute_Config, &m_SocketPath);
+}
 
 /**
  * Starts the component.
@@ -43,18 +49,9 @@ void LivestatusComponent::Start(void)
        m_Listener = socket;
 }
 
-/**
- * Stops the component.
- */
-void LivestatusComponent::Stop(void)
-{
-}
-
 String LivestatusComponent::GetSocketPath(void) const
 {
-       DynamicObject::Ptr config = GetConfig();
-
-       Value socketPath = config->Get("socket_path");
+       Value socketPath = m_SocketPath;
        if (socketPath.IsEmpty())
                return Application::GetLocalStateDir() + "/run/icinga2/livestatus";
        else
index 5a1aec7842f0e3bc64950b934009eb71dbf01838..c00f7b6d3475f82f5f013249ba47cf133cb2026d 100644 (file)
@@ -26,15 +26,18 @@ namespace livestatus
 /**
  * @ingroup livestatus
  */
-class LivestatusComponent : public IComponent
+class LivestatusComponent : public DynamicObject
 {
 public:
+       LivestatusComponent(const Dictionary::Ptr& serializedUpdate);
+
        virtual void Start(void);
-       virtual void Stop(void);
 
        String GetSocketPath(void) const;
 
 private:
+       Attribute<String> m_SocketPath;
+
        Socket::Ptr m_Listener;
        set<LivestatusConnection::Ptr> m_Connections;
 
diff --git a/components/livestatus/livestatus-type.conf b/components/livestatus/livestatus-type.conf
new file mode 100644 (file)
index 0000000..966237c
--- /dev/null
@@ -0,0 +1,21 @@
+/******************************************************************************
+ * Icinga 2                                                                   *
+ * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
+ *                                                                            *
+ * This program is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU General Public License                *
+ * as published by the Free Software Foundation; either version 2             *
+ * of the License, or (at your option) any later version.                     *
+ *                                                                            *
+ * This program is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
+ * GNU General Public License for more details.                               *
+ *                                                                            *
+ * You should have received a copy of the GNU General Public License          *
+ * along with this program; if not, write to the Free Software Foundation     *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
+ ******************************************************************************/
+
+type LivestatusComponent {
+}
diff --git a/components/notification/.gitignore b/components/notification/.gitignore
new file mode 100644 (file)
index 0000000..bfe7cd0
--- /dev/null
@@ -0,0 +1 @@
+notification-type.cpp
index 25f1929d34ca1a5866fc72629cf9cd8c6f21749e..1e10da562ecee27e419b8f68a9bb268c42377d76 100644 (file)
@@ -1,28 +1,35 @@
 ## Process this file with automake to produce Makefile.in
 
 pkglib_LTLIBRARIES = \
-       notification.la
+       libnotification.la
 
-notification_la_SOURCES = \
+EXTRA_DIST = \
+       notification-type.conf
+
+.conf.cpp:
+       $(top_builddir)/tools/mkembedconfig $< $@
+
+libnotification_la_SOURCES = \
        notificationcomponent.cpp \
        notificationcomponent.h \
+       notification-type.cpp \
        i2-notification.h
 
-notification_la_CPPFLAGS = \
+libnotification_la_CPPFLAGS = \
        $(BOOST_CPPFLAGS) \
        -I${top_srcdir}/lib/base \
        -I${top_srcdir}/lib/config \
        -I${top_srcdir}/lib/remoting \
        -I${top_srcdir}/lib/icinga
 
-notification_la_LDFLAGS = \
+libnotification_la_LDFLAGS = \
        $(BOOST_LDFLAGS) \
        -module \
        -no-undefined \
        @RELEASE_INFO@ \
        @VERSION_INFO@
 
-notification_la_LIBADD = \
+libnotification_la_LIBADD = \
        $(BOOST_SIGNALS_LIB) \
        $(BOOST_THREAD_LIB) \
        ${top_builddir}/lib/base/libbase.la \
diff --git a/components/notification/notification-type.conf b/components/notification/notification-type.conf
new file mode 100644 (file)
index 0000000..7b9c055
--- /dev/null
@@ -0,0 +1,21 @@
+/******************************************************************************
+ * Icinga 2                                                                   *
+ * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
+ *                                                                            *
+ * This program is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU General Public License                *
+ * as published by the Free Software Foundation; either version 2             *
+ * of the License, or (at your option) any later version.                     *
+ *                                                                            *
+ * This program is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
+ * GNU General Public License for more details.                               *
+ *                                                                            *
+ * You should have received a copy of the GNU General Public License          *
+ * along with this program; if not, write to the Free Software Foundation     *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
+ ******************************************************************************/
+
+type NotificationComponent {
+}
index a777cb6004ffb13cc0306a9f2e75b1bf8ff08316..da823f3d3d8d7b55276d80e7682a307125ba7b56 100644 (file)
 
 using namespace icinga;
 
-REGISTER_COMPONENT("notification", NotificationComponent);
+REGISTER_TYPE(NotificationComponent);
+
+NotificationComponent::NotificationComponent(const Dictionary::Ptr& serializedUpdate)
+       : DynamicObject(serializedUpdate)
+{ }
 
 /**
  * Starts the component.
index c40cd8ac10a3912518d7bb837cb176fc70a17b37..0703ad3f8939f31b8412f8e4cdbd32cbb69a003f 100644 (file)
@@ -26,9 +26,11 @@ namespace icinga
 /**
  * @ingroup notification
  */
-class NotificationComponent : public IComponent
+class NotificationComponent : public DynamicObject
 {
 public:
+       NotificationComponent(const Dictionary::Ptr& serializedUpdate);
+
        virtual void Start(void);
        virtual void Stop(void);
 
diff --git a/components/replication/.gitignore b/components/replication/.gitignore
new file mode 100644 (file)
index 0000000..90c7869
--- /dev/null
@@ -0,0 +1 @@
+replication-type.cpp
index 83c09fbaeb924a496b6df93e00c3af1e12ab58e8..b1eab152d76eeb9056188c695c6a21e424644201 100644 (file)
@@ -1,28 +1,35 @@
 ## Process this file with automake to produce Makefile.in
 
 pkglib_LTLIBRARIES = \
-       replication.la
+       libreplication.la
 
-replication_la_SOURCES = \
+EXTRA_DIST = \
+       replication-type.conf
+
+.conf.cpp:
+       $(top_builddir)/tools/mkembedconfig $< $@
+
+libreplication_la_SOURCES = \
        replicationcomponent.cpp \
        replicationcomponent.h \
+       replication-type.cpp \
        i2-replication.h
 
-replication_la_CPPFLAGS = \
+libreplication_la_CPPFLAGS = \
        $(BOOST_CPPFLAGS) \
        -I${top_srcdir}/lib/base \
        -I${top_srcdir}/lib/config \
        -I${top_srcdir}/lib/remoting \
        -I${top_srcdir}/lib/icinga
 
-replication_la_LDFLAGS = \
+libreplication_la_LDFLAGS = \
        $(BOOST_LDFLAGS) \
        -module \
        -no-undefined \
        @RELEASE_INFO@ \
        @VERSION_INFO@
 
-replication_la_LIBADD = \
+libreplication_la_LIBADD = \
        $(BOOST_SIGNALS_LIB) \
        $(BOOST_THREAD_LIB) \
        ${top_builddir}/lib/base/libbase.la \
diff --git a/components/replication/replication-type.conf b/components/replication/replication-type.conf
new file mode 100644 (file)
index 0000000..559acfd
--- /dev/null
@@ -0,0 +1,21 @@
+/******************************************************************************
+ * Icinga 2                                                                   *
+ * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
+ *                                                                            *
+ * This program is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU General Public License                *
+ * as published by the Free Software Foundation; either version 2             *
+ * of the License, or (at your option) any later version.                     *
+ *                                                                            *
+ * This program is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
+ * GNU General Public License for more details.                               *
+ *                                                                            *
+ * You should have received a copy of the GNU General Public License          *
+ * along with this program; if not, write to the Free Software Foundation     *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
+ ******************************************************************************/
+
+type ReplicationComponent {
+}
index 70dd403e46c7b6af3f2baf5ec86757abe1f1e181..060d221760d06b7983b3f3c2abad3d5bb26e59e2 100644 (file)
 
 using namespace icinga;
 
-REGISTER_COMPONENT("replication", ReplicationComponent);
+REGISTER_TYPE(ReplicationComponent);
+
+ReplicationComponent::ReplicationComponent(const Dictionary::Ptr& serializedUpdate)
+       : DynamicObject(serializedUpdate)
+{ }
 
 /**
  * Starts the component.
index 08557c2d8b6ccff72ec19e7d716a79d2ece551f0..3ac10d9b9c145bfbfeb24b0e7a9165ee15de4919 100644 (file)
@@ -26,9 +26,11 @@ namespace icinga
 /**
  * @ingroup replication
  */
-class ReplicationComponent : public IComponent
+class ReplicationComponent : public DynamicObject
 {
 public:
+       ReplicationComponent(const Dictionary::Ptr& serializedUpdate);
+
        virtual void Start(void);
        virtual void Stop(void);
 
index 89319389a5a2e6a7a0ad6490c9936475ce35e769..e8cab61db1aba885169e4a9f32b558dc9334e3c0 100644 (file)
@@ -131,6 +131,7 @@ third-party/cJSON/Makefile
 third-party/execvpe/Makefile
 third-party/mmatch/Makefile
 third-party/popen-noshell/Makefile
+tools/Makefile
 ])
 AC_OUTPUT([
 etc/init.d/icinga2
index c96be3935223e3cb9928d3e0b3875c9206ccc640..5ab2c55be5b42f724476bfbe6f04119aeea76c0c 100644 (file)
@@ -29,12 +29,12 @@ icinga2_LDADD = \
        ${top_builddir}/lib/base/libbase.la \
        ${top_builddir}/lib/config/libconfig.la \
        -dlopen ${top_builddir}/lib/icinga/libicinga.la \
-       -dlopen ${top_builddir}/components/checker/checker.la \
-       -dlopen ${top_builddir}/components/replication/replication.la \
-       -dlopen ${top_builddir}/components/compat/compat.la \
-       -dlopen ${top_builddir}/components/delegation/delegation.la \
-       -dlopen ${top_builddir}/components/demo/demo.la \
-       -dlopen ${top_builddir}/components/notification/notification.la
+       -dlopen ${top_builddir}/components/checker/libchecker.la \
+       -dlopen ${top_builddir}/components/replication/libreplication.la \
+       -dlopen ${top_builddir}/components/compat/libcompat.la \
+       -dlopen ${top_builddir}/components/delegation/libdelegation.la \
+       -dlopen ${top_builddir}/components/demo/libdemo.la \
+       -dlopen ${top_builddir}/components/notification/libnotification.la
 
 if PYTHON_USE
 icinga2_LDADD += \
index c10b03811bd05ce144f07f430907b4865a52d383..af5c566fc559a7ad7f1f1943860e8937425ce628 100644 (file)
@@ -48,6 +48,11 @@ static bool LoadConfigFiles(bool validateOnly)
                ConfigCompiler::CompileFile(configPath);
        }
 
+       String name, fragment;
+       BOOST_FOREACH(tie(name, fragment), ConfigCompiler::GetConfigFragments()) {
+               ConfigCompiler::CompileText(name, fragment);
+       }
+
        ConfigCompilerContext::SetContext(NULL);
 
        context.Validate();
@@ -207,13 +212,20 @@ int main(int argc, char **argv)
 #endif /* _WIN32 */
            );
 
-       Component::AddSearchDir(Application::GetPkgLibDir());
+       String searchDir = Application::GetPkgLibDir();
+       Logger::Write(LogInformation, "base", "Adding library search dir: " + searchDir);
+
+#ifdef _WIN32
+       SetDllDirectory(searchDir.CStr());
+#else /* _WIN32 */
+       lt_dladdsearchdir(searchDir.CStr());
+#endif /* _WIN32 */
 
-       (void) Utility::LoadIcingaLibrary("icinga", false);
+       (void) Utility::LoadExtensionLibrary("icinga");
 
        if (g_AppParams.count("library")) {
                BOOST_FOREACH(const String& libraryName, g_AppParams["library"].as<vector<String> >()) {
-                       Utility::LoadIcingaLibrary(libraryName, false);
+                       (void) Utility::LoadExtensionLibrary(libraryName);
                }
        }
 
index 5d8d03eb3c523b91df9cf83ce91531f846c4db58..b2eb46736d1e06ef017ae51d19a2fe4cbc7d8847 100644 (file)
@@ -5,5 +5,4 @@ icinga2itl_DATA = \
        notification.conf \
        service.conf \
        service-common.conf \
-       standalone.conf \
-       types.conf
+       standalone.conf
index 7ae68c7d153e9e0b02644fd67b6d47c3419444df..0ba84e41eb51ca4355cad2f7d629bf23be5e6202 100644 (file)
@@ -22,8 +22,6 @@
  * configuration templates.
  */
 
-#include "types.conf"
-
 #include "host.conf"
 #include "service.conf"
 #include "service-common.conf"
index 174a071cf608142cbbdfcd1e77d1f5cdd5c51dfe..2ba784c7875f6343af25d8872a17c7f08415e9f2 100644 (file)
  * along with this program; if not, write to the Free Software Foundation     *
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
-local object Component "checker" {}
 
-local object Component "delegation" {}
+#library "checker"
+local object CheckerComponent "checker" {}
 
-local object Component "notification" {}
+#library "delegation"
+local object DelegationComponent "delegation" {}
+
+#library "notification"
+local object NotificationComponent "notification" {}
index 3dca102f071d961e141f95e5fe5f64e8e82f2125..997d8368cf1993f3e623cac08601766952854294 100644 (file)
@@ -12,8 +12,6 @@ libbase_la_SOURCES =  \
        asynctask.h \
        attribute.cpp \
        attribute.h \
-       component.cpp \
-       component.h \
        connection.cpp \
        connection.h \
        convert.cpp \
diff --git a/lib/base/component.cpp b/lib/base/component.cpp
deleted file mode 100644 (file)
index aecb2c6..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/******************************************************************************
- * Icinga 2                                                                   *
- * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
- *                                                                            *
- * This program is free software; you can redistribute it and/or              *
- * modify it under the terms of the GNU General Public License                *
- * as published by the Free Software Foundation; either version 2             *
- * of the License, or (at your option) any later version.                     *
- *                                                                            *
- * This program is distributed in the hope that it will be useful,            *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
- * GNU General Public License for more details.                               *
- *                                                                            *
- * You should have received a copy of the GNU General Public License          *
- * along with this program; if not, write to the Free Software Foundation     *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
- ******************************************************************************/
-
-#include "i2-base.h"
-
-using namespace icinga;
-
-REGISTER_TYPE(Component);
-
-boost::mutex Component::m_Mutex;
-map<String, Component::Factory> Component::m_Factories;
-
-/**
- * Constructor for the component class.
- */
-Component::Component(const Dictionary::Ptr& properties)
-       : DynamicObject(properties)
-{
-       if (!IsLocal())
-               BOOST_THROW_EXCEPTION(runtime_error("Component objects must be local."));
-
-       Logger::Write(LogInformation, "base", "Loading component '" + GetName() + "'");
-
-       (void) Utility::LoadIcingaLibrary(GetName(), true);
-
-       Component::Factory factory;
-
-       {
-               boost::mutex::scoped_lock lock(m_Mutex);
-
-               map<String, Factory>::iterator it;
-               it = m_Factories.find(GetName());
-
-               if (it == m_Factories.end())
-                       BOOST_THROW_EXCEPTION(invalid_argument("Unknown component: " + GetName()));
-
-               factory = it->second;
-       }
-
-       m_Impl = factory();
-
-       if (!m_Impl)
-               BOOST_THROW_EXCEPTION(runtime_error("Component factory returned NULL."));
-}
-
-/**
- * Destructor for the Component class.
- */
-Component::~Component(void)
-{
-       if (m_Impl)
-               m_Impl->Stop();
-}
-
-/**
- * Starts the component. Called when the DynamicObject is fully
- * constructed/registered.
- */
-void Component::Start(void)
-{
-       m_Impl->SetConfig(GetSelf());
-       m_Impl->Start();
-}
-
-/**
- * Adds a directory to the component search path.
- *
- * @param componentDirectory The directory.
- */
-void Component::AddSearchDir(const String& componentDirectory)
-{
-       Logger::Write(LogInformation, "base", "Adding library search dir: " +
-           componentDirectory);
-
-#ifdef _WIN32
-       SetDllDirectory(componentDirectory.CStr());
-#else /* _WIN32 */
-       lt_dladdsearchdir(componentDirectory.CStr());
-#endif /* _WIN32 */
-}
-
-/**
- * Retrieves the configuration for this component.
- *
- * @returns The configuration.
- */
-DynamicObject::Ptr IComponent::GetConfig(void) const
-{
-       return m_Config.lock();
-}
-
-/**
- * Sets the configuration for this component.
- */
-void IComponent::SetConfig(const DynamicObject::Ptr& config)
-{
-       m_Config = config;
-}
-
-/**
- * Starts the component.
- */
-void IComponent::Start(void)
-{
-       /* Nothing to do in the default implementation. */
-}
-
-/**
- * Stops the component.
- */
-void IComponent::Stop(void)
-{
-       /* Nothing to do in the default implementation. */
-}
-
-/**
- * Registers a component factory.
- */
-void Component::Register(const String& name, const Component::Factory& factory)
-{
-       boost::mutex::scoped_lock lock(m_Mutex);
-
-       m_Factories[name] = factory;
-}
diff --git a/lib/base/component.h b/lib/base/component.h
deleted file mode 100644 (file)
index d6a9a82..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/******************************************************************************
- * Icinga 2                                                                   *
- * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
- *                                                                            *
- * This program is free software; you can redistribute it and/or              *
- * modify it under the terms of the GNU General Public License                *
- * as published by the Free Software Foundation; either version 2             *
- * of the License, or (at your option) any later version.                     *
- *                                                                            *
- * This program is distributed in the hope that it will be useful,            *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
- * GNU General Public License for more details.                               *
- *                                                                            *
- * You should have received a copy of the GNU General Public License          *
- * along with this program; if not, write to the Free Software Foundation     *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
- ******************************************************************************/
-
-#ifndef COMPONENT_H
-#define COMPONENT_H
-
-namespace icinga
-{
-
-/**
- * Interface for application extensions.
- *
- * @ingroup base
- */
-class I2_BASE_API IComponent : public Object
-{
-public:
-       typedef shared_ptr<IComponent> Ptr;
-       typedef weak_ptr<IComponent> WeakPtr;
-
-       virtual void Start(void);
-       virtual void Stop(void);
-
-protected:
-       DynamicObject::Ptr GetConfig(void) const;
-
-private:
-       DynamicObject::WeakPtr m_Config; /**< The configuration object for this
-                                     component. */
-
-       void SetConfig(const DynamicObject::Ptr& config);
-
-       friend class Component;
-};
-
-/**
- * An application extension that can be dynamically loaded
- * at run-time.
- *
- * @ingroup base
- */
-class I2_BASE_API Component : public DynamicObject
-{
-public:
-       typedef shared_ptr<Component> Ptr;
-       typedef weak_ptr<Component> WeakPtr;
-
-       typedef function<IComponent::Ptr (void)> Factory;
-
-       Component(const Dictionary::Ptr& properties);
-       ~Component(void);
-
-       virtual void Start(void);
-
-       static void AddSearchDir(const String& componentDirectory);
-
-       static void Register(const String& name, const Factory& factory);
-
-private:
-       IComponent::Ptr m_Impl; /**< The implementation object for this
-                                    component. */
-
-       static boost::mutex m_Mutex;
-       static map<String, Factory> m_Factories;
-};
-
-/**
- * Helper class for registering Component implementation classes.
- *
- * @ingroup base
- */
-class RegisterComponentHelper
-{
-public:
-       RegisterComponentHelper(const String& name, const Component::Factory& factory)
-       {
-               Component::Register(name, factory);
-       }
-};
-
-/**
- * Factory function for IComponent-based classes.
- *
- * @ingroup base
- */
-template<typename T>
-IComponent::Ptr ComponentFactory(void)
-{
-       return boost::make_shared<T>();
-}
-
-
-#define REGISTER_COMPONENT(name, klass) \
-       static RegisterComponentHelper g_RegisterSF_ ## type(name, ComponentFactory<klass>)
-
-}
-
-#endif /* COMPONENT_H */
index 28a5292164e1a17f79c88a3ed622f041c55a35d6..4d10d0fbd5044c636cad3a6cd6800039bd5ffd85 100644 (file)
@@ -95,7 +95,7 @@ shared_ptr<T> DynamicObjectFactory(const Dictionary::Ptr& serializedUpdate)
 }
 
 #define REGISTER_TYPE_ALIAS(type, alias) \
-       static RegisterTypeHelper g_RegisterDT_ ## type(alias, DynamicObjectFactory<type>)
+       static icinga::RegisterTypeHelper g_RegisterDT_ ## type(alias, DynamicObjectFactory<type>)
 
 #define REGISTER_TYPE(type) \
        REGISTER_TYPE_ALIAS(type, #type)
index 041319c1522cdbbffbecc1228081c2c4f5ed49be..f1ca5c22800025c414d6f0c4f4633c40f02d5045 100644 (file)
@@ -233,7 +233,6 @@ namespace signals2 = boost::signals2;
 #include "scriptlanguage.h"
 #include "logger.h"
 #include "application.h"
-#include "component.h"
 #include "streamlogger.h"
 #include "sysloglogger.h"
 
index 3a7b4167becdb0820251360137d457043e7aab9c..50bffc6e7c0d5a96d03a7674e806e680e83af6bd 100644 (file)
@@ -78,7 +78,7 @@ public:
 };
 
 #define REGISTER_SCRIPTFUNCTION(name, callback) \
-       static RegisterFunctionHelper g_RegisterSF_ ## type(name, callback)
+       static icinga::RegisterFunctionHelper g_RegisterSF_ ## type(name, callback)
 
 }
 
index c10d8d7a3f5b9a0bb5086f8a6edbd577463b839c..1ad374429972d8ba788102dc24dd2c0c3fd5815c 100644 (file)
@@ -346,25 +346,22 @@ void Utility::Sleep(double timeout)
 }
 
 /**
- * Loads the specified library and invokes an Icinga-specific init
- * function if available.
+ * Loads the specified library.
  *
  * @param library The name of the library.
- * @param module Whether the library is a module (non-module libraries have a
- *                                               "lib" prefix on *NIX).
  */
 #ifdef _WIN32
 HMODULE
 #else /* _WIN32 */
 lt_dlhandle
 #endif /* _WIN32 */
-Utility::LoadIcingaLibrary(const String& library, bool module)
+Utility::LoadExtensionLibrary(const String& library)
 {
        String path;
 #ifdef _WIN32
        path = library + ".dll";
 #else /* _WIN32 */
-       path = (module ? "" : "lib") + library + ".la";
+       path = "lib" + library + ".la";
 #endif /* _WIN32 */
 
        Logger::Write(LogInformation, "base", "Loading library '" + path + "'");
@@ -547,4 +544,3 @@ String Utility::FormatDateTime(const char *format, double ts)
 
        return timestamp;
 }
-
index c5c56829fe4d591fe5698b1b5df39bcd11e310bd..37827f0653437d5745b64819d2f6324959e23089 100644 (file)
@@ -65,7 +65,7 @@ public:
 #else /* _WIN32 */
        lt_dlhandle
 #endif /* _WIN32 */
-       LoadIcingaLibrary(const String& library, bool module);
+       LoadExtensionLibrary(const String& library);
 
 #ifndef _WIN32
        static void SetNonBlocking(int fd);
diff --git a/lib/config/.gitignore b/lib/config/.gitignore
new file mode 100644 (file)
index 0000000..e8c1bf7
--- /dev/null
@@ -0,0 +1 @@
+base-type.cpp
index 18ad41c77c0a66656aeb9df352110936747b0c10..60f471514d0ef26043af73c71457c0e71df81f9d 100644 (file)
@@ -8,7 +8,14 @@ BUILT_SOURCES = config_parser.h
 
 AM_YFLAGS = -d
 
+EXTRA_DIST = \
+       base-type.conf
+
+.conf.cpp:
+       $(top_builddir)/tools/mkembedconfig $< $@
+
 libconfig_la_SOURCES = \
+       base-type.cpp \
        configcompiler.cpp \
        configcompiler.h \
        configcompilercontext.cpp \
diff --git a/lib/config/base-type.conf b/lib/config/base-type.conf
new file mode 100644 (file)
index 0000000..b1615f2
--- /dev/null
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * Icinga 2                                                                   *
+ * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
+ *                                                                            *
+ * This program is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU General Public License                *
+ * as published by the Free Software Foundation; either version 2             *
+ * of the License, or (at your option) any later version.                     *
+ *                                                                            *
+ * This program is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
+ * GNU General Public License for more details.                               *
+ *                                                                            *
+ * You should have received a copy of the GNU General Public License          *
+ * along with this program; if not, write to the Free Software Foundation     *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
+ ******************************************************************************/
+
+type DynamicObject {
+       %require "__local",
+       %attribute number "__local",
+
+       %require "__name",
+       %attribute string "__name",
+
+       %require "__type",
+       %attribute string "__type",
+
+       %attribute dictionary "methods" {
+       },
+
+       %attribute any "custom::*"
+}
+
+type Logger {
+       %attribute string "type",
+       %attribute string "path",
+       %attribute string "severity"
+}
+
+type Script {
+       %require "language",
+       %attribute string "language",
+
+       %require "code",
+       %attribute string "code"
+}
index a499bb7f74fe60ae41d23941c633998deacfe31c..487b714f6670e317eea11b58109566f176185f2a 100644 (file)
@@ -108,7 +108,7 @@ void ConfigCompiler::HandleInclude(const String& include, bool search, const Deb
  */
 void ConfigCompiler::HandleLibrary(const String& library)
 {
-       Utility::LoadIcingaLibrary(library, false);
+       (void) Utility::LoadExtensionLibrary(library);
 }
 
 /**
@@ -211,3 +211,13 @@ void ConfigCompiler::AddIncludeSearchDir(const String& dir)
        m_IncludeSearchDirs.push_back(dir);
 }
 
+void ConfigCompiler::RegisterConfigFragment(const String& name, const String& fragment)
+{
+       GetConfigFragments()[name] = fragment;
+}
+
+map<String, String>& ConfigCompiler::GetConfigFragments(void)
+{
+       static map<String, String> fragments;
+       return fragments;
+}
index 036b3e8b39674fc74c39897862ef9738914b0333..04d7468b1af44c7a6b70a4cb0390e778a2a27be1 100644 (file)
@@ -50,14 +50,17 @@ public:
 
        static void HandleFileInclude(const String& include, bool search,
            const DebugInfo& debuginfo);
-       
+
        /* internally used methods */
        void HandleInclude(const String& include, bool search, const DebugInfo& debuginfo);
        void HandleLibrary(const String& library);
-       
+
        size_t ReadInput(char *buffer, size_t max_bytes);
        void *GetScanner(void) const;
 
+       static void RegisterConfigFragment(const String& name, const String& fragment);
+       static map<String, String>& GetConfigFragments(void);
+
 private:
        String m_Path;
        istream *m_Input;
@@ -72,6 +75,23 @@ private:
        void DestroyScanner(void);
 };
 
+/**
+ * Helper class for registering config fragments.
+ *
+ * @ingroup base
+ */
+class RegisterConfigFragmentHelper
+{
+public:
+       RegisterConfigFragmentHelper(const String& name, const String& fragment)
+       {
+               ConfigCompiler::RegisterConfigFragment(name, fragment);
+       }
+};
+
+#define REGISTER_CONFIG_FRAGMENT(name, fragment) \
+       static icinga::RegisterConfigFragmentHelper g_RegisterCF_ ## type(name, fragment)
+
 }
 
 #endif /* CONFIGCOMPILER_H */
diff --git a/lib/icinga/.gitignore b/lib/icinga/.gitignore
new file mode 100644 (file)
index 0000000..93a8d0d
--- /dev/null
@@ -0,0 +1 @@
+icinga-type.cpp
index f4c82ae9f0ea86eb97095c925a56f87e9f9dc395..242f64db9018e3dd2e400fd3d0a80e76c1ce9a53 100644 (file)
@@ -4,6 +4,12 @@
 pkglib_LTLIBRARIES =  \
        libicinga.la
 
+EXTRA_DIST = \
+       icinga-type.conf
+
+.conf.cpp:
+       $(top_builddir)/tools/mkembedconfig $< $@
+
 libicinga_la_SOURCES =  \
        api.cpp \
        api.h \
@@ -19,6 +25,7 @@ libicinga_la_SOURCES =  \
        host.h \
        i2-icinga.cpp \
        i2-icinga.h \
+       icinga-type.cpp \
        icingaapplication.cpp \
        icingaapplication.h \
        macroprocessor.cpp \
similarity index 91%
rename from itl/types.conf
rename to lib/icinga/icinga-type.conf
index 1a7d358ddc7b7ef4d00c134eaac63d66a98927ed..89fa93b72a1c1266e09e51ca7ca79045f83c1d63 100644 (file)
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
 
-type DynamicObject {
-       %require "__local",
-       %attribute number "__local",
-
-       %require "__name",
-       %attribute string "__name",
-
-       %require "__type",
-       %attribute string "__type",
-
-       %attribute dictionary "methods" {
-       },
-
-       %attribute any "custom::*"
-}
-
-type Component {
-}
-
-type Logger {
-       %attribute string "type",
-       %attribute string "path",
-       %attribute string "severity"
-}
-
 type Host {
        %attribute string "alias",
        %attribute string "hostcheck",
@@ -227,15 +202,6 @@ type ServiceGroup {
        %attribute string "action_url"
 }
 
-type Endpoint {
-       %attribute string "node",
-       %attribute string "service",
-       %attribute number "local"
-}
-
-type TimePeriod {
-}
-
 type Notification {
        %require "methods",
        %attribute dictionary "methods" {
@@ -258,21 +224,13 @@ type Notification {
        %attribute dictionary "groups" {
                %attribute string "*"
        },
+
        %attribute dictionary "notification_command" {
                %attribute string "_*"
        },
        %attribute string "notification_command"
 }
 
-type Script {
-       %require "language",
-       %attribute string "language",
-
-       %require "code",
-       %attribute string "code"
-}
-
 type User {
        %attribute string "display_name",
 
diff --git a/lib/remoting/.gitignore b/lib/remoting/.gitignore
new file mode 100644 (file)
index 0000000..83eb6c9
--- /dev/null
@@ -0,0 +1 @@
+remoting-type.cpp
index 372dcca81541fe0d079bf5b9e0aae3c103c3c146..cb12b5181799b4ec7a7d3274178eeed3c1b0fc65 100644 (file)
@@ -4,6 +4,9 @@
 pkglib_LTLIBRARIES = \
        libremoting.la
 
+.conf.cpp:
+       $(top_builddir)/tools/mkembedconfig $< $@
+
 libremoting_la_SOURCES = \
        endpoint.cpp \
        endpoint.h \
@@ -15,6 +18,7 @@ libremoting_la_SOURCES = \
        jsonrpcconnection.h \
        messagepart.cpp \
        messagepart.h \
+       remoting-type.cpp \
        requestmessage.cpp \
        requestmessage.h \
        responsemessage.cpp \
diff --git a/lib/remoting/remoting-type.conf b/lib/remoting/remoting-type.conf
new file mode 100644 (file)
index 0000000..5eab466
--- /dev/null
@@ -0,0 +1,24 @@
+/******************************************************************************
+ * Icinga 2                                                                   *
+ * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
+ *                                                                            *
+ * This program is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU General Public License                *
+ * as published by the Free Software Foundation; either version 2             *
+ * of the License, or (at your option) any later version.                     *
+ *                                                                            *
+ * This program is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
+ * GNU General Public License for more details.                               *
+ *                                                                            *
+ * You should have received a copy of the GNU General Public License          *
+ * along with this program; if not, write to the Free Software Foundation     *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
+ ******************************************************************************/
+
+type Endpoint {
+       %attribute string "node",
+       %attribute string "service",
+       %attribute number "local"
+}