Skip to content

Commit

Permalink
remove unused internal classes, minor cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
  • Loading branch information
lukasj committed Mar 12, 2024
1 parent 1f9a377 commit c5aed35
Show file tree
Hide file tree
Showing 21 changed files with 168 additions and 311 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ public String getProcedureAsString() {
/**
* Some platforms have an option list
* Only to be used for stored procedure creation.
*
*
* @see org.eclipse.persistence.tools.schemaframework.StoredProcedureDefinition
*/
public String getProcedureOptionList() {
Expand Down Expand Up @@ -1359,7 +1359,7 @@ public String getSelectForUpdateString() {
/**
* Platforms that support the WAIT option should override this method.
* By default the wait timeout is ignored.
*
*
* @see DatabasePlatform#supportsWaitForUpdate()
*/
public String getSelectForUpdateWaitString(Integer waitTimeout) {
Expand Down Expand Up @@ -1482,14 +1482,14 @@ public boolean isLobCompatibleWithDistinct() {
}

/**
* Returns the attribute containing the results from the batch execution
* Returns the attribute containing the results from the batch execution
*/
public int[] getExecuteBatchRowCounts() {
return executeBatchRowCounts;
}

/**
* Sets the attribute containing the results from the batch execution
* Sets the attribute containing the results from the batch execution
*/
public void setExecuteBatchRowCounts(int[] rowCounts) {
executeBatchRowCounts = rowCounts;
Expand Down Expand Up @@ -1602,7 +1602,7 @@ public int printValuelist(Collection<?> theObjects, DatabaseCall call, Writer wr
/**
* This method is used to register output parameter on CallableStatements for Stored Procedures
* as each database seems to have a different method.
*
*
* @see java.sql.CallableStatement#registerOutParameter(int parameterIndex, int sqlType)
*/
public void registerOutputParameter(CallableStatement statement, int parameterIndex, int sqlType) throws SQLException {
Expand All @@ -1612,7 +1612,7 @@ public void registerOutputParameter(CallableStatement statement, int parameterIn
/**
* This method is used to register output parameter on CallableStatements for Stored Procedures
* as each database seems to have a different method.
*
*
* @see java.sql.CallableStatement#registerOutParameter(int parameterIndex, int sqlType, String typeName)
*/
public void registerOutputParameter(CallableStatement statement, int parameterIndex, int sqlType, String typeName) throws SQLException {
Expand All @@ -1622,7 +1622,7 @@ public void registerOutputParameter(CallableStatement statement, int parameterIn
/**
* This method is used to register output parameter on CallableStatements for Stored Procedures
* as each database seems to have a different method.
*
*
* @see java.sql.CallableStatement#registerOutParameter(String parameterName, int sqlType)
*/
public void registerOutputParameter(CallableStatement statement, String parameterName, int sqlType) throws SQLException {
Expand All @@ -1632,7 +1632,7 @@ public void registerOutputParameter(CallableStatement statement, String paramete
/**
* This method is used to register output parameter on CallableStatements for Stored Procedures
* as each database seems to have a different method.
*
*
* @see java.sql.CallableStatement#registerOutParameter(String parameterName, int sqlType, String typeName)
*/
public void registerOutputParameter(CallableStatement statement, String parameterName, int sqlType, String typeName) throws SQLException {
Expand Down Expand Up @@ -2247,7 +2247,7 @@ public boolean supportsVPD() {
/**
* INTERNAL:
* Indicates whether the platform supports timeouts on For Update
*
*
* @see DatabasePlatform#getSelectForUpdateWaitString(Integer waitTimeout)
*/
public boolean supportsWaitForUpdate() {
Expand Down Expand Up @@ -2383,6 +2383,7 @@ public void setPingSQL(String pingSQL) {
public void setParameterValueInDatabaseCall(Object parameter,
PreparedStatement statement, int index, AbstractSession session)
throws SQLException {

// Process common types first.
if (parameter instanceof String) {
// Check for stream binding of large strings.
Expand Down Expand Up @@ -3539,7 +3540,7 @@ public void setShouldBindLiterals(boolean shouldBindLiterals) {
* Some databases have issues with using parameters on certain functions and relations.
* This allows statements to disable binding only in these cases.
* <p>
* Alternatively, DatabasePlatforms can override specific ExpressionOperators and add them
* Alternatively, DatabasePlatforms can override specific ExpressionOperators and add them
* to the platform specific operators. See {@link DatasourcePlatform#initializePlatformOperators()}
*/
public boolean isDynamicSQLRequiredForFunctions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4353,7 +4353,7 @@ protected void loadBatchReadAttributes(ClassDescriptor concreteDescriptor, Objec
}
AbstractSession session = query.getExecutionSession();
mapping.readFromRowIntoObject(databaseRow, joinManager, sourceObject, cacheKey, query, query.getExecutionSession(),isTargetProtected);
session.getIdentityMapAccessorInstance().getIdentityMap(concreteDescriptor).lazyRelationshipLoaded(sourceObject, (ValueHolderInterface) ((ForeignReferenceMapping)mapping).getIndirectionPolicy().getOriginalValueHolder(attributeValue, session), (ForeignReferenceMapping)mapping);
session.getIdentityMapAccessorInstance().getIdentityMap(concreteDescriptor).lazyRelationshipLoaded(sourceObject, (ValueHolderInterface<?>) ((ForeignReferenceMapping)mapping).getIndirectionPolicy().getOriginalValueHolder(attributeValue, session), (ForeignReferenceMapping)mapping);
}
}
}
Expand Down Expand Up @@ -4399,7 +4399,7 @@ protected void loadJoinedAttributes(ClassDescriptor concreteDescriptor, Object s
}
AbstractSession session = query.getExecutionSession();
mapping.readFromRowIntoObject(databaseRow, joinManager, intermediateValue, cacheKey, query, query.getExecutionSession(), isTargetProtected);
session.getIdentityMapAccessorInstance().getIdentityMap(concreteDescriptor).lazyRelationshipLoaded(intermediateValue, (ValueHolderInterface) ((ForeignReferenceMapping)mapping).getIndirectionPolicy().getOriginalValueHolder(attributeValue, session), (ForeignReferenceMapping)mapping);
session.getIdentityMapAccessorInstance().getIdentityMap(concreteDescriptor).lazyRelationshipLoaded(intermediateValue, (ValueHolderInterface<?>) ((ForeignReferenceMapping)mapping).getIndirectionPolicy().getOriginalValueHolder(attributeValue, session), (ForeignReferenceMapping)mapping);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -22,6 +22,7 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
* <p><b>Purpose</b>: Caches objects, and allows their retrieval by their primary key.
Expand Down Expand Up @@ -222,16 +223,16 @@ public CacheKey acquireReadLockOnCacheKeyNoWait(Object primaryKey) {
* Used to print all the locks in the identity map.
*/
@Override
public abstract void collectLocks(HashMap threadList);
public abstract void collectLocks(Map<Thread, Set<CacheKey>> threadList);

/**
* Clone the map and all of the CacheKeys.
* This is used by UnitOfWork commitAndResumeOnFailure to avoid corrupting the cache during a failed commit.
*/
@Override
public Object clone() {
public IdentityMap clone() {
try {
return super.clone();
return (IdentityMap) super.clone();
} catch (CloneNotSupportedException exception) {
throw new InternalError(exception.toString());
}
Expand All @@ -258,7 +259,7 @@ public CacheKey createCacheKey(Object primaryKey, Object object, Object writeLoc
* Allow for the cache to be iterated on.
*/
@Override
public abstract Enumeration elements();
public abstract Enumeration<Object> elements();

/**
* Return the object cached in the identity map or null if it could not be found.
Expand Down Expand Up @@ -413,7 +414,7 @@ public Object getWriteLockValue(Object primaryKey) {
* Allow for the CacheKeys to be iterated on.
*/
@Override
public abstract Enumeration keys();
public abstract Enumeration<CacheKey> keys();

/**
* Store the object in the cache at its primary key.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -24,13 +24,11 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
* <p><b>Purpose</b>: A FullIdentityMap holds all objects stored within it for the life of the application.
Expand All @@ -53,17 +51,17 @@ public FullIdentityMap() {

public FullIdentityMap(int size, ClassDescriptor descriptor, AbstractSession session, boolean isolated) {
super(size, descriptor, session, isolated);
this.cacheKeys = new ConcurrentHashMap(size);
this.cacheKeys = new ConcurrentHashMap<>(size);
}

/**
* INTERNAL:
* Clones itself.
*/
@Override
public Object clone() {
public IdentityMap clone() {
FullIdentityMap clone = (FullIdentityMap)super.clone();
clone.setCacheKeys(new ConcurrentHashMap(this.cacheKeys.size()));
clone.setCacheKeys(new ConcurrentHashMap<>(this.cacheKeys.size()));

for (Iterator<CacheKey> cacheKeysIterator = this.cacheKeys.values().iterator(); cacheKeysIterator.hasNext();) {
CacheKey key = (CacheKey) cacheKeysIterator.next().clone();
Expand All @@ -78,17 +76,13 @@ public Object clone() {
* Used to print all the Locks in every identity map in this session.
*/
@Override
public void collectLocks(HashMap threadList) {
public void collectLocks(Map<Thread, Set<CacheKey>> threadList) {
Iterator<CacheKey> cacheKeyIterator = this.cacheKeys.values().iterator();
while (cacheKeyIterator.hasNext()) {
CacheKey cacheKey = cacheKeyIterator.next();
if (cacheKey.isAcquired()) {
Thread activeThread = cacheKey.getActiveThread();
Set set = (Set)threadList.get(activeThread);
if (set == null) {
set = new HashSet();
threadList.put(activeThread, set);
}
Set<CacheKey> set = threadList.computeIfAbsent(activeThread, k -> new HashSet<>());
set.add(cacheKey);
}
}
Expand All @@ -100,7 +94,7 @@ public void collectLocks(HashMap threadList) {
* @return {@link Enumeration} of {@link CacheKey#getObject()} instances.
*/
@Override
public Enumeration elements() {
public Enumeration<Object> elements() {
return new IdentityMapEnumeration(this.getCacheKeys().values());
}

Expand All @@ -121,7 +115,7 @@ public CacheKey getCacheKey(Object searchKey, boolean forMerge) {
@Override
protected CacheKey putCacheKeyIfAbsent(CacheKey searchKey) {
searchKey.setOwningMap(this);
return (CacheKey)((ConcurrentMap)this.cacheKeys).putIfAbsent(searchKey.getKey(), searchKey);
return this.cacheKeys.putIfAbsent(searchKey.getKey(), searchKey);
}

/**
Expand Down Expand Up @@ -196,15 +190,15 @@ public Enumeration<CacheKey> keys(boolean checkReadLocks) {
*/
@Override
public Enumeration<CacheKey> cloneKeys() {
return new IdentityMapKeyEnumeration(new ArrayList(this.getCacheKeys().values()), true);
return new IdentityMapKeyEnumeration(new ArrayList<>(this.getCacheKeys().values()), true);
}

/**
* Notify the cache that a lazy relationship has been triggered in the object
* and the cache may need to be updated
*/
@Override
public void lazyRelationshipLoaded(Object object, ValueHolderInterface valueHolder, ForeignReferenceMapping mapping){
public void lazyRelationshipLoaded(Object object, ValueHolderInterface<?> valueHolder, ForeignReferenceMapping mapping){
//NO-OP
}

Expand Down
Loading

0 comments on commit c5aed35

Please sign in to comment.