[ mx4j-Bugs-575066 ] RelationService

"SourceForge.net" <[email protected]>
Newsgroups gmane.comp.java.mx4j.devel
Message-ID <[email protected]>
Bugs item #575066, was opened at 2002-06-28 15:10
Message generated for change (Settings changed) made by dsamsonoff
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=450647&aid=575066&group_id=47745

Category: JMX implementation
Group: Release 1.1
>Status: Open
Resolution: Fixed
Priority: 5
Submitted By: Timo Baur (faloondev)
>Assigned to: D.Samsonoff (dsamsonoff)
Summary: RelationService

Initial Comment:
Hi,

I have a RelationMBean connecting two other Mbeans.
one of the MBeans, lets call it MyMbean, is part of a 
second relation with
another type.

when I call findReferencingRelations
(myMbeanName,null,null) in the
RelationService, I get 
back only one relationid instead of two. 

but i am pretty sure that there are two relations the 
mbean is involved in,
I can see them on my visualisation (which works by 
calling getRole on the
RelationMBean) and I also verified this myself by calling 
getRole on the Id of
the RelationMBean from the html-adaptor, where I get 
the corresponding
myMBeanName. But findReferencingRelations called on 
MyBean does only give back one
relationid (the one of the other relation with another 
relationtype).

some code I use for this:

Object[] param={name,null,null};
String[]
signature=
{"javax.management.ObjectName","java.lang.String","jav
a.lang.String"};
String relid;
HashMap refRel=new HashMap();                        
Set coset=null;
try{
      refRel=(HashMap)getServer().invoke   
                         
(RelServObjectName,"findReferencingRelations",param,s
ignature);    
}catch(Exception e){e.printStackTrace();}
System.out.println("ConnectionHashMap: "+refRel);
coset=refRel.keySet();
System.out.println("ConnectionSet: "+coset);

the output:

ConnectionHashMap: {3=[Teil]}
ConnectionSet: [3]

what I miss is a second entry saying 1=[Quelle] or 
something like that.

Could you please verify if the findReferencingRelations 
method is working correct !? I am not 100 % sure that it 
is a bug but please fix it or tell me that it is none.

Thanks & Greetings

P.S.: I experienced similar problems with 
findAssociatedMBeans


----------------------------------------------------------------------

Comment By: D.Samsonoff (dsamsonoff)
Date: 2004-04-22 08:50

Message:
Logged In: YES 
user_id=1022526

The problem is when a bean participates in more than one 
relation, the relation service does not update the refrences 
correctly.

Here is the code that fixes the problem:

class: javax.management.relation.RelationService
method: addNewMBeanReference

private boolean addNewMBeanReference(ObjectName 
objectName, String relationId, String roleName)
			throws IllegalArgumentException
	{
		if(relationId == null) throw new 
IllegalArgumentException("Null Relation Id");
		if(roleName == null) throw new 
IllegalArgumentException("Null Role Name");
		if(objectName == null) throw new 
IllegalArgumentException("Null ObjectName.");

		// get the ObjectNames of the referenced 
ObjectName
		HashMap mbeanReferenceMap;
		synchronized
(m_referencedMBeanObjectNameToRelationIds)
		{
			mbeanReferenceMap = 
((HashMap)m_referencedMBeanObjectNameToRelationIds.get
(objectName));
		}
		// it is null, add it to our map and return 
true - we have a new reference
                //IF THE MAP DOES NOT EXISTS, CREATE IT...
		if(mbeanReferenceMap == null)
		{
			mbeanReferenceMap = new 
HashMap();
		}
		//IF THE MAP ALREADY CONTAINS A 
RELATION REFERENCE (identified by relationId) 
		//IGNORE IT OTHERWISE ADD IT TO THE 
RELATION REFERENCE MAP!
		if(mbeanReferenceMap.get(relationId) == 
null)
		{
			ArrayList roleNames = new 
ArrayList();
			roleNames.add(roleName);
			
			mbeanReferenceMap.put
(relationId, roleNames);
		
	addObjectNameToMBeanReference(objectName, 
mbeanReferenceMap);
			return true;
		}
		// not a new MBeanReference return false
		return false;
	}

----------------------------------------------------------------------

Comment By: Timo Baur (faloondev)
Date: 2002-07-02 19:08

Message:
Logged In: YES 
user_id=562283

Now I am sure that it is a mx4j-bug.
I tried my program with the RelationService of the sun 
reference implementation and it worked.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=450647&aid=575066&group_id=47745


-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.