Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2008-05-14 03:29:38 -0400
committerslewis2008-05-14 03:29:38 -0400
commit98d8161290ae7bc2b0197921eca891421e2b5a1a (patch)
tree65aad93cd3c6543b88ec458e1f46997aa6ae1eeb
parent8ae979f388431ab6f2316f2646db9c4f71ce8918 (diff)
downloadorg.eclipse.ecf-98d8161290ae7bc2b0197921eca891421e2b5a1a.tar.gz
org.eclipse.ecf-98d8161290ae7bc2b0197921eca891421e2b5a1a.tar.xz
org.eclipse.ecf-98d8161290ae7bc2b0197921eca891421e2b5a1a.zip
Setup logging
-rw-r--r--framework/bundles/org.eclipse.ecf.storage/META-INF/MANIFEST.MF4
-rw-r--r--framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/Activator.java37
-rw-r--r--framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/IDEntry.java14
3 files changed, 50 insertions, 5 deletions
diff --git a/framework/bundles/org.eclipse.ecf.storage/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.storage/META-INF/MANIFEST.MF
index e21bc1cc0..f1f0769a1 100644
--- a/framework/bundles/org.eclipse.ecf.storage/META-INF/MANIFEST.MF
+++ b/framework/bundles/org.eclipse.ecf.storage/META-INF/MANIFEST.MF
@@ -9,7 +9,9 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.4
Eclipse-LazyStart: true
Import-Package: org.eclipse.equinox.security.storage;version="1.0.0",
org.eclipse.osgi.util;version="1.1.0",
- org.osgi.framework
+ org.osgi.framework,
+ org.osgi.service.log;version="1.3.0",
+ org.osgi.util.tracker;version="1.3.3"
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.equinox.common,
org.eclipse.ecf.identity;bundle-version="2.0.0"
diff --git a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/Activator.java b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/Activator.java
index 76c562616..cb90931e0 100644
--- a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/Activator.java
+++ b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/Activator.java
@@ -1,8 +1,13 @@
package org.eclipse.ecf.internal.storage;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.ecf.core.util.LogHelper;
+import org.eclipse.ecf.core.util.SystemLogService;
import org.eclipse.ecf.storage.IIDStore;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
/**
* The activator class controls the plug-in life cycle
@@ -15,6 +20,12 @@ public class Activator implements BundleActivator {
// The shared instance
private static Activator plugin;
+ private ServiceTracker logServiceTracker = null;
+
+ private LogService logService = null;
+
+ private BundleContext context = null;
+
/**
* The constructor
*/
@@ -27,6 +38,7 @@ public class Activator implements BundleActivator {
*/
public void start(BundleContext context) throws Exception {
plugin = this;
+ this.context = context;
context.registerService(IIDStore.class.getName(), new IDStore(), null);
}
@@ -35,6 +47,12 @@ public class Activator implements BundleActivator {
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
+ if (logServiceTracker != null) {
+ logServiceTracker.close();
+ logServiceTracker = null;
+ logService = null;
+ }
+ context = null;
plugin = null;
}
@@ -47,4 +65,23 @@ public class Activator implements BundleActivator {
return plugin;
}
+ protected LogService getLogService() {
+ if (logServiceTracker == null) {
+ logServiceTracker = new ServiceTracker(this.context, LogService.class.getName(), null);
+ logServiceTracker.open();
+ }
+ logService = (LogService) logServiceTracker.getService();
+ if (logService == null)
+ logService = new SystemLogService(PLUGIN_ID);
+ return logService;
+ }
+
+ public void log(IStatus status) {
+ if (logService == null)
+ logService = getLogService();
+
+ if (logService != null)
+ logService.log(LogHelper.getLogCode(status), LogHelper.getLogMessage(status), status.getException());
+ }
+
}
diff --git a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/IDEntry.java b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/IDEntry.java
index 589dbccc7..e9cbf372b 100644
--- a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/IDEntry.java
+++ b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/IDEntry.java
@@ -12,6 +12,8 @@
package org.eclipse.ecf.internal.storage;
import java.util.*;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.ecf.core.identity.*;
import org.eclipse.ecf.storage.IDStoreException;
import org.eclipse.ecf.storage.IIDEntry;
@@ -23,6 +25,11 @@ import org.eclipse.osgi.util.NLS;
*/
public class IDEntry implements IIDEntry {
+ /**
+ *
+ */
+ private static final String DELIMITER = ":"; //$NON-NLS-1$
+
private final ISecurePreferences prefs;
private final String ASSOCIATE_IDENTRIES_NODE = "associates"; //$NON-NLS-1$
@@ -49,7 +56,7 @@ public class IDEntry implements IIDEntry {
private String createAssociateName(IIDEntry entry) throws IDStoreException {
ISecurePreferences prefs = entry.getPreferences();
- return prefs.parent().name() + ":" + prefs.name(); //$NON-NLS-1$
+ return prefs.parent().name() + DELIMITER + prefs.name();
}
private ISecurePreferences getNamespaceRoot() {
@@ -65,7 +72,7 @@ public class IDEntry implements IIDEntry {
}
private IIDEntry createAssociateFromName(String name) throws IDStoreException {
- int index = name.indexOf(":"); //$NON-NLS-1$
+ int index = name.indexOf(DELIMITER);
if (index == -1)
throw new IDStoreException("Associate ID not well-formed"); //$NON-NLS-1$
try {
@@ -109,8 +116,7 @@ public class IDEntry implements IIDEntry {
IIDEntry associateEntry = createAssociateFromName(childrenNames[i]);
results.add(associateEntry);
} catch (IDStoreException e) {
- // LOG
- //Activator.getDefault().log();
+ Activator.getDefault().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, "Unable to create associate ID", e)); //$NON-NLS-1$
}
}
return (IIDEntry[]) results.toArray(new IIDEntry[] {});

Back to the top