1 18 package org.apache.activemq.util; 19 20 import java.net.URISyntaxException ; 21 22 import org.apache.activemq.ActiveMQConnection; 23 24 import javax.jms.Connection ; 25 import javax.jms.JMSException ; 26 27 33 public class JmsLogAppender extends JmsLogAppenderSupport { 34 private String uri = "tcp://localhost:61616"; 35 private String userName; 36 private String password; 37 38 public JmsLogAppender() { 39 } 40 41 public String getUri() { 42 return uri; 43 } 44 45 public void setUri(String uri) { 46 this.uri = uri; 47 } 48 49 public String getUserName() { 50 return userName; 51 } 52 53 public void setUserName(String userName) { 54 this.userName = userName; 55 } 56 57 public String getPassword() { 58 return password; 59 } 60 61 public void setPassword(String password) { 62 this.password = password; 63 } 64 65 protected Connection createConnection() throws JMSException { 66 if (userName != null) { 67 try { 68 return ActiveMQConnection.makeConnection(userName, password, uri); 69 } catch (URISyntaxException e) { 70 throw new JMSException ("Unable to connect to a broker using " + 71 "userName: \'" + userName + 72 "\' password \'" + password + 73 "\' uri \'" + uri + "\' :: error - " + 74 e.getMessage()); 75 } 76 } 77 else { 78 try { 79 return ActiveMQConnection.makeConnection(uri); 80 } catch (URISyntaxException e) { 81 throw new JMSException ("Unable to connect to a broker using " + 82 "uri \'" + uri + "\' :: error - " + 83 e.getMessage()); 84 } 85 } 86 } 87 } 88 | Popular Tags |