home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / HTTPTrigger.class (.txt) < prev    next >
Encoding:
Java Class File  |  2004-07-12  |  1.7 KB  |  25 lines

  1. package org.apache.cocoon.samples.jms;
  2.  
  3. import java.net.HttpURLConnection;
  4. import java.net.URL;
  5. import java.net.URLEncoder;
  6. import org.hsqldb.Trigger;
  7.  
  8. public class HTTPTrigger implements Trigger {
  9.    protected String protocol = "http";
  10.    protected String hostname = "localhost";
  11.    protected int port = 8888;
  12.    protected String path = "/samples/jms/database/jms-invalidate";
  13.  
  14.    public void fire(String triggerName, String tableName, Object[] row) {
  15.       try {
  16.          HttpURLConnection con = (HttpURLConnection)(new URL(this.protocol, this.hostname, this.port, this.path + "?trigger=" + URLEncoder.encode(triggerName.toLowerCase()) + "&table=" + URLEncoder.encode(tableName.toLowerCase()))).openConnection();
  17.          con.connect();
  18.          con.getContent();
  19.          con.disconnect();
  20.       } catch (Exception e) {
  21.          throw new RuntimeException("Cannot execute trigger: " + e.getMessage());
  22.       }
  23.    }
  24. }
  25.