001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.jms.jdbc;
030:
031: import com.caucho.config.ConfigException;
032: import com.caucho.jms.JMSExceptionWrapper;
033: import com.caucho.util.L10N;
034:
035: import javax.annotation.PostConstruct;
036: import javax.jms.JMSException;
037: import javax.jms.Message;
038: import javax.jms.Topic;
039: import javax.jms.TopicSubscriber;
040: import java.sql.SQLException;
041: import java.util.logging.Logger;
042:
043: /**
044: * A jdbc topic.
045: */
046: //public class JdbcTopic extends JdbcDestination implements Topic {
047: public class JdbcTopic {
048: static final Logger log = Logger.getLogger(JdbcTopic.class
049: .getName());
050: static final L10N L = new L10N(JdbcTopic.class);
051:
052: private int _id;
053:
054: public JdbcTopic() {
055: }
056:
057: /**
058: * Returns the topic's name.
059: */
060: public String getTopicName() {
061: return getName();
062: }
063:
064: public String getName() {
065: return "ook";
066: }
067:
068: /**
069: * Sets the topic's name.
070: */
071: public void setTopicName(String name) {
072: //setName(name);
073: }
074:
075: /**
076: * Returns true for a topic.
077: */
078: public boolean isTopic() {
079: return true;
080: }
081:
082: /**
083: * Returns the JDBC id for the topic.
084: */
085: public int getId() {
086: return _id;
087: }
088:
089: /**
090: * Initializes the JdbcTopic
091: */
092: @PostConstruct
093: public void init() throws ConfigException, SQLException {
094: /*
095: if (_jdbcManager.getDataSource() == null)
096: throw new ConfigException(L.l("JdbcTopic requires a <data-source> element."));
097:
098: if (getName() == null)
099: throw new ConfigException(L.l("JdbcTopic requires a <topic-name> element."));
100:
101: _jdbcManager.init();
102:
103: _id = createDestination(getName(), true);
104:
105: super.init();
106: */
107: }
108:
109: /**
110: * Creates a consumer.
111: */
112: /*
113: public MessageConsumerImpl createConsumer(SessionImpl session,
114: String selector,
115: boolean noLocal)
116: throws JMSException
117: {
118: return new JdbcTopicConsumer(session, selector,
119: _jdbcManager, this, noLocal);
120: }
121: */
122:
123: /**
124: * Creates a durable subscriber.
125: */
126: /*
127: public TopicSubscriber createDurableSubscriber(SessionImpl session,
128: String selector,
129: boolean noLocal,
130: String name)
131: throws JMSException
132: {
133: return new JdbcTopicConsumer(session, selector,
134: _jdbcManager, this, noLocal, name);
135: }
136: */
137:
138: /**
139: * Sends the message to the queue.
140: */
141: public void send(Message message) throws JMSException {
142: /*
143: long expireTime = message.getJMSExpiration();
144: if (expireTime <= 0)
145: expireTime = Long.MAX_VALUE / 2;
146:
147: purgeExpiredMessages();
148:
149: try {
150: _jdbcManager.getJdbcMessage().send(message, _id, expireTime);
151: } catch (Exception e) {
152: throw new JMSExceptionWrapper(e);
153: }
154:
155: messageAvailable();
156: */
157: }
158:
159: /**
160: * Returns a printable view of the queue.
161: */
162: public String toString() {
163: //return "JdbcTopic[" + getName() + "]";
164:
165: return "JdbcTopic[]";
166: }
167: }
|