{ try { if (bean==null || _beans.containsKey(bean)) return; Object mbean=ObjectMBean.mbeanFor(bean); if (mbean==null) return;  String name=bean.getClass().getName().toLowerCase(); int dot = name.lastIndexOf('.'); if (dot>=0) name=name.substring(dot+1); Integer count=(Integer)_unique.get(name); count=TypeUtil.newInteger(count==null?0:(1+count.intValue())); _unique.put(name, count);  ObjectName oname=new ObjectName(_domain+":"+name+"="+count);  ObjectInstance oinstance = _server.registerMBean(mbean, oname); Log.info("registered "+oinstance.getObjectName()); _beans.put(bean,oinstance.getObjectName());  } catch(Exception e) { Log.warn(""+bean,e); } }
{ try { if (bean == null || _beans.containsKey(bean)) return; Object mbean = ObjectMBean.mbeanFor(bean); if (mbean == null) return;  if (mbean instanceof ObjectMBean) ((ObjectMBean)mbean).setMBeanContainer(this);  String name = bean.getClass().getName().toLowerCase(); int dot = name.lastIndexOf('.'); if (dot >= 0) name = name.substring(dot + 1); Integer count = (Integer)_unique.get(name); count = TypeUtil.newInteger(count == null ? 0 : (1 + count.intValue())); _unique.put(name, count);  ObjectName oname = ObjectName.getInstance("", name, String.valueOf(count));  ObjectInstance oinstance = _server.registerMBean(mbean, oname); Log.info("Registered " + oinstance.getObjectName()); _beans.put(bean, oinstance.getObjectName());  } catch (Exception e) { Log.warn(e); } }
    private synchronized void addBean(Object bean)    {        try        {            if (bean==null || _beans.containsKey(bean))                return;            Object mbean=ObjectMBean.mbeanFor(bean);            if (mbean==null)                return;                        String name=bean.getClass().getName().toLowerCase();            int dot = name.lastIndexOf('.');            if (dot>=0)                name=name.substring(dot+1);            Integer count=(Integer)_unique.get(name);            count=TypeUtil.newInteger(count==null?0:(1+count.intValue()));            _unique.put(name, count);                        ObjectName oname=new ObjectName(_domain+":"+name+"="+count);                        ObjectInstance oinstance = _server.registerMBean(mbean, oname);            Log.info("registered "+oinstance.getObjectName());            _beans.put(bean,oinstance.getObjectName());                    }        catch(Exception e)        {            Log.warn(""+bean,e);        }    }