Skip to content

Commit

Permalink
HWKALERTS-24 Refactoring of notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasponce committed Mar 6, 2015
1 parent 5e975a0 commit 6988d6e
Show file tree
Hide file tree
Showing 67 changed files with 938 additions and 1,497 deletions.
92 changes: 0 additions & 92 deletions examples/example-alerts-ui/pom.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
</parent>

<groupId>org.hawkular.alerts</groupId>
<artifactId>hawkular-notifiers-api</artifactId>
<artifactId>hawkular-actions-api</artifactId>
<packaging>jar</packaging>

<name>Hawkular Notifiers Api</name>
<name>Hawkular Actions Api</name>

<dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hawkular.notifiers.api.log;
package org.hawkular.actions.api.log;

import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
Expand All @@ -34,23 +34,15 @@ public interface MsgLogger extends BasicLogger {
MsgLogger LOGGER = Logger.getMessageLogger(MsgLogger.class, MsgLogger.class.getPackage().getName());

@LogMessage(level = Logger.Level.INFO)
@Message(id = 240001, value = "Plugin [%s] has received a notification message: [%s]")
void infoNotificationReceived(String notifierType, String msg);

@LogMessage(level = Logger.Level.INFO)
@Message(id = 240002, value = "Plugin [%s] has received a notifier Id: [%s] registration request: [%s]")
void infoNotifierRegistrationReceived(String notifierType, String notifierId, String msg);
@Message(id = 240001, value = "Plugin [%s] has received a action message: [%s]")
void infoActionReceived(String actionPlugin, String msg);

@LogMessage(level = Logger.Level.INFO)
@Message(id = 240003, value = "Plugin [%s] hast sent a registration request: [%s]")
void infoPluginRegistration(String notifierType, String msg);

@LogMessage(level = Logger.Level.INFO)
@Message(id = 240004, value = "Plugin [%s] has been unregistered")
void infoPluginUnregistered(String notifierType);
void infoPluginRegistration(String actionPlugin, String msg);

@LogMessage(level = Logger.Level.ERROR)
@Message(id = 240005, value = "Plugin [%s] cannot send a message to the bus. Error: [%s]")
void errorCannotSendMessage(String notifierType, String msg);
void errorCannotSendMessage(String actionPlugin, String msg);

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hawkular.notifiers.api.model;
package org.hawkular.actions.api.model;

import java.util.Map;

import com.google.gson.annotations.Expose;
import org.hawkular.bus.common.BasicMessage;

/**
* A notification message generated from the alerts engine through alert-bus subsystem.
* Notifier plugin must listen per notifierType of message in the filter.
* Notifier plugin should resolve notifierId and process message.
* A action message generated from the alerts engine through alert-bus subsystem.
* Action plugins must listen per actionPlugin of message in the filter.
*
* @author Jay Shaughnessy
* @author Lucas Ponce
*/
public class NotificationMessage extends BasicMessage {
public class ActionMessage extends BasicMessage {

@Expose
String notifierId;
String actionId;

@Expose
String message;

public NotificationMessage() { }
@Expose
Map<String, String> properties;

public ActionMessage() { }

public String getMessage() {
return message;
Expand All @@ -45,39 +49,47 @@ public void setMessage(String message) {
this.message = message;
}

public String getNotifierId() {
return notifierId;
public String getActionId() {
return actionId;
}

public void setActionId(String actionId) {
this.actionId = actionId;
}

public Map<String, String> getProperties() {
return properties;
}

public void setNotifierId(String notifierId) {
this.notifierId = notifierId;
public void setProperties(Map<String, String> properties) {
this.properties = properties;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

NotificationMessage that = (NotificationMessage) o;
ActionMessage that = (ActionMessage) o;

if (message != null ? !message.equals(that.message) : that.message != null) return false;
if (notifierId != null ? !notifierId.equals(that.notifierId) : that.notifierId != null) return false;
if (actionId != null ? !actionId.equals(that.actionId) : that.actionId != null) return false;

return true;
}

@Override
public int hashCode() {
int result = notifierId != null ? notifierId.hashCode() : 0;
int result = actionId != null ? actionId.hashCode() : 0;
result = 31 * result + (message != null ? message.hashCode() : 0);
return result;
}

@Override
public String toString() {
return "NotificationMessage{" +
return "ActionMessage{" +
"message='" + message + '\'' +
", notifierId='" + notifierId + '\'' +
'}';
", actionId='" + actionId + '\'' +
", properties=" + properties + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,46 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hawkular.notifiers.api.model;
package org.hawkular.actions.api.model;

import com.google.gson.annotations.Expose;
import org.hawkular.bus.common.BasicMessage;

import java.util.Set;

/**
* A notifier type registration message.
* An action plugin registration message.
* i.e. sms, snmp, email
*
* This message is generated by the notifier plugin at registration phase.
* It helps to centralize into the alerts engine how many types of notifier are available.
* This message is generated by the action plugin at registration phase.
* It helps to centralize into the alerts engine how many types of plugins are available.
*
* "op" parameter define the operation (register a plugin, re-register a plugin).
* Current values are:
* - "init" -> register and initializes a plugin
*
* @author Jay Shaughnessy
* @author Lucas Ponce
*/
public class NotifierTypeRegistrationMessage extends BasicMessage {
public class ActionPluginMessage extends BasicMessage {

@Expose
String op;

@Expose
String notifierType;
String actionPlugin;

@Expose
Set<String> properties;

public NotifierTypeRegistrationMessage() { }
public ActionPluginMessage() { }

public String getNotifierType() {
return notifierType;
public String getActionPlugin() {
return actionPlugin;
}

public void setNotifierType(String notifierType) {
this.notifierType = notifierType;
public void setActionPlugin(String actionPlugin) {
this.actionPlugin = actionPlugin;
}

public String getOp() {
Expand All @@ -73,9 +77,9 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

NotifierTypeRegistrationMessage that = (NotifierTypeRegistrationMessage) o;
ActionPluginMessage that = (ActionPluginMessage) o;

if (notifierType != null ? !notifierType.equals(that.notifierType) : that.notifierType != null) return false;
if (actionPlugin != null ? !actionPlugin.equals(that.actionPlugin) : that.actionPlugin != null) return false;
if (op != null ? !op.equals(that.op) : that.op != null) return false;
if (properties != null ? !properties.equals(that.properties) : that.properties != null) return false;

Expand All @@ -85,15 +89,15 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = op != null ? op.hashCode() : 0;
result = 31 * result + (notifierType != null ? notifierType.hashCode() : 0);
result = 31 * result + (actionPlugin != null ? actionPlugin.hashCode() : 0);
result = 31 * result + (properties != null ? properties.hashCode() : 0);
return result;
}

@Override
public String toString() {
return "NotifierTypeRegistrationMessage{" +
"notifierType='" + notifierType + '\'' +
return "ActionPluginMessage{" +
"actionPlugin='" + actionPlugin + '\'' +
", op='" + op + '\'' +
", properties=" + properties +
'}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@
</parent>

<groupId>org.hawkular.alerts</groupId>
<artifactId>hawkular-notifiers-sms</artifactId>
<artifactId>hawkular-actions-email</artifactId>
<packaging>war</packaging>

<name>Hawkular Notifiers Sms Plugin</name>
<name>Hawkular Action Email Plugin</name>

<dependencies>

<dependency>
<groupId>org.hawkular.alerts</groupId>
<artifactId>hawkular-notifiers-api</artifactId>
<artifactId>hawkular-actions-api</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down

0 comments on commit 6988d6e

Please sign in to comment.