Added: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/PostgreSQLDialect.html URL: http://svn.apache.org/viewvc/logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/PostgreSQLDialect.html?view=auto&rev=558362 ============================================================================== --- logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/PostgreSQLDialect.html (added) +++ logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/PostgreSQLDialect.html Sat Jul 21 10:50:33 2007 @@ -0,0 +1,47 @@ + + + +PostgreSQLDialect xref + + + +
View Javadoc
+
+1   /*
+2    * Copyright 1999,2004 The Apache Software Foundation.
+3    *
+4    * Licensed under the Apache License, Version 2.0 (the "License");
+5    * you may not use this file except in compliance with the License.
+6    * You may obtain a copy of the License at
+7    *
+8    *      http://www.apache.org/licenses/LICENSE-2.0
+9    *
+10   * Unless required by applicable law or agreed to in writing, software
+11   * distributed under the License is distributed on an "AS IS" BASIS,
+12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+13   * See the License for the specific language governing permissions and
+14   * limitations under the License.
+15   */
+16  
+17  package org.apache.log4j.db.dialect;
+18  
+19  
+20  /***
+21   * 
+22   * @author ceki
+23   *
+24   * To change the template for this generated type comment go to
+25   * Window>Preferences>Java>Code Generation>Code and Comments
+26   */
+27  public class PostgreSQLDialect
+28         implements SQLDialect {
+29    public static final String SELECT_CURRVAL = "SELECT currval('logging_event_id_seq')";
+30  
+31    public String getSelectInsertId() {
+32      return SELECT_CURRVAL;
+33    }
+34  }
+
+
+ + Propchange: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/PostgreSQLDialect.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/SQLDialect.html URL: http://svn.apache.org/viewvc/logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/SQLDialect.html?view=auto&rev=558362 ============================================================================== --- logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/SQLDialect.html (added) +++ logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/SQLDialect.html Sat Jul 21 10:50:33 2007 @@ -0,0 +1,39 @@ + + + +SQLDialect xref + + + +
View Javadoc
+
+1   /*
+2    * Copyright 1999,2004 The Apache Software Foundation.
+3    * 
+4    * Licensed under the Apache License, Version 2.0 (the "License");
+5    * you may not use this file except in compliance with the License.
+6    * You may obtain a copy of the License at
+7    * 
+8    *      http://www.apache.org/licenses/LICENSE-2.0
+9    * 
+10   * Unless required by applicable law or agreed to in writing, software
+11   * distributed under the License is distributed on an "AS IS" BASIS,
+12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+13   * See the License for the specific language governing permissions and
+14   * limitations under the License.
+15   */
+16  package org.apache.log4j.db.dialect;
+17  
+18  /***
+19   * @author ceki
+20   *
+21   */
+22  public interface SQLDialect {
+23    
+24    public String getSelectInsertId();
+25    
+26  }
+
+
+ + Propchange: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/SQLDialect.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/Util.html URL: http://svn.apache.org/viewvc/logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/Util.html?view=auto&rev=558362 ============================================================================== --- logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/Util.html (added) +++ logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/Util.html Sat Jul 21 10:50:33 2007 @@ -0,0 +1,137 @@ + + + +Util xref + + + +
View Javadoc
+
+1   /*
+2    * Copyright 1999,2006 The Apache Software Foundation.
+3    *
+4    * Licensed under the Apache License, Version 2.0 (the "License");
+5    * you may not use this file except in compliance with the License.
+6    * You may obtain a copy of the License at
+7    *
+8    *      http://www.apache.org/licenses/LICENSE-2.0
+9    *
+10   * Unless required by applicable law or agreed to in writing, software
+11   * distributed under the License is distributed on an "AS IS" BASIS,
+12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+13   * See the License for the specific language governing permissions and
+14   * limitations under the License.
+15   */
+16  
+17  package org.apache.log4j.db.dialect;
+18  
+19  import org.apache.log4j.db.ConnectionSource;
+20  import org.apache.log4j.spi.ComponentBase;
+21  
+22  import java.sql.DatabaseMetaData;
+23  import java.sql.SQLException;
+24  
+25  
+26  /***
+27   * 
+28   * @author Ceki Gulcu
+29   *
+30   */
+31  public class Util extends ComponentBase {
+32    private static final String POSTGRES_PART = "postgresql";
+33    private static final String MYSQL_PART = "mysql";
+34    private static final String ORACLE_PART = "oracle";
+35    //private static final String MSSQL_PART = "mssqlserver4";
+36    private static final String MSSQL_PART = "microsoft";
+37    private static final String HSQL_PART = "hsql";
+38    
+39    public static int discoverSQLDialect(DatabaseMetaData meta) {
+40      int dialectCode = 0;
+41  
+42      try {
+43  
+44        String dbName = meta.getDatabaseProductName().toLowerCase();
+45  
+46        if (dbName.indexOf(POSTGRES_PART) != -1) {
+47          return ConnectionSource.POSTGRES_DIALECT;
+48        } else if (dbName.indexOf(MYSQL_PART) != -1) {
+49          return ConnectionSource.MYSQL_DIALECT;
+50        } else if (dbName.indexOf(ORACLE_PART) != -1) {
+51          return ConnectionSource.ORACLE_DIALECT;
+52        } else if (dbName.indexOf(MSSQL_PART) != -1) {
+53          return ConnectionSource.MSSQL_DIALECT;
+54        } else if (dbName.indexOf(HSQL_PART) != -1) {
+55          return ConnectionSource.HSQL_DIALECT;
+56        } else {
+57          return ConnectionSource.UNKNOWN_DIALECT;
+58        }
+59      } catch (SQLException sqle) {
+60        // we can't do much here
+61      }
+62  
+63      return dialectCode;
+64    }
+65  
+66    public static SQLDialect getDialectFromCode(int dialectCode) {
+67      SQLDialect sqlDialect = null;
+68  
+69      switch (dialectCode) {
+70      case ConnectionSource.POSTGRES_DIALECT:
+71        sqlDialect = new PostgreSQLDialect();
+72  
+73        break;
+74      case ConnectionSource.MYSQL_DIALECT:
+75        sqlDialect = new MySQLDialect();
+76  
+77        break;
+78      case ConnectionSource.ORACLE_DIALECT:
+79        sqlDialect = new OracleDialect();
+80  
+81        break;
+82      case ConnectionSource.MSSQL_DIALECT:
+83        sqlDialect = new MsSQLDialect();
+84  
+85        break;
+86      case ConnectionSource.HSQL_DIALECT:
+87        sqlDialect = new HSQLDBDialect();
+88  
+89        break;
+90      }
+91      return sqlDialect;
+92    }
+93    
+94    /***
+95     * This method handles cases where the 
+96     * {@link DatabaseMetaData#supportsGetGeneratedKeys} method is missing in the
+97     * JDBC driver implementation.
+98     */
+99    public boolean supportsGetGeneratedKeys(DatabaseMetaData meta) {
+100     try {
+101       //
+102       //   invoking JDK 1.4 method by reflection
+103       //
+104       return ((Boolean) DatabaseMetaData.class.getMethod("supportsGetGeneratedKeys", null).invoke(meta, null)).booleanValue();
+105     } catch(Throwable e) {
+106       getLogger().info("Could not call supportsGetGeneratedKeys method. This may be recoverable");
+107       return false;
+108     }
+109   }
+110   
+111 /*** 
+112   * This method handles cases where the 
+113   * {@link DatabaseMetaData#supportsBatchUpdates} method is missing in the
+114   * JDBC driver implementation.
+115   */
+116   public boolean supportsBatchUpdates(DatabaseMetaData meta) {
+117     try {
+118       return meta.supportsBatchUpdates();
+119     } catch(Throwable e) {
+120       getLogger().info("Missing DatabaseMetaData.supportsBatchUpdates method.");
+121       return false;
+122     }
+123   }
+124 }
+
+
+ + Propchange: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/Util.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/package-frame.html URL: http://svn.apache.org/viewvc/logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/package-frame.html?view=auto&rev=558362 ============================================================================== --- logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/package-frame.html (added) +++ logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/package-frame.html Sat Jul 21 10:50:33 2007 @@ -0,0 +1,42 @@ + + + + + + Apache Receivers Companion for log4j 1.2. 1.1-SNAPSHOT Reference Package org.apache.log4j.db.dialect + + + + +

