[jboss-cvs] JBossAS SVN: r67611 - trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Nov 29 11:08:57 EST 2007
Author: remy.maucherat at jboss.com
Date: 2007-11-29 11:08:57 -0500 (Thu, 29 Nov 2007)
New Revision: 67611
Modified:
trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
Log:
- Remove the findConfig method, and include it inside normal
deployment when checking if the folder exists.
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java 2007-11-29 16:04:40 UTC (rev 67610)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java 2007-11-29 16:08:57 UTC (rev 67611)
@@ -185,25 +185,55 @@
Registry.getRegistry().registerComponent(context, objectName, config.getContextClassName());
- // Find and set warInfo file on the context
- // If WAR is packed, expand warInfo file to temp folder
String ctxConfig = null;
- try
+ File warFile = new File(url.getFile());
+ if (warFile.isDirectory() == false)
{
- // TODO: this should be input metadata
- ctxConfig = findConfig(webApp, url);
- }
- catch (IOException e)
- {
- log.debug("No " + CONTEXT_CONFIG_FILE + " in " + url, e);
- }
-
- if ((new File(url.getFile())).isDirectory() == false)
- {
+ // Using VFS access
VFSDirContext resources = new VFSDirContext();
resources.setVirtualFile(webApp.getDeploymentUnit().getFile(""));
context.setResources(resources);
+ // Find META-INF/context.xml
+ VirtualFile file = webApp.getDeploymentUnit().getFile(CONTEXT_CONFIG_FILE);
+ if (file != null)
+ {
+ // Copy the META-INF/context.xml from the VFS to the temp folder
+ InputStream is = file.openStream();
+ FileOutputStream fos = null;
+ try
+ {
+ byte[] buffer = new byte[512];
+ int bytes;
+ // FIXME: use JBoss'temp folder instead
+ File tempFile = File.createTempFile("context-", ".xml");
+ tempFile.deleteOnExit();
+ fos = new FileOutputStream(tempFile);
+ while ((bytes = is.read(buffer)) > 0)
+ {
+ fos.write(buffer, 0, bytes);
+ }
+ ctxConfig = tempFile.getAbsolutePath();
+ }
+ finally
+ {
+ is.close();
+ if (fos != null)
+ {
+ fos.close();
+ }
+ }
+ }
}
+ else
+ {
+ // Using direct filesystem access: no operation needed
+ // Find META-INF/context.xml
+ File webDD = new File(warFile, CONTEXT_CONFIG_FILE);
+ if (webDD.exists() == true)
+ {
+ ctxConfig = webDD.getAbsolutePath();
+ }
+ }
context.setInstanceManager(injectionContainer);
context.setDocBase(url.getFile());
@@ -680,52 +710,4 @@
return hosts.iterator();
}
- protected String findConfig(WebApplication webApp, URL warURL) throws IOException
- {
- String result = null;
- // See if the warUrl is a dir or a file
- File warFile = new File(warURL.getFile());
- if (warFile.isDirectory() == true)
- {
- File webDD = new File(warFile, CONTEXT_CONFIG_FILE);
- if (webDD.exists() == true)
- {
- result = webDD.getAbsolutePath();
- }
- }
- else
- {
- VirtualFile file = webApp.getDeploymentUnit().getFile(CONTEXT_CONFIG_FILE);
- if (file != null)
- {
- // Copy the file to the temp folder
- InputStream is = file.openStream();
- FileOutputStream fos = null;
- try
- {
- byte[] buffer = new byte[512];
- int bytes;
- // FIXME: use JBoss'temp folder instead
- File tempFile = File.createTempFile("context-", ".xml");
- tempFile.deleteOnExit();
- fos = new FileOutputStream(tempFile);
- while ((bytes = is.read(buffer)) > 0)
- {
- fos.write(buffer, 0, bytes);
- }
- result = tempFile.getAbsolutePath();
- }
- finally
- {
- is.close();
- if (fos != null)
- {
- fos.close();
- }
- }
- }
- }
- return result;
- }
-
}
More information about the jboss-cvs-commits
mailing list