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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.plugins.event.protocol.jms;
23 import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters;
26 * Event protocol parameters for JMS Object messages as an event protocol.
28 * <p>On reception of an a JMS {@code javax.jms.ObjectMessage}, the JMS Object plugin unmarshals the message as follows:
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
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>
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.
46 * <p>The parameters for this plugin are:
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>
58 * @author Liam Fallon (liam.fallon@ericsson.com)
60 public class JmsObjectEventProtocolParameters extends EventProtocolParameters {
61 /** The label of this event protocol. */
62 public static final String JMS_OBJECT_EVENT_PROTOCOL_LABEL = "JMSOBJECT";
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";
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;
79 * Constructor to create a JSON event protocol parameter instance and register the instance with the
82 public JmsObjectEventProtocolParameters() {
85 // Set the event protocol properties for the JMS Text event protocol
86 this.setLabel(JMS_OBJECT_EVENT_PROTOCOL_LABEL);
88 // Set the event protocol plugin class
89 this.setEventProtocolPluginClass(Apex2JmsObjectEventConverter.class.getCanonicalName());
93 * Gets the incoming event version.
95 * @return the incoming event version
97 public String getIncomingEventVersion() {
98 return incomingEventVersion;
102 * Gets the incoming event source.
104 * @return the incoming event source
106 public String getIncomingEventSource() {
107 return incomingEventSource;
111 * Gets the incoming event target.
113 * @return the incoming event target
115 public String getIncomingEventTarget() {
116 return incomingEventTarget;
120 * Gets the incoming event suffix.
122 * @return the incoming event suffix
124 public String getIncomingEventSuffix() {
125 return incomingEventSuffix;