Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-03-12 18:27:25 +0000
committerrescobar2010-03-12 18:27:25 +0000
commit205aa057fa925d37a3a5375aa8418b9567e99c6d (patch)
treed33f80b9f727c479b8031aeb352494c38ad9878d /plugins/org.eclipse.osee.framework.plugin.core
parent0e6d2b595cfb4d54eccdf3479e7c5d74d9c736a5 (diff)
downloadorg.eclipse.osee-205aa057fa925d37a3a5375aa8418b9567e99c6d.tar.gz
org.eclipse.osee-205aa057fa925d37a3a5375aa8418b9567e99c6d.tar.xz
org.eclipse.osee-205aa057fa925d37a3a5375aa8418b9567e99c6d.zip
Diffstat (limited to 'plugins/org.eclipse.osee.framework.plugin.core')
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/.classpath7
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/.project28
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/META-INF/MANIFEST.MF22
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/build.properties9
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/plugin.xml10
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/ActivatorHelper.java81
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/CorePreferences.java38
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/EclipseErrorLogLogger.java37
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IActionReportingService.java20
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IActionable.java25
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IWorkbenchUser.java27
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IWorkbenchUserService.java22
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/OseeActivator.java51
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/config/JiniLookupGroupConfig.java65
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/config/NonEclipseManifestHeader.java235
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/internal/CorePreferenceInitializer.java42
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/internal/PluginCoreActivator.java54
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/BundleResourceFinder.java53
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ClassFinder.java34
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ClassServer.java292
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ClassServerPermissions.java45
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/PathResourceFinder.java238
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ResourceFinder.java37
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/resources/classserver.properties15
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/Command.java83
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/NativeCommand.java56
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/NativeTaskMaster.java68
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/Parameter.java35
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/TaskRequester.java76
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/TaskServerThread.java206
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/AIFile.java70
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/CatchAndReleaseJob.java52
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/ExportClassLoader.java141
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/ExtensionDefinedObjects.java131
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/ExtensionPoints.java116
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/IExceptionableRunnable.java23
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/Jobs.java53
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/OseeData.java120
39 files changed, 2729 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/.classpath b/plugins/org.eclipse.osee.framework.plugin.core/.classpath
new file mode 100644
index 00000000000..8a8f1668cdc
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/.project b/plugins/org.eclipse.osee.framework.plugin.core/.project
new file mode 100644
index 00000000000..ea36ab1093e
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.framework.plugin.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.osee.framework.plugin.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..a8020f2dc2e
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Fri Mar 28 14:00:57 GMT 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.plugin.core/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..a8471cff279
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Plug-in for common eclipse-based non-ui code (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.framework.plugin.core;singleton:=true
+Bundle-Version: 0.9.2.qualifier
+Bundle-Activator: org.eclipse.osee.framework.plugin.core.internal.PluginCoreActivator
+Bundle-Vendor: Eclipse.org
+Require-Bundle: org.eclipse.core.runtime
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.osee.framework.plugin.core,
+ org.eclipse.osee.framework.plugin.core.config,
+ org.eclipse.osee.framework.plugin.core.server,
+ org.eclipse.osee.framework.plugin.core.server.resources,
+ org.eclipse.osee.framework.plugin.core.server.task,
+ org.eclipse.osee.framework.plugin.core.util
+Import-Package: org.eclipse.core.resources,
+ org.eclipse.osee.framework.core.exception,
+ org.eclipse.osee.framework.core.operation,
+ org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.framework.jdk.core.util.io,
+ org.eclipse.osee.framework.logging
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/build.properties b/plugins/org.eclipse.osee.framework.plugin.core/build.properties
new file mode 100644
index 00000000000..07b21305d68
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/build.properties
@@ -0,0 +1,9 @@
+bin.includes = META-INF/,\
+ schema/,\
+ plugin.xml,\
+ .
+output.library.jar = bin/
+jars.compile.order = library.jar,\
+ .
+source.. = src/
+output.. = bin/
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/plugin.xml b/plugins/org.eclipse.osee.framework.plugin.core/plugin.xml
new file mode 100644
index 00000000000..a56889f9ab8
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/plugin.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.osee.framework.plugin.core.internal.CorePreferenceInitializer">
+ </initializer>
+ </extension>
+</plugin>
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/ActivatorHelper.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/ActivatorHelper.java
new file mode 100644
index 00000000000..a82cc278a49
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/ActivatorHelper.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class ActivatorHelper {
+ private static Map<String, Plugin> pluginIdToOseePlugin = new HashMap<String, Plugin>();
+ private final BundleContext context;
+ private final Plugin plugin;
+
+ /**
+ *
+ */
+ public ActivatorHelper(BundleContext context, Plugin plugin) {
+ pluginIdToOseePlugin.put(plugin.getBundle().getSymbolicName(), plugin);
+ this.context = context;
+ this.plugin = plugin;
+ }
+
+ /**
+ * returns a File to from the default persistent storage area provided for the bundle by the Framework (.ie.)
+ * myworkspace/.metadata/.plugins/org.eclipse.pde.core/myPlugin/...
+ */
+ public File getPluginStoreFile(String path) {
+ return context.getDataFile(path);
+ }
+
+ /**
+ * finds a resource in the plugin bundle and writes it out to the default persistent storage area as a regular file
+ *
+ * @param path
+ * @return Return plugin file reference
+ * @throws IOException
+ */
+ public File getPluginFile(String path) throws IOException {
+ File result = getPluginStoreFile(path);
+ result.getParentFile().mkdirs();
+ InputStream inStream = getInputStream(path);
+ Lib.inputStreamToFile(inStream, result);
+ if (!result.exists()) {
+ return null;
+ }
+ return result;
+ }
+
+ public InputStream getInputStream(String resource) throws IOException {
+ return plugin.getBundle().getEntry(resource).openStream();
+ }
+
+ public List<URL> getInputStreams(String directory, String pattern, boolean recurse) throws IOException {
+ Enumeration<?> enumeration = plugin.getBundle().findEntries(directory, pattern, recurse);
+ List<URL> inputs = new ArrayList<URL>();
+ while (enumeration.hasMoreElements()) {
+ inputs.add(((URL) enumeration.nextElement()));
+ }
+ return inputs;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/CorePreferences.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/CorePreferences.java
new file mode 100644
index 00000000000..627c3f77b6a
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/CorePreferences.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import org.eclipse.osee.framework.jdk.core.util.Network;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.plugin.core.internal.PluginCoreActivator;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class CorePreferences {
+
+ private CorePreferences() {
+ }
+
+ public static final String INETADDRESS_KEY = PluginCoreActivator.PLUGIN_ID + ".preferences.InetAddressDefault";
+
+ @SuppressWarnings("deprecation")
+ public static InetAddress getDefaultInetAddress() throws UnknownHostException {
+ String inetaddress =
+ PluginCoreActivator.getInstance().getPluginPreferences().getString(CorePreferences.INETADDRESS_KEY);
+ if (Strings.isValid(inetaddress)) {
+ return InetAddress.getByName(inetaddress);
+ }
+ return Network.getValidIP();
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/EclipseErrorLogLogger.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/EclipseErrorLogLogger.java
new file mode 100644
index 00000000000..68b703036be
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/EclipseErrorLogLogger.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core;
+
+import java.util.logging.Level;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osee.framework.logging.ILoggerListener;
+import org.eclipse.osee.framework.plugin.core.internal.PluginCoreActivator;
+
+public class EclipseErrorLogLogger implements ILoggerListener {
+
+ public EclipseErrorLogLogger() {
+ }
+
+ public void log(String loggerName, Level level, String message, Throwable th) {
+ int statusLevel = 0;
+ if (level.intValue() >= Level.SEVERE.intValue()) {
+ statusLevel = Status.ERROR;
+ } else if (level.intValue() >= Level.WARNING.intValue()) {
+ statusLevel = Status.WARNING;
+ } else if (level.intValue() >= Level.INFO.intValue()) {
+ statusLevel = Status.INFO;
+ } else {
+ return;
+ }
+ PluginCoreActivator.getInstance().getLog().log(new Status(statusLevel, loggerName, statusLevel, message, th));
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IActionReportingService.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IActionReportingService.java
new file mode 100644
index 00000000000..e132f66ed98
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IActionReportingService.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IActionReportingService {
+
+ public void report(String actionableItem, String desc) throws Exception;
+
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IActionable.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IActionable.java
new file mode 100644
index 00000000000..fad7ad3e196
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IActionable.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core;
+
+/**
+ * @author Donald G. Dunne
+ */
+public interface IActionable {
+
+ /**
+ * Provide description over and above the viewpart name and version to be used by ATS
+ *
+ * @return description
+ */
+ public String getActionDescription();
+
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IWorkbenchUser.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IWorkbenchUser.java
new file mode 100644
index 00000000000..4285a435587
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IWorkbenchUser.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IWorkbenchUser {
+
+ String getEmail() throws OseeCoreException;
+
+ String getName() throws OseeCoreException;
+
+ String getUserID() throws OseeCoreException;
+
+ boolean isActive() throws OseeCoreException;
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IWorkbenchUserService.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IWorkbenchUserService.java
new file mode 100644
index 00000000000..d95ceb737ce
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/IWorkbenchUserService.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IWorkbenchUserService {
+
+ IWorkbenchUser getUser() throws OseeCoreException;
+
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/OseeActivator.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/OseeActivator.java
new file mode 100644
index 00000000000..bb8213034ee
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/OseeActivator.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core;
+
+import java.io.File;
+import java.io.IOException;
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class OseeActivator extends Plugin {
+ private ActivatorHelper helper;
+
+ /**
+ * The constructor.
+ */
+ protected OseeActivator() {
+ super();
+ }
+
+ /**
+ * finds a resource in the plugin bundle and writes it out to the default persistent storage area as a regular file
+ *
+ * @param path
+ * @return Return plugin file reference
+ * @throws IOException
+ */
+ public File getPluginFile(String path) throws IOException {
+ return helper.getPluginFile(path);
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ helper = new ActivatorHelper(context, this);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/config/JiniLookupGroupConfig.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/config/JiniLookupGroupConfig.java
new file mode 100644
index 00000000000..f80c0630c89
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/config/JiniLookupGroupConfig.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.config;
+
+import java.util.logging.Level;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.osee.framework.jdk.core.util.OseeProperties;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author Michael P. Masterson
+ */
+public class JiniLookupGroupConfig {
+
+ private JiniLookupGroupConfig() {
+ }
+
+ public static String[] getOseeJiniServiceGroups() {
+ String[] serviceGroups = null;
+ try {
+ Bundle bundle = Platform.getBundle("org.eclipse.osee.framework.jini");
+ serviceGroups = new String[1];
+ serviceGroups[0] = (String) bundle.getHeaders().get("Bundle-Version");
+ } catch (Exception ex) {
+ OseeLog.log(JiniLookupGroupConfig.class, Level.INFO, "Error getting bundle org.eclipse.osee.framework.jini");
+ }
+
+ String filterGroups = OseeProperties.getOseeJiniServiceGroups();
+ if (filterGroups != null && filterGroups.length() > 0) {
+ String[] values = filterGroups.split(",");
+ for (int index = 0; index < values.length; index++) {
+ values[index] = values[index].trim();
+ }
+ serviceGroups = values;
+ }
+
+ if (serviceGroups == null || serviceGroups.length == 0) {
+ OseeLog.log(JiniLookupGroupConfig.class, Level.SEVERE,
+ "[-D" + filterGroups + "] was not set.\n" + "Please enter the Jini Group this service register with.");
+ serviceGroups = new String[] {"NO_LOOKUP_GROUP_SPECIFIED"};
+ } else {
+ String toStore = "";
+ for (int index = 0; index < serviceGroups.length; index++) {
+ toStore += serviceGroups[index];
+ if (index + 1 < serviceGroups.length) {
+ toStore += ",";
+ }
+ }
+ OseeLog.log(JiniLookupGroupConfig.class, Level.INFO, "osee.jini.lookup.groups: " + toStore);
+ OseeProperties.setOseeJiniServiceGroups(toStore);
+ }
+
+ return serviceGroups;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/config/NonEclipseManifestHeader.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/config/NonEclipseManifestHeader.java
new file mode 100644
index 00000000000..ce863a3dbf5
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/config/NonEclipseManifestHeader.java
@@ -0,0 +1,235 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.config;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.util.Dictionary;
+import java.util.Enumeration;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class NonEclipseManifestHeader extends Dictionary<Object, Object> {
+
+ Object[] headers;
+ Object[] values;
+ int size = 0;
+
+ private NonEclipseManifestHeader(int initialCapacity) {
+ headers = new Object[initialCapacity];
+ values = new Object[initialCapacity];
+ }
+
+ private int getIndex(Object key) {
+ boolean stringKey = key instanceof String;
+ for (int i = 0; i < size; i++) {
+ if (headers[i].equals(key)) {
+ return i;
+ }
+ if (stringKey && headers[i] instanceof String && ((String) headers[i]).equalsIgnoreCase((String) key)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public Object remove(Object key) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Object put(Object key, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public synchronized Object get(Object key) {
+ int i = -1;
+ if ((i = getIndex(key)) != -1) {
+ return values[i];
+ }
+ return null;
+ }
+
+ private Object remove(int remove) {
+ Object removed = values[remove];
+ for (int i = remove; i < size; i++) {
+ if (i == headers.length - 1) {
+ headers[i] = null;
+ values[i] = null;
+ } else {
+ headers[i] = headers[i + 1];
+ values[i] = values[i + 1];
+ }
+ }
+ if (remove < size) {
+ size--;
+ }
+ return removed;
+ }
+
+ public synchronized Object set(Object key, Object value) {
+ if (key instanceof String) {
+ key = ((String) key).intern();
+ }
+ int i = getIndex(key);
+ if (value == null) /* remove */
+ {
+ if (i != -1) {
+ return remove(i);
+ }
+ } else /* put */
+ {
+ if (i != -1) {
+ throw new IllegalArgumentException("Duplicate key found" + key);
+ }
+ add(key, value);
+ }
+ return null;
+ }
+
+ private void add(Object header, Object value) {
+ if (size == headers.length) {
+ // grow the arrays
+ Object[] newHeaders = new Object[headers.length + 10];
+ Object[] newValues = new Object[values.length + 10];
+ System.arraycopy(headers, 0, newHeaders, 0, headers.length);
+ System.arraycopy(values, 0, newValues, 0, values.length);
+ headers = newHeaders;
+ values = newValues;
+ }
+ headers[size] = header;
+ values[size] = value;
+ size++;
+ }
+
+ public static Dictionary<Object, Object> parseManifest(InputStream in) throws Exception {
+ try {
+ NonEclipseManifestHeader headers = new NonEclipseManifestHeader(10);
+ BufferedReader br;
+ try {
+ br = new BufferedReader(new InputStreamReader(in, "UTF8")); //$NON-NLS-1$
+ } catch (UnsupportedEncodingException e) {
+ br = new BufferedReader(new InputStreamReader(in));
+ }
+
+ String header = null;
+ StringBuffer value = new StringBuffer(256);
+ boolean firstLine = true;
+
+ while (true) {
+ String line = br.readLine();
+ /*
+ * The java.util.jar classes in JDK 1.3 use the value of the last encountered manifest
+ * header. So we do the same to emulate this behavior. We no longer throw a
+ * BundleException for duplicate manifest headers.
+ */
+
+ if (line == null || line.length() == 0) /* EOF or empty line */
+ {
+ if (!firstLine) /* flush last line */
+ {
+ headers.set(header, null); /* remove old attribute,if present */
+ headers.set(header, value.toString().trim());
+ }
+ break; /* done processing main attributes */
+ }
+
+ if (line.charAt(0) == ' ') /* continuation */
+ {
+ if (firstLine) /* if no previous line */
+ {
+ throw new Exception("Invalid Space at line: " + line);
+ }
+ value.append(line.substring(1));
+ continue;
+ }
+
+ if (!firstLine) {
+ headers.set(header, null); /* remove old attribute,if present */
+ headers.set(header, value.toString().trim());
+ value.setLength(0); /* clear StringBuffer */
+ }
+
+ int colon = line.indexOf(':');
+ if (colon == -1) /* no colon */
+ {
+ throw new Exception("Invalid Colon at line: " + line);
+ }
+ header = line.substring(0, colon).trim();
+ value.append(line.substring(colon + 1));
+ firstLine = false;
+ }
+ return headers;
+ } catch (IOException e) {
+ throw new Exception("IO Exception: ", e);
+ } finally {
+ try {
+ in.close();
+ } catch (IOException ee) {
+ }
+ }
+ }
+
+ @Override
+ public synchronized Enumeration<Object> keys() {
+ return new ArrayEnumeration(headers, size);
+ }
+
+ @Override
+ public synchronized Enumeration<Object> elements() {
+ return new ArrayEnumeration(values, size);
+ }
+
+ @Override
+ public synchronized int size() {
+ return size;
+ }
+
+ @Override
+ public synchronized boolean isEmpty() {
+ return size == 0;
+ }
+
+ @Override
+ public String toString() {
+ String toReturn = "[";
+ for (int index = 0; index < size; index++) {
+ toReturn += headers[index] + "=" + values[index] + ",";
+ }
+ toReturn += "]";
+ return toReturn;
+ }
+
+ class ArrayEnumeration implements Enumeration<Object> {
+ private final Object[] array;
+ int cur = 0;
+
+ public ArrayEnumeration(Object[] array, int size) {
+ this.array = new Object[size];
+ System.arraycopy(array, 0, this.array, 0, this.array.length);
+ }
+
+ public boolean hasMoreElements() {
+ return cur < array.length;
+ }
+
+ public Object nextElement() {
+ return array[cur++];
+ }
+
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/internal/CorePreferenceInitializer.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/internal/CorePreferenceInitializer.java
new file mode 100644
index 00000000000..2257b3c71e2
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/internal/CorePreferenceInitializer.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.osee.framework.plugin.core.internal;
+
+import java.net.UnknownHostException;
+import java.util.logging.Level;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.osee.framework.jdk.core.util.Network;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.plugin.core.CorePreferences;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class CorePreferenceInitializer extends AbstractPreferenceInitializer {
+
+ @Override
+ public void initializeDefaultPreferences() {
+ Preferences store = PluginCoreActivator.getInstance().getPluginPreferences();
+ try {
+ String defaultNetworkValue = Network.getValidIP().getHostAddress();
+ store.setDefault(CorePreferences.INETADDRESS_KEY, defaultNetworkValue);
+ String value = store.getString(CorePreferences.INETADDRESS_KEY);
+ if (!Strings.isValid(value)) {
+ store.setValue(CorePreferences.INETADDRESS_KEY, store.getDefaultString(CorePreferences.INETADDRESS_KEY));
+ }
+ } catch (UnknownHostException ex) {
+ OseeLog.log(PluginCoreActivator.class, Level.SEVERE, "Error initializing default inet address key", ex);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/internal/PluginCoreActivator.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/internal/PluginCoreActivator.java
new file mode 100644
index 00000000000..3b1ba352631
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/internal/PluginCoreActivator.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.internal;
+
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.plugin.core.EclipseErrorLogLogger;
+import org.eclipse.osee.framework.plugin.core.OseeActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class PluginCoreActivator extends OseeActivator {
+ public static final String PLUGIN_ID = "org.eclipse.osee.framework.plugin.core";
+
+ private static PluginCoreActivator pluginInstance;
+ private ServiceTracker packageAdminTracker;
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ pluginInstance = this;
+
+ OseeLog.registerLoggerListener(new EclipseErrorLogLogger());
+
+ packageAdminTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null);
+ packageAdminTracker.open();
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ packageAdminTracker.close();
+ }
+
+ public static PluginCoreActivator getInstance() {
+ return pluginInstance;
+ }
+
+ public PackageAdmin getPackageAdmin() {
+ return (PackageAdmin) packageAdminTracker.getService();
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/BundleResourceFinder.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/BundleResourceFinder.java
new file mode 100644
index 00000000000..00345c8b39f
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/BundleResourceFinder.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.server;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.logging.Level;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.plugin.core.internal.PluginCoreActivator;
+import org.osgi.framework.Bundle;
+
+public class BundleResourceFinder extends ResourceFinder {
+ private ArrayList<Bundle> bundles;
+
+ public BundleResourceFinder(String[] bundlenames) {
+ bundles = new ArrayList<Bundle>();
+ for (int i = 0; i < bundlenames.length; i++) {
+ Bundle bundle = Platform.getBundle(bundlenames[i]);
+ if (bundle != null) {
+ bundles.add(Platform.getBundle(bundlenames[i]));
+ } else {
+ OseeLog.log(PluginCoreActivator.class, Level.SEVERE, String.format(
+ "Unable to load bundle [ %s ]. This bundle was not added to the list in BundleResourceFinder.",
+ bundlenames[i]));
+ }
+ }
+ }
+
+ public byte[] find(String path) throws IOException {
+ for (int i = 0; i < bundles.size(); i++) {
+ URL url = bundles.get(i).getResource(path);
+ if (url != null) {
+ return getBytes(url.openStream());
+ }
+ }
+ return null;
+ }
+
+ public void dispose() {
+ bundles.clear();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ClassFinder.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ClassFinder.java
new file mode 100644
index 00000000000..20d6452dd21
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ClassFinder.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.server;
+
+import java.io.IOException;
+import org.eclipse.osee.framework.plugin.core.util.ExportClassLoader;
+import org.osgi.framework.Bundle;
+
+public class ClassFinder extends ResourceFinder {
+
+ private final ExportClassLoader loader = new ExportClassLoader();
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public byte[] find(String path) throws IOException {
+ Bundle bundle = loader.getExportingBundle(path);
+ if (bundle != null) {
+ return getBytes(bundle.getResource(path).openStream());
+ }
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ClassServer.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ClassServer.java
new file mode 100644
index 00000000000..6161ab46581
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ClassServer.java
@@ -0,0 +1,292 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.server;
+
+import java.io.BufferedInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.plugin.core.internal.PluginCoreActivator;
+
+public class ClassServer extends Thread {
+ private ServerSocket server;
+ private URL hostName;
+ private List<ResourceFinder> resourceFinders;
+
+ private ExecutorService socketThreads;
+
+ /**
+ * Construct a server
+ *
+ * @param port the port to use
+ * @param address
+ * @throws IOException if the server socket cannot be created
+ */
+ public ClassServer(int port, InetAddress address) throws IOException {
+ server = new ServerSocket(port, 50, address);
+ socketThreads = Executors.newCachedThreadPool(new ThreadFactory() {
+
+ public Thread newThread(Runnable arg0) {
+ Thread th = new Thread(arg0, "ClassServer Task");
+ th.setDaemon(true);
+ return th;
+ }
+ });
+ hostName = new URL("http://" + address.getHostAddress() + ":" + port + "/");
+
+ this.setName("OSEE ClassServer");
+ this.resourceFinders = new ArrayList<ResourceFinder>();
+ }
+
+ public void addResourceFinder(ResourceFinder finder) {
+ this.resourceFinders.add(finder);
+ }
+
+ /**
+ * Spawn a thread for each connection requesting service
+ */
+ public void run() {
+
+ String msg = "ClassServer started [";
+
+ msg += "port ";
+ msg += Integer.toString(getPort());
+ msg += "]";
+
+ OseeLog.log(PluginCoreActivator.class, Level.INFO, msg);
+ try {
+ while (true) {
+ Socket socket = server.accept();
+ socketThreads.submit(new Task(socket));
+ }
+ } catch (IOException e) {
+ synchronized (this) {
+ if (!server.isClosed()) {
+ OseeLog.log(PluginCoreActivator.class, Level.SEVERE, "accepting connection", e);
+ terminate();
+ OseeLog.log(PluginCoreActivator.class, Level.WARNING, "ClassServer Terminated");
+ }
+ }
+ }
+ }
+
+ /**
+ * Terminate Server - perform cleanup
+ */
+ public synchronized void terminate() {
+ try {
+ server.close();
+ } catch (IOException e) {
+ // do nothing
+ }
+ final Iterator<ResourceFinder> iter = resourceFinders.iterator();
+ while (iter.hasNext()) {
+ final ResourceFinder resFinder = iter.next();
+ resFinder.dispose();
+ }
+
+ }
+
+ /** Returns the port on which this server is listening. */
+ public int getPort() {
+ return server.getLocalPort();
+ }
+
+ /** Read up to CRLF, return false if EOF */
+ private static boolean readLine(InputStream in, StringBuffer buf) throws IOException {
+ while (true) {
+ int c = in.read();
+ if (c < 0) return buf.length() > 0;
+ if (c == '\r') {
+ in.mark(1);
+ c = in.read();
+ if (c != '\n') in.reset();
+ return true;
+ }
+ if (c == '\n') return true;
+ buf.append((char) c);
+ }
+ }
+
+ /** Read the request/response and return the initial line. */
+ private static String getInput(Socket sock, boolean isRequest) throws IOException {
+ BufferedInputStream in = new BufferedInputStream(sock.getInputStream(), 256);
+ StringBuffer buf = new StringBuffer(80);
+ do {
+ if (!readLine(in, buf)) return null;
+ } while (isRequest && buf.length() == 0);
+ String initial = buf.toString();
+ do {
+ buf.setLength(0);
+ } while (readLine(in, buf) && buf.length() > 0);
+ return initial;
+ }
+
+ /**
+ * This method provides a way for subclasses to be notified when a file has been completely downloaded.
+ *
+ * @param fp The path to the file that was downloaded.
+ */
+ protected void fileDownloaded(String fp, InetAddress addr) {
+ }
+
+ public URL getHostName() {
+ return hostName;
+ }
+
+ private class Task implements Runnable {// Thread {
+
+ private Socket sock;
+
+ public Task(Socket sock) {
+ this.sock = sock;
+ // setDaemon(true);
+ }
+
+ /**
+ * Get bytes from path Returns the bytes of the requested file, or null if not found.
+ */
+ private byte[] getBytes(String path) throws IOException {
+ byte[] bytes = null;
+ for (int i = 0; i < resourceFinders.size(); i++) {
+ ResourceFinder finder = resourceFinders.get(i);
+ bytes = finder.find(path);
+ if (bytes != null) {
+ return bytes;
+ }
+ }
+ OseeLog.log(PluginCoreActivator.class, Level.INFO, "requested file: '" + path + "' was not found.");
+ return null;
+ }
+
+ /** Parse % HEX HEX from s starting at i */
+ private char decode(String s, int i) {
+ return (char) Integer.parseInt(s.substring(i + 1, i + 3), 16);
+ }
+
+ private String getCanonicalizedPath(String path) {
+ try {
+ if (path.regionMatches(true, 0, "http://", 0, 7)) {
+ int i = path.indexOf('/', 7);
+ if (i < 0)
+ path = "/";
+ else
+ path = path.substring(i);
+ }
+ for (int i = path.indexOf('%'); i >= 0; i = path.indexOf('%', i + 1)) {
+ char c = decode(path, i);
+ int n = 3;
+ if ((c & 0x80) != 0) {
+ switch (c >> 4) {
+ case 0xC:
+ case 0xD:
+ n = 6;
+ c = (char) (((c & 0x1F) << 6) | (decode(path, i + 3) & 0x3F));
+ break;
+ case 0xE:
+ n = 9;
+ c =
+ (char) (((c & 0x0f) << 12) | ((decode(path, i + 3) & 0x3F) << 6) | (decode(path, i + 6) & 0x3F));
+ break;
+ default:
+ return null;
+ }
+ }
+ path = path.substring(0, i) + c + path.substring(i + n);
+ }
+ } catch (Exception e) {
+ return null;
+ }
+ if (path.length() == 0 || path.charAt(0) != '/') return null;
+ return path.substring(1);
+ }
+
+ public void run() {
+ try {
+ DataOutputStream out = new DataOutputStream(sock.getOutputStream());
+ String req;
+ try {
+ req = getInput(sock, true);
+ } catch (Exception e) {
+ OseeLog.log(PluginCoreActivator.class, Level.INFO, "reading request", e);
+ return;
+ }
+ if (req == null) return;
+ if (req.startsWith("SHUTDOWN *")) {
+ out.writeBytes("HTTP/1.0 403 Forbidden\r\n\r\n");
+ out.flush();
+ return;
+ }
+ String[] args = null;
+ boolean get = req.startsWith("GET ");
+ if (!get && !req.startsWith("HEAD ")) {
+ OseeLog.log(PluginCoreActivator.class, Level.FINE, "bad request \"{0}\" from {1}:{2}");
+ out.writeBytes("HTTP/1.0 400 Bad Request\r\n\r\n");
+ out.flush();
+ return;
+ }
+ String path = req.substring(get ? 4 : 5);
+ int i = path.indexOf(' ');
+ if (i > 0) path = path.substring(0, i);
+ path = getCanonicalizedPath(path);
+ if (path == null) {
+ OseeLog.log(PluginCoreActivator.class, Level.FINE, "bad request \"{0}\" from {1}:{2}");
+ out.writeBytes("HTTP/1.0 400 Bad Request\r\n\r\n");
+ out.flush();
+ return;
+ }
+ if (args != null) args[0] = path;
+ OseeLog.log(PluginCoreActivator.class, Level.FINER,
+ get ? "{0} requested from {1}:{2}" : "{0} probed from {1}:{2}");
+ byte[] bytes;
+ try {
+ bytes = getBytes(path);
+ } catch (Exception e) {
+ OseeLog.log(PluginCoreActivator.class, Level.WARNING, "getting bytes", e);
+ out.writeBytes("HTTP/1.0 500 Internal Error\r\n\r\n");
+ out.flush();
+ return;
+ }
+ if (bytes == null) {
+ OseeLog.log(PluginCoreActivator.class, Level.FINE, String.format("%s not found", path));
+ out.writeBytes("HTTP/1.0 404 Not Found\r\n\r\n");
+ out.flush();
+ return;
+ }
+ out.writeBytes("HTTP/1.0 200 OK\r\n");
+ out.writeBytes("Content-Length: " + bytes.length + "\r\n");
+ out.writeBytes("Content-Type: application/java\r\n\r\n");
+ if (get) out.write(bytes);
+ out.flush();
+ if (get) fileDownloaded(path, sock.getInetAddress());
+ } catch (Exception e) {
+ OseeLog.log(PluginCoreActivator.class, Level.INFO, "writing response", e);
+ } finally {
+ try {
+ sock.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ClassServerPermissions.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ClassServerPermissions.java
new file mode 100644
index 00000000000..5f508a954d5
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ClassServerPermissions.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.server;
+
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.util.ArrayList;
+import java.util.Enumeration;
+
+/**
+ * @author Andrew M. Finkbeiner
+ */
+public class ClassServerPermissions extends PermissionCollection {
+
+ private static final long serialVersionUID = 7752469678730039503L;
+ private ArrayList<Permission> list;
+
+ public ClassServerPermissions() {
+ list = new ArrayList<Permission>();
+ }
+
+ public void add(Permission permission) {
+ list.add(permission);
+ }
+
+ public boolean implies(Permission permission) {
+ for (int i = 0; i < list.size(); i++) {
+ if (list.get(i).implies(permission)) return true;
+ }
+ return false;
+ }
+
+ public Enumeration<Permission> elements() {
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/PathResourceFinder.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/PathResourceFinder.java
new file mode 100644
index 00000000000..d3b505bbe5e
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/PathResourceFinder.java
@@ -0,0 +1,238 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.server;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FilePermission;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.plugin.core.internal.PluginCoreActivator;
+
+public class PathResourceFinder extends ResourceFinder {
+
+ private final HashSet<JarFile> jars = new HashSet<JarFile>(128);
+ private final HashSet<String> dirs = new HashSet<String>(128);
+ private final HashMap<String, JarFile[]> map = new HashMap<String, JarFile[]>(128);
+ private boolean trees;
+ private ClassServerPermissions perm;
+ private static final int NUMBER_OF_FILE_READ_ATTEMPTS = 20;
+
+ public PathResourceFinder(String[] dirsToAdd, boolean trees) {
+ this.trees = trees;
+ perm = new ClassServerPermissions();
+ if (dirsToAdd != null) addPaths(dirsToAdd);
+ }
+
+ public byte[] find(String path) throws IOException {
+
+ int i = path.indexOf('/');
+ if (i > 0) {
+ JarFile[] jfs = map.get(path.substring(0, i));
+ if (jfs != null) {
+ String jpath = path.substring(i + 1);
+ for (i = 0; i < jfs.length; i++) {
+ JarEntry je = jfs[i].getJarEntry(jpath);
+ if (je != null) return getBytes(jfs[i].getInputStream(je), je.getSize());
+ }
+ }
+ }
+ synchronized (jars) {
+ Iterator<JarFile> it = jars.iterator();
+ while (it.hasNext()) {
+ JarFile jar = it.next();
+ JarEntry je = jar.getJarEntry(path);
+ if (je != null) {
+ return getBytes(jar.getInputStream(je), je.getSize());
+ }
+ }
+ }
+ boolean exists = false;
+ File f = null;
+ synchronized (dirs) {
+ for (int j = 0; j < NUMBER_OF_FILE_READ_ATTEMPTS; j++) { // we'll retry in case there is a
+ // compile going on
+ Iterator<String> it = dirs.iterator();
+ while (it.hasNext()) {
+ String dirString = it.next();
+ f = new File(dirString + File.separatorChar + path.replace('/', File.separatorChar));
+ if (f.exists()) {
+ exists = true;
+ break;
+ }
+ }
+ if (!exists) {
+ try {
+ synchronized (this) {
+ this.wait(1000);
+ }
+ System.err.println(String.format("trying to find :%s %d", path, j));
+ } catch (InterruptedException ex) {
+ }
+ } else {
+ break;
+ }
+ }
+ }
+
+ if (exists) {
+ if (perm.implies(new FilePermission(f.getPath(), "read"))) {
+ try {
+ return getBytes(new FileInputStream(f), f.length());
+ } catch (FileNotFoundException e) {
+ }
+ }
+ }
+ return null;
+ }
+
+ public void addPaths(String[] paths) {
+
+ for (int i = 0; i < paths.length; i++) {
+ String path = paths[i];
+
+ if (path.startsWith("file:\\")) path = path.substring(6);
+
+ if (path.endsWith(".jar")) {
+ try {
+ synchronized (jars) {
+ jars.add(new JarFile(new File(path)));
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ continue;
+ }
+ } else {
+ if (dirs.add(path)) perm.add(new FilePermission(path + File.separator + '-', "read"));
+ }
+
+ if (trees) {
+ File fdir = new File(path);
+ String[] files = fdir.list();
+ if (files != null) {
+ try {
+ URL base = fdir.toURI().toURL();
+ for (int j = 0; j < files.length; j++) {
+ String jar = files[j];
+ if (jar.endsWith(".jar") || jar.endsWith(".zip")) {
+ ArrayList<JarFile> jfs = new ArrayList<JarFile>(10);
+ try {
+ addJar(jar, jfs, base);
+ map.put(jar.substring(0, jar.length() - 4), jfs.toArray(new JarFile[jfs.size()]));
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+ } catch (MalformedURLException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+
+ /** Add transitive Class-Path JARs to jfs. */
+ private void addJar(String jar, ArrayList<JarFile> jfs, URL base) throws IOException {
+ base = new URL(base, jar);
+ jar = base.getFile().replace('/', File.separatorChar);
+ for (int i = jfs.size(); --i >= 0;) {
+ if (jar.equals(jfs.get(i).getName())) return;
+ }
+
+ JarFile jf = new JarFile(jar);
+ jfs.add(jf);
+ try {
+ Manifest man = jf.getManifest();
+ if (man == null) return;
+ Attributes attrs = man.getMainAttributes();
+ if (attrs == null) return;
+ String val = attrs.getValue(Attributes.Name.CLASS_PATH);
+ if (val == null) return;
+ for (StringTokenizer st = new StringTokenizer(val); st.hasMoreTokens();) {
+ addJar(st.nextToken(), jfs, base);
+ }
+ } catch (IOException ex) {
+ jfs.remove(jf);
+ jf.close();
+ throw ex;
+ }
+ }
+
+ /**
+ * Finds the jarFile if it is being served.
+ *
+ * @param name The name of the jar file
+ * @return The jar represented as a File, or null if the jar was not found.
+ */
+ public File getJarFile(String name) {
+ File jarFileReturn = null;
+ synchronized (jars) {
+ Iterator<JarFile> it = jars.iterator();
+ while (it.hasNext()) {
+ JarFile jarFile = it.next();
+ if (jarFile.getName().endsWith(File.separator + name)) {
+ jarFileReturn = (new File(jarFile.getName()));
+ break;
+ }
+ }
+ }
+ return jarFileReturn;
+ }
+
+ public void removeJarFile(String name) {
+ synchronized (jars) {
+ Iterator<JarFile> it = jars.iterator();
+ while (it.hasNext()) {
+ JarFile jarFile = it.next();
+ if (jarFile.getName().endsWith(File.separator + name)) {
+ try {
+ OseeLog.log(PluginCoreActivator.class, Level.INFO, "removing JAR file " + name);
+ jarFile.close();
+ } catch (IOException ex) {
+ // do nothing
+ }
+ it.remove();
+ return;
+ }
+ }
+ }
+ }
+
+ public void dispose() {
+ synchronized (jars) {
+ OseeLog.log(PluginCoreActivator.class, Level.INFO, "disposing path resource finder's cached JAR files");
+ Iterator<JarFile> it = jars.iterator();
+ while (it.hasNext()) {
+ JarFile jarFile = it.next();
+ try {
+ jarFile.close();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ jars.clear();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ResourceFinder.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ResourceFinder.java
new file mode 100644
index 00000000000..8c8456b25d7
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/ResourceFinder.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.server;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public abstract class ResourceFinder {
+
+ public abstract byte[] find(String path) throws IOException;
+
+ public byte[] getBytes(InputStream in, long length) throws IOException {
+ DataInputStream din = new DataInputStream(in);
+ byte[] bytes = new byte[(int) length];
+ try {
+ din.readFully(bytes);
+ } finally {
+ din.close();
+ }
+ return bytes;
+ }
+
+ public byte[] getBytes(InputStream stream) throws IOException {
+ return getBytes(stream, stream.available());
+ }
+
+ public abstract void dispose();
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/resources/classserver.properties b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/resources/classserver.properties
new file mode 100644
index 00000000000..d9c2d56f85e
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/resources/classserver.properties
@@ -0,0 +1,15 @@
+
+
+
+classserver.jar:{0}
+classserver.inputerror:exception reading request from {0}:{1}
+classserver.request:{0} requested from {1}:{2}
+classserver.probe:{0} probed from {1}:{2}
+classserver.badrequest:bad request "{0}" from {1}:{2}
+classserver.shutdown:shutdown request from {0}:{1}
+classserver.notfound:{0} not found
+classserver.usage:[-port <port>] [-dir <dir>] [-stoppable] [-verbose] [-trees]\
+\n or\
+\n[-port <port>] -stop
+classserver.forbidden:stop request denied
+classserver.status:HTTP status code: {0} {1}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/Command.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/Command.java
new file mode 100644
index 00000000000..ae1e9835046
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/Command.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.server.task;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public abstract class Command {
+ private final int commandId;
+
+ public Command(int commandId) {
+ this.commandId = commandId;
+ }
+
+ public void sendCommand(ObjectOutputStream toServer, Object... parameters) throws IOException {
+ toServer.writeInt(commandId);
+ toServer.writeByte((byte) parameters.length); // number of parameters
+
+ for (Object parameter : parameters) {
+ writeParameter(toServer, parameter);
+ }
+
+ toServer.flush();
+ }
+
+ private void writeParameter(ObjectOutputStream toServer, Object parameter) throws IOException {
+ if (parameter instanceof Boolean) {
+ toServer.writeByte((byte) Parameter.BOOLEAN.ordinal());
+ toServer.writeByte(((Boolean) parameter) ? 1 : 0);
+ }
+ if (parameter instanceof Byte) {
+ toServer.writeByte((byte) Parameter.BYTE.ordinal());
+ toServer.writeByte((Byte) parameter);
+ }
+ if (parameter instanceof Short) {
+ toServer.writeByte((byte) Parameter.SHORT.ordinal());
+ toServer.writeShort((Short) parameter);
+ }
+ if (parameter instanceof Character) {
+ toServer.writeByte((byte) Parameter.CHAR.ordinal());
+ toServer.writeChar((Character) parameter);
+ }
+ if (parameter instanceof Integer) {
+ toServer.writeByte((byte) Parameter.INT.ordinal());
+ toServer.writeInt((Integer) parameter);
+ }
+ if (parameter instanceof Long) {
+ toServer.writeByte((byte) Parameter.LONG.ordinal());
+ toServer.writeLong((Long) parameter);
+ }
+ if (parameter instanceof Float) {
+ toServer.writeByte((byte) Parameter.FLOAT.ordinal());
+ toServer.writeFloat((Float) parameter);
+ }
+ if (parameter instanceof Double) {
+ toServer.writeByte((byte) Parameter.DOUBLE.ordinal());
+ toServer.writeDouble((Double) parameter);
+ }
+ if (parameter instanceof String) {
+ toServer.writeByte((byte) Parameter.STRING.ordinal());
+ toServer.writeUTF((String) parameter);
+ }
+ /* if (parameter.getClass().isArray()) {
+ for (Object obj : parameter) {
+ toServer.writeShort(Array.getLength(obj)); // write array length
+ writeParameter(toServer, obj);
+ }
+ }*/
+ }
+
+ public abstract Object invoke(Object... parameters) throws Exception;
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/NativeCommand.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/NativeCommand.java
new file mode 100644
index 00000000000..ff85b1a6efc
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/NativeCommand.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.server.task;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class NativeCommand extends Command {
+ public static final int NATIVE_CMD_ID = 0;
+
+ public NativeCommand() {
+ super(NATIVE_CMD_ID);
+ }
+
+ public void sendNativeCommand(ObjectOutputStream toServer, String[] callAndArgs) throws IOException {
+ Object[] params = new Object[callAndArgs.length];
+ System.arraycopy(callAndArgs, 0, params, 0, params.length);
+ sendCommand(toServer, params);
+ }
+
+ public Object invoke(Object... parameters) throws IOException {
+ String[] callAndArgs = new String[parameters.length];
+ System.arraycopy(parameters, 0, callAndArgs, 0, parameters.length);
+
+ Process process = Runtime.getRuntime().exec(callAndArgs);
+ BufferedReader inError = new BufferedReader(new InputStreamReader(process.getErrorStream()));
+ BufferedReader inOutput = new BufferedReader(new InputStreamReader(process.getInputStream()));
+
+ ArrayList<String> lines = new ArrayList<String>();
+ String line = null;
+ while ((line = inOutput.readLine()) != null) {
+ lines.add(line);
+ }
+ inOutput.close();
+
+ while ((line = inError.readLine()) != null) {
+ lines.add(line);
+ }
+ inError.close();
+ return lines.toArray(new String[lines.size()]);
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/NativeTaskMaster.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/NativeTaskMaster.java
new file mode 100644
index 00000000000..c8f46e3eaac
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/NativeTaskMaster.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.server.task;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class NativeTaskMaster {
+ private boolean listening;
+ private ServerSocket serverSocket;
+
+ public static void main(String[] args) {
+ if (args.length != 1) {
+ System.err.println("Usage: java NativeTaskMaster <port>");
+ return;
+ }
+
+ try {
+ NativeTaskMaster app = new NativeTaskMaster(Integer.parseInt(args[0]));
+ app.listen();
+ } catch (NumberFormatException ex) {
+ System.err.println(ex);
+ return;
+ }
+ }
+
+ /**
+ * @param port
+ */
+ public NativeTaskMaster(int port) {
+ super();
+ this.listening = true;
+
+ if (port < 1) {
+ throw new IllegalArgumentException("port argument must be a natural number");
+ }
+ try {
+ serverSocket = new ServerSocket(port);
+ } catch (IOException ex) {
+ System.err.println("Could not listen on port: " + port + ".");
+ return;
+ }
+ }
+
+ private void listen() {
+ try {
+ while (listening) {
+ Socket socket = serverSocket.accept(); // wait for the next connection
+ new Thread(new TaskServerThread(587289473, socket)).start();
+ }
+ serverSocket.close();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/Parameter.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/Parameter.java
new file mode 100644
index 00000000000..f5dc24e2dea
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/Parameter.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.server.task;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public enum Parameter {
+ BOOLEAN,
+ BYTE,
+ SHORT,
+ CHAR,
+ INT,
+ LONG,
+ FLOAT,
+ DOUBLE,
+ STRING,
+ BOOLEAN_ARRAY,
+ BYTE_ARRAY,
+ SHORT_ARRAY,
+ CHAR_ARRAY,
+ INT_ARRAY,
+ LONG_ARRAY,
+ FLOAT_ARRAY,
+ DOUBLE_ARRAY,
+ STRING_ARRAY
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/TaskRequester.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/TaskRequester.java
new file mode 100644
index 00000000000..4b144424c06
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/TaskRequester.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.server.task;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.ObjectOutputStream;
+import java.net.InetAddress;
+import java.net.Socket;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class TaskRequester {
+ private NativeCommand nativeCommand;
+ private Socket taskSocket;
+ private BufferedReader fromServer;
+ private ObjectOutputStream toServer;
+
+ public TaskRequester(String machine, int port) throws IOException {
+ if (port < 1) {
+ throw new IllegalArgumentException("port argument must be a natural number");
+ }
+ if (machine.equals("")) {
+ throw new IllegalArgumentException("machine must be specified");
+ }
+
+ taskSocket = new Socket(machine, port);
+ fromServer = new BufferedReader(new InputStreamReader(taskSocket.getInputStream()));
+ toServer = new ObjectOutputStream(taskSocket.getOutputStream());
+ toServer.writeInt(587289473); // magic number
+ nativeCommand = new NativeCommand();
+ }
+
+ public void close() {
+ try {
+ toServer.close();
+ taskSocket.close();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private void executeCommand(String[] callAndArgs) throws IOException {
+ nativeCommand.sendNativeCommand(toServer, callAndArgs);
+ }
+
+ private static void printUsage() {
+ System.err.println("Usage: java TaskRequester <cmd> [args]");
+ }
+
+ public static void main(String[] args) throws IOException {
+ if (args.length < 1) {
+ printUsage();
+ return;
+ }
+
+ TaskRequester app = new TaskRequester(InetAddress.getLocalHost().getHostName(), 8140);
+ app.executeCommand(args);
+
+ String line = null;
+ while ((line = app.fromServer.readLine()) != null) {
+ System.out.printf(line);
+ }
+ app.close();
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/TaskServerThread.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/TaskServerThread.java
new file mode 100644
index 00000000000..7086c418681
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/server/task/TaskServerThread.java
@@ -0,0 +1,206 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.server.task;
+
+import static org.eclipse.osee.framework.plugin.core.server.task.Parameter.BYTE;
+import static org.eclipse.osee.framework.plugin.core.server.task.Parameter.CHAR;
+import static org.eclipse.osee.framework.plugin.core.server.task.Parameter.DOUBLE;
+import static org.eclipse.osee.framework.plugin.core.server.task.Parameter.INT;
+import static org.eclipse.osee.framework.plugin.core.server.task.Parameter.LONG;
+import static org.eclipse.osee.framework.plugin.core.server.task.Parameter.SHORT;
+import static org.eclipse.osee.framework.plugin.core.server.task.Parameter.STRING;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.PrintWriter;
+import java.net.Socket;
+import java.util.HashMap;
+
+/**
+ * Protocol 2-byte 1-byte 1-byte n-bytes <command_id> <n_params> [<type_id> <parma_value>]* For each type, the protocol
+ * explicitly defines the format of the paramater value.
+ *
+ * @author Ryan D. Brooks
+ */
+public class TaskServerThread implements Runnable {
+ private int magicNumber;
+ private Socket socket = null;
+ private ObjectInputStream inFromClient;
+ private PrintWriter out;
+ private HashMap<Integer, Command> commands;
+ private boolean running;
+
+ public TaskServerThread(int magicNumber, Socket socket) {
+ this.socket = socket;
+ this.magicNumber = magicNumber;
+ this.commands = new HashMap<Integer, Command>();
+ running = true;
+ }
+
+ public void run() {
+ try {
+ out = new PrintWriter(socket.getOutputStream(), true);
+ inFromClient = new ObjectInputStream(socket.getInputStream()); // this is a blocking call
+
+ int code = inFromClient.readInt();
+ if (code != magicNumber) {
+ System.out.println("look what you did!");
+ return;
+ }
+ while (running) {
+ try {
+ int commandId = inFromClient.readUnsignedShort();
+ Object[] parameters = parseParameters();
+
+ Command command = commands.get(commandId);
+ sendResultToClient(command.invoke(parameters));
+ } catch (Exception ex) {
+ System.out.println(ex);
+ }
+ }
+
+ inFromClient.close();
+ out.close();
+ socket.close();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * @param result
+ */
+ private void sendResultToClient(Object result) {
+ if (result == null) {
+ return;
+ }
+ if (result instanceof Object[]) {
+
+ }
+
+ }
+
+ public void registerCommand(int commandId, Command command) {
+ commands.put(commandId, command);
+ }
+
+ /*
+ * Protocol
+ * 2-byte 1-byte 1-byte n-bytes
+ * <command_id> <n_params> [<type_id> <param_value>]
+ */
+ private Object[] parseParameters() throws IOException {
+ int parametersCount = inFromClient.readUnsignedByte();
+ if (parametersCount == 0) {
+ return null;
+ }
+ Object[] parameters = new Object[parametersCount];
+
+ for (int i = 0; i < parametersCount; i++) {
+ parameters[i] = readNextParameter();
+ }
+ return parameters;
+ }
+
+ private Object readNextParameter() throws IOException {
+ return readNextParameter(Parameter.values()[inFromClient.readUnsignedByte()]);
+ }
+
+ /**
+ * type type_id format boolean 0 unsigned byte byte 1 signed byte short 2 signed 2-bytes char 3 unsigned 2-bytes int
+ * 4 signed 4-bytes long 5 signed 8-bytes float 6 4-bytes double 7 8-bytes string 8 unsigned 2-byte len, n-bytes char
+ * data boolean_array 9 unsigned 2-byte array element count, element data byte_array 10 unsigned 2-byte array element
+ * count, element data short_array 11 unsigned 2-byte array element count, element data char_array 12 unsigned 2-byte
+ * array element count, element data int_array 13 unsigned 2-byte array element count, element data long_array 14
+ * unsigned 2-byte array element count, element data float_array 15 unsigned 2-byte array element count, element data
+ * double_array 16 unsigned 2-byte array element count, element data string_array 17 unsigned 2-byte array element
+ * count, element data
+ *
+ * @param typeId
+ * @return Return next parameter reference
+ */
+ private Object readNextParameter(Parameter typeId) {
+ try {
+ switch (typeId) {
+ case BOOLEAN:
+ return inFromClient.readBoolean();
+ case BYTE:
+ return inFromClient.readByte();
+ case SHORT:
+ return inFromClient.readShort();
+ case CHAR:
+ return inFromClient.readChar();
+ case INT:
+ return inFromClient.readInt();
+ case LONG:
+ return inFromClient.readLong();
+ case FLOAT:
+ return inFromClient.readFloat();
+ case DOUBLE:
+ return inFromClient.readDouble();
+ case STRING:
+ return inFromClient.readUTF();
+ case BYTE_ARRAY:
+ byte[] byteArray = new byte[inFromClient.readUnsignedShort()];
+ for (int i = 0; i < byteArray.length; i++) {
+ byteArray[i] = (Byte) readNextParameter(BYTE);
+ }
+ return byteArray;
+ case SHORT_ARRAY:
+ short[] shortArray = new short[inFromClient.readUnsignedShort()];
+ for (int i = 0; i < shortArray.length; i++) {
+ shortArray[i] = (Short) readNextParameter(SHORT);
+ }
+ return shortArray;
+ case CHAR_ARRAY:
+ char[] charArray = new char[inFromClient.readUnsignedShort()];
+ for (int i = 0; i < charArray.length; i++) {
+ charArray[i] = (Character) readNextParameter(CHAR);
+ }
+ return charArray;
+ case INT_ARRAY:
+ int[] intArray = new int[inFromClient.readUnsignedShort()];
+ for (int i = 0; i < intArray.length; i++) {
+ intArray[i] = (Integer) readNextParameter(INT);
+ }
+ return intArray;
+ case LONG_ARRAY:
+ long[] longArray = new long[inFromClient.readUnsignedShort()];
+ for (int i = 0; i < longArray.length; i++) {
+ longArray[i] = (Long) readNextParameter(LONG);
+ }
+ return longArray;
+ case FLOAT_ARRAY:
+ int[] floatArray = new int[inFromClient.readUnsignedShort()];
+ for (int i = 0; i < floatArray.length; i++) {
+ floatArray[i] = (Integer) readNextParameter(INT);
+ }
+ return floatArray;
+ case DOUBLE_ARRAY:
+ double[] doubleArray = new double[inFromClient.readUnsignedShort()];
+ for (int i = 0; i < doubleArray.length; i++) {
+ doubleArray[i] = (Double) readNextParameter(DOUBLE);
+ }
+ return doubleArray;
+ case STRING_ARRAY:
+ String[] stringArray = new String[inFromClient.readUnsignedShort()];
+ for (int i = 0; i < stringArray.length; i++) {
+ stringArray[i] = (String) readNextParameter(STRING);
+ }
+ return stringArray;
+ default:
+ throw new IllegalArgumentException("invalid parameter type id");
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/AIFile.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/AIFile.java
new file mode 100644
index 00000000000..bc469f69769
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/AIFile.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.jdk.core.util.io.Streams;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public final class AIFile {
+
+ private AIFile() {
+ }
+
+ public static void writeToFile(IFile file, InputStream in) throws OseeCoreException {
+ try {
+ if (file.exists()) {
+ file.setCharset("UTF-8", new NullProgressMonitor());
+ file.setContents(in, true, false, null); // steam will be closed before return
+ } else {
+ file.create(in, true, null);
+ in.close();
+ }
+ } catch (CoreException ex) {
+ throw new OseeCoreException(ex);
+ } catch (IOException ex) {
+ throw new OseeCoreException(ex);
+ }
+ }
+
+ public static void writeToFile(IFile file, String string) throws OseeCoreException {
+ writeToFile(file, string, "UTF-8");
+ }
+
+ public static void writeToFile(IFile file, String string, String charcode) throws OseeCoreException {
+ try {
+ writeToFile(file, Streams.convertStringToInputStream(string, charcode));
+ } catch (UnsupportedEncodingException ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ }
+
+ public static IFile constructIFile(String fullPath) {
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IFile[] files = workspaceRoot.findFilesForLocation(Path.fromOSString(fullPath));
+ if (files == null || files.length == 0) {
+ return null;
+ }
+ return workspaceRoot.findFilesForLocation(Path.fromOSString(fullPath))[0];
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/CatchAndReleaseJob.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/CatchAndReleaseJob.java
new file mode 100644
index 00000000000..a657e876f5e
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/CatchAndReleaseJob.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.util;
+
+import java.util.logging.Level;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class CatchAndReleaseJob extends Job {
+ private final IExceptionableRunnable runnable;
+ private final Class<?> clazz;
+ private final String pluginId;
+
+ /**
+ * @param name
+ * @param runnable
+ * @param logger
+ * @param pluginId
+ */
+ public CatchAndReleaseJob(String name, IExceptionableRunnable runnable, Class<?> clazz, String pluginId) {
+ super(name);
+ this.runnable = runnable;
+ this.clazz = clazz;
+ this.pluginId = pluginId;
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ runnable.run(monitor);
+ } catch (Exception ex) {
+ String message = ex.getLocalizedMessage() == null ? ex.toString() : ex.getLocalizedMessage();
+ OseeLog.log(clazz, Level.SEVERE, ex);
+ return new Status(Status.ERROR, pluginId, Status.OK, message, ex);
+ }
+ return Status.OK_STATUS;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/ExportClassLoader.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/ExportClassLoader.java
new file mode 100644
index 00000000000..7289d3cd30b
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/ExportClassLoader.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.util;
+
+import java.util.HashMap;
+import org.eclipse.osee.framework.plugin.core.internal.PluginCoreActivator;
+import org.osgi.framework.Bundle;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * @author Ken J. Aguilar
+ */
+public class ExportClassLoader extends ClassLoader {
+
+ private static ExportClassLoader exportClassloaderInstance;
+ private final PackageAdmin packageAdmin;
+ private final HashMap<String, Bundle> cache = new HashMap<String, Bundle>(1024);
+
+ public static ExportClassLoader getInstance(){
+ if(exportClassloaderInstance == null){
+ exportClassloaderInstance = new ExportClassLoader();
+ }
+ return exportClassloaderInstance;
+ }
+
+ public ExportClassLoader(PackageAdmin packageAdmin) {
+ super(ExportClassLoader.class.getClassLoader());
+ this.packageAdmin = packageAdmin;
+ }
+
+ public ExportClassLoader()
+ {
+ this(PluginCoreActivator.getInstance().getPackageAdmin());
+ }
+
+ @Override
+ protected Class<?> findClass(String name) throws ClassNotFoundException {
+ try {
+ Bundle bundle = getExportingBundle(name);
+ if (bundle != null) {
+ return bundle.loadClass(name);
+ }
+ throw new ClassNotFoundException("could not locate a class for " + name);
+ } catch (Exception e) {
+ throw new ClassNotFoundException("could not locate a class for " + name, e);
+ }
+ }
+
+/* this helps camel find annotated classes
+
+@Override
+protected Enumeration<URL> findResources(String name) throws IOException {
+// packageAdmin.
+ Vector<URL> found = new Vector<URL>();
+ String packageName = name.replace('/', '.');
+ int index = packageName.lastIndexOf('.');
+ if(packageName.length()-1 == index){
+ packageName = packageName.substring(0, index);
+ }
+ ExportedPackage packages = packageAdmin.getExportedPackage(packageName);
+ if(packages != null){
+// Enumeration<URL> en = packages.getExportingBundle().getEntryPaths(name);
+ Bundle bundle = packages.getExportingBundle();
+ URL url = bundle.getEntry(name);
+ if(url != null){
+ URL resolved = FileLocator.resolve(url);
+ found.add(resolved);
+ System.out.println(resolved);
+ }
+ if(url == null){
+
+ }
+ if(url == null){
+ url = bundle.getEntry("/libs/");
+ File file = new File(url.getFile());
+ URL newurl = FileLocator.resolve(url);
+ file = new File(newurl.getFile());
+ if(file.isDirectory()){
+ for(File jar:file.listFiles()){
+ if(jar.getName().endsWith("jar")){
+ ZipFile zipFile = new ZipFile(jar, ZipFile.OPEN_READ);
+ ZipEntry entry = zipFile.getEntry(name);
+ if(entry != null){
+ InputStream stream = zipFile.getInputStream(entry);
+ String anotherUrl;
+ try {
+ anotherUrl = newurl.toURI().toASCIIString() + jar.getName() + "!/" + entry;
+ URL goodurl = new URL(anotherUrl);
+ found.add(goodurl);
+ System.out.println(goodurl);
+ } catch (URISyntaxException ex) {
+ ex.printStackTrace();
+ }
+
+
+ }
+ }
+ }
+ }
+ }
+// FileLocator.findEntries(bundle, path);
+// bundle.findEntries(name, filePattern, recurse)
+ return found.elements();//super.findResources(name);
+ } else {
+ return super.findResources(name);
+ }
+}
+*/
+public Bundle getExportingBundle(String name) {
+ final String pkg = name.substring(0, name.lastIndexOf('.'));
+ Bundle cachedBundle = cache.get(pkg);
+ if (cachedBundle != null && cachedBundle.getState() != Bundle.UNINSTALLED) {
+ return cachedBundle;
+ }
+ ExportedPackage[] list = packageAdmin.getExportedPackages(pkg);
+ if (list != null) {
+ for (ExportedPackage ep : list) {
+ final Bundle bundle = ep.getExportingBundle();
+ final int state = bundle.getState();
+ if (state == Bundle.RESOLVED || state == Bundle.STARTING
+ || state == Bundle.ACTIVE || state == Bundle.STOPPING) {
+ cache.put(pkg, bundle);
+ return bundle;
+ }
+ }
+ }
+ return null;
+ }
+
+
+
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/ExtensionDefinedObjects.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/ExtensionDefinedObjects.java
new file mode 100644
index 00000000000..6d2d252f3ae
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/ExtensionDefinedObjects.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.util;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.plugin.core.OseeActivator;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ExtensionDefinedObjects<T> {
+
+ private List<T> loadedObjects;
+ private Map<String, T> objectsByID;
+
+ private final String extensionPointId;
+ private final String elementName;
+ private final String classNameAttribute;
+ private final boolean allowsEmptyOnLoad;
+
+ public ExtensionDefinedObjects(String extensionPointId, String elementName, String classNameAttribute) {
+ this(extensionPointId, elementName, classNameAttribute, false);
+ }
+
+ public ExtensionDefinedObjects(String extensionPointId, String elementName, String classNameAttribute, boolean allowsEmptyOnLoad) {
+ this.extensionPointId = extensionPointId;
+ this.elementName = elementName;
+ this.classNameAttribute = classNameAttribute;
+ this.allowsEmptyOnLoad = allowsEmptyOnLoad;
+ }
+
+ public List<T> getObjects() {
+ checkInitialized();
+ return loadedObjects;
+ }
+
+ public T getObjectById(String id) {
+ checkInitialized();
+ return objectsByID.get(id);
+ }
+
+ public Collection<String> getObjectIds() {
+ checkInitialized();
+ return objectsByID.keySet();
+ }
+
+ private synchronized void checkInitialized() {
+ if (!isInitialized()) {
+ initialize(extensionPointId, elementName, classNameAttribute);
+ }
+ }
+
+ private boolean isInitialized() {
+ return loadedObjects != null && objectsByID != null;
+ }
+
+ public synchronized void clear() {
+ if (loadedObjects != null) {
+ loadedObjects.clear();
+ loadedObjects = null;
+ }
+ if (objectsByID != null) {
+ objectsByID.clear();
+ objectsByID = null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void initialize(String extensionPointId, String elementName, String classNameAttribute) {
+ loadedObjects = new ArrayList<T>();
+ objectsByID = new HashMap<String, T>();
+ List<IConfigurationElement> elements = ExtensionPoints.getExtensionElements(extensionPointId, elementName);
+ for (IConfigurationElement element : elements) {
+ IExtension extension = (IExtension) element.getParent();
+ String identifier = extension.getUniqueIdentifier();
+ String className = element.getAttribute(classNameAttribute);
+ String bundleName = element.getContributor().getName();
+
+ if (Strings.isValid(bundleName) && Strings.isValid(className)) {
+ try {
+ Bundle bundle = Platform.getBundle(bundleName);
+ Class<?> taskClass = bundle.loadClass(className);
+ T object = null;
+ try {
+ Method getInstance = taskClass.getMethod("getInstance", new Class[] {});
+ object = (T) getInstance.invoke(null, new Object[] {});
+ } catch (Exception ex) {
+ object = (T) taskClass.newInstance();
+ }
+ if (object != null) {
+ loadedObjects.add(object);
+ objectsByID.put(identifier, object);
+ }
+ } catch (Exception ex) {
+ OseeLog.log(OseeActivator.class, Level.SEVERE, String.format("Unable to Load: [%s - %s]", bundleName,
+ className), ex);
+ }
+ }
+ }
+ if (!allowsEmptyOnLoad && loadedObjects.isEmpty()) {
+ OseeLog.log(OseeActivator.class, Level.WARNING, String.format(
+ "No Objects loaded for [%s] with element name [%s] and attribute [%s]", extensionPointId, elementName,
+ classNameAttribute));
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getObjects().toString();
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/ExtensionPoints.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/ExtensionPoints.java
new file mode 100644
index 00000000000..721c4c69260
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/ExtensionPoints.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.osee.framework.plugin.core.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Level;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.plugin.core.internal.PluginCoreActivator;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class ExtensionPoints {
+ public static List<IConfigurationElement> getExtensionElements(Plugin plugin, String extensionPointName, String elementName) {
+ Bundle bundle = plugin.getBundle();
+ return getExtensionElements(bundle.getSymbolicName() + "." + extensionPointName, elementName);
+ }
+
+ public static List<IConfigurationElement> getExtensionElements(String extensionPointId, String elementName) {
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ if (extensionRegistry == null) {
+ throw new IllegalStateException("The extension registry is unavailable");
+ }
+
+ IExtensionPoint point = extensionRegistry.getExtensionPoint(extensionPointId);
+ if (point == null) {
+ throw new IllegalArgumentException("The extension point " + extensionPointId + " does not exist");
+ }
+
+ IExtension[] extensions = point.getExtensions();
+ ArrayList<IConfigurationElement> elementsList = new ArrayList<IConfigurationElement>(extensions.length * 3);
+
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ for (IConfigurationElement element : elements) {
+ if (element.getName().equalsIgnoreCase(elementName)) {
+ elementsList.add(element);
+ }
+ }
+ }
+ return elementsList;
+ }
+
+ /**
+ * Return extension point unique ids if type extensionPointId
+ *
+ * @param extensionPointId <plugin>.Point Id
+ * @param extensionPointUniqueIds array of unique ids
+ */
+ public static List<IExtension> getExtensionsByUniqueId(String extensionPointId, Collection<String> extensionPointUniqueIds) {
+ List<IExtension> extensions = new ArrayList<IExtension>();
+ for (String entensionPointUniqueId : extensionPointUniqueIds) {
+ IExtension extension = Platform.getExtensionRegistry().getExtension(entensionPointUniqueId);
+ if (extension == null) {
+ OseeLog.log(PluginCoreActivator.class, Level.SEVERE,
+ "Unable to locate extension [" + entensionPointUniqueId + "]");
+ } else {
+ String thisPointId = extension.getExtensionPointUniqueIdentifier();
+ if (extensionPointId.equals(thisPointId)) {
+ extensions.add(extension);
+ } else {
+ OseeLog.log(PluginCoreActivator.class, Level.SEVERE,
+ "Unknown extension id [" + thisPointId + "] from extension [" + entensionPointUniqueId + "]");
+ }
+ }
+ }
+ return extensions;
+ }
+
+ public static List<String> getExtensionsPointUniqueIds(String extensionPointId) {
+ List<String> extensionPointIds = new ArrayList<String>();
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(extensionPointId);
+ if (point == null) {
+ throw new IllegalArgumentException("The extension point " + extensionPointId + " does not exist");
+ }
+
+ IExtension[] extensions = point.getExtensions();
+ for (IExtension extension : extensions) {
+ extensionPointIds.add(extension.getUniqueIdentifier());
+ }
+ return extensionPointIds;
+ }
+
+ public static IConfigurationElement getExtensionElement(String extensionPointId, String elementName) {
+ List<IConfigurationElement> elements = ExtensionPoints.getExtensionElements(extensionPointId, elementName);
+
+ if (elements.size() == 0) {
+ throw new IllegalArgumentException(
+ "no elements named " + elementName + " for " + extensionPointId + " where found.");
+ }
+ if (elements.size() > 1) {
+ throw new IllegalArgumentException(
+ elements.size() + " elements named " + elementName + " for " + extensionPointId + " where found. Expected exactly one.");
+ }
+ return elements.get(0);
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/IExceptionableRunnable.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/IExceptionableRunnable.java
new file mode 100644
index 00000000000..646e7cc61ae
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/IExceptionableRunnable.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.util;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * @author Ryan D. Brooks
+ * @author Robert A. Fisher
+ */
+public interface IExceptionableRunnable {
+
+ public IStatus run(IProgressMonitor monitor) throws Exception;
+}
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/Jobs.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/Jobs.java
new file mode 100644
index 00000000000..1d20d97a42a
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/Jobs.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.util;
+
+import org.eclipse.core.runtime.jobs.IJobChangeListener;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.osee.framework.core.operation.AbstractOperation;
+import org.eclipse.osee.framework.core.operation.Operations;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public final class Jobs {
+
+ private Jobs() {
+ }
+
+ public static Job startJob(Job job, IJobChangeListener jobChangeListener) {
+ return startJob(job, true, jobChangeListener);
+ }
+
+ public static Job startJob(Job job) {
+ return startJob(job, true, null);
+ }
+
+ public static Job startJob(Job job, boolean user) {
+ return startJob(job, user, null);
+ }
+
+ public static void runInJob(String name, IExceptionableRunnable runnable, Class<?> clazz, String pluginId) {
+ runInJob(name, runnable, clazz, pluginId, true);
+ }
+
+ public static void runInJob(String name, IExceptionableRunnable runnable, Class<?> clazz, String pluginId, boolean user) {
+ startJob(new CatchAndReleaseJob(name, runnable, clazz, pluginId), user);
+ }
+
+ public static void runInJob(AbstractOperation operation, boolean user) {
+ Operations.executeAsJob(operation, user);
+ }
+
+ public static Job startJob(Job job, boolean user, IJobChangeListener jobChangeListener) {
+ return Operations.scheduleJob(job, user, Job.LONG, jobChangeListener);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/OseeData.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/OseeData.java
new file mode 100644
index 00000000000..198e452ee0a
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/OseeData.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.plugin.core.util;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.logging.Level;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.plugin.core.internal.PluginCoreActivator;
+
+/**
+ * This class provides a front end to writing files to a common osee.data directory in the workspace. This dir is
+ * invisible to Eclipse Navigator and Package Explorer. It is provided as a common repository for files that need to be
+ * created and retained by any plugin, but don't need to be visible to the user. This class does nothing more than
+ * ensure the directory is created and provide a way to get the path for other plugins to use.
+ *
+ * @author Donald G. Dunne
+ */
+public class OseeData {
+ private static final IPath workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
+ private static final String oseeDataPathName = ".osee.data";
+ private static final IPath oseeDataPath = workspacePath.append(oseeDataPathName);
+ private static final File oseeDir = oseeDataPath.toFile();
+ private static IProject project;
+
+ static {
+ if (!oseeDir.exists()) {
+ if (!oseeDir.mkdir()) {
+ OseeLog.log(PluginCoreActivator.class, Level.SEVERE, "Can't create " + oseeDataPathName + " dir.");
+ }
+ }
+ createProject();
+ }
+
+ public static IPath getPath() {
+ return oseeDataPath;
+ }
+
+ public static File getFile(String filename) {
+ return new File(oseeDir, filename);
+ }
+
+ public static IFile getIFile(String fileName) {
+ return project.getFile(fileName);
+ }
+
+ public static IFile getIFile(String fileName, InputStream in) throws OseeCoreException {
+ return getIFile(fileName, in, false);
+ }
+
+ public static IFile getIFile(String fileName, InputStream in, boolean overwrite) throws OseeCoreException {
+ IFile iFile = project.getFile(fileName);
+ if (!iFile.exists() || overwrite) {
+ AIFile.writeToFile(iFile, in);
+ }
+ return iFile;
+ }
+
+ public static File getWorkspaceFile(String path) {
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ return new File(workspaceRoot.getFile(new Path(path)).getLocation().toString());
+ }
+
+ private static boolean createProject() {
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ project = workspaceRoot.getProject(oseeDataPathName);
+ if (!project.exists()) {
+ try {
+ project.create(null);
+ } catch (CoreException ex) {
+ ex.printStackTrace();
+ return false;
+ }
+ }
+ try {
+ project.open(null);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * @return Returns the project.
+ */
+ public static IProject getProject() {
+ return project;
+ }
+
+ public static IFolder getFolder(String name) throws OseeCoreException {
+ try {
+ IFolder folder = project.getFolder(name);
+
+ if (!folder.exists()) {
+ folder.create(true, true, null);
+ }
+ return folder;
+ } catch (CoreException ex) {
+ throw new OseeCoreException(ex);
+ }
+ }
+} \ No newline at end of file

Back to the top