From e5bde743cbe0bc5bc875c9198476c6dd9930952c Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Tue, 14 Sep 2021 17:58:44 +0200 Subject: [PATCH] remove entity listener --- .../src/main/java/de/hsadmin/bo/pac/Pac.java | 2 - .../java/de/hsadmin/bo/pac/PacComponent.java | 2 - .../de/hsadmin/bo/pac/PacEntityListener.java | 129 ------------------ 3 files changed, 133 deletions(-) delete mode 100644 cust-services/src/main/java/de/hsadmin/bo/pac/PacEntityListener.java diff --git a/cust-services/src/main/java/de/hsadmin/bo/pac/Pac.java b/cust-services/src/main/java/de/hsadmin/bo/pac/Pac.java index 9c7c741..9771a26 100644 --- a/cust-services/src/main/java/de/hsadmin/bo/pac/Pac.java +++ b/cust-services/src/main/java/de/hsadmin/bo/pac/Pac.java @@ -12,7 +12,6 @@ import java.util.Set; import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.EntityListeners; import javax.persistence.EntityManager; import javax.persistence.GeneratedValue; import javax.persistence.Id; @@ -30,7 +29,6 @@ import de.hsadmin.bo.customer.Customer; @Entity(name = "Pac") @Table(name = "packet") @SequenceGenerator(name = "PacsSeqGen", sequenceName = "packet_packet_id_seq") -// @EntityListeners({PacEntityListener.class}) public class Pac implements Serializable { private static final long serialVersionUID = 1L; diff --git a/cust-services/src/main/java/de/hsadmin/bo/pac/PacComponent.java b/cust-services/src/main/java/de/hsadmin/bo/pac/PacComponent.java index 12381a5..d11e8ed 100644 --- a/cust-services/src/main/java/de/hsadmin/bo/pac/PacComponent.java +++ b/cust-services/src/main/java/de/hsadmin/bo/pac/PacComponent.java @@ -7,7 +7,6 @@ import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.EntityListeners; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; @@ -20,7 +19,6 @@ import javax.persistence.TemporalType; @Entity(name = "PacComponents") @Table(name = "packet_component") @SequenceGenerator(name = "PacCompSeqGen", sequenceName = "packet_component_id_seq") -// @EntityListeners({PacEntityListener.class}) public class PacComponent implements Serializable { private static final long serialVersionUID = 1L; diff --git a/cust-services/src/main/java/de/hsadmin/bo/pac/PacEntityListener.java b/cust-services/src/main/java/de/hsadmin/bo/pac/PacEntityListener.java deleted file mode 100644 index 859c7e8..0000000 --- a/cust-services/src/main/java/de/hsadmin/bo/pac/PacEntityListener.java +++ /dev/null @@ -1,129 +0,0 @@ -package de.hsadmin.bo.pac; - -//import javax.jms.JMSException; -//import javax.jms.Queue; -//import javax.jms.QueueConnection; -//import javax.jms.QueueSender; -//import javax.jms.QueueSession; -//import javax.jms.Session; -//import javax.jms.TextMessage; -import javax.persistence.PostLoad; -import javax.persistence.PostPersist; -import javax.persistence.PostUpdate; -import javax.persistence.PreRemove; - -//import org.apache.activemq.ActiveMQConnectionFactory; - -public class PacEntityListener { - - public PacEntityListener() { - System.out.println("PacEntityListener()"); - } - - @PostLoad - public void onLoad(final Object entity) { - System.out.println("onLoad"); - Pac pac = null; - if (entity instanceof PacComponent) { - final PacComponent component = (PacComponent) entity; - pac = component.getPac(); - } - if (entity instanceof Pac) { - pac = (Pac) entity; - System.out.println("Pac: " + pac.getName() + " free:" + pac.isFree()); - } - System.out.println("Pac: " + pac.getName() + " free:" + pac.isFree()); - System.out.println(" from: " + this.toString()); - } - - @PostPersist - public void onCreate(final Object entity) { - System.out.println("onCreate"); - Pac pac = null; - if (entity instanceof PacComponent) { - final PacComponent component = (PacComponent) entity; - pac = component.getPac(); - } - if (entity instanceof Pac) { - pac = (Pac) entity; - System.out.println("Pac: " + pac.getName() + " free:" + pac.isFree()); - } - if (pac != null) { - final String name = pac.getName(); - System.out.println("Pac: " + name + " free:" + pac.isFree()); - sendNotification("pac", "add", name); - } - System.out.println(" from: " + this.toString()); - } - - @PostUpdate - public void onUpdate(final Object entity) { - System.out.println("onUpdate"); - Pac pac = null; - if (entity instanceof PacComponent) { - final PacComponent component = (PacComponent) entity; - pac = component.getPac(); - } - if (entity instanceof Pac) { - pac = (Pac) entity; - System.out.println("Pac: " + pac.getName() + " free:" + pac.isFree()); - } - if (pac != null) { - final String name = pac.getName(); - System.out.println("Pac: " + name + " free:" + pac.isFree()); - sendNotification("pac", "update", name); - } - System.out.println(" from: " + this.toString()); - } - - @PreRemove - public void onDelete(final Object entity) { - System.out.println("onDelete"); - Pac pac = null; - if (entity instanceof PacComponent) { - final PacComponent component = (PacComponent) entity; - pac = component.getPac(); - } - if (entity instanceof Pac) { - pac = (Pac) entity; - System.out.println("Pac: " + pac.getName() + " free:" + pac.isFree()); - } - if (pac != null) { - System.out.println("Pac: " + pac.getName() + " free:" + pac.isFree()); - final String name = pac.getName(); - System.out.println("Pac: " + name + " free:" + pac.isFree()); - sendNotification("pac", "delete", name); - } - System.out.println(" from: " + this.toString()); - } - - public void sendNotification(final String module, final String opCode, final String name) - { -// final ActiveMQConnectionFactory connFactory = new ActiveMQConnectionFactory("ssl://hsh03.hostsharing.net:61617"); -// QueueConnection connection = null; -// try { -// connection = connFactory.createQueueConnection("user-pactasks", "Ohf4oh"); -// connection.start(); -// final QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); -// final Queue queue = session.createQueue("queue.hsadminSystem-pactasks"); -// final String string = module + "." + opCode + ":" + name + ":" + new Date(); -// System.out.println(string); -// final TextMessage message = session.createTextMessage(string); -// final QueueSender sender = session.createSender(queue); -// sender.send(message); -// sender.close(); -// session.close(); -// } catch (JMSException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } finally { -// if (connection != null) { try { connection.close(); } catch(JMSException e) { } } -// } - } - - public static void main(String[] args) { - PacEntityListener listener = new PacEntityListener(); - listener.sendNotification("pac", "add", "xyz01"); - } - -}