Author: scamp
Date: Wed Feb  2 09:42:06 2005
New Revision: 149538

URL: http://svn.apache.org/viewcvs?view=rev&rev=149538
Log:
remved EPR references since the EPR really wasn't used

Added:
    incubator/hermes/trunk/src/java/org/apache/ws/util/thread/
    incubator/hermes/trunk/src/java/org/apache/ws/util/thread/NamedThread.java
Modified:
    
incubator/hermes/trunk/src/java/org/apache/ws/pubsub/emitter/EmitterTask.java
    
incubator/hermes/trunk/src/java/org/apache/ws/pubsub/emitter/file/FileEmitterTask.java
    
incubator/hermes/trunk/src/java/org/apache/ws/pubsub/emitter/http/HttpEmitterTask.java

Modified: 
incubator/hermes/trunk/src/java/org/apache/ws/pubsub/emitter/EmitterTask.java
URL: 
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/pubsub/emitter/EmitterTask.java?view=diff&r1=149537&r2=149538
==============================================================================
--- 
incubator/hermes/trunk/src/java/org/apache/ws/pubsub/emitter/EmitterTask.java 
(original)
+++ 
incubator/hermes/trunk/src/java/org/apache/ws/pubsub/emitter/EmitterTask.java 
Wed Feb  2 09:42:06 2005
@@ -15,8 +15,8 @@
  
*=============================================================================*/
 package org.apache.ws.pubsub.emitter;
 
-import org.apache.ws.pubsub.emitter.file.FileNotificationEmitterTask;
-import org.apache.ws.pubsub.emitter.http.HttpNotificationEmitterTask;
+import org.apache.ws.pubsub.emitter.file.FileEmitterTask;
+import org.apache.ws.pubsub.emitter.http.HttpEmitterTask;
 import org.apache.ws.pubsub.i18n.MessagesImpl;
 import org.apache.ws.pubsub.i18n.Keys;
 import org.apache.ws.util.i18n.Messages;
@@ -39,25 +39,25 @@
  * a destination URL and a destination EPR as a
  * [EMAIL PROTECTED] 
org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType}; these 
constructors are called by this class' factory method.
  */
-public abstract class NotificationEmitterTask
+public abstract class EmitterTask
    implements Runnable
 {
    /** object used to obtain I18N messages */
    private static final Messages MSG = MessagesImpl.getInstance(  );
 
    /** object used to log messages */
-   private static final Log LOG = LogFactory.getLog( 
NotificationEmitterTask.class );
+   private static final Log LOG = LogFactory.getLog( EmitterTask.class );
 
    /**
-    * Protocol emitter map: key is protocol name, value is corresponding 
[EMAIL PROTECTED] NotificationEmitterTask} class.
+    * Protocol emitter map: key is protocol name, value is corresponding 
[EMAIL PROTECTED] EmitterTask} class.
     */
    private static final HashMap PROTOCOL_EMITTER_MAP;
 
    static
    {
       PROTOCOL_EMITTER_MAP = new HashMap(  );
-      PROTOCOL_EMITTER_MAP.put( FileNotificationEmitterTask.PROTOCOL, 
FileNotificationEmitterTask.class );
-      PROTOCOL_EMITTER_MAP.put( HttpNotificationEmitterTask.PROTOCOL, 
HttpNotificationEmitterTask.class );
+      PROTOCOL_EMITTER_MAP.put( FileEmitterTask.PROTOCOL, 
FileEmitterTask.class );
+      PROTOCOL_EMITTER_MAP.put( HttpEmitterTask.PROTOCOL, 
HttpEmitterTask.class );
 
       //PROTOCOL_EMITTER_MAP.put( HttpsNotificationEmitterTask.PROTOCOL, 
HttpsNotificationEmitterTask.class );
       //PROTOCOL_EMITTER_MAP.put( FtpNotificationEmitterTask.PROTOCOL, 
FtpNotificationEmitterTask.class );
@@ -71,25 +71,19 @@
    /** The destination URL where the notification will be sent */
    private final URL m_destinationUrl;
 
