dblevins 2005/07/09 04:51:00
Modified: modules/core/src/java/org/openejb/alt/config
ConfigUtils.java ConfigurationFactory.java
Deploy.java EjbJarUtils.java EjbValidator.java
ValidationTable.java
Log:
I can't fix this Tomcat integration issue with all the silly statics.
Killing the statics. Death to the statics!
Added a class called SystemInstance, which is a singleton and hopefully the
only important static for the 1.0 codebase someday.
Changed FileUtils to get its instances from SystemInstance, then inlined all
that code.
Changed ClasspathUtils to get its Loader instance from SystemInstance and
managed to inline all the remaining code.
Revision Changes Path
1.11 +9 -8
openejb1/modules/core/src/java/org/openejb/alt/config/ConfigUtils.java
Index: ConfigUtils.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb1/modules/core/src/java/org/openejb/alt/config/ConfigUtils.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ConfigUtils.java 9 Jul 2005 05:53:21 -0000 1.10
+++ ConfigUtils.java 9 Jul 2005 08:50:59 -0000 1.11
@@ -66,6 +66,7 @@
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.openejb.OpenEJBException;
+import org.openejb.loader.SystemInstance;
import org.openejb.alt.config.ejb11.OpenejbJar;
import org.openejb.alt.config.sys.Deployments;
import org.openejb.alt.config.sys.Openejb;
@@ -322,7 +323,7 @@
* [2] Try finding the file relative to the openejb.base
directory
*/
try {
- file = FileUtils.getBase().getFile(path);
+ file = SystemInstance.get().getBase().getFile(path);
if (file != null && file.exists() && file.isFile()) {
return file.getAbsolutePath();
}
@@ -334,7 +335,7 @@
* [3] Try finding the file relative to the openejb.home
directory
*/
try {
- file = FileUtils.getHome().getFile(path);
+ file = SystemInstance.get().getHome().getFile(path);
if (file != null && file.exists() && file.isFile()) {
return file.getAbsolutePath();
}
@@ -352,7 +353,7 @@
* openejb.base directory
*/
try {
- file = FileUtils.getBase().getFile("conf/openejb.conf");
+ file =
SystemInstance.get().getBase().getFile("conf/openejb.conf");
if (file != null && file.exists() && file.isFile()) {
return file.getAbsolutePath();
}
@@ -364,7 +365,7 @@
* openejb.home directory
*/
try {
- file = FileUtils.getHome().getFile("conf/openejb.conf");
+ file =
SystemInstance.get().getHome().getFile("conf/openejb.conf");
if (file != null && file.exists() && file.isFile()) {
return file.getAbsolutePath();
}
@@ -378,7 +379,7 @@
* the openejb-x.x.x.jar
*/
//Gets the conf directory, creating it if needed.
- File confDir = FileUtils.getBase().getDirectory("conf", true);
+ File confDir =
SystemInstance.get().getBase().getDirectory("conf", true);
//TODO:1: We cannot find the user's conf file and
// are taking the liberty of creating one for them.
@@ -431,7 +432,7 @@
if (d.getJar() != null) {
try {
- File target = FileUtils.getBase().getFile(d.getJar(),
false);
+ File target =
SystemInstance.get().getBase().getFile(d.getJar(), false);
/*
* If the jar entry is already there, no need
@@ -446,7 +447,7 @@
}
} else if (d.getDir() != null) {
try {
- File target = FileUtils.getBase().getFile(d.getDir(),
false);
+ File target =
SystemInstance.get().getBase().getFile(d.getDir(), false);
File jarDir = jar.getAbsoluteFile().getParentFile();
/*
1.12 +10 -7
openejb1/modules/core/src/java/org/openejb/alt/config/ConfigurationFactory.java
Index: ConfigurationFactory.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb1/modules/core/src/java/org/openejb/alt/config/ConfigurationFactory.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ConfigurationFactory.java 9 Jul 2005 05:53:21 -0000 1.11
+++ ConfigurationFactory.java 9 Jul 2005 08:50:59 -0000 1.12
@@ -54,6 +54,7 @@
import java.util.Vector;
import org.openejb.OpenEJBException;
+import org.openejb.loader.SystemInstance;
import org.openejb.alt.assembler.classic.ConnectionManagerInfo;
import org.openejb.alt.assembler.classic.ConnectorInfo;
import org.openejb.alt.assembler.classic.ContainerInfo;
@@ -119,6 +120,7 @@
import org.openejb.util.FileUtils;
import org.openejb.util.Logger;
import org.openejb.util.Messages;
+import org.openejb.util.ClasspathUtils;
/**
* An implementation of the Classic Assembler's OpenEjbConfigurationFactory
@@ -681,7 +683,8 @@
//TODO:2: This is really temporary, jars should have their
// own classpaths. We have code for this, but it has a couple
// issues in the CMP container that prevent us from relying on
it.
- org.openejb.util.ClasspathUtils.addJarToPath(jar.jarURI);
+ File jarFile =
SystemInstance.get().getHome().getFile(jar.jarURI);
+ SystemInstance.get().getLoader().addJarToPath(jarFile.toURL());
} catch (Exception e) {
e.printStackTrace();
}
@@ -1136,10 +1139,10 @@
if (d.getDir() == null && d.getJar() != null) {
File jar = null;
try {
- jar = FileUtils.getBase().getFile(d.getJar(), false);
+ jar =
SystemInstance.get().getBase().getFile(d.getJar(), false);
} catch (Exception ignored) {
try {
- jar = FileUtils.getHome().getFile(d.getJar(),
false);
+ jar =
SystemInstance.get().getHome().getFile(d.getJar(), false);
} catch (Exception ignoredAgain) {
}
}
@@ -1155,12 +1158,12 @@
File dir = null;
try {
- dir = FileUtils.getBase().getFile(d.getDir(), false);
+ dir = SystemInstance.get().getBase().getFile(d.getDir(),
false);
} catch (Exception ignored) {
}
if (dir == null || !dir.exists()) {
try {
- dir = FileUtils.getHome().getFile(d.getDir(), false);
+ dir =
SystemInstance.get().getHome().getFile(d.getDir(), false);
} catch (Exception ignoredAgain) {
}
}
@@ -1198,7 +1201,7 @@
dir = null;
try {
- dir = FileUtils.getHome().getFile(d.getDir(), false);
+ dir =
SystemInstance.get().getHome().getFile(d.getDir(), false);
} catch (Exception ignoredAgain) {
}
1.6 +8 -3
openejb1/modules/core/src/java/org/openejb/alt/config/Deploy.java
Index: Deploy.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb1/modules/core/src/java/org/openejb/alt/config/Deploy.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Deploy.java 24 Jun 2005 12:04:40 -0000 1.5
+++ Deploy.java 9 Jul 2005 08:50:59 -0000 1.6
@@ -47,12 +47,14 @@
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.PrintStream;
+import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.Properties;
import java.util.StringTokenizer;
import org.openejb.OpenEJBException;
+import org.openejb.loader.SystemInstance;
import org.openejb.alt.config.ejb11.EjbDeployment;
import org.openejb.alt.config.ejb11.EjbJar;
import org.openejb.alt.config.ejb11.MethodParams;
@@ -67,6 +69,7 @@
import org.openejb.util.Messages;
import org.openejb.util.SafeToolkit;
import org.openejb.util.Logger;
+import org.openejb.util.ClasspathUtils;
/**
* This class represents a command line tool for deploying beans.
@@ -758,8 +761,10 @@
public static void main(String args[]) {
try {
- org.openejb.util.ClasspathUtils.addJarsToPath("lib");
- org.openejb.util.ClasspathUtils.addJarsToPath("dist");
+ File directory =
SystemInstance.get().getHome().getDirectory("lib");
+ SystemInstance.get().getLoader().addJarsToPath(directory);
+ File directory1 =
SystemInstance.get().getHome().getDirectory("dist");
+ SystemInstance.get().getLoader().addJarsToPath(directory1);
} catch (Exception e) {
e.printStackTrace();
}
1.5 +4 -3
openejb1/modules/core/src/java/org/openejb/alt/config/EjbJarUtils.java
Index: EjbJarUtils.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb1/modules/core/src/java/org/openejb/alt/config/EjbJarUtils.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- EjbJarUtils.java 9 Jul 2005 05:14:47 -0000 1.4
+++ EjbJarUtils.java 9 Jul 2005 08:50:59 -0000 1.5
@@ -62,6 +62,7 @@
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.openejb.OpenEJBException;
+import org.openejb.loader.SystemInstance;
import org.openejb.alt.config.ejb11.EjbJar;
import org.openejb.alt.config.ejb11.EnterpriseBeansItem;
import org.openejb.alt.config.sys.Container;
@@ -197,7 +198,7 @@
String jarName = origFile.getName();
File beansDir = null;
try {
- beansDir = FileUtils.getBase().getDirectory("beans");
+ beansDir = SystemInstance.get().getBase().getDirectory("beans");
} catch (java.io.IOException ioe) {
handleException("deploy.m.040", origFile.getAbsolutePath(),
ioe.getMessage());
}
@@ -247,7 +248,7 @@
String jarName = origFile.getName();
File beansDir = null;
try {
- beansDir = FileUtils.getBase().getDirectory("beans");
+ beansDir = SystemInstance.get().getBase().getDirectory("beans");
} catch (java.io.IOException ioe) {
handleException("deploy.c.040", origFile.getAbsolutePath(),
ioe.getMessage());
return jar;
1.7 +8 -3
openejb1/modules/core/src/java/org/openejb/alt/config/EjbValidator.java
Index: EjbValidator.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb1/modules/core/src/java/org/openejb/alt/config/EjbValidator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- EjbValidator.java 16 Jun 2005 22:29:50 -0000 1.6
+++ EjbValidator.java 9 Jul 2005 08:50:59 -0000 1.7
@@ -45,16 +45,19 @@
package org.openejb.alt.config;
import java.io.InputStream;
+import java.io.File;
import java.net.URL;
import java.util.Properties;
import java.util.Vector;
import org.openejb.OpenEJBException;
+import org.openejb.loader.SystemInstance;
import org.openejb.alt.config.ejb11.EjbJar;
import org.openejb.alt.config.rules.CheckClasses;
import org.openejb.alt.config.rules.CheckMethods;
import org.openejb.util.JarUtils;
import org.openejb.util.Messages;
+import org.openejb.util.ClasspathUtils;
/**
@@ -325,8 +328,10 @@
public static void main(String args[]) {
try{
- org.openejb.util.ClasspathUtils.addJarsToPath("lib");
- org.openejb.util.ClasspathUtils.addJarsToPath("dist");
+ File directory =
SystemInstance.get().getHome().getDirectory("lib");
+ SystemInstance.get().getLoader().addJarsToPath(directory);
+ File directory1 =
SystemInstance.get().getHome().getDirectory("dist");
+ SystemInstance.get().getLoader().addJarsToPath(directory1);
} catch (Exception e){
// ignore it
}
1.6 +4 -3
openejb1/modules/core/src/java/org/openejb/alt/config/ValidationTable.java
Index: ValidationTable.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb1/modules/core/src/java/org/openejb/alt/config/ValidationTable.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ValidationTable.java 6 Jul 2005 02:04:03 -0000 1.5
+++ ValidationTable.java 9 Jul 2005 08:50:59 -0000 1.6
@@ -57,6 +57,7 @@
import org.openejb.util.FileUtils;
import org.openejb.util.JarUtils;
import org.openejb.OpenEJB;
+import org.openejb.loader.SystemInstance;
/**
* Beans should be validated, but only when:
@@ -150,7 +151,7 @@
public boolean isValidated(String jarFile){
try{
- File jar = FileUtils.getBase().getFile(jarFile);
+ File jar = SystemInstance.get().getBase().getFile(jarFile);
long lastModified = jar.lastModified();
long lastValidated = getLastValidated(jar);
//System.out.println(" -- modified "+lastModified);
@@ -230,7 +231,7 @@
public void setLastValidated(String jarFile, long timeValidated){
try{
conn = getConnection();
- File jar = FileUtils.getBase().getFile(jarFile);
+ File jar = SystemInstance.get().getBase().getFile(jarFile);
String jarFileURL = jar.toURL().toExternalForm();
//System.out.println("[] setLastValidated "+jarFileURL );
//System.out.println(" -- time "+timeValidated );