JmsLogAppender xref

View Javadoc

    1   /***
    2    *
    3    * Copyright 2004 Protique Ltd
    4    *
    5    * Licensed under the Apache License, Version 2.0 (the "License");
    6    * you may not use this file except in compliance with the License.
    7    * You may obtain a copy of the License at
    8    *
    9    * http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   *
    17   **/
    18  package org.codehaus.activemq.util;
    19
    20  import org.codehaus.activemq.ActiveMQConnection;
    21
    22  import javax.jms.Connection;
    23  import javax.jms.JMSException;
    24
    25  /***
    26   * A JMS 1.1 log4j appender which uses ActiveMQ by default and does not require any JNDI
    27   * configurations
    28   *
    29   * @version $Revision: 1.1 $
    30   */
    31  public class JmsLogAppender extends JmsLogAppenderSupport {
    32      private String uri = "tcp://localhost:61616";
    33      private String userName;
    34      private String password;
    35
    36      public JmsLogAppender() {
    37      }
    38
    39      public String getUri() {
    40          return uri;
    41      }
    42
    43      public void setUri(String uri) {
    44          this.uri = uri;
    45      }
    46
    47      public String getUserName() {
    48          return userName;
    49      }
    50
    51      public void setUserName(String userName) {
    52          this.userName = userName;
    53      }
    54
    55      public String getPassword() {
    56          return password;
    57      }
    58
    59      public void setPassword(String password) {
    60          this.password = password;
    61      }
    62
    63      protected Connection createConnection() throws JMSException {
    64          if (userName != null) {
    65              return ActiveMQConnection.makeConnection(userName, password, uri);
    66          }
    67          else {
    68              return ActiveMQConnection.makeConnection(uri);
    69          }
    70      }
    71  }