wms-commons-modeler

16:53:59.950 INFO  jd.cli.Main - Decompiling wms-commons-modeler.jar
package org.apache.commons.modeler;

import java.io.Serializable;
import java.lang.reflect.Method;
import javax.management.Descriptor;
import javax.management.modelmbean.ModelMBeanAttributeInfo;

public class AttributeInfo
  extends FeatureInfo
  implements Serializable
{
  static final long serialVersionUID = -2511626862303972143L;
  protected transient ModelMBeanAttributeInfo info = null;
  protected String displayName = null;
  protected String getMethod = null;
  protected String setMethod = null;
  protected transient Method getMethodObj = null;
  protected transient Method setMethodObj = null;
  protected boolean readable = true;
  protected boolean writeable = true;
  protected boolean is = false;
  protected String type = null;
  protected String persist;
  protected String defaultStringValue;
  
  public void setDescription(String paramString)
  {
    super.setDescription(paramString);
    info = null;
  }
  
  public void setName(String paramString)
  {
    super.setName(paramString);
    info = null;
  }
  
  public String getDisplayName()
  {
    return displayName;
  }
  
  public void setDisplayName(String paramString)
  {
    displayName = paramString;
  }
  
  public String getGetMethod()
  {
    return getMethod;
  }
  
  public void setGetMethod(String paramString)
  {
    getMethod = paramString;
    info = null;
  }
  
  public Method getGetMethodObj()
  {
    return getMethodObj;
  }
  
  public void setGetMethodObj(Method paramMethod)
  {
    getMethodObj = paramMethod;
  }
  
  public Method getSetMethodObj()
  {
    return setMethodObj;
  }
  
  public void setSetMethodObj(Method paramMethod)
  {
    setMethodObj = paramMethod;
  }
  
  public boolean isIs()
  {
    return is;
  }
  
  public void setIs(boolean paramBoolean)
  {
    is = paramBoolean;
    info = null;
  }
  
  public boolean isReadable()
  {
    return readable;
  }
  
  public void setReadable(boolean paramBoolean)
  {
    readable = paramBoolean;
    info = null;
  }
  
  public String getSetMethod()
  {
    return setMethod;
  }
  
  public void setSetMethod(String paramString)
  {
    setMethod = paramString;
    info = null;
  }
  
  public String getType()
  {
    return type;
  }
  
  public void setType(String paramString)
  {
    type = paramString;
    info = null;
  }
  
  public boolean isWriteable()
  {
    return writeable;
  }
  
  public void setWriteable(boolean paramBoolean)
  {
    writeable = paramBoolean;
    info = null;
  }
  
  public String getPersist()
  {
    return persist;
  }
  
  public void setPersist(String paramString)
  {
    persist = paramString;
  }
  
  public String getDefault()
  {
    return defaultStringValue;
  }
  
  public void setDefault(String paramString)
  {
    defaultStringValue = paramString;
  }
  
  public ModelMBeanAttributeInfo createAttributeInfo()
  {
    if (info != null) {
      return info;
    }
    if ((getMethodObj != null) || (setMethodObj != null)) {
      try
      {
        info = new ModelMBeanAttributeInfo(getName(), getDescription(), getMethodObj, setMethodObj);
        
        return info;
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
      }
    }
    info = new ModelMBeanAttributeInfo(getName(), getType(), getDescription(), isReadable(), isWriteable(), false);
    
    Descriptor localDescriptor = info.getDescriptor();
    if (getDisplayName() != null) {
      localDescriptor.setField("displayName", getDisplayName());
    }
    if (isReadable()) {
      if (getGetMethod() != null) {
        localDescriptor.setField("getMethod", getGetMethod());
      } else {
        localDescriptor.setField("getMethod", getMethodName(getName(), true, isIs()));
      }
    }
    if (isWriteable()) {
      if (getSetMethod() != null) {
        localDescriptor.setField("setMethod", getSetMethod());
      } else {
        localDescriptor.setField("setMethod", getMethodName(getName(), false, false));
      }
    }
    addFields(localDescriptor);
    info.setDescriptor(localDescriptor);
    return info;
  }
  
  public String toString()
  {
    StringBuffer localStringBuffer = new StringBuffer("AttributeInfo[");
    localStringBuffer.append("name=");
    localStringBuffer.append(name);
    localStringBuffer.append(", description=");
    localStringBuffer.append(description);
    if (!readable)
    {
      localStringBuffer.append(", readable=");
      localStringBuffer.append(readable);
    }
    localStringBuffer.append(", type=");
    localStringBuffer.append(type);
    if (!writeable)
    {
      localStringBuffer.append(", writeable=");
      localStringBuffer.append(writeable);
    }
    localStringBuffer.append("]");
    return localStringBuffer.toString();
  }
  
  private String getMethodName(String paramString, boolean paramBoolean1, boolean paramBoolean2)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    if (paramBoolean1)
    {
      if (paramBoolean2) {
        localStringBuffer.append("is");
      } else {
        localStringBuffer.append("get");
      }
    }
    else {
      localStringBuffer.append("set");
    }
    localStringBuffer.append(Character.toUpperCase(paramString.charAt(0)));
    localStringBuffer.append(paramString.substring(1));
    return localStringBuffer.toString();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.modeler.AttributeInfo
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.modeler;

import java.util.HashSet;
import javax.management.AttributeChangeNotification;
import javax.management.Notification;
import javax.management.NotificationFilter;

public class BaseAttributeFilter
  implements NotificationFilter
{
  public BaseAttributeFilter(String paramString)
  {
    if (paramString != null) {
      addAttribute(paramString);
    }
  }
  
  private HashSet names = new HashSet();
  
  public void addAttribute(String paramString)
  {
    synchronized (names)
    {
      names.add(paramString);
    }
  }
  
  public void clear()
  {
    synchronized (names)
    {
      names.clear();
    }
  }
  
  /* Error */
  public String[] getNames()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 4	org/apache/commons/modeler/BaseAttributeFilter:names	Ljava/util/HashSet;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 4	org/apache/commons/modeler/BaseAttributeFilter:names	Ljava/util/HashSet;
    //   11: aload_0
    //   12: getfield 4	org/apache/commons/modeler/BaseAttributeFilter:names	Ljava/util/HashSet;
    //   15: invokevirtual 8	java/util/HashSet:size	()I
    //   18: anewarray 9	java/lang/String
    //   21: invokevirtual 10	java/util/HashSet:toArray	([Ljava/lang/Object;)[Ljava/lang/Object;
    //   24: checkcast 11	[Ljava/lang/String;
    //   27: checkcast 11	[Ljava/lang/String;
    //   30: aload_1
    //   31: monitorexit
    //   32: areturn
    //   33: astore_2
    //   34: aload_1
    //   35: monitorexit
    //   36: aload_2
    //   37: athrow
    // Line number table:
    //   Java source line #105	-> byte code offset #0
    //   Java source line #106	-> byte code offset #7
    //   Java source line #107	-> byte code offset #33
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	38	0	this	BaseAttributeFilter
    //   5	30	1	Ljava/lang/Object;	Object
    //   33	4	2	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   7	32	33	finally
    //   33	36	33	finally
  }
  
  public boolean isNotificationEnabled(Notification paramNotification)
  {
    if (paramNotification == null) {
      return false;
    }
    if (!(paramNotification instanceof AttributeChangeNotification)) {
      return false;
    }
    AttributeChangeNotification localAttributeChangeNotification = (AttributeChangeNotification)paramNotification;
    if (!"jmx.attribute.change".equals(localAttributeChangeNotification.getType())) {
      return false;
    }
    synchronized (names)
    {
      if (names.size() < 1) {
        return true;
      }
      return names.contains(localAttributeChangeNotification.getAttributeName());
    }
  }
  
  public void removeAttribute(String paramString)
  {
    synchronized (names)
    {
      names.remove(paramString);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.modeler.BaseAttributeFilter
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.modeler;

class BaseModelMBean$MethodKey
{
  private String name;
  private String[] signature;
  
  BaseModelMBean$MethodKey(String paramString, String[] paramArrayOfString)
  {
    name = paramString;
    if (paramArrayOfString == null) {
      paramArrayOfString = new String[0];
    }
    signature = paramArrayOfString;
  }
  
  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof MethodKey)) {
      return false;
    }
    MethodKey localMethodKey = (MethodKey)paramObject;
    if (!name.equals(name)) {
      return false;
    }
    if (signature.length != signature.length) {
      return false;
    }
    for (int i = 0; i < signature.length; i++) {
      if (!signature[i].equals(signature[i])) {
        return false;
      }
    }
    return true;
  }
  
  public int hashCode()
  {
    return name.hashCode();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.modeler.BaseModelMBean.MethodKey
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.modeler;

import com.wowza.wms.logging.WMSLogger;
import com.wowza.wms.logging.WMSLoggerFactory;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import javax.management.Attribute;
import javax.management.AttributeChangeNotification;
import javax.management.AttributeList;
import javax.management.AttributeNotFoundException;
import javax.management.Descriptor;
import javax.management.DynamicMBean;
import javax.management.InstanceNotFoundException;
import javax.management.InvalidAttributeValueException;
import javax.management.ListenerNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanInfo;
import javax.management.MBeanNotificationInfo;
import javax.management.MBeanRegistration;
import javax.management.MBeanServer;
import javax.management.Notification;
import javax.management.NotificationFilter;
import javax.management.NotificationListener;
import javax.management.ObjectName;
import javax.management.ReflectionException;
import javax.management.RuntimeErrorException;
import javax.management.RuntimeOperationsException;
import javax.management.ServiceNotFoundException;
import javax.management.modelmbean.DescriptorSupport;
import javax.management.modelmbean.InvalidTargetObjectTypeException;
import javax.management.modelmbean.ModelMBean;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanInfo;
import javax.management.modelmbean.ModelMBeanInfoSupport;
import javax.management.modelmbean.ModelMBeanNotificationInfo;
import org.apache.commons.modeler.modules.ModelerSource;

public class BaseModelMBean
  implements ModelMBean, MBeanRegistration
{
  public BaseModelMBean()
    throws MBeanException, RuntimeOperationsException
  {
    setModelMBeanInfo(createDefaultModelMBeanInfo());
  }
  
  public BaseModelMBean(ModelMBeanInfo paramModelMBeanInfo)
    throws MBeanException, RuntimeOperationsException
  {
    setModelMBeanInfo(paramModelMBeanInfo);
  }
  
  public BaseModelMBean(String paramString)
    throws MBeanException, RuntimeOperationsException
  {
    try
    {
      setModeledType(paramString);
    }
    catch (Throwable localThrowable)
    {
      WMSLoggerFactory.getLogger(BaseModelMBean.class).error("Error creating mbean ", localThrowable);
    }
  }
  
  public BaseModelMBean(String paramString, ModelerSource paramModelerSource)
    throws MBeanException, RuntimeOperationsException
  {
    try
    {
      setModeledType(paramString);
    }
    catch (Throwable localThrowable)
    {
      WMSLoggerFactory.getLogger(BaseModelMBean.class).error("Error creating mbean ", localThrowable);
    }
    source = paramModelerSource;
  }
  
  protected BaseNotificationBroadcaster attributeBroadcaster = null;
  protected Registry registry = null;
  protected BaseNotificationBroadcaster generalBroadcaster = null;
  protected ObjectName oname = null;
  protected ModelMBeanInfo info = null;
  protected Object resource = null;
  protected String resourceType = null;
  protected ModelerSource source = null;
  protected HashMap attributes = new HashMap();
  static final Object[] NO_ARGS_PARAM = new Object[0];
  static final Class[] NO_ARGS_PARAM_SIG = new Class[0];
  private Hashtable getAttMap = new Hashtable();
  private Hashtable setAttMap = new Hashtable();
  private Hashtable invokeAttMap = new Hashtable();
  
  public Object getAttribute(String paramString)
    throws AttributeNotFoundException, MBeanException, ReflectionException
  {
    if (paramString == null) {
      throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name is null"), "Attribute name is null");
    }
    if (((resource instanceof DynamicMBean)) && (!(resource instanceof BaseModelMBean))) {
      return ((DynamicMBean)resource).getAttribute(paramString);
    }
    Method localMethod = (Method)getAttMap.get(paramString);
    Object localObject2;
    Object localObject3;
    if (localMethod == null)
    {
      localObject1 = info.getAttribute(paramString);
      if (localObject1 == null) {
        throw new AttributeNotFoundException(" Cannot find attribute " + paramString);
      }
      localObject2 = ((ModelMBeanAttributeInfo)localObject1).getDescriptor();
      if (localObject2 == null) {
        throw new AttributeNotFoundException("Cannot find attribute " + paramString + " descriptor");
      }
      localObject3 = (String)((Descriptor)localObject2).getFieldValue("getMethod");
      if (localObject3 == null) {
        throw new AttributeNotFoundException("Cannot find attribute " + paramString + " get method name");
      }
      Object localObject4 = null;
      Object localObject5 = null;
      try
      {
        localObject4 = this;
        localMethod = localObject4.getClass().getMethod((String)localObject3, NO_ARGS_PARAM_SIG);
      }
      catch (NoSuchMethodException localNoSuchMethodException1)
      {
        localObject5 = localNoSuchMethodException1;
      }
      if ((localMethod == null) && (resource != null)) {
        try
        {
          localObject4 = resource;
          localMethod = localObject4.getClass().getMethod((String)localObject3, NO_ARGS_PARAM_SIG);
          localObject5 = null;
        }
        catch (NoSuchMethodException localNoSuchMethodException2)
        {
          localObject5 = localNoSuchMethodException2;
        }
      }
      if (localObject5 != null) {
        throw new ReflectionException((Exception)localObject5, "Cannot find getter method " + (String)localObject3);
      }
      getAttMap.put(paramString, localMethod);
    }
    Object localObject1 = null;
    try
    {
      localObject2 = localMethod.getDeclaringClass();
      if (((Class)localObject2).isAssignableFrom(getClass())) {
        localObject1 = localMethod.invoke(this, NO_ARGS_PARAM);
      } else {
        localObject1 = localMethod.invoke(resource, NO_ARGS_PARAM);
      }
    }
    catch (InvocationTargetException localInvocationTargetException)
    {
      localObject3 = localInvocationTargetException.getTargetException();
      if (localObject3 == null) {
        localObject3 = localInvocationTargetException;
      }
      if ((localObject3 instanceof RuntimeException)) {
        throw new RuntimeOperationsException((RuntimeException)localObject3, "Exception invoking method " + paramString);
      }
      if ((localObject3 instanceof Error)) {
        throw new RuntimeErrorException((Error)localObject3, "Error invoking method " + paramString);
      }
      throw new MBeanException(localInvocationTargetException, "Exception invoking method " + paramString);
    }
    catch (Exception localException)
    {
      throw new MBeanException(localException, "Exception invoking method " + paramString);
    }
    return localObject1;
  }
  
  public AttributeList getAttributes(String[] paramArrayOfString)
  {
    if (paramArrayOfString == null) {
      throw new RuntimeOperationsException(new IllegalArgumentException("Attribute names list is null"), "Attribute names list is null");
    }
    AttributeList localAttributeList = new AttributeList();
    for (int i = 0; i < paramArrayOfString.length; i++) {
      try
      {
        localAttributeList.add(new Attribute(paramArrayOfString[i], getAttribute(paramArrayOfString[i])));
      }
      catch (Exception localException) {}
    }
    return localAttributeList;
  }
  
  public MBeanInfo getMBeanInfo()
  {
    if (info == null) {
      return null;
    }
    return (MBeanInfo)info.clone();
  }
  
  public Object invoke(String paramString, Object[] paramArrayOfObject, String[] paramArrayOfString)
    throws MBeanException, ReflectionException
  {
    if (((resource instanceof DynamicMBean)) && (!(resource instanceof BaseModelMBean))) {
      return ((DynamicMBean)resource).invoke(paramString, paramArrayOfObject, paramArrayOfString);
    }
    if (paramString == null) {
      throw new RuntimeOperationsException(new IllegalArgumentException("Method name is null"), "Method name is null");
    }
    WMSLogger localWMSLogger = WMSLoggerFactory.getLogger(BaseModelMBean.class);
    if (localWMSLogger.isDebugEnabled()) {
      localWMSLogger.debug("Invoke " + paramString);
    }
    MethodKey localMethodKey = new MethodKey(paramString, paramArrayOfString);
    Method localMethod = (Method)invokeAttMap.get(localMethodKey);
    Object localObject2;
    if (localMethod == null)
    {
      if (paramArrayOfObject == null) {
        paramArrayOfObject = new Object[0];
      }
      if (paramArrayOfString == null) {
        paramArrayOfString = new String[0];
      }
      if (paramArrayOfObject.length != paramArrayOfString.length) {
        throw new RuntimeOperationsException(new IllegalArgumentException("Inconsistent arguments and signature"), "Inconsistent arguments and signature");
      }
      localObject1 = info.getOperation(paramString);
      if (localObject1 == null) {
        throw new MBeanException(new ServiceNotFoundException("Cannot find operation " + paramString), "Cannot find operation " + paramString);
      }
      Class[] arrayOfClass = new Class[paramArrayOfString.length];
      for (int i = 0; i < paramArrayOfString.length; i++) {
        arrayOfClass[i] = getAttributeClass(paramArrayOfString[i]);
      }
      localObject2 = null;
      Object localObject3 = null;
      try
      {
        localObject2 = this;
        localMethod = localObject2.getClass().getMethod(paramString, arrayOfClass);
      }
      catch (NoSuchMethodException localNoSuchMethodException1)
      {
        localObject3 = localNoSuchMethodException1;
      }
      try
      {
        if ((localMethod == null) && (resource != null))
        {
          localObject2 = resource;
          localMethod = localObject2.getClass().getMethod(paramString, arrayOfClass);
        }
      }
      catch (NoSuchMethodException localNoSuchMethodException2)
      {
        localObject3 = localNoSuchMethodException2;
      }
      if (localMethod == null) {
        throw new ReflectionException((Exception)localObject3, "Cannot find method " + paramString + " with this signature");
      }
      invokeAttMap.put(localMethodKey, localMethod);
    }
    Object localObject1 = null;
    try
    {
      if (localMethod.getDeclaringClass().isAssignableFrom(getClass())) {
        localObject1 = localMethod.invoke(this, paramArrayOfObject);
      } else {
        localObject1 = localMethod.invoke(resource, paramArrayOfObject);
      }
    }
    catch (InvocationTargetException localInvocationTargetException)
    {
      localObject2 = localInvocationTargetException.getTargetException();
      localWMSLogger.error("Exception invoking method " + paramString, (Throwable)localObject2);
      if (localObject2 == null) {
        localObject2 = localInvocationTargetException;
      }
      if ((localObject2 instanceof RuntimeException)) {
        throw new RuntimeOperationsException((RuntimeException)localObject2, "Exception invoking method " + paramString);
      }
      if ((localObject2 instanceof Error)) {
        throw new RuntimeErrorException((Error)localObject2, "Error invoking method " + paramString);
      }
      throw new MBeanException((Exception)localObject2, "Exception invoking method " + paramString);
    }
    catch (Exception localException)
    {
      localWMSLogger.error("Exception invoking method " + paramString, localException);
      throw new MBeanException(localException, "Exception invoking method " + paramString);
    }
    return localObject1;
  }
  
  private Class getAttributeClass(String paramString)
    throws ReflectionException
  {
    if (paramString.equals(Boolean.TYPE.getName())) {
      return Boolean.TYPE;
    }
    if (paramString.equals(Byte.TYPE.getName())) {
      return Byte.TYPE;
    }
    if (paramString.equals(Character.TYPE.getName())) {
      return Character.TYPE;
    }
    if (paramString.equals(Double.TYPE.getName())) {
      return Double.TYPE;
    }
    if (paramString.equals(Float.TYPE.getName())) {
      return Float.TYPE;
    }
    if (paramString.equals(Integer.TYPE.getName())) {
      return Integer.TYPE;
    }
    if (paramString.equals(Long.TYPE.getName())) {
      return Long.TYPE;
    }
    if (paramString.equals(Short.TYPE.getName())) {
      return Short.TYPE;
    }
    try
    {
      ClassLoader localClassLoader = Thread.currentThread().getContextClassLoader();
      if (localClassLoader != null) {
        return localClassLoader.loadClass(paramString);
      }
    }
    catch (ClassNotFoundException localClassNotFoundException1) {}
    try
    {
      return Class.forName(paramString);
    }
    catch (ClassNotFoundException localClassNotFoundException2)
    {
      throw new ReflectionException(localClassNotFoundException2, "Cannot find Class for " + paramString);
    }
  }
  
  public void setAttribute(Attribute paramAttribute)
    throws AttributeNotFoundException, MBeanException, ReflectionException
  {
    WMSLogger localWMSLogger = WMSLoggerFactory.getLogger(BaseModelMBean.class);
    if (localWMSLogger.isDebugEnabled()) {
      localWMSLogger.debug("Setting attribute " + this + " " + paramAttribute);
    }
    if (((resource instanceof DynamicMBean)) && (!(resource instanceof BaseModelMBean)))
    {
      try
      {
        ((DynamicMBean)resource).setAttribute(paramAttribute);
      }
      catch (InvalidAttributeValueException localInvalidAttributeValueException)
      {
        throw new MBeanException(localInvalidAttributeValueException);
      }
      return;
    }
    if (paramAttribute == null) {
      throw new RuntimeOperationsException(new IllegalArgumentException("Attribute is null"), "Attribute is null");
    }
    String str1 = paramAttribute.getName();
    Object localObject1 = paramAttribute.getValue();
    if (str1 == null) {
      throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name is null"), "Attribute name is null");
    }
    ModelMBeanAttributeInfo localModelMBeanAttributeInfo = info.getAttribute(str1);
    if (localModelMBeanAttributeInfo == null) {
      throw new AttributeNotFoundException("Cannot find attribute " + str1);
    }
    Descriptor localDescriptor = localModelMBeanAttributeInfo.getDescriptor();
    if (localDescriptor == null) {
      throw new AttributeNotFoundException("Cannot find attribute " + str1 + " descriptor");
    }
    Object localObject2 = null;
    if (getAttMap.get(str1) != null) {
      localObject2 = getAttribute(str1);
    }
    Method localMethod = (Method)setAttMap.get(str1);
    Object localObject4;
    if (localMethod == null)
    {
      localObject3 = (String)localDescriptor.getFieldValue("setMethod");
      if (localObject3 == null) {
        throw new AttributeNotFoundException("Cannot find attribute " + str1 + " set method name");
      }
      String str2 = localModelMBeanAttributeInfo.getType();
      
      localObject4 = new Class[] { getAttributeClass(str2) };
      
      Object localObject5 = null;
      Object localObject6 = null;
      try
      {
        localObject5 = this;
        localMethod = localObject5.getClass().getMethod((String)localObject3, (Class[])localObject4);
      }
      catch (NoSuchMethodException localNoSuchMethodException1)
      {
        localObject6 = localNoSuchMethodException1;
      }
      if ((localMethod == null) && (resource != null)) {
        try
        {
          localObject5 = resource;
          localMethod = localObject5.getClass().getMethod((String)localObject3, (Class[])localObject4);
          localObject6 = null;
        }
        catch (NoSuchMethodException localNoSuchMethodException2)
        {
          if (localWMSLogger.isDebugEnabled()) {
            localWMSLogger.debug("Method not found in resource " + resource);
          }
          localObject6 = localNoSuchMethodException2;
        }
      }
      if (localObject6 != null) {
        throw new ReflectionException((Exception)localObject6, "Cannot find setter method " + (String)localObject3 + " " + resource);
      }
      setAttMap.put(str1, localMethod);
    }
    Object localObject3 = null;
    try
    {
      if (localMethod.getDeclaringClass().isAssignableFrom(getClass())) {
        localObject3 = localMethod.invoke(this, new Object[] { localObject1 });
      } else {
        localObject3 = localMethod.invoke(resource, new Object[] { localObject1 });
      }
    }
    catch (InvocationTargetException localInvocationTargetException)
    {
      localObject4 = localInvocationTargetException.getTargetException();
      if (localObject4 == null) {
        localObject4 = localInvocationTargetException;
      }
      if ((localObject4 instanceof RuntimeException)) {
        throw new RuntimeOperationsException((RuntimeException)localObject4, "Exception invoking method " + str1);
      }
      if ((localObject4 instanceof Error)) {
        throw new RuntimeErrorException((Error)localObject4, "Error invoking method " + str1);
      }
      throw new MBeanException(localInvocationTargetException, "Exception invoking method " + str1);
    }
    catch (Exception localException1)
    {
      localWMSLogger.error("Exception invoking method " + str1, localException1);
      throw new MBeanException(localException1, "Exception invoking method " + str1);
    }
    try
    {
      sendAttributeChangeNotification(new Attribute(str1, localObject2), paramAttribute);
    }
    catch (Exception localException2)
    {
      localWMSLogger.error("Error sending notification " + str1, localException2);
    }
    attributes.put(str1, localObject1);
    if (source != null) {
      source.updateField(oname, str1, localObject1);
    }
  }
  
  public String toString()
  {
    if (resource == null) {
      return "BaseModelMbean[" + resourceType + "]";
    }
    return resource.toString();
  }
  
  public AttributeList setAttributes(AttributeList paramAttributeList)
  {
    if (paramAttributeList == null) {
      throw new RuntimeOperationsException(new IllegalArgumentException("Attributes list is null"), "Attributes list is null");
    }
    AttributeList localAttributeList = new AttributeList();
    String[] arrayOfString = new String[paramAttributeList.size()];
    int i = 0;
    Iterator localIterator = paramAttributeList.iterator();
    while (localIterator.hasNext())
    {
      Attribute localAttribute = (Attribute)localIterator.next();
      arrayOfString[(i++)] = localAttribute.getName();
      try
      {
        setAttribute(localAttribute);
      }
      catch (Exception localException) {}
    }
    return getAttributes(arrayOfString);
  }
  
  public Object getManagedResource()
    throws InstanceNotFoundException, InvalidTargetObjectTypeException, MBeanException, RuntimeOperationsException
  {
    if (resource == null) {
      throw new RuntimeOperationsException(new IllegalArgumentException("Managed resource is null"), "Managed resource is null");
    }
    return resource;
  }
  
  public void setManagedResource(Object paramObject, String paramString)
    throws InstanceNotFoundException, InvalidTargetObjectTypeException, MBeanException, RuntimeOperationsException
  {
    if (paramObject == null) {
      throw new RuntimeOperationsException(new IllegalArgumentException("Managed resource is null"), "Managed resource is null");
    }
    if (!"objectreference".equalsIgnoreCase(paramString)) {
      throw new InvalidTargetObjectTypeException(paramString);
    }
    resource = paramObject;
    resourceType = paramObject.getClass().getName();
    try
    {
      Method localMethod = paramObject.getClass().getMethod("setModelMBean", new Class[] { ModelMBean.class });
      if (localMethod != null) {
        localMethod.invoke(paramObject, new Object[] { this });
      }
    }
    catch (NoSuchMethodException localNoSuchMethodException) {}catch (Throwable localThrowable)
    {
      WMSLoggerFactory.getLogger(BaseModelMBean.class).error("Can't set model mbean ", localThrowable);
    }
  }
  
  public void setModelMBeanInfo(ModelMBeanInfo paramModelMBeanInfo)
    throws MBeanException, RuntimeOperationsException
  {
    if (paramModelMBeanInfo == null) {
      throw new RuntimeOperationsException(new IllegalArgumentException("ModelMBeanInfo is null"), "ModelMBeanInfo is null");
    }
    if (!isModelMBeanInfoValid(paramModelMBeanInfo)) {
      throw new RuntimeOperationsException(new IllegalArgumentException("ModelMBeanInfo is invalid"), "ModelMBeanInfo is invalid");
    }
    info = ((ModelMBeanInfo)paramModelMBeanInfo.clone());
  }
  
  public void addAttributeChangeNotificationListener(NotificationListener paramNotificationListener, String paramString, Object paramObject)
    throws IllegalArgumentException
  {
    if (paramNotificationListener == null) {
      throw new IllegalArgumentException("Listener is null");
    }
    if (attributeBroadcaster == null) {
      attributeBroadcaster = new BaseNotificationBroadcaster();
    }
    BaseAttributeFilter localBaseAttributeFilter = new BaseAttributeFilter(paramString);
    attributeBroadcaster.addNotificationListener(paramNotificationListener, localBaseAttributeFilter, paramObject);
  }
  
  public void removeAttributeChangeNotificationListener(NotificationListener paramNotificationListener, String paramString)
    throws ListenerNotFoundException
  {
    if (paramNotificationListener == null) {
      throw new IllegalArgumentException("Listener is null");
    }
    if (attributeBroadcaster == null) {
      attributeBroadcaster = new BaseNotificationBroadcaster();
    }
    attributeBroadcaster.removeNotificationListener(paramNotificationListener);
  }
  
  public void removeAttributeChangeNotificationListener(NotificationListener paramNotificationListener, String paramString, Object paramObject)
    throws ListenerNotFoundException
  {
    removeAttributeChangeNotificationListener(paramNotificationListener, paramString);
  }
  
  public void sendAttributeChangeNotification(AttributeChangeNotification paramAttributeChangeNotification)
    throws MBeanException, RuntimeOperationsException
  {
    if (paramAttributeChangeNotification == null) {
      throw new RuntimeOperationsException(new IllegalArgumentException("Notification is null"), "Notification is null");
    }
    if (attributeBroadcaster == null) {
      return;
    }
    attributeBroadcaster.sendNotification(paramAttributeChangeNotification);
  }
  
  public void sendAttributeChangeNotification(Attribute paramAttribute1, Attribute paramAttribute2)
    throws MBeanException, RuntimeOperationsException
  {
    String str = null;
    if (paramAttribute2.getValue() != null) {
      str = paramAttribute2.getValue().getClass().getName();
    } else if (paramAttribute1.getValue() != null) {
      str = paramAttribute1.getValue().getClass().getName();
    } else {
      return;
    }
    AttributeChangeNotification localAttributeChangeNotification = new AttributeChangeNotification(this, 1L, System.currentTimeMillis(), "Attribute value has changed", paramAttribute1.getName(), str, paramAttribute1.getValue(), paramAttribute2.getValue());
    
    sendAttributeChangeNotification(localAttributeChangeNotification);
  }
  
  public void sendNotification(Notification paramNotification)
    throws MBeanException, RuntimeOperationsException
  {
    if (paramNotification == null) {
      throw new RuntimeOperationsException(new IllegalArgumentException("Notification is null"), "Notification is null");
    }
    if (generalBroadcaster == null) {
      return;
    }
    generalBroadcaster.sendNotification(paramNotification);
  }
  
  public void sendNotification(String paramString)
    throws MBeanException, RuntimeOperationsException
  {
    if (paramString == null) {
      throw new RuntimeOperationsException(new IllegalArgumentException("Message is null"), "Message is null");
    }
    Notification localNotification = new Notification("jmx.modelmbean.generic", this, 1L, paramString);
    
    sendNotification(localNotification);
  }
  
  public void addNotificationListener(NotificationListener paramNotificationListener, NotificationFilter paramNotificationFilter, Object paramObject)
    throws IllegalArgumentException
  {
    if (paramNotificationListener == null) {
      throw new IllegalArgumentException("Listener is null");
    }
    if (generalBroadcaster == null) {
      generalBroadcaster = new BaseNotificationBroadcaster();
    }
    generalBroadcaster.addNotificationListener(paramNotificationListener, paramNotificationFilter, paramObject);
    if (attributeBroadcaster == null) {
      attributeBroadcaster = new BaseNotificationBroadcaster();
    }
    attributeBroadcaster.addNotificationListener(paramNotificationListener, paramNotificationFilter, paramObject);
  }
  
  public MBeanNotificationInfo[] getNotificationInfo()
  {
    MBeanNotificationInfo[] arrayOfMBeanNotificationInfo1 = info.getNotifications();
    if (arrayOfMBeanNotificationInfo1 == null) {
      arrayOfMBeanNotificationInfo1 = new MBeanNotificationInfo[0];
    }
    MBeanNotificationInfo[] arrayOfMBeanNotificationInfo2 = new MBeanNotificationInfo[arrayOfMBeanNotificationInfo1.length + 2];
    
    DescriptorSupport localDescriptorSupport = null;
    
    localDescriptorSupport = new DescriptorSupport(new String[] { "name=GENERIC", "descriptorType=notification", "log=T", "severity=5", "displayName=jmx.modelmbean.generic" });
    
    arrayOfMBeanNotificationInfo2[0] = new ModelMBeanNotificationInfo(new String[] { "jmx.modelmbean.generic" }, "GENERIC", "Text message notification from the managed resource", localDescriptorSupport);
    
    localDescriptorSupport = new DescriptorSupport(new String[] { "name=ATTRIBUTE_CHANGE", "descriptorType=notification", "log=T", "severity=5", "displayName=jmx.attribute.change" });
    
    arrayOfMBeanNotificationInfo2[1] = new ModelMBeanNotificationInfo(new String[] { "jmx.attribute.change" }, "ATTRIBUTE_CHANGE", "Observed MBean attribute value has changed", localDescriptorSupport);
    
    System.arraycopy(arrayOfMBeanNotificationInfo1, 0, arrayOfMBeanNotificationInfo2, 2, arrayOfMBeanNotificationInfo1.length);
    return arrayOfMBeanNotificationInfo2;
  }
  
  public void removeNotificationListener(NotificationListener paramNotificationListener)
    throws ListenerNotFoundException
  {
    if (paramNotificationListener == null) {
      throw new IllegalArgumentException("Listener is null");
    }
    if (generalBroadcaster == null) {
      generalBroadcaster = new BaseNotificationBroadcaster();
    }
    generalBroadcaster.removeNotificationListener(paramNotificationListener);
  }
  
  public void removeNotificationListener(NotificationListener paramNotificationListener, Object paramObject)
    throws ListenerNotFoundException
  {
    removeNotificationListener(paramNotificationListener);
  }
  
  public void removeNotificationListener(NotificationListener paramNotificationListener, NotificationFilter paramNotificationFilter, Object paramObject)
    throws ListenerNotFoundException
  {
    removeNotificationListener(paramNotificationListener);
  }
  
  public void load()
    throws InstanceNotFoundException, MBeanException, RuntimeOperationsException
  {
    throw new MBeanException(new IllegalStateException("Persistence is not supported"), "Persistence is not supported");
  }
  
  public void store()
    throws InstanceNotFoundException, MBeanException, RuntimeOperationsException
  {
    throw new MBeanException(new IllegalStateException("Persistence is not supported"), "Persistence is not supported");
  }
  
  public void setModeledType(String paramString)
  {
    initModelInfo(paramString);
    createResource();
  }
  
  protected void initModelInfo(String paramString)
  {
    try
    {
      WMSLogger localWMSLogger = WMSLoggerFactory.getLogger(BaseModelMBean.class);
      if (localWMSLogger.isDebugEnabled()) {
        localWMSLogger.debug("setModeledType " + paramString);
      }
      localWMSLogger.debug("Set model Info " + paramString);
      if (paramString == null) {
        return;
      }
      resourceType = paramString;
      
      Class localClass = null;
      try
      {
        localClass = Class.forName(paramString);
      }
      catch (Throwable localThrowable2)
      {
        localWMSLogger.debug("Error creating class " + localThrowable2);
      }
      ManagedBean localManagedBean = getRegistry().findManagedBean(localClass, paramString);
      if (localManagedBean == null) {
        return;
      }
      setModelMBeanInfo(localManagedBean.createMBeanInfo());
    }
    catch (Throwable localThrowable1)
    {
      WMSLoggerFactory.getLogger(BaseModelMBean.class).error("TCL: " + Thread.currentThread().getContextClassLoader(), localThrowable1);
    }
  }
  
  protected void createResource()
  {
    try
    {
      Class localClass = null;
      try
      {
        localClass = Class.forName(resourceType);
        resource = localClass.newInstance();
      }
      catch (Throwable localThrowable2)
      {
        WMSLoggerFactory.getLogger(BaseModelMBean.class).error("Error creating class " + localThrowable2);
      }
    }
    catch (Throwable localThrowable1)
    {
      WMSLoggerFactory.getLogger(BaseModelMBean.class).error("TCL: " + Thread.currentThread().getContextClassLoader(), localThrowable1);
    }
  }
  
  public String getModelerType()
  {
    return resourceType;
  }
  
  public String getClassName()
  {
    return getModelerType();
  }
  
  public ObjectName getJmxName()
  {
    return oname;
  }
  
  public String getObjectName()
  {
    if (oname != null) {
      return oname.toString();
    }
    return null;
  }
  
  public void setRegistry(Registry paramRegistry)
  {
    registry = paramRegistry;
  }
  
  public Registry getRegistry()
  {
    if (registry == null) {
      registry = Registry.getRegistry();
    }
    return registry;
  }
  
  protected ModelMBeanInfo createDefaultModelMBeanInfo()
  {
    return new ModelMBeanInfoSupport(getClass().getName(), "Default ModelMBean", null, null, null, null);
  }
  
  protected boolean isModelMBeanInfoValid(ModelMBeanInfo paramModelMBeanInfo)
  {
    return true;
  }
  
  public ObjectName preRegister(MBeanServer paramMBeanServer, ObjectName paramObjectName)
    throws Exception
  {
    oname = paramObjectName;
    if ((resource instanceof MBeanRegistration)) {
    
1 2 3 4 5 6

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd