Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-12-10 09:23:23 +0000
committerEike Stepper2011-12-10 09:23:23 +0000
commit030fea1eb3d590c95dc75813e51c31975074fbd0 (patch)
tree0df32567d7396920b00c69c4a393ad0bda2d574e /plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util
parenta9b8b8d3831d1729cc067edf91544df3f43fa05d (diff)
downloadcdo-030fea1eb3d590c95dc75813e51c31975074fbd0.tar.gz
cdo-030fea1eb3d590c95dc75813e51c31975074fbd0.tar.xz
cdo-030fea1eb3d590c95dc75813e51c31975074fbd0.zip
[366290] Provide an OMBundle.getClasses() method
https://bugs.eclipse.org/bugs/show_bug.cgi?id=366290
Diffstat (limited to 'plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util')
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/AbstractIterator.java79
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMBundle.java12
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java10
3 files changed, 98 insertions, 3 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/AbstractIterator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/AbstractIterator.java
new file mode 100644
index 0000000000..897a487bb0
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/AbstractIterator.java
@@ -0,0 +1,79 @@
+/*
+ * 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.net4j.util.collection;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * An abstract base class for custom iterators that only requires to implement a single {@link #computeNextElement()}
+ * method.
+ *
+ * @author Eike Stepper
+ * @since 3.2
+ */
+public abstract class AbstractIterator<T> implements Iterator<T>
+{
+ /**
+ * The token to be used in {@link #computeNextElement()} to indicate the end of the iteration.
+ */
+ protected static final Object END_OF_DATA = new Object();
+
+ private boolean computed;
+
+ private T next;
+
+ public AbstractIterator()
+ {
+ }
+
+ public final boolean hasNext()
+ {
+ if (computed)
+ {
+ return true;
+ }
+
+ Object object = computeNextElement();
+ computed = true;
+
+ if (object == END_OF_DATA)
+ {
+ return false;
+ }
+
+ @SuppressWarnings("unchecked")
+ T cast = (T)object;
+ next = cast;
+ return true;
+ }
+
+ public final T next()
+ {
+ if (!hasNext())
+ {
+ throw new NoSuchElementException();
+ }
+
+ computed = false;
+ return next;
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the next iteration element, or {@link #END_OF_DATA} if the end of the iteration has been reached.
+ */
+ protected abstract Object computeNextElement();
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMBundle.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMBundle.java
index 28b5862871..252912edff 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMBundle.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMBundle.java
@@ -22,6 +22,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.Iterator;
import java.util.Properties;
import java.util.ResourceBundle;
@@ -47,7 +48,10 @@ public interface OMBundle
public URL getBaseURL();
- public void setBundleContext(Object bundleContext);
+ /**
+ * @since 3.2
+ */
+ public Iterator<Class<?>> getClasses();
public OMTracer tracer(String name);
@@ -68,6 +72,12 @@ public interface OMBundle
public TranslationSupport getTranslationSupport();
/**
+ * @deprecated For internal use only.
+ */
+ @Deprecated
+ public void setBundleContext(Object bundleContext);
+
+ /**
* A facility for accessing OSGi {@link DebugOptions debug options}, whether OSGi {@link OMPlatform#isOSGiRunning() is
* running} or not.
*
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java
index 50968f839e..2d41ba444b 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java
@@ -61,7 +61,7 @@ public abstract class OSGiActivator implements BundleActivator
try
{
- omBundle.setBundleContext(context);
+ setBundleContext(context);
((AbstractBundle)omBundle).start();
doStart();
}
@@ -89,7 +89,7 @@ public abstract class OSGiActivator implements BundleActivator
{
doStop();
((AbstractBundle)omBundle).stop();
- omBundle.setBundleContext(null);
+ setBundleContext(null);
}
catch (Error error)
{
@@ -147,6 +147,12 @@ public abstract class OSGiActivator implements BundleActivator
{
}
+ @SuppressWarnings("deprecation")
+ private void setBundleContext(BundleContext context)
+ {
+ omBundle.setBundleContext(context);
+ }
+
/**
* @since 2.0
*/

Back to the top