You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by kd...@apache.org on 2018/08/21 14:28:30 UTC

nifi-registry git commit: NIFIREG-192: Implement REGISTRY_START event

Repository: nifi-registry
Updated Branches:
  refs/heads/master ead0ea6e6 -> 3672f8b98


NIFIREG-192: Implement REGISTRY_START event

This closes #134.

Signed-off-by: Kevin Doran <kd...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/nifi-registry/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi-registry/commit/3672f8b9
Tree: http://git-wip-us.apache.org/repos/asf/nifi-registry/tree/3672f8b9
Diff: http://git-wip-us.apache.org/repos/asf/nifi-registry/diff/3672f8b9

Branch: refs/heads/master
Commit: 3672f8b986f38abefb4918b5d83fe019c9311910
Parents: ead0ea6
Author: Jeremy Dyer <je...@apache.org>
Authored: Wed Aug 8 22:37:12 2018 -0400
Committer: Kevin Doran <kd...@apache.org>
Committed: Tue Aug 21 10:28:03 2018 -0400

----------------------------------------------------------------------
 .../src/main/asciidoc/administration-guide.adoc |  1 +
 .../apache/nifi/registry/hook/EventType.java    |  3 +--
 .../registry/NiFiRegistryApiApplication.java    | 24 ++++++++++++++++++++
 3 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/3672f8b9/nifi-registry-docs/src/main/asciidoc/administration-guide.adoc
----------------------------------------------------------------------
diff --git a/nifi-registry-docs/src/main/asciidoc/administration-guide.adoc b/nifi-registry-docs/src/main/asciidoc/administration-guide.adoc
index 9e8d0c0..53e32cf 100644
--- a/nifi-registry-docs/src/main/asciidoc/administration-guide.adoc
+++ b/nifi-registry-docs/src/main/asciidoc/administration-guide.adoc
@@ -1161,6 +1161,7 @@ Event hooks are an integration point that allows for custom code to to be trigge
 |`UPDATE_FLOW` | A flow that exist in a bucket has been updated.
 |`DELETE_BUCKET` | An existing bucket in the registry is deleted.
 |`DELETE_FLOW` | An existing flow in the registry is deleted.
+|`REGISTRY_START` | Invoked once the NiFi Registry application has been successfully started. This is only invoked after a complete and successful start.
 |==================================================================================================================================================
 
 === Shared Event Hook Properties

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/3672f8b9/nifi-registry-provider-api/src/main/java/org/apache/nifi/registry/hook/EventType.java
----------------------------------------------------------------------
diff --git a/nifi-registry-provider-api/src/main/java/org/apache/nifi/registry/hook/EventType.java b/nifi-registry-provider-api/src/main/java/org/apache/nifi/registry/hook/EventType.java
index ce6930a..c11a60c 100644
--- a/nifi-registry-provider-api/src/main/java/org/apache/nifi/registry/hook/EventType.java
+++ b/nifi-registry-provider-api/src/main/java/org/apache/nifi/registry/hook/EventType.java
@@ -41,7 +41,7 @@ public enum EventType {
             EventFieldName.VERSION,
             EventFieldName.USER,
             EventFieldName.COMMENT),
-
+    REGISTRY_START(),
     UPDATE_BUCKET(
             EventFieldName.BUCKET_ID,
             EventFieldName.USER),
@@ -49,7 +49,6 @@ public enum EventType {
             EventFieldName.BUCKET_ID,
             EventFieldName.FLOW_ID,
             EventFieldName.USER),
-
     DELETE_BUCKET(
             EventFieldName.BUCKET_ID,
             EventFieldName.USER),

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/3672f8b9/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/NiFiRegistryApiApplication.java
----------------------------------------------------------------------
diff --git a/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/NiFiRegistryApiApplication.java b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/NiFiRegistryApiApplication.java
index 256efb4..d06555d 100644
--- a/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/NiFiRegistryApiApplication.java
+++ b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/NiFiRegistryApiApplication.java
@@ -16,10 +16,18 @@
  */
 package org.apache.nifi.registry;
 
+import org.apache.nifi.registry.event.EventService;
+import org.apache.nifi.registry.event.StandardEvent;
+import org.apache.nifi.registry.hook.Event;
+import org.apache.nifi.registry.hook.EventType;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+import org.springframework.context.ApplicationListener;
+import org.springframework.stereotype.Component;
 
 import java.util.Properties;
 
@@ -39,6 +47,9 @@ public class NiFiRegistryApiApplication extends SpringBootServletInitializer {
     public static final String NIFI_REGISTRY_PROPERTIES_ATTRIBUTE = "nifi-registry.properties";
     public static final String NIFI_REGISTRY_MASTER_KEY_ATTRIBUTE = "nifi-registry.key";
 
+    @Autowired
+    private EventService eventService;
+
     @Override
     protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
         final Properties defaultProperties = new Properties();
@@ -54,6 +65,19 @@ public class NiFiRegistryApiApplication extends SpringBootServletInitializer {
                 .properties(defaultProperties);
     }
 
+    @Component
+    private class OnApplicationReadyEventing
+            implements ApplicationListener<ApplicationReadyEvent> {
+
+        @Override
+        public void onApplicationEvent(final ApplicationReadyEvent event) {
+            Event registryStartEvent = new StandardEvent.Builder()
+                    .eventType(EventType.REGISTRY_START)
+                    .build();
+            eventService.publish(registryStartEvent);
+        }
+    }
+
     public static void main(String[] args) {
         SpringApplication.run(NiFiRegistryApiApplication.class, args);
     }