diff options
author | afinkbein | 2010-03-22 18:29:18 +0000 |
---|---|---|
committer | afinkbein | 2010-03-22 18:29:18 +0000 |
commit | 76544a17ce0553ff37d24123a1da4e68367a1228 (patch) | |
tree | 637a5be21d714ae93ecd1c528c8f3207155805f6 | |
parent | fd0489fb094e555a76ebe0ae859177fd503ab05a (diff) | |
download | org.eclipse.osee-76544a17ce0553ff37d24123a1da4e68367a1228.tar.gz org.eclipse.osee-76544a17ce0553ff37d24123a1da4e68367a1228.tar.xz org.eclipse.osee-76544a17ce0553ff37d24123a1da4e68367a1228.zip |
20 files changed, 1418 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.ote.server/.classpath b/plugins/org.eclipse.osee.ote.server/.classpath new file mode 100644 index 00000000000..8a8f1668cdc --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/.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.ote.server/.project b/plugins/org.eclipse.osee.ote.server/.project new file mode 100644 index 00000000000..97e73224a74 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.ote.server</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.ote.server/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.osee.ote.server/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..11df6222f5b --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Wed Mar 17 14:47:24 MST 2010
+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.compliance=1.6
+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.ote.server/.settings/org.eclipse.pde.core.prefs b/plugins/org.eclipse.osee.ote.server/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 00000000000..0bb84977985 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,4 @@ +#Wed Mar 17 14:47:24 MST 2010
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/plugins/org.eclipse.osee.ote.server/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ote.server/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..574c114d399 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/META-INF/MANIFEST.MF @@ -0,0 +1,42 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: OTE Server Launching Plug-in (Incubation) +Bundle-SymbolicName: org.eclipse.osee.ote.server;singleton:=true +Bundle-Version: 0.9.3.qualifier +Bundle-Description: OTE Server +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Import-Package: net.jini.core.lookup, + net.jini.id, + org.apache.activemq.broker, + org.eclipse.core.runtime;version="3.4.0", + org.eclipse.osee.connection.service, + org.eclipse.osee.framework.core.exception, + org.eclipse.osee.framework.core.util, + org.eclipse.osee.framework.jdk.core.reportdata, + org.eclipse.osee.framework.jdk.core.util, + org.eclipse.osee.framework.jdk.core.util.network, + org.eclipse.osee.framework.jini.service.interfaces, + org.eclipse.osee.framework.logging, + org.eclipse.osee.framework.messaging, + org.eclipse.osee.framework.messaging.services, + org.eclipse.osee.framework.messaging.services.messages, + org.eclipse.osee.framework.plugin.core.util, + org.eclipse.osee.ote.connection.jini, + org.eclipse.osee.ote.core, + org.eclipse.osee.ote.core.cmd, + org.eclipse.osee.ote.core.environment, + org.eclipse.osee.ote.core.environment.console, + org.eclipse.osee.ote.core.environment.interfaces, + org.eclipse.osee.ote.core.environment.status, + org.eclipse.osee.ote.core.framework.command, + org.eclipse.osee.ote.core.model, + org.eclipse.osee.ote.message, + org.eclipse.osee.ote.message.instrumentation, + org.eclipse.osee.ote.message.interfaces, + org.osgi.framework;version="1.5.0", + org.osgi.service.packageadmin;version="1.2.0", + org.osgi.util.tracker;version="1.4.0" +Bundle-Activator: org.eclipse.osee.ote.server.internal.Activator +Export-Package: org.eclipse.osee.ote.server +Bundle-Vendor: Eclipse.org diff --git a/plugins/org.eclipse.osee.ote.server/build.properties b/plugins/org.eclipse.osee.ote.server/build.properties new file mode 100644 index 00000000000..41eb6ade2b4 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/build.properties @@ -0,0 +1,4 @@ +source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/OteServiceStarter.java b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/OteServiceStarter.java new file mode 100644 index 00000000000..3aee4b2a8ff --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/OteServiceStarter.java @@ -0,0 +1,19 @@ +/*
+ * Created on Mar 21, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.server;
+
+import org.eclipse.osee.connection.service.IServiceConnector;
+import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironmentServiceConfig;
+
+public interface OteServiceStarter {
+
+ public void start(IServiceConnector serviceSideConnector, ITestEnvironmentServiceConfig config, PropertyParamter propertyParameter, String environmentFactoryClass) throws Exception;
+
+ public void start(IServiceConnector serviceSideConnector, ITestEnvironmentServiceConfig config, PropertyParamter propertyParameter, TestEnvironmentFactory factory) throws Exception;
+
+ public void stop() throws Exception;
+
+}
diff --git a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/PropertyParamter.java b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/PropertyParamter.java new file mode 100644 index 00000000000..4d0e86d6d01 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/PropertyParamter.java @@ -0,0 +1,52 @@ +/*
+ * Created on Mar 17, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.server;
+
+/**
+ * @author Andrew M. Finkbeiner
+ */
+public class PropertyParamter {
+ private final String type;
+ private final String version;
+ private final String comment;
+ private final String station;
+ private final boolean useJiniLookup;
+ private final boolean isLocalConnector;
+
+ public PropertyParamter(String version, String comment, String station, String type, boolean useJiniLookup, boolean isLocalConnector) {
+ this.version = version;
+ this.comment = comment;
+ this.station = station;
+ this.type = type;
+ this.useJiniLookup = useJiniLookup;
+ this.isLocalConnector = isLocalConnector;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public String getStation() {
+ return station;
+ }
+
+ public boolean isLocalConnector() {
+ return isLocalConnector;
+ }
+
+ public boolean useJiniLookup() {
+ return useJiniLookup;
+ }
+
+}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/TestEnvironmentFactory.java b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/TestEnvironmentFactory.java new file mode 100644 index 00000000000..63ab65439cf --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/TestEnvironmentFactory.java @@ -0,0 +1,13 @@ +/*
+ * Created on Mar 17, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.server;
+
+import org.eclipse.osee.ote.core.environment.interfaces.IRuntimeLibraryManager;
+import org.eclipse.osee.ote.message.MessageSystemTestEnvironment;
+
+public interface TestEnvironmentFactory {
+ MessageSystemTestEnvironment createEnvironment(IRuntimeLibraryManager runtimeLibraryManager) throws Throwable;
+}
diff --git a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/TestEnvironmentServiceConfigImpl.java b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/TestEnvironmentServiceConfigImpl.java new file mode 100644 index 00000000000..f01ca713e5d --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/TestEnvironmentServiceConfigImpl.java @@ -0,0 +1,76 @@ +/*
+ * Created on Feb 22, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.server;
+
+import java.lang.reflect.Constructor;
+import org.eclipse.osee.ote.core.environment.TestEnvironment;
+import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironmentServiceConfig;
+
+/**
+ * @author Andrew M. Finkbeiner
+ */
+public class TestEnvironmentServiceConfigImpl implements ITestEnvironmentServiceConfig {
+
+ private final boolean keepAliveWithNoUsers;
+ private final String title;
+ private final String name;
+ private final String outfileLocation;
+ private final Constructor<? extends TestEnvironment> constructor;
+
+ public TestEnvironmentServiceConfigImpl(boolean keepAliveWithNoUsers, String title, String name, String outfileLocation, Constructor<? extends TestEnvironment> constructor) {
+ this.keepAliveWithNoUsers = keepAliveWithNoUsers;
+ this.title = title;
+ this.name = name;
+ this.outfileLocation = outfileLocation;
+ this.constructor = constructor;
+ }
+
+ @Override
+ public Object[] getConstructorParameters() {
+ return new Object[0];
+ }
+
+ @Override
+ public Constructor<? extends TestEnvironment> getEnvironmentConstructor() {
+ return constructor;
+ }
+
+ @Override
+ public int getMaxEnvironments() {
+ return 1;
+ }
+
+ @Override
+ public int getMaxUsersPerEnvironment() {
+ return Integer.MAX_VALUE;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getOutfileLocation() {
+ return outfileLocation;
+ }
+
+ @Override
+ public String getServerTitle() {
+ return title;
+ }
+
+ @Override
+ public boolean keepEnvAliveWithNoUsers() {
+ return keepAliveWithNoUsers;
+ }
+
+ @Override
+ public boolean startEnvionrmnetOnServiceInit() {
+ return true;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/Activator.java b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/Activator.java new file mode 100644 index 00000000000..e7f952bc4f0 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/Activator.java @@ -0,0 +1,112 @@ +/*
+ * Created on Mar 17, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.server.internal;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.util.ServiceDependencyTracker;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.ote.core.environment.console.ICommandManager;
+import org.eclipse.osee.ote.core.environment.interfaces.RuntimeManagerHandler;
+import org.eclipse.osee.ote.core.environment.status.OTEStatusBoard;
+import org.eclipse.osee.ote.server.PropertyParamter;
+import org.eclipse.osee.ote.server.TestEnvironmentServiceConfigImpl;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class Activator implements BundleActivator {
+
+ private BundleContext context;
+ private ServiceTracker oteStatusBoardTracker;
+ private ServiceTracker consoleCommandtracker;
+ private ServiceDependencyTracker oteServiceTracker;
+ private ServiceDependencyTracker runtimeManagerHandler;
+ private ServiceDependencyTracker oteServiceStarterHandler;
+ private static Activator instance;
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ instance = this;
+ this.context = context;
+
+ oteStatusBoardTracker = new ServiceTracker(context, OTEStatusBoard.class.getName(), null);
+ oteStatusBoardTracker.open(true);
+
+ consoleCommandtracker =
+ new ServiceTracker(context, ICommandManager.class.getName(), null);
+ consoleCommandtracker.open(true);
+
+ runtimeManagerHandler = new ServiceDependencyTracker(context, new RuntimeManagerHandler());
+ runtimeManagerHandler.open();
+
+ oteServiceStarterHandler = new ServiceDependencyTracker(context, new OteServiceStarterCreationHandler());
+ oteServiceStarterHandler.open();
+
+ startServer();
+ }
+
+ public void startServer() throws ClassNotFoundException, SecurityException, NoSuchMethodException{
+ String oteServerFactoryClass = System.getProperty("osee.ote.server.factory.class");
+ if(oteServerFactoryClass != null){
+ String outfileLocation = System.getProperty("osee.ote.outfiles");
+ if(outfileLocation == null){
+ outfileLocation = System.getProperty("java.io.tmpdir");
+ }
+ String title = System.getProperty("osee.ote.server.title");
+ String name = System.getProperty("user.name");
+
+ TestEnvironmentServiceConfigImpl config = new TestEnvironmentServiceConfigImpl(true, title, name, outfileLocation, null);
+
+ String version = context.getBundle().getHeaders().get("Bundle-Version").toString();
+ String comment = context.getBundle().getHeaders().get("Bundle-Description").toString();
+ String station = "unknown";
+ try {
+ station = InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ boolean useJiniLookup = System.getProperty("osee.ote.use.lookup") != null;
+ boolean isLocalConnector = false;
+
+ int index = oteServerFactoryClass.indexOf('.');
+ String type = oteServerFactoryClass.substring(index > 0 ? index+1:0);
+ PropertyParamter propertyParameter = new PropertyParamter(version, comment, station, type, useJiniLookup, isLocalConnector);
+
+ oteServiceTracker = new ServiceDependencyTracker(context, new OteServiceCreationHandler(config, propertyParameter, oteServerFactoryClass));
+ oteServiceTracker.open();
+ }
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ oteStatusBoardTracker.close();
+ if(oteServiceTracker != null){
+ oteServiceTracker.close();
+ }
+ runtimeManagerHandler.close();
+ instance = null;
+ this.context = null;
+ }
+
+ static Activator getDefault(){
+ return instance;
+ }
+
+ public BundleContext getContext() {
+ return context;
+ }
+
+ public OTEStatusBoard getOteStatusBoard() {
+ return (OTEStatusBoard)oteStatusBoardTracker.getService();
+ }
+
+ public ICommandManager getCommandManager() {
+ return (ICommandManager)consoleCommandtracker.getService();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/EnvironmentCreationParameter.java b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/EnvironmentCreationParameter.java new file mode 100644 index 00000000000..4349276d999 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/EnvironmentCreationParameter.java @@ -0,0 +1,72 @@ +/*
+ * Created on Mar 17, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.server.internal;
+
+import java.io.Serializable;
+import java.rmi.server.ExportException;
+import org.eclipse.osee.connection.service.IServiceConnector;
+import org.eclipse.osee.framework.messaging.NodeInfo;
+import org.eclipse.osee.ote.core.environment.interfaces.IRuntimeLibraryManager;
+import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironment;
+import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironmentServiceConfig;
+import org.eclipse.osee.ote.message.MessageSystemTestEnvironment;
+import org.eclipse.osee.ote.server.TestEnvironmentFactory;
+/**
+ * @author Andrew M. Finkbeiner
+ */
+public class EnvironmentCreationParameter {
+ private final NodeInfo oteEmbeddedBroker;
+ private final IServiceConnector serviceConnector;
+ private final ITestEnvironmentServiceConfig config;
+ private final IRuntimeLibraryManager runtimeLibraryManager;
+ private ITestEnvironment remoteTestEnvironment;
+ private ITestEnvironment exportedRemoteTestEnvironment;
+ private final TestEnvironmentFactory factory;
+
+ /**
+ * @param runtimeLibraryManager2
+ * @param nodeInfo
+ * @param serviceSideConnector
+ * @param config2
+ * @param factory
+ */
+ public EnvironmentCreationParameter(IRuntimeLibraryManager runtimeLibraryManager, NodeInfo oteEmbeddedBroker, IServiceConnector serviceConnector, ITestEnvironmentServiceConfig config, TestEnvironmentFactory factory) {
+ this.oteEmbeddedBroker = oteEmbeddedBroker;
+ this.serviceConnector = serviceConnector;
+ this.config = config;
+ this.runtimeLibraryManager = runtimeLibraryManager;
+ this.factory = factory;
+ }
+
+ public Serializable getServerTitle() {
+ return config.getServerTitle();
+ }
+
+ public int getMaxUsersPerEnvironment() {
+ return config.getMaxUsersPerEnvironment();
+ }
+
+ public String getOutfileLocation(){
+ return config.getOutfileLocation();
+ }
+
+ public MessageSystemTestEnvironment createEnvironment() throws Throwable {
+ MessageSystemTestEnvironment testEnvironment = factory.createEnvironment(runtimeLibraryManager);
+ testEnvironment.setOteNodeInfo(oteEmbeddedBroker);
+ testEnvironment.init(serviceConnector);
+ return testEnvironment;
+ }
+
+ public ITestEnvironment createRemoteTestEnvironment(MessageSystemTestEnvironment currentEnvironment) throws ExportException {
+ remoteTestEnvironment = new RemoteTestEnvironment(currentEnvironment, serviceConnector);
+ exportedRemoteTestEnvironment = (ITestEnvironment)serviceConnector.export(remoteTestEnvironment);
+ return exportedRemoteTestEnvironment;
+ }
+
+ public IServiceConnector getServiceConnector() {
+ return serviceConnector;
+ }
+}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/MessageToolExportCustomizer.java b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/MessageToolExportCustomizer.java new file mode 100644 index 00000000000..7328e160e8a --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/MessageToolExportCustomizer.java @@ -0,0 +1,46 @@ +package org.eclipse.osee.ote.server.internal; + +import java.rmi.server.ExportException; +import java.util.logging.Level; +import org.eclipse.osee.connection.service.IServiceConnector; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.ote.message.interfaces.IRemoteMessageService; +import org.osgi.framework.ServiceReference; +import org.osgi.util.tracker.ServiceTrackerCustomizer; + +public class MessageToolExportCustomizer implements ServiceTrackerCustomizer{ + + private final IServiceConnector connector; + private IRemoteMessageService messageToolServiceInstance; + public MessageToolExportCustomizer(IServiceConnector connector) { + this.connector = connector; + } + + @Override + public Object addingService(ServiceReference reference) { + messageToolServiceInstance = (IRemoteMessageService) Activator.getDefault().getContext().getService(reference); + try { + return connector.export(messageToolServiceInstance); + } catch (ExportException e) { + OseeLog.log(MessageToolExportCustomizer.class, Level.SEVERE, "failed to export message tool service", e); + return null; + } + + } + + @Override + public void modifiedService(ServiceReference reference, Object service) { + // TODO Auto-generated method stub + + } + + @Override + public void removedService(ServiceReference reference, Object service) { + try { + connector.unexport(messageToolServiceInstance); + } catch (Exception e) { + OseeLog.log(MessageToolExportCustomizer.class, Level.WARNING, "failed to unexport message tool service", e); + } + } + +} diff --git a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/MessageToolServiceTracker.java b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/MessageToolServiceTracker.java new file mode 100644 index 00000000000..81117c2d456 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/MessageToolServiceTracker.java @@ -0,0 +1,23 @@ +package org.eclipse.osee.ote.server.internal; + +import org.eclipse.osee.ote.message.interfaces.IRemoteMessageService; +import org.osgi.util.tracker.ServiceTracker; +import org.osgi.util.tracker.ServiceTrackerCustomizer; + +public class MessageToolServiceTracker extends ServiceTracker{ + + public MessageToolServiceTracker() { + super(Activator.getDefault().getContext(), IRemoteMessageService.class.getName(), null); + } + + public MessageToolServiceTracker(ServiceTrackerCustomizer customizer) { + super(Activator.getDefault().getContext(), IRemoteMessageService.class.getName(), customizer); + } + + @Override + public IRemoteMessageService waitForService(long timeout) throws InterruptedException { + return (IRemoteMessageService) super.waitForService(timeout); + } + + +} diff --git a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteService.java b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteService.java new file mode 100644 index 00000000000..74d7e60b726 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteService.java @@ -0,0 +1,174 @@ +package org.eclipse.osee.ote.server.internal; + +import java.rmi.RemoteException; +import java.util.Collection; +import java.util.Date; +import java.util.LinkedList; +import java.util.logging.Level; +import net.jini.core.lookup.ServiceID; +import net.jini.id.Uuid; +import net.jini.id.UuidFactory; +import org.eclipse.osee.framework.jdk.core.util.EnhancedProperties; +import org.eclipse.osee.framework.jini.service.interfaces.IService; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.messaging.services.RegisteredServiceReference; +import org.eclipse.osee.ote.core.ConnectionRequestResult; +import org.eclipse.osee.ote.core.IRemoteUserSession; +import org.eclipse.osee.ote.core.OSEEPerson1_4; +import org.eclipse.osee.ote.core.ReturnStatus; +import org.eclipse.osee.ote.core.environment.BundleDescription; +import org.eclipse.osee.ote.core.environment.TestEnvironmentConfig; +import org.eclipse.osee.ote.core.environment.UserTestSessionKey; +import org.eclipse.osee.ote.core.environment.interfaces.IHostTestEnvironment; +import org.eclipse.osee.ote.core.environment.interfaces.IRuntimeLibraryManager; +import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironment; +import org.eclipse.osee.ote.message.MessageSystemTestEnvironment; +import org.eclipse.osee.ote.server.PropertyParamter; + + +public class OteService implements IHostTestEnvironment, IService { + + private final ServiceID serviceID; + private final EnhancedProperties enhancedProperties; + private MessageSystemTestEnvironment currentEnvironment; + private ITestEnvironment remoteEnvironment; + private EnvironmentCreationParameter environmentCreation; + private final IRuntimeLibraryManager runtimeLibraryManager; + private RegisteredServiceReference registeredServiceReference; + + public OteService(IRuntimeLibraryManager runtimeLibraryManager, EnvironmentCreationParameter environmentCreation, PropertyParamter parameterObject){ + this.runtimeLibraryManager = runtimeLibraryManager; + this.environmentCreation = environmentCreation; + Uuid uuid = UuidFactory.generate(); + Long lsb = Long.valueOf(uuid.getLeastSignificantBits()); + Long msb = Long.valueOf(uuid.getMostSignificantBits()); + serviceID = new ServiceID(msb.longValue(), lsb.longValue()); + + enhancedProperties = new EnhancedProperties(); + enhancedProperties.setProperty("name", environmentCreation.getServerTitle()); + enhancedProperties.setProperty("station", parameterObject.getStation()); + enhancedProperties.setProperty("version", parameterObject.getVersion()); + enhancedProperties.setProperty("type", parameterObject.getType()); + enhancedProperties.setProperty("maxUsers", Integer.toString(environmentCreation.getMaxUsersPerEnvironment())); + enhancedProperties.setProperty("comment", parameterObject.getComment()); + enhancedProperties.setProperty("date", new Date().toString()); + enhancedProperties.setProperty("group", "OSEE Test Environment"); + enhancedProperties.setProperty("owner", System.getProperty("user.name")); + } + + @Override + public byte[] getOutfileResultSummary() throws RemoteException { + return null; + } + + @Override + public EnhancedProperties getProperties() throws RemoteException { + return enhancedProperties; + } + + @Override + public ITestEnvironment[] getRemoteEnvironments() throws RemoteException { + if(isEnvironmentAvailable()){ + return new ITestEnvironment[]{remoteEnvironment}; + } else { + return new ITestEnvironment[0]; + } + } + + @Override + public ConnectionRequestResult requestEnvironment(IRemoteUserSession session, TestEnvironmentConfig config) throws RemoteException { + try { + OseeLog.log(OteService.class, Level.INFO,"received request for test environment from user " + session.getUser().getName()); + if (!isEnvironmentAvailable()){ + createEnvironment(); + + } else { + ReturnStatus status = currentEnvironment.getRuntimeManager().isRunningJarVersions(config.getJarVersions()); + if (!status.getStatus()) { + return new ConnectionRequestResult(null, null, + new ReturnStatus(String.format("Unable to connect to environment because users already connected are using different runtime jars. Connected users [%s]. %s", + currentEnvironment.getUserList().toString(), status.getMessage()), false)); + } + } + UserTestSessionKey key = currentEnvironment.addUser(session); + updateDynamicInfo(); + return new ConnectionRequestResult(remoteEnvironment, key, new ReturnStatus("Success", true)); + } catch (Throwable ex) { + OseeLog.log(OteService.class, Level.SEVERE, + "Exception while requesting environment for user " + session.getUser().getName(), ex); + throw new RemoteException("Exception while requesting environment for user ", ex); + } + } + + private void createEnvironment() throws Throwable { + currentEnvironment = environmentCreation.createEnvironment(); + remoteEnvironment = environmentCreation.createRemoteTestEnvironment(currentEnvironment); + remoteEnvironment.startup(environmentCreation.getOutfileLocation()); + } + + private boolean isEnvironmentAvailable() { + return remoteEnvironment != null; + } + + public void updateDynamicInfo() throws RemoteException { + Collection<OSEEPerson1_4> userList = new LinkedList<OSEEPerson1_4>(); + StringBuilder sb = new StringBuilder(); + if(isEnvironmentAvailable()){ + userList.addAll(remoteEnvironment.getUserList()); + } + for(OSEEPerson1_4 person:userList){ + sb.append(person.getName()); + sb.append(", "); + } + if(sb.length()>2){ + String list = sb.toString().substring(0, sb.length()-2); + environmentCreation.getServiceConnector().setProperty("user_list", list); + } else { + environmentCreation.getServiceConnector().setProperty("user_list", ""); + } + registeredServiceReference.update(); + } + + @Override + public ServiceID getServiceID() throws RemoteException { + return serviceID; + } + + @Override + public void kill() throws RemoteException { + } + + @Override + public void cleanupRuntimeBundles() throws RemoteException { + runtimeLibraryManager.cleanup(); + } + + @Override + public boolean isBundleAvailable(String symbolicName, String version, byte[] md5Digest) throws RemoteException { + return runtimeLibraryManager.isBundleAvailable(symbolicName, version, md5Digest); + } + + @Override + public void sendRuntimeBundle(Collection<BundleDescription> bundles) throws RemoteException { + try { + runtimeLibraryManager.loadBundles(bundles); + } catch (Exception ex) { + OseeLog.log(OteService.class, Level.SEVERE, ex); + throw new RemoteException(ex.getMessage()); + } + } + + @Override + public void updateRuntimeBundle(Collection<BundleDescription> bundles) throws RemoteException { + try { + runtimeLibraryManager.updateBundles(bundles); + } catch (Exception ex) { + OseeLog.log(OteService.class, Level.SEVERE, ex); + throw new RemoteException(ex.getMessage()); + } + } + + public void set(RegisteredServiceReference ref) { + this.registeredServiceReference = ref; + } +} diff --git a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteServiceCreationHandler.java b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteServiceCreationHandler.java new file mode 100644 index 00000000000..e7f47db63bf --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteServiceCreationHandler.java @@ -0,0 +1,59 @@ +/*
+ * Created on Mar 18, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.server.internal;
+
+import java.util.Map;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.ote.connection.jini.JiniServiceSideConnector;
+import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironmentServiceConfig;
+import org.eclipse.osee.ote.server.OteServiceStarter;
+import org.eclipse.osee.ote.server.PropertyParamter;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @author Andrew M. Finkbeiner
+ */
+public class OteServiceCreationHandler extends AbstractTrackingHandler {
+
+ private final static Class<?>[] SERVICE_DEPENDENCIES = new Class<?>[] {OteServiceStarter.class};
+
+ private final ITestEnvironmentServiceConfig config;
+ private final PropertyParamter propertyParameter;
+ private final String envFactoryClass;
+ private OteServiceStarter oteServiceStarter;
+
+ public OteServiceCreationHandler(ITestEnvironmentServiceConfig config, PropertyParamter propertyParameter, String envFactoryClass) {
+ this.config = config;
+ this.propertyParameter = propertyParameter;
+ this.envFactoryClass = envFactoryClass;
+ }
+
+ @Override
+ public Class<?>[] getDependencies() {
+ return SERVICE_DEPENDENCIES;
+ }
+
+ @Override
+ public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
+ oteServiceStarter = getService(OteServiceStarter.class, services);
+ try {
+ oteServiceStarter.start(new JiniServiceSideConnector(), config, propertyParameter, envFactoryClass);
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+
+ @Override
+ public void onDeActivate() {
+ try {
+ oteServiceStarter.stop();
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteServiceStarterCreationHandler.java b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteServiceStarterCreationHandler.java new file mode 100644 index 00000000000..0f824ac093c --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteServiceStarterCreationHandler.java @@ -0,0 +1,58 @@ +/*
+ * Created on Mar 18, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.server.internal;
+
+import java.util.Map;
+import java.util.logging.Level;
+import org.eclipse.osee.connection.service.IConnectionService;
+import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.messaging.MessageService;
+import org.eclipse.osee.framework.messaging.services.RemoteServiceRegistrar;
+import org.eclipse.osee.ote.core.environment.interfaces.IRuntimeLibraryManager;
+import org.eclipse.osee.ote.server.OteServiceStarter;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * @author Andrew M. Finkbeiner
+ *
+ */
+public class OteServiceStarterCreationHandler extends AbstractTrackingHandler {
+
+ private final static Class<?>[] SERVICE_DEPENDENCIES =
+ new Class<?>[] {IRuntimeLibraryManager.class, RemoteServiceRegistrar.class, MessageService.class, IConnectionService.class, PackageAdmin.class};
+ private ServiceRegistration registration;
+
+ OteServiceStarterCreationHandler(){
+ }
+
+ @Override
+ public Class<?>[] getDependencies() {
+ return SERVICE_DEPENDENCIES;
+ }
+
+ @Override
+ public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
+ RemoteServiceRegistrar remoteServiceRegistrar = getService(RemoteServiceRegistrar.class, services);
+ MessageService messageService = getService(MessageService.class, services);
+ IConnectionService connectionService = getService(IConnectionService.class, services);
+ IRuntimeLibraryManager runtimeLibraryManager = getService(IRuntimeLibraryManager.class, services);
+ PackageAdmin packateAdmin = getService(PackageAdmin.class, services);
+ try {
+ OteServiceStarterImpl oteServiceStarterImpl = new OteServiceStarterImpl(packateAdmin, runtimeLibraryManager, connectionService, remoteServiceRegistrar, messageService);
+ registration = context.registerService(OteServiceStarter.class.getName(), oteServiceStarterImpl, null);
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+
+ @Override
+ public void onDeActivate() {
+ registration.unregister();
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteServiceStarterImpl.java b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteServiceStarterImpl.java new file mode 100644 index 00000000000..93a0985821a --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteServiceStarterImpl.java @@ -0,0 +1,199 @@ +/*
+ * Created on Mar 21, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.server.internal;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.UnknownHostException;
+import java.rmi.RemoteException;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.logging.Level;
+import org.apache.activemq.broker.BrokerService;
+import org.eclipse.osee.connection.service.IConnectionService;
+import org.eclipse.osee.connection.service.IServiceConnector;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeStateException;
+import org.eclipse.osee.framework.jdk.core.util.network.PortUtil;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.messaging.MessageService;
+import org.eclipse.osee.framework.messaging.NodeInfo;
+import org.eclipse.osee.framework.messaging.OseeMessagingListener;
+import org.eclipse.osee.framework.messaging.OseeMessagingStatusCallback;
+import org.eclipse.osee.framework.messaging.ReplyConnection;
+import org.eclipse.osee.framework.messaging.services.RegisteredServiceReference;
+import org.eclipse.osee.framework.messaging.services.RemoteServiceRegistrar;
+import org.eclipse.osee.framework.messaging.services.ServiceInfoPopulator;
+import org.eclipse.osee.framework.messaging.services.messages.ServiceDescriptionPair;
+import org.eclipse.osee.framework.plugin.core.util.ExportClassLoader;
+import org.eclipse.osee.ote.core.OteBaseMessages;
+import org.eclipse.osee.ote.core.environment.interfaces.IRuntimeLibraryManager;
+import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironmentServiceConfig;
+import org.eclipse.osee.ote.server.OteServiceStarter;
+import org.eclipse.osee.ote.server.PropertyParamter;
+import org.eclipse.osee.ote.server.TestEnvironmentFactory;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * @author Andrew M. Finkbeiner
+ *
+ */
+public class OteServiceStarterImpl implements OteServiceStarter, ServiceInfoPopulator, OseeMessagingStatusCallback {
+
+
+ private final PackageAdmin packageAdmin;
+ private final IRuntimeLibraryManager runtimeLibraryManager;
+ private final IConnectionService connectionService;
+ private final RemoteServiceRegistrar remoteServiceRegistrar;
+ private final MessageService messageService;
+
+ private BrokerService brokerService;
+ private OteService service;
+ private ListenForHostRequest listenForHostRequest;
+
+ private IServiceConnector serviceSideConnector;
+
+
+ OteServiceStarterImpl(PackageAdmin packageAdmin, IRuntimeLibraryManager runtimeLibraryManager, IConnectionService connectionService, RemoteServiceRegistrar remoteServiceRegistrar, MessageService messageService ) {
+ this.packageAdmin = packageAdmin;
+ this.runtimeLibraryManager = runtimeLibraryManager;
+ this.connectionService = connectionService;
+ this.remoteServiceRegistrar = remoteServiceRegistrar;
+ this.messageService = messageService;
+ listenForHostRequest = new ListenForHostRequest();
+ }
+
+ @Override
+ public void start(IServiceConnector serviceSideConnector, ITestEnvironmentServiceConfig config, PropertyParamter propertyParameter, String environmentFactoryClass) throws Exception{
+ ExportClassLoader exportClassLoader = new ExportClassLoader(packageAdmin);
+ Class<? extends TestEnvironmentFactory> clazz = exportClassLoader.loadClass(environmentFactoryClass).asSubclass(TestEnvironmentFactory.class);
+ TestEnvironmentFactory factory = clazz.newInstance();
+ start(serviceSideConnector, config, propertyParameter, factory);
+ }
+
+ @Override
+ public void start(IServiceConnector serviceSideConnector, ITestEnvironmentServiceConfig config, PropertyParamter propertyParameter, TestEnvironmentFactory factory) throws Exception{
+ if(service != null){
+ throw new OseeStateException("An ote Server has already been started.");
+ }
+
+ this.serviceSideConnector = serviceSideConnector;
+ brokerService = new BrokerService();
+ String addressAsString = getAddress();
+ int port = PortUtil.getInstance().getValidPort();
+ String strUri = String.format("tcp://%s:%d", addressAsString, port);
+ brokerService.addConnector(strUri);
+ brokerService.setEnableStatistics(false);
+ brokerService.setBrokerName("OTEServer");
+ brokerService.setPersistent(false);
+ brokerService.setUseJmx(false);
+ brokerService.start();
+ URI uri = new URI(strUri);
+
+ NodeInfo nodeInfo = new NodeInfo("OTEEmbeddedBroker", uri);
+
+ EnvironmentCreationParameter environmentCreationParameter = new EnvironmentCreationParameter(runtimeLibraryManager, nodeInfo, serviceSideConnector, config, factory);
+
+ service = new OteService(runtimeLibraryManager,environmentCreationParameter, propertyParameter);
+
+ serviceSideConnector.init(service, service.getProperties());
+
+ if(propertyParameter.isLocalConnector() || propertyParameter.useJiniLookup()){
+ connectionService.addConnector(serviceSideConnector);
+ }
+ messageService.getDefault().subscribe(OteBaseMessages.RequestOteHost, listenForHostRequest, this);
+ RegisteredServiceReference ref = remoteServiceRegistrar.registerService("osee.ote.server", "1.0", service.getServiceID().toString(), uri, this, 60 * 3);
+ service.set(ref);
+ }
+
+ @Override
+ public void stop(){
+ if (service != null) {
+ try {
+ remoteServiceRegistrar.unregisterService("osee.ote.server", "1.0", service.getServiceID().toString());
+ } catch (RemoteException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+ if (brokerService != null){
+ try {
+ brokerService.stop();
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+ service = null;
+ brokerService = null;
+ }
+
+ private String getAddress() throws UnknownHostException {
+ InetAddress[] all = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());
+ String addressAsString = all[0].getHostAddress();
+ int local = 0;
+ for(int i = 0; i < all.length; i++){
+ if(all[i].getHostAddress().contains("192.168")){
+ local = i;
+ }
+ }
+ if(all.length > 1){
+ for(int i = 0; i < all.length; i++){
+ if(i != local){
+ addressAsString = all[i].getHostAddress();
+ break;
+ }
+ }
+ }
+ return addressAsString;
+ }
+
+ private class ListenForHostRequest extends OseeMessagingListener {
+
+ @Override
+ public void process(Object message, Map<String, Object> headers, ReplyConnection replyConnection) {
+ if (replyConnection.isReplyRequested()) {
+ try {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(message);
+ oos.writeObject(serviceSideConnector.getService());
+ replyConnection.send(baos.toByteArray(), null, OteServiceStarterImpl.this);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ } catch (IOException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void updateServiceInfo(List<ServiceDescriptionPair> serviceDescription) {
+ for (Entry<String, Serializable> entry : serviceSideConnector.getProperties().entrySet()) {
+ ServiceDescriptionPair pair = new ServiceDescriptionPair();
+ if (entry.getKey() != null && entry.getValue() != null) {
+ pair.setName(entry.getKey());
+ pair.setValue(entry.getValue().toString());
+ serviceDescription.add(pair);
+ }
+ }
+ }
+
+ @Override
+ public void fail(Throwable th) {
+ OseeLog.log(Activator.class, Level.SEVERE, th);
+ }
+
+ @Override
+ public void success() {
+ }
+
+
+}
diff --git a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/RemoteShell.java b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/RemoteShell.java new file mode 100644 index 00000000000..f13ad2f9fb3 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/RemoteShell.java @@ -0,0 +1,47 @@ +/*
+ * Created on Oct 10, 2006
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.server.internal;
+
+import java.rmi.RemoteException;
+import org.eclipse.osee.ote.core.environment.console.ConsoleShell;
+import org.eclipse.osee.ote.core.environment.console.ICommandManager;
+import org.eclipse.osee.ote.core.environment.interfaces.IRemoteCommandConsole;
+
+/**
+ * @author Ken J. Aguilar
+ */
+public class RemoteShell extends ConsoleShell implements IRemoteCommandConsole{
+
+ private static final long serialVersionUID = -4931966494670170915L;
+ private final StringBuffer buffer = new StringBuffer(32000);
+
+ public synchronized String doCommand(String line) throws RemoteException {
+ buffer.setLength(0);
+ buffer.append('>').append(line).append('\n');
+ try {
+ parseAndExecuteCmd(line);
+ } catch (Throwable t) {
+ printStackTrace(t);
+ }
+ return buffer.toString();
+ }
+
+ public RemoteShell(ICommandManager manager) {
+ super(manager);
+ }
+
+ public void println(String string) {
+ buffer.append(string).append('\n');
+ }
+
+ public void print(String string) {
+ buffer.append(string);
+ }
+
+ public void println() {
+ buffer.append('\n');
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/RemoteTestEnvironment.java b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/RemoteTestEnvironment.java new file mode 100644 index 00000000000..7742601a261 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/RemoteTestEnvironment.java @@ -0,0 +1,375 @@ +/*
+ * Created on Mar 17, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.server.internal;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.URL;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
+import org.eclipse.osee.connection.service.IServiceConnector;
+import org.eclipse.osee.framework.jdk.core.reportdata.ReportDataListener;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.messaging.Message;
+import org.eclipse.osee.ote.core.IUserSession;
+import org.eclipse.osee.ote.core.OSEEPerson1_4;
+import org.eclipse.osee.ote.core.ReturnStatus;
+import org.eclipse.osee.ote.core.cmd.Command;
+import org.eclipse.osee.ote.core.environment.UserTestSessionKey;
+import org.eclipse.osee.ote.core.environment.interfaces.IRemoteCommandConsole;
+import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironment;
+import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironmentListener;
+import org.eclipse.osee.ote.core.environment.status.IServiceStatusListener;
+import org.eclipse.osee.ote.core.framework.command.ICommandHandle;
+import org.eclipse.osee.ote.core.framework.command.ITestServerCommand;
+import org.eclipse.osee.ote.core.model.IModel;
+import org.eclipse.osee.ote.core.model.IModelListener;
+import org.eclipse.osee.ote.core.model.IModelManagerRemote;
+import org.eclipse.osee.ote.core.model.ModelKey;
+import org.eclipse.osee.ote.core.model.ModelState;
+import org.eclipse.osee.ote.message.IInstrumentationRegistrationListener;
+import org.eclipse.osee.ote.message.MessageSystemTestEnvironment;
+import org.eclipse.osee.ote.message.instrumentation.IOInstrumentation;
+import org.eclipse.osee.ote.message.interfaces.IRemoteMessageService;
+import org.eclipse.osee.ote.message.interfaces.ITestEnvironmentMessageSystem;
+
+public class RemoteTestEnvironment implements ITestEnvironmentMessageSystem {
+
+ private final MessageSystemTestEnvironment env;
+ private final IServiceConnector serviceConnector;
+ private RemoteModelManager modelManager;
+ private final MessageToolServiceTracker messageToolServiceTracker;
+ private final HashMap<IRemoteCommandConsole, RemoteShell> exportedConsoles = new HashMap<IRemoteCommandConsole, RemoteShell>(32);
+
+ public RemoteTestEnvironment(MessageSystemTestEnvironment currentEnvironment, IServiceConnector serviceConnector) {
+ this.env = currentEnvironment;
+ this.serviceConnector = serviceConnector;
+ messageToolServiceTracker = new MessageToolServiceTracker(new MessageToolExportCustomizer(serviceConnector));
+ messageToolServiceTracker.open(true);
+ }
+
+ @Override
+ public Remote getControlInterface(String controlInterfaceID) throws RemoteException {
+ Remote controlInterface = env.getControlInterface(controlInterfaceID);
+ if (controlInterface != null) {
+ try {
+ controlInterface = (Remote) serviceConnector.export(controlInterface);
+ } catch (Exception ex) {
+ OseeLog.log(RemoteTestEnvironment.class, Level.SEVERE,
+ "exception exporting control interface " + controlInterfaceID, ex);
+ throw new RemoteException("exception exporting control interface " + controlInterfaceID, ex);
+ }
+ }
+ return controlInterface;
+ }
+
+ public IOInstrumentation getIOInstrumentation(String name) throws RemoteException {
+ IOInstrumentation io = env.getIOInstrumentation(name);
+ if (io != null) {
+ try {
+ Object exported = serviceConnector.findExport(io);
+ if (exported == null) {
+ exported = serviceConnector.export(io);
+ }
+ return (IOInstrumentation) exported;
+ } catch (Exception ex) {
+ OseeLog.log(RemoteTestEnvironment.class, Level.SEVERE,
+ ex.toString(), ex);
+ throw new RemoteException("Unable to export the remote IOInstrumentation for " + name, ex);
+ }
+ }
+ throw new RemoteException("No IOInstrumentation registered for type " + name);
+ }
+
+ @Override
+ public void addInstrumentationRegistrationListener(IInstrumentationRegistrationListener listener) throws RemoteException {
+ env.addInstrumentationRegistrationListener(listener);
+ }
+
+ @Override
+ public void removeInstrumentationRegistrationListener(IInstrumentationRegistrationListener listener) throws RemoteException {
+ env.removeInstrumentationRegistrationListener(listener);
+ }
+
+ public IRemoteMessageService getMessageToolServiceProxy() throws RemoteException {
+ try {
+ return messageToolServiceTracker.waitForService(10000);
+ } catch (InterruptedException e) {
+ throw new RemoteException("", e);
+ }
+ }
+
+ public void removeUser(OSEEPerson1_4 user) {
+ env.removeUser(user);
+ }
+
+ public ReturnStatus isRunningJarVersions(String[] jarVersions) {
+ return env.getRuntimeManager().isRunningJarVersions(jarVersions);
+ }
+
+ public ICommandHandle addCommand(ITestServerCommand cmd) throws RemoteException {
+ return env.addCommand(cmd);
+ }
+
+ @Deprecated
+ public boolean isMessageJarAvailable(String version) throws RemoteException {
+ return env.isMessageJarAvailable(version);
+ }
+
+ @Deprecated
+ public void sendRuntimeJar(byte[] messageJar) throws RemoteException {
+ }
+
+ public void addEnvironmentListener(ITestEnvironmentListener listener) throws RemoteException {
+ env.addEnvironmentListener(listener);
+ }
+
+ @Override
+ public void setupClassLoaderAndJar(String[] jarVersions, String classPath) throws RemoteException {
+ }
+
+ @Override
+ public void setupClassLoaderAndJar(String[] jarVersion, String[] classPaths) throws RemoteException {
+ }
+
+ public IRemoteCommandConsole getCommandConsole() throws RemoteException {
+ OseeLog.log(RemoteTestEnvironment.class, Level.FINE,
+ "Remote command onsole requested");
+ RemoteShell shell = new RemoteShell(Activator.getDefault().getCommandManager());
+
+ IRemoteCommandConsole exportedConsole;
+ try {
+ exportedConsole = (IRemoteCommandConsole) serviceConnector.export(shell);
+ } catch (Exception ex) {
+ throw new RemoteException("failed to export remote console", ex);
+ }
+ exportedConsoles.put(exportedConsole, shell);
+ return exportedConsole;
+ }
+
+ public void closeCommandConsole(IRemoteCommandConsole console) throws RemoteException {
+ RemoteShell shell = exportedConsoles.remove(console);
+ if (shell != null) {
+ try {
+ serviceConnector.unexport(shell);
+ } catch (Exception ex) {
+ throw new RemoteException("failed to unexport remote shell", ex);
+ }
+
+ OseeLog.log(RemoteTestEnvironment.class, Level.FINE,
+ "closed command console");
+ } else {
+ OseeLog.log(RemoteTestEnvironment.class, Level.FINE,
+ "trying to remove non existing console");
+ }
+ }
+
+ public void addStatusListener(IServiceStatusListener listener) throws RemoteException {
+ if(Activator.getDefault().getOteStatusBoard() != null){
+ Activator.getDefault().getOteStatusBoard().addStatusListener(listener);
+ }
+ }
+
+ public UserTestSessionKey addUser(IUserSession user) throws RemoteException {
+ try {
+ return env.addUser(user);
+ } catch (Exception ex) {
+ throw new RemoteException("could not add user sessoion", ex);
+ }
+ }
+ //TODO
+ public void disconnect(UserTestSessionKey user) throws RemoteException {
+
+ }
+
+ public boolean equals(ITestEnvironment testEnvironment) throws RemoteException {
+ return env.getUniqueId() == testEnvironment.getUniqueId();
+ }
+
+ public List<String> getQueueLabels() throws RemoteException {
+ return env.getQueueLabels();
+ }
+
+ public Remote getRemoteModel(String modelClassName) throws RemoteException {
+ return (Remote) getRemoteModel(modelClassName, new Class[0], new Object[0]);
+ }
+
+ public IModelManagerRemote getModelManager() throws RemoteException {
+ if (modelManager == null) modelManager = new RemoteModelManager();
+ try {
+ return (IModelManagerRemote) serviceConnector.export(modelManager);
+ } catch (Throwable t) {
+ throw new RemoteException(
+ "Could not load get model manager" + t.getMessage());
+ }
+ }
+
+ public byte[] getScriptOutfile(String outfilePath) throws RemoteException {
+ return env.getScriptOutfile(outfilePath);
+ }
+
+ public int getUniqueId() throws RemoteException {
+ return env.getUniqueId();
+ }
+
+ public Collection<OSEEPerson1_4> getUserList() throws RemoteException {
+ Collection<OSEEPerson1_4> users = new ArrayList<OSEEPerson1_4>(env.getSessionKeys().size());
+ try {
+ Set<Serializable> sessionKeys = env.getSessionKeys();
+ for (Serializable serializable : sessionKeys) {
+ if (serializable instanceof UserTestSessionKey) {
+ try {
+ users.add(((UserTestSessionKey) serializable).getUser());
+ } catch (Exception ex) {
+ OseeLog.log(RemoteTestEnvironment.class, Level.SEVERE,
+ "exception while getting user list", ex);
+ }
+ }
+ }
+ return users;
+ } catch (Exception ex) {
+ OseeLog.log(RemoteTestEnvironment.class, Level.SEVERE,
+ "exception while generating user list", ex);
+ throw new RemoteException("exception while generating user list", ex);
+ }
+ }
+
+ //TODO
+ public void onHostKilled() throws RemoteException {
+ }
+
+ public void removeQueueListener(ReportDataListener listener) throws RemoteException {
+ env.removeQueueListener(listener);
+ }
+
+ public void removeStatusListener(IServiceStatusListener listener) throws RemoteException {
+ if(Activator.getDefault().getOteStatusBoard() != null){
+ Activator.getDefault().getOteStatusBoard().removeStatusListener(listener);
+ }
+ }
+
+ public URL setBatchLibJar(byte[] messageJar) throws RemoteException {
+ try {
+ return env.setBatchLibJar(messageJar);
+ } catch (IOException ex) {
+ throw new RemoteException("unable to set batch jar", ex);
+ }
+ }
+
+ public void setClientClasses(URL[] urls) throws RemoteException {
+ env.setClientClasses(urls);
+ }
+
+ public void startup(String outfileDir) throws RemoteException {
+ try {
+ env.startup(outfileDir);
+ } catch (Exception ex) {
+ throw new RemoteException("unable to set outfile location " + ex.getMessage());
+ }
+ }
+
+ public IUserSession getUserSession(UserTestSessionKey key) {
+ return env.getUserSession(key);
+ }
+
+ private class RemoteModelManager implements IModelManagerRemote {
+
+ public void addModelActivityListener(IModelListener listener) throws RemoteException {
+ env.getModelManager().addModelActivityListener(listener);
+ }
+
+ public void removeModelActivityListener(IModelListener listener) throws RemoteException {
+ env.getModelManager().removeModelActivityListener(listener);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void addModelActivityListener(IModelListener listener, ModelKey key) throws RemoteException {
+ env.getModelManager().addModelActivityListener(listener, key);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void removeModelActivityListener(IModelListener listener, ModelKey key) throws RemoteException {
+ env.getModelManager().removeModelActivityListener(listener, key);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<ModelKey> getRegisteredModels() throws RemoteException {
+ return env.getModelManager().getRegisteredModels();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Remote getRemoteModel(ModelKey key) throws RemoteException {
+ try {
+ Class modelClass;
+ try {
+
+ modelClass = env.loadClassFromScriptLoader(key.getClassName());
+ } catch (ClassNotFoundException ex) {
+ throw new RemoteException("Could not load model class: " + key.getClassName(), ex);
+ }
+ key.setModelClass(modelClass);
+ IModel model = env.getModelManager().getModel(key);
+ return (Remote) serviceConnector.export(model);
+ } catch (Throwable t) {
+ throw new RemoteException("Could not load model " + key.getClassName(), t);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void releaseReference(ModelKey key) throws RemoteException {
+ env.getModelManager().releaseReference(key);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void changeModelState(ModelKey key, ModelState state) throws RemoteException {
+ Class modelClass;
+ try {
+ modelClass = env.loadClassFromScriptLoader(key.getClassName());
+ } catch (ClassNotFoundException ex) {
+ throw new RemoteException("Could not load model class: " + key.getClassName());
+ }
+ key.setModelClass(modelClass);
+ env.getModelManager().changeModelState(key, state);
+ }
+
+ @SuppressWarnings("unchecked")
+ public ModelState getModelState(ModelKey key) throws RemoteException {
+ return env.getModelManager().getModelState(key);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void releaseAllReferences(ModelKey key) throws RemoteException {
+ env.getModelManager().releaseAllReferences(key);
+ }
+
+ }
+
+ @Override
+ public void setBatchMode(boolean isInBatchMode) throws RemoteException {
+ env.setBatchMode(isInBatchMode);
+ }
+
+ @Override
+ public void sendCommand(Command command) throws RemoteException {
+ env.sendCommand(command);
+ }
+
+ @Override
+ public void sendMessage(Message message) throws RemoteException {
+ env.sendMessageToServer(message);
+ }
+
+ @Override
+ public Remote getRemoteModel(String modelClassName, Class<?>[] methodParameterTypes, Object[] methodParameters) throws RemoteException {
+ return null;
+ }
+}
|