001 /** 002 * 003 * Copyright 2004 Protique Ltd 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 package org.activemq.util; 019 020 import org.activemq.ActiveMQConnection; 021 022 import javax.jms.Connection; 023 import javax.jms.JMSException; 024 025 /** 026 * A JMS 1.1 log4j appender which uses ActiveMQ by default and does not require any JNDI 027 * configurations 028 * 029 * @version $Revision: 1.1.1.1 $ 030 */ 031 public class JmsLogAppender extends JmsLogAppenderSupport { 032 private String uri = "tcp://localhost:61616"; 033 private String userName; 034 private String password; 035 036 public JmsLogAppender() { 037 } 038 039 public String getUri() { 040 return uri; 041 } 042 043 public void setUri(String uri) { 044 this.uri = uri; 045 } 046 047 public String getUserName() { 048 return userName; 049 } 050 051 public void setUserName(String userName) { 052 this.userName = userName; 053 } 054 055 public String getPassword() { 056 return password; 057 } 058 059 public void setPassword(String password) { 060 this.password = password; 061 } 062 063 protected Connection createConnection() throws JMSException { 064 if (userName != null) { 065 return ActiveMQConnection.makeConnection(userName, password, uri); 066 } 067 else { 068 return ActiveMQConnection.makeConnection(uri); 069 } 070 } 071 }