86ad0009ed3d95798b42a438f2c0e536c799b6d2
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      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  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.plugins.event.protocol.jms;
22
23 import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters;
24
25 /**
26  * Event protocol parameters for JMS Object messages as an event protocol.
27  *
28  * <p>On reception of an a JMS {@code javax.jms.ObjectMessage}, the JMS Object plugin unmarshals the message as follows:
29  * <ol>
30  * <li>It extracts the Java object from the {@code javax.jms.ObjectMessage} instance.</li>
31  * <li>It creates an {@link org.onap.policy.apex.service.engine.event.ApexEvent} instance to hold the java object.</li>
32  * <li>It sets the name of the Apex event to be the simple class name of the incoming Java object and appends the value
33  * of the {@code incomingEventSuffix} parameter to it.</li>
34  * <li>It sets the version of the incoming event to the value of the {@code incomingEventVersion} parameter.</li>
35  * <li>It sets the name space of the incoming event to be the value of the package of the class of the incoming Java
36  * object.</li>
37  * <li>It sets the source of the incoming event to the value of the {@code incomingEventSource} parameter.</li>
38  * <li>It sets the target of the incoming event to the value of the {@code incomingEventTarget} parameter.</li>
39  * <li>It puts a single entry into the Apex event map with the the simple class name of the incoming Java object being
40  * the key of the entry and the actual incoming object as the value of the entry.</li>
41  * </ol>
42  * 
43  * <p>When sending an object to JMS, the plugin expects to receive an Apex event with a single entry. The plugin
44  * marshals the value of that entry to an object that can be sent by JMS as a {@code javax.jms.ObjectMessage} instance.
45  * 
46  * <p>The parameters for this plugin are:
47  * <ol>
48  * <li>incomingEventSuffix: The suffix to append to the simple name of incoming Java class instances when they are
49  * encapsulated in Apex events. The parameter defaults to the string value {@code IncomingEvent}.</li>
50  * <li>incomingEventVersion: The event version to use for incoming Java class instances when they are encapsulated in
51  * Apex events. The parameter defaults to the string value {@code 1.0.0}.</li>
52  * <li>incomingEventSource: The event source to use for incoming Java class instances when they are encapsulated in Apex
53  * events. The parameter defaults to the string value {@code JMS}.</li>
54  * <li>incomingEventTarget: The event target to use for incoming Java class instances when they are encapsulated in Apex
55  * events. The parameter defaults to the string value {@code Apex}.</li>
56  * </ol>
57  *
58  * @author Liam Fallon (liam.fallon@ericsson.com)
59  */
60 public class JmsObjectEventProtocolParameters extends EventProtocolParameters {
61     /** The label of this event protocol. */
62     public static final String JMS_OBJECT_EVENT_PROTOCOL_LABEL = "JMSOBJECT";
63
64     //@formatter:off
65     // Default parameter values
66     private static final String   DEFAULT_INCOMING_EVENT_SUFFIX  = "IncomingEvent";
67     private static final String   DEFAULT_INCOMING_EVENT_VERSION = "1.0.0";
68     private static final String   DEFAULT_INCOMING_EVENT_SOURCE  = "JMS";
69     private static final String   DEFAULT_INCOMING_EVENT_TARGET  = "Apex";
70
71     // JMS carrier parameters
72     private String incomingEventSuffix   = DEFAULT_INCOMING_EVENT_SUFFIX;
73     private String incomingEventVersion  = DEFAULT_INCOMING_EVENT_VERSION;
74     private String incomingEventSource   = DEFAULT_INCOMING_EVENT_SOURCE;
75     private String incomingEventTarget   = DEFAULT_INCOMING_EVENT_TARGET;
76     //@formatter:off
77
78     /**
79      * Constructor to create a JSON event protocol parameter instance and register the instance with the
80      *  parameter service.
81      */
82     public JmsObjectEventProtocolParameters() {
83         super();
84
85         // Set the event protocol properties for the JMS Text event protocol
86         this.setLabel(JMS_OBJECT_EVENT_PROTOCOL_LABEL);
87
88         // Set the event protocol plugin class
89         this.setEventProtocolPluginClass(Apex2JmsObjectEventConverter.class.getCanonicalName());
90     }
91
92     /**
93      * Gets the incoming event version.
94      *
95      * @return the incoming event version
96      */
97     public String getIncomingEventVersion() {
98         return incomingEventVersion;
99     }
100
101     /**
102      * Gets the incoming event source.
103      *
104      * @return the incoming event source
105      */
106     public String getIncomingEventSource() {
107         return incomingEventSource;
108     }
109
110     /**
111      * Gets the incoming event target.
112      *
113      * @return the incoming event target
114      */
115     public String getIncomingEventTarget() {
116         return incomingEventTarget;
117     }
118
119     /**
120      * Gets the incoming event suffix.
121      *
122      * @return the incoming event suffix
123      */
124     public String getIncomingEventSuffix() {
125         return incomingEventSuffix;
126     }
127 }