Skip to content

Commit

Permalink
drop vector from Project
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 Jan 25, 2024
1 parent 3a3cb27 commit 351fc6f
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 63 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 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 Down Expand Up @@ -43,46 +43,32 @@ public ReadOnlyClassAccessingTestCase() {
/**
* Compares a Hashtable and a vector for equality.
*/
protected boolean areEqual(Set ht, Vector v1) {
protected boolean areEqual(Set<?> ht, List<?> v1) {
if (v1.size() != ht.size()) {
return false;
}
for (Enumeration enumtr = v1.elements(); enumtr.hasMoreElements();) {
if (!ht.contains(enumtr.nextElement())) {
return false;
}
}
return true;
return ht.containsAll(v1);
}

/**
* Compares two vectors for equality.
*/
protected boolean areEqual(Vector v1, Vector v2) {
protected boolean areEqual(List<?> v1, List<?> v2) {
if (v1.size() != v2.size()) {
return false;
}
for (Enumeration enumtr = v1.elements(); enumtr.hasMoreElements();) {
if (!v2.contains(enumtr.nextElement())) {
return false;
}
}
for (Enumeration enumtr = v2.elements(); enumtr.hasMoreElements();) {
if (!v1.contains(enumtr.nextElement())) {
return false;
}
}
return true;

return v1.containsAll(v2);
}

@Override
public void reset() {
getSession().getProject().setDefaultReadOnlyClasses(new Vector());
getSession().getProject().setDefaultReadOnlyClasses(new ArrayList<>());
}

@Override
protected void setup() {
getSession().getProject().setDefaultReadOnlyClasses(new Vector());
getSession().getProject().setDefaultReadOnlyClasses(new ArrayList<>());

}

Expand Down Expand Up @@ -147,9 +133,9 @@ protected void test() {
}

// Check that the default read-only classes work.
Vector someClasses = new Vector();
someClasses.addElement(Country.class);
someClasses.addElement(Address.class);
List<Class<?>> someClasses = new ArrayList<>();
someClasses.add(Country.class);
someClasses.add(Address.class);
getSession().getProject().setDefaultReadOnlyClasses(someClasses);
UnitOfWork uow3 = getSession().acquireUnitOfWork();
if (!areEqual(uow3.getReadOnlyClasses(), someClasses)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 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 Down Expand Up @@ -40,7 +40,7 @@ public ReadOnlyClassAggregateTestCase() {

@Override
public void reset() {
getSession().getProject().setDefaultReadOnlyClasses(new Vector());
getSession().getProject().setDefaultReadOnlyClasses(new ArrayList<>());
rollbackTransaction();
getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ReadOnlyClassDeepMergeCloneTest() {

@Override
public void reset() {
getSession().getProject().setDefaultReadOnlyClasses(new Vector());
getSession().getProject().setDefaultReadOnlyClasses(new ArrayList<>());
getSession().getIdentityMapAccessor().initializeIdentityMaps();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 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 Down Expand Up @@ -42,7 +42,7 @@ public ReadOnlyClassDeleteTestCase() {

@Override
public void reset() {
getSession().getProject().setDefaultReadOnlyClasses(new Vector());
getSession().getProject().setDefaultReadOnlyClasses(new ArrayList<>());
rollbackTransaction();
getSession().getIdentityMapAccessor().initializeIdentityMaps();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 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 Down Expand Up @@ -43,7 +43,7 @@ public ReadOnlyClassInsertTestCase() {

@Override
public void reset() {
getSession().getProject().setDefaultReadOnlyClasses(new Vector());
getSession().getProject().setDefaultReadOnlyClasses(new ArrayList<>());

rollbackTransaction();
getSession().getIdentityMapAccessor().initializeIdentityMaps();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 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 Down Expand Up @@ -41,7 +41,7 @@ public ReadOnlyClassUpdateTestCase() {

@Override
public void reset() {
getSession().getProject().setDefaultReadOnlyClasses(new Vector());
getSession().getProject().setDefaultReadOnlyClasses(new ArrayList<>());

rollbackTransaction();
getSession().getIdentityMapAccessor().initializeIdentityMaps();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 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 Down Expand Up @@ -48,7 +48,7 @@ protected void setup() {

@Override
public void reset() {
getSession().getProject().setDefaultReadOnlyClasses(new Vector());
getSession().getProject().setDefaultReadOnlyClasses(new ArrayList<>());
rollbackTransaction();
getSession().getIdentityMapAccessor().initializeIdentityMaps();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 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 Down Expand Up @@ -264,12 +264,12 @@ public ClassDescriptor getDescriptorForAlias(Class<?> domainClass) {
* Return the read-only classes
*/
@Override
public Vector getDefaultReadOnlyClasses() {
public List<Class<?>> getDefaultReadOnlyClasses() {
Transporter transporter = getRemoteSessionController().getDefaultReadOnlyClasses();
if (!transporter.wasOperationSuccessful()) {
throw transporter.getException();
} else {
return (Vector)transporter.getObject();
return (List<Class<?>>)transporter.getObject();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 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 @@ -18,6 +18,7 @@
import java.rmi.server.ObjID;
import java.util.Enumeration;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Vector;

import org.eclipse.persistence.descriptors.ClassDescriptor;
Expand Down Expand Up @@ -280,13 +281,13 @@ public RemoteScrollableCursor cursorSelectObjects(ScrollableCursorPolicy policy,
* Return the read-only classes
*/
@Override
public Vector getDefaultReadOnlyClasses() {
public List<Class<?>> getDefaultReadOnlyClasses() {
try {
Transporter transporter = getRemoteSessionController().getDefaultReadOnlyClasses();
if (!transporter.wasOperationSuccessful()) {
throw transporter.getException();
} else {
return (Vector)transporter.getObject();
return (List<Class<?>>)transporter.getObject();
}
} catch (RemoteException exception) {
throw CommunicationException.errorInInvocation(exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1159,11 +1159,11 @@ public Object copyInternal(Object originalObject, CopyGroup copyGroup) {
/**
* INTERNAL:
* Copy the read only classes from the unit of work
*
* <p>
* Added Nov 8, 2000 JED for Patch 2.5.1.8
* Ref: Prs 24502
*/
public Vector copyReadOnlyClasses() {
public List<Class<?>> copyReadOnlyClasses() {
return getDefaultReadOnlyClasses();
}

Expand Down Expand Up @@ -2351,7 +2351,7 @@ public CommitManager getCommitManager() {
*
* @see org.eclipse.persistence.sessions.Project#setDefaultReadOnlyClasses(Collection)
*/
public Vector getDefaultReadOnlyClasses() {
public List<Class<?>> getDefaultReadOnlyClasses() {
//Bug#3911318 All brokered sessions share the same DefaultReadOnlyClasses.
if (hasBroker()) {
return getBroker().getDefaultReadOnlyClasses();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ public void releaseWriteLocks() {
*/
// Added Nov 8, 2000 JED for Patch 2.5.1.8, Ref: Prs 24502
@Override
public Vector copyReadOnlyClasses() {
public List<Class<?>> copyReadOnlyClasses() {
return new Vector(getReadOnlyClasses());
}

Expand Down Expand Up @@ -2336,7 +2336,7 @@ public UnitOfWorkImpl getContainerUnitOfWork() {
* @see org.eclipse.persistence.sessions.Project#setDefaultReadOnlyClasses(Collection)
*/
@Override
public Vector getDefaultReadOnlyClasses() {
public List<Class<?>> getDefaultReadOnlyClasses() {
return this.parent.getDefaultReadOnlyClasses();
}

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 Down Expand Up @@ -124,7 +124,7 @@ public boolean isConnected() {
* INTERNAL:
* Get the read-only classes
*/
public abstract Vector getDefaultReadOnlyClasses();
public abstract List<Class<?>> getDefaultReadOnlyClasses();

/**
* Get descriptor
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 Down Expand Up @@ -47,7 +47,6 @@
import org.eclipse.persistence.descriptors.MultitenantPolicy;
import org.eclipse.persistence.descriptors.partitioning.PartitioningPolicy;
import org.eclipse.persistence.internal.helper.ConcurrentFixedCache;
import org.eclipse.persistence.internal.helper.NonSynchronizedVector;
import org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap;
import org.eclipse.persistence.internal.identitymaps.IdentityMap;
import org.eclipse.persistence.internal.sessions.AbstractSession;
Expand All @@ -67,7 +66,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Vector;

/**
* <b>Purpose</b>: Maintain all of the EclipseLink configuration information for a system.
Expand All @@ -91,7 +89,7 @@ public class Project extends CoreProject<ClassDescriptor, Login, DatabaseSession
protected MultitenantPolicy multitenantPolicy;

/** Holds the default set of read-only classes that apply to each UnitOfWork. */
protected Vector<Class<?>> defaultReadOnlyClasses;
protected List<Class<?>> defaultReadOnlyClasses;

/** Cache the EJBQL descriptor aliases. */
protected Map<String, ClassDescriptor> aliasDescriptors;
Expand Down Expand Up @@ -212,7 +210,7 @@ public class Project extends CoreProject<ClassDescriptor, Login, DatabaseSession
public Project() {
this.name = "";
this.descriptors = new HashMap<>();
this.defaultReadOnlyClasses = NonSynchronizedVector.newInstance();
this.defaultReadOnlyClasses = new ArrayList<>();
this.orderedDescriptors = new ArrayList<>();
this.hasIsolatedClasses = false;
this.hasGenericHistorySupport = false;
Expand Down Expand Up @@ -409,7 +407,7 @@ public void setVPDLastIdentifierClassName(String vpdLastIdentifierClassName) {
* Add the read-only class which apply to each UnitOfWork created by default.
*/
public void addDefaultReadOnlyClass(Class<?> readOnlyClass) {
getDefaultReadOnlyClasses().addElement(readOnlyClass);
getDefaultReadOnlyClasses().add(readOnlyClass);
}

/**
Expand Down Expand Up @@ -697,7 +695,7 @@ public Server createServerSession(ConnectionPolicy defaultConnectionPolicy) {
* PUBLIC:
* Returns the default set of read-only classes.
*/
public Vector getDefaultReadOnlyClasses() {
public List<Class<?>> getDefaultReadOnlyClasses() {
return defaultReadOnlyClasses;
}

Expand Down Expand Up @@ -907,8 +905,8 @@ public boolean hasGenericHistorySupport() {
* PUBLIC:
* Set the read-only classes which apply to each UnitOfWork create by default.
*/
public void setDefaultReadOnlyClasses(Collection newValue) {
this.defaultReadOnlyClasses = new Vector(newValue);
public void setDefaultReadOnlyClasses(Collection<Class<?>> newValue) {
this.defaultReadOnlyClasses = new ArrayList<>(newValue);
}

/**
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 Down Expand Up @@ -36,6 +36,7 @@
import org.eclipse.persistence.sessions.Login;
import org.eclipse.persistence.sessions.SessionProfiler;

import java.util.List;
import java.util.Map;
import java.util.Vector;

Expand Down Expand Up @@ -202,10 +203,11 @@ public Object executeQuery(DatabaseQuery query, AbstractRecord row) {
* CR#2751
* Returns the set of read-only classes for the receiver. These class come from the
* Remote connection
*
* @return A Vector containing the Java Classes that are currently read-only.
*/
@Override
public Vector getDefaultReadOnlyClasses() {
public List<Class<?>> getDefaultReadOnlyClasses() {
if (this.isMetadataRemote && !this.hasDefaultReadOnlyClasses) {
getProject().setDefaultReadOnlyClasses(getRemoteConnection().getDefaultReadOnlyClasses());
this.hasDefaultReadOnlyClasses = true;
Expand Down

0 comments on commit 351fc6f

Please sign in to comment.