package jacorb.util.tracing;

import java.io.*;
<<<<<<< ServerTraceInterceptor.java
import org.omg.CORBA.Any;
=======

import org.omg.IOP_N.Codec;
import org.omg.CORBA.*;
>>>>>>> 1.3
import org.omg.CORBA.portable.*;
import org.omg.PortableInterceptor.*;
<<<<<<< ServerTraceInterceptor.java
import jacorb.orb.LocalityConstrainedObject;
=======

import jacorb.orb.LocalityConstrainedObject;
>>>>>>> 1.3

public class ServerTraceInterceptor 
    extends LocalityConstrainedObject 
    implements ServerRequestInterceptor
{
<<<<<<< ServerTraceInterceptor.java
    private int slotId;

    public ServerTraceInterceptor( int slotId )
=======

    private int slot_id;
    private PrintStream logStream = null;
    private Codec codec = null;

    public ServerTraceInterceptor( int slot_id, Codec codec )
>>>>>>> 1.3
    {
<<<<<<< ServerTraceInterceptor.java
        this.slotId = slotId;
=======
        this(slot_id, codec, System.out);
>>>>>>> 1.3
    }

<<<<<<< ServerTraceInterceptor.java
=======
    public ServerTraceInterceptor( int slot_id, Codec codec, 
                                   PrintStream logStream )
    {
        this.slot_id = slot_id;
        this.codec = codec;
        this.logStream = logStream;        
    }

>>>>>>> 1.3
    public String name() 
    {
        return "ServerTraceInterceptor";
    }

    public void receive_request_service_contexts( ServerRequestInfo ri ) 
        throws org.omg.PortableInterceptor.ForwardRequest
    {
        System.out.println("SI in operation <" + ri.operation() + ">");
        try
        {
            System.out.println("Request for op " + ri.operation());
            
            org.omg.IOP.ServiceContext ctx = 
<<<<<<< ServerTraceInterceptor.java
                ri.get_request_service_context( TracingContextID.value );
=======
                ri.get_request_service_context( TracingContextID.value );
            
            ri.set_slot(slot_id, codec.decode(ctx.context_data));
>>>>>>> 1.3

            ri.add_reply_service_context( ctx, true );
<<<<<<< ServerTraceInterceptor.java
        }
        catch( org.omg.CORBA.BAD_PARAM e )
=======
        }
        catch (org.omg.CORBA.BAD_PARAM bp)
        {
            //ignore, SC not present

            System.out.println("ServerRequestInterceptor: " + bp);
 
        }
        catch( Exception e )
>>>>>>> 1.3
        {
            System.err.println("No service context in operation <" + ri.operation() + ">");
            e.printStackTrace();
        }
    }

    public void receive_request( ServerRequestInfo ri ) 
        throws org.omg.PortableInterceptor.ForwardRequest
    {
    }

    public void send_reply(org.omg.PortableInterceptor.ServerRequestInfo ri)
    {

    }

    public void send_exception(org.omg.PortableInterceptor.ServerRequestInfo ri) 
        throws org.omg.PortableInterceptor.ForwardRequest
    {

    }

    public void send_other(org.omg.PortableInterceptor.ServerRequestInfo ri) 
        throws org.omg.PortableInterceptor.ForwardRequest
    {

    }


}
