Skip to main content
summaryrefslogtreecommitdiffstats
blob: 2107678948334bdbc67180345519630863054735 (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
/*******************************************************************************
 * 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.framework.messaging.internal.activemq;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.logging.Level;

import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.messaging.ConnectionNode;
import org.eclipse.osee.framework.messaging.ConnectionNodeFactory;
import org.eclipse.osee.framework.messaging.NodeInfo;
import org.eclipse.osee.framework.messaging.internal.Activator;
import org.eclipse.osee.framework.messaging.internal.FailoverConnectionNode;

/**
 * @author Roberto E. Escobar
 */
public class ConnectionNodeFactoryImpl implements ConnectionNodeFactory {

   private final ExecutorService executor;
   private final ScheduledExecutorService scheduledExecutor;
   private final String version;
   private final String sourceId;

   public ConnectionNodeFactoryImpl(String version, String sourceId, ExecutorService executor) {
      this.version = version;
      this.sourceId = sourceId;
      this.executor = executor;
      this.scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
   }

   @Override
   public synchronized ConnectionNode create(NodeInfo nodeInfo) {
	  OseeExceptionListener exceptionListener = new OseeExceptionListener();
      final ConnectionNodeActiveMq node = new ConnectionNodeActiveMq(version, sourceId, nodeInfo, executor, exceptionListener);
      OseeLog.log(Activator.class, Level.FINEST, "Going to start a connection node.");
      try {
         node.start();
      } catch (OseeCoreException ex) {
         OseeLog.log(ConnectionNodeFactoryImpl.class, Level.SEVERE, ex);
      }
      OseeLog.log(Activator.class, Level.FINE, "Started a connection node.");
      return new FailoverConnectionNode(node, scheduledExecutor, exceptionListener);
   }

}

Back to the top