donaldp     01/02/21 23:51:36

  Added:       src/java/org/apache/cornerstone/services Scheduler.java
                        SocketServer.java Store.java
               src/java/org/apache/cornerstone/services/connection
                        ConnectionHandler.java
                        ConnectionHandlerFactory.java
                        ConnectionManager.java
               src/java/org/apache/cornerstone/services/scheduler
                        CronTimeTrigger.java Job.java JobScheduler.java
                        PeriodicTimeTrigger.java Target.java
                        TimeScheduler.java TimeTrigger.java Trigger.java
               src/java/org/apache/cornerstone/services/scheduler/test
                        CronTimeTriggerTestlet.java
               src/java/org/apache/cornerstone/services/security
                        AuthorizationManager.java MutableRealm.java
                        Realm.java RoleManager.java
               src/java/org/apache/cornerstone/services/sockets
                        ServerSocketFactory.java SocketFactory.java
                        SocketManager.java
  Log:
  Committing all the cornerstone service interfaces
  
  Revision  Changes    Path
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/Scheduler.java
  
  Index: Scheduler.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services;
  
  import java.util.Date;
  import org.apache.avalon.Stoppable;
  import org.apache.phoenix.Service;
  
  /**
   * The <code>Scheduler</code> specifies the interface to a system for setting
   * and receiving alarms within Avalon. The <code>Scheduler</code> allows to 
set
   * a listener on a specific event.
   *
   * @author Federico Barbieri <[EMAIL PROTECTED]>
   * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
   */
  public interface Scheduler 
      extends Service
  {
      /**
       * Sets an alarm by name, callback (Target), and the class (EventTrigger) 
       * that trigger the event. For example:
       *   <code> setAlarm("wakeup", new Alarm(10*Alarm.MIN, "Wake up!", 
       *            Alarm.DAY), this); </code>
       * this line sets an alarm based on time (the event triggered by the 
class 
       * Alarm) to call <code> this </code> in 10 minunes from now and every day
       * after that.
       *
       * @param name          The name of the alarm
       * @param target        The callback for the alarm
       * @param eventTrigger  The class Event that trigger the desidered event.
       */
      void setAlarm( String name, EventTrigger eventTrigger, Target target );
  
      /**
       * Removes an alarm by name.  If the alarm does not exist a 
RuntimeException 
       * is thrown.
       *
       * @param name The name of the alarm
       */
      void removeAlarm( String name );
  
      /**
       * Resets the alarm specified.
       *
       * @param name The name of the alarm
       */
      void resetAlarm( String name );
  
      /**
       * The <code>TimeServer.Bell</code> is the interface that any consumer of 
the
       * <code>TimeServer</code> must implement to handle the event that the 
alarm
       * went off.  In other words, the <code>TimeServer.Bell</code> is the 
effect
       * of the alarm.
       */
      public interface Target 
      {
          /**
           * Wakes up the destination so that it receives the name of the alarm 
and
           * the memo.  The memo is not required by the <code>TimeServer</code> 
system,
           * and so it must have meaning with the implementer of the 
<code>TimerServer.Bell</code>.
           */
          void wake( String name, Event event );
  
      }
  
      public interface EventTrigger 
          extends Runnable, Stoppable
      {
          /**
           * This method is called by the scheduler just after creatin to init
           * the EventTrigger.
           *
           * @param name      Sets the name of this EventTrigger
           * @param target    Sets the target of this EventTrigger
           * @param parent    Sets the parent of this EventTrigger that must
           *                  be called to to notify the Scheduler that this 
           *                  EvenTrigger wish to be destroyed.
           */
          void initialize( String name, Target target, Scheduler parent );
          
          /**
           * This method is used to reset the EventTrigger. 
           * NOTE:
           * Is the reset method generic for any EventTrggers? In other words a
           * SystemEvent(SIG_TERM) EventTrigger can use the reset method? 
           */
          void reset();
      }
      
      public class Event 
      {
          private Object m_memo;
          private Object m_descriptor;
          
          protected Event( final Object memo )
          {
              m_memo = memo;
          }
          
          /**
           * This method is used by the target to retrive the memo.
           */
          public Object getMemo() 
          {
              return m_memo;
          }
          
          /**
           * This method is used by the target to retrive a decriptor of the 
event.
           */
          public Object getDescriptor() 
          {
              return m_descriptor;
          }
          
          protected void setDescriptor( final Object descriptor ) 
          {
              m_descriptor = descriptor;
          }
      }
      
  /*    protected class AlarmServer extends Thread {
        private Vector waypoints;
          
        {
        waypoints = new Vector();
        this.start();
        }
          
        protected static addWaypoint(long time) {
  */          
          
      /**
       * This is an implementation of an EventTrigger that triggers time 
events. 
       * NOTE:
       * I don't like the idea of a class like this in the .services interfaces 
       * but since it must somehow be as public as the interface... 
       */
      public class Alarm 
          implements EventTrigger
      {
          private Target m_target;
          private long m_starttime, m_periodicity;
          private boolean m_stop, m_reset;
          private Event m_event;
          private String m_name;
          private Scheduler m_parent;
          
          // public memo for periodicity;
          public static final long SEC = 1000;
          public static final long MIN = 60 * SEC;
          public static final long HOUR = 60 * MIN;
          public static final long DAY = 24 * HOUR;
          public static final long MONTH = 30 * DAY; // 30.416 * DAY 
          public static final long YEAR = 365 * DAY;
  
          // constructors
          public Alarm( final long starttime )
          {
              this( starttime, null, 0 );
          }
          
          public Alarm( final long starttime, final Object memo )
          {
              this( starttime, memo, 0 );
          }
          
          public Alarm( final long starttime, final Object memo, final long 
periodicity )
          {
              if( starttime < 0 || periodicity < 0 ) 
              {
                  throw new IllegalArgumentException( "starttime and 
periodicity must be " +
                                                      "both positive");
              }
  
              m_starttime = starttime;
              m_periodicity = periodicity;
              m_event = new Event( memo );
          }
  
          public Alarm( final Date startdate ) 
          {
              this( startdate, null, 0 );
          }
          
          public Alarm( final Date startdate, final Object memo ) 
          {
              this( startdate, memo, 0 );
          }
  
          public Alarm( final Date startdate, final Object memo, final long 
periodicity ) 
          {
              this( startdate.getTime() - new Date().getTime(), memo, 
periodicity );
          }
              
          public void initialize( final String name, final Target target, final 
Scheduler parent ) 
          {
              m_target = target;
              m_name = name;
              m_parent = parent;
          }
  
          public void run() 
          {
              boolean again = true;
  
              while( again ) 
              {
                  synchronized( this ) 
                  {
                      try { wait( m_starttime ); } 
                      catch( final InterruptedException ie ) {}
                      if( m_stop ) 
                      {
                          again = false;
                      }
                      else if( m_reset ) 
                      {
                          m_reset = false;
                      }
                      else 
                      {
                          m_event.setDescriptor( new Date() );
                          m_target.wake( m_name, m_event );
                          m_starttime = m_periodicity;
                          again = ( m_periodicity != 0 );
                          if( !again ) m_parent.removeAlarm( m_name );
                      }
                  }
              }
          }
  
          public void reset() 
          {
              synchronized( this ) 
              {
                  m_reset = true;
                  notifyAll();
              }
          }
      
          public void stop() 
          {
              synchronized( this ) 
              {
                  m_stop = true;
                  notifyAll();
              }
          }
      }
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/SocketServer.java
  
  Index: SocketServer.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services;
  
  import java.net.InetAddress;
  import java.net.Socket;
  import org.apache.avalon.Component;
  import org.apache.phoenix.Service;
  
  /**
   * @author  Federico Barbieri <[EMAIL PROTECTED]>
   * @deprecated This class is deprecated in favour of 
org.apache.avalon.cornerstone.sockets.* and 
org.apache.cornerstone.services.connection.*. This still has bugs with respect 
to closing connections at shutdown time and it also exhibits scalability 
problems.
   */
  public interface SocketServer 
      extends Service
  {
      String DEFAULT = "DEFAULT";
      String IPFILTERING = "IPFILTERING";
      String TLS = "TLS";
  
      void openListener( String name, 
                         String type, 
                         int port, 
                         InetAddress bind, 
                         SocketServer.SocketHandler handler );
  
      void openListener( String name, String type, int port, SocketHandler 
handler );
  
      void closeListener( String name );
  
      public interface SocketHandler 
      {
          /**
           * Menage request on passed socket.
           *
           * @param socket The opened socket. This method is called by a 
Listener.
           */
          void parseRequest( Socket socket );
      }
  
      public interface Listener 
          extends Component, Runnable 
      {
          void listen( int port, SocketHandler handler, InetAddress bind );
      }
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/Store.java
  
  Index: Store.java
  ===================================================================
  
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services;
  
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.util.Iterator;
  import org.apache.avalon.Component;
  import org.apache.avalon.ComponentManagerException;
  import org.apache.avalon.ComponentSelector;
  import org.apache.phoenix.Service;
  
  /**
   * @author Federico Barbieri <[EMAIL PROTECTED]>
   */
  public interface Store
      extends Service, ComponentSelector
  {
      /**
       * This method accept a Configuration object as hint and return the 
       * corresponding Repository. 
       * The Configuration must be in the form of:
       * <repository destinationURL="[URL of this repository]"
       *             type="[repository type ex. OBJECT or STREAM or MAIL etc.]"
       *             model="[repository model ex. PERSISTENT or CACHE etc.]">
       *   [addition configuration]
       * </repository>
       */
      Component select( Object hint ) 
          throws ComponentManagerException;
  
      /**
       * Generic Repository interface
       */
      public interface Repository 
          extends Component
      {
          Repository getChildRepository( String childName );
      }
      
      /**
       * Repository for Serializable Objects.
       */
      public interface ObjectRepository 
          extends Repository
      {
          Object get( String key );
  
          void put( String key, Object value );
  
          void remove( String key );
  
          boolean containsKey( String key );
  
          Iterator list();
      }
  
      /**
       * Repository for Streams 
       */
      public interface StreamRepository 
          extends Repository
      {
          OutputStream put( String key );
  
          InputStream get( String key );
  
          void remove( String key );
  
          Iterator list();
      }
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/connection/ConnectionHandler.java
  
  Index: ConnectionHandler.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.connection;
  
  import java.io.IOException;
  import java.net.ProtocolException;
  import java.net.Socket;
  import org.apache.avalon.Component;
  
  /**
   * This interface is the way in which handlers are created.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface ConnectionHandler
      extends Component
  {
      /**
       * Handle a connection.
       * This handler is responsible for processing connections as they occur.
       *
       * @param connection the connection
       * @exception IOException if an error reading from socket occurs
       * @exception ProtocolException if an error handling connection occurs
       */
      void handleConnection( Socket connection ) 
          throws IOException, ProtocolException;
  }
  
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/connection/ConnectionHandlerFactory.java
  
  Index: ConnectionHandlerFactory.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.connection;
  
  /**
   * This interface is the way in which handlers are created.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface ConnectionHandlerFactory
  {
      /**
       * Construct an appropriate ConnectionHandler.
       *
       * @return the new ConnectionHandler
       * @exception Exception if an error occurs
       */
      ConnectionHandler createConnectionHandler()
          throws Exception;
  }
  
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/connection/ConnectionManager.java
  
  Index: ConnectionManager.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.connection;
  
  import java.net.ServerSocket;
  import org.apache.phoenix.Service;
  import org.apache.avalon.util.thread.ThreadPool;
  
  /**
   * This is the service through which ConnectionManagement occurs.
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface ConnectionManager
      extends Service
  {
      /**
       * Start managing a connection.
       * Management involves accepting connections and farming them out to 
threads 
       * from pool to be handled.
       *
       * @param name the name of connection
       * @param socket the ServerSocket from which to 
       * @param handlerFactory the factory from which to aquire handlers
       * @param threadPool the thread pool to use
       * @exception Exception if an error occurs
       */
      void connect( String name, 
                    ServerSocket socket,
                    ConnectionHandlerFactory handlerFactory,
                    ThreadPool threadPool )
          throws Exception;
  
      /**
       * Start managing a connection. 
       * This is similar to other connect method except that it uses default 
thread pool.
       *
       * @param name the name of connection
       * @param socket the ServerSocket from which to 
       * @param handlerFactory the factory from which to aquire handlers
       * @exception Exception if an error occurs
       */
      void connect( String name, 
                    ServerSocket socket, 
                    ConnectionHandlerFactory handlerFactory )
          throws Exception;
  
      /**
       * This shuts down all handlers and socket, waiting for each to 
gracefully shutdown.
       *
       * @param name the name of connection
       * @exception Exception if an error occurs
       */
      void disconnect( String name )
          throws Exception;
  
      /**
       * This shuts down all handlers and socket. 
       * If tearDown is true then it will forcefully shutdown all connections 
and try 
       * to return as soon as possible. Otherwise it will behave the same as 
       * void disconnect( String name );
       *
       * @param name the name of connection
       * @param tearDown if true will forcefully tear down all handlers
       * @exception Exception if an error occurs
       */
      void disconnect( String name, boolean tearDown )
          throws Exception;
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/scheduler/CronTimeTrigger.java
  
  Index: CronTimeTrigger.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.scheduler;
  
  import java.util.Calendar;
  import java.util.Date;
  import java.util.GregorianCalendar;
  
  /**
   * This is the holder triggers based on standard crontabs format.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public class CronTimeTrigger
      implements TimeTrigger
  {
      protected final int    m_minute;
      protected final int    m_hour;
      protected final int    m_dayOfMonth;
      protected final int    m_month;
      protected final int    m_dayOfWeek;
      protected final int    m_year;
      
      /**
       * Constructor for CronTimeTrigger.
       * Day is either day of week or day of month depending on value of 
isDayOfWeek.
       * if (isDayOfWeek == true) then valid values are 1-7 otherwise the values
       * are 1-31
       *
       * @param minute the minute at which job is scheduled. (0-59)
       * @param hour hour at which job is scheduled. (0-23 or -1 for every hour)
       * @param month the month at which job is scheduled. (0-11 or -1 for 
every month)
       * @param year the year when job is scheduled (-1 implies every year)
       * @param day the day 
       * @param isDayOfWeek true if day is a day of week or false if day is day 
of month 
       */
      public CronTimeTrigger( final int minute, 
                              final int hour, 
                              final int day, 
                              final int month,
                              final int year, 
                              final boolean isDayOfWeek )
      {
          m_minute = minute;
          m_hour = hour;
          m_month = month;
          m_year = year;
  
          if( isDayOfWeek )
          {
              m_dayOfMonth = -1;
              m_dayOfWeek = day; 
          }
          else
          {
              m_dayOfMonth = day;
              m_dayOfWeek = -1; 
          }
      }
  
      /**
       * Retrieve the next time at which this trigger activates.
       *
       * @return the time at which the trigger will activate
       */
      public long getTimeAfter( final long time )
      {
          //first create calendars 
          final Date timeMarker = new Date( time );
          final GregorianCalendar relativeTo = new GregorianCalendar();        
          relativeTo.setTime( timeMarker );
          relativeTo.set( Calendar.SECOND, 0 );
  
          final GregorianCalendar next = (GregorianCalendar)relativeTo.clone();
          
          if( -1 != m_minute ) next.set( Calendar.MINUTE, m_minute );
          else
          {
              if( -1 == m_hour && -1 == m_month && -1 == m_year )
              {
                  //roll minutes if all other values -1
                  next.add( Calendar.MINUTE, 1 );
              }
              else
              {
                  next.set( Calendar.MINUTE, 0 );
              }
          }
  
          if( -1 != m_hour ) 
          {
              next.set( Calendar.HOUR_OF_DAY, m_hour );
              if( -1 == m_minute ) next.set( Calendar.MINUTE, 0 );
          }
  
          if( -1 != m_month ) 
          {
              next.set( Calendar.MONTH, m_month );
              if( -1 == m_hour ) next.set( Calendar.HOUR_OF_DAY, 0 );
              if( -1 == m_minute ) next.set( Calendar.MINUTE, 0 );
          }
  
          if( -1 != m_year ) 
          {
              next.set( Calendar.YEAR, m_year );
              if( -1 == m_month ) next.set( Calendar.MONTH, 0 );
              if( -1 == m_hour ) next.set( Calendar.HOUR_OF_DAY, 0 );
              if( -1 == m_minute ) next.set( Calendar.MINUTE, 0 );
          }
  
          //use zeroed constant to make if statements easier to read
          final int minute = ( -1 != m_minute ) ? m_minute : 0;
          final int rminute = relativeTo.get( Calendar.MINUTE );
          
          if( -1 == m_year && -1 == m_month && -1 == m_hour && 
              -1 != m_minute && rminute >= minute )
          {
              //for every hour jobs and job is done this hour
              next.add( Calendar.HOUR_OF_DAY, 1 );
          }
  
          //use zeroed constant to make if statements easier to read
          final int hour = ( -1 != m_hour ) ? m_hour : 0;
          final int rhour = relativeTo.get( Calendar.HOUR_OF_DAY );
  
          //System.out.println("m_month=" + m_month );
          //System.out.println("m_hour=" + m_hour );
          //System.out.println("m_minute=" + m_minute );
          //System.out.println("relativeTo=" + rhour + ":" + rminute );
  
          if( -1 == m_dayOfMonth && -1 == m_dayOfWeek &&
              ( 
               //for when past hour that was scheduled to run
               ( -1 != m_hour && rhour > hour ) ||
  
               //for the case where you have to wrap over day
               //when hour is not specified
               ( -1 == m_hour && rhour == 24 && rminute >= minute ) ||
  
               //for when you are past time of day where both minute and 
               //hour are specified
               ( -1 != m_hour && rhour == hour && rminute >= minute ) 
               )
              )
          {
              //for jobs scheduled everyday and job is done this day
              next.roll( Calendar.DAY_OF_YEAR, true );
          }
  
          final int month = ( -1 != m_month ) ? m_month : 0;
          final int dayOfMonth = ( -1 != m_dayOfMonth ) ? m_dayOfMonth : 0;
  
          //update the year if ran job for this year
          if( -1 != m_month && -1 == m_year &&
              ( relativeTo.get( Calendar.MONTH ) > month ||
                ( relativeTo.get( Calendar.MONTH ) == month &&
                  ( relativeTo.get( Calendar.DAY_OF_MONTH ) > dayOfMonth ||
                    ( relativeTo.get( Calendar.DAY_OF_MONTH ) == dayOfMonth &&
                      ( relativeTo.get( Calendar.HOUR_OF_DAY ) > hour ||
                        ( relativeTo.get( Calendar.HOUR_OF_DAY ) == hour &&
                          ( relativeTo.get( Calendar.MINUTE ) >= minute ) ) ) ) 
) ) ) ) 
          {
              next.add( Calendar.YEAR, 1 );
          }
  
          if( -1 != m_year )
          {
              //if past current year or already executed job this year then 
              //bail out
              if( relativeTo.get( Calendar.YEAR ) > m_year ||
                  ( relativeTo.get( Calendar.YEAR )== m_year &&
                    ( relativeTo.get( Calendar.MONTH ) > month ||
                      ( relativeTo.get( Calendar.MONTH ) == month &&
                        ( relativeTo.get( Calendar.DAY_OF_MONTH ) > dayOfMonth 
||
                          ( relativeTo.get( Calendar.DAY_OF_MONTH ) == 
dayOfMonth &&
                            ( relativeTo.get( Calendar.HOUR_OF_DAY ) > hour ||
                              ( relativeTo.get( Calendar.HOUR_OF_DAY ) == hour 
&&
                                ( relativeTo.get( Calendar.MINUTE ) >= minute ) 
) ) ) ) ) ) ) )
              {
                  return -1;
              }
          }
  
          //schedule weekly jobs
          if( -1 != m_dayOfWeek )
          {
              final int dayWait = 
                  ( 7 + m_dayOfWeek - relativeTo.get( Calendar.DAY_OF_WEEK ) ) 
% 7;
  
              if( 0 != dayWait )
              {
                  next.add( Calendar.DAY_OF_YEAR, dayWait );
              }
              else if( relativeTo.get( Calendar.HOUR_OF_DAY ) > hour ||
                       ( relativeTo.get( Calendar.HOUR_OF_DAY ) == hour && 
                         relativeTo.get( Calendar.MINUTE ) >= minute ) ) 
              {
                  //if job scheduled for today has passed then schedule on next 
week
                  next.add( Calendar.DAY_OF_YEAR, 7 );
              }
          }
          // Schedule monthly jobs
          else if( -1 != m_dayOfMonth )
          {
              next.set( Calendar.DAY_OF_MONTH, m_dayOfMonth );
        
              //if this months job has already run then schedule next week
              if ( m_month == -1 &&
                   ( relativeTo.get( Calendar.DAY_OF_MONTH ) > m_dayOfMonth ||
                     ( relativeTo.get( Calendar.DAY_OF_MONTH ) == m_dayOfMonth 
&&
                       ( relativeTo.get( Calendar.HOUR_OF_DAY ) > hour ||
                         ( relativeTo.get( Calendar.HOUR_OF_DAY ) == hour && 
                           relativeTo.get( Calendar.MINUTE ) >= minute ) ) ) ) 
) 
              {
                  next.roll( Calendar.MONTH, true );
              }
          }
          
          //return time in millis
          return next.getTime().getTime();  
      }
  
      public String toString()
      {
          final StringBuffer sb = new StringBuffer();
          sb.append( "CronTimeTrigger[ " );
  
          if( -1 != m_minute )
          {
              sb.append( "minute=" );
              sb.append( m_minute );
              sb.append( " " );
          }
  
          if( -1 != m_hour )
          {
              sb.append( "hour=" );
              sb.append( m_hour );
              sb.append( " " );
          }
  
          if( -1 != m_month )
          {
              sb.append( "month=" );
              sb.append( m_month );
              sb.append( " " );
          }
  
          if( -1 != m_year )
          {
              sb.append( "year=" );
              sb.append( m_year );
              sb.append( " " );
          }
  
          if( -1 != m_dayOfMonth )
          {
              sb.append( "dayOfMonth=" );
              sb.append( m_dayOfMonth );
              sb.append( " " );
          }
  
          if( -1 != m_dayOfWeek )
          {
              sb.append( "dayOfWeek=" );
              sb.append( m_dayOfWeek );
              sb.append( " " );
          }
          
          sb.append("]");
  
          return sb.toString();
      }
  }
  
  
  
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/scheduler/Job.java
  
  Index: Job.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.scheduler;
  
  import org.apache.avalon.configuration.Configuration;
  
  /**
   * This is the interface to hold a particular CronJob.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface Job
  {
      /**
       * Retrieve the next time at which this task needs to be run.
       *
       * @return the time at which the task needs to be run
       */
      long getTimeAfter( long time );
  
      /**
       * Retrieve task to execute at each time slice.
       *
       * @return the executable
       */
      Runnable getRunnable(); 
  
      /**
       * Retrieve configuraiton data to use to configure task.
       *
       * @return configuration data
       */
      Configuration getConfiguration(); 
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/scheduler/JobScheduler.java
  
  Index: JobScheduler.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.scheduler;
  
  import org.apache.phoenix.Service;
  
  /**
   * This service provides a way to regularly schedule jobs.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface JobScheduler
      extends Service
  {
      /**
       * Add a job to be scheduled to run.
       * Note that if a job already has same name then it is removed.
       *
       * @param name the name of job
       * @param job the job
       */
      void addJob( String name, Job job );
  
      /**
       * Remove a job scheduled to be run by name.
       *
       * @param name the name of the job
       */
      void removeJob( String name );
  
      /**
       * Retrieve a job by name
       *
       * @param name the name of job
       * @return the Job
       */
      Job getJob( String name );
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/scheduler/PeriodicTimeTrigger.java
  
  Index: PeriodicTimeTrigger.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.scheduler;
  
  /**
   * This is the triggers based on a start time and period.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public class PeriodicTimeTrigger
      implements TimeTrigger
  {
      protected final long    m_startTime;
      protected final long    m_period;
      
      public PeriodicTimeTrigger( final int startTime, final int period )
      {
          final long current = System.currentTimeMillis();
  
          if( -1 == startTime )
          {
              m_startTime = current;
          }
          else
          {
              m_startTime = current + startTime;
          }
  
          m_period = period;
      }
  
      /**
       * Retrieve the next time at which this trigger activates.
       *
       * @return the time at which the trigger will activate
       */
      public long getTimeAfter( final long time )
      {
          if( time <= m_startTime ) return m_startTime;
          else
          {
              if( -1 == m_period ) return -1;
  
              final long over = time - m_startTime;
              final long remainder = over % m_period;
  
              return time + ( m_period - remainder );
          }
      }
  
      public String toString()
      {
          final StringBuffer sb = new StringBuffer();
          sb.append( "PeriodicTimeTrigger[ " );
  
          sb.append( "start=" );
          sb.append( m_startTime );
          sb.append( " " );
  
          if( -1 != m_period )
          {
              sb.append( "period=" );
              sb.append( m_period );
              sb.append( " " );
          }
          
          sb.append("]");
  
          return sb.toString();
      }
  }
  
  
  
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/scheduler/Target.java
  
  Index: Target.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.scheduler;
  
  import org.apache.avalon.configuration.Configuration;
  
  /**
   * This is the interface to implement to receive notification trigger.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   * @author <a href="mailto:[EMAIL PROTECTED]">Federico Barbieri</a>
   * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
   */
  public interface Target
  {
      /**
       * Notify target that trigger has occured.
       *
       * @param triggerName the name of trigger
       */
      void targetTriggered( String triggerName );
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/scheduler/TimeScheduler.java
  
  Index: TimeScheduler.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.scheduler;
  
  import java.util.NoSuchElementException;
  import org.apache.phoenix.Service;
  
  /**
   * This service provides a way to regularly schedule jobs.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface TimeScheduler
      extends Service
  {
      /**
       * Schedule a time based trigger.
       * Note that if a TimeTrigger already has same name then it is removed.
       *
       * @param name the name of the trigger
       * @param trigger the trigger
       * @param target the target
       */
      void addTrigger( String name, TimeTrigger trigger, Target target );
  
      /**
       * Remove a scheduled trigger by name.
       *
       * @param name the name of the trigger
       * @exception NoSuchElementException if no trigger exists with that name
       */
      void removeTrigger( String name )
          throws NoSuchElementException;
  
      /**
       * Force a trigger time to be recalculated.
       *
       * @param name the name of the trigger
       * @exception NoSuchElementException if no trigger exists with that name
       */
      void resetTrigger( String name )
          throws NoSuchElementException;
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/scheduler/TimeTrigger.java
  
  Index: TimeTrigger.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.scheduler;
  
  /**
   * This is the marker interface for Triggers.
   * Triggers can be time-based, event-based or other.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface TimeTrigger
      extends Trigger
  {
      /**
       * Retrieve the next time at trigger activates relative to another time.
       *
       * @return the time at which the trigger activates
       */
      long getTimeAfter( long time );
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/scheduler/Trigger.java
  
  Index: Trigger.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.scheduler;
  
  /**
   * This is the marker interface for Triggers.
   * Triggers can be time-based, event-based or other.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface Trigger
  {
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/scheduler/test/CronTimeTriggerTestlet.java
  
  Index: CronTimeTriggerTestlet.java
  ===================================================================
  /* 
   * 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 file. 
   */ 
  package org.apache.cornerstone.services.scheduler.test;
   
  import java.util.Calendar;
  import java.util.Date;
  import org.apache.cornerstone.services.scheduler.CronTimeTrigger; 
  import org.apache.testlet.AbstractTestlet; 
   
  /** 
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a> 
   */ 
  public final class CronTimeTriggerTestlet 
      extends AbstractTestlet 
  {
      protected final static long MINUTE = 60000;
      protected final static long HOUR = 60 * MINUTE;
      protected final static long DAY = 24 * HOUR;
      protected final static long WEEK = 7 * DAY;
  
      public void testMinutes()
      {
          final CronTimeTrigger trigger = new CronTimeTrigger( -1, -1, -1, -1, 
-1, true );
  
          final Calendar now = Calendar.getInstance();
          now.set( Calendar.SECOND, 0 );
          
          long time = now.getTime().getTime();
          long next = trigger.getTimeAfter( time );
  
          for( int i = 0; i < 5; i++ )
          {
              final long delta = next - time;
              assert("Time increments of 1 minute", MINUTE == delta );
              time = next;
              next = trigger.getTimeAfter( time );
          }
      }
  
      public void testHours()
      {
          final CronTimeTrigger trigger = new CronTimeTrigger( 51, -1, -1, -1, 
-1, true );
  
          final Calendar now = Calendar.getInstance();
          now.set( Calendar.SECOND, 0 );
          now.set( Calendar.MINUTE, 2 );
          
          long time = now.getTime().getTime();
          long next = trigger.getTimeAfter( time );
          long delta = next - time;
  
          final long expected = (51 - 2) * MINUTE;
          assert( "Collect time at start", expected == delta );
  
          time = next;
          next = trigger.getTimeAfter( time );
  
          for( int i = 0; i < 5; i++ )
          {
              delta = next - time;
              assert( "Time increments of 1 hour", HOUR == delta );
              time = next;
              next = trigger.getTimeAfter( time );
          }
      }
  
      public void testDays()
      {
          final CronTimeTrigger trigger = new CronTimeTrigger( 51, 5, -1, -1, 
-1, true );
   
          final Calendar now = Calendar.getInstance();
          now.set( Calendar.SECOND, 0 );
          now.set( Calendar.MINUTE, 2 );
          now.set( Calendar.HOUR_OF_DAY, 3 );
          
          long time = now.getTime().getTime();
          long next = trigger.getTimeAfter( time );
          long delta = next - time;
  
          final long expected = (51 - 2) * MINUTE + HOUR * (5 - 3);
  
          assert( "Collect time at start", expected == delta );
  
          time = next;
          next = trigger.getTimeAfter( time );
  
          for( int i = 0; i < 5; i++ )
          {
              delta = next - time;
              assert( "Time increments of 1 day", DAY == delta );
              time = next;
              next = trigger.getTimeAfter( time );
          }
      }
  
      public void testMinutelessDays()
      {
          final CronTimeTrigger trigger = new CronTimeTrigger( -1, 5, -1, -1, 
-1, true );
  
          final Calendar now = Calendar.getInstance();
          now.set( Calendar.SECOND, 0 );
          now.set( Calendar.MINUTE, 2 );
          now.set( Calendar.HOUR_OF_DAY, 3 );
          
          long time = now.getTime().getTime();
          long next = trigger.getTimeAfter( time );
          long delta = next - time;
  
          final long expected = ( -2 ) * MINUTE + HOUR * (5 - 3);
          assert( "Collect time at start", expected == delta );
  
          time = next;
          next = trigger.getTimeAfter( time );
  
          for( int i = 0; i < 5; i++ )
          {
              delta = next - time;
              assert( "Time increments of 1 day", DAY == delta );
              time = next;
              next = trigger.getTimeAfter( time );
          }
      }
  
      public void testWeekly()
      {
          final CronTimeTrigger trigger = new CronTimeTrigger( -1, 5, 2, -1, 
-1, true );
  
          final Calendar now = Calendar.getInstance();
          now.set( Calendar.SECOND, 0 );
          now.set( Calendar.MINUTE, 2 );
          now.set( Calendar.HOUR_OF_DAY, 3 );
          now.set( Calendar.DAY_OF_WEEK, 3 );
          now.set( Calendar.MONTH, 0 );
  
          long time = now.getTime().getTime();
          long next = trigger.getTimeAfter( time );
          long delta = next - time;
  
          final long expected = ( -2 ) * MINUTE + HOUR * (5 - 3) + DAY * 6;
          assert( "Collect time at start", expected == delta );
  
          time = next;
          next = trigger.getTimeAfter( time );
  
          for( int i = 0; i < 5; i++ )
          {
              delta = next - time;
              assert( "Time increments of 1 hour", WEEK == delta );
              time = next;
              next = trigger.getTimeAfter( time );
          }
      }
  
      public void testWeekly2()
      {
          final CronTimeTrigger trigger = new CronTimeTrigger( 3, 5, 2, -1, -1, 
true );
  
          final Calendar now = Calendar.getInstance();
          now.set( Calendar.SECOND, 0 );
          now.set( Calendar.MINUTE, 2 );
          now.set( Calendar.HOUR_OF_DAY, 3 );
          now.set( Calendar.DAY_OF_WEEK, 3 );
          now.set( Calendar.MONTH, 0 );
          
          long time = now.getTime().getTime();
          long next = trigger.getTimeAfter( time );
          long delta = next - time;
  
          final long expected = ( 1 ) * MINUTE + HOUR * (5 - 3) + DAY * 6;
          assert( "Collect time at start", expected == delta );
  
          time = next;
          next = trigger.getTimeAfter( time );
  
          for( int i = 0; i < 5; i++ )
          {
              delta = next - time;
              assert( "Time increments of 1 hour", WEEK == delta );
              time = next;
              next = trigger.getTimeAfter( time );
          }
      }
  
      public void testDayAMonth()
      {
          final CronTimeTrigger trigger = new CronTimeTrigger( 3, 5, 2, -1, -1, 
false );
  
          final Calendar now = Calendar.getInstance();
          now.set( Calendar.SECOND, 0 );
          now.set( Calendar.MINUTE, 2 );
          now.set( Calendar.HOUR_OF_DAY, 3 );
          now.set( Calendar.DAY_OF_MONTH, 1 );
          
          long time = now.getTime().getTime();
          long next = trigger.getTimeAfter( time );
          long delta = next - time;
  
          long expected = ( 1 ) * MINUTE + HOUR * (5 - 3) + DAY * 1;
          assert( "Collect time at start", expected == delta );
  
          int month = now.get( Calendar.MONTH );
  
          time = next;
          next = trigger.getTimeAfter( time );
  
          for( int i = 0; i < 5; i++ )
          {
              month = (month + 1) % 12;
  
              now.setTime( new Date( next ) );
              
              assert( "Minute", now.get( Calendar.MINUTE ) == 3 );
              assert( "Hour of Day", now.get( Calendar.HOUR_OF_DAY ) == 5 );
              assert( "Day of month", now.get( Calendar.DAY_OF_MONTH ) == 2 );
              assert( "Month", now.get( Calendar.MONTH ) == month );
  
              time = next;
              next = trigger.getTimeAfter( time );
          }
      }
  
      public void testYearly()
      {
          final CronTimeTrigger trigger = new CronTimeTrigger( -1, -1, -1, 4, 
-1, true );
          //System.out.println( "CronTimeTrigger: " + trigger );
  
          final Calendar now = Calendar.getInstance();
          now.set( Calendar.SECOND, 0 );
          now.set( Calendar.MINUTE, 2 );
          now.set( Calendar.HOUR_OF_DAY, 3 );
          now.set( Calendar.DAY_OF_MONTH, 1 );
          now.set( Calendar.MONTH, 3 );
          
          long time = now.getTime().getTime();
          long next = trigger.getTimeAfter( time );
          long delta = next - time;
  
          now.setTime( new Date( next ) );
          
          assert( "Minute", now.get( Calendar.MINUTE ) == 0 );
          assert( "Hour of Day", now.get( Calendar.HOUR_OF_DAY ) == 0 );
          assert( "Day of month", now.get( Calendar.DAY_OF_MONTH ) == 1 );
          assert( "Month", now.get( Calendar.MONTH ) == 4 );
  
          time = next;
          next = trigger.getTimeAfter( time );
  
          for( int i = 0; i < 5; i++ )
          {
              now.setTime( new Date( next ) );
  
              //System.out.println( "day/Month hr:min " + now.get( 
Calendar.DAY_OF_MONTH ) +
              //"/" + now.get( Calendar.MONTH ) + " " + 
              //now.get( Calendar.HOUR ) + ":" + now.get( Calendar.MINUTE ) );
              
              assert( "Minute", now.get( Calendar.MINUTE ) == 0 );
              assert( "Hour of Day", now.get( Calendar.HOUR_OF_DAY ) == 0 );
              assert( "Day of month", now.get( Calendar.DAY_OF_MONTH ) == 1 );
              assert( "Month", now.get( Calendar.MONTH ) == 4 );
  
              time = next;
              next = trigger.getTimeAfter( time );
          }
      }
  
      public void testOneYear()
      {
          final CronTimeTrigger trigger = new CronTimeTrigger( -1, -1, -1, -1, 
2020, true );
          //System.out.println( "CronTimeTrigger: " + trigger );
  
          final Calendar now = Calendar.getInstance();
          now.set( Calendar.SECOND, 0 );
          now.set( Calendar.MINUTE, 2 );
          now.set( Calendar.HOUR_OF_DAY, 3 );
          now.set( Calendar.DAY_OF_MONTH, 1 );
          now.set( Calendar.MONTH, 3 );
          now.set( Calendar.YEAR, 2000 );
  
          long time = now.getTime().getTime();
          long next = trigger.getTimeAfter( time );
          long delta = next - time;
  
          now.setTime( new Date( next ) );
          
          assert( "Minute", now.get( Calendar.MINUTE ) == 0 );
          assert( "Hour of Day", now.get( Calendar.HOUR_OF_DAY ) == 0 );
          assert( "Day of month", now.get( Calendar.DAY_OF_MONTH ) == 1 );
          assert( "Month", now.get( Calendar.MONTH ) == 0 );
          assert( "year", now.get( Calendar.YEAR ) == 2020 );
  
          time = next;
          next = trigger.getTimeAfter( time );
          assert( "year", -1 == next );
      }
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/security/AuthorizationManager.java
  
  Index: AuthorizationManager.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.security;
  
  import java.security.Permission;
  import java.security.AccessControlException;
  import java.security.Principal;
  import org.apache.phoenix.Service;
  
  /**
   * Service to manage authorization. 
   * May be succeeded by JAAS in the the future.
   *
   * Warning: This is experimental and will most likely change in the future.
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface AuthorizationManager 
      extends Service
  {
      //Permissions getPermissions( Principal principal );
      void checkPermission( Principal principal, Permission permission )
          throws AccessControlException;
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/security/MutableRealm.java
  
  Index: MutableRealm.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.security;
  
  import java.security.Principal;
  
  /**
   * Extends Realm to allow addition and subtraction of Principals.
   *
   * Warning: This is experimental and will most likely change in the future.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface MutableRealm
      extends Realm
  {
      void addPrincipal( Principal principal );
      void removePrincipal( Principal principal );
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/security/Realm.java
  
  Index: Realm.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.security;
  
  import java.security.Principal;
  import java.util.Iterator;
  import org.apache.phoenix.Service;
  
  /**
   * Interface for a Realm. 
   * A Realm is a grouping of principals. The names of principals are guarenteed
   * to be unique within a realm. Sample realms may be 
   * <ul>
   *   <li>unix domain</li>
   *   <li>NT domain</li>
   *   <li>set of users who have mail forwarding accounts</li>
   *   <li>set of users who have access to HTTP Realm "Foo"</li>
   * </ul>
   *
   * Warning: This is experimental and will most likely change in the future.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface Realm
      extends Service
  {
      Principal getPrincipal( String name );
      Iterator getPrincipalNames();
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/security/RoleManager.java
  
  Index: RoleManager.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.security;
  
  import java.security.Principal;
  import org.apache.phoenix.Service;
  
  /**
   * Service to manager the role mappings for principles.
   * TODO: This should be refactored to be per-Realm.
   *
   * Warning: This is experimental and will most likely change in the future.
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface RoleManager 
      extends Service
  {
      boolean isPrincipalInRole( Principal principal, String role );
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/sockets/ServerSocketFactory.java
  
  Index: ServerSocketFactory.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.sockets;
  
  import java.io.IOException;
  import java.net.InetAddress;
  import java.net.ServerSocket;
  import org.apache.avalon.Component;
  
  /**
   * The interface used to create server sockets.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface ServerSocketFactory
      extends Component
  {
      /**
       * Creates a socket on specified port.
       *
       * @param port the port
       * @return the created ServerSocket
       * @exception IOException if an error occurs
       */
      ServerSocket createServerSocket( int port )
          throws IOException;
  
      /**
       * Creates a socket on specified port with a specified backLog.
       *
       * @param port the port
       * @param backLog the backLog
       * @return the created ServerSocket
       * @exception IOException if an error occurs
       */
      ServerSocket createServerSocket( int port, int backLog )
          throws IOException;
  
      /**
       * Creates a socket on a particular network interface on specified port 
       * with a specified backLog.
       *
       * @param port the port
       * @param backLog the backLog
       * @param bindAddress the network interface to bind to.
       * @return the created ServerSocket
       * @exception IOException if an error occurs
       */
      ServerSocket createServerSocket( int port, int backLog, InetAddress 
bindAddress )
          throws IOException;
  }
  
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/sockets/SocketFactory.java
  
  Index: SocketFactory.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.sockets;
  
  import java.io.IOException;
  import java.net.InetAddress;
  import java.net.Socket;
  import org.apache.avalon.Component;
  
  /**
   * The interface used to create client sockets.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface SocketFactory
      extends Component
  {
      /**
       * Create a socket and connect to remote address specified.
       *
       * @param address the remote address
       * @param port the remote port
       * @return the socket
       * @exception IOException if an error occurs
       */
      Socket createSocket( InetAddress address, int port )
          throws IOException;
  
      /**
       * Create a socket and connect to remote address specified 
       * originating from specified local address.
       *
       * @param address the remote address
       * @param port the remote port
       * @param localAddress the local address
       * @param localPort the local port
       * @return the socket
       * @exception IOException if an error occurs
       */
      Socket createSocket( InetAddress address, int port, 
                           InetAddress localAddress, int localPort )
          throws IOException;
  }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/src/java/org/apache/cornerstone/services/sockets/SocketManager.java
  
  Index: SocketManager.java
  ===================================================================
  /*
   * 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 file.
   */
  package org.apache.cornerstone.services.sockets;
  
  import org.apache.avalon.ComponentNotFoundException;
  import org.apache.phoenix.Service;
  
  /**
   * Service to manager the socket factories.
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Federico Barbieri</a>
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface SocketManager 
      extends Service
  {
      /**
       * Retrieve a server socket factory by name.
       *
       * @param name the name of server socket factory
       * @return the ServerSocketFactory
       * @exception ComponentNotFoundException if server socket factory is not 
available
       */
      ServerSocketFactory getServerSocketFactory( String name )
          throws ComponentNotFoundException;
  
      /**
       * Retrieve a client socket factory by name.
       *
       * @param name the name of client socket factory
       * @return the SocketFactory
       * @exception ComponentNotFoundException if socket factory is not 
available
       */
      SocketFactory getSocketFactory( String name )
          throws ComponentNotFoundException;
  }
  
  
  

Reply via email to