Package com.commander4j.javaAbstract

Source Code of com.commander4j.javaAbstract.AbstractInboundInterface

package com.commander4j.javaAbstract;

import java.util.Timer;
import java.util.TimerTask;

import org.apache.log4j.Logger;
import org.w3c.dom.Document;

import com.commander4j.connectors.ConnectorASCII;
import com.commander4j.connectors.ConnectorCSV;
import com.commander4j.connectors.ConnectorDB;
import com.commander4j.connectors.ConnectorIDOC;
import com.commander4j.connectors.ConnectorPOP;
import com.commander4j.connectors.ConnectorSMTP;
import com.commander4j.connectors.ConnectorWSDL;
import com.commander4j.connectors.ConnectorXML;
import com.commander4j.interfaces.InboundInterface;
import com.commander4j.javaInterface.IntefaceConnector;
import com.commander4j.javaInterface.InterfaceInterface;
import com.commander4j.mapping.Map;

public abstract class AbstractInboundInterface extends TimerTask implements InterfaceInterface{
  boolean enabled = false;
  private String type = "";
  public AbstractConnector connector;
  private Long timerFrequency = (long) 2000;
  private boolean running=false;
  Timer timer = new Timer();
  protected Map map;
    protected Document data;
    private String inputPath = "";
    private String outputPath = "";
    private String backupPath = "";
    private String inputFileMask = "*.*";
    private String inputFilename = "";;
    private String xsltFilename = "";
  Logger logger = Logger.getLogger(AbstractInboundInterface.class);


  public String getXSLTFilename()
  {
    return xsltFilename;
  }

  public void setXSLTFilename(String xsltFilename)
  {
    this.xsltFilename = xsltFilename;
  }
   
    public AbstractInboundInterface(Map map)
    {
      this.map = map;
    }
 
    public void processInboundData()
    {
      map.processInboundInterfaceToMap(getFilename(),getData());
    }
   
  public String getFilename()
  {
    return this.inputFilename;
  }
   
  public Document getData()
  {
    return this.data;
  }
 
  public boolean getEnabled()
  {
    return this.enabled;
  }
 
  public void setInputFileMask(String mask)
  {
    this.inputFileMask = mask;
  }

  public String getInputFileMask()
  {
    return this.inputFileMask;
  }
 
  public void setInputFilename(String filename)
 
  {
    this.inputFilename = filename;
  }
 
  public void setInputPath(String path)
 
  {
    this.inputPath = path;
  }
 
  public void setOutputPath(String path)
 
  {
    this.outputPath = path;
  }
 
  public void setBackupPath(String path)
 
  {
    this.backupPath = path;
  }
 
  public String getInputPath()
  {
    return this.inputPath;
  }

  public String getOutputPath()
  {
    return this.outputPath;
  }
 
  public String getBackupPath()
  {
    return this.backupPath;
  }
 
  public void setEnabled(boolean enable)
  {
   
    if ((enable==true) && (enabled==false) && (running==false))
    {
      // start
      connector.setEnabled(enabled);
      this.enabled = enable;
      setRunning(true);
      timer.scheduleAtFixedRate(this, 0, timerFrequency);
    }
    else
    {
      // stop
      timer.cancel();
      logger.debug("Inbound Stop Requested");
      setRunning(false);
    }
  }

  private void setRunning(boolean yes)
  {
    this.running = yes;
  }
 
  public boolean isRunning()
  {
    return this.running;
  }

  public String getType()
  {
    return type;
  }

  public void setPollingInterval(Long millisec)
  {
    timerFrequency = millisec;
  }

  public void setType(String type)
  {
    this.type = type;

    switch (type)
    {
    case IntefaceConnector.Connector_ASCII:
      connector = new ConnectorASCII((InboundInterface) this);
      break;
    case IntefaceConnector.Connector_CSV:
      connector = new ConnectorCSV((InboundInterface) this);
      break;
    case IntefaceConnector.Connector_DB:
      connector = new ConnectorDB((InboundInterface) this);
      break;
    case IntefaceConnector.Connector_IDOC:
      connector = new ConnectorIDOC((InboundInterface) this);
      break;
    case IntefaceConnector.Connector_POP:
      connector = new ConnectorPOP((InboundInterface) this);
      break;
    case IntefaceConnector.Connector_SMTP:
      connector = new ConnectorSMTP((InboundInterface) this);
      break;
    case IntefaceConnector.Connector_WSDL:
      connector = new ConnectorWSDL((InboundInterface) this);
      break;
    case IntefaceConnector.Connector_XML:
      connector = new ConnectorXML((InboundInterface) this);
      break;     
    default:
      throw new IllegalArgumentException();
    }

  }

}
TOP

Related Classes of com.commander4j.javaAbstract.AbstractInboundInterface

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.