/* Copyright (c) 2002, Oracle Corporation. All Rights Reserved. */ 
package oracle.portal.sample.portalTools.devguide.jcasample;

import javax.resource.cci.Connection;
import javax.resource.ResourceException;
import javax.resource.NotSupportedException;
import javax.resource.cci.Interaction;
import javax.resource.cci.ConnectionMetaData;
import javax.resource.cci.ResultSetInfo;
import javax.resource.cci.LocalTransaction;
import javax.resource.spi.EISSystemException;

/**
 * This class implements the connection for the sample adapter. 
 *
 * The sample adapter uses XML file to get data. This is a simplified 
 * implementation of a real life senario where data comes from an EIS 
 * application. 
 *
 * This sample class implements the createInteraction method only. It throws
 * "not supported" exceptions for the rest of the method implementations.
 */
public class SampleConnection implements Connection
{

  /** Location of the data file. This will be populated through constructor. */
  String mDataLoc = null;
  
  /**
   * Creates a connection object.
   * @param dataLoc The location of the data file.
   */
  protected SampleConnection(String dataLoc)
  {
    mDataLoc = dataLoc; 
  }

  /** 
   * Creates the interaction from this connection object. 
   * @return It returns a SampleInteraction object.
   * @throws ResourceException if fails to create interaction.
   */
  public Interaction createInteraction() throws ResourceException
  {
    return new SampleInteraction(this, mDataLoc);
  }

  /**
   * Close the connection. We will do nothing here.
   */
  public void close() throws ResourceException
  {
  }

  /** This method is not supported for the sample adapter. */
  public LocalTransaction getLocalTransaction() throws ResourceException
  {
    throw new NotSupportedException("Not supported by the Sample Adapter"); 
  }

  /** This method is not supported for the sample adapter. */
  public ConnectionMetaData getMetaData() throws ResourceException
  {
    throw new NotSupportedException("Not supported by the Sample Adapter"); 
  }

  /** This method is not supported for the sample adapter. */
  public ResultSetInfo getResultSetInfo() throws ResourceException
  {
    throw new NotSupportedException("Not supported by the Sample Adapter"); 
  }

  
}


