/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// Services state
public enum ServicesState {
- STOPPED, READY, INITIALIZING, RUNNING
+ STOPPED,
+ READY,
+ INITIALIZING,
+ RUNNING
}
private ServicesState state = ServicesState.STOPPED;
} catch (final ApexDeploymentRestParameterException e) {
throw new ApexDeploymentRestParameterException(
REST_ENDPOINT_PREFIX + this.toString() + ") parameter error, " + e.getMessage() + '\n'
- + parser.getHelp(ApexDeploymentRestMain.class.getCanonicalName()), e);
+ + parser.getHelp(ApexDeploymentRestMain.class.getName()),
+ e);
}
if (parameters.isHelpSet()) {
- throw new ApexDeploymentRestParameterException(
- parser.getHelp(ApexDeploymentRestMain.class.getCanonicalName()));
+ throw new ApexDeploymentRestParameterException(parser.getHelp(ApexDeploymentRestMain.class.getName()));
}
// Validate the parameters
if (validationMessage.length() > 0) {
throw new ApexDeploymentRestParameterException(
REST_ENDPOINT_PREFIX + this.toString() + ") parameters invalid, " + validationMessage + '\n'
- + parser.getHelp(ApexDeploymentRestMain.class.getCanonicalName()));
+ + parser.getHelp(ApexDeploymentRestMain.class.getName()));
}
state = ServicesState.READY;
String message = REST_ENDPOINT_PREFIX + this.toString() + ") failed at with error: " + e.getMessage();
outStream.println(message);
LOGGER.warn(message, e);
- } finally {
+ }
+ finally {
if (apexDeploymentRest != null) {
apexDeploymentRest.shutdown();
apexDeploymentRest = null;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
parameters = parser.parse(args);
} catch (final ApexEditorParameterException e) {
throw new ApexEditorParameterException(REST_ENDPOINT_PREFIX + this.toString() + ") parameter error, "
- + e.getMessage() + '\n' + parser.getHelp(ApexEditorMain.class.getCanonicalName()), e);
+ + e.getMessage() + '\n' + parser.getHelp(ApexEditorMain.class.getName()), e);
}
if (parameters.isHelpSet()) {
- throw new ApexEditorParameterException(parser.getHelp(ApexEditorMain.class.getCanonicalName()));
+ throw new ApexEditorParameterException(parser.getHelp(ApexEditorMain.class.getName()));
}
// Validate the parameters
final String validationMessage = parameters.validate();
if (validationMessage.length() > 0) {
throw new ApexEditorParameterException(REST_ENDPOINT_PREFIX + this.toString() + ") parameters invalid, "
- + validationMessage + '\n' + parser.getHelp(ApexEditorMain.class.getCanonicalName()));
+ + validationMessage + '\n' + parser.getHelp(ApexEditorMain.class.getName()));
}
state = EditorState.READY;
String message = REST_ENDPOINT_PREFIX + this.toString() + ") failed at with error: " + e.getMessage();
outStream.println(message);
LOGGER.warn(message, e);
- } finally {
+ }
+ finally {
if (apexEditor != null) {
apexEditor.shutdown();
apexEditor = null;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
parameters = parser.parse(args);
} catch (final ApexServicesRestParameterException e) {
throw new ApexServicesRestParameterException(REST_ENDPOINT_PREFIX + this.toString() + ") parameter error, "
- + e.getMessage() + '\n' + parser.getHelp(ApexServicesRestMain.class.getCanonicalName()), e);
+ + e.getMessage() + '\n' + parser.getHelp(ApexServicesRestMain.class.getName()), e);
}
if (parameters.isHelpSet()) {
- throw new ApexServicesRestParameterException(parser.getHelp(ApexServicesRestMain.class.getCanonicalName()));
+ throw new ApexServicesRestParameterException(parser.getHelp(ApexServicesRestMain.class.getName()));
}
// Validate the parameters
if (validationMessage.length() > 0) {
throw new ApexServicesRestParameterException(
REST_ENDPOINT_PREFIX + this.toString() + ") parameters invalid, " + validationMessage + '\n'
- + parser.getHelp(ApexServicesRestMain.class.getCanonicalName()));
+ + parser.getHelp(ApexServicesRestMain.class.getName()));
}
state = EditorState.READY;
String message = REST_ENDPOINT_PREFIX + this.toString() + ") failed at with error: " + e.getMessage();
outStream.println(message);
LOGGER.warn(message, e);
- } finally {
+ }
+ finally {
if (apexServices != null) {
apexServices.shutdown();
apexServices = null;
}
}
}
-
+
/**
* Main method, main entry point for command.
*
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// Services state
public enum ServicesState {
- STOPPED, READY, INITIALIZING, RUNNING
+ STOPPED,
+ READY,
+ INITIALIZING,
+ RUNNING
}
private ServicesState state = ServicesState.STOPPED;
} catch (final ApexMonitoringRestParameterException e) {
throw new ApexMonitoringRestParameterException(
REST_ENDPOINT_PREFIX + this.toString() + ") parameter error, " + e.getMessage() + '\n'
- + parser.getHelp(ApexMonitoringRestMain.class.getCanonicalName()), e);
+ + parser.getHelp(ApexMonitoringRestMain.class.getName()),
+ e);
}
if (parameters.isHelpSet()) {
- throw new ApexMonitoringRestParameterException(
- parser.getHelp(ApexMonitoringRestMain.class.getCanonicalName()));
+ throw new ApexMonitoringRestParameterException(parser.getHelp(ApexMonitoringRestMain.class.getName()));
}
// Validate the parameters
if (validationMessage.length() > 0) {
throw new ApexMonitoringRestParameterException(
REST_ENDPOINT_PREFIX + this.toString() + ") parameters invalid, " + validationMessage + '\n'
- + parser.getHelp(ApexMonitoringRestMain.class.getCanonicalName()));
+ + parser.getHelp(ApexMonitoringRestMain.class.getName()));
}
state = ServicesState.READY;
String message = REST_ENDPOINT_PREFIX + this.toString() + ") failed at with error: " + e.getMessage();
outStream.println(message);
LOGGER.warn(message, e);
- } finally {
+ }
+ finally {
if (apexMonitoringRest != null) {
apexMonitoringRest.shutdown();
apexMonitoringRest = null;
return schemaClass.newInstance();
} catch (final Exception e) {
final String returnString = userKey.getId() + ": could not create an instance of class \""
- + schemaClass.getCanonicalName() + "\" using the default constructor \""
+ + schemaClass.getName() + "\" using the default constructor \""
+ schemaClass.getSimpleName() + "()\"";
LOGGER.warn(returnString, e);
throw new ContextRuntimeException(returnString, e);
return stringConstructor.newInstance(stringValue);
} catch (final Exception e) {
final String returnString = userKey.getId() + ": could not create an instance of class \""
- + schemaClass.getCanonicalName() + "\" using the string constructor \""
+ + schemaClass.getName() + "\" using the string constructor \""
+ schemaClass.getSimpleName() + "(String)\"";
LOGGER.warn(returnString, e);
throw new ContextRuntimeException(returnString);
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
final String returnString = getUserKey().getId() + ": the object \"" + incomingObject + "\" of type \""
- + incomingObject.getClass().getCanonicalName()
- + "\" is not an instance of JsonObject and is not assignable to \""
- + getSchemaClass().getCanonicalName() + "\"";
+ + incomingObject.getClass().getName()
+ + "\" is not an instance of JsonObject and is not assignable to \"" + getSchemaClass().getName()
+ + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
return getGson().toJson(schemaObject);
} else {
final String returnString = getUserKey().getId() + ": object \"" + schemaObject.toString()
- + "\" of class \"" + schemaObject.getClass().getCanonicalName()
- + "\" not compatible with class \"" + getSchemaClass().getCanonicalName() + "\"";
+ + "\" of class \"" + schemaObject.getClass().getName() + "\" not compatible with class \""
+ + getSchemaClass().getName() + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
return stringConstructor.newInstance(object.toString());
} catch (final Exception e) {
final String returnString = getUserKey().getId() + ": object \"" + object.toString() + "\" of class \""
- + object.getClass().getCanonicalName() + "\" not compatible with class \""
- + getSchemaClass().getCanonicalName() + "\"";
+ + object.getClass().getName() + "\" not compatible with class \""
+ + getSchemaClass().getName() + "\"";
LOGGER.warn(returnString, e);
throw new ContextRuntimeException(returnString);
}
/**
* Get a GSON instance that has the correct adaptation included.
- *
+ *
* @return the GSON instance
*/
private Gson getGson() {
JavaSchemaHelperParameters javaSchemaHelperParmeters = (JavaSchemaHelperParameters) schemaParameters
.getSchemaHelperParameterMap().get("Java");
-
+
if (javaSchemaHelperParmeters == null) {
javaSchemaHelperParmeters = new JavaSchemaHelperParameters();
}
-
+
for (JavaSchemaHelperJsonAdapterParameters jsonAdapterEntry : javaSchemaHelperParmeters.getJsonAdapters()
.values()) {
// executor class
if (executorClass == null) {
final String errorMessage = "Executor plugin class not defined for \"" + logicFlavour
- + "\" executor of type \"" + executorSuperClass.getCanonicalName() + "\"";
+ + "\" executor of type \"" + executorSuperClass.getName() + "\"";
LOGGER.error(errorMessage);
throw new StateMachineRuntimeException(errorMessage);
}
executorObject = executorClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
final String errorMessage = "Instantiation error on \"" + logicFlavour + "\" executor of type \""
- + executorClass.getCanonicalName() + "\"";
+ + executorClass.getName() + "\"";
LOGGER.error(errorMessage, e);
throw new StateMachineRuntimeException(errorMessage, e);
}
// Check the class is the correct type of executor
if (!(executorSuperClass.isAssignableFrom(executorObject.getClass()))) {
final String errorMessage = "Executor on \"" + logicFlavour + "\" of type \"" + executorClass
- + "\" is not an instance of \"" + executorSuperClass.getCanonicalName() + "\"";
+ + "\" is not an instance of \"" + executorSuperClass.getName() + "\"";
LOGGER.error(errorMessage);
throw new StateMachineRuntimeException(errorMessage);
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* Private default constructor to prevent subclassing.
*/
- private AadmDomainModelSaver() {}
+ private AadmDomainModelSaver() {
+ }
/**
* Write the AADM model to args[0].
*/
public static void main(final String[] args) throws ApexException {
if (args.length != 1) {
- LOGGER.error("usage: " + AadmDomainModelSaver.class.getCanonicalName() + " modelDirectory");
+ LOGGER.error("usage: " + AadmDomainModelSaver.class.getName() + " modelDirectory");
return;
}
// Save Java model
final AxPolicyModel aadmPolicyModel = new AadmDomainModelFactory().getAadmPolicyModel();
- final ApexModelSaver<AxPolicyModel> aadmModelSaver =
- new ApexModelSaver<>(AxPolicyModel.class, aadmPolicyModel, args[0]);
+ final ApexModelSaver<AxPolicyModel> aadmModelSaver = new ApexModelSaver<>(AxPolicyModel.class, aadmPolicyModel,
+ args[0]);
aadmModelSaver.apexModelWriteJson();
aadmModelSaver.apexModelWriteXml();
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
public static void main(final String[] args) throws ApexException {
if (args.length != 1) {
- LOGGER.error("usage: " + AdaptiveDomainModelSaver.class.getCanonicalName() + " modelDirectory");
+ LOGGER.error("usage: " + AdaptiveDomainModelSaver.class.getName() + " modelDirectory");
return;
}
// Save Anomaly Detection model
final AxPolicyModel adPolicyModel = new AdaptiveDomainModelFactory().getAnomalyDetectionPolicyModel();
- final ApexModelSaver<AxPolicyModel> adModelSaver =
- new ApexModelSaver<>(AxPolicyModel.class, adPolicyModel, args[0]);
+ final ApexModelSaver<AxPolicyModel> adModelSaver = new ApexModelSaver<>(AxPolicyModel.class, adPolicyModel,
+ args[0]);
adModelSaver.apexModelWriteJson();
adModelSaver.apexModelWriteXml();
// Save Auto Learn model
final AxPolicyModel alPolicyModel = new AdaptiveDomainModelFactory().getAutoLearnPolicyModel();
- final ApexModelSaver<AxPolicyModel> alModelSaver =
- new ApexModelSaver<>(AxPolicyModel.class, alPolicyModel, args[0]);
+ final ApexModelSaver<AxPolicyModel> alModelSaver = new ApexModelSaver<>(AxPolicyModel.class, alPolicyModel,
+ args[0]);
alModelSaver.apexModelWriteJson();
alModelSaver.apexModelWriteXml();
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private static final XLogger LOGGER = XLoggerFactory.getXLogger(MfpDomainModelSaver.class);
/** Private constructor to prevent instantiation. */
- private MfpDomainModelSaver() {}
+ private MfpDomainModelSaver() {
+ }
/**
* Write the MyFirstPolicy model to args[0].
*/
public static void main(final String[] args) throws ApexException {
if (args.length != 1) {
- LOGGER.error("usage: " + MfpDomainModelSaver.class.getCanonicalName() + " modelDirectory");
+ LOGGER.error("usage: " + MfpDomainModelSaver.class.getName() + " modelDirectory");
return;
}
// Save Java model
AxPolicyModel mfpPolicyModel = new MfpDomainModelFactory().getMfp1PolicyModel();
- ApexModelSaver<AxPolicyModel> mfpModelSaver =
- new ApexModelSaver<>(AxPolicyModel.class, mfpPolicyModel, args[0] + "/1/");
+ ApexModelSaver<AxPolicyModel> mfpModelSaver = new ApexModelSaver<>(AxPolicyModel.class, mfpPolicyModel,
+ args[0] + "/1/");
mfpModelSaver.apexModelWriteJson();
mfpModelSaver.apexModelWriteXml();
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
public static void main(final String[] args) throws ApexException {
if (args.length != 2) {
- LOGGER.error("usage: " + PcvsDomainModelSaver.class.getCanonicalName()
- + " workingDirectory modelDirectory");
+ LOGGER.error("usage: " + PcvsDomainModelSaver.class.getName() + " workingDirectory modelDirectory");
return;
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
mg.getTransaction().begin();
mg.merge(obj);
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
}
mg.getTransaction().begin();
mg.remove(mg.contains(obj) ? obj : mg.merge(obj));
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
}
mg.createQuery(DELETE_FROM + someClass.getSimpleName() + C_WHERE_C_KEY_NAME + key.getName()
+ AND_C_KEY_VERSION + key.getVersion() + "'", someClass).executeUpdate();
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
}
+ key.getParentKeyName() + AND_C_KEY_PARENT_KEY_VERSION + key.getParentKeyVersion()
+ AND_C_KEY_LOCAL_NAME + key.getLocalName() + "'", someClass).executeUpdate();
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
}
mg.merge(t);
}
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
}
mg.remove(mg.contains(t) ? t : mg.merge(t));
}
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
}
.executeUpdate();
}
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
return deletedCount;
+ AND_C_KEY_LOCAL_NAME + key.getLocalName() + "'", someClass).executeUpdate();
}
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
return deletedCount;
mg.getTransaction().begin();
mg.createQuery(DELETE_FROM + someClass.getSimpleName() + " c ", someClass).executeUpdate();
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
}
t.copyTo(clonedT);
return clonedT;
} catch (final Exception e) {
- LOGGER.warn("Could not clone object of class \"" + someClass.getCanonicalName() + "\"", e);
+ LOGGER.warn("Could not clone object of class \"" + someClass.getName() + "\"", e);
return null;
}
} else {
return null;
}
- } finally {
+ }
+ finally {
mg.close();
}
}
t.copyTo(clonedT);
return clonedT;
} catch (final Exception e) {
- LOGGER.warn("Could not clone object of class \"" + someClass.getCanonicalName() + "\"", e);
+ LOGGER.warn("Could not clone object of class \"" + someClass.getName() + "\"", e);
return null;
}
} else {
return null;
}
- } finally {
+ }
+ finally {
mg.close();
}
}
final EntityManager mg = getEntityManager();
try {
return mg.createQuery(SELECT_C_FROM + someClass.getSimpleName() + " c", someClass).getResultList();
- } finally {
+ }
+ finally {
mg.close();
}
}
return mg.createQuery(SELECT_C_FROM + someClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME
+ parentKey.getName() + AND_C_KEY_PARENT_KEY_VERSION + parentKey.getVersion() + "'",
someClass).getResultList();
- } finally {
+ }
+ finally {
mg.close();
}
}
try {
ret = mg.createQuery(SELECT_C_FROM + someClass.getSimpleName() + C_WHERE_C_KEY_NAME + key.getName()
+ AND_C_KEY_VERSION + key.getVersion() + "'", someClass).getResultList();
- } finally {
+ }
+ finally {
mg.close();
}
if (ret == null || ret.isEmpty()) {
ret = mg.createQuery(SELECT_C_FROM + someClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME
+ key.getParentKeyName() + AND_C_KEY_PARENT_KEY_VERSION + key.getParentKeyVersion()
+ AND_C_KEY_LOCAL_NAME + key.getLocalName() + "'", someClass).getResultList();
- } finally {
+ }
+ finally {
mg.close();
}
if (ret == null || ret.isEmpty()) {
ret = mg.merge(obj);
mg.flush();
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
return ret;
try {
size = mg.createQuery("SELECT COUNT(c) FROM " + someClass.getSimpleName() + " c", Long.class)
.getSingleResult();
- } finally {
+ }
+ finally {
mg.close();
}
return size;
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
* chains in modules such as the Apex engine and editor. The model service makes the model and concept definitions
* available statically.
*
- * <p>Note that the use of the model service means that only a single Apex model of a particular type may exist in
- * Apex (particularly the engine) at any time. Of course the model in a JVM can be changed at any time provided all
- * users of the model are stopped and restarted in an orderly manner.
+ * <p>Note that the use of the model service means that only a single Apex model of a particular type may exist in Apex
+ * (particularly the engine) at any time. Of course the model in a JVM can be changed at any time provided all users of
+ * the model are stopped and restarted in an orderly manner.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
final M model = (M) modelMap.get(modelClass);
if (model == null) {
- throw new ApexRuntimeException(
- "Model for " + modelClass.getCanonicalName() + " not found in model service");
+ throw new ApexRuntimeException("Model for " + modelClass.getName() + " not found in model service");
}
return model;
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
*/
public static Type build(final String type) {
if (type == null || type.length() == 0) {
- throw new IllegalArgumentException("Blank type string passed to " + TypeBuilder.class.getCanonicalName()
- + ".build(String type)");
+ throw new IllegalArgumentException(
+ "Blank type string passed to " + TypeBuilder.class.getName() + ".build(String type)");
}
try {
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
public Object mapFromAvro(final Object avroObject) {
// The Avro object should be a Utf8 object
if (!(avroObject instanceof ByteBuffer)) {
- final String returnString =
- userKey.getId() + ": object \"" + avroObject + "\" of class \"" + avroObject.getClass()
- + "\" cannot be decoded to an object of class \"" + schemaClass.getCanonicalName() + "\"";
+ final String returnString = userKey.getId() + ": object \"" + avroObject + "\" of class \""
+ + avroObject.getClass() + "\" cannot be decoded to an object of class \""
+ + schemaClass.getName() + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
public Object mapToAvro(final Object object) {
if (object == null) {
final String returnString = userKey.getId() + ": cannot encode a null object of class \""
- + schemaClass.getCanonicalName() + "\"";
+ + schemaClass.getName() + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
// The incoming object should be a byte array
if (!(object instanceof byte[])) {
final String returnString = userKey.getId() + ": object \"" + object + "\" of class \"" + object.getClass()
- + "\" cannot be decoded to an object of class \"" + schemaClass.getCanonicalName() + "\"";
+ + "\" cannot be decoded to an object of class \"" + schemaClass.getName() + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
import org.slf4j.ext.XLoggerFactory;
/**
- * This class does direct mapping from Avro classes to Java classes, used for Avro primitive types
- * that directly produce Java objects.
+ * This class does direct mapping from Avro classes to Java classes, used for Avro primitive types that directly produce
+ * Java objects.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
// It is legal for the schema class to be null, if the Avro schema has a "null" type then
// the decoded object is always returned as a null
if (!schemaClass.isAssignableFrom(avroObject.getClass())) {
- final String returnString =
- userKey.getId() + ": object \"" + avroObject + "\" of class \"" + avroObject.getClass()
- + "\" cannot be decoded to an object of class \"" + schemaClass.getCanonicalName() + "\"";
+ final String returnString = userKey.getId() + ": object \"" + avroObject + "\" of class \""
+ + avroObject.getClass() + "\" cannot be decoded to an object of class \""
+ + schemaClass.getName() + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
// Null values are only allowed if the schema class is null
if (object == null && schemaClass != null) {
final String returnString = userKey.getId() + ": cannot encode a null object of class \""
- + schemaClass.getCanonicalName() + "\"";
+ + schemaClass.getName() + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
/**
* Create an instance of a sub type of this type.
- *
+ *
* @param schema the Avro schema of the the type
* @param subInstanceType the sub type
* @param foundTypes types we have already found
/**
* Instantiate a sub instance of a type.
- *
+ *
* @param subInstanceType the type of the sub instance to create
* @param subSchema the sub schema we have received
* @param foundTypes types we have already found
/**
* Check that the incoming object is a string, the incoming object must be a string containing Json.
- *
+ *
* @param object incoming object
* @return object as String
*/
}
} catch (final ClassCastException e) {
final String returnString = getUserKey().getId() + OBJECT_TAG + object + "\" of type \""
- + (object != null ? object.getClass().getCanonicalName() : "null")
- + "\" must be assignable to \"" + getSchemaClass().getCanonicalName()
+ + (object != null ? object.getClass().getName() : "null") + "\" must be assignable to \""
+ + getSchemaClass().getName()
+ "\" or be a Json string representation of it for Avro unmarshalling";
LOGGER.warn(returnString, e);
throw new ContextRuntimeException(returnString);
/**
* Get a string object.
- *
+ *
* @param object the string object
* @return the string
*/
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
*/
public class AvroSchemaHelperParameters extends SchemaHelperParameters {
/**
- * The Default Constructor sets the {@link AvroSchemaHelper} as the schema helper class for Avro
- * schemas.
+ * The Default Constructor sets the {@link AvroSchemaHelper} as the schema helper class for Avro schemas.
*/
public AvroSchemaHelperParameters() {
- this.setSchemaHelperPluginClass(AvroSchemaHelper.class.getCanonicalName());
+ this.setSchemaHelperPluginClass(AvroSchemaHelper.class.getName());
}
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
public Object mapFromAvro(final Object avroObject) {
// The Avro object should be a Utf8 object
if (!(avroObject instanceof Utf8)) {
- final String returnString =
- userKey.getId() + ": object \"" + avroObject + "\" of class \"" + avroObject.getClass()
- + "\" cannot be decoded to an object of class \"" + schemaClass.getCanonicalName() + "\"";
+ final String returnString = userKey.getId() + ": object \"" + avroObject + "\" of class \""
+ + avroObject.getClass() + "\" cannot be decoded to an object of class \""
+ + schemaClass.getName() + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
public Object mapToAvro(final Object object) {
if (object == null) {
final String returnString = userKey.getId() + ": cannot encode a null object of class \""
- + schemaClass.getCanonicalName() + "\"";
+ + schemaClass.getName() + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
fail("Test should throw an exception here");
} catch (final Exception e) {
assertEquals("AvroTest:0.0.1: could not create an instance "
- + "of class \"org.apache.avro.generic.GenericData.Fixed\" "
+ + "of class \"org.apache.avro.generic.GenericData$Fixed\" "
+ "using the default constructor \"Fixed()\"", e.getMessage());
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage()
- .startsWith("AvroTest:0.0.1: cannot encode a null object of class \"java.lang.Byte[]\""));
+ .startsWith("AvroTest:0.0.1: cannot encode a null object of class \"[Ljava.lang.Byte;\""));
}
}
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
schemaHelper.createNewInstance();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Byte[]\" "
+ assertEquals("AvroTest:0.0.1: could not create an instance of class \"[Ljava.lang.Byte;\" "
+ "using the default constructor \"Byte[]()\"", e.getMessage());
}
final byte[] newBytes = (byte[]) schemaHelper.createNewInstance("\"hello\"");
// Check and get the JMS Properties
if (!(consumerParameters.getCarrierTechnologyParameters() instanceof JmsCarrierTechnologyParameters)) {
final String errorMessage = "specified consumer properties of type \""
- + consumerParameters.getCarrierTechnologyParameters().getClass().getCanonicalName()
+ + consumerParameters.getCarrierTechnologyParameters().getClass().getName()
+ "\" are not applicable to a JMS consumer";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
@Override
public void init(final String producerName, final EventHandlerParameters producerParameters)
- throws ApexEventException {
+ throws ApexEventException {
this.name = producerName;
// Check and get the JMS Properties
if (!(producerParameters.getCarrierTechnologyParameters() instanceof JmsCarrierTechnologyParameters)) {
- final String errorMessage =
- "specified producer properties are not applicable to a JMS producer (" + this.name + ")";
+ final String errorMessage = "specified producer properties are not applicable to a JMS producer ("
+ + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
// Check if we actually got a connection factory
if (connectionFactory == null) {
throw new IllegalArgumentException(
- "JMS context lookup of \"" + jmsProducerProperties.getConnectionFactory()
- + "\" returned null for producer (" + this.name + ")");
+ "JMS context lookup of \"" + jmsProducerProperties.getConnectionFactory()
+ + "\" returned null for producer (" + this.name + ")");
}
} catch (final Exception e) {
final String errorMessage = "lookup of JMS connection factory \""
- + jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \""
- + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
+ + jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \""
+ + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
// Check if we actually got a topic
if (jmsOutgoingTopic == null) {
throw new IllegalArgumentException("JMS context lookup of \"" + jmsProducerProperties.getProducerTopic()
- + "\" returned null for producer (" + this.name + ")");
+ + "\" returned null for producer (" + this.name + ")");
}
} catch (final Exception e) {
final String errorMessage = "lookup of JMS topic \"" + jmsProducerProperties.getProducerTopic()
- + "\" failed for JMS producer properties \"" + jmsProducerProperties.getJmsProducerProperties()
- + FOR_PRODUCER_TAG + this.name + ")";
+ + "\" failed for JMS producer properties \""
+ + jmsProducerProperties.getJmsProducerProperties() + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
// Create and start a connection to the JMS server
try {
connection = connectionFactory.createConnection(jmsProducerProperties.getSecurityPrincipal(),
- jmsProducerProperties.getSecurityCredentials());
+ jmsProducerProperties.getSecurityCredentials());
connection.start();
} catch (final Exception e) {
final String errorMessage = "connection to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
} catch (final Exception e) {
final String errorMessage = "creation of session to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
try {
messageProducer = jmsSession.createProducer(jmsOutgoingTopic);
} catch (final Exception e) {
- final String errorMessage =
- "creation of producer for sending events " + "to JMS server failed for JMS properties \""
+ final String errorMessage = "creation of producer for sending events "
+ + "to JMS server failed for JMS properties \""
+ jmsProducerProperties.getJmsConsumerProperties() + "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
*/
@Override
public void sendEvent(final long executionId, final Properties executionProperties, final String eventname,
- final Object eventObject) {
+ final Object eventObject) {
// Check if this is a synchronized event, if so we have received a reply
- final SynchronousEventCache synchronousEventCache =
- (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
+ final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) peerReferenceMap
+ .get(EventHandlerPeeredMode.SYNCHRONOUS);
if (synchronousEventCache != null) {
synchronousEventCache.removeCachedEventToApexIfExists(executionId);
}
// Check if the object to be sent is serializable
if (!Serializable.class.isAssignableFrom(eventObject.getClass())) {
final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name
- + ", object of type \"" + eventObject.getClass().getCanonicalName() + "\" is not serializable";
+ + ", object of type \"" + eventObject.getClass().getName() + "\" is not serializable";
LOGGER.warn(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
jmsMessage = jmsSession.createObjectMessage((Serializable) eventObject);
} catch (final Exception e) {
final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name
- + ", could not create JMS Object Message for object \"" + eventObject;
+ + ", could not create JMS Object Message for object \"" + eventObject;
LOGGER.warn(errorMessage, e);
throw new ApexEventRuntimeException(errorMessage);
}
jmsMessage = jmsSession.createTextMessage(eventObject.toString());
} catch (final Exception e) {
final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name
- + ", could not create JMS Text Message for object \"" + eventObject;
+ + ", could not create JMS Text Message for object \"" + eventObject;
LOGGER.warn(errorMessage, e);
throw new ApexEventRuntimeException(errorMessage);
}
messageProducer.send(jmsMessage);
} catch (final Exception e) {
final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name
- + ", send failed for object \"" + eventObject;
+ + ", send failed for object \"" + eventObject;
LOGGER.warn(errorMessage, e);
throw new ApexEventRuntimeException(errorMessage);
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
@Override
public void init(final String consumerName, final EventHandlerParameters consumerParameters,
- final ApexEventReceiver incomingEventReceiver) throws ApexEventException {
+ final ApexEventReceiver incomingEventReceiver) throws ApexEventException {
this.eventReceiver = incomingEventReceiver;
this.name = consumerName;
// Check and get the Kafka Properties
if (!(consumerParameters.getCarrierTechnologyParameters() instanceof KafkaCarrierTechnologyParameters)) {
LOGGER.warn("specified consumer properties of type \""
- + consumerParameters.getCarrierTechnologyParameters().getClass().getCanonicalName()
- + "\" are not applicable to a Kafka consumer");
+ + consumerParameters.getCarrierTechnologyParameters().getClass().getName()
+ + "\" are not applicable to a Kafka consumer");
throw new ApexEventException("specified consumer properties of type \""
- + consumerParameters.getCarrierTechnologyParameters().getClass().getCanonicalName()
- + "\" are not applicable to a Kafka consumer");
+ + consumerParameters.getCarrierTechnologyParameters().getClass().getName()
+ + "\" are not applicable to a Kafka consumer");
}
- kafkaConsumerProperties =
- (KafkaCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
+ kafkaConsumerProperties = (KafkaCarrierTechnologyParameters) consumerParameters
+ .getCarrierTechnologyParameters();
// Kick off the Kafka consumer
kafkaConsumer = new KafkaConsumer<>(kafkaConsumerProperties.getKafkaConsumerProperties());
kafkaConsumer.subscribe(kafkaConsumerProperties.getConsumerTopicListAsCollection());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("event receiver for " + this.getClass().getName() + ":" + this.name + " subscribed to topics: "
- + kafkaConsumerProperties.getConsumerTopicList());
+ + kafkaConsumerProperties.getConsumerTopicList());
}
}
kafkaConsumer.subscribe(kafkaConsumerProperties.getConsumerTopicListAsCollection());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("event receiver for " + this.getClass().getName() + ":" + this.name + " subscribed to topics: "
- + kafkaConsumerProperties.getConsumerTopicList());
+ + kafkaConsumerProperties.getConsumerTopicList());
}
// The endless loop that receives events over Kafka
while (consumerThread.isAlive() && !stopOrderedFlag) {
try {
- final ConsumerRecords<String, String> records =
- kafkaConsumer.poll(kafkaConsumerProperties.getConsumerPollDuration());
+ final ConsumerRecords<String, String> records = kafkaConsumer
+ .poll(kafkaConsumerProperties.getConsumerPollDuration());
for (final ConsumerRecord<String, String> record : records) {
traceIfTraceEnabled(record);
eventReceiver.receiveEvent(new Properties(), record.value());
private void traceIfTraceEnabled(final ConsumerRecord<String, String> record) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("event received for {} for forwarding to Apex engine : {} {}",
- this.getClass().getName() + ":" + this.name, record.key(), record.value());
+ this.getClass().getName() + ":" + this.name, record.key(), record.value());
}
}
/** The producer plugin class for the REST carrier technology. */
public static final String RESTREQUSTOR_EVENT_PRODUCER_PLUGIN_CLASS =
- ApexRestRequestorProducer.class.getCanonicalName();
+ ApexRestRequestorProducer.class.getName();
/** The consumer plugin class for the REST carrier technology. */
public static final String RESTREQUSTOR_EVENT_CONSUMER_PLUGIN_CLASS =
- ApexRestRequestorConsumer.class.getCanonicalName();
+ ApexRestRequestorConsumer.class.getName();
/** The default HTTP method for request events. */
public static final HttpMethod DEFAULT_REQUESTOR_HTTP_METHOD = HttpMethod.GET;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// 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 "
+ + parameters.getClass().getName() + "\" are not applicable to a "
+ Apex2JmsObjectEventConverter.class.getName() + " converter";
LOGGER.error(errormessage);
} else {
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
/**
* Get the event header name space.
- *
+ *
* @param yamlMap the YAML map to read from
* @param eventDefinition the event definition
* @return the event header name space
/**
* Get the event header source.
- *
+ *
* @param yamlMap the YAML map to read from
* @param eventDefinition the event definition
* @return the event header source
/**
* Get the event header target.
- *
+ *
* @param yamlMap the YAML map to read from
* @param eventDefinition the event definition
* @return the event header target
if (!(yamlField instanceof String)) {
// The element is not a string so throw an error
throw new ApexEventRuntimeException("field \"" + fieldName + "\" with type \""
- + yamlField.getClass().getCanonicalName() + "\" is not a string value");
+ + yamlField.getClass().getName() + "\" is not a string value");
}
final String fieldValueString = (String) yamlField;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
* Create an event consumer of the required type for the specified consumer technology.
*
* @param name the name of the consumer
- * @param consumerParameters The parameters for the Apex engine, we use the technology type of
- * the required consumer
+ * @param consumerParameters The parameters for the Apex engine, we use the technology type of the required consumer
* @return the event consumer
* @throws ApexEventException on errors creating the Apex event consumer
*/
public ApexEventConsumer createConsumer(final String name, final EventHandlerParameters consumerParameters)
- throws ApexEventException {
+ throws ApexEventException {
// Get the carrier technology parameters
final CarrierTechnologyParameters technologyParameters = consumerParameters.getCarrierTechnologyParameters();
consumerPluginObject = Class.forName(consumerPluginClass).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
final String errorMessage = "could not create an Apex event consumer for \"" + name
- + "\" for the carrier technology \"" + technologyParameters.getLabel()
- + "\", specified event consumer plugin class \"" + consumerPluginClass + "\" not found";
+ + "\" for the carrier technology \"" + technologyParameters.getLabel()
+ + "\", specified event consumer plugin class \"" + consumerPluginClass + "\" not found";
LOGGER.error(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
// Check the class is an event consumer
if (!(consumerPluginObject instanceof ApexEventConsumer)) {
final String errorMessage = "could not create an Apex event consumer \"" + name
- + "\" for the carrier technology \"" + technologyParameters.getLabel()
- + "\", specified event consumer plugin class \"" + consumerPluginClass
- + "\" is not an instance of \"" + ApexEventConsumer.class.getCanonicalName() + "\"";
+ + "\" for the carrier technology \"" + technologyParameters.getLabel()
+ + "\", specified event consumer plugin class \"" + consumerPluginClass
+ + "\" is not an instance of \"" + ApexEventConsumer.class.getName() + "\"";
LOGGER.error(errorMessage);
throw new ApexEventException(errorMessage);
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
* @throws ApexEventException on errors creating the Apex event producer
*/
public ApexEventProducer createProducer(final String name, final EventHandlerParameters producerParameters)
- throws ApexEventException {
+ throws ApexEventException {
// Get the carrier technology parameters
final CarrierTechnologyParameters technologyParameters = producerParameters.getCarrierTechnologyParameters();
producerPluginObject = Class.forName(producerPluginClass).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
final String errorMessage = "could not create an Apex event producer for Producer \"" + name
- + "\" for the carrier technology \"" + technologyParameters.getLabel()
- + "\", specified event producer plugin class \"" + producerPluginClass + "\" not found";
+ + "\" for the carrier technology \"" + technologyParameters.getLabel()
+ + "\", specified event producer plugin class \"" + producerPluginClass + "\" not found";
LOGGER.error(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
// Check the class is an event producer
if (!(producerPluginObject instanceof ApexEventProducer)) {
final String errorMessage = "could not create an Apex event producer for Producer \"" + name
- + "\" for the carrier technology \"" + technologyParameters.getLabel()
- + "\", specified event producer plugin class \"" + producerPluginClass
- + "\" is not an instance of \"" + ApexEventProducer.class.getCanonicalName() + "\"";
+ + "\" for the carrier technology \"" + technologyParameters.getLabel()
+ + "\", specified event producer plugin class \"" + producerPluginClass
+ + "\" is not an instance of \"" + ApexEventProducer.class.getName() + "\"";
LOGGER.error(errorMessage);
throw new ApexEventException(errorMessage);
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
import org.slf4j.ext.XLoggerFactory;
/**
- * This factory class uses the Apex event protocol parameters to create and return an instance of
- * the correct Apex event protocol converter plugin for the specified event protocol.
+ * This factory class uses the Apex event protocol parameters to create and return an instance of the correct Apex event
+ * protocol converter plugin for the specified event protocol.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
private static final XLogger LOGGER = XLoggerFactory.getXLogger(EventProtocolFactory.class);
/**
- * Create an event converter that converts between an
- * {@link org.onap.policy.apex.service.engine.event.ApexEvent} and the specified event protocol.
+ * Create an event converter that converts between an {@link org.onap.policy.apex.service.engine.event.ApexEvent}
+ * and the specified event protocol.
*
* @param name the name of the event protocol
- * @param eventProtocolParameters the event protocol parameters defining what to convert from
- * and to
+ * @param eventProtocolParameters the event protocol parameters defining what to convert from and to
* @return The event converter for converting events to and from Apex format
*/
public ApexEventProtocolConverter createConverter(final String name,
- final EventProtocolParameters eventProtocolParameters) {
+ final EventProtocolParameters eventProtocolParameters) {
// Get the class for the event protocol plugin using reflection
final String eventProtocolPluginClass = eventProtocolParameters.getEventProtocolPluginClass();
Object eventProtocolPluginObject = null;
eventProtocolPluginObject = Class.forName(eventProtocolPluginClass).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
final String errorMessage = "could not create an Apex event protocol converter for \"" + name
- + "\" for the protocol \"" + eventProtocolParameters.getLabel()
- + "\", specified event protocol converter plugin class \"" + eventProtocolPluginClass
- + "\" not found";
+ + "\" for the protocol \"" + eventProtocolParameters.getLabel()
+ + "\", specified event protocol converter plugin class \"" + eventProtocolPluginClass
+ + "\" not found";
LOGGER.error(errorMessage, e);
throw new ApexEventRuntimeException(errorMessage, e);
}
// Check the class is an event consumer
if (!(eventProtocolPluginObject instanceof ApexEventProtocolConverter)) {
final String errorMessage = "could not create an Apex event protocol converter for \"" + name
- + "\" for the protocol \"" + eventProtocolParameters.getLabel()
- + "\", specified event protocol converter plugin class \"" + eventProtocolPluginClass
- + "\" is not an instance of \"" + ApexEventProtocolConverter.class.getCanonicalName() + "\"";
+ + "\" for the protocol \"" + eventProtocolParameters.getLabel()
+ + "\", specified event protocol converter plugin class \"" + eventProtocolPluginClass
+ + "\" is not an instance of \"" + ApexEventProtocolConverter.class.getName() + "\"";
LOGGER.error(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
/**
* Decode a list of Apex events.
- *
+ *
* @param eventName the name of the incoming events
* @param jsonEventString the JSON representation of the event list
* @param decodedJsonObject The JSON list object
}
}
- /**
/**
* Serialise an Apex event to a JSON string field by field.
- *
+ *
* @param apexEvent the event to Serialise
* @return the Serialise event as JSON
* @throws ApexEventException exceptions on marshaling to JSON
if (!apexEvent.containsKey(fieldName)) {
if (!eventField.getOptional()) {
- final String errorMessage = ERROR_CODING + eventDefinition.getId() + " event to Json. "
- + "Field \"" + fieldName + "\" is missing, but is mandatory. Fields: " + apexEvent;
+ final String errorMessage = ERROR_CODING + eventDefinition.getId() + " event to Json. " + "Field \""
+ + fieldName + "\" is missing, but is mandatory. Fields: " + apexEvent;
LOGGER.debug(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
/**
* Serialise an Apex event to a JSON string as a single POJO.
- *
+ *
* @param apexEvent the event to Serialise
* @return the Serialise event as JSON
* @throws ApexEventException exceptions on marshaling to JSON
// Get the schema helper
final SchemaHelper fieldSchemaHelper = new SchemaHelperFactory()
.createSchemaHelper(pojoFieldDefinition.getKey(), pojoFieldDefinition.getSchema());
-
+
return fieldSchemaHelper.marshal2String(fieldValue);
}
/**
* Decode an Apex event field by field.
- *
+ *
* @param jsonObject the JSON representation of the event
* @param apexEvent the incoming event header
* @param eventDefinition the definition of the event from the model
/**
* Decode an Apex event as a single POJO.
- *
+ *
* @param jsonObject the JSON representation of the event
* @param apexEvent the incoming event header
* @param eventDefinition the definition of the event from the model
/**
* Determine the name field of the event header.
- *
+ *
* @param jsonObject the event in JSON format
* @param parameterEventName the configured event name from the parameters
* @return the event name to use on the event header
/**
* Determine the version field of the event header.
- *
+ *
* @param jsonObject the event in JSON format
* @return the event version
*/
/**
* Determine the name space field of the event header.
- *
+ *
* @param jsonObject the event in JSON format
* @param eventName the name of the event
* @param eventDefinition the definition of the event structure
/**
* Determine the source field of the event header.
- *
+ *
* @param jsonObject the event in JSON format
* @param eventDefinition the definition of the event structure
* @return the event version
/**
* Determine the target field of the event header.
- *
+ *
* @param jsonObject the event in JSON format
* @param eventDefinition the definition of the event structure
* @return the event version
} catch (final Exception e) {
// The element is not a string so throw an error
throw new ApexEventRuntimeException("field \"" + fieldName + "\" with type \""
- + jsonField.getClass().getCanonicalName() + "\" is not a string value", e);
+ + jsonField.getClass().getName() + "\" is not a string value", e);
}
// Is regular expression checking required
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
parameters = context.deserialize(parametersObject, Class.forName(parameterClassName));
} catch (JsonParseException | ClassNotFoundException e) {
final String returnMessage = "failed to deserialize the parameters for \"" + parametersLabel + "\" "
- + "to parameter class \"" + parameterClassName + "\"\n" + e.getClass().getCanonicalName()
- + ": " + e.getMessage();
+ + "to parameter class \"" + parameterClassName + "\"\n" + e.getClass().getName() + ": "
+ + e.getMessage();
LOGGER.error(returnMessage, e);
throw new ParameterRuntimeException(returnMessage, e);
}
@Override
public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
final Object event) {
- LOGGER.info("Sending Event: " + this.getClass().getCanonicalName() + ":" + this.name + " ... event ("
+ LOGGER.info("Sending Event: " + this.getClass().getName() + ":" + this.name + " ... event ("
+ eventName + ") : " + event);
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
private String name;
- public SuperDooperEventSubscriber() {}
+ public SuperDooperEventSubscriber() {
+ }
@Override
public void init(final String name, final EventHandlerParameters consumerParameters,
- final ApexEventReceiver apexEventReceiver) throws ApexEventException {
+ final ApexEventReceiver apexEventReceiver) throws ApexEventException {
this.name = name;
- LOGGER.info("Initialising Apex Consumer: " + this.getClass().getCanonicalName() + ":" + this.name);
+ LOGGER.info("Initialising Apex Consumer: " + this.getClass().getName() + ":" + this.name);
}
@Override
* {@inheritDoc}.
*/
@Override
- public void setPeeredReference(final EventHandlerPeeredMode peeredMode, final PeeredReference peeredReference) {}
+ public void setPeeredReference(final EventHandlerPeeredMode peeredMode, final PeeredReference peeredReference) {
+ }
@Override
public void start() {
}
@Override
- public void stop() {}
+ public void stop() {
+ }
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
*/
public static void main(final String[] args) throws ApexException {
if (args.length != 1) {
- LOGGER.error("usage: " + SampleDomainModelSaver.class.getCanonicalName() + " modelDirectory");
+ LOGGER.error("usage: " + SampleDomainModelSaver.class.getName() + " modelDirectory");
return;
}
// Save Java model
final AxPolicyModel javaPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVA");
- final ApexModelSaver<AxPolicyModel> javaModelSaver = new ApexModelSaver<>(AxPolicyModel.class,
- javaPolicyModel, args[0]);
+ final ApexModelSaver<AxPolicyModel> javaModelSaver = new ApexModelSaver<>(AxPolicyModel.class, javaPolicyModel,
+ args[0]);
javaModelSaver.apexModelWriteJson();
javaModelSaver.apexModelWriteXml();
// Save Javascript model
final AxPolicyModel javascriptPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVASCRIPT");
- final ApexModelSaver<AxPolicyModel> javascriptModelSaver = new ApexModelSaver<>(
- AxPolicyModel.class, javascriptPolicyModel, args[0]);
+ final ApexModelSaver<AxPolicyModel> javascriptModelSaver = new ApexModelSaver<>(AxPolicyModel.class,
+ javascriptPolicyModel, args[0]);
javascriptModelSaver.apexModelWriteJson();
javascriptModelSaver.apexModelWriteXml();
// Save MVEL model
final AxPolicyModel mvelPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("MVEL");
- final ApexModelSaver<AxPolicyModel> mvelModelSaver = new ApexModelSaver<>(AxPolicyModel.class,
- mvelPolicyModel, args[0]);
+ final ApexModelSaver<AxPolicyModel> mvelModelSaver = new ApexModelSaver<>(AxPolicyModel.class, mvelPolicyModel,
+ args[0]);
mvelModelSaver.apexModelWriteJson();
mvelModelSaver.apexModelWriteXml();
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
private void sendEventsToTopic(final Session jmsSession, final MessageProducer jmsProducer) throws JMSException {
- LOGGER.debug("{} : sending events to JMS server, event count {}", this.getClass().getCanonicalName(),
- eventCount);
+ LOGGER.debug("{} : sending events to JMS server, event count {}", this.getClass().getName(), eventCount);
for (int i = 0; i < eventCount; i++) {
ThreadUtilities.sleep(eventInterval);
jmsProducer.send(jmsMessage);
eventsSentCount++;
}
- LOGGER.debug("{} : completed, number of events sent", this.getClass().getCanonicalName(), eventsSentCount);
+ LOGGER.debug("{} : completed, number of events sent", this.getClass().getName(), eventsSentCount);
}
/**
* Shutdown.
*/
public void shutdown() {
- LOGGER.debug("{} : stopping", this.getClass().getCanonicalName());
+ LOGGER.debug("{} : stopping", this.getClass().getName());
stopFlag = true;
while (producerThread.isAlive()) {
ThreadUtilities.sleep(10);
}
- LOGGER.debug("{} : stopped", this.getClass().getCanonicalName());
+ LOGGER.debug("{} : stopped", this.getClass().getName());
}
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
((TextMessage) message).getText();
} else {
throw new ApexEventException("unknowm message \"" + message + "\" of type \""
- + message.getClass().getCanonicalName() + "\" received");
+ + message.getClass().getName() + "\" received");
}
eventsReceivedCount++;
} catch (final Exception e) {
throw new ApexEventRuntimeException("JMS event consumption failed", e);
}
- LOGGER.debug("{} : event reception completed", this.getClass().getCanonicalName());
+ LOGGER.debug("{} : event reception completed", this.getClass().getName());
}
/**
}
connection.close();
- LOGGER.debug("{} : stopped", this.getClass().getCanonicalName());
+ LOGGER.debug("{} : stopped", this.getClass().getName());
}
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
private void sendEventsToTopic(final Producer<String, String> producer) {
LOGGER.debug("{} : sending events to Kafka server, event count {}, xmlEvents {}",
- KafkaEventProducer.class.getCanonicalName(), eventCount, xmlEvents);
+ KafkaEventProducer.class.getName(), eventCount, xmlEvents);
for (int i = 0; i < eventCount; i++) {
- LOGGER.debug("{} : waiting {} milliseconds before sending next event",
- KafkaEventProducer.class.getCanonicalName(), eventInterval);
+ LOGGER.debug("{} : waiting {} milliseconds before sending next event", KafkaEventProducer.class.getName(),
+ eventInterval);
ThreadUtilities.sleep(eventInterval);
String eventString = null;
eventsSentCount++;
LOGGER.debug("****** Sent event No. {} ******", eventsSentCount);
}
- LOGGER.debug("{}: completed", KafkaEventProducer.class.getCanonicalName());
+ LOGGER.debug("{}: completed", KafkaEventProducer.class.getName());
}
/**
* Shutdown.
*/
public void shutdown() {
- LOGGER.debug("{} : stopping", KafkaEventProducer.class.getCanonicalName());
+ LOGGER.debug("{} : stopping", KafkaEventProducer.class.getName());
stopFlag = true;
ThreadUtilities.sleep(10);
}
- LOGGER.debug("{} : stopped", KafkaEventProducer.class.getCanonicalName());
+ LOGGER.debug("{} : stopped", KafkaEventProducer.class.getName());
}
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
@Override
public void run() {
- LOGGER.debug("{}: receiving events from Kafka server on topic {}",
- KafkaEventSubscriber.class.getCanonicalName(), topic);
+ LOGGER.debug("{}: receiving events from Kafka server on topic {}", KafkaEventSubscriber.class.getName(),
+ topic);
while (subscriberThread.isAlive() && !subscriberThread.isInterrupted()) {
try {
}
}
- LOGGER.debug("{}: event reception completed", KafkaEventSubscriber.class.getCanonicalName());
+ LOGGER.debug("{}: event reception completed", KafkaEventSubscriber.class.getName());
}
/**
}
consumer.close();
- LOGGER.debug("{} : stopped", KafkaEventSubscriber.class.getCanonicalName());
+ LOGGER.debug("{} : stopped", KafkaEventSubscriber.class.getName());
}
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
client = new WsStringMessageClient(host, port);
client.start(this);
- LOGGER.debug("{}: host {}, port {}, event count {}, xmlEvents {}",
- WebSocketEventProducerClient.class.getCanonicalName(), host, port, eventCount, xmlEvents);
+ LOGGER.debug("{}: host {}, port {}, event count {}, xmlEvents {}", WebSocketEventProducerClient.class.getName(),
+ host, port, eventCount, xmlEvents);
}
/**
*/
public void sendEvents() {
LOGGER.debug("{}: sending events on host {}, port {}, event count {}, xmlEvents {}",
- WebSocketEventProducerClient.class.getCanonicalName(), host, port, eventCount, xmlEvents);
+ WebSocketEventProducerClient.class.getName(), host, port, eventCount, xmlEvents);
for (int i = 0; i < eventCount; i++) {
LOGGER.debug("{}: waiting {} milliseconds before sending next event",
- WebSocketEventProducerClient.class.getCanonicalName(), eventInterval);
+ WebSocketEventProducerClient.class.getName(), eventInterval);
ThreadUtilities.sleep(eventInterval);
String eventString = null;
}
client.sendString(eventString);
eventsSentCount++;
- LOGGER.debug("{}: host {}, port {}, sent event {}", WebSocketEventProducerClient.class.getCanonicalName(),
- host, port, eventString);
+ LOGGER.debug("{}: host {}, port {}, sent event {}", WebSocketEventProducerClient.class.getName(), host,
+ port, eventString);
}
- LOGGER.debug("{}: completed", WebSocketEventProducerClient.class.getCanonicalName());
+ LOGGER.debug("{}: completed", WebSocketEventProducerClient.class.getName());
}
/**
*/
public void shutdown() {
client.stop();
- LOGGER.debug("{}: stopped", WebSocketEventProducerClient.class.getCanonicalName());
+ LOGGER.debug("{}: stopped", WebSocketEventProducerClient.class.getName());
}
/**
*/
@Override
public void receiveString(final String eventString) {
- LOGGER.debug("{}: host {}, port {}, received event {}", WebSocketEventProducerServer.class.getCanonicalName(),
- host, port, eventString);
+ LOGGER.debug("{}: host {}, port {}, received event {}", WebSocketEventProducerServer.class.getName(), host,
+ port, eventString);
}
/**
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
server = new WsStringMessageServer(port);
server.start(this);
- LOGGER.debug("{}: port {}, event count {}, xmlEvents {}", WebSocketEventProducerServer.class.getCanonicalName(),
- port, eventCount, xmlEvents);
+ LOGGER.debug("{}: port {}, event count {}, xmlEvents {}", WebSocketEventProducerServer.class.getName(), port,
+ eventCount, xmlEvents);
}
/**
*/
public void sendEvents() {
LOGGER.debug("{}: sending events on port {}, event count {}, xmlEvents {}",
- WebSocketEventProducerServer.class.getCanonicalName(), port, eventCount, xmlEvents);
+ WebSocketEventProducerServer.class.getName(), port, eventCount, xmlEvents);
for (int i = 0; i < eventCount; i++) {
LOGGER.debug("{}: waiting {} milliseconds before sending next event",
- WebSocketEventProducerServer.class.getCanonicalName(), eventInterval);
+ WebSocketEventProducerServer.class.getName(), eventInterval);
ThreadUtilities.sleep(eventInterval);
String eventString = null;
}
server.sendString(eventString);
eventsSentCount++;
- LOGGER.debug("{}: port {}, sent event {}", WebSocketEventProducerServer.class.getCanonicalName(), port,
- eventString);
+ LOGGER.debug("{}: port {}, sent event {}", WebSocketEventProducerServer.class.getName(), port, eventString);
}
- LOGGER.debug("{}: event sending completed", WebSocketEventProducerServer.class.getCanonicalName());
+ LOGGER.debug("{}: event sending completed", WebSocketEventProducerServer.class.getName());
}
/**
*/
public void shutdown() {
server.stop();
- LOGGER.debug("{}: stopped", WebSocketEventProducerServer.class.getCanonicalName());
+ LOGGER.debug("{}: stopped", WebSocketEventProducerServer.class.getName());
}
/**
*/
@Override
public void receiveString(final String eventString) {
- LOGGER.debug("{}: port {}, received event {}", WebSocketEventProducerServer.class.getCanonicalName(), port,
- eventString);
+ LOGGER.debug("{}: port {}, received event {}", WebSocketEventProducerServer.class.getName(), port, eventString);
}
/**
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
@Override
public void receiveString(final String eventString) {
- LOGGER.debug("{}: port {}, received event {}", WebSocketEventSubscriberClient.class.getCanonicalName(), port,
+ LOGGER.debug("{}: port {}, received event {}", WebSocketEventSubscriberClient.class.getName(), port,
eventString);
eventsReceivedCount++;
}
*/
public void shutdown() {
client.stop();
- LOGGER.debug("{}: stopped", WebSocketEventSubscriberServer.class.getCanonicalName());
+ LOGGER.debug("{}: stopped", WebSocketEventSubscriberServer.class.getName());
}
/**
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
server = new WsStringMessageServer(port);
server.start(this);
- LOGGER.debug("{}: port {}, waiting for events", WebSocketEventSubscriberServer.class.getCanonicalName(), port);
+ LOGGER.debug("{}: port {}, waiting for events", WebSocketEventSubscriberServer.class.getName(), port);
}
/**
*/
@Override
public void receiveString(final String eventString) {
- LOGGER.debug("{}: port {}, received event {}", WebSocketEventSubscriberServer.class.getCanonicalName(), port,
+ LOGGER.debug("{}: port {}, received event {}", WebSocketEventSubscriberServer.class.getName(), port,
eventString);
eventsReceivedCount++;
}
*/
public void shutdown() {
server.stop();
- LOGGER.debug("{} : stopped", WebSocketEventSubscriberServer.class.getCanonicalName());
+ LOGGER.debug("{} : stopped", WebSocketEventSubscriberServer.class.getName());
}
/**
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@Override
public void init(final String consumerName, final EventHandlerParameters consumerParameters,
- final ApexEventReceiver incomingEventReceiver) throws ApexEventException {
+ final ApexEventReceiver incomingEventReceiver) throws ApexEventException {
this.eventReceiver = incomingEventReceiver;
this.name = consumerName;
-
// Check and get the properties
if (!(consumerParameters.getCarrierTechnologyParameters() instanceof DummyCarrierTechnologyParameters)) {
String message = "specified consumer properties of type \""
- + consumerParameters.getCarrierTechnologyParameters().getClass().getCanonicalName()
- + "\" are not applicable to a dummy consumer";
+ + consumerParameters.getCarrierTechnologyParameters().getClass().getName()
+ + "\" are not applicable to a dummy consumer";
LOGGER.warn(message);
throw new ApexEventException(message);
}
- dummyConsumerProperties =
- (DummyCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
+ dummyConsumerProperties = (DummyCarrierTechnologyParameters) consumerParameters
+ .getCarrierTechnologyParameters();
}
@Override
}
@Override
- public void stop() {}
+ public void stop() {
+ }
private class RunTestEventSender implements Runnable {
@Override
executionProperties.load(new FileInputStream(new File(dummyConsumerProperties.getPropertyFileName())));
} catch (IOException e1) {
String message = "reading of executor properties for testing failed from file: "
- + dummyConsumerProperties.getPropertyFileName();
+ + dummyConsumerProperties.getPropertyFileName();
LOGGER.warn(message);
throw new ApexEventRuntimeException(message);
}