Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab 6 – EJB User Managment

Similar presentations


Presentation on theme: "Lab 6 – EJB User Managment"— Presentation transcript:

1 Lab 6 – EJB User Managment
Middleware Platforms Lab 6 – EJB User Managment Robert Sombrutzki Contact: 1

2 Important Dates 2 weeks for lab 6 Next meeting: 14.02.2012
Start: End: Next meeting:

3 Lab 6 explained Enterprise JavaBeans Covered topics Environment
Entity-Beans Session-Beans (stateful)‏ MessageDriven-Beans Environment Java 1.4 (5/6)‏ JBoss application server

4 Lab 6 explained

5 Lab 6 explained Simple Entity Bean(s)‏ Stateful Session Bean
User, Role, Phone, Address, Permission, Log Stateful Session Bean UserManager Message Driven Bean LoggerBean Keys (IDs) Log: time (Date) Permission: objectId (long) Role: name (String) Address, Phone, User: id (int)

6 Lab 6 explained Entity Relationships
Role – Permission: Role – User – User –

7 Lab 6 explained Phone Key @Id long areaCode;
@JoinColumn(name = "AREA_CODE") long number;

8 Lab 6 explained Remove-Method
EntityManager em; private void attachAndRemove(User user) { user = em.merge(user); em.remove(user); } To remove an entity, you must use a managed instance Object instance passed to method is called detached

9 Lab 6 explained Log Bean Logger Bean
ID: Time Logger Bean Implements interface MessageListener Method: void onMessage(Message msg) Messaging Model: Point-to-Point (Queue) Annotation: @MessageDriven(activationConfig={ @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"), @ActivationConfigProperty(propertyName="destination", propertyValue="queue/titan-LogEJBQueue")})‏ Slides: Asynchrones Messaging (S.5)

10 Lab 6 explained MessageQueue in UserManagerBean
@Resource(mappedName="java:/JmsXA") private ConnectionFactory connFactory; @Resource(mappedName="queue/titan-LogEJBQueue") private Queue queue; Connection cnn = connFactory.createConnection(); Session sess = cnn.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer mess = sess.createProducer(queue); TextMessage textMsg = sess.createTextMessage(); textMsg.setText(message); textMsg.setShortProperty("level", (short)level); mess.send(textMsg); cnn.close(); Slides: Asynchrones Messaging (S.1)


Download ppt "Lab 6 – EJB User Managment"

Similar presentations


Ads by Google