/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.qpid.proton4j.engine.impl;

/**
 * Factory class for proton4j Engine creation
 */
public final class ProtonEngineFactory {

    private ProtonEngineFactory() {}

    // TODO - How do we distinguish client from server, or should we ?

    public static ProtonEngine createClientEngine() {
        ProtonEngine engine = new ProtonEngine();

        ProtonEnginePipeline pipeline = engine.pipeline();

        pipeline.addLast(ProtonConstants.AMQP_PERFORMATIVE_HANDLER_NAME, new ProtonPerformativeHandler());
        pipeline.addLast(ProtonConstants.FRAME_LOGGING_HANDLER, new ProtonFrameLoggingHandler());
        pipeline.addLast(ProtonConstants.FRAME_PARSING_HANDLER, new ProtonFrameParsingHandler());
        pipeline.addLast(ProtonConstants.FRAME_WRITING_HANDLER, new ProtonFrameWritingHandler());

        return engine;
    }

    public static ProtonEngine createServierEngine() {
        ProtonEngine engine = new ProtonEngine();

        ProtonEnginePipeline pipeline = engine.pipeline();

        pipeline.addLast(ProtonConstants.AMQP_PERFORMATIVE_HANDLER_NAME, new ProtonPerformativeHandler());
        pipeline.addLast(ProtonConstants.FRAME_LOGGING_HANDLER, new ProtonFrameLoggingHandler());
        pipeline.addLast(ProtonConstants.FRAME_PARSING_HANDLER, new ProtonFrameParsingHandler());
        pipeline.addLast(ProtonConstants.FRAME_WRITING_HANDLER, new ProtonFrameWritingHandler());

        return engine;
    }
}

@@ -847,185 +847,960 @@
 l;%0A%0A
-/**%0A * Factory class for proton4j Engine creation%0A */%0Apublic final class ProtonEngineFactory %7B%0A%0A    private ProtonEngineFactory() %7B%7D%0A%0A    // TODO - How do we distinguish
+import org.apache.qpid.proton4j.engine.sasl.SaslClientListener;%0Aimport org.apache.qpid.proton4j.engine.sasl.SaslHandler;%0Aimport org.apache.qpid.proton4j.engine.sasl.SaslServerListener;%0A%0A/**%0A * Factory class for proton4j Engine creation%0A */%0Apublic final class ProtonEngineFactory %7B%0A%0A    private ProtonEngineFactory() %7B%7D%0A%0A    public static ProtonEngine createEngine() %7B%0A        ProtonEngine engine = new ProtonEngine();%0A%0A        ProtonEnginePipeline pipeline = engine.pipeline();%0A%0A        pipeline.addLast(ProtonConstants.AMQP_PERFORMATIVE_HANDLER_NAME, new ProtonPerformativeHandler());%0A        pipeline.addLast(ProtonConstants.FRAME_LOGGING_HANDLER, new ProtonFrameLoggingHandler());%0A        pipeline.addLast(ProtonConstants.FRAME_PARSING_HANDLER, new ProtonFrameParsingHandler());%0A        pipeline.addLast(ProtonConstants.FRAME_WRITING_HANDLER, new ProtonFrameWritingHandler());%0A%0A        return engine;%0A    %7D%0A%0A    // TODO - Do we want to force
  client 
 from
@@ -1799,33 +1799,201 @@
 ent 
-from
+and
  server
-, or should we
+ on SASL here, or move that to the EngineSaslContext%0A    //        so that it can be decided later, or possible configured to auto decide based on configured%0A    //        mechanisms.
  ?%0A%0A
@@ -2029,16 +2029,20 @@
 e create
+Sasl
 ClientEn
@@ -2042,24 +2042,51 @@
 lientEngine(
+SaslClientListener listener
 ) %7B%0A        
@@ -2287,32 +2287,136 @@
 tiveHandler());%0A
+        pipeline.addLast(ProtonConstants.SASL_PERFORMATIVE_HANDLER_NAME, SaslHandler.client(listener));%0A
         pipeline
@@ -2766,12 +2766,15 @@
 ateS
+aslS
 erv
-i
 erEn
@@ -2774,24 +2774,51 @@
 erverEngine(
+SaslServerListener listener
 ) %7B%0A        
@@ -3019,32 +3019,136 @@
 tiveHandler());%0A
+        pipeline.addLast(ProtonConstants.SASL_PERFORMATIVE_HANDLER_NAME, SaslHandler.server(listener));%0A
         pipeline

Build out some more of the engine factory and add some notes.