[embjopr-commits] EMBJOPR SVN: r912 - trunk/core/src/main/java/org/jboss/on/embedded/ui.
embjopr-commits at lists.jboss.org
embjopr-commits at lists.jboss.org
Wed Apr 7 10:54:52 EDT 2010
Author: ips
Date: 2010-04-07 10:54:52 -0400 (Wed, 07 Apr 2010)
New Revision: 912
Modified:
trunk/core/src/main/java/org/jboss/on/embedded/ui/BootstrapAction.java
Log:
replace usages of Seam's ServletLifecycle class with JSF APIs
Modified: trunk/core/src/main/java/org/jboss/on/embedded/ui/BootstrapAction.java
===================================================================
--- trunk/core/src/main/java/org/jboss/on/embedded/ui/BootstrapAction.java 2010-04-07 00:06:55 UTC (rev 911)
+++ trunk/core/src/main/java/org/jboss/on/embedded/ui/BootstrapAction.java 2010-04-07 14:54:52 UTC (rev 912)
@@ -1,6 +1,6 @@
/*
* Embedded Jopr Project
- * Copyright (C) 2006-2009 Red Hat, Inc.
+ * Copyright (C) 2006-2010 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -30,7 +30,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.servlet.ServletContext;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -48,7 +49,6 @@
import org.jboss.seam.annotations.Observer;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Startup;
-import org.jboss.seam.contexts.ServletLifecycle;
import org.jboss.seam.security.Identity;
import org.jboss.on.embedded.EmbeddedInventoryEventListener;
@@ -167,13 +167,17 @@
version = this.getClass().getPackage().getImplementationVersion();
if (version == null)
{
- ServletContext servletContext = ServletLifecycle.getServletContext();
- String manifestPath = servletContext.getRealPath("/META-INF/MANIFEST.MF");
- Manifest manifest = new Manifest(new FileInputStream(manifestPath));
- version = (String)manifest.getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION);
- if (version == null)
- {
- throw new IllegalStateException(Attributes.Name.IMPLEMENTATION_VERSION + " attribute is not set in WAR's manifest.");
+ String manifestPath = getRealPath("/META-INF/MANIFEST.MF");
+ FileInputStream inputStream = new FileInputStream(manifestPath);
+ try {
+ Manifest manifest = new Manifest(inputStream);
+ version = (String)manifest.getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION);
+ if (version == null)
+ {
+ throw new IllegalStateException(Attributes.Name.IMPLEMENTATION_VERSION + " attribute is not set in WAR's manifest.");
+ }
+ } finally {
+ inputStream.close();
}
}
}
@@ -184,6 +188,12 @@
return version;
}
+ private String getRealPath(String webAppPath) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ExternalContext externalContext = facesContext.getExternalContext();
+ return externalContext.getRealPath(webAppPath);
+ }
+
private static void reconfigureJdkLogging()
{
try
@@ -225,20 +235,35 @@
private static SimplePluginFinder createPluginFinder() throws MalformedURLException
{
- ServletContext servletContext = ServletLifecycle.getServletContext();
SimplePluginFinder pluginFinder = new SimplePluginFinder();
- Set<String> pluginStringSet = servletContext.getResourcePaths("/plugins/");
- for (String pluginString : pluginStringSet)
+ Set<String> pluginResourcePaths = getResourcePaths("/plugins/");
+ for (String pluginResourcePath : pluginResourcePaths)
{
- if (pluginString.endsWith(".jar"))
+ if (pluginResourcePath.endsWith(".jar"))
{
- URL pluginUrl = servletContext.getResource(pluginString);
+ URL pluginUrl = getResource(pluginResourcePath);
pluginFinder.addUrl(pluginUrl);
}
}
return pluginFinder;
}
+ private static Set<String> getResourcePaths(String webAppPath) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ExternalContext externalContext = facesContext.getExternalContext();
+ return externalContext.getResourcePaths(webAppPath);
+ }
+
+ private static URL getResource(String resourcePath) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ExternalContext externalContext = facesContext.getExternalContext();
+ try {
+ return externalContext.getResource(resourcePath);
+ } catch (MalformedURLException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
private static void configureMockScenarioLoader()
{
LOG.trace("Configuring Mock Scenario Loader...");
More information about the embjopr-commits
mailing list