import javax.xml.transform.dom.DOMSource;
 
 import org.wamblee.general.Clock;
+import org.wamblee.general.Pair;
 import org.wamblee.xml.XMLDocument;
 import org.wamblee.xmlrouter.common.Id;
 import org.wamblee.xmlrouter.config.DocumentType;
 
     @Override
     public void publish(String aSource, DOMSource aEvent) {
-        config.startPublishEvent();
-        try {
-            publishImpl(aSource, aEvent);
-        } finally {
-            config.endPublishEvent();
-        }
-    }
-
-    private void publishImpl(String aSource, DOMSource aEvent) {
         long time = clock.currentTimeMillis();
 
+        Pair<ExtendedRouterConfig, TransformationPaths> snapshotconfig = config
+            .getConfig();
+
         Id<DOMSource> id = new Id<DOMSource>(nextEventId.getAndIncrement() + "");
-        List<String> types = determineDocumentTypes(aEvent);
+        List<String> types = determineDocumentTypes(snapshotconfig.getFirst()
+            .documentTypeConfig().values(), aEvent);
         EventInfo info = new EventInfo(time, aSource, id, types, aEvent);
 
         boolean delivered = false;
         try {
 
             List<String> filteredInputTypes = determineFilteredInputTypes(
-                types, aEvent);
+                snapshotconfig.getFirst().filterConfig().values(), types,
+                aEvent);
             if (filteredInputTypes.isEmpty()) {
                 if (LOGGER.isLoggable(Level.FINE)) {
                     String doc = new XMLDocument(aEvent).print(true);
             // This is however certainly not the main case.
 
             for (String inputType : filteredInputTypes) {
-                boolean result = deliverEvent(info, inputType);
+                boolean result = deliverEvent(snapshotconfig.getFirst()
+                    .filterConfig().values(), snapshotconfig.getSecond(), info,
+                    inputType);
                 delivered = delivered || result;
             }
         } finally {
         }
     }
 
-    private boolean deliverEvent(EventInfo aInfo, String aInputType) {
+    private boolean deliverEvent(Collection<Filter> aFilters,
+        TransformationPaths aTransformations, EventInfo aInfo, String aInputType) {
 
         boolean delivered = false;
         Set<String> possibleTargetTypes = new HashSet<String>();
-        possibleTargetTypes.addAll(config.getTransformations()
+        possibleTargetTypes.addAll(aTransformations
             .getPossibleTargetTypes(aInputType));
 
         // ask each destination what target types, if any they want to have.
             if (!requested.isEmpty()) {
                 // Deliver to the destination.
                 for (String targetType : requested) {
-                    TransformationPath path = config.getTransformations()
-                        .getPath(aInputType, targetType);
+                    TransformationPath path = aTransformations.getPath(
+                        aInputType, targetType);
                     List<Transformation> ts = path.getTransformations();
                     int i = 0;
                     boolean allowed = true;
                                 aInfo.getEvent(), aInputType, t, orig);
                         }
 
-                        if (!isAllowedByFilters(t.getToType(), transformed)) {
+                        if (!isAllowedByFilters(aFilters, t.getToType(),
+                            transformed)) {
                             allowed = false;
                         }
                         i++;
         return delivered;
     }
 
-    private List<String> determineFilteredInputTypes(List<String> aTypes,
-        DOMSource aEvent) {
+    private List<String> determineFilteredInputTypes(
+        Collection<Filter> aFilters, List<String> aTypes, DOMSource aEvent) {
 
         // apply filters to the input
         List<String> filteredTypes = new ArrayList<String>();
         for (String type : aTypes) {
-            boolean allowed = isAllowedByFilters(type, aEvent);
+            boolean allowed = isAllowedByFilters(aFilters, type, aEvent);
             if (allowed) {
                 filteredTypes.add(type);
             }
         return filteredTypes;
     }
 
-    private boolean isAllowedByFilters(String aType, DOMSource aEvent) {
+    private boolean isAllowedByFilters(Collection<Filter> aFilters,
+        String aType, DOMSource aEvent) {
         boolean allowed = true;
-        for (Filter filter : config.getRouterConfig().filterConfig().values()) {
+        for (Filter filter : aFilters) {
             if (!filter.isAllowed(aType, aEvent)) {
                 allowed = false;
             }
         return allowed;
     }
 
-    private List<String> determineDocumentTypes(DOMSource aEvent) {
+    private List<String> determineDocumentTypes(
+        Collection<DocumentType> aTypes, DOMSource aEvent) {
         List<String> res = new ArrayList<String>();
-        for (DocumentType type : config.getRouterConfig().documentTypeConfig()
-            .values()) {
+        for (DocumentType type : aTypes) {
             if (type.isInstance(aEvent)) {
                 res.add(type.getName());
             }
 
  */
 package org.wamblee.xmlrouter.impl;
 
+import org.wamblee.general.Pair;
+
 /**
  * The XML Router configuration contains both configuration data as well as
  * derived data used by the XML router. It is important that all this data is
 public interface XMLRouterConfiguration {
 
     /**
-     * To be called before the configuration is used. Corresponds to read lock
-     * acquire.
-     */
-    void startPublishEvent();
-
-    /**
-     * @return Configuration data. {@link #startPublishEvent()} must have been
-     *         called before doing this.
-     */
-    ExtendedRouterConfig getRouterConfig();
-
-    /**
-     * @return Transformation paths (derived data).
-     */
-    TransformationPaths getTransformations();
-
-    /**
-     * To be called after the configuration is used. Corresponds to read lock
-     * release.
+     * Atomically get the configuration. The XMLRouter uses this to get a
+     * snapshot of the configuration data for handling a single message. In this
+     * way a consistent configuration is used for each event.
+     * 
+     * @return Configuration.
      */
-    void endPublishEvent();
+    Pair<ExtendedRouterConfig, TransformationPaths> getConfig();
 
     /**
      * Atomically sets the configuration and updates derived data. There will be