aboutsummaryrefslogtreecommitdiffstats
path: root/feature-session-persistence/src/main/java/org
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-08-05 14:53:19 -0400
committerJim Hahn <jrh3@att.com>2021-08-05 15:25:14 -0400
commitda1b7d9f04453e94fb77ebe4213f456a0be63fc2 (patch)
treee59daec0050c7ce88c07f1d7f97168aa849128a7 /feature-session-persistence/src/main/java/org
parent1744dac574fb771301027be74c9257eb070125f7 (diff)
Use lombok in drools-pdp #2
Updated feature-session-persistence thru drools-domains. Issue-ID: POLICY-3397 Change-Id: I0b1c6da8b2301c00dd792675e8cf1f49888edb9f Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-session-persistence/src/main/java/org')
-rw-r--r--feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsPersistenceProperties.java9
-rw-r--r--feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java72
-rw-r--r--feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/EntityMgrTrans.java27
-rw-r--r--feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java8
-rw-r--r--feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java6
5 files changed, 27 insertions, 95 deletions
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsPersistenceProperties.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsPersistenceProperties.java
index 93440dad..ab85864f 100644
--- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsPersistenceProperties.java
+++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsPersistenceProperties.java
@@ -20,9 +20,12 @@
package org.onap.policy.drools.persistence;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.eclipse.persistence.config.PersistenceUnitProperties;
-public class DroolsPersistenceProperties {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class DroolsPersistenceProperties {
/*
* feature-session-persistence.properties parameter key values
*/
@@ -32,8 +35,4 @@ public class DroolsPersistenceProperties {
public static final String DB_PWD = PersistenceUnitProperties.JDBC_PASSWORD;
public static final String DB_SESSIONINFO_TIMEOUT = "persistence.sessioninfo.timeout";
public static final String JTA_OBJECTSTORE_DIR = "persistence.objectstore.dir";
-
- private DroolsPersistenceProperties() {
- super();
- }
}
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java
index ec9e5b76..9ac68567 100644
--- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java
+++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* feature-session-persistence
* ================================================================================
- * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018, 2020-2021 AT&T Intellectual Property. 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.
@@ -29,14 +29,23 @@ import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
@Entity
+@Getter
+@Setter
+@EqualsAndHashCode(onlyExplicitlyIncluded = true)
+@NoArgsConstructor
public class DroolsSessionEntity implements Serializable, DroolsSession {
private static final long serialVersionUID = -5495057038819948709L;
@Id
@Column(name = "sessionName", nullable = false)
+ @EqualsAndHashCode.Include
private String sessionName = "-1";
@Column(name = "sessionId", nullable = false)
@@ -50,9 +59,6 @@ public class DroolsSessionEntity implements Serializable, DroolsSession {
@Column(name = "updatedDate", nullable = false)
private Date updatedDate;
- public DroolsSessionEntity() {
- }
-
public DroolsSessionEntity(String sessionName, long sessionId) {
this.sessionName = sessionName;
this.sessionId = sessionId;
@@ -70,64 +76,6 @@ public class DroolsSessionEntity implements Serializable, DroolsSession {
}
@Override
- public String getSessionName() {
- return sessionName;
- }
-
- @Override
- public void setSessionName(String sessionName) {
- this.sessionName = sessionName;
- }
-
- @Override
- public long getSessionId() {
- return sessionId;
- }
-
- @Override
- public void setSessionId(long sessionId) {
- this.sessionId = sessionId;
- }
-
- @Override
- public Date getCreatedDate() {
- return createdDate;
- }
-
- @Override
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- @Override
- public Date getUpdatedDate() {
- return updatedDate;
- }
-
- @Override
- public void setUpdatedDate(Date updatedDate) {
- this.updatedDate = updatedDate;
- }
-
- @Override
- public boolean equals(Object other) {
- if (other instanceof DroolsSession) {
- DroolsSession session = (DroolsSession) other;
- return this.getSessionName().equals(session.getSessionName());
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + getSessionName().hashCode();
- return result;
- }
-
- @Override
public String toString() {
return "{name=" + getSessionName() + ", id=" + getSessionId() + "}";
}
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/EntityMgrTrans.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/EntityMgrTrans.java
index 988cd9c2..7103c47c 100644
--- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/EntityMgrTrans.java
+++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/EntityMgrTrans.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* feature-session-persistence
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. 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.
@@ -28,6 +28,9 @@ import javax.transaction.RollbackException;
import javax.transaction.Status;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.common.utils.jpa.EntityMgrCloser;
/**
@@ -40,6 +43,8 @@ public class EntityMgrTrans extends EntityMgrCloser {
/**
* Transaction to be rolled back.
*/
+ @Getter(AccessLevel.PROTECTED)
+ @Setter(AccessLevel.PROTECTED)
private static UserTransaction userTrans = com.arjuna.ats.jta.UserTransaction.userTransaction();
/**
@@ -71,24 +76,6 @@ public class EntityMgrTrans extends EntityMgrCloser {
}
/**
- * Gets the user transaction. For use by junit tests.
- *
- * @return the user transaction
- */
- protected static UserTransaction getUserTrans() {
- return userTrans;
- }
-
- /**
- * Sets the user transaction. For use by junit tests.
- *
- * @param userTrans the new user transaction
- */
- protected static void setUserTrans(UserTransaction userTrans) {
- EntityMgrTrans.userTrans = userTrans;
- }
-
- /**
* Commits the transaction.
*/
public void commit() {
@@ -146,7 +133,7 @@ public class EntityMgrTrans extends EntityMgrCloser {
/**
* Constructor.
- *
+ *
* @param ex exception to be wrapped
*/
public EntityMgrException(Exception ex) {
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java
index d682e563..8fcbc795 100644
--- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java
+++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* feature-session-persistence
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. 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.
@@ -22,19 +22,17 @@ package org.onap.policy.drools.persistence;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
+import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@AllArgsConstructor
public class JpaDroolsSessionConnector implements DroolsSessionConnector {
private static Logger logger = LoggerFactory.getLogger(JpaDroolsSessionConnector.class);
private final EntityManagerFactory emf;
- public JpaDroolsSessionConnector(EntityManagerFactory emf) {
- this.emf = emf;
- }
-
@Override
public DroolsSession get(String sessName) {
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java
index 3c3e5008..a929c712 100644
--- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java
+++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java
@@ -151,7 +151,7 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine
@Override
public PolicySession.ThreadModel selectThreadModel(PolicySession session) {
- var policyContainer = session.getPolicyContainer();
+ var policyContainer = session.getContainer();
if (isPersistenceEnabled(policyContainer, session.getName())) {
return new PersistentThreadModel(session, getProperties(policyContainer));
}
@@ -165,7 +165,7 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine
public void disposeKieSession(PolicySession policySession) {
ContainerAdjunct contAdj =
- (ContainerAdjunct) policySession.getPolicyContainer().getAdjunct(this);
+ (ContainerAdjunct) policySession.getContainer().getAdjunct(this);
if (contAdj != null) {
contAdj.disposeKieSession(policySession.getName());
}
@@ -178,7 +178,7 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine
public void destroyKieSession(PolicySession policySession) {
ContainerAdjunct contAdj =
- (ContainerAdjunct) policySession.getPolicyContainer().getAdjunct(this);
+ (ContainerAdjunct) policySession.getContainer().getAdjunct(this);
if (contAdj != null) {
contAdj.destroyKieSession(policySession.getName());
}