01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.samples.jms;
18:
19: import java.net.HttpURLConnection;
20: import java.net.URL;
21:
22: import org.apache.cocoon.util.NetUtils;
23: import org.hsqldb.Trigger;
24:
25: /**
26: * @version CVS $Id: HTTPTrigger.java 433543 2006-08-22 06:22:54Z crossley $
27: * @author <a href="mailto:chaul@apache.org">chaul</a>
28: */
29: public class HTTPTrigger implements Trigger {
30:
31: protected String protocol = "http";
32: protected String hostname = "localhost";
33: protected int port = 8888;
34: protected String path = "/samples/jms/database/jms-invalidate";
35:
36: /*
37: * @see org.hsqldb.Trigger#fire(java.lang.String, java.lang.String, java.lang.Object[])
38: */
39: public void fire(String triggerName, String tableName, Object[] row) {
40: try {
41: HttpURLConnection con = (HttpURLConnection) new URL(
42: this .protocol, this .hostname, this .port, this .path
43: + "?trigger="
44: + NetUtils.encode(
45: triggerName.toLowerCase(), "utf-8")
46: + "&table="
47: + NetUtils.encode(tableName.toLowerCase(),
48: "utf-8")).openConnection();
49: con.connect();
50: con.getContent();
51: con.disconnect();
52: } catch (Exception e) {
53: // not much we can do here.
54: throw new RuntimeException("Cannot execute trigger: "
55: + e.getMessage());
56: }
57: }
58:
59: /* (non-Javadoc)
60: * @see org.hsqldb.Trigger#fire(int, java.lang.String, java.lang.String, java.lang.Object[], java.lang.Object[])
61: */
62: public void fire(int arg0, String arg1, String arg2, Object[] arg3,
63: Object[] arg4) {
64: // TODO Auto-generated method stub
65:
66: }
67:
68: }
|