09.12.2012 Views

Advanced Queuing - Oracle

Advanced Queuing - Oracle

Advanced Queuing - Oracle

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Customizing the AQ Servlet<br />

The void setStyleSheet(String type,String href)method allows<br />

<br />

the user to set the style sheet for a particular call. So instead of specifying a<br />

single style sheet for all responses from this servlet, users can set style sheets for<br />

specific responses.<br />

The style sheet specified in the callback overrides the style sheet (if any)<br />

specified for the servlet in the init() method<br />

Example<br />

Before any AQ operation in the servlet, you want to insert a row in the EMP table.<br />

Do this by creating a callback class and associating it with a particular servlet as<br />

follows:<br />

import javax.servlet.*;<br />

import javax.servlet.http.*;<br />

import oracle.AQ.xml.*;<br />

import java.sql.*;<br />

import javax.jms.*;<br />

/**<br />

* This is a sample AQ Servlet callback<br />

*/<br />

public class TestCallback implements oracle.AQ.xml.AQxmlCallback<br />

{<br />

/** Callback invoked before any AQ operations are performed by the servlet */<br />

public void beforeAQOperation(HttpServletRequest request, HttpServletResponse<br />

response,<br />

AQxmlCallbackContext ctx)<br />

{<br />

Connection conn = null;<br />

System.out.println("Entering BeforeAQ Callback ...");<br />

try<br />

{<br />

// Get the connection object from the callback context<br />

conn = ctx.getDBConnection();<br />

// Insert value in the EMP table<br />

PreparedStatement pstmt =<br />

conn.prepareStatement ("insert into EMP (EMPNO, ENAME) values (100,<br />

’HARRY’)");<br />

pstmt.execute ();<br />

pstmt.close();<br />

Internet Access to <strong>Advanced</strong> <strong>Queuing</strong> 17-69

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!