-   /** The destination EPR of the notification consumer */
-   private final EndpointReferenceType m_destinationEpr;
-
    /**
     * Constructor to build the task.  This is protected to enforce that fact 
that only
-    * [EMAIL PROTECTED] #createEmitterTask(javax.xml.soap.SOAPMessage, 
org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType)}
+    * [EMAIL PROTECTED] #createEmitterTask(javax.xml.soap.SOAPMessage, String)}
     * should be used by clients to create these task objects.
     *
     * @param notif notification to send
     * @param url endpoint URL of notification consumer
-    * @param destination endpoint reference of the notification consumer
     */
-   protected NotificationEmitterTask( SOAPMessage           notif,
-                                      URL                   url,
-                                      EndpointReferenceType destination )
+   protected EmitterTask( SOAPMessage           notif,
+                                      URL                   url )
    {
       m_notification      = notif;
       m_destinationUrl    = url;
-      m_destinationEpr    = destination;
    }
 
    /**
@@ -103,11 +97,11 @@
     *
     * @throws EmitterException if failed to create the task
     */
-   public static NotificationEmitterTask createEmitterTask( SOAPMessage        
   notif,
-                                                            
EndpointReferenceType destination )
+   public static EmitterTask createEmitterTask( SOAPMessage           notif,
+                                                            String destination 
)
    throws EmitterException
    {
-      NotificationEmitterTask task;
+      EmitterTask task;
       Class                   task_class = null;
 
       LOG.debug( MSG.getMessage( Keys.CREATING_NOTIF_EMITTER, destination ) );
@@ -118,7 +112,7 @@
 
          try
          {
-            url = new URL( destination.getAddress(  ).getStringValue(  ) );
+            url = new URL( destination );
          }
          catch ( MalformedURLException murle )
          {
@@ -133,17 +127,15 @@
             Class[] sig = new Class[]
                           {
                              SOAPMessage.class,
-                             URL.class,
-                             EndpointReferenceType.class
+                             URL.class
                           };
             Object[] params = new Object[]
                               {
                                  notif,
-                                 url,
-                                 destination
+                                 url
                               };
 
-            task = (NotificationEmitterTask) task_class.getConstructor( sig 
).newInstance( params );
+            task = (EmitterTask) task_class.getConstructor( sig ).newInstance( 
params );
          }
          else
          {
@@ -192,7 +184,7 @@
     */
    public void run(  )
    {
-      LOG.debug( MSG.getMessage( Keys.EMITTING_NOTIFICATION, m_destinationEpr, 
m_notification ) );
+      LOG.debug( MSG.getMessage( Keys.EMITTING_NOTIFICATION, m_destinationUrl, 
m_notification ) );
       try
       {
          emit(  );
@@ -216,14 +208,6 @@
                                        t.getCause(  ) ) );
          }
       }
-   }
-
-   /**
-    * @return the notification consumer's EPR
-    */
-   protected EndpointReferenceType getDestinationEpr(  )
-   {
-      return m_destinationEpr;
    }
 
    /**

Modified: 
incubator/hermes/trunk/src/java/org/apache/ws/pubsub/emitter/file/FileEmitterTask.java
URL: 
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/pubsub/emitter/file/FileEmitterTask.java?view=diff&r1=149537&r2=149538
==============================================================================
--- 
incubator/hermes/trunk/src/java/org/apache/ws/pubsub/emitter/file/FileEmitterTask.java
 (original)
+++ 
incubator/hermes/trunk/src/java/org/apache/ws/pubsub/emitter/file/FileEmitterTask.java
 Wed Feb  2 09:42:06 2005
@@ -17,12 +17,12 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.ws.pubsub.emitter.NotificationEmitterTask;
 import org.apache.ws.pubsub.emitter.EmitterException;
-import org.apache.ws.pubsub.i18n.MessagesImpl;
+import org.apache.ws.pubsub.emitter.EmitterTask;
 import org.apache.ws.pubsub.i18n.Keys;
+import org.apache.ws.pubsub.i18n.MessagesImpl;
 import org.apache.ws.util.i18n.Messages;
-import org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType;
+
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPMessage;
 import java.io.File;
@@ -36,8 +36,8 @@
  * If the file already exists, the new notification data will be appended to 
the end.
  * If the file is actually a directory, the notification filename will be 
generated.
  */
-public class FileNotificationEmitterTask
-   extends NotificationEmitterTask
+public class FileEmitterTask
+   extends EmitterTask
 {
    /** This emitter's protocol */
    public static final String PROTOCOL = "file";
@@ -46,18 +46,17 @@
    private static final Messages MSG = MessagesImpl.getInstance(  );
 
    /** object used to log messages */
-   private static final Log LOG = LogFactory.getLog( 
FileNotificationEmitterTask.class );
+   private static final Log LOG = LogFactory.getLog( FileEmitterTask.class );
 
    /**
-    * Creates a new [EMAIL PROTECTED] FileNotificationEmitterTask} object.
+    * Creates a new [EMAIL PROTECTED] FileEmitterTask} object.
     *
-    * @see NotificationEmitterTask#NotificationEmitterTask(SOAPMessage, URL, 
EndpointReferenceType)
+    * @see EmitterTask(SOAPMessage, URL)
     */
-   public FileNotificationEmitterTask( SOAPMessage           notif,
-                                       URL                   url,
-                                       EndpointReferenceType epr )
+   public FileEmitterTask( SOAPMessage           notif,
+                                       URL                   url)
    {
-      super( notif, url, epr );
+      super( notif, url );
    }
 
    /**
@@ -66,7 +65,7 @@
     * it is up to the subscriber to provide a file URI that will be suitable 
for
     * writing.  If the file is a directory, a file will be created in that 
directory.
     *
-    * @see NotificationEmitterTask#emit()
+    * @see EmitterTask#emit()
     */
    protected void emit(  )
    throws EmitterException

Modified: 
incubator/hermes/trunk/src/java/org/apache/ws/pubsub/emitter/http/HttpEmitterTask.java
URL: 
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/pubsub/emitter/http/HttpEmitterTask.java?view=diff&r1=149537&r2=149538
==============================================================================
--- 
incubator/hermes/trunk/src/java/org/apache/ws/pubsub/emitter/http/HttpEmitterTask.java
 (original)
+++ 
incubator/hermes/trunk/src/java/org/apache/ws/pubsub/emitter/http/HttpEmitterTask.java
 Wed Feb  2 09:42:06 2005
@@ -15,7 +15,7 @@
  
*=============================================================================*/
 package org.apache.ws.pubsub.emitter.http;
 
-import org.apache.ws.pubsub.emitter.NotificationEmitterTask;
+import org.apache.ws.pubsub.emitter.EmitterTask;
 import org.apache.ws.pubsub.emitter.EmitterException;
 import org.apache.ws.pubsub.i18n.MessagesImpl;
 import org.apache.ws.pubsub.i18n.Keys;
@@ -32,8 +32,8 @@
 /**
  * An emitter task that sends a notification via the HTTP protocol.
  */
-public class HttpNotificationEmitterTask
-   extends NotificationEmitterTask
+public class HttpEmitterTask
+   extends EmitterTask
 {
    /** This emitter's protocol */
    public static final String PROTOCOL = "http";
@@ -42,24 +42,23 @@
    private static final Messages MSG = MessagesImpl.getInstance(  );
 
    /** object used to log messages */
-   private static final Log LOG = LogFactory.getLog( 
HttpNotificationEmitterTask.class );
+   private static final Log LOG = LogFactory.getLog( HttpEmitterTask.class );
 
    /**
-    * Creates a new [EMAIL PROTECTED] HttpNotificationEmitterTask} object.
+    * Creates a new [EMAIL PROTECTED] HttpEmitterTask} object.
     *
-    * @see NotificationEmitterTask#NotificationEmitterTask(SOAPMessage, URL, 
EndpointReferenceType)
+    * @see EmitterTask(SOAPMessage, URL)
     */
-   public HttpNotificationEmitterTask( SOAPMessage           notif,
-                                       URL                   url,
-                                       EndpointReferenceType destination )
+   public HttpEmitterTask( SOAPMessage           notif,
+                                       URL                   url )
    {
-      super( notif, url, destination );
+      super( notif, url );
    }
 
    /**
     * Sends the notification to the destination via HTTP.
     *
-    * @see NotificationEmitterTask#emit()
+    * @see EmitterTask#emit()
     */
    protected void emit(  )
    throws EmitterException

Added: 
incubator/hermes/trunk/src/java/org/apache/ws/util/thread/NamedThread.java
URL: 
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/util/thread/NamedThread.java?view=auto&rev=149538
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/util/thread/NamedThread.java 
(added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/util/thread/NamedThread.java 
Wed Feb  2 09:42:06 2005
@@ -0,0 +1,250 @@
+/*=============================================================================*
+ *  Copyright 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.ws.util.thread;
+
+import EDU.oswego.cs.dl.util.concurrent.ThreadFactory;
+
+/**
+ * Subclass of [EMAIL PROTECTED] java.lang.Thread} that provides commonly 
named threads for
+ * use inside a particular software application.
+ * <p/>
+ * The main purpose of this class is to provide all threads
+ * running in the software with a consistent naming convention.  When 
instantiating
+ * a <code>NamedThread</code>, if a name is provided, that name will be used 
as the
+ * base name for the thread.  The base name will be decorated with additional 
information
+ * to make the thread name unique.
+ */
+public class NamedThread
+   extends Thread
+{
+   /** all thread names will have this string as a prefix */
+   public static final String THREAD_NAME_PREFIX = "muse.thread.";
+
+   /** number of named threads that have been created */
+   private static long s_threadCount = 0L;
+
+   /** base name used to create this thread; or <code>null</code> if no name 
was specified */
+   private final String m_baseName;
+
+   /**
+    * Creates the thread with an empty base name.
+    *
+    * @see java.lang.Thread#Thread(java.lang.String)
+    */
+   public NamedThread(  )
+   {
+      super( createThreadName( null ) );
+      m_baseName = null;
+   }
+
+   /**
+    * Creates the thread with an empty base name.
+    *
+    * @see java.lang.Thread#Thread(java.lang.Runnable)
+    */
+   public NamedThread( Runnable target )
+   {
+      super( target,
+             createThreadName( null ) );
+      m_baseName = null;
+   }
+
+   /**
+    * Creates the thread with an empty base name.
+    *
+    * @see java.lang.Thread#Thread(java.lang.ThreadGroup, java.lang.Runnable)
+    */
+   public NamedThread( ThreadGroup group,
+                       Runnable    target )
+   {
+      super( group, target,
+             createThreadName( null ) );
+      m_baseName = null;
+   }
+
+   /**
+    * Creates the thread with the given name to be used as the base name.
+    *
+    * @see java.lang.Thread#Thread(java.lang.String)
+    */
+   public NamedThread( String name )
+   {
+      super( createThreadName( name ) );
+      m_baseName = name;
+   }
+
+   /**
+    * Creates the thread with the given name to be used as the base name.
+    *
+    * @see java.lang.Thread#Thread(java.lang.ThreadGroup, java.lang.String)
+    */
+   public NamedThread( ThreadGroup group,
+                       String      name )
+   {
+      super( group,
+             createThreadName( name ) );
+      m_baseName = name;
+   }
+
+   /**
+    * Creates the thread with the given name to be used as the base name.
+    *
+    * @see java.lang.Thread#Thread(java.lang.Runnable, java.lang.String)
+    */
+   public NamedThread( Runnable target,
+                       String   name )
+   {
+      super( target,
+             createThreadName( name ) );
+      m_baseName = name;
+   }
+
+   /**
+    * Creates the thread with the given name to be used as the base name.
+    *
+    * @see java.lang.Thread#Thread(java.lang.ThreadGroup, java.lang.Runnable, 
java.lang.String)
+    */
+   public NamedThread( ThreadGroup group,
+                       Runnable    target,
+                       String      name )
+   {
+      super( group, target,
+             createThreadName( name ) );
+      m_baseName = name;
+   }
+
+   /**
+    * Returns the base name used to create the thread.  To get the actual name
+    * of the thread, use [EMAIL PROTECTED] java.lang.Thread#getName()}.  If no 
name was
+    * passed into a constructor, or if null was passed, then null is returned.
+    *
+    * @return base name of the thread (the name passed into the constructor)
+    */
+   public String getBaseName(  )
+   {
+      return m_baseName;
+   }
+
+   /**
+    * Builds a thread name that is unique to the JVM.
+    * The base name provided will be used as part of the thread
+    * name to further describe the thread's purpose.  If the base name is
+    * null, it will not be used.
+    *
+    * @param baseName thread's base name
+    *
+    * @return String a String that can be used as a thread name
+    */
+   protected static String createThreadName( String baseName )
+   {
+      String name;
+      long   thread_num;
+
+      synchronized ( THREAD_NAME_PREFIX )
+      { // really we want to synchronize on m_threadCount, but its a primitive
+
+         // so just use THREAD_NAME_PREFIX as a monitor lock
+         thread_num = s_threadCount++;
+      }
+
+      name = THREAD_NAME_PREFIX + thread_num;
+
+      if ( baseName != null )
+      {
+         name += ( "." + baseName );
+      }
+
+      return name;
+   }
+
+   /**
+    * A thread factory for use with the Concurrent API.  This factory creates 
threads
+    * of type [EMAIL PROTECTED] NamedThread} and provides the ability to name 
the threads via the
+    * base name facility of [EMAIL PROTECTED] NamedThread}.  Threads created 
by this
+    * factory may be daemon threads if desired
+    * (see [EMAIL PROTECTED] 
ConcurrentThreadFactory#ConcurrentThreadFactory(String, boolean)}).
+    */
+   public static class ConcurrentThreadFactory
+      implements ThreadFactory
+   {
+      /** the base name this factory will use for all of its threads */
+      private String m_factoryBaseName;
+
+      /** determines if all threads created by this factory are daemon threads 
or not */
+      private boolean m_isDaemon;
+
+      /**
+       * Creates a factory that does not define a base name for the user 
threads it will create.
+       */
+      public ConcurrentThreadFactory(  )
+      {
+         this( null, false );
+      }
+
+      /**
+       * Creates a factory that defines a base name for the user threads it 
will create.
+       *
+       * @param baseName the base name used for all threads created by this 
factory (may be <code>null</code>)
+       *
+       * @see NamedThread#getBaseName()
+       */
+      public ConcurrentThreadFactory( String baseName )
+      {
+         this( baseName, false );
+      }
+
+      /**
+       * Creates a factory that does not define a base name for the threads it 
will create but explicitly
+       * defines whether or not the threads will be daemon or user threads.
+       *
+       * @param isDaemon if <code>true</code> then all threads created by this 
factory will be daemon threads.
+       */
+      public ConcurrentThreadFactory( boolean isDaemon )
+      {
+         this( null, isDaemon );
+      }
+
+      /**
+       * Creates a factory that defines the new threads' base names and 
whether or not the threads to be
+       * created will be daemon or user threads.
+       *
+       * @param baseName the base name used for all threads created by this 
factory (may be <code>null</code>)
+       * @param isDaemon if <code>true</code> then all threads created by this 
factory will be daemon threads.
+       */
+      public ConcurrentThreadFactory( String  baseName,
+                                      boolean isDaemon )
+      {
+         m_factoryBaseName    = baseName;
+         m_isDaemon           = isDaemon;
+      }
+
+      /**
+       * Creates a [EMAIL PROTECTED] NamedThread} using this factory's base 
name as the new thread's base name.
+       *
+       * @see ThreadFactory#newThread(java.lang.Runnable)
+       * @see NamedThread#NamedThread(Runnable, String)
+       * @see NamedThread#getBaseName()
+       */
+      public Thread newThread( Runnable command )
+      {
+         NamedThread retNewThread = new NamedThread( command, 
m_factoryBaseName );
+
+         retNewThread.setDaemon( m_isDaemon );
+
+         return retNewThread;
+      }
+   }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to