001 /*
002 * Copyright 1999-2004 The Apache Software Foundation.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 */
017
018 package de.jw.cloud42.core.eventing.subscription;
019
020
021 import java.net.URI;
022
023 import javax.persistence.Entity;
024 import javax.persistence.Id;
025 import javax.persistence.MappedSuperclass;
026
027 import de.jw.cloud42.core.eventing.Message;
028
029 /**
030 * A Subscription entity saves information belonging to a subscribing endpoint, such as its subscription id.
031 *
032 * The method <code>sendEventData</code> is used to send notification messages. The concrete format and transport
033 * protocol are definded in concrete implementations of this class.
034 */
035
036 @Entity
037 public abstract class Subscription {
038
039 /**
040 * Id of subscriber/subscription
041 */
042 private String id;
043
044 /**
045 * Topic for this Subscription
046 */
047 private String topic;
048
049
050 /**
051 *
052 * @return the subscription id.
053 */
054 @Id
055 public String getId() {
056
057 return id;
058 }
059
060 /**
061 *
062 * @return the topic of the subscription.
063 */
064 public String getTopic() {
065
066 return topic;
067 }
068
069 /**
070 *
071 * @param id the subscription id to set.
072 */
073 public void setId(String id) {
074
075 this.id = id;
076 }
077
078 /**
079 *
080 * @param topic the topic to set.
081 */
082 public void setTopic(String topic) {
083 this.topic = topic;
084
085 }
086
087 /**
088 * Send data to subscribing endpoint.
089 * @param eventData the message to be transformed and sent.
090 * @throws Exception
091 */
092 public abstract void sendEventData(Message eventData) throws Exception;
093
094
095 }