j'ai créé un projet pour faire un jar contenant
et
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 /* * PromoMBeanImplMBean.java * * Created on 21 avril 2010, 12:19 */ package hotel.jmx; /** * Interface PromoMBeanImplMBean * * @author MiGuilbert */ public interface PromoMBeanImplMBean { /** * Get NewAttribute0 Description */ public String getDateDebut(); /** * Set NewAttribute0 Description */ public void setDateDebut(String value); /** * Get NewAttribute1 Description */ public String getDateFin(); /** * Set NewAttribute1 Description */ public void setDateFin(String value); }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 /* * PromoMBeanImpl.java * * Created on 21 avril 2010, 12:19 */ package hotel.jmx; import javax.management.*; /** * Class PromoMBeanImpl * * @author MiGuilbert */ public class PromoMBeanImpl implements PromoMBeanImplMBean { /** * Attribute : DateDebut */ private String dateDebut; /** * Attribute : DateFin */ private String dateFin; public PromoMBeanImpl(){ } /** * Get NewAttribute0 Description */ public String getDateDebut() { return dateDebut; } /** * Set NewAttribute0 Description */ public void setDateDebut(String value) { dateDebut = value; } /** * Get NewAttribute1 Description */ public String getDateFin() { return dateFin; } /** * Set NewAttribute1 Description */ public void setDateFin(String value) { dateFin = value; } }
Dans mon EJB (qui est dans un autre projet) je fais :
J'ai déployer mon application ear contenant l'EJB
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 try { // Register MBean in Platform MBeanServer mbeanPromo = new PromoMBeanImpl(); ManagementFactory.getPlatformMBeanServer(). registerMBean(mbeanPromo, new ObjectName("hotel.jmx:type=PromoMBeanImpl")); }catch(JMException ex) { // TODO handle exception } Logger.getLogger(HotelBean.class.getName()).finest("==============================================="); Logger.getLogger(HotelBean.class.getName()).finest("===========>"+mbeanPromo.getDateDebut()+"<==========="); Logger.getLogger(HotelBean.class.getName()).finest("===============================================");
J'ai déployé mon "Mbeans personnalisés" à partir du fichier jar
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 Nom : mBeans Nom de classe d'implémentation :hotel.jmx.PromoMBeanImpl Nom d'objet : user:impl-class-name=hotel.jmx.PromoMBeanImpl,name=PromoMBeanImpl Description : Statut : Activé Attribut(s) (2) Nom Type Valeur DateDebut java.lang.String 01/01/2010 DateFin java.lang.String 01/01/2010et dans les logs j'ai "null"
![]()





Répondre avec citation
Partager