Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

clojure.osgi 1.3 #4

Closed
wants to merge 2 commits into from

2 participants

@aav

My changes to CCW, to make it compatible with current (1.3) state of clojure.osgi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 15, 2011
  1. @aav
Commits on Dec 24, 2011
  1. @aav

    remove with-bundle*

    aav authored
This page is out of date. Refresh to see the latest.
View
41 ccw.core/src/ccw/CCWPlugin.java
@@ -40,6 +40,7 @@
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
import ccw.editors.clojure.ClojureEditor;
import ccw.editors.clojure.IScanContext;
@@ -51,7 +52,7 @@
import clojure.lang.Keyword;
import clojure.lang.Symbol;
import clojure.lang.Var;
-import clojure.osgi.ClojureOSGi;
+import clojure.osgi.IClojureOSGi;
import clojure.tools.nrepl.Connection;
/**
@@ -61,6 +62,17 @@
/** The plug-in ID */
public static final String PLUGIN_ID = "ccw";
+
+
+
+ private ServiceReference clojureOSGiReference;
+
+ private static IClojureOSGi clojureOSGi;
+
+ public static IClojureOSGi getClojureOSGi() {
+ return clojureOSGi;
+ }
+
/**
* @param swtKey a key from SWT.COLOR_xxx
@@ -132,6 +144,13 @@ public void start(BundleContext context) throws Exception {
System.out.println("CCWPlugin start() starts");
super.start(context);
plugin = this;
+
+ clojureOSGiReference = context.getServiceReference(IClojureOSGi.class.getName());
+ if(clojureOSGiReference == null)
+ throw new IllegalStateException();
+
+ clojureOSGi = (IClojureOSGi) context.getService(clojureOSGiReference);
+
startClojureCode(context);
System.out.println("CCWPlugin start() ends");
}
@@ -200,18 +219,18 @@ public IPreferenceStore getCombinedPreferenceStore() {
private void startClojureCode(BundleContext bundleContext) throws Exception {
// ClojureOSGi.loadAOTClass(bundleContext, "ccw.editors.clojure.ClojureFormat");
- ClojureOSGi.require(bundleContext, "ccw.util.bundle-utils");
- ClojureOSGi.require(bundleContext, "ccw.editors.clojure.hyperlink");
+ clojureOSGi.require(bundleContext.getBundle(), "ccw.util.bundle-utils");
+ clojureOSGi.require(bundleContext.getBundle(), "ccw.editors.clojure.hyperlink");
- ClojureOSGi.require(bundleContext, "ccw.editors.clojure.editor-support");
+ clojureOSGi.require(bundleContext.getBundle(), "ccw.editors.clojure.editor-support");
- ClojureOSGi.require(bundleContext, "ccw.editors.clojure.ClojureTopLevelFormsDamagerImpl");
- ClojureOSGi.require(bundleContext, "ccw.editors.clojure.PareditAutoEditStrategyImpl");
+ clojureOSGi.require(bundleContext.getBundle(), "ccw.editors.clojure.ClojureTopLevelFormsDamagerImpl");
+ clojureOSGi.require(bundleContext.getBundle(), "ccw.editors.clojure.PareditAutoEditStrategyImpl");
- ClojureOSGi.require(bundleContext, "ccw.debug.clientrepl");
- ClojureOSGi.require(bundleContext, "ccw.debug.serverrepl"); // <= to enable REPLView
+ clojureOSGi.require(bundleContext.getBundle(), "ccw.debug.clientrepl");
+ clojureOSGi.require(bundleContext.getBundle(), "ccw.debug.serverrepl"); // <= to enable REPLView
// server-side tooling
- ClojureOSGi.require(bundleContext, "ccw.static-analysis");
+ clojureOSGi.require(bundleContext.getBundle(), "ccw.static-analysis");
}
public void stop(BundleContext context) throws Exception {
@@ -220,6 +239,10 @@ public void stop(BundleContext context) throws Exception {
// corresponding method on the ColorRegistry instance!
// We also don't remove fonts when deregistered
stopREPLServer();
+
+ if(clojureOSGiReference != null)
+ context.ungetService(clojureOSGiReference);
+
plugin = null;
super.stop(context);
}
View
3  ccw.core/src/ccw/editors/clojure/ClojureEditor.java
@@ -38,7 +38,6 @@
import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-import clojure.osgi.ClojureOSGi;
import ccw.CCWPlugin;
import ccw.editors.outline.ClojureOutlinePage;
@@ -50,7 +49,7 @@
private static final String EDITOR_SUPPORT_NS = "ccw.editors.clojure.editor-support";
static {
try {
- ClojureOSGi.require(CCWPlugin.getDefault().getBundle().getBundleContext(), EDITOR_SUPPORT_NS);
+ CCWPlugin.getClojureOSGi().require(CCWPlugin.getDefault().getBundle(), EDITOR_SUPPORT_NS);
} catch (Exception e) {
throw new RuntimeException(e);
}
View
3  ccw.core/src/ccw/editors/clojure/ClojureSourceViewer.java
@@ -54,7 +54,6 @@
import ccw.repl.REPLView;
import ccw.util.ClojureUtils;
import ccw.util.DisplayUtil;
-import clojure.osgi.ClojureOSGi;
public abstract class ClojureSourceViewer extends ProjectionViewer implements
IClojureEditor, IPropertyChangeListener {
@@ -63,7 +62,7 @@
private static final String EDITOR_SUPPORT_NS = "ccw.editors.clojure.editor-support";
static {
try {
- ClojureOSGi.require(CCWPlugin.getDefault().getBundle().getBundleContext(), EDITOR_SUPPORT_NS);
+ CCWPlugin.getClojureOSGi().require(CCWPlugin.getDefault().getBundle(), EDITOR_SUPPORT_NS);
} catch (Exception e) {
throw new RuntimeException(e);
}
View
5 ccw.core/src/ccw/editors/clojure/ClojureTokenScanner.java
@@ -32,15 +32,14 @@
import ccw.util.ClojureUtils;
import clojure.lang.ISeq;
import clojure.lang.Keyword;
-import clojure.osgi.ClojureOSGi;
abstract public class ClojureTokenScanner implements ITokenScanner {
private static final String EDITOR_SUPPORT_NS = "ccw.editors.clojure.editor-support";
private static final String ClojureTopLevelFormsDamager_NS = "ccw.editors.clojure.ClojureTopLevelFormsDamagerImpl";
static {
try {
- ClojureOSGi.require(CCWPlugin.getDefault().getBundle().getBundleContext(), EDITOR_SUPPORT_NS);
- ClojureOSGi.require(CCWPlugin.getDefault().getBundle().getBundleContext(), ClojureTopLevelFormsDamager_NS);
+ CCWPlugin.getClojureOSGi().require(CCWPlugin.getDefault().getBundle(), EDITOR_SUPPORT_NS);
+ CCWPlugin.getClojureOSGi().require(CCWPlugin.getDefault().getBundle(), ClojureTopLevelFormsDamager_NS);
} catch (Exception e) {
throw new RuntimeException(e);
}
View
3  ccw.core/src/ccw/editors/clojure/ClojureTopLevelFormsDamager.java
@@ -9,7 +9,6 @@
import ccw.CCWPlugin;
import ccw.util.ClojureUtils;
import clojure.lang.Ref;
-import clojure.osgi.ClojureOSGi;
public class ClojureTopLevelFormsDamager implements IPresentationDamager {
private static final String ClojureTopLevelFormsDamagerImpl_NS = "ccw.editors.clojure.ClojureTopLevelFormsDamagerImpl";
@@ -17,7 +16,7 @@
static {
try {
- ClojureOSGi.require(CCWPlugin.getDefault().getBundle().getBundleContext(), ClojureTopLevelFormsDamagerImpl_NS);
+ CCWPlugin.getClojureOSGi().require(CCWPlugin.getDefault().getBundle(), ClojureTopLevelFormsDamagerImpl_NS);
} catch (Exception e) {
throw new RuntimeException(e);
}
View
3  ccw.core/src/ccw/editors/clojure/LoadFileAction.java
@@ -25,7 +25,6 @@
import ccw.repl.REPLView;
import clojure.lang.Symbol;
import clojure.lang.Var;
-import clojure.osgi.ClojureOSGi;
public class LoadFileAction extends Action {
@@ -34,7 +33,7 @@
private static Var loadFileCommand;
static {
try {
- ClojureOSGi.require(CCWPlugin.getDefault().getBundle().getBundleContext(), "clojure.tools.nrepl.helpers");
+ CCWPlugin.getClojureOSGi().require(CCWPlugin.getDefault().getBundle(), "clojure.tools.nrepl.helpers");
loadFileCommand = Var.find(Symbol.intern("clojure.tools.nrepl.helpers/load-file-command"));
} catch (Exception e) {
CCWPlugin.logError("Could not initialize code loading helpers.", e);
View
3  ccw.core/src/ccw/editors/clojure/PareditAutoEditStrategy.java
@@ -8,7 +8,6 @@
import ccw.CCWPlugin;
import ccw.util.ClojureUtils;
import clojure.lang.Ref;
-import clojure.osgi.ClojureOSGi;
public class PareditAutoEditStrategy implements IAutoEditStrategy {
private static final String PareditAutoEditStrategyImpl_NS = "ccw.editors.clojure.PareditAutoEditStrategyImpl";
@@ -16,7 +15,7 @@
static {
try {
- ClojureOSGi.require(CCWPlugin.getDefault().getBundle().getBundleContext(), PareditAutoEditStrategyImpl_NS);
+ CCWPlugin.getClojureOSGi().require(CCWPlugin.getDefault().getBundle(), PareditAutoEditStrategyImpl_NS);
} catch (Exception e) {
throw new RuntimeException(e);
}
View
5 ccw.core/src/ccw/repl/REPLView.java
@@ -52,14 +52,13 @@
import clojure.lang.PersistentTreeMap;
import clojure.lang.Symbol;
import clojure.lang.Var;
-import clojure.osgi.ClojureOSGi;
import clojure.tools.nrepl.Connection;
public class REPLView extends ViewPart implements IAdaptable {
private static final String EDITOR_SUPPORT_NS = "ccw.editors.clojure.editor-support";
static {
try {
- ClojureOSGi.require(CCWPlugin.getDefault().getBundle().getBundleContext(), EDITOR_SUPPORT_NS);
+ CCWPlugin.getClojureOSGi().require(CCWPlugin.getDefault().getBundle(), EDITOR_SUPPORT_NS);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -75,7 +74,7 @@
private static Var configureREPLView;
static {
try {
- ClojureOSGi.require(CCWPlugin.getDefault().getBundle().getBundleContext(), "ccw.repl.view-helpers");
+ CCWPlugin.getClojureOSGi().require(CCWPlugin.getDefault().getBundle(), "ccw.repl.view-helpers");
log = Var.find(Symbol.intern("ccw.repl.view-helpers/log"));
configureREPLView = Var.find(Symbol.intern("ccw.repl.view-helpers/configure-repl-view"));
} catch (Exception e) {
View
4 ccw.core/src/ccw/util/BundleUtils.java
@@ -7,10 +7,10 @@
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
+import ccw.CCWPlugin;
import clojure.lang.RT;
import clojure.lang.Symbol;
import clojure.lang.Var;
-import clojure.osgi.ClojureOSGi;
public final class BundleUtils {
private static final Var findNs = RT.var("clojure.core", "find-ns");
@@ -33,7 +33,7 @@ public static Var requireAndGetVar(String bundleSymbolicName, String varName) th
final String[] nsFn = varName.split("/");
try {
if (findNs.invoke(Symbol.intern(nsFn[0])) == null) {
- ClojureOSGi.require(loadAndGetBundle(bundleSymbolicName).getBundleContext(), nsFn[0]);
+ CCWPlugin.getClojureOSGi().require(loadAndGetBundle(bundleSymbolicName), nsFn[0]);
}
return RT.var(nsFn[0], nsFn[1]);
} catch (Exception e) {
View
3  ccw.core/src/ccw/util/GenericExecutableExtension.java
@@ -10,7 +10,6 @@
import ccw.CCWPlugin;
import clojure.lang.Var;
-import clojure.osgi.ClojureOSGi;
import clojure.osgi.RunnableWithException;
public class GenericExecutableExtension implements IExecutableExtensionFactory, IExecutableExtension {
@@ -20,7 +19,7 @@
public Object create() throws CoreException {
try {
- return ClojureOSGi.withBundle(BundleUtils.loadAndGetBundle(bundleName), new RunnableWithException() {
+ return CCWPlugin.getClojureOSGi().withBundle(BundleUtils.loadAndGetBundle(bundleName), new RunnableWithException() {
public Object run() throws Exception {
return factory.invoke(factoryParams);
}
View
10 ccw.core/src/ccw/util/bundle_utils.clj
@@ -5,7 +5,8 @@
org.eclipse.core.runtime.Status
org.osgi.framework.Bundle
org.osgi.framework.BundleException
- clojure.osgi.ClojureOSGi))
+ clojure.osgi.BundleClassLoader
+ ))
;(defn require-and-get-var)
; public static Var requireAndGetVar(String bundleSymbolicName, String varName) throws CoreException {
@@ -67,12 +68,7 @@
; (bundle-class-loader bundle) function)
; )
;)
-
-(defn with-bundle* [bundle f]
- (clojure.osgi.ClojureOSGi/withBundle
- bundle
- (reify clojure.osgi.RunnableWithException
- (run [this] (f)))))
+;
;; http://www.ibm.com/developerworks/opensource/library/os-ecl-dynext/
(defn add-contribution [s bundle]
Something went wrong with that request. Please try again.