83aef4e9dd4ef777a658d4a97785771e1adfb7d2
[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>
29  * On reception of an a JMS {@code javax.jms.ObjectMessage}, the JMS Object plugin unmarshals the message as follows:
30  * <ol>
31  * <li>It extracts the Java object from the {@code javax.jms.ObjectMessage} instance.</li>
32  * <li>It creates an {@link org.onap.policy.apex.service.engine.event.ApexEvent} instance to hold the java object.</li>
33  * <li>It sets the name of the Apex event to be the simple class name of the incoming Java object and appends the value
34  * of the {@code incomingEventSuffix} parameter to it.</li>
35  * <li>It sets the version of the incoming event to the value of the {@code incomingEventVersion} parameter.</li>
36  * <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  * object.</li>
38  * <li>It sets the source of the incoming event to the value of the {@code incomingEventSource} parameter.</li>
39  * <li>It sets the target of the incoming event to the value of the {@code incomingEventTarget} parameter.</li>
40  * <li>It puts a single entry into the Apex event map with the the simple class name of the incoming Java object being
41  * the key of the entry and the actual incoming object as the value of the entry.</li>
42  * </ol>
43  * <p>
44  * When sending an object to JMS, the plugin expects to receive an Apex event with a single entry. The plugin marshals
45  * the value of that entry to an object that can be sent by JMS as a {@code javax.jms.ObjectMessage} instance.
46  * <p>
47  * The parameters for this plugin are:
48  * <ol>
49  * <li>incomingEventSuffix: The suffix to append to the simple name of incoming Java class instances when they are
50  * encapsulated in Apex events. The parameter defaults to the string value {@code IncomingEvent}.</li>
51  * <li>incomingEventVersion: The event version to use for incoming Java class instances when they are encapsulated in
52  * Apex events. The parameter defaults to the string value {@code 1.0.0}.</li>
53  * <li>incomingEventSource: The event source to use for incoming Java class instances when they are encapsulated in Apex
54  * events. The parameter defaults to the string value {@code JMS}.</li>
55  * <li>incomingEventTarget: The event target to use for incoming Java class instances when they are encapsulated in Apex
56  * events. The parameter defaults to the string value {@code Apex}.</li>
57  * </ol>
58  *
59  * @author Liam Fallon (liam.fallon@ericsson.com)
60  */
61 public class JMSObjectEventProtocolParameters extends EventProtocolParameters {
62     /** The label of this event protocol. */
63     public static final String JMS_OBJECT_EVENT_PROTOCOL_LABEL = "JMSOBJECT";
64
65     //@formatter:off
66     // Default parameter values
67     private static final String   DEFAULT_INCOMING_EVENT_SUFFIX  = "IncomingEvent";
68     private static final String   DEFAULT_INCOMING_EVENT_VERSION = "1.0.0";
69     private static final String   DEFAULT_INCOMING_EVENT_SOURCE  = "JMS";
70     private static final String   DEFAULT_INCOMING_EVENT_TARGET  = "Apex";
71
72     // JMS carrier parameters
73     private String incomingEventSuffix   = DEFAULT_INCOMING_EVENT_SUFFIX;
74     private String incomingEventVersion  = DEFAULT_INCOMING_EVENT_VERSION;
75     private String incomingEventSource   = DEFAULT_INCOMING_EVENT_SOURCE;
76     private String incomingEventTarget   = DEFAULT_INCOMING_EVENT_TARGET;
77     //@formatter:off
78
79     /**
80      * Constructor to create a JSON event protocol parameter instance and register the instance with the parameter service.
81      */
82     public JMSObjectEventProtocolParameters() {
83         super(JMSObjectEventProtocolParameters.class.getCanonicalName());
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 }