+ org.apache.log4j.db.dialect +

+ +

Classes

+ + + + + \ No newline at end of file Propchange: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/package-frame.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/package-summary.html URL: http://svn.apache.org/viewvc/logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/package-summary.html?view=auto&rev=558362 ============================================================================== --- logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/package-summary.html (added) +++ logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/package-summary.html Sat Jul 21 10:50:33 2007 @@ -0,0 +1,97 @@ + + + + + + Apache Receivers Companion for log4j 1.2. 1.1-SNAPSHOT Reference Package $name + + + +
+ +
+
+ +
+ +

Package org.apache.log4j.db.dialect

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Class Summary
+ HSQLDBDialect +
+ MsSQLDialect +
+ MySQLDialect +
+ OracleDialect +
+ PostgreSQLDialect +
+ SQLDialect +
+ Util +
+ +
+ +
+
+ +
+
+ Copyright © null Apache Software Foundation. All Rights Reserved. + + \ No newline at end of file Propchange: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/dialect/package-summary.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/package-frame.html URL: http://svn.apache.org/viewvc/logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/package-frame.html?view=auto&rev=558362 ============================================================================== --- logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/package-frame.html (added) +++ logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/package-frame.html Sat Jul 21 10:50:33 2007 @@ -0,0 +1,51 @@ + + + + + + Apache Receivers Companion for log4j 1.2. 1.1-SNAPSHOT Reference Package org.apache.log4j.db + + + + +

