Moved project package from org.eclipse.moquette to io.moquette
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2015 The original author or authors
|
||||
* ------------------------------------------------------
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Apache License v2.0 which accompanies this distribution.
|
||||
*
|
||||
* The Eclipse Public License is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* The Apache License v2.0 is available at
|
||||
* http://www.opensource.org/licenses/apache2.0.php
|
||||
*
|
||||
* You may elect to redistribute this code under either of these licenses.
|
||||
*/
|
||||
package io.moquette.interception;
|
||||
|
||||
import io.moquette.proto.messages.AbstractMessage;
|
||||
import io.moquette.spi.impl.subscriptions.Subscription;
|
||||
import io.moquette.interception.messages.InterceptConnectMessage;
|
||||
import io.moquette.interception.messages.InterceptDisconnectMessage;
|
||||
import io.moquette.interception.messages.InterceptPublishMessage;
|
||||
import io.moquette.interception.messages.InterceptSubscribeMessage;
|
||||
import io.moquette.interception.messages.InterceptUnsubscribeMessage;
|
||||
|
||||
/**
|
||||
* This interface is used to inject code for intercepting broker events.
|
||||
* <p>
|
||||
* The events can act only as observers.
|
||||
* <p>
|
||||
* Almost every method receives a subclass of {@link AbstractMessage}, except
|
||||
* <code>onDisconnect</code> that receives the client id string and
|
||||
* <code>onSubscribe</code> and <code>onUnsubscribe</code> that receive a
|
||||
* {@link Subscription} object.
|
||||
*
|
||||
* @author Wagner Macedo
|
||||
*/
|
||||
public interface InterceptHandler {
|
||||
|
||||
void onConnect(InterceptConnectMessage msg);
|
||||
|
||||
void onDisconnect(InterceptDisconnectMessage msg);
|
||||
|
||||
void onPublish(InterceptPublishMessage msg);
|
||||
|
||||
void onSubscribe(InterceptSubscribeMessage msg);
|
||||
|
||||
void onUnsubscribe(InterceptUnsubscribeMessage msg);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2015 The original author or authors
|
||||
* ------------------------------------------------------
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Apache License v2.0 which accompanies this distribution.
|
||||
*
|
||||
* The Eclipse Public License is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* The Apache License v2.0 is available at
|
||||
* http://www.opensource.org/licenses/apache2.0.php
|
||||
*
|
||||
* You may elect to redistribute this code under either of these licenses.
|
||||
*/
|
||||
package io.moquette.interception;
|
||||
|
||||
import io.moquette.proto.messages.ConnectMessage;
|
||||
import io.moquette.proto.messages.PublishMessage;
|
||||
import io.moquette.spi.impl.subscriptions.Subscription;
|
||||
|
||||
/**
|
||||
* This interface is to be used internally by the broker components.
|
||||
* <p>
|
||||
* An interface is used instead of a class to allow more flexibility in changing
|
||||
* an implementation.
|
||||
* <p>
|
||||
* Interceptor implementations forward notifications to a <code>InterceptHandler</code>,
|
||||
* that is normally a field. So, the implementations should act as a proxy to a custom
|
||||
* intercept handler.
|
||||
*
|
||||
* @see InterceptHandler
|
||||
* @author Wagner Macedo
|
||||
*/
|
||||
public interface Interceptor {
|
||||
|
||||
void notifyClientConnected(ConnectMessage msg);
|
||||
|
||||
void notifyClientDisconnected(String clientID);
|
||||
|
||||
void notifyTopicPublished(PublishMessage msg, String clientID);
|
||||
|
||||
void notifyTopicSubscribed(Subscription sub);
|
||||
|
||||
void notifyTopicUnsubscribed(String topic, String clientID);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package io.moquette.interception.messages;
|
||||
|
||||
import io.moquette.proto.messages.AbstractMessage;
|
||||
|
||||
/**
|
||||
* @author Wagner Macedo
|
||||
*/
|
||||
public abstract class InterceptAbstractMessage {
|
||||
private final AbstractMessage msg;
|
||||
|
||||
InterceptAbstractMessage(AbstractMessage msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public boolean isRetainFlag() {
|
||||
return msg.isRetainFlag();
|
||||
}
|
||||
|
||||
public boolean isDupFlag() {
|
||||
return msg.isDupFlag();
|
||||
}
|
||||
|
||||
public AbstractMessage.QOSType getQos() {
|
||||
return msg.getQos();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package io.moquette.interception.messages;
|
||||
|
||||
import io.moquette.proto.messages.ConnectMessage;
|
||||
|
||||
/**
|
||||
* @author Wagner Macedo
|
||||
*/
|
||||
public class InterceptConnectMessage extends InterceptAbstractMessage {
|
||||
private final ConnectMessage msg;
|
||||
|
||||
public InterceptConnectMessage(ConnectMessage msg) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getClientID() {
|
||||
return msg.getClientID();
|
||||
}
|
||||
|
||||
public boolean isCleanSession() {
|
||||
return msg.isCleanSession();
|
||||
}
|
||||
|
||||
public int getKeepAlive() {
|
||||
return msg.getKeepAlive();
|
||||
}
|
||||
|
||||
public boolean isPasswordFlag() {
|
||||
return msg.isPasswordFlag();
|
||||
}
|
||||
|
||||
public byte getProtocolVersion() {
|
||||
return msg.getProtocolVersion();
|
||||
}
|
||||
|
||||
public String getProtocolName() {
|
||||
return msg.getProtocolName();
|
||||
}
|
||||
|
||||
public boolean isUserFlag() {
|
||||
return msg.isUserFlag();
|
||||
}
|
||||
|
||||
public boolean isWillFlag() {
|
||||
return msg.isWillFlag();
|
||||
}
|
||||
|
||||
public byte getWillQos() {
|
||||
return msg.getWillQos();
|
||||
}
|
||||
|
||||
public boolean isWillRetain() {
|
||||
return msg.isWillRetain();
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return msg.getUsername();
|
||||
}
|
||||
|
||||
public byte[] getPassword() {
|
||||
return msg.getPassword();
|
||||
}
|
||||
|
||||
public String getWillTopic() {
|
||||
return msg.getWillTopic();
|
||||
}
|
||||
|
||||
public byte[] getWillMessage() {
|
||||
return msg.getWillMessage();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package io.moquette.interception.messages;
|
||||
|
||||
/**
|
||||
* @author Wagner Macedo
|
||||
*/
|
||||
public class InterceptDisconnectMessage {
|
||||
private final String clientID;
|
||||
|
||||
public InterceptDisconnectMessage(String clientID) {
|
||||
this.clientID = clientID;
|
||||
}
|
||||
|
||||
public String getClientID() {
|
||||
return clientID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package io.moquette.interception.messages;
|
||||
|
||||
import io.moquette.proto.messages.PublishMessage;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* @author Wagner Macedo
|
||||
*/
|
||||
public class InterceptPublishMessage extends InterceptAbstractMessage {
|
||||
private final PublishMessage msg;
|
||||
private final String clientID;
|
||||
|
||||
public InterceptPublishMessage(PublishMessage msg, String clientID) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
this.clientID = clientID;
|
||||
}
|
||||
|
||||
public String getTopicName() {
|
||||
return msg.getTopicName();
|
||||
}
|
||||
|
||||
public ByteBuffer getPayload() {
|
||||
return msg.getPayload();
|
||||
}
|
||||
|
||||
public String getClientID() {
|
||||
return clientID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package io.moquette.interception.messages;
|
||||
|
||||
import io.moquette.proto.messages.AbstractMessage;
|
||||
import io.moquette.spi.impl.subscriptions.Subscription;
|
||||
|
||||
/**
|
||||
* @author Wagner Macedo
|
||||
*/
|
||||
public class InterceptSubscribeMessage {
|
||||
private final Subscription subscription;
|
||||
|
||||
public InterceptSubscribeMessage(Subscription subscription) {
|
||||
this.subscription = subscription;
|
||||
}
|
||||
|
||||
public String getClientID() {
|
||||
return subscription.getClientId();
|
||||
}
|
||||
|
||||
public AbstractMessage.QOSType getRequestedQos() {
|
||||
return subscription.getRequestedQos();
|
||||
}
|
||||
|
||||
public String getTopicFilter() {
|
||||
return subscription.getTopicFilter();
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package io.moquette.interception.messages;
|
||||
|
||||
/**
|
||||
* @author Wagner Macedo
|
||||
*/
|
||||
public class InterceptUnsubscribeMessage {
|
||||
private final String topicFilter;
|
||||
private final String clientID;
|
||||
|
||||
public InterceptUnsubscribeMessage(String topicFilter, String clientID) {
|
||||
this.topicFilter = topicFilter;
|
||||
this.clientID = clientID;
|
||||
}
|
||||
|
||||
public String getTopicFilter() {
|
||||
return topicFilter;
|
||||
}
|
||||
|
||||
public String getClientID() {
|
||||
return clientID;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user