Issue #2005 stop cave from starting if spring fails, prompt user if they want to restart
Change-Id: I6b77e06c5737dab04c6c1a89cc2f5242a784bc53 Conflicts: cave/com.raytheon.viz.ui.personalities.awips/META-INF/MANIFEST.MF Former-commit-id:329d9d1c6a
[formerly329d9d1c6a
[formerly 6742f7dbcac39261d8bee4e055bb9e4eda66520d]] Former-commit-id:5d1ecb3a5d
Former-commit-id:2d1405b9c4
This commit is contained in:
parent
d01a608015
commit
5c2f0ab151
5 changed files with 172 additions and 136 deletions
|
@ -11,3 +11,4 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
com.raytheon.uf.common.comm;bundle-version="1.12.1174"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.raytheon.uf.viz.spring.dm
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
@ -34,6 +35,7 @@ import org.osgi.framework.Constants;
|
|||
* Jan 24, 2013 1522 bkowal Halt initialization if a p2 installation
|
||||
* has been started
|
||||
* Mar 05, 2013 1754 djohnson Catch exceptions and allow as much of the Spring container to boot as possible.
|
||||
* May 23, 2013 2005 njensen Added springSuccess flag
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -42,102 +44,110 @@ import org.osgi.framework.Constants;
|
|||
*/
|
||||
public class Activator implements BundleActivator {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "com.raytheon.uf.viz.spring.dm";
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "com.raytheon.uf.viz.spring.dm";
|
||||
|
||||
private static final String SPRING_PATH = "res" + IPath.SEPARATOR
|
||||
+ "spring";
|
||||
private static final String SPRING_PATH = "res" + IPath.SEPARATOR
|
||||
+ "spring";
|
||||
|
||||
private static final String SPRING_FILE_EXT = "*.xml";
|
||||
private static final String SPRING_FILE_EXT = "*.xml";
|
||||
|
||||
// The shared instance
|
||||
private static Activator plugin;
|
||||
private static final Pattern COMMA_SPLIT = Pattern.compile("[,]");
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public Activator() {
|
||||
}
|
||||
private static final Pattern SEMICOLON_SPLIT = Pattern.compile("[;]");
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
@Override
|
||||
// The shared instance
|
||||
private static Activator plugin;
|
||||
|
||||
private boolean springSuccess = true;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public Activator() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
if (this.isInstallOperation()) {
|
||||
return;
|
||||
}
|
||||
plugin = this;
|
||||
if (this.isInstallOperation()) {
|
||||
return;
|
||||
}
|
||||
plugin = this;
|
||||
|
||||
Map<String, OSGIXmlApplicationContext> contextMap = new HashMap<String, OSGIXmlApplicationContext>();
|
||||
Set<String> processing = new HashSet<String>();
|
||||
Bundle[] bundles = context.getBundles();
|
||||
Map<String, Bundle> bundleMap = new HashMap<String, Bundle>();
|
||||
for (Bundle b : bundles) {
|
||||
bundleMap.put(b.getSymbolicName(), b);
|
||||
}
|
||||
for (Bundle b : bundles) {
|
||||
createContext(bundleMap, contextMap, b, processing);
|
||||
}
|
||||
}
|
||||
Map<String, OSGIXmlApplicationContext> contextMap = new HashMap<String, OSGIXmlApplicationContext>();
|
||||
Set<String> processing = new HashSet<String>();
|
||||
Bundle[] bundles = context.getBundles();
|
||||
Map<String, Bundle> bundleMap = new HashMap<String, Bundle>();
|
||||
for (Bundle b : bundles) {
|
||||
bundleMap.put(b.getSymbolicName(), b);
|
||||
}
|
||||
for (Bundle b : bundles) {
|
||||
createContext(bundleMap, contextMap, b, processing);
|
||||
}
|
||||
}
|
||||
|
||||
private OSGIXmlApplicationContext createContext(
|
||||
Map<String, Bundle> bundles,
|
||||
Map<String, OSGIXmlApplicationContext> contextMap, Bundle bundle,
|
||||
Set<String> processing) {
|
||||
String bundleName = bundle.getSymbolicName();
|
||||
OSGIXmlApplicationContext appCtx = contextMap.get(bundleName);
|
||||
if (contextMap.containsKey(bundleName) == false
|
||||
&& bundleName.contains(".edex.") == false) {
|
||||
if (processing.contains(bundleName)) {
|
||||
throw new RuntimeException(
|
||||
"Found recursive spring dependency while processing plugins: "
|
||||
+ bundleName);
|
||||
}
|
||||
processing.add(bundleName);
|
||||
private OSGIXmlApplicationContext createContext(
|
||||
Map<String, Bundle> bundles,
|
||||
Map<String, OSGIXmlApplicationContext> contextMap, Bundle bundle,
|
||||
Set<String> processing) {
|
||||
String bundleName = bundle.getSymbolicName();
|
||||
OSGIXmlApplicationContext appCtx = contextMap.get(bundleName);
|
||||
if (contextMap.containsKey(bundleName) == false
|
||||
&& bundleName.contains(".edex.") == false) {
|
||||
if (processing.contains(bundleName)) {
|
||||
springSuccess = false;
|
||||
throw new RuntimeException(
|
||||
"Found recursive spring dependency while processing plugins: "
|
||||
+ bundleName);
|
||||
}
|
||||
processing.add(bundleName);
|
||||
|
||||
// No context created yet and not edex project, check for files
|
||||
Enumeration<?> entries = bundle.findEntries(SPRING_PATH,
|
||||
SPRING_FILE_EXT, true);
|
||||
if (entries != null) {
|
||||
List<String> files = new ArrayList<String>();
|
||||
while (entries.hasMoreElements()) {
|
||||
URL url = (URL) entries.nextElement();
|
||||
try {
|
||||
url = FileLocator.toFileURL(url);
|
||||
files.add(url.toString());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(
|
||||
"Error resolving spring file: " + url, e);
|
||||
}
|
||||
}
|
||||
if (files.size() > 0) {
|
||||
// Files found, check for dependencies
|
||||
String requiredBundlesHeader = (String) bundle.getHeaders()
|
||||
.get(Constants.REQUIRE_BUNDLE);
|
||||
// Split comma separated string from MANIFEST
|
||||
String[] requiredBundles = requiredBundlesHeader
|
||||
.split("[,]");
|
||||
List<OSGIXmlApplicationContext> parentContexts = new ArrayList<OSGIXmlApplicationContext>();
|
||||
for (String requiredBndl : requiredBundles) {
|
||||
// Extract bundle name which is first item in
|
||||
// semicolon
|
||||
// split list
|
||||
String[] bndlParts = requiredBndl.split("[;]");
|
||||
Bundle reqBndl = bundles.get(bndlParts[0]);
|
||||
if (reqBndl != null) {
|
||||
// Found bundle, process context for bundle
|
||||
OSGIXmlApplicationContext parent = createContext(
|
||||
bundles, contextMap, reqBndl, processing);
|
||||
if (parent != null) {
|
||||
// Context found, add to list
|
||||
parentContexts.add(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
// No context created yet and not edex project, check for files
|
||||
Enumeration<?> entries = bundle.findEntries(SPRING_PATH,
|
||||
SPRING_FILE_EXT, true);
|
||||
if (entries != null) {
|
||||
List<String> files = new ArrayList<String>();
|
||||
while (entries.hasMoreElements()) {
|
||||
URL url = (URL) entries.nextElement();
|
||||
try {
|
||||
url = FileLocator.toFileURL(url);
|
||||
files.add(url.toString());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(
|
||||
"Error resolving spring file: " + url, e);
|
||||
}
|
||||
}
|
||||
if (files.size() > 0) {
|
||||
// Files found, check for dependencies
|
||||
String requiredBundlesHeader = (String) bundle.getHeaders()
|
||||
.get(Constants.REQUIRE_BUNDLE);
|
||||
// Split comma separated string from MANIFEST
|
||||
String[] requiredBundles = COMMA_SPLIT
|
||||
.split(requiredBundlesHeader);
|
||||
List<OSGIXmlApplicationContext> parentContexts = new ArrayList<OSGIXmlApplicationContext>();
|
||||
for (String requiredBndl : requiredBundles) {
|
||||
// Extract bundle name which is first item in
|
||||
// semicolon
|
||||
// split list
|
||||
String[] bndlParts = SEMICOLON_SPLIT
|
||||
.split(requiredBndl);
|
||||
Bundle reqBndl = bundles.get(bndlParts[0]);
|
||||
if (reqBndl != null) {
|
||||
// Found bundle, process context for bundle
|
||||
OSGIXmlApplicationContext parent = createContext(
|
||||
bundles, contextMap, reqBndl, processing);
|
||||
if (parent != null) {
|
||||
// Context found, add to list
|
||||
parentContexts.add(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (parentContexts.size() > 0) {
|
||||
|
@ -159,58 +169,63 @@ public class Activator implements BundleActivator {
|
|||
System.err
|
||||
.println("Errors booting the Spring container. CAVE will not be fully functional.");
|
||||
t.printStackTrace();
|
||||
springSuccess = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
contextMap.put(bundleName, appCtx);
|
||||
}
|
||||
processing.remove(bundleName);
|
||||
return appCtx;
|
||||
}
|
||||
}
|
||||
}
|
||||
contextMap.put(bundleName, appCtx);
|
||||
}
|
||||
processing.remove(bundleName);
|
||||
return appCtx;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
@Override
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
@Override
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
plugin = null;
|
||||
}
|
||||
plugin = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance
|
||||
*
|
||||
* @return the shared instance
|
||||
*/
|
||||
public static Activator getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
/**
|
||||
* Returns the shared instance
|
||||
*
|
||||
* @return the shared instance
|
||||
*/
|
||||
public static Activator getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on the command line arguments, determine whether or not an Eclipse
|
||||
* p2 repository will be installed
|
||||
*
|
||||
* @return true if an Eclipse p2 repository is going to be installed, false
|
||||
* otherwise
|
||||
*/
|
||||
private boolean isInstallOperation() {
|
||||
final String P2_DIRECTOR = "org.eclipse.equinox.p2.director";
|
||||
/**
|
||||
* Based on the command line arguments, determine whether or not an Eclipse
|
||||
* p2 repository will be installed
|
||||
*
|
||||
* @return true if an Eclipse p2 repository is going to be installed, false
|
||||
* otherwise
|
||||
*/
|
||||
private boolean isInstallOperation() {
|
||||
final String P2_DIRECTOR = "org.eclipse.equinox.p2.director";
|
||||
|
||||
/**
|
||||
* We look at the command line arguments instead of the program
|
||||
* arguments (com.raytheon.uf.viz.application.ProgramArguments) because
|
||||
* the command line arguments include almost everything that was passed
|
||||
* as an argument to the Eclipse executable instead of just what CAVE is
|
||||
* interested in.
|
||||
*/
|
||||
for (String argument : Platform.getCommandLineArgs()) {
|
||||
if (P2_DIRECTOR.equals(argument)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* We look at the command line arguments instead of the program
|
||||
* arguments (com.raytheon.uf.viz.application.ProgramArguments) because
|
||||
* the command line arguments include almost everything that was passed
|
||||
* as an argument to the Eclipse executable instead of just what CAVE is
|
||||
* interested in.
|
||||
*/
|
||||
for (String argument : Platform.getCommandLineArgs()) {
|
||||
if (P2_DIRECTOR.equals(argument)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
public boolean isSpringInitSuccessful() {
|
||||
return springSuccess;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,8 @@ Require-Bundle: org.eclipse.ui,
|
|||
com.raytheon.uf.viz.ui.menus;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.viz.application;bundle-version="1.0.0",
|
||||
com.raytheon.viz.alerts;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.comm;bundle-version="1.12.1174"
|
||||
com.raytheon.uf.common.comm;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.viz.spring.dm
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-ClassPath: .
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.eclipse.core.runtime.jobs.Job;
|
|||
import org.eclipse.equinox.app.IApplication;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.application.WorkbenchAdvisor;
|
||||
import org.eclipse.ui.internal.WorkbenchPlugin;
|
||||
|
@ -95,6 +96,7 @@ import com.raytheon.viz.core.units.UnitRegistrar;
|
|||
* Apr 17, 2013 1786 mpduff startComponent now sets StatusHandlerFactory
|
||||
* Apr 23, 2013 #1939 randerso Allow serialization to complete initialization
|
||||
* before connecting to JMS to avoid deadlock
|
||||
* May 23, 2013 #2005 njensen Shutdown on spring initialization errors
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -158,6 +160,24 @@ public abstract class AbstractCAVEComponent implements IStandaloneComponent {
|
|||
display = new Display();
|
||||
}
|
||||
|
||||
// verify Spring successfully initialized, otherwise stop CAVE
|
||||
if (!com.raytheon.uf.viz.spring.dm.Activator.getDefault()
|
||||
.isSpringInitSuccessful()) {
|
||||
String msg = "CAVE's Spring container did not initialize correctly and CAVE must shut down.";
|
||||
boolean restart = false;
|
||||
if (!nonui) {
|
||||
msg += " Attempt to restart CAVE?";
|
||||
restart = MessageDialog.openQuestion(new Shell(display),
|
||||
"Startup Error", msg);
|
||||
} else {
|
||||
System.err.println(msg);
|
||||
}
|
||||
if (restart) {
|
||||
return IApplication.EXIT_RESTART;
|
||||
}
|
||||
return IApplication.EXIT_OK;
|
||||
}
|
||||
|
||||
try {
|
||||
initializeLocalization(nonui);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -461,7 +461,6 @@ public abstract class AbstractWWAResource extends
|
|||
}
|
||||
|
||||
protected void cleanupData(DataTime paintTime, DataTime[] descFrameTimes) {
|
||||
System.out.println("entryMap size " + entryMap.size());
|
||||
List<TimeRange> framePeriods = new ArrayList<TimeRange>(
|
||||
descFrameTimes.length);
|
||||
for (int i = 0; i < descFrameTimes.length; i++) {
|
||||
|
|
Loading…
Add table
Reference in a new issue