📄 aqservlet.java
字号:
/**
* @author Rajat Gupta
* @version 1.0
*
* Name of the Application : AQServlet.java
* Development Environment : Oracle 9i JDeveloper
* Creation/Modification History :
*
* Rajat Gupta 15-Jan-2001 Created
*
*/
// Import Statements
import java.io.PrintStream;
import java.io.FileOutputStream;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import oracle.AQ.xml.AQxmlException;
import oracle.AQ.xml.AQxmlDebug;
import oracle.AQ.xml.AQxmlDataSource;
import java.util.Hashtable;
import oracle.otnsamples.AQ.Helper.ConnectionHelper;
/**
* This class extends the AQxmlServlet20 which is a Servlet defined by AQ.
* This servlet is used when a message has to be sent to a database queue
* through Internet. The protocol used for this is called IDAP
* (Internet Data Access Protocol). The request goes in the form of a SOAP
* message which adheres to a schema file.
* In our class, we specify the database to which it has to connect and also
* provide the other required information to connect to the database.
*/
public class AQServlet extends oracle.AQ.xml.AQxmlServlet20{
/**
* This method is called first whenever this servlet is loaded. The main
* function of this method is to set the database parameters and the
* stylesheet. The response of this servlet is a XML file. So, a XSL
* stylesheet is required to show the formatted output.
*
* @exception ServletException In case an exception is generated in the
* Servlet
* @param config HttpServlet Config Object
*/
public void init(ServletConfig p_config) throws ServletException {
// Get Retail DataBase Parameters
Hashtable dbUserDetails = new Hashtable();
try{
dbUserDetails = ConnectionHelper.getDBUserDetails();
}catch(Exception p_exp){
// Log the Exception and Throw it. Servlet Container takes care.
p_config.getServletContext().log("Exception in init() of AQServlet : " + p_exp.getMessage());
throw new ServletException(p_exp);
}
// Get Retail DataBase UserName
String username = (String)dbUserDetails.get("UserName");
// Get Retail DataBase Password
String password = (String)dbUserDetails.get("Password");
// Get Retail DataBase SID
String sid = (String)dbUserDetails.get("SID");
// Get Retail DataBase HostName
String host = (String)dbUserDetails.get("HostName");
// Get Retail DataBase Port No.
String port = dbUserDetails.get("PortNo").toString();
AQxmlDataSource db_drv = null;
try {
// Set the log file
PrintStream debugFile = new PrintStream (new FileOutputStream("aqdebug.log"));
debugFile.println("Function Called");
debugFile.flush();
super.init(p_config);
AQxmlDebug.setTraceLevel(5);
AQxmlDebug.setDebug(true);
AQxmlDebug.setLogStream(new FileOutputStream("aqlogfile"));
// Get DataSource
db_drv = new AQxmlDataSource(username, password, sid, host, port);
// Set DataSource
setAQDataSource(db_drv);
// Set StyleSheet
setStyleSheet("text/xsl", "include/Response.xsl");
}catch (AQxmlException aq_ex) {
aq_ex.printStackTrace();
aq_ex.getNextException().printStackTrace();
}catch (Exception ex) {
ex.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -