Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgidijus Vaisnora2012-01-09 15:46:29 +0000
committerEgidijus Vaisnora2012-01-09 15:46:29 +0000
commit2800e0660f5343c592c76281b969c85b4bafc087 (patch)
treeb84db54db19848eda7be80e86609c9bed095cb41
parentcf524f68156a5172a1c0436cde560b5e5ab31d9c (diff)
parenta340df661b0510e48bae72dbbcc23a00e66d6032 (diff)
downloadcdo-2800e0660f5343c592c76281b969c85b4bafc087.tar.gz
cdo-2800e0660f5343c592c76281b969c85b4bafc087.tar.xz
cdo-2800e0660f5343c592c76281b969c85b4bafc087.zip
Merge branch 'master' of ssh://evaisnora@git.eclipse.org/gitroot/cdo/cdo.git into bugs/350120
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PartialCollectionLoadingNotSupportedException.java45
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java10
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java110
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDONotificationBuilder.java9
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java24
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java50
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractBundle.java33
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/OSGiBundle.java38
9 files changed, 259 insertions, 63 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PartialCollectionLoadingNotSupportedException.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PartialCollectionLoadingNotSupportedException.java
new file mode 100644
index 0000000000..f4f3db5926
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PartialCollectionLoadingNotSupportedException.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * 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.common.util;
+
+import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
+
+/**
+ * An unchecked exception that indicates that {@link CDOElementProxy list element proxies} have been encountered but
+ * cannot be handled.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @since 4.1
+ */
+public class PartialCollectionLoadingNotSupportedException extends IllegalStateException
+{
+ private static final long serialVersionUID = 1L;
+
+ public PartialCollectionLoadingNotSupportedException()
+ {
+ }
+
+ public PartialCollectionLoadingNotSupportedException(String message)
+ {
+ super(message);
+ }
+
+ public PartialCollectionLoadingNotSupportedException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public PartialCollectionLoadingNotSupportedException(Throwable cause)
+ {
+ super(cause);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java
index bc6e671bc9..bd5b0ba57e 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java
@@ -30,6 +30,7 @@ import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
+import org.eclipse.emf.cdo.common.util.PartialCollectionLoadingNotSupportedException;
import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
@@ -367,7 +368,7 @@ public class CDORevisionDeltaImpl implements InternalCDORevisionDelta
{
if (element instanceof CDOElementProxy)
{
- throw new IllegalStateException("List contains proxy elements");
+ throw new PartialCollectionLoadingNotSupportedException("List contains proxy elements");
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java
index 82d24768ab..f8ebfb18a5 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java
@@ -308,6 +308,16 @@ public class ServerCDOView extends AbstractCDOView implements org.eclipse.emf.cd
throw new UnsupportedOperationException();
}
+ public boolean isLoadNotificationEnabled()
+ {
+ return false;
+ }
+
+ public void setLoadNotificationEnabled(boolean enabled)
+ {
+ throw new UnsupportedOperationException();
+ }
+
public boolean isLockNotificationEnabled()
{
return false;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java
index 1f421e906b..847dc118a3 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java
@@ -461,31 +461,21 @@ public interface CDOView extends CDOCommonView, CDOUpdatable, INotifier
public static final int NO_REVISION_PREFETCHING = 1;
/**
- * Returns the reference type to be used in the internal object cache.
+ * Returns <code>true</code> if the {@link CDOObject objects} in this view will notify their
+ * {@link org.eclipse.emf.common.notify.Adapter adapters} about the fact that they are <em>loaded</em>,
+ * <code>false</code> otherwise.
*
- * @return Either {@link ReferenceType#STRONG STRONG}, {@link ReferenceType#SOFT SOFT} or {@link ReferenceType#WEAK
- * WEAK}.
- */
- public ReferenceType getCacheReferenceType();
-
- /**
- * Sets the reference type to be used in the internal object cache to either {@link ReferenceType#STRONG STRONG},
- * {@link ReferenceType#SOFT SOFT} or {@link ReferenceType#WEAK WEAK}. If <code>null</code> is passed the default
- * reference type {@link ReferenceType#SOFT SOFT} is set. If the given reference type does not differ from the one
- * being currently set the new value is ignored and <code>false</code> is returned. Otherwise existing object
- * references are converted to the new type and <code>true</code> is returned.
- */
- public boolean setCacheReferenceType(ReferenceType referenceType);
-
- /**
- * @since 3.0
+ * @since 4.1
*/
- public CDOInvalidationPolicy getInvalidationPolicy();
+ public boolean isLoadNotificationEnabled();
/**
- * @since 3.0
+ * Specifies whether the {@link CDOObject objects} in this view will notify their
+ * {@link org.eclipse.emf.common.notify.Adapter adapters} about the fact that they are <em>loaded</em> or not.
+ *
+ * @since 4.1
*/
- public void setInvalidationPolicy(CDOInvalidationPolicy policy);
+ public void setLoadNotificationEnabled(boolean enabled);
/**
* Returns <code>true</code> if the {@link CDOObject objects} in this view will notify their
@@ -506,6 +496,16 @@ public interface CDOView extends CDOCommonView, CDOUpdatable, INotifier
public void setInvalidationNotificationEnabled(boolean enabled);
/**
+ * @since 3.0
+ */
+ public CDOInvalidationPolicy getInvalidationPolicy();
+
+ /**
+ * @since 3.0
+ */
+ public void setInvalidationPolicy(CDOInvalidationPolicy policy);
+
+ /**
* Returns the current set of {@link CDOAdapterPolicy change subscription policies}.
*
* @return The current set of change subscription policies, never <code>null</code>.
@@ -553,6 +553,23 @@ public interface CDOView extends CDOCommonView, CDOUpdatable, INotifier
*/
public void removeChangeSubscriptionPolicy(CDOAdapterPolicy policy);
+ /**
+ * Returns the reference type to be used in the internal object cache.
+ *
+ * @return Either {@link ReferenceType#STRONG STRONG}, {@link ReferenceType#SOFT SOFT} or {@link ReferenceType#WEAK
+ * WEAK}.
+ */
+ public ReferenceType getCacheReferenceType();
+
+ /**
+ * Sets the reference type to be used in the internal object cache to either {@link ReferenceType#STRONG STRONG},
+ * {@link ReferenceType#SOFT SOFT} or {@link ReferenceType#WEAK WEAK}. If <code>null</code> is passed the default
+ * reference type {@link ReferenceType#SOFT SOFT} is set. If the given reference type does not differ from the one
+ * being currently set the new value is ignored and <code>false</code> is returned. Otherwise existing object
+ * references are converted to the new type and <code>true</code> is returned.
+ */
+ public boolean setCacheReferenceType(ReferenceType referenceType);
+
// TODO
public CDOAdapterPolicy getStrongReferencePolicy();
@@ -617,90 +634,103 @@ public interface CDOView extends CDOCommonView, CDOUpdatable, INotifier
/**
* An {@link IOptionsEvent options event} fired from view {@link CDOView#options() options} when the
- * {@link Options#setCacheReferenceType(ReferenceType) cache reference type} option has changed.
+ * {@link Options#setLoadNotificationEnabled(boolean) load notification enabled} option has changed.
*
* @author Eike Stepper
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
+ * @since 4.1
*/
- public interface CacheReferenceTypeEvent extends IOptionsEvent
+ public interface LoadNotificationEvent extends IOptionsEvent
{
}
/**
* An {@link IOptionsEvent options event} fired from view {@link CDOView#options() options} when the
- * {@link Options#setStrongReferencePolicy(CDOAdapterPolicy) strong reference policy} option has changed.
+ * {@link Options#setInvalidationNotificationEnabled(boolean) invalidation notification enabled} option has changed.
*
* @author Eike Stepper
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
- * @since 4.0
*/
- public interface StrongReferencePolicyEvent extends IOptionsEvent
+ public interface InvalidationNotificationEvent extends IOptionsEvent
{
}
/**
* An {@link IOptionsEvent options event} fired from view {@link CDOView#options() options} when the
- * {@link Options#setStrongReferencePolicy(CDOAdapterPolicy) strong reference policy} option has changed.
+ * {@link Options#setInvalidationPolicy(CDOInvalidationPolicy) invalidation policy} option has changed.
*
* @author Eike Stepper
+ * @since 3.0
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
- * @deprecated Use {@link StrongReferencePolicyEvent} instead.
- * @apiviz.exclude
*/
- @Deprecated
- public interface ReferencePolicyEvent extends StrongReferencePolicyEvent
+ public interface InvalidationPolicyEvent extends IOptionsEvent
{
}
/**
* An {@link IOptionsEvent options event} fired from view {@link CDOView#options() options} when the
- * {@link Options#setStaleReferenceBehaviour(CDOStaleReferencePolicy) stale reference type} option has changed.
+ * {@link Options#addChangeSubscriptionPolicy(CDOAdapterPolicy) change subscription policies} option has changed.
*
- * @since 3.0
+ * @author Eike Stepper
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
- public interface StaleReferencePolicyEvent extends IOptionsEvent
+ public interface ChangeSubscriptionPoliciesEvent extends IOptionsEvent
{
}
/**
* An {@link IOptionsEvent options event} fired from view {@link CDOView#options() options} when the
- * {@link Options#addChangeSubscriptionPolicy(CDOAdapterPolicy) change subscription policies} option has changed.
+ * {@link Options#setCacheReferenceType(ReferenceType) cache reference type} option has changed.
*
* @author Eike Stepper
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
- public interface ChangeSubscriptionPoliciesEvent extends IOptionsEvent
+ public interface CacheReferenceTypeEvent extends IOptionsEvent
{
}
/**
* An {@link IOptionsEvent options event} fired from view {@link CDOView#options() options} when the
- * {@link Options#setInvalidationPolicy(CDOInvalidationPolicy) invalidation policy} option has changed.
+ * {@link Options#setStrongReferencePolicy(CDOAdapterPolicy) strong reference policy} option has changed.
*
* @author Eike Stepper
- * @since 3.0
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
+ * @since 4.0
*/
- public interface InvalidationPolicyEvent extends IOptionsEvent
+ public interface StrongReferencePolicyEvent extends IOptionsEvent
{
}
/**
* An {@link IOptionsEvent options event} fired from view {@link CDOView#options() options} when the
- * {@link Options#setInvalidationNotificationEnabled(boolean) invalidation notification enabled} option has changed.
+ * {@link Options#setStrongReferencePolicy(CDOAdapterPolicy) strong reference policy} option has changed.
*
* @author Eike Stepper
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
+ * @deprecated Use {@link StrongReferencePolicyEvent} instead.
+ * @apiviz.exclude
*/
- public interface InvalidationNotificationEvent extends IOptionsEvent
+ @Deprecated
+ public interface ReferencePolicyEvent extends StrongReferencePolicyEvent
+ {
+ }
+
+ /**
+ * An {@link IOptionsEvent options event} fired from view {@link CDOView#options() options} when the
+ * {@link Options#setStaleReferenceBehaviour(CDOStaleReferencePolicy) stale reference type} option has changed.
+ *
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+ public interface StaleReferencePolicyEvent extends IOptionsEvent
{
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDONotificationBuilder.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDONotificationBuilder.java
index 5efff5015a..131e5e0640 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDONotificationBuilder.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDONotificationBuilder.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.internal.cdo.object;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
@@ -31,6 +32,7 @@ import org.eclipse.emf.common.notify.impl.NotificationChainImpl;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.spi.cdo.InternalCDOObject;
import java.util.ArrayList;
import java.util.List;
@@ -87,6 +89,13 @@ public class CDONotificationBuilder extends CDOFeatureDeltaVisitorImpl
return notification;
}
+ public synchronized NotificationChain buildNotification(InternalCDOObject object, InternalCDORevision newRevision)
+ {
+ InternalCDORevision oldRevision = (InternalCDORevision)CDORevisionFactory.DEFAULT.createRevision(object.eClass());
+ CDORevisionDelta revisionDelta = newRevision.compare(oldRevision);
+ return buildNotification(object, oldRevision, revisionDelta, null);
+ }
+
@Override
public void visit(CDOMoveFeatureDelta delta)
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java
index 47b12d224d..aed2f3deba 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java
@@ -23,6 +23,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.common.util.PartialCollectionLoadingNotSupportedException;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
@@ -33,6 +34,7 @@ import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.internal.cdo.CDOObjectImpl;
import org.eclipse.emf.internal.cdo.bundle.OM;
+import org.eclipse.emf.internal.cdo.object.CDONotificationBuilder;
import org.eclipse.net4j.util.collection.Pair;
import org.eclipse.net4j.util.collection.Triplet;
@@ -40,6 +42,7 @@ import org.eclipse.net4j.util.fsm.FiniteStateMachine;
import org.eclipse.net4j.util.fsm.ITransition;
import org.eclipse.net4j.util.om.trace.ContextTracer;
+import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
@@ -1002,6 +1005,27 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
changeState(object, CDOState.CLEAN);
object.cdoInternalPostLoad();
+ if (view.options().isLoadNotificationEnabled())
+ {
+ try
+ {
+ CDONotificationBuilder builder = new CDONotificationBuilder(view);
+
+ NotificationChain notification = builder.buildNotification(object, revision);
+ if (notification != null)
+ {
+ notification.dispatch();
+ }
+ }
+ catch (PartialCollectionLoadingNotSupportedException ex)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
+ }
+ }
+
if (forWrite)
{
INSTANCE.writeWithoutViewLock(object, (CDOFeatureDelta)delta);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
index 83bf125f66..0578bcb0b2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
@@ -1622,6 +1622,8 @@ public class CDOViewImpl extends AbstractCDOView
*/
protected class OptionsImpl extends Notifier implements Options
{
+ private boolean loadNotificationEnabled;
+
private boolean invalidationNotificationEnabled;
private CDOInvalidationPolicy invalidationPolicy = CDOInvalidationPolicy.DEFAULT;
@@ -1647,23 +1649,23 @@ public class CDOViewImpl extends AbstractCDOView
return CDOViewImpl.this;
}
- public CDOInvalidationPolicy getInvalidationPolicy()
+ public boolean isLoadNotificationEnabled()
{
synchronized (CDOViewImpl.this)
{
- return invalidationPolicy;
+ return loadNotificationEnabled;
}
}
- public void setInvalidationPolicy(CDOInvalidationPolicy policy)
+ public void setLoadNotificationEnabled(boolean enabled)
{
IEvent event = null;
synchronized (CDOViewImpl.this)
{
- if (invalidationPolicy != policy)
+ if (loadNotificationEnabled != enabled)
{
- invalidationPolicy = policy;
- event = new InvalidationPolicyEventImpl();
+ loadNotificationEnabled = enabled;
+ event = new LoadNotificationEventImpl();
}
}
@@ -1693,6 +1695,29 @@ public class CDOViewImpl extends AbstractCDOView
fireEvent(event);
}
+ public CDOInvalidationPolicy getInvalidationPolicy()
+ {
+ synchronized (CDOViewImpl.this)
+ {
+ return invalidationPolicy;
+ }
+ }
+
+ public void setInvalidationPolicy(CDOInvalidationPolicy policy)
+ {
+ IEvent event = null;
+ synchronized (CDOViewImpl.this)
+ {
+ if (invalidationPolicy != policy)
+ {
+ invalidationPolicy = policy;
+ event = new InvalidationPolicyEventImpl();
+ }
+ }
+
+ fireEvent(event);
+ }
+
public boolean isLockNotificationEnabled()
{
return lockNotificationsEnabled;
@@ -1987,6 +2012,19 @@ public class CDOViewImpl extends AbstractCDOView
/**
* @author Eike Stepper
*/
+ private final class LoadNotificationEventImpl extends OptionsEvent implements LoadNotificationEvent
+ {
+ private static final long serialVersionUID = 1L;
+
+ public LoadNotificationEventImpl()
+ {
+ super(OptionsImpl.this);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
private final class InvalidationNotificationEventImpl extends OptionsEvent implements InvalidationNotificationEvent
{
private static final long serialVersionUID = 1L;
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractBundle.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractBundle.java
index 13111b433c..a61c00f2be 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractBundle.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractBundle.java
@@ -385,14 +385,33 @@ public abstract class AbstractBundle implements OMBundle, OMBundle.DebugSupport,
int end = path.length() - CLASS_EXTENSION.length();
String className = path.substring(start, end).replace('/', '.');
- try
+ for (;;)
{
- ClassLoader classLoader = getAccessor().getClassLoader();
- return classLoader.loadClass(className);
- }
- catch (ClassNotFoundException ex)
- {
- //$FALL-THROUGH$
+ try
+ {
+ ClassLoader classLoader = getAccessor().getClassLoader();
+ Class<?> c = classLoader.loadClass(className);
+ if (c != null)
+ {
+ return c;
+ }
+ }
+ catch (NoClassDefFoundError ex)
+ {
+ //$FALL-THROUGH$
+ }
+ catch (ClassNotFoundException ex)
+ {
+ //$FALL-THROUGH$
+ }
+
+ int dot = className.indexOf('.');
+ if (dot == -1)
+ {
+ break;
+ }
+
+ className = className.substring(dot + 1);
}
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/OSGiBundle.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/OSGiBundle.java
index 8090a07251..5c965fa0e1 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/OSGiBundle.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/OSGiBundle.java
@@ -25,6 +25,8 @@ import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Queue;
/**
* @author Eike Stepper
@@ -64,26 +66,44 @@ public class OSGiBundle extends AbstractBundle
public Iterator<Class<?>> getClasses()
{
- final Bundle bundle = getBundleContext().getBundle();
+ final Queue<String> folders = new LinkedList<String>();
+ folders.offer("/");
return new AbstractIterator<Class<?>>()
{
- private Enumeration<String> entryPaths = bundle.getEntryPaths("/");
+ private Enumeration<String> entryPaths;
@Override
protected Object computeNextElement()
{
- while (entryPaths.hasMoreElements())
+ for (;;)
{
- String entryPath = entryPaths.nextElement();
- Class<?> c = getClassFromBundle(entryPath);
- if (c != null)
+ while (entryPaths != null && entryPaths.hasMoreElements())
{
- return c;
+ String entryPath = entryPaths.nextElement();
+ if (entryPath.endsWith("/"))
+ {
+ folders.offer(entryPath);
+ }
+ else
+ {
+ Class<?> c = getClassFromBundle(entryPath);
+ if (c != null)
+ {
+ return c;
+ }
+ }
}
- }
- return END_OF_DATA;
+ String folder = folders.poll();
+ if (folder == null)
+ {
+ return END_OF_DATA;
+ }
+
+ Bundle bundle = getBundleContext().getBundle();
+ entryPaths = bundle.getEntryPaths(folder);
+ }
}
};
}

Back to the top