Hi devs,
I'd like to quickly add a new ApplicationReadyEvent and send when we initialize the
XWiki class the first time:
Index:
../xwiki-commons/xwiki-commons-core/xwiki-commons-observation/xwiki-commons-observation-api/src/main/java/org/xwiki/observation/event/ApplicationReadyEvent.java
===================================================================
---
../xwiki-commons/xwiki-commons-core/xwiki-commons-observation/xwiki-commons-observation-api/src/main/java/org/xwiki/observation/event/ApplicationReadyEvent.java (revision
)
+++
../xwiki-commons/xwiki-commons-core/xwiki-commons-observation/xwiki-commons-observation-api/src/main/java/org/xwiki/observation/event/ApplicationReadyEvent.java (revision
)
@@ -0,0 +1,35 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.xwiki.observation.event;
+
+/**
+ * An event triggered when the XWiki application is ready to service requests.
+ *
+ * @version $Id$
+ * @since 4.0M2
+ */
+public class ApplicationReadyEvent implements Event
+{
+ @Override
+ public boolean matches(Object otherEvent)
+ {
+ return this.getClass().isAssignableFrom(otherEvent.getClass());
+ }
+}
Index: xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/XWiki.java
===================================================================
---
xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/XWiki.java (revision
6ddfc45a6aa807ac4b6a9bc9e101c042d0f0dd3d)
+++
xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/XWiki.java (revision
)
@@ -109,6 +109,7 @@
import org.xwiki.model.reference.WikiReference;
import org.xwiki.observation.EventListener;
import org.xwiki.observation.ObservationManager;
+import org.xwiki.observation.event.ApplicationReadyEvent;
import org.xwiki.observation.event.Event;
import org.xwiki.query.QueryException;
import org.xwiki.rendering.macro.wikibridge.WikiMacroInitializer;
@@ -808,7 +809,12 @@
// that we need DB access to be available (at component initialization) to make
this possible.
registerWikiMacros();
- Utils.<ObservationManager> getComponent((Type)
ObservationManager.class).addListener(this);
+ ObservationManager observationManager =
+ Utils.<ObservationManager> getComponent((Type)
ObservationManager.class);
+ observationManager.addListener(this);
+
+ // Send Event to signal that the application is ready to service requests.
+ observationManager.notify(new ApplicationReadyEvent(), this);
}
/**
The rationale is that a lot of code require to know when the application is ready for
servicing and need to listen to this event and right now we're postponing implementing
several refactorings in XWiki because of this missing event.
WDYT?
Thanks
-Vincent
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs