hermes-1.14

16:36:24.496 INFO  jd.cli.Main - Decompiling hermes-1.14.jar
package hermes.ext.activemq;

import hermes.Domain;
import hermes.Hermes;
import hermes.HermesAdmin;
import hermes.HermesException;
import hermes.browser.HermesBrowser;
import hermes.config.DestinationConfig;
import hermes.ext.HermesAdminSupport;
import hermes.impl.ConfigDAO;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.QueueBrowser;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanInfo;
import javax.management.MBeanServerConnection;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import org.apache.log4j.Logger;

public class ActiveMQAdmin
  extends HermesAdminSupport
  implements HermesAdmin
{
  private static final Logger log = Logger.getLogger(ActiveMQAdmin.class);
  private JMXServiceURL serviceURL;
  private JMXConnector connector;
  private MBeanServerConnection server;
  private String[] queueProperties = { "ConsumerCount", "EnqueueCount", "DequeueCount", "MemoryLimit", "MemoryPercentageUsed", "QueueSize" };
  private ActiveMQAdminFactory factory;
  
  public ActiveMQAdmin(ActiveMQAdminFactory factory, Hermes hermes, String brokerName, JMXServiceURL serviceURL)
  {
    super(hermes);
    
    this.serviceURL = serviceURL;
    this.factory = factory;
  }
  
  public int getDepth(DestinationConfig destination)
    throws JMSException
  {
    try
    {
      if (destination.getDomain().intValue() == Domain.QUEUE.getId())
      {
        ObjectName objectName = getDestinationObjectName(destination);
        return ((Long)getConnection().getAttribute(objectName, "QueueSize")).intValue();
      }
      if ((destination.getDomain().intValue() == Domain.TOPIC.getId()) && (destination.isDurable()))
      {
        ObjectName objectName = getDestinationObjectName(destination);
        return ((Integer)getConnection().getAttribute(objectName, "PendingQueueSize")).intValue();
      }
      return 0;
    }
    catch (Exception ex)
    {
      close();
      
      log.error(ex.getMessage(), ex);
      throw new HermesException(ex);
    }
  }
  
  public QueueBrowser createDurableSubscriptionBrowser(DestinationConfig dConfig)
    throws JMSException
  {
    try
    {
      return super.createDurableSubscriptionBrowser(dConfig);
    }
    catch (Exception ex)
    {
      throw new HermesException(ex);
    }
  }
  
  public Object getAttributeQuietly(ObjectName objectName, String attribute)
  {
    try
    {
      return getConnection().getAttribute(objectName, attribute);
    }
    catch (Exception e)
    {
      log.error(e.getMessage(), e);
      return e.getMessage();
    }
  }
  
  public Collection<DestinationConfig> discoverDestinationConfigs()
    throws JMSException
  {
    Collection<DestinationConfig> rval = new HashSet();
    try
    {
      ObjectName[] queues = (ObjectName[])getConnection().getAttribute(getBrokerObjectName(), "Queues");
      for (ObjectName queue : queues)
      {
        String name = (String)getConnection().getAttribute(queue, "Name");
        
        rval.add(HermesBrowser.getConfigDAO().createDestinationConfig(name, Domain.QUEUE));
      }
      try
      {
        ObjectName[] tempQueues = (ObjectName[])getConnection().getAttribute(getBrokerObjectName(), "TemporaryQueues");
        for (ObjectName queue : tempQueues)
        {
          String name = (String)getConnection().getAttribute(queue, "Name");
          
          rval.add(HermesBrowser.getConfigDAO().createDestinationConfig(name, Domain.QUEUE));
        }
      }
      catch (Exception ex)
      {
        log.error(ex.getMessage(), ex);
      }
      ObjectName[] topics = (ObjectName[])getConnection().getAttribute(getBrokerObjectName(), "Topics");
      for (ObjectName topic : topics)
      {
        String name = (String)getConnection().getAttribute(topic, "Name");
        
        rval.add(HermesBrowser.getConfigDAO().createDestinationConfig(name, Domain.TOPIC));
      }
    }
    catch (Exception ex)
    {
      throw new HermesException(ex);
    }
    rval.addAll(_discoverDurableSubscriptions());
    return rval;
  }
  
  protected Collection<DestinationConfig> _discoverDurableSubscriptions()
    throws JMSException
  {
    Collection<DestinationConfig> rval = new HashSet();
    try
    {
      ObjectName[] subs = (ObjectName[])getConnection().getAttribute(getBrokerObjectName(), "DurableTopicSubscribers");
      for (ObjectName sub : subs)
      {
        String name = (String)getConnection().getAttribute(sub, "DestinationName");
        String subscriptionName = (String)getConnection().getAttribute(sub, "SubscriptionName");
        DestinationConfig dConfig = HermesBrowser.getConfigDAO().createDestinationConfig(name, Domain.TOPIC);
        dConfig.setDurable(Boolean.valueOf(true));
        dConfig.setClientID(subscriptionName);
        
        rval.add(dConfig);
      }
    }
    catch (Exception e)
    {
      throw new HermesException(e);
    }
    try
    {
      ObjectName[] subs = (ObjectName[])getConnection().getAttribute(getBrokerObjectName(), "InactiveDurableTopicSubscribers");
      for (ObjectName sub : subs)
      {
        String name = (String)getConnection().getAttribute(sub, "DestinationName");
        String subscriptionName = (String)getConnection().getAttribute(sub, "SubscriptionName");
        DestinationConfig dConfig = HermesBrowser.getConfigDAO().createDestinationConfig(name, Domain.TOPIC);
        dConfig.setDurable(Boolean.valueOf(true));
        dConfig.setClientID(subscriptionName);
        
        rval.add(dConfig);
      }
    }
    catch (Exception e)
    {
      throw new HermesException(e);
    }
    return rval;
  }
  
  public Map getStatistics(DestinationConfig destination)
    throws JMSException
  {
    Map<String, Object> rval = new HashMap();
    try
    {
      ObjectName objectName = getDestinationObjectName(destination);
      MBeanInfo objectInfo = getConnection().getMBeanInfo(objectName);
      for (MBeanAttributeInfo info : objectInfo.getAttributes())
      {
        Object o = getConnection().getAttribute(objectName, info.getName());
        rval.put(info.getName(), o);
      }
    }
    catch (Exception ex)
    {
      close();
      log.error(ex.getMessage(), ex);
      throw new HermesException(ex);
    }
    return rval;
  }
  
  private ObjectName getDestinationObjectName(DestinationConfig destination)
    throws MalformedObjectNameException, NullPointerException, JMSException
  {
    if (destination.getDomain().intValue() == Domain.QUEUE.getId()) {
      return new ObjectName("org.apache.activemq:BrokerName=" + factory.getBrokerName() + ",Type=Queue,Destination=" + destination.getName());
    }
    if (destination.isDurable()) {
      try
      {
        return new ObjectName("org.apache.activemq:BrokerName=" + factory.getBrokerName() + ",Type=Subscription,active=true,name=" + getHermes().getConnection().getClientID() + "_" + destination.getClientID());
      }
      catch (MalformedObjectNameException e)
      {
        return new ObjectName("org.apache.activemq:BrokerName=" + factory.getBrokerName() + ",Type=Subscription,active=false,name=" + getHermes().getConnection().getClientID() + "_" + destination.getClientID());
      }
    }
    return new ObjectName("org.apache.activemq:BrokerName=" + factory.getBrokerName() + ",Type=Topic,Destination=" + destination.getName());
  }
  
  private ObjectName getBrokerObjectName()
    throws MalformedObjectNameException, NullPointerException
  {
    return new ObjectName("org.apache.activemq:BrokerName=" + factory.getBrokerName() + ",Type=Broker");
  }
  
  public synchronized void close()
    throws JMSException
  {
    try
    {
      if (connector != null)
      {
        connector.close();
        
        log.debug("closed ActiveMQ JMX connection to " + factory.getBrokerName());
      }
    }
    catch (IOException ex)
    {
      log.error(ex.getMessage(), ex);
    }
    finally
    {
      connector = null;
      server = null;
    }
  }
  
  private Map getMap()
  {
    if (factory.getUsername() == null) {
      return Collections.EMPTY_MAP;
    }
    Map rval = new HashMap();
    rval.put("jmx.remote.credentials", new String[] { factory.getUsername(), factory.getPassword() });
    return rval;
  }
  
  private synchronized void connect()
    throws JMSException
  {
    close();
    try
    {
      connector = JMXConnectorFactory.connect(serviceURL, getMap());
      server = connector.getMBeanServerConnection();
    }
    catch (Exception ex)
    {
      throw new HermesException(ex);
    }
  }
  
  private synchronized MBeanServerConnection getConnection()
    throws JMSException
  {
    if (server == null) {
      connect();
    }
    return server;
  }
}

