001/*
002 * jPOS Project [http://jpos.org]
003 * Copyright (C) 2000-2026 jPOS Software SRL
004 *
005 * This program is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU Affero General Public License as
007 * published by the Free Software Foundation, either version 3 of the
008 * License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013 * GNU Affero General Public License for more details.
014 *
015 * You should have received a copy of the GNU Affero General Public License
016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.jpos.jfr;
020
021import jdk.jfr.*;
022
023@Category("jPOS")
024@Name("jpos.Channel")
025@StackTrace
026public class ChannelEvent extends Event {
027    @Name("detail")
028    protected String detail;
029
030    public ChannelEvent() {}
031    public ChannelEvent(String detail) {
032        this.detail = detail;
033    }
034
035    public void setDetail(String detail) {
036        this.detail = detail;
037    }
038
039    public String getDetail() {
040        return detail;
041    }
042
043    public ChannelEvent append (String additionalDetail) {
044        detail = detail != null ?
045          "%s, %s".formatted (detail, additionalDetail) : additionalDetail;
046        return this;
047    }
048
049    @Name("jpos.Channel.Send")
050    public static class Send extends ChannelEvent { }
051
052    @Name("jpos.Channel.Receive")
053    public static class Receive extends ChannelEvent { }
054
055    @Name("jpos.Channel.Connect")
056    public static class Connect extends ChannelEvent { }
057
058    @Name("jpos.Channel.Accept")
059    public static class Accept extends ChannelEvent { }
060
061    @Name("jpos.Channel.Disconnect")
062    public static class Disconnect extends ChannelEvent { }
063
064    @Name("jpos.Channel.ConnectionException")
065    public static class ConnectionException extends ChannelEvent {
066        public ConnectionException(String detail) {
067            super(detail);
068        }
069    }
070
071    @Name("jpos.Channel.AcceptException")
072    public static class AcceptException extends ChannelEvent {
073        public AcceptException(String detail) {
074            super(detail);
075        }
076    }
077
078    @Name("jpos.Channel.SendException")
079    public static class SendException extends ChannelEvent {
080        public SendException(String detail) {
081            super(detail);
082        }
083    }
084
085}