Skip to main content
summaryrefslogtreecommitdiffstats
blob: 62b2d23ab83372c16c0bc04e7ae5157a9d905df9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*******************************************************************************
 * Copyright (c) 2010 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.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.framework.plugin.core.util.ExportClassLoader;
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
 */
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 TestEnvironmentFactory factory;
   private final String environmentFactoryClass;

   public EnvironmentCreationParameter(IRuntimeLibraryManager runtimeLibraryManager, NodeInfo oteEmbeddedBroker, IServiceConnector serviceConnector, ITestEnvironmentServiceConfig config, TestEnvironmentFactory factory, String environmentFactoryClass) {
      this.oteEmbeddedBroker = oteEmbeddedBroker;
      this.serviceConnector = serviceConnector;
      this.config = config;
      this.runtimeLibraryManager = runtimeLibraryManager;
      this.factory = factory;
      this.environmentFactoryClass = environmentFactoryClass;

   }
   
   public NodeInfo getBroker(){
      return oteEmbeddedBroker;
   }

   public Serializable getServerTitle() {
      return config.getServerTitle();
   }

   public int getMaxUsersPerEnvironment() {
      return config.getMaxUsersPerEnvironment();
   }

   public String getOutfileLocation() {
      return config.getOutfileLocation();
   }

   public MessageSystemTestEnvironment createEnvironment() throws Throwable {
      if (factory == null) {
         ExportClassLoader exportClassLoader = ExportClassLoader.getInstance();
         Class<? extends TestEnvironmentFactory> clazz =
            exportClassLoader.loadClass(environmentFactoryClass).asSubclass(TestEnvironmentFactory.class);
         factory = clazz.newInstance();
      }
      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, config.keepEnvAliveWithNoUsers());
      exportedRemoteTestEnvironment = (ITestEnvironment) serviceConnector.export(remoteTestEnvironment);
      return exportedRemoteTestEnvironment;
   }

   public IServiceConnector getServiceConnector() {
      return serviceConnector;
   }

   public boolean isKeepAliveWithNoUsers() {
      return config.keepEnvAliveWithNoUsers();
   }
}

Back to the top