summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-02-12 02:01:52 (EST)
committerEike Stepper2008-02-12 02:01:52 (EST)
commit88a865a511dad813ca3df2adb4df6bbee65e81e9 (patch)
tree9fcf88db3a2c41fd9eec17238e70f84ba4b5e616
parent9978960de6d97702457d326046cffbf94d299201 (diff)
downloadcdo-88a865a511dad813ca3df2adb4df6bbee65e81e9.zip
cdo-88a865a511dad813ca3df2adb4df6bbee65e81e9.tar.gz
cdo-88a865a511dad813ca3df2adb4df6bbee65e81e9.tar.bz2
[217117] Develop a HibernateStore
https://bugs.eclipse.org/bugs/show_bug.cgi?id=217117 [217236] Provide a way to query if a specific resource (path) exists https://bugs.eclipse.org/bugs/show_bug.cgi?id=217236
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java26
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourceManager.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java24
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IResourceManager.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java59
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java11
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java13
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java52
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java39
14 files changed, 197 insertions, 59 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java
index 7a445e8..5793bf5 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java
@@ -12,10 +12,13 @@
package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.model.resource.CDOPathFeature;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IView;
+import org.eclipse.net4j.util.ObjectUtil;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -132,6 +135,29 @@ public class MEMStore extends LongIDStore
return false;
}
+ public synchronized CDORevision getResource(String path)
+ {
+ CDOPathFeature pathFeature = getRepository().getPackageManager().getCDOResourcePackage().getCDOResourceClass()
+ .getCDOPathFeature();
+ for (List<CDORevision> list : revisions.values())
+ {
+ if (!list.isEmpty())
+ {
+ CDORevision revision = list.get(0);
+ if (revision.isResource())
+ {
+ String p = (String)revision.getData().get(pathFeature, 0);
+ if (ObjectUtil.equals(p, path))
+ {
+ return revision;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
public boolean hasBranchingSupport()
{
return false;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
index f76fba0..02abd52 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
@@ -120,7 +120,8 @@ public class MEMStoreAccessor extends StoreAccessor implements IStoreReader, ISt
public CDOID readResourceID(String path)
{
- throw new UnsupportedOperationException();
+ CDORevision revision = getStore().getResource(path);
+ return revision == null ? null : revision.getID();
}
public String readResourcePath(CDOID id)
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourceManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourceManager.java
index 3e09004..4776a1b 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourceManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourceManager.java
@@ -51,7 +51,10 @@ public class ResourceManager extends Lifecycle implements IResourceManager
if (id == null)
{
id = loadID(path);
- registerResource(id, path);
+ if (id != null)
+ {
+ registerResource(id, path);
+ }
}
return id;
@@ -63,7 +66,10 @@ public class ResourceManager extends Lifecycle implements IResourceManager
if (path == null)
{
path = loadPath(id);
- registerResource(id, path);
+ if (path != null)
+ {
+ registerResource(id, path);
+ }
}
return path;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
index 3f43851..9d9ceb7 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server.protocol;
+import org.eclipse.emf.cdo.internal.protocol.id.CDOIDObjectFactoryImpl;
import org.eclipse.emf.cdo.internal.server.PackageManager;
import org.eclipse.emf.cdo.internal.server.Repository;
import org.eclipse.emf.cdo.internal.server.Session;
@@ -165,17 +166,24 @@ public class OpenSessionIndication extends IndicationWithResponse
private void writeCDOIDObjectFactory(ExtendedDataOutputStream out, CDOIDObjectFactory factory) throws IOException
{
- Class<?>[] classes = factory.getCDOIDObjectClasses();
- if (classes == null)
+ if (factory.getClass() == CDOIDObjectFactoryImpl.class)
{
- classes = new Class<?>[0];
+ out.writeInt(0);
}
-
- out.writeInt(1 + classes.length);
- serializeClass(out, factory.getClass());
- for (Class<?> c : classes)
+ else
{
- serializeClass(out, c);
+ Class<?>[] classes = factory.getCDOIDObjectClasses();
+ if (classes == null)
+ {
+ classes = new Class<?>[0];
+ }
+
+ out.writeInt(1 + classes.length);
+ serializeClass(out, factory.getClass());
+ for (Class<?> c : classes)
+ {
+ serializeClass(out, c);
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IResourceManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IResourceManager.java
index 07c543a..f6cc603 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IResourceManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IResourceManager.java
@@ -17,7 +17,13 @@ import org.eclipse.emf.cdo.protocol.id.CDOID;
*/
public interface IResourceManager extends IRepositoryElement
{
+ /**
+ * Returns the <code>CDOID</code> of the resource with the given path.
+ */
public CDOID getResourceID(String path);
+ /**
+ * Returns the path of the resource with the given <code>CDOID</code>.
+ */
public String getResourcePath(CDOID id);
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
index 87ab5dc..86e02a7 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
@@ -56,8 +56,16 @@ public interface IStoreReader extends IStoreAccessor
public CDORevision readRevisionByVersion(CDOID id, int referenceChunk, int version);
+ /**
+ * Returns the <code>CDOID</code> of the resource with the given path if a resource with this path exists in the
+ * store, <code>null</code> otherwise.
+ */
public CDOID readResourceID(String path);
+ /**
+ * Returns the path of the resource with the given <code>CDOID</code> if a resource with this <code>CDOID</code>
+ * exists in the store, <code>null</code> otherwise.
+ */
public String readResourcePath(CDOID id);
public CDORevision verifyRevision(CDORevision revision);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
index e4fcba9..8a3c0dc 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
@@ -25,6 +25,7 @@ public class AllTests
// $JUnit-BEGIN$
suite.addTestSuite(InitialTest.class);
suite.addTestSuite(StateMachineTest.class);
+ suite.addTestSuite(ViewTest.class);
suite.addTestSuite(ResourceTest.class);
suite.addTestSuite(ContainmentTest.class);
suite.addTestSuite(InvalidationTest.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java
new file mode 100644
index 0000000..e4e2804
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java
@@ -0,0 +1,59 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.CDOTransaction;
+import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.protocol.id.CDOID;
+
+/**
+ * @author Eike Stepper
+ */
+public class ViewTest extends AbstractCDOTest
+{
+ public void testHasResource() throws Exception
+ {
+ {
+ CDOSession session = openModel1Session();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.createResource("/test1");
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openModel1Session();
+ CDOView view = session.openView();
+ assertEquals(true, view.hasResource("/test1"));
+ assertEquals(false, view.hasResource("/test2"));
+ session.close();
+ }
+
+ public void testGetOrCreateResource() throws Exception
+ {
+ CDOID id;
+ {
+ CDOSession session = openModel1Session();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test1");
+ transaction.commit();
+ id = resource.cdoID();
+ session.close();
+ }
+
+ CDOSession session = openModel1Session();
+ CDOTransaction transaction = session.openTransaction();
+ assertEquals(id, transaction.getOrCreateResource("/test1").cdoID());
+ assertNotSame(id, transaction.getOrCreateResource("/test2").cdoID());
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java
index 2c9d188..34b3f49 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java
@@ -42,6 +42,8 @@ public interface CDOTransaction extends CDOView
*/
public CDOResource createResource(String path);
+ public CDOResource getOrCreateResource(String path);
+
public CDOObject newInstance(EClass eClass);
public CDOObject newInstance(CDOClass cdoClass);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
index a774bc2..e81c106 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
@@ -55,6 +55,8 @@ public interface CDOView extends CDOProtocolView, INotifier
*/
public CDORevision getRevision(CDOID id);
+ public boolean hasResource(String path);
+
/**
* @see ResourceSet#getResource(URI, boolean)
*/
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index 90fa71f..a30bcbc 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -75,6 +75,9 @@ import java.util.concurrent.ConcurrentMap;
/**
* @author Eike Stepper
*/
+/**
+ * @author Eike Stepper
+ */
public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CDOIDObjectFactory
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SESSION, CDOSessionImpl.class);
@@ -700,14 +703,6 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
/**
* @author Eike Stepper
*/
- private final class CDOIDObjectFactoryClassLoader extends ClassLoader
- {
- public CDOIDObjectFactoryClassLoader()
- {
- super(OM.BUNDLE.getClass().getClassLoader());
- }
- }
-
private final class InvalidationEvent extends Event implements CDOSessionInvalidationEvent
{
private static final long serialVersionUID = 1L;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
index b188cf0..3dcba3a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
@@ -194,6 +194,19 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
return (CDOResource)getResourceSet().createResource(createURI);
}
+ public CDOResource getOrCreateResource(String path)
+ {
+ CDOID id = getResourceID(path);
+ if (id == null || id.isNull())
+ {
+ return createResource(path);
+ }
+ else
+ {
+ return addResource(id, path);
+ }
+ }
+
public void commit() throws TransactionException
{
if (dirty)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index 8fb81de..5ac3d46 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -37,6 +37,7 @@ import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.ReadOnlyException;
import org.eclipse.emf.internal.cdo.bundle.OM;
+import org.eclipse.emf.internal.cdo.protocol.ResourceIDRequest;
import org.eclipse.emf.internal.cdo.protocol.ResourcePathRequest;
import org.eclipse.emf.internal.cdo.util.FSMUtil;
import org.eclipse.emf.internal.cdo.util.ModelUtil;
@@ -45,6 +46,7 @@ import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.signal.failover.IFailOverStrategy;
import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.ref.ReferenceValueMap;
+import org.eclipse.net4j.util.transaction.TransactionException;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
@@ -182,6 +184,26 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
throw new ReadOnlyException("CDO view is read only: " + this);
}
+ public boolean hasResource(String path)
+ {
+ CDOID id = getResourceID(path);
+ return id != null && !id.isNull();
+ }
+
+ public CDOID getResourceID(String path)
+ {
+ try
+ {
+ IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
+ ResourceIDRequest request = new ResourceIDRequest(session.getChannel(), path);
+ return failOverStrategy.send(request);
+ }
+ catch (Exception ex)
+ {
+ throw new TransactionException(ex);
+ }
+ }
+
public CDOResource getResource(String path)
{
URI uri = CDOUtil.createResourceURI(path);
@@ -195,6 +217,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
throw new IllegalArgumentException("resourceID == null || resourceID == CDOID.NULL");
}
+ // TODO What about somply looking in the objects cache of this view as well?
ResourceSet resourceSet = getResourceSet();
EList<Resource> resources = resourceSet.getResources();
for (Resource resource : resources)
@@ -214,18 +237,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
ResourcePathRequest request = new ResourcePathRequest(session.getChannel(), resourceID);
String path = failOverStrategy.send(request);
-
- CDOResourceImpl resource = (CDOResourceImpl)EresourceFactory.eINSTANCE.createCDOResource();
- resource.setPath(path);
-
- InternalCDOObject resourceObject = resource;
- resourceObject.cdoInternalSetID(resourceID);
- resourceObject.cdoInternalSetView(this);
- resourceObject.cdoInternalSetResource(resource);
- resourceObject.cdoInternalSetState(CDOState.PROXY);
-
- resourceSet.getResources().add(resource);
- return resource;
+ return addResource(resourceID, path);
}
catch (RuntimeException ex)
{
@@ -237,6 +249,22 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
}
}
+ public CDOResourceImpl addResource(CDOID id, String path)
+ {
+ CDOResourceImpl resource = (CDOResourceImpl)EresourceFactory.eINSTANCE.createCDOResource();
+ resource.setPath(path);
+
+ InternalCDOObject resourceObject = resource;
+ resourceObject.cdoInternalSetID(id);
+ resourceObject.cdoInternalSetView(this);
+ resourceObject.cdoInternalSetResource(resource);
+ resourceObject.cdoInternalSetState(CDOState.PROXY);
+
+ ResourceSet resourceSet = getResourceSet();
+ resourceSet.getResources().add(resource);
+ return resource;
+ }
+
public InternalCDOObject newInstance(EClass eClass)
{
EObject eObject = EcoreUtil.create(eClass);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java
index 71cb799..f4af60f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo.protocol;
+import org.eclipse.emf.cdo.internal.protocol.id.CDOIDObjectFactoryImpl;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
@@ -118,10 +119,17 @@ public class OpenSessionRequest extends RequestWithConfirmation<OpenSessionResul
}
int classes = in.readInt();
- result.setCDOIDObjectFactoryClass(deserializeClass(in));
- for (int i = 1; i < classes; i++)
+ if (classes == 0)
{
- result.addCDOIDObjectClass(deserializeClass(in));
+ result.setCDOIDObjectFactoryClass(CDOIDObjectFactoryImpl.class);
+ }
+ else
+ {
+ result.setCDOIDObjectFactoryClass(deserializeClass(in));
+ for (int i = 1; i < classes; i++)
+ {
+ result.addCDOIDObjectClass(deserializeClass(in));
+ }
}
return result;
@@ -158,29 +166,4 @@ public class OpenSessionRequest extends RequestWithConfirmation<OpenSessionResul
throw WrappedException.wrap(ex);
}
}
-
- private static final class CustomObjectInputStream extends ObjectInputStream
- {
- public CustomObjectInputStream(InputStream in) throws IOException
- {
- super(in);
- }
-
- @Override
- protected Class<?> resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException
- {
- String className = v.getName();
- ClassLoader loader = getClass().getClassLoader();
-
- try
- {
- return loader.loadClass(className);
- }
- catch (ClassNotFoundException ex)
- {
- ex.printStackTrace();
- return super.resolveClass(v);
- }
- }
- }
}