+ org.apache.log4j.db +

+ +

Classes

+ + + + + \ No newline at end of file Propchange: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/package-frame.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/package-summary.html URL: http://svn.apache.org/viewvc/logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/package-summary.html?view=auto&rev=558362 ============================================================================== --- logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/package-summary.html (added) +++ logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/package-summary.html Sat Jul 21 10:50:33 2007 @@ -0,0 +1,112 @@ + + + + + + Apache Receivers Companion for log4j 1.2. 1.1-SNAPSHOT Reference Package $name + + + +
+ +
+
+ +
+ +

Package org.apache.log4j.db

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Class Summary
+ ConnectionSource +
+ ConnectionSourceSkeleton +
+ CustomSQLDBReceiver +
+ DBAppender +
+ DBHelper +
+ DBReceiver +
+ DBReceiverJob +
+ DataSourceConnectionSource +
+ DriverManagerConnectionSource +
+ JNDIConnectionSource +
+ +
+ +
+
+ +
+
+ Copyright © null Apache Software Foundation. All Rights Reserved. + + \ No newline at end of file Propchange: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/db/package-summary.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/helpers/UtilLoggingLevel.html URL: http://svn.apache.org/viewvc/logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/helpers/UtilLoggingLevel.html?view=auto&rev=558362 ============================================================================== --- logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/helpers/UtilLoggingLevel.html (added) +++ logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/helpers/UtilLoggingLevel.html Sat Jul 21 10:50:33 2007 @@ -0,0 +1,252 @@ + + + +UtilLoggingLevel xref + + + +
View Javadoc
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one or more
+3    * contributor license agreements.  See the NOTICE file distributed with
+4    * this work for additional information regarding copyright ownership.
+5    * The ASF licenses this file to You under the Apache License, Version 2.0
+6    * (the "License"); you may not use this file except in compliance with
+7    * the License.  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.apache.log4j.helpers;
+19  
+20  import java.util.ArrayList;
+21  import java.util.List;
+22  
+23  import org.apache.log4j.Level;
+24  
+25  /***
+26   * An extension of the Level class that provides support for java.util.logging
+27   * Levels.
+28   *
+29   * @since 1.3
+30   *
+31   * @author Scott Deboy (sdeboy@apache.org)
+32   */
+33  
+34  public class UtilLoggingLevel extends Level {
+35  
+36      /***
+37       * Serialization version id.
+38       */
+39      private static final long serialVersionUID = 909301162611820211L;
+40  
+41      /***
+42       * Numerical value for SEVERE.
+43       */
+44      public static final int SEVERE_INT = 17000;
+45      /***
+46       * Numerical value for WARNING.
+47       */
+48      public static final int WARNING_INT = 16000;
+49      /***
+50       * Numerical value for INFO.
+51       */
+52      public static final int INFO_INT = 15000;
+53      /***
+54       * Numerical value for CONFIG.
+55       */
+56      public static final int CONFIG_INT = 14000;
+57      /***
+58       * Numerical value for FINE.
+59       */
+60      public static final int FINE_INT = 13000;
+61      /***
+62       * Numerical value for FINER.
+63       */
+64      public static final int FINER_INT = 12000;
+65      /***
+66       * Numerical value for FINEST.
+67       */
+68      public static final int FINEST_INT = 11000;
+69      /***
+70       * Numerical value for UNKNOWN.
+71       */
+72      public static final int UNKNOWN_INT = 10000;
+73  
+74      /***
+75       * SEVERE.
+76       */
+77      public static final UtilLoggingLevel SEVERE =
+78              new UtilLoggingLevel(SEVERE_INT, "SEVERE", 0);
+79      /***
+80       * WARNING.
+81       */
+82      public static final UtilLoggingLevel WARNING =
+83              new UtilLoggingLevel(WARNING_INT, "WARNING", 4);
+84      /***
+85       * INFO.
+86       */
+87      public static final UtilLoggingLevel INFO =
+88              new UtilLoggingLevel(INFO_INT, "INFO", 5);
+89      /***
+90       * CONFIG.
+91       */
+92      public static final UtilLoggingLevel CONFIG =
+93              new UtilLoggingLevel(CONFIG_INT, "CONFIG", 6);
+94      /***
+95       * FINE.
+96       */
+97      public static final UtilLoggingLevel FINE =
+98              new UtilLoggingLevel(FINE_INT, "FINE", 7);
+99      /***
+100      * FINER.
+101      */
+102     public static final UtilLoggingLevel FINER =
+103             new UtilLoggingLevel(FINER_INT, "FINER", 8);
+104     /***
+105      * FINEST.
+106      */
+107     public static final UtilLoggingLevel FINEST =
+108             new UtilLoggingLevel(FINEST_INT, "FINEST", 9);
+109 
+110     /***
+111      * Create new instance.
+112      * @param level numeric value for level.
+113      * @param levelStr symbolic name for level.
+114      * @param syslogEquivalent Equivalent syslog severity.
+115      */
+116     protected UtilLoggingLevel(final int level,
+117                                final String levelStr,
+118                                final int syslogEquivalent) {
+119         super(level, levelStr, syslogEquivalent);
+120     }
+121 
+122     /***
+123      * Convert an integer passed as argument to a level. If the
+124      * conversion fails, then this method returns the specified default.
+125      * @param val numeric value.
+126      * @param defaultLevel level to be returned if no level matches
+127      * numeric value.
+128      * @return matching level or default level.
+129      */
+130     public static UtilLoggingLevel toLevel(final int val,
+131                                final UtilLoggingLevel defaultLevel) {
+132         switch (val) {
+133             case SEVERE_INT:
+134                 return SEVERE;
+135 
+136             case WARNING_INT:
+137                 return WARNING;
+138 
+139             case INFO_INT:
+140                 return INFO;
+141 
+142             case CONFIG_INT:
+143                 return CONFIG;
+144 
+145             case FINE_INT:
+146                 return FINE;
+147 
+148             case FINER_INT:
+149                 return FINER;
+150 
+151             case FINEST_INT:
+152                 return FINEST;
+153 
+154             default:
+155                 return defaultLevel;
+156         }
+157     }
+158 
+159     /***
+160      * Gets level matching numeric value.
+161      * @param val numeric value.
+162      * @return  matching level or UtilLoggerLevel.FINEST if no match.
+163      */
+164     public static Level toLevel(final int val) {
+165         return toLevel(val, FINEST);
+166     }
+167 
+168     /***
+169      * Gets list of supported levels.
+170      * @return  list of supported levels.
+171      */
+172     public static List getAllPossibleLevels() {
+173         ArrayList list = new ArrayList();
+174         list.add(FINE);
+175         list.add(FINER);
+176         list.add(FINEST);
+177         list.add(INFO);
+178         list.add(CONFIG);
+179         list.add(WARNING);
+180         list.add(SEVERE);
+181         return list;
+182     }
+183 
+184     /***
+185      * Get level with specified symbolic name.
+186      * @param s symbolic name.
+187      * @return matching level or Level.DEBUG if no match.
+188      */
+189     public static Level toLevel(final String s) {
+190         return toLevel(s, Level.DEBUG);
+191     }
+192 
+193 
+194     /***
+195      * Get level with specified symbolic name.
+196      * @param sArg symbolic name.
+197      * @param defaultLevel level to return if no match.
+198      * @return matching level or defaultLevel if no match.
+199      */
+200     public static Level toLevel(final String sArg,
+201                                 final Level defaultLevel) {
+202         if (sArg == null) {
+203             return defaultLevel;
+204         }
+205 
+206         String s = sArg.toUpperCase();
+207 
+208         if (s.equals("SEVERE")) {
+209             return SEVERE;
+210         }
+211 
+212         //if(s.equals("FINE")) return Level.FINE;
+213         if (s.equals("WARNING")) {
+214             return WARNING;
+215         }
+216 
+217         if (s.equals("INFO")) {
+218             return INFO;
+219         }
+220 
+221         if (s.equals("CONFI")) {
+222             return CONFIG;
+223         }
+224 
+225         if (s.equals("FINE")) {
+226             return FINE;
+227         }
+228 
+229         if (s.equals("FINER")) {
+230             return FINER;
+231         }
+232 
+233         if (s.equals("FINEST")) {
+234             return FINEST;
+235         }
+236         return defaultLevel;
+237     }
+238 
+239 }
+
+
+ + Propchange: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/helpers/UtilLoggingLevel.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/helpers/package-frame.html URL: http://svn.apache.org/viewvc/logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/helpers/package-frame.html?view=auto&rev=558362 ============================================================================== --- logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/helpers/package-frame.html (added) +++ logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/helpers/package-frame.html Sat Jul 21 10:50:33 2007 @@ -0,0 +1,24 @@ + + + + + + Apache Receivers Companion for log4j 1.2. 1.1-SNAPSHOT Reference Package org.apache.log4j.helpers + + + + +

