KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > samples > jms > HTTPTrigger


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.samples.jms;
17
18 import java.net.HttpURLConnection JavaDoc;
19 import java.net.URL JavaDoc;
20
21 import org.apache.cocoon.util.NetUtils;
22 import org.hsqldb.Trigger;
23
24 /**
25  * @version CVS $Id: HTTPTrigger.java 126035 2005-01-22 12:39:50Z cziegeler $
26  * @author <a HREF="mailto:chaul@apache.org">chaul</a>
27  */

28 public class HTTPTrigger implements Trigger {
29
30     protected String JavaDoc protocol = "http";
31     protected String JavaDoc hostname = "localhost";
32     protected int port = 8888;
33     protected String JavaDoc path = "/samples/jms/database/jms-invalidate";
34
35     /*
36      * @see org.hsqldb.Trigger#fire(java.lang.String, java.lang.String, java.lang.Object[])
37      */

38     public void fire(String JavaDoc triggerName, String JavaDoc tableName, Object JavaDoc[] row) {
39         try {
40             HttpURLConnection JavaDoc con = (HttpURLConnection JavaDoc) new URL JavaDoc(this.protocol, this.hostname, this.port, this.path+"?trigger="
41                             + NetUtils.encode(triggerName.toLowerCase(), "utf-8")
42                             + "&table="
43                             + NetUtils.encode(tableName.toLowerCase(), "utf-8")).openConnection();
44             con.connect();
45             con.getContent();
46             con.disconnect();
47         } catch (Exception JavaDoc e) {
48             // not much we can do here.
49
throw new RuntimeException JavaDoc("Cannot execute trigger: "+e.getMessage());
50         }
51     }
52
53     /* (non-Javadoc)
54      * @see org.hsqldb.Trigger#fire(int, java.lang.String, java.lang.String, java.lang.Object[], java.lang.Object[])
55      */

56     public void fire(int arg0, String JavaDoc arg1, String JavaDoc arg2, Object JavaDoc[] arg3, Object JavaDoc[] arg4) {
57         // TODO Auto-generated method stub
58

59     }
60
61 }
62
Popular Tags