From 4cfa2e2d98f6877d54da304ef17f096284430908 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Thu, 13 Sep 2018 15:25:32 +0100 Subject: Sonar/Checkstyle in service/plugins Sonar and Checkstyle changes in plugins and services, and knock on changes Issue-ID: POLICY-1034 Change-Id: Iff7df74e54fce2c661dcc2fae75ae93d4cacfe5b Signed-off-by: liamfallon --- .../protocol/jms/Apex2JMSObjectEventConverter.java | 151 -------------------- .../protocol/jms/Apex2JMSTextEventConverter.java | 102 -------------- .../protocol/jms/Apex2JmsObjectEventConverter.java | 153 +++++++++++++++++++++ .../protocol/jms/Apex2JmsTextEventConverter.java | 95 +++++++++++++ .../jms/JMSObjectEventProtocolParameters.java | 127 ----------------- .../jms/JMSTextEventProtocolParameters.java | 56 -------- .../jms/JmsObjectEventProtocolParameters.java | 127 +++++++++++++++++ .../jms/JmsTextEventProtocolParameters.java | 56 ++++++++ 8 files changed, 431 insertions(+), 436 deletions(-) delete mode 100644 plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSObjectEventConverter.java delete mode 100644 plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSTextEventConverter.java create mode 100644 plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java create mode 100644 plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverter.java delete mode 100644 plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSObjectEventProtocolParameters.java delete mode 100644 plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSTextEventProtocolParameters.java create mode 100644 plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParameters.java create mode 100644 plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsTextEventProtocolParameters.java (limited to 'plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org') diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSObjectEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSObjectEventConverter.java deleted file mode 100644 index 6c21070c2..000000000 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSObjectEventConverter.java +++ /dev/null @@ -1,151 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.plugins.event.protocol.jms; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -import org.onap.policy.apex.service.engine.event.ApexEvent; -import org.onap.policy.apex.service.engine.event.ApexEventException; -import org.onap.policy.apex.service.engine.event.ApexEventProtocolConverter; -import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; -import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; - -/** - * The Class Apex2JMSObjectEventConverter converts {@link ApexEvent} instances into string instances of - * object message events for JMS. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public final class Apex2JMSObjectEventConverter implements ApexEventProtocolConverter { - private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2JMSObjectEventConverter.class); - - // JMS event protocol parameters on the consumer (JMS->Apex) sides - private JMSObjectEventProtocolParameters eventProtocolParameters = null; - - /** - * Constructor to create the Apex to JMS Object converter. - * - * @throws ApexEventException - * the apex event exception - */ - public Apex2JMSObjectEventConverter() throws ApexEventException { - // Nothing specific to initiate for this plugin - } - - @Override - public void init(final EventProtocolParameters parameters) { - // Check if properties have been set for JMS object event conversion as a consumer. They may not be set because - // JMS may not be in use - // on both sides of Apex - if (!(parameters instanceof JMSObjectEventProtocolParameters)) { - final String errormessage = "specified Event Protocol Parameters properties of type \"" - + parameters.getClass().getCanonicalName() + "\" are not applicable to a " - + Apex2JMSObjectEventConverter.class.getName() + " converter"; - LOGGER.error(errormessage); - } else { - this.eventProtocolParameters = (JMSObjectEventProtocolParameters) parameters; - } - - } - - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.service.engine.event.ApexEventConverter#toApexEvent(java.lang.String, java.lang.Object) - */ - @Override - public List toApexEvent(final String eventName, final Object eventObject) throws ApexEventException { - // Look for a "getObject()" method on the incoming object, if there is no such method, then we cannot fetch the - // object from JMS - Method getObjectMethod; - try { - getObjectMethod = eventObject.getClass().getMethod("getObject", (Class[]) null); - } catch (Exception e) { - final String errorMessage = "message \"" + eventObject - + "\" received from JMS does not have a \"getObject()\" method"; - LOGGER.warn(errorMessage); - throw new ApexEventRuntimeException(errorMessage); - } - - Object jmsIncomingObject; - try { - jmsIncomingObject = getObjectMethod.invoke(eventObject, (Object[]) null); - } catch (final Exception e) { - final String errorMessage = "object contained in message \"" + eventObject - + "\" received from JMS could not be retrieved as a Java object"; - LOGGER.debug(errorMessage, e); - throw new ApexEventRuntimeException(errorMessage, e); - } - - // Check that the consumer parameters for JMS->Apex messaging have been set - if (eventProtocolParameters == null) { - final String errorMessage = "consumer parameters for JMS events consumed by Apex are not set in the Apex configuration for this engine"; - LOGGER.debug(errorMessage); - throw new ApexEventRuntimeException(errorMessage); - } - - // Create the Apex event - // @formatter:off - final ApexEvent apexEvent = new ApexEvent( - jmsIncomingObject.getClass().getSimpleName() + eventProtocolParameters.getIncomingEventSuffix(), - eventProtocolParameters.getIncomingEventVersion(), - jmsIncomingObject.toString().getClass().getPackage().getName(), - eventProtocolParameters.getIncomingEventSource(), - eventProtocolParameters.getIncomingEventTarget()); - // @formattter:on - - // Set the data on the apex event as the incoming object - apexEvent.put(jmsIncomingObject.getClass().getSimpleName(), jmsIncomingObject); - - // Return the event in a single element - final ArrayList eventList = new ArrayList<>(); - eventList.add(apexEvent); - return eventList; - } - - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.service.engine.event.ApexEventConverter#fromApexEvent(org.onap.policy.apex.service.engine.event.ApexEvent) - */ - @Override - public Object fromApexEvent(final ApexEvent apexEvent) throws ApexEventException { - // Check the Apex event - if (apexEvent == null) { - LOGGER.warn("event processing failed, Apex event is null"); - throw new ApexEventException("event processing failed, Apex event is null"); - } - - // Check that the Apex event has a single parameter - if (apexEvent.size() != 1) { - final String errorMessage = "event processing failed, Apex event must have one and only one parameter for JMS Object handling"; - LOGGER.warn(errorMessage); - throw new ApexEventException(errorMessage); - } - - // Return the single object from the Apex event message - return apexEvent.values().iterator().next(); - } -} diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSTextEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSTextEventConverter.java deleted file mode 100644 index e845a4a08..000000000 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSTextEventConverter.java +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.plugins.event.protocol.jms; - -import java.lang.reflect.Method; -import java.util.List; - -import org.onap.policy.apex.service.engine.event.ApexEvent; -import org.onap.policy.apex.service.engine.event.ApexEventException; -import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; -import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JSONEventConverter; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; - -/** - * The Class Apex2JMSTextEventConverter converts {@link ApexEvent} instances into string instances of - * text message events for JMS. It is a proxy for the built in - * {@link org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JSONEventConverter} plugin. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public final class Apex2JMSTextEventConverter extends Apex2JSONEventConverter { - private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2JMSTextEventConverter.class); - - /** - * Constructor to create the Apex to JMS Object converter. - * - * @throws ApexEventException the apex event exception - */ - public Apex2JMSTextEventConverter() throws ApexEventException {} - - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.service.engine.event.ApexEventConverter#toApexEvent(java.lang.String, java.lang.Object) - */ - @Override - public List toApexEvent(final String eventName, final Object eventObject) throws ApexEventException { - // Look for a "getText()" method on the incoming object, if there is no such method, then we cannot fetch the - // text from JMS - Method getTextMethod; - try { - getTextMethod = eventObject.getClass().getMethod("getText", (Class[]) null); - } catch (Exception e) { - final String errorMessage = "message \"" + eventObject - + "\" received from JMS does not have a \"getText()\" method"; - LOGGER.warn(errorMessage); - throw new ApexEventRuntimeException(errorMessage); - } - - - String jmsString; - try { - jmsString = (String) getTextMethod.invoke(eventObject, (Object[]) null); - } catch (final Exception e) { - final String errorMessage = "object contained in message \"" + eventObject - + "\" received from JMS could not be retrieved as a Java String"; - LOGGER.debug(errorMessage, e); - throw new ApexEventRuntimeException(errorMessage, e); - } - - // Use the generic JSON plugin from here - return super.toApexEvent(eventName, jmsString); - } - - /* - * (non-Javadoc) - * - * @see - * org.onap.policy.apex.service.engine.event.ApexEventConverter#fromApexEvent(org.onap.policy.apex.service.engine. - * event. ApexEvent) - */ - @Override - public Object fromApexEvent(final ApexEvent apexEvent) throws ApexEventException { - // Check the Apex event - if (apexEvent == null) { - LOGGER.warn("event processing failed, Apex event is null"); - throw new ApexEventException("event processing failed, Apex event is null"); - } - - // Return the Apex event as a string object - return super.fromApexEvent(apexEvent); - } -} diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java new file mode 100644 index 000000000..ca02709fe --- /dev/null +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java @@ -0,0 +1,153 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.plugins.event.protocol.jms; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +import org.onap.policy.apex.service.engine.event.ApexEvent; +import org.onap.policy.apex.service.engine.event.ApexEventException; +import org.onap.policy.apex.service.engine.event.ApexEventProtocolConverter; +import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; +import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * The Class Apex2JMSObjectEventConverter converts {@link ApexEvent} instances into string instances of object message + * events for JMS. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public final class Apex2JmsObjectEventConverter implements ApexEventProtocolConverter { + private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2JmsObjectEventConverter.class); + + // JMS event protocol parameters on the consumer (JMS->Apex) sides + private JmsObjectEventProtocolParameters eventProtocolParameters = null; + + /** + * Constructor to create the Apex to JMS Object converter. + * + * @throws ApexEventException the apex event exception + */ + public Apex2JmsObjectEventConverter() throws ApexEventException { + // Nothing specific to initiate for this plugin + } + + @Override + public void init(final EventProtocolParameters parameters) { + // Check if properties have been set for JMS object event conversion as a consumer. They may not be set because + // JMS may not be in use + // on both sides of Apex + if (!(parameters instanceof JmsObjectEventProtocolParameters)) { + final String errormessage = "specified Event Protocol Parameters properties of type \"" + + parameters.getClass().getCanonicalName() + "\" are not applicable to a " + + Apex2JmsObjectEventConverter.class.getName() + " converter"; + LOGGER.error(errormessage); + } else { + this.eventProtocolParameters = (JmsObjectEventProtocolParameters) parameters; + } + + } + + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.service.engine.event.ApexEventConverter#toApexEvent(java.lang.String, java.lang.Object) + */ + @Override + public List toApexEvent(final String eventName, final Object eventObject) throws ApexEventException { + // Look for a "getObject()" method on the incoming object, if there is no such method, then we cannot fetch the + // object from JMS + Method getObjectMethod; + try { + getObjectMethod = eventObject.getClass().getMethod("getObject", (Class[]) null); + } catch (Exception e) { + final String errorMessage = "message \"" + eventObject + + "\" received from JMS does not have a \"getObject()\" method"; + LOGGER.warn(errorMessage); + throw new ApexEventRuntimeException(errorMessage); + } + + Object jmsIncomingObject; + try { + jmsIncomingObject = getObjectMethod.invoke(eventObject, (Object[]) null); + } catch (final Exception e) { + final String errorMessage = "object contained in message \"" + eventObject + + "\" received from JMS could not be retrieved as a Java object"; + LOGGER.debug(errorMessage, e); + throw new ApexEventRuntimeException(errorMessage, e); + } + + // Check that the consumer parameters for JMS->Apex messaging have been set + if (eventProtocolParameters == null) { + final String errorMessage = "consumer parameters for JMS events consumed by " + + "Apex are not set in the Apex configuration for this engine"; + LOGGER.debug(errorMessage); + throw new ApexEventRuntimeException(errorMessage); + } + + // Create the Apex event + // @formatter:off + final ApexEvent apexEvent = new ApexEvent( + jmsIncomingObject.getClass().getSimpleName() + eventProtocolParameters.getIncomingEventSuffix(), + eventProtocolParameters.getIncomingEventVersion(), + jmsIncomingObject.toString().getClass().getPackage().getName(), + eventProtocolParameters.getIncomingEventSource(), + eventProtocolParameters.getIncomingEventTarget()); + // @formatter:on + + // Set the data on the apex event as the incoming object + apexEvent.put(jmsIncomingObject.getClass().getSimpleName(), jmsIncomingObject); + + // Return the event in a single element + final ArrayList eventList = new ArrayList<>(); + eventList.add(apexEvent); + return eventList; + } + + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.service.engine.event.ApexEventConverter#fromApexEvent + * (org.onap.policy.apex.service.engine.event.ApexEvent) + */ + @Override + public Object fromApexEvent(final ApexEvent apexEvent) throws ApexEventException { + // Check the Apex event + if (apexEvent == null) { + LOGGER.warn("event processing failed, Apex event is null"); + throw new ApexEventException("event processing failed, Apex event is null"); + } + + // Check that the Apex event has a single parameter + if (apexEvent.size() != 1) { + final String errorMessage = "event processing failed, " + + "Apex event must have one and only one parameter for JMS Object handling"; + LOGGER.warn(errorMessage); + throw new ApexEventException(errorMessage); + } + + // Return the single object from the Apex event message + return apexEvent.values().iterator().next(); + } +} diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverter.java new file mode 100644 index 000000000..1c44dd111 --- /dev/null +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverter.java @@ -0,0 +1,95 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.plugins.event.protocol.jms; + +import java.lang.reflect.Method; +import java.util.List; + +import org.onap.policy.apex.service.engine.event.ApexEvent; +import org.onap.policy.apex.service.engine.event.ApexEventException; +import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; +import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JsonEventConverter; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * The Class Apex2JMSTextEventConverter converts {@link ApexEvent} instances into string instances of + * text message events for JMS. It is a proxy for the built in + * {@link org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JsonEventConverter} plugin. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public final class Apex2JmsTextEventConverter extends Apex2JsonEventConverter { + private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2JmsTextEventConverter.class); + + /* + * (non-Javadoc) + * + * @see org.onap.policy.apex.service.engine.event.ApexEventConverter#toApexEvent(java.lang.String, java.lang.Object) + */ + @Override + public List toApexEvent(final String eventName, final Object eventObject) throws ApexEventException { + // Look for a "getText()" method on the incoming object, if there is no such method, then we cannot fetch the + // text from JMS + Method getTextMethod; + try { + getTextMethod = eventObject.getClass().getMethod("getText", (Class[]) null); + } catch (Exception e) { + final String errorMessage = "message \"" + eventObject + + "\" received from JMS does not have a \"getText()\" method"; + LOGGER.warn(errorMessage); + throw new ApexEventRuntimeException(errorMessage); + } + + + String jmsString; + try { + jmsString = (String) getTextMethod.invoke(eventObject, (Object[]) null); + } catch (final Exception e) { + final String errorMessage = "object contained in message \"" + eventObject + + "\" received from JMS could not be retrieved as a Java String"; + LOGGER.debug(errorMessage, e); + throw new ApexEventRuntimeException(errorMessage, e); + } + + // Use the generic JSON plugin from here + return super.toApexEvent(eventName, jmsString); + } + + /* + * (non-Javadoc) + * + * @see + * org.onap.policy.apex.service.engine.event.ApexEventConverter#fromApexEvent(org.onap.policy.apex.service.engine. + * event. ApexEvent) + */ + @Override + public Object fromApexEvent(final ApexEvent apexEvent) throws ApexEventException { + // Check the Apex event + if (apexEvent == null) { + LOGGER.warn("event processing failed, Apex event is null"); + throw new ApexEventException("event processing failed, Apex event is null"); + } + + // Return the Apex event as a string object + return super.fromApexEvent(apexEvent); + } +} diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSObjectEventProtocolParameters.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSObjectEventProtocolParameters.java deleted file mode 100644 index 83aef4e9d..000000000 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSObjectEventProtocolParameters.java +++ /dev/null @@ -1,127 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.plugins.event.protocol.jms; - -import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters; - -/** - * Event protocol parameters for JMS Object messages as an event protocol. - * - *

- * On reception of an a JMS {@code javax.jms.ObjectMessage}, the JMS Object plugin unmarshals the message as follows: - *

    - *
  1. It extracts the Java object from the {@code javax.jms.ObjectMessage} instance.
  2. - *
  3. It creates an {@link org.onap.policy.apex.service.engine.event.ApexEvent} instance to hold the java object.
  4. - *
  5. It sets the name of the Apex event to be the simple class name of the incoming Java object and appends the value - * of the {@code incomingEventSuffix} parameter to it.
  6. - *
  7. It sets the version of the incoming event to the value of the {@code incomingEventVersion} parameter.
  8. - *
  9. It sets the name space of the incoming event to be the value of the package of the class of the incoming Java - * object.
  10. - *
  11. It sets the source of the incoming event to the value of the {@code incomingEventSource} parameter.
  12. - *
  13. It sets the target of the incoming event to the value of the {@code incomingEventTarget} parameter.
  14. - *
  15. It puts a single entry into the Apex event map with the the simple class name of the incoming Java object being - * the key of the entry and the actual incoming object as the value of the entry.
  16. - *
- *

- * When sending an object to JMS, the plugin expects to receive an Apex event with a single entry. The plugin marshals - * the value of that entry to an object that can be sent by JMS as a {@code javax.jms.ObjectMessage} instance. - *

- * The parameters for this plugin are: - *

    - *
  1. incomingEventSuffix: The suffix to append to the simple name of incoming Java class instances when they are - * encapsulated in Apex events. The parameter defaults to the string value {@code IncomingEvent}.
  2. - *
  3. incomingEventVersion: The event version to use for incoming Java class instances when they are encapsulated in - * Apex events. The parameter defaults to the string value {@code 1.0.0}.
  4. - *
  5. incomingEventSource: The event source to use for incoming Java class instances when they are encapsulated in Apex - * events. The parameter defaults to the string value {@code JMS}.
  6. - *
  7. incomingEventTarget: The event target to use for incoming Java class instances when they are encapsulated in Apex - * events. The parameter defaults to the string value {@code Apex}.
  8. - *
- * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class JMSObjectEventProtocolParameters extends EventProtocolParameters { - /** The label of this event protocol. */ - public static final String JMS_OBJECT_EVENT_PROTOCOL_LABEL = "JMSOBJECT"; - - //@formatter:off - // Default parameter values - private static final String DEFAULT_INCOMING_EVENT_SUFFIX = "IncomingEvent"; - private static final String DEFAULT_INCOMING_EVENT_VERSION = "1.0.0"; - private static final String DEFAULT_INCOMING_EVENT_SOURCE = "JMS"; - private static final String DEFAULT_INCOMING_EVENT_TARGET = "Apex"; - - // JMS carrier parameters - private String incomingEventSuffix = DEFAULT_INCOMING_EVENT_SUFFIX; - private String incomingEventVersion = DEFAULT_INCOMING_EVENT_VERSION; - private String incomingEventSource = DEFAULT_INCOMING_EVENT_SOURCE; - private String incomingEventTarget = DEFAULT_INCOMING_EVENT_TARGET; - //@formatter:off - - /** - * Constructor to create a JSON event protocol parameter instance and register the instance with the parameter service. - */ - public JMSObjectEventProtocolParameters() { - super(JMSObjectEventProtocolParameters.class.getCanonicalName()); - - // Set the event protocol properties for the JMS Text event protocol - this.setLabel(JMS_OBJECT_EVENT_PROTOCOL_LABEL); - - // Set the event protocol plugin class - this.setEventProtocolPluginClass(Apex2JMSObjectEventConverter.class.getCanonicalName()); - } - - /** - * Gets the incoming event version. - * - * @return the incoming event version - */ - public String getIncomingEventVersion() { - return incomingEventVersion; - } - - /** - * Gets the incoming event source. - * - * @return the incoming event source - */ - public String getIncomingEventSource() { - return incomingEventSource; - } - - /** - * Gets the incoming event target. - * - * @return the incoming event target - */ - public String getIncomingEventTarget() { - return incomingEventTarget; - } - - /** - * Gets the incoming event suffix. - * - * @return the incoming event suffix - */ - public String getIncomingEventSuffix() { - return incomingEventSuffix; - } -} diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSTextEventProtocolParameters.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSTextEventProtocolParameters.java deleted file mode 100644 index b3a9154ff..000000000 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSTextEventProtocolParameters.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.plugins.event.protocol.jms; - -import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters; - -/** - * Event protocol parameters for JMS Text messages as an event protocol. - *

- * Text messages received and sent over JMS in ~Text format are assumed to be in a JSON format that Apex can understand. - * Therefore this plugin is a subclass of the built in JSON event protocol plugin. - *

- * On reception of a JMS {@code javax.jms.TextMessage} message, the JMS Text plugin unmarshals the message the JMS text - * message and passes it to its JSON superclass unmarshaling for processing. - *

- * When sending an Apex event, the plugin uses its underlying JSON superclass to marshal the event to a JSON string and - * passes that string to the JSON carrier plugin for sending. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class JMSTextEventProtocolParameters extends JSONEventProtocolParameters { - /** The label of this event protocol. */ - public static final String JMS_TEXT_EVENT_PROTOCOL_LABEL = "JMSTEXT"; - - /** - * Constructor to create a JSON event protocol parameter instance and register the instance with the parameter - * service. - */ - public JMSTextEventProtocolParameters() { - super(JMSTextEventProtocolParameters.class.getCanonicalName(), JMS_TEXT_EVENT_PROTOCOL_LABEL); - - // Set the event protocol properties for the JMS Text event protocol - this.setLabel(JMS_TEXT_EVENT_PROTOCOL_LABEL); - - // Set the event protocol plugin class - this.setEventProtocolPluginClass(Apex2JMSTextEventConverter.class.getCanonicalName()); - } -} diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParameters.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParameters.java new file mode 100644 index 000000000..3c15a7825 --- /dev/null +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParameters.java @@ -0,0 +1,127 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.plugins.event.protocol.jms; + +import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters; + +/** + * Event protocol parameters for JMS Object messages as an event protocol. + * + *

On reception of an a JMS {@code javax.jms.ObjectMessage}, the JMS Object plugin unmarshals the message as follows: + *

    + *
  1. It extracts the Java object from the {@code javax.jms.ObjectMessage} instance.
  2. + *
  3. It creates an {@link org.onap.policy.apex.service.engine.event.ApexEvent} instance to hold the java object.
  4. + *
  5. It sets the name of the Apex event to be the simple class name of the incoming Java object and appends the value + * of the {@code incomingEventSuffix} parameter to it.
  6. + *
  7. It sets the version of the incoming event to the value of the {@code incomingEventVersion} parameter.
  8. + *
  9. It sets the name space of the incoming event to be the value of the package of the class of the incoming Java + * object.
  10. + *
  11. It sets the source of the incoming event to the value of the {@code incomingEventSource} parameter.
  12. + *
  13. It sets the target of the incoming event to the value of the {@code incomingEventTarget} parameter.
  14. + *
  15. It puts a single entry into the Apex event map with the the simple class name of the incoming Java object being + * the key of the entry and the actual incoming object as the value of the entry.
  16. + *
+ * + *

When sending an object to JMS, the plugin expects to receive an Apex event with a single entry. The plugin + * marshals the value of that entry to an object that can be sent by JMS as a {@code javax.jms.ObjectMessage} instance. + * + *

The parameters for this plugin are: + *

    + *
  1. incomingEventSuffix: The suffix to append to the simple name of incoming Java class instances when they are + * encapsulated in Apex events. The parameter defaults to the string value {@code IncomingEvent}.
  2. + *
  3. incomingEventVersion: The event version to use for incoming Java class instances when they are encapsulated in + * Apex events. The parameter defaults to the string value {@code 1.0.0}.
  4. + *
  5. incomingEventSource: The event source to use for incoming Java class instances when they are encapsulated in Apex + * events. The parameter defaults to the string value {@code JMS}.
  6. + *
  7. incomingEventTarget: The event target to use for incoming Java class instances when they are encapsulated in Apex + * events. The parameter defaults to the string value {@code Apex}.
  8. + *
+ * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class JmsObjectEventProtocolParameters extends EventProtocolParameters { + /** The label of this event protocol. */ + public static final String JMS_OBJECT_EVENT_PROTOCOL_LABEL = "JMSOBJECT"; + + //@formatter:off + // Default parameter values + private static final String DEFAULT_INCOMING_EVENT_SUFFIX = "IncomingEvent"; + private static final String DEFAULT_INCOMING_EVENT_VERSION = "1.0.0"; + private static final String DEFAULT_INCOMING_EVENT_SOURCE = "JMS"; + private static final String DEFAULT_INCOMING_EVENT_TARGET = "Apex"; + + // JMS carrier parameters + private String incomingEventSuffix = DEFAULT_INCOMING_EVENT_SUFFIX; + private String incomingEventVersion = DEFAULT_INCOMING_EVENT_VERSION; + private String incomingEventSource = DEFAULT_INCOMING_EVENT_SOURCE; + private String incomingEventTarget = DEFAULT_INCOMING_EVENT_TARGET; + //@formatter:off + + /** + * Constructor to create a JSON event protocol parameter instance and register the instance with the + * parameter service. + */ + public JmsObjectEventProtocolParameters() { + super(JmsObjectEventProtocolParameters.class.getCanonicalName()); + + // Set the event protocol properties for the JMS Text event protocol + this.setLabel(JMS_OBJECT_EVENT_PROTOCOL_LABEL); + + // Set the event protocol plugin class + this.setEventProtocolPluginClass(Apex2JmsObjectEventConverter.class.getCanonicalName()); + } + + /** + * Gets the incoming event version. + * + * @return the incoming event version + */ + public String getIncomingEventVersion() { + return incomingEventVersion; + } + + /** + * Gets the incoming event source. + * + * @return the incoming event source + */ + public String getIncomingEventSource() { + return incomingEventSource; + } + + /** + * Gets the incoming event target. + * + * @return the incoming event target + */ + public String getIncomingEventTarget() { + return incomingEventTarget; + } + + /** + * Gets the incoming event suffix. + * + * @return the incoming event suffix + */ + public String getIncomingEventSuffix() { + return incomingEventSuffix; + } +} diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsTextEventProtocolParameters.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsTextEventProtocolParameters.java new file mode 100644 index 000000000..67b211a08 --- /dev/null +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsTextEventProtocolParameters.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.plugins.event.protocol.jms; + +import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters; + +/** + * Event protocol parameters for JMS Text messages as an event protocol. + * + *

Text messages received and sent over JMS in ~Text format are assumed to be in a JSON format that Apex can + * understand. Therefore this plugin is a subclass of the built in JSON event protocol plugin. + * + *

On reception of a JMS {@code javax.jms.TextMessage} message, the JMS Text plugin unmarshals the message the JMS + * text message and passes it to its JSON superclass unmarshaling for processing. + * + *

When sending an Apex event, the plugin uses its underlying JSON superclass to marshal the event to a JSON string + * and passes that string to the JSON carrier plugin for sending. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class JmsTextEventProtocolParameters extends JsonEventProtocolParameters { + /** The label of this event protocol. */ + public static final String JMS_TEXT_EVENT_PROTOCOL_LABEL = "JMSTEXT"; + + /** + * Constructor to create a JSON event protocol parameter instance and register the instance with the parameter + * service. + */ + public JmsTextEventProtocolParameters() { + super(JmsTextEventProtocolParameters.class.getCanonicalName(), JMS_TEXT_EVENT_PROTOCOL_LABEL); + + // Set the event protocol properties for the JMS Text event protocol + this.setLabel(JMS_TEXT_EVENT_PROTOCOL_LABEL); + + // Set the event protocol plugin class + this.setEventProtocolPluginClass(Apex2JmsTextEventConverter.class.getCanonicalName()); + } +} -- cgit 1.2.3-korg