+ org.apache.log4j.helpers +

+ +

Classes

+ + + + + \ No newline at end of file Propchange: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/helpers/package-frame.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/helpers/package-summary.html URL: http://svn.apache.org/viewvc/logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/helpers/package-summary.html?view=auto&rev=558362 ============================================================================== --- logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/helpers/package-summary.html (added) +++ logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/helpers/package-summary.html Sat Jul 21 10:50:33 2007 @@ -0,0 +1,67 @@ + + + + + + Apache Receivers Companion for log4j 1.2. 1.1-SNAPSHOT Reference Package $name + + + +
+ +
+
+ +
+ +

Package org.apache.log4j.helpers

+ + + + + + + + + + + + +
Class Summary
+ UtilLoggingLevel +
+ +
+ +
+
+ +
+
+ Copyright © null Apache Software Foundation. All Rights Reserved. + + \ No newline at end of file Propchange: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/helpers/package-summary.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/net/AddressBased.html URL: http://svn.apache.org/viewvc/logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/net/AddressBased.html?view=auto&rev=558362 ============================================================================== --- logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/net/AddressBased.html (added) +++ logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/net/AddressBased.html Sat Jul 21 10:50:33 2007 @@ -0,0 +1,49 @@ + + + +AddressBased xref + + + +
View Javadoc
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one or more
+3    * contributor license agreements.  See the NOTICE file distributed with
+4    * this work for additional information regarding copyright ownership.
+5    * The ASF licenses this file to You under the Apache License, Version 2.0
+6    * (the "License"); you may not use this file except in compliance with
+7    * the License.  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.apache.log4j.net;
+19  
+20  
+21  /***
+22   * Net based entities that 'work with' an Address
+23   * should consider implementing this
+24   * interface so that they can be treated generically.
+25   *
+26   * @author Paul Smith (psmith@apache.org)
+27   *
+28   */
+29  public interface AddressBased extends NetworkBased {
+30    /***
+31     * Returns a String representation of the Address this instance
+32     * encompasses.
+33     * @return String representation of the Address
+34     */
+35    String getAddress();
+36  }
+
+
+ + Propchange: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/net/AddressBased.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/net/JMSReceiver.html URL: http://svn.apache.org/viewvc/logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/net/JMSReceiver.html?view=auto&rev=558362 ============================================================================== --- logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/net/JMSReceiver.html (added) +++ logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/net/JMSReceiver.html Sat Jul 21 10:50:33 2007 @@ -0,0 +1,315 @@ + + + +JMSReceiver xref + + + +
View Javadoc
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one or more
+3    * contributor license agreements.  See the NOTICE file distributed with
+4    * this work for additional information regarding copyright ownership.
+5    * The ASF licenses this file to You under the Apache License, Version 2.0
+6    * (the "License"); you may not use this file except in compliance with
+7    * the License.  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.apache.log4j.net;
+19  
+20  import java.io.FileInputStream;
+21  import java.util.Properties;
+22  
+23  import javax.jms.Message;
+24  import javax.jms.MessageListener;
+25  import javax.jms.TopicConnection;
+26  import javax.jms.Topic;
+27  import javax.jms.TopicConnectionFactory;
+28  import javax.jms.TopicSubscriber;
+29  import javax.jms.Session;
+30  import javax.jms.TopicSession;
+31  import javax.jms.ObjectMessage;
+32  
+33  import javax.naming.InitialContext;
+34  import javax.naming.Context;
+35  import javax.naming.NameNotFoundException;
+36  import javax.naming.NamingException;
+37  
+38  import org.apache.log4j.spi.LoggingEvent;
+39  import org.apache.log4j.plugins.Plugin;
+40  import org.apache.log4j.plugins.Receiver;
+41  
+42  /***
+43    JMSReceiver receives a remote logging event on a configured
+44    JSM topic and "posts" it to a LoggerRepository as if the event was 
+45    generated locally. This class is designed to receive events from 
+46    the JMSAppender class (or classes that send compatible events).
+47    
+48    <p>Once the event has been "posted", it will be handled by the 
+49    appenders currently configured in the LoggerRespository.
+50    
+51    <p>This implementation borrows heavily from the JMSSink
+52    implementation.
+53    
+54    @author Mark Womack
+55    @author Paul Smith
+56    @author Stephen Pain
+57    @since 1.3
+58  */
+59  public class JMSReceiver extends Receiver implements MessageListener {
+60  
+61    private boolean active = false;
+62  
+63    protected String topicFactoryName;
+64    protected String topicName;
+65    protected String userId;
+66    protected String password;
+67    protected TopicConnection topicConnection;
+68    protected String jndiPath;
+69    
+70    private String remoteInfo;
+71    private String providerUrl;
+72  
+73    public JMSReceiver() { }
+74  
+75    public JMSReceiver(String _topicFactoryName, String _topicName,
+76            String _userId, String _password, String _jndiPath) {      
+77        topicFactoryName = _topicFactoryName;
+78        topicName = _topicName;
+79        userId = _userId;
+80        password = _password;
+81        jndiPath = _jndiPath;
+82    }
+83  
+84    /***
+85           * Sets the path to a properties file containing
+86           * the initial context and jndi provider url
+87           */
+88      public void setJndiPath(String _jndiPath) {
+89            jndiPath = _jndiPath;
+90      }
+91    
+92       /***
+93           * Gets the path to a properties file containing
+94           * the initial context and jndi provider url
+95           */
+96       public String getJndiPath() {
+97            return jndiPath;
+98       }
+99    
+100   /***
+101     Sets the JMS topic factory name to use when creating the 
+102     JMS connection. */
+103   public void setTopicFactoryName(String _topicFactoryName) {
+104     topicFactoryName = _topicFactoryName;
+105   }
+106   
+107   /***
+108     Gets the curernt JMS topic factory name property. */
+109   public String getTopicFactoryName() {
+110     return topicFactoryName;
+111   }
+112   
+113   /***
+114    * Sets the JMS topic name to use when creating the
+115    * JMS connection.
+116    */
+117   public void setTopicName(String _topicName) {
+118     topicName = _topicName;
+119   }
+120   
+121   /***
+122    * Gets the curernt JMS topic name property.
+123    */
+124   public String getTopicName() {
+125     return topicName;
+126   }
+127 
+128   /***
+129     Sets the user id to use when creating the 
+130     JMS connection. */
+131   public void setUserId(String _userId) {
+132     userId = _userId;
+133   }
+134   
+135   /***
+136    * Gets the current user id property.
+137    */
+138   public String getUserId() {
+139     return userId;
+140   }
+141 
+142   /***
+143    * Sets the password to use when creating the
+144    * JMS connection.
+145    */
+146   public void setPassword(String _password) {
+147     password = _password;
+148   }
+149   
+150   /***
+151    * Gets the curernt password property.
+152    */
+153   public String getPassword() {
+154     return password;
+155   }
+156  
+157   /***
+158    * Returns true if the receiver is the same class and they are
+159    * configured for the same properties, and super class also considers
+160    * them to be equivalent. This is used by PluginRegistry when determining
+161    * if the a similarly configured receiver is being started.
+162    * 
+163    * @param testPlugin The plugin to test equivalency against.
+164    * @return boolean True if the testPlugin is equivalent to this plugin.
+165    */
+166   public boolean isEquivalent(Plugin testPlugin) {
+167     // only do full check if an instance of this class
+168     if (testPlugin instanceof JMSReceiver) {
+169  
+170       JMSReceiver receiver = (JMSReceiver)testPlugin;
+171       
+172       // check for same topic name and super class equivalency
+173       return (
+174             topicFactoryName.equals(receiver.getTopicFactoryName()) && 
+175             (jndiPath == null || jndiPath.equals(receiver.getJndiPath())) && 
+176             super.isEquivalent(testPlugin)
+177             );
+178     }
+179     
+180     return false;
+181   }
+182   
+183   /***
+184     Returns true if this receiver is active. */
+185   public synchronized boolean isActive() {
+186     return active;
+187   }
+188   
+189   /***
+190     Sets the flag to indicate if receiver is active or not. */
+191   protected synchronized void setActive(boolean _active) {
+192     active = _active;
+193   }
+194   
+195   /***
+196     Starts the JMSReceiver with the current options. */
+197   public void activateOptions() {
+198     if (!isActive()) {
+199       try {
+200         remoteInfo = topicFactoryName + ":" + topicName;
+201 
+202         Context ctx = null;
+203         if (jndiPath == null || jndiPath.equals("")) {
+204                 ctx = new InitialContext();
+205         } else {
+206                 FileInputStream is = new FileInputStream(jndiPath);
+207                 Properties p = new Properties();
+208                 p.load(is);
+209                 is.close();
+210                 ctx = new InitialContext(p);
+211         }
+212 
+213         // give some more flexibility about the choice of a tab name
+214         providerUrl = (String)ctx.getEnvironment().get(Context.PROVIDER_URL);
+215         TopicConnectionFactory topicConnectionFactory;
+216         topicConnectionFactory = 
+217           (TopicConnectionFactory) lookup(ctx, topicFactoryName);
+218         
+219         if (userId != null && password != null) {
+220           topicConnection =
+221     	       topicConnectionFactory.createTopicConnection(userId, password);
+222         } else {
+223           topicConnection =
+224     	       topicConnectionFactory.createTopicConnection();
+225         }
+226   	       
+227         TopicSession topicSession =
+228           topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+229   
+230         Topic topic = (Topic)ctx.lookup(topicName);
+231   
+232         TopicSubscriber topicSubscriber = topicSession.createSubscriber(topic);
+233       
+234         topicSubscriber.setMessageListener(this);
+235  
+236         topicConnection.start();
+237  
+238         setActive(true);
+239       } catch(Exception e) {
+240         setActive(false);
+241         if (topicConnection != null) {
+242           try {
+243             topicConnection.close();
+244           } catch (Exception e2) {
+245             // do nothing
+246           }
+247           topicConnection = null;
+248         }
+249         getLogger().error("Could not start JMSReceiver.", e);
+250       }
+251     }
+252   }
+253   
+254   /***
+255     Called when the receiver should be stopped. */
+256   public synchronized void shutdown() {
+257     if (isActive()) {
+258       // mark this as no longer running
+259       setActive(false);
+260     
+261       if (topicConnection != null) {
+262         try {
+263           topicConnection.close();
+264         } catch (Exception e) {
+265           // do nothing
+266         }
+267         topicConnection = null;
+268       }
+269     }
+270   }
+271 
+272   public void onMessage(Message message) {
+273     try {
+274       if(message instanceof  ObjectMessage) {
+275         // get the logging event and post it to the repository
+276       	ObjectMessage objectMessage = (ObjectMessage) message;
+277       	LoggingEvent event = (LoggingEvent) objectMessage.getObject();
+278       	
+279       	// store the known remote info in an event property
+280       	event.setProperty("log4j.remoteSourceInfo", remoteInfo);
+281         event.setProperty("log4j.jmsProviderUrl", providerUrl);
+282         
+283       	doPost(event);
+284       } else {
+285       	getLogger().warn("Received message is of type "+message.getJMSType()
+286 		    +", was expecting ObjectMessage.");
+287       }      
+288     } catch(Exception e) {
+289       getLogger().error("Exception thrown while processing incoming message.", e);
+290     }
+291   }
+292 
+293   protected Object lookup(Context ctx, String name) throws NamingException {
+294     try {
+295       return ctx.lookup(name);
+296     } catch(NameNotFoundException e) {
+297       getLogger().error("Could not find name ["+name+"].");
+298       throw e;
+299     }
+300   }
+301 
+302 }
+
+
+ + Propchange: logging/site/trunk/docs/log4j/companions/receivers/xref/org/apache/log4j/net/JMSReceiver.html ------------------------------------------------------------------------------ svn:mime-type = text/html