logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject cvs commit: logging-log4j/tests/src/java/org/apache/log4j/net ShortSocketServer.java
Date Tue, 04 May 2004 14:39:25 GMT
ceki        2004/05/04 07:39:25

  Modified:    tests/src/java/org/apache/log4j/net ShortSocketServer.java
  Log:
  Jalopy formatting + license update
  
  Revision  Changes    Path
  1.4       +44 -39    logging-log4j/tests/src/java/org/apache/log4j/net/ShortSocketServer.java
  
  Index: ShortSocketServer.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/src/java/org/apache/log4j/net/ShortSocketServer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ShortSocketServer.java	13 May 2003 16:33:16 -0000	1.3
  +++ ShortSocketServer.java	4 May 2004 14:39:25 -0000	1.4
  @@ -1,23 +1,31 @@
  -/* Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included  with this distribution in
  - * the LICENSE.txt file.
  +/*
  + * Copyright 1999,2004 The Apache Software Foundation.
  + * 
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + * 
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + * 
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
    */
  -
  -
   package org.apache.log4j.net;
   
  -import java.net.Socket;
   import java.net.ServerSocket;
  +import java.net.Socket;
   
  -import org.apache.log4j.Logger;
   import org.apache.log4j.LogManager;
  -import org.apache.log4j.PropertyConfigurator;
  +import org.apache.log4j.Logger;
   import org.apache.log4j.MDC;
  +import org.apache.log4j.PropertyConfigurator;
   import org.apache.log4j.helpers.LogLog;
   import org.apache.log4j.net.SocketNode;
   
  +
   /**
    * This SocketServer exits after certain number of connections from a
    * client. This number is determined the totalsTest parameter, that is
  @@ -28,49 +36,46 @@
    * (prefix+i+".properties").
    *
    * @author Ceki Gulcu */
  -
  -public class ShortSocketServer  {
  -
  +public class ShortSocketServer {
     static Logger cat = Logger.getLogger(ShortSocketServer.class);
   
  -  public 
  -  static 
  -  void main(String args[]) throws Exception {
  +  public static void main(String[] args)
  +         throws Exception {
       int totalTests = 0;
       String prefix = null;
   
  -    if(args.length == 2) {
  +    if (args.length == 2) {
         totalTests = Integer.parseInt(args[0]);
         prefix = args[1];
       } else {
  -      usage("Wrong number of arguments."); 
  +      usage("Wrong number of arguments.");
       }
  -    
   
  -      LogLog.debug("Listening on port " + SocketServerTestCase.PORT);
  -      ServerSocket serverSocket = new ServerSocket(SocketServerTestCase.PORT);
  +    LogLog.debug("Listening on port " + SocketServerTestCase.PORT);
  +
  +    ServerSocket serverSocket = new ServerSocket(SocketServerTestCase.PORT);
  +
  +    MDC.put("hostID", "shortSocketServer");
   
  -      MDC.put("hostID", "shortSocketServer");
  +    for (int i = 1; i <= totalTests; i++) {
  +      PropertyConfigurator.configure(prefix + i + ".properties");
  +      LogLog.debug("Waiting to accept a new client.");
   
  -      for(int i = 1; i <= totalTests; i++) {
  -	PropertyConfigurator.configure(prefix+i+".properties");
  -	LogLog.debug("Waiting to accept a new client.");
  -	Socket socket = serverSocket.accept();
  -	LogLog.debug("Connected to client at " + socket.getInetAddress());
  -	LogLog.debug("Starting new socket node.");	
  -	SocketNode sn = new SocketNode(socket, LogManager.getLoggerRepository());
  -	Thread t = new Thread(sn);
  -	t.start(); 
  -	t.join();
  -      }
  +      Socket socket = serverSocket.accept();
  +      LogLog.debug("Connected to client at " + socket.getInetAddress());
  +      LogLog.debug("Starting new socket node.");
  +
  +      SocketNode sn = new SocketNode(socket, LogManager.getLoggerRepository());
  +      Thread t = new Thread(sn);
  +      t.start();
  +      t.join();
  +    }
     }
   
  -  
  -  static
  -  void usage(String msg) {
  +
  +  static void usage(String msg) {
       System.err.println(msg);
  -    System.err.println(
  -      "Usage: java " +ShortSocketServer.class.getName() + " totalTests configFilePrefix");
  +    System.err.println("Usage: java " + ShortSocketServer.class.getName() + " totalTests
configFilePrefix");
       System.exit(1);
  -  }    
  +  }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message