addConnection(ConnectionContext,ConnectionInfo)   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 5
c 0
b 0
f 0
cc 1
rs 10
1
/*
2
 * Copyright (C) 2017 Luca Coraci <[email protected]> ISTC-CNR
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
package it.cnr.istc.pst.cognition.koala.network.mqtt;
18
19
import java.util.logging.Level;
20
import java.util.logging.Logger;
21
22
import org.apache.activemq.broker.Broker;
23
import org.apache.activemq.broker.BrokerFilter;
24
import org.apache.activemq.broker.ConnectionContext;
25
import org.apache.activemq.command.ConnectionInfo;
26
27
/**
28
 *
29
 * @author Luca Coraci <[email protected]> ISTC-CNR
30
 */
31
public class MyBroker extends BrokerFilter {
32
33
    private static final Logger LOG = Logger.getLogger(MyBroker.class.getName());
34
35
    public MyBroker(Broker next) {
36
        super(next);
37
    }
38
39
    @Override
40
    public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception {
41
        LOG.log(Level.INFO, "new connection: {0}", info);
42
        System.out.println("new !");
43
        super.addConnection(context, info);
44
    }
45
46
    @Override
47
    public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable error) throws Exception {
48
        LOG.log(Level.INFO, "lost connection: {0}", info);
49
        System.out.println("lost");
50
        super.removeConnection(context, info, error);
51
    }
52
}
53