remove entity listener
This commit is contained in:
parent
18b6f30b35
commit
e5bde743cb
@ -12,7 +12,6 @@ import java.util.Set;
|
|||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.EntityListeners;
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
@ -30,7 +29,6 @@ import de.hsadmin.bo.customer.Customer;
|
|||||||
@Entity(name = "Pac")
|
@Entity(name = "Pac")
|
||||||
@Table(name = "packet")
|
@Table(name = "packet")
|
||||||
@SequenceGenerator(name = "PacsSeqGen", sequenceName = "packet_packet_id_seq")
|
@SequenceGenerator(name = "PacsSeqGen", sequenceName = "packet_packet_id_seq")
|
||||||
// @EntityListeners({PacEntityListener.class})
|
|
||||||
public class Pac implements Serializable {
|
public class Pac implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -7,7 +7,6 @@ import java.util.Date;
|
|||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.EntityListeners;
|
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
@ -20,7 +19,6 @@ import javax.persistence.TemporalType;
|
|||||||
@Entity(name = "PacComponents")
|
@Entity(name = "PacComponents")
|
||||||
@Table(name = "packet_component")
|
@Table(name = "packet_component")
|
||||||
@SequenceGenerator(name = "PacCompSeqGen", sequenceName = "packet_component_id_seq")
|
@SequenceGenerator(name = "PacCompSeqGen", sequenceName = "packet_component_id_seq")
|
||||||
// @EntityListeners({PacEntityListener.class})
|
|
||||||
public class PacComponent implements Serializable {
|
public class PacComponent implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -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");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user