/* Location:
 * Qualified Name:     classes-ext.activemq.hermes.ext.activemq.ActiveMQAdmin
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package hermes.ext.activemq;

import hermes.Hermes;
import hermes.HermesAdmin;
import hermes.HermesAdminFactory;
import hermes.HermesException;
import java.net.MalformedURLException;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.management.remote.JMXServiceURL;
import javax.naming.NamingException;

public class ActiveMQAdminFactory
  implements HermesAdminFactory
{
  private static String DEFAULT_URL = "service:jmx:rmi:///jndi/rmi://localhost:1616/jmxrmi";
  private String serviceURL;
  private String brokerName = "localhost";
  private String username;
  private String password;
  
  public HermesAdmin createSession(Hermes hermes, ConnectionFactory connectionFactory)
    throws JMSException, NamingException
  {
    try
    {
      return createHermesAdmin(hermes);
    }
    catch (MalformedURLException e)
    {
      throw new HermesException(e);
    }
  }
  
  private ActiveMQAdmin createHermesAdmin(Hermes hermes)
    throws MalformedURLException
  {
    if (serviceURL == null) {
      return new ActiveMQAdmin(this, hermes, brokerName, new JMXServiceURL(DEFAULT_URL));
    }
    return new ActiveMQAdmin(this, hermes, brokerName, new JMXServiceURL(serviceURL));
  }
  
  public String getBrokerName()
  {
    return brokerName;
  }
  
  public void setBrokerName(String brokerName)
  {
    this.brokerName = brokerName;
  }
  
  public String getServiceURL()
  {
    return serviceURL;
  }
  
  public void setServiceURL(String serviceURL)
  {
    this.serviceURL = serviceURL;
  }
  
  public String getPassword()
  {
    return password;
  }
  
  public void setPassword(String password)
  {
    this.password = password;
  }
  
  public String getUsername()
  {
    return username;
  }
  
  public void setUsername(String username)
  {
    this.username = username;
  }
}

/* Location:
 * Qualified Name:     classes-ext.activemq.hermes.ext.activemq.ActiveMQAdminFactory
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package hermes.ext.arjuna;

import com.arjuna.ams.admin.Admin;
import com.arjuna.ams.admin.AdminException;
import com.arjuna.ams.admin.AuthorizationAdminException;
import hermes.Domain;
import hermes.Hermes;
import hermes.HermesAdmin;
import hermes.HermesException;
import hermes.JNDIConnectionFactory;
import hermes.config.DestinationConfig;
import hermes.ext.HermesAdminSupport;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Hashtable;
import java.util.Map;
import javax.jms.JMSException;
import javax.jms.QueueConnectionFactory;
import javax.jms.TopicConnectionFactory;
import javax.naming.Context;
import javax.naming.NamingException;
import org.apache.log4j.Logger;

public class ArjunaMSAdmin
  extends HermesAdminSupport
  implements HermesAdmin
{
  private static final Logger log = Logger.getLogger(ArjunaMSAdmin.class);
  private static final String NAME = "Name";
  private Context context;
  private Admin admin;
  private ArjunaMSAdminFactory factory;
  
  public ArjunaMSAdmin(Hermes hermes, ArjunaMSAdminFactory factory, Context context)
  {
    super(hermes);
    
    this.context = context;
    this.factory = factory;
  }
  
  protected synchronized Admin getAdmin()
    throws JMSException
  {
    try
    {
      if (admin == null) {
        admin = ((Admin)context.lookup(factory.getAdminBinding()));
      }
    }
    catch (NamingException ex)
    {
      throw new HermesException(ex);
    }
    return admin;
  }
  
  public int getDepth(DestinationConfig dest)
    throws JMSException
  {
    try
    {
      Map stats = getAdmin().getDestinationStatistics(getRealDestinationName(dest));
      return ((Integer)stats.get("NumMessagesOustanding")).intValue();
    }
    catch (AdminException e)
    {
      throw new HermesException(e);
    }
  }
  
  public void close()
    throws JMSException
  {
    if (admin != null)
    {
      admin.close();
      admin = null;
    }
  }
  
  public Map getStatistics(DestinationConfig destination)
    throws JMSException
  {
    try
    {
      return getAdmin().getDestinationStatistics(getRealDestinationName(destination));
    }
    catch (Exception e)
    {
      throw new HermesException(e);
    }
  }
  
  private DestinationConfig createDestinationConfig(Hashtable info, Domain domain)
  {
    DestinationConfig dConfig = new DestinationConfig();
    String name = (String)info.get("Name");
    
    dConfig.setName(name);
    dConfig.setDomain(Integer.valueOf(domain.getId()));
    
    return dConfig;
  }
  
  public Collection discoverDestinationConfigs()
    throws JMSException
  {
    try
    {
      if ((getHermes().getConnectionFactory() instanceof JNDIConnectionFactory)) {
        return super.discoverDestinationConfigs();
      }
      Collection rval = new ArrayList();
      if ((getHermes().getConnectionFactory() instanceof QueueConnectionFactory))
      {
        Hashtable[] queueDetails = getAdmin().getAllQueuesDetails();
        for (int i = 0; i < queueDetails.length; i++)
        {
          Hashtable t = queueDetails[i];
          
          rval.add(createDestinationConfig(t, Domain.QUEUE));
        }
      }
      else if ((getHermes().getConnectionFactory() instanceof TopicConnectionFactory))
      {
        Hashtable[] topicDetails = getAdmin().getAllTopicsDetails();
        for (int i = 0; i < topicDetails.length; i++)
        {
          Hashtable t = topicDetails[i];
          
          rval.add(createDestinationConfig(t, Domain.TOPIC));
          rval.addAll(discoverDurableSubscriptions((String)t.get("Name"), null));
        }
      }
      return rval;
    }
    catch (AuthorizationAdminException e)
    {
      throw new HermesException(e);
    }
    catch (AdminException e)
    {
      throw new HermesException(e);
    }
  }
}

/* Location:
 * Qualified Name:     classes-ext.arjuna.hermes.ext.arjuna.ArjunaMSAdmin
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package hermes.ext.arjuna;

import hermes.Hermes;
import hermes.HermesAdmin;
import hermes.HermesAdminFactory;
import hermes.HermesException;
import hermes.JNDIConnectionFactory;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.naming.NamingException;
import org.apache.log4j.Logger;

public class ArjunaMSAdminFactory
  implements HermesAdminFactory
{
  private static final Logger log = Logger.getLogger(ArjunaMSAdminFactory.class);
  private String adminBinding = "Admin";
  
  public HermesAdmin createSession(Hermes hermes, ConnectionFactory connectionFactory)
    throws JMSException, NamingException
  {
    if ((connectionFactory instanceof JNDIConnectionFactory))
    {
      JNDIConnectionFactory jndiCF = (JNDIConnectionFactory)connectionFactory;
      return new ArjunaMSAdmin(hermes, this, jndiCF.createContext());
    }
    throw new HermesException("Provider is not ArjunaMS");
  }
  
  public String getAdminBinding()
  {
    return adminBinding;
  }
  
  public void setAdminBinding(String adminBinding)
  {
    this.adminBinding = adminBinding;
  }
}

/* Location:
 * Qualified Name:     classes-ext.arjuna.hermes.ext.arjuna.ArjunaMSAdminFactory
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package hermes.ext.ems;

import com.tibco.tibjms.admin.DestinationInfo;
import com.tibco.tibjms.admin.DurableInfo;
import com.tibco.tibjms.admin.QueueInfo;
import com.tibco.tibjms.admin.StatData;
import com.tibco.tibjms.admin.TibjmsAdmin;
import com.tibco.tibjms.admin.TibjmsAdminException;
import com.tibco.tibjms.admin.TopicInfo;
import hermes.Domain;
import hermes.Hermes;
import hermes.HermesAdmin;
import hermes.HermesException;
import hermes.JNDIConnectionFactory;
import hermes.browser.HermesBrowser;
import hermes.config.DestinationConfig;
import hermes.ext.HermesAdminSupport;
import hermes.impl.ConfigDAO;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.TreeMap;
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
import javax.jms.TopicConnectionFactory;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.log4j.Logger;

public class TibcoEMSAdmin
  extends HermesAdminSupport
  implements HermesAdmin
{
  private static final Logger log = Logger.getLogger(TibcoEMSAdmin.class);
  private TibcoEMSAdminFactory factory;
  private TibjmsAdmin admin;
  
  public TibcoEMSAdmin(Hermes hermes, TibcoEMSAdminFactory factory)
  {
    super(hermes);
    
    this.factory = factory;
  }
  
  private synchronized TibjmsAdmin getAdmin()
    throws JMSException
  {
    if (admin == null) {
      admin = factory.createAdmin(getHermes().getConnectionFactory());
    }
    return admin;
  }
  
  public synchronized void close()
    throws JMSException
  {
    try
    {
      if (admin != null)
      {
        admin.close();
        admin = null;
      }
    }
    catch (TibjmsAdminException e)
    {
      throw new HermesException(e);
    }
  }
  
  public int getDepth(DestinationConfig destination)
    throws JMSException
  {
    if (destination.isDurable()) {
      try
      {
        DurableInfo info = getAdmin().getDurable(destination.getClientID(), getHermes().getConnection().getClientID());
        if (info != null) {
          return (int)info.getPendingMessageCount();
        }
        throw new HermesException("No durable information availble for clientID=" + getHermes().getConnection().getClientID() + ", durableName=" + destination.getClientID());
      }
      catch (TibjmsAdminException ex)
      {
        throw new HermesException(ex);
      }
    }
    DestinationInfo info = getDestinationInfo(destination);
    if (info != null) {
      return (int)info.getPendingMessageCount();
    }
    return 0;
  }
  
  public Map getStatistics(DestinationConfig destination)
    throws JMSException
  {
    try
    {
      DestinationInfo info = getDestinationInfo(destination);
      TreeMap rval = new TreeMap();
      
      rval.putAll(PropertyUtils.describe(info));
      
      rval.remove("inboundStatistics");
      rval.remove("outboundStatistics");
      
      rval.put("inboundByteRate", new Long(info.getInboundStatistics().getByteRate()));
      rval.put("inboundMessageRate", new Long(info.getInboundStatistics().getMessageRate()));
      rval.put("inboundTotalBytes", new Long(info.getInboundStatistics().getTotalBytes()));
      rval.put("inboundTotalMessages", new Long(info.getInboundStatistics().getTotalMessages()));
      
      rval.put("outboundByteRate", new Long(info.getOutboundStatistics().getByteRate()));
      rval.put("outboundMessageRate", new Long(info.getOutboundStatistics().getMessageRate()));
      rval.put("outboundTotalBytes", new Long(info.getOutboundStatistics().getTotalBytes()));
      rval.put("outboundTotalMessages", new Long(info.getOutboundStatistics().getTotalMessages()));
      
      return rval;
    }
    catch (IllegalAccessException e)
    {
      throw new HermesException(e);
    }
    catch (InvocationTargetException e)
    {
      throw new HermesException(e);
    }
    catch (NoSuchMethodException e)
    {
      throw new HermesException(e);
    }
  }
  
  private DestinationInfo getDestinationInfo(DestinationConfig dConfig)
    throws JMSException
  {
    try
    {
      if (dConfig.getDomain().intValue() == Domain.QUEUE.getId()) {
        return getAdmin().getQueue(getRealDestinationName(dConfig));
      }
      return getAdmin().getTopic(getRealDestinationName(dConfig));
    }
    catch (TibjmsAdminException e)
    {
      throw new HermesException(e);
    }
  }
  
  private DestinationInfo getDestinationInfo(Destination destination)
    throws JMSException
  {
    String name = getHermes().getDestinationName(destination);
    try
    {
      if ((destination instanceof Queue)) {
        return getAdmin().getQueue(name);
      }
      return getAdmin().getTopic(name);
    }
    catch (TibjmsAdminException e)
    {
      throw new HermesException(e);
    }
  }
  
  public int truncate(DestinationConfig dConfig)
    throws JMSException
  {
    try
    {
      int rval = getDepth(dConfig);
      if (dConfig.getDomain().intValue() == Domain.QUEUE.getId()) {
        getAdmin().purgeQueue(dConfig.getName());
      } else if (dConfig.isDurable()) {
        getAdmin().purgeDurable(dConfig.getClientID(), getHermes().getConnection().getClientID());
      } else {
        getAdmin().purgeTopic(dConfig.getName());
      }
      return rval;
    }
    catch (TibjmsAdminException e)
    {
      throw new HermesException(e);
    }
  }
  
  public Collection discoverDestinationConfigs()
    throws JMSException
  {
    try
    {
      Collection<DestinationConfig> rval = new ArrayList();
      
      boolean both = ((getHermes().getConnectionFactory() instanceof TopicConnectionFactory)) && ((getHermes().getConnectionFactory() instanceof TopicConnectionFactory));
      if ((!(getHermes().getConnectionFactory() instanceof TopicConnectionFactory)) || (both))
      {
        QueueInfo[] qinfos = getAdmin().getQueues();
        for (int i = 0; i < qinfos.length; i++) {
          if ((getHermes().getConnectionFactory() instanceof JNDIConnectionFactory))
          {
            if (qinfos[i].getJNDINames() != null) {
              for (int j = 0; j < qinfos[i].getJNDINames().length; j++)
              {
                DestinationConfig dConfig = HermesBrowser.getConfigDAO().createDestinationConfig();
                
                dConfig.setName(qinfos[i].getJNDINames()[j]);
                dConfig.setDomain(Integer.valueOf(Domain.QUEUE.getId()));
                rval.add(dConfig);
              }
            }
          }
          else
          {
            DestinationConfig dConfig = HermesBrowser.getConfigDAO().createDestinationConfig();
            
            dConfig.setName(qinfos[i].getName());
            dConfig.setDomain(Integer.valueOf(Domain.QUEUE.getId()));
            rval.add(dConfig);
          }
        }
      }
      if ((!(getHermes().getConnectionFactory() instanceof QueueConnectionFactory)) || (both))
      {
        TopicInfo[] tinfos = getAdmin().getTopics();
        for (int i = 0; i < tinfos.length; i++) {
          if ((getHermes().getConnectionFactory() instanceof JNDIConnectionFactory))
          {
            if (tinfos[i].getJNDINames() != null) {
              for (int j = 0; j < tinfos[i].getJNDINames().length; j++)
              {
                DestinationConfig dConfig = HermesBrowser.getConfigDAO().createDestinationConfig();
                
                dConfig.setName(tinfos[i].getJNDINames()[j]);
                dConfig.setDomain(Integer.valueOf(Domain.TOPIC.getId()));
                rval.add(dConfig);
                rval.addAll(discoverDurableSubscriptions(tinfos[i].getName(), tinfos[i].getJNDINames()[j]));
              }
            }
          }
          else
          {
            DestinationConfig dConfig = HermesBrowser.getConfigDAO().createDestinationConfig();
            dConfig.setName(tinfos[i].getName());
            
            dConfig.setDomain(Integer.valueOf(Domain.TOPIC.getId()));
            rval.add(dConfig);
            
            rval.addAll(discoverDurableSubscriptions(tinfos[i].getName(), null));
          }
        }
      }
      return rval;
    }
    catch (TibjmsAdminException e)
    {
      log.error(e.getMessage(), e);
      
      throw new HermesException(e);
    }
  }
  
  protected Collection<DestinationConfig> discoverDurableSubscriptions(String topicName, String jndiName)
    throws JMSException
  {
    try
    {
      Collection<DestinationConfig> rval = new ArrayList();
      DurableInfo[] dInfos = getAdmin().getDurables(topicName);
      for (int j = 0; j < dInfos.length; j++)
      {
        DurableInfo dInfo = dInfos[j];
        
        DestinationConfig dConfig = HermesBrowser.getConfigDAO().createDestinationConfig();
        
        dConfig.setDurable(Boolean.valueOf(true));
        dConfig.setName(jndiName == null ? dInfo.getTopicName() : jndiName);
        dConfig.setClientID(dInfo.getDurableName());
        dConfig.setSelector(dInfo.getSelector());
        dConfig.setDomain(Integer.valueOf(Domain.TOPIC.getId()));
        
        rval.add(dConfig);
      }
      return rval;
    }
    catch (TibjmsAdminException e)
    {
      log.error(e.getMessage(), e);
      
      throw new HermesException(e);
    }
  }
}

/* Location:
 * Qualified Name:     classes-ext.ems.hermes.ext.ems.TibcoEMSAdmin
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package hermes.ext.ems;

import com.tibco.tibjms.TibjmsConnectionFactory;
import com.tibco.tibjms.admin.TibjmsAdmin;
import hermes.Hermes;
import hermes.HermesAdmin;
import hermes.HermesAdminFactory;
import hermes.HermesException;
import hermes.HermesRuntimeException;
import hermes.JNDIConnectionFactory;
import java.util.HashMap;
import java.util.Map;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.naming.NamingException;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;

public class TibcoEMSAdminFactory
  implements HermesAdminFactory
{
  private static final Logger log = Logger.getLogger(TibcoEMSAdminFactory.class);
  private String serverURL;
  private String username;
  private String password;
  
  public HermesAdmin createSession(Hermes hermes, ConnectionFactory connectionFactory)
    throws JMSException, NamingException
  {
    TibjmsAdmin admin = null;
    
    return new TibcoEMSAdmin(hermes, this);
  }
  
  TibjmsAdmin createAdmin(ConnectionFactory connectionFactory)
    throws JMSException
  {
    TibjmsAdmin admin = null;
    try
    {
      if ((connectionFactory instanceof JNDIConnectionFactory))
      {
        JNDIConnectionFactory jndiCF = (JNDIConnectionFactory)connectionFactory;
        if ((username == null) && (jndiCF.getSecurityPrincipal() != null))
        {
          username = jndiCF.getSecurityCredentials();
          if ((password == null) && (jndiCF.getSecurityCredentials() != null)) {
            password = jndiCF.getSecurityCredentials();
          }
        }
        admin = new TibjmsAdmin(serverURL == null ? jndiCF.getProviderURL() : serverURL, username, password);
      }
      else if ((connectionFactory instanceof TibjmsConnectionFactory))
      {
        TibjmsConnectionFactory tibCF = (TibjmsConnectionFactory)connectionFactory;
        Map ssl = getSSLParameters(tibCF);
        
        serverURL = (serverURL == null ? BeanUtils.getProperty(tibCF, "serverUrl") : serverURL);
        username = (username == null ? BeanUtils.getProperty(tibCF, "userName") : username);
        password = (password == null ? BeanUtils.getProperty(tibCF, "userPassword") : password);
        if (ssl.size() == 0) {
          admin = new TibjmsAdmin(serverURL, username, password);
        } else {
          admin = new TibjmsAdmin(serverURL, username, password, ssl);
        }
      }
      if (admin == null) {
        throw new HermesException("Provider is not TibcoEMS");
      }
    }
    catch (Exception e)
    {
      log.error(e.getMessage(), e);
      
      throw new HermesException(e);
    }
    return admin;
  }
  
  private Map getSSLParameters(TibjmsConnectionFactory tibCF)
  {
    try
    {
      Map rval = new HashMap();
      if (BeanUtils.getProperty(tibCF, "SSLIdentity") != null)
      {
        rval.put("com.tibco.tibjms.ssl.identity", BeanUtils.getProperty(tibCF, "SSLIdentity"));
        rval.put("com.tibco.tibjms.ssl.auth_only", BeanUtils.getProperty(tibCF, "SSLAuthOnly"));
        rval.put("com.tibco.tibjms.ssl.cipher_suites", BeanUtils.getProperty(tibCF, "SSLCipherSuites"));
        rval.put("com.tibco.tibjms.ssl.debug_trace", BeanUtils.getProperty(tibCF, "SSLDebugTrace"));
        rval.put("com.tibco.tibjms.ssl.enable_verify_host", BeanUtils.getProperty(tibCF, "SSLEnableVerifyHost"));
        rval.put("com.tibco.tibjms.ssl.enable_verify_hostname", BeanUtils.getProperty(tibCF, "SSLEnableVerifyHostName"));
        rval.put("com.tibco.tibjms.ssl.expected_hostname", BeanUtils.getProperty(tibCF, "SSLExpectedHostName"));
        rval.put("com.tibco.tibjms.ssl.identity_encoding", BeanUtils.getProperty(tibCF, "SSLIdentityEncoding"));
        rval.put("com.tibco.tibjms.ssl.issuer_certs", BeanUtils.getProperty(tibCF, "SSLIssuerCertificate"));
        rval.put("com.tibco.tibjms.ssl.password", BeanUtils.getProperty(tibCF, "SSLPassword"));
        rval.put("com.tibco.tibjms.ssl.private_key", BeanUtils.getProperty(tibCF, "SSLPrivateKey"));
        rval.put("com.tibco.tibjms.ssl.private_key_encoding", BeanUtils.getProperty(tibCF, "SSLPrivateKeyEncoding"));
        rval.put("com.tibco.tibjms.ssl.trace", BeanUtils.getProperty(tibCF, "SSLTrace"));
        rval.put("com.tibco.tibjms.ssl.trusted_certs", BeanUtils.getProperty(tibCF, "SSLTrustedCertificate"));
        rval.put("com.tibco.tibjms.ssl.vendor", BeanUtils.getProperty(tibCF, "SSLVendor"));
      }
      return rval;
    }
    catch (Exception ex)
    {
      throw new HermesRuntimeException(ex);
    }
  }
  
  public String getPassword()
  {
    return password;
  }
  
  public void setPassword(String password)
  {
    if (password.equals("")) {
      this.password = null;
    } else {
      this.password = password;
    }
  }
  
  public String getServerURL()
  {
    return serverURL;
  }
  
  public void setServerURL(String serverURL)
  {
    if (serverURL.equals("")) {
      this.serverURL = null;
    } else {
      this.serverURL = serverURL;
    }
  }
  
  public String getUsername()
  {
    return username;
  }
  
  public void setUsername(String username)
  {
    if (username.equals("")) {
      this.username = null;
    } else {
      this.username = username;
    }
  }
}

/* Location:
 * Qualified Name:     classes-ext.ems.hermes.ext.ems.TibcoEMSAdminFactory
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package hermes.ext.fiorano;

import fiorano.jms.runtime.admin.MQAdminConnection;
import fiorano.jms.runtime.admin.MQAdminService;
import hermes.Domain;
import hermes.Hermes;
import hermes.HermesAdmin;
import hermes.HermesException;
import hermes.config.DestinationConfig;
import hermes.ext.HermesAdminSupport;
import java.util.Map;
import java.util.TreeMap;
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;

public class FioranoAdmin
  extends HermesAdminSupport
  implements HermesAdmin
{
  private static final String DELIVERABLE_MESSGAES = "deliverable";
  private static final String UNDELETED_MESSGAES = "undeleted";
  private MQAdminConnection adminConnection;
  private MQAdminService adminService;
  
  public FioranoAdmin(Hermes hermes, MQAdminConnection adminConnection)
  {
    super(hermes);
    
    this.adminConnection = adminConnection;
  }
  
  protected synchronized MQAdminService getAdminService()
    throws JMSException
  {
    if (adminService == null) {
      if (adminConnection != null) {
        adminService = adminConnection.getMQAdminService();
      } else {
        throw new HermesException("FioranoMQ plugin is closed");
      }
    }
    return adminService;
  }
  
  public int truncate(DestinationConfig dConfig)
    throws JMSException
  {
    int rval = getDepth(dConfig);
    if (dConfig.getDomain().intValue() == Domain.QUEUE.getId()) {
      getAdminService().purgeQueueMessages(getRealDestinationName(dConfig));
    } else if ((dConfig.getDomain().intValue() == Domain.TOPIC.getId()) && (dConfig.isDurable())) {
      getAdminService().purgeSubscriptionMessages(getHermes().getConnection().getClientID(), dConfig.getClientID());
    } else {
      throw new HermesException("Domain for " + dConfig.getName() + " is unknown.");
    }
    return rval;
  }
  
  public int getDepth(DestinationConfig dConfig)
    throws JMSException
  {
    if (dConfig.getDomain().intValue() == Domain.QUEUE.getId()) {
      return (int)getAdminService().getNumberOfDeliverableMessages(getRealDestinationName(dConfig));
    }
    String clientId = getHermes().getConnection().getClientID();
    String subId = dConfig.getClientID();
    
    return (int)getAdminService().getNumberOfDeliverableMessages(clientId, subId);
  }
  
  public Map getStatistics(DestinationConfig dConfig)
    throws JMSException
  {
    Map<String, Object> map = new TreeMap();
    Domain domain = Domain.getDomain(dConfig.getDomain().intValue());
    if (domain == Domain.QUEUE)
    {
      map.put("deliverable", new Long(getAdminService().getNumberOfDeliverableMessages(dConfig.getName())));
      map.put("undeleted", new Long(getAdminService().getNumberOfUndeletedMessages(dConfig.getName())));
    }
    else if (dConfig.isDurable())
    {
      String clientId = getHermes().getConnection().getClientID();
      String subId = dConfig.getClientID();
      
      map.put("deliverable", new Long(getAdminService().getNumberOfDeliverableMessages(dConfig.getName(), subId)));
    }
    return map;
  }
  
  public int truncate(Destination destination)
    throws JMSException
  {
    String queueName = getHermes().getDestinationName(destination);
    long endIndex = getAdminService().getNumberOfDeliverableMessages(queueName);
    
    getAdminService().purgeQueueMessages(queueName);
    return (int)endIndex;
  }
  
  public synchronized void close()
    throws JMSException
  {
    try
    {
      adminConnection.close();
    }
    finally
    {
      adminConnection = null;
      adminService = null;
    }
  }
}

/* Location:
 * Qualified Name:     classes-ext.fiorano.hermes.ext.fiorano.FioranoAdmin
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package hermes.ext.fiorano;

import fiorano.jms.runtime.admin.MQAdminConnection;
import fiorano.jms.runtime.admin.MQAdminConnectionFactory;
import hermes.Hermes;
import hermes.HermesAdmin;
import hermes.HermesAdminFactory;
import hermes.HermesException;
import hermes.JNDIConnectionFactory;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.naming.Context;
import javax.naming.NamingException;

public class FioranoAdminFactory
  implements HermesAdminFactory
{
  private String adminBinding = "primaryACF";
  private String adminUser = "admin";
  private String adminPassword = "passwd";
  
  public HermesAdmin createSession(Hermes hermes, ConnectionFactory connectionFactory)
    throws JMSException, NamingException
  {
    if ((connectionFactory instanceof JNDIConnectionFactory))
    {
      JNDIConnectionFactory jndiCF = (JNDIConnectionFactory)connectionFactory;
      MQAdminConnectionFactory aCF = (MQAdminConnectionFactory)jndiCF.createContext().lookup(getAdminBinding());
      MQAdminConnection aCon = aCF.createMQAdminConnection(getAdminUser(), getAdminPassword());
      
      return new FioranoAdmin(hermes, aCon);
    }
    throw new HermesException("Can only access FioranoMQ via JNDI");
  }
  
  public String getAdminBinding()
  {
    return adminBinding;
  }
  
  public void setAdminBinding(String adminBinding)
  {
    this.adminBinding = adminBinding;
  }
  
  public String getAdminPassword()
  {
    return adminPassword;
  }
  
  public void setAdminPassword(String adminPassword)
  {
    this.adminPassword = adminPassword;
  }
  
  public String getAdminUser()
  {
    return adminUser;
  }
  
  public void setAdminUser(String adminUser)
  {
    this.adminUser = adminUser;
  }
}

/* Location:
 * Qualified Name:     classes-ext.fiorano.hermes.ext.fiorano.FioranoAdminFactory
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package hermes.ext.imq;

import javax.jms.Connection;
import javax.jms.JMSException;

public class ConnectionFactory
  implements javax.jms.ConnectionFactory
{
  private com.sun.messaging.ConnectionFactory sunMqConnectionFactory;
  private String imqBrokerHostName;
  private String imqBrokerHostPort;
  private String imqDefaultUsername;
  private String imqDefaultPassword;
  
  public void init()
    throws JMSException
  {
    sunMqConnectionFactory = new com.sun.messaging.ConnectionFactory();
    if ((imqBrokerHostName == null) || (imqBrokerHostPort == null)) {
      throw new RuntimeException("You must set all the following connection properties: imqBrokerHostName, imqBrokerHostPort.");
    }
    sunMqConnectionFactory.setProperty("imqBrokerHostName", imqBrokerHostName);
    
    sunMqConnectionFactory.setProperty("imqBrokerHostPort", imqBrokerHostPort);
    if (imqDefaultUsername != null) {
      sunMqConnectionFactory.setProperty("imqDefaultUsername", imqDefaultUsername);
    }
    if (imqDefaultPassword != null) {
      sunMqConnectionFactory.setProperty("imqDefaultPassword", imqDefaultPassword);
    }
  }
  
  public Connection createConnection()
    throws JMSException
  {
    init();
    return sunMqConnectionFactory.createConnection();
  }
  
  public Connection createConnection(String arg0, String arg1)
    throws JMSException
  {
    init();
    return sunMqConnectionFactory.createConnection(arg0, arg1);
  }
  
  public String getImqBrokerHostName()
  {
    return imqBrokerHostName;
  }
  
  public void setImqBrokerHostName(String imqBrokerHostName)
  {
    this.imqBrokerHostName = imqBrokerHostName;
  }
  
  public String getImqBrokerHostPort()
  {
    return imqBrokerHostPort;
  }
  
  public void setImqBrokerHostPort(String imqBrokerHostPort)
  {
    this.imqBrokerHostPort = imqBrokerHostPort;
  }
  
  public String getImqDefaultUsername()
  {
    return imqDefaultUsername;
  }
  
  public void setImqDefaultUsername(String imqDefaultUsername)
  {
    this.imqDefaultUsername = imqDefaultUsername;
  }
  
  public String getImqDefaultPassword()
  {
    return imqDefaultPassword;
  }
  
  public void setImqDefaultPassword(String imqDefaultPassword)
  {
    this.imqDefaultPassword = imqDefaultPassword;
  }
}

/* Location:
 * Qualified Name:     classes-ext.imq.hermes.ext.imq.ConnectionFactory
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package hermes.ext.imq;

import hermes.config.DestinationConfig;
import java.util.Comparator;

final class ImqAdmin$1
  implements Comparator<DestinationConfig>
{
  ImqAdmin$1(ImqAdmin paramImqAdmin) {}
  
  public int compare(DestinationConfig o1, DestinationConfig o2)
  {
    return o1.getShortName().compareTo(o2.getShortName());
  }
}

/* Location:
 * Qualified Name:     classes-ext.imq.hermes.ext.imq.ImqAdmin.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package hermes.ext.imq;

import hermes.Domain;
import hermes.Hermes;
import hermes.HermesAdmin;
import hermes.browser.HermesBrowser;
import hermes.config.DestinationConfig;
import hermes.ext.HermesAdminSupport;
import hermes.i
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

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