oops! forgot the diff.
-- dims
On 6/19/07, Davanum Srinivas <[EMAIL PROTECTED]> wrote:
Jerome,
You are right!
Team,
I am reviewing the code and running the tests, i can see that
org.apache.axis2.deployment.scheduler.Scheduler needs to cancel a
timer. So this means that we have to add cleanup methods in various
layers. Here's a diff that i got working with help from Glen and
Deepal. Unfortunately it means adding a cleanup method in
AxisConfigurator interface. I'll run some more tests before i checkin.
thanks,
dims
On 6/19/07, Jerome Camilleri <[EMAIL PROTECTED]> wrote:
> Davanum Srinivas wrote:
> > Please don't call createConfigurationContextFromFileSystem multiple
> > times. just call once when the daemon starts.
> thanks for this workaround...but don't you think that we should have a
> way to clean up the ressources used by the ConfigurationContext ?
>
> Regards
>
> Jérôme
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Davanum Srinivas :: http://davanum.wordpress.com
--
Davanum Srinivas :: http://davanum.wordpress.com
Index: src/org/apache/axis2/deployment/WarBasedAxisConfigurator.java
===================================================================
--- src/org/apache/axis2/deployment/WarBasedAxisConfigurator.java (revision 548719)
+++ src/org/apache/axis2/deployment/WarBasedAxisConfigurator.java (working copy)
@@ -144,6 +144,9 @@
}
axisConfig = populateAxisConfiguration(axis2Stream);
+ if(axis2Stream != null){
+ axis2Stream.close();
+ }
Parameter param = new Parameter();
param.setName(Constants.Configuration.ARTIFACTS_TEMP_DIR);
param.setValue(config.getServletContext().getAttribute("javax.servlet.context.tempdir"));
@@ -233,6 +236,7 @@
log.error(ex + ": loading repository from classpath");
loadFromClassPath();
}
+ axisConfig.setConfigurator(this);
return axisConfig;
}
Index: src/org/apache/axis2/deployment/DeploymentEngine.java
===================================================================
--- src/org/apache/axis2/deployment/DeploymentEngine.java (revision 548719)
+++ src/org/apache/axis2/deployment/DeploymentEngine.java (working copy)
@@ -53,6 +53,7 @@
//to keep the web resource location if any
protected static String webLocationString = null;
+ protected Scheduler scheduler;
public static void setWebLocationString(String webLocationString) {
DeploymentEngine.webLocationString = webLocationString;
@@ -598,7 +599,7 @@
* @param listener : RepositoryListener
*/
protected void startSearch(RepositoryListener listener) {
- Scheduler scheduler = new Scheduler();
+ scheduler = new Scheduler();
scheduler.schedule(new SchedulerTask(listener), new DeploymentIterator());
}
@@ -1071,4 +1072,13 @@
public Deployer getDeployerForExtension(String extension) {
return (Deployer)extensionToDeployerMappingMap.get(extension);
}
+
+ /**
+ * Clean up the mess
+ */
+ public void cleanup() {
+ if(scheduler != null){
+ scheduler.cleanup();
+ }
+ }
}
Index: src/org/apache/axis2/deployment/FileSystemConfigurator.java
===================================================================
--- src/org/apache/axis2/deployment/FileSystemConfigurator.java (revision 548719)
+++ src/org/apache/axis2/deployment/FileSystemConfigurator.java (working copy)
@@ -13,6 +13,7 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
+import java.io.IOException;
/*
* Copyright 2004,2005 The Apache Software Foundation.
@@ -103,7 +104,7 @@
* @throws AxisFault
*/
public synchronized AxisConfiguration getAxisConfiguration() throws AxisFault {
- InputStream configStream;
+ InputStream configStream = null;
try {
if (axis2xml != null && !"".equals(axis2xml)) {
configStream = new FileInputStream(axis2xml);
@@ -114,6 +115,14 @@
axisConfig = populateAxisConfiguration(configStream);
} catch (FileNotFoundException e) {
throw new AxisFault("System can not find the given axis2.xml " + axis2xml);
+ } finally {
+ if(configStream != null) {
+ try {
+ configStream.close();
+ } catch (IOException e) {
+ throw AxisFault.makeFault(e);
+ }
+ }
}
Parameter axis2repoPara = axisConfig.getParameter(DeploymentConstants.AXIS2_REPO);
if (axis2repoPara != null) {
@@ -124,6 +133,7 @@
} else {
loadFromClassPath();
}
+ axisConfig.setConfigurator(this);
return axisConfig;
}
Index: src/org/apache/axis2/deployment/URLBasedAxisConfigurator.java
===================================================================
--- src/org/apache/axis2/deployment/URLBasedAxisConfigurator.java (revision 548719)
+++ src/org/apache/axis2/deployment/URLBasedAxisConfigurator.java (working copy)
@@ -75,6 +75,7 @@
} catch (IOException e) {
throw new AxisFault(e.getMessage());
}
+ axisConfig.setConfigurator(this);
return axisConfig;
}
Index: src/org/apache/axis2/deployment/scheduler/Scheduler.java
===================================================================
--- src/org/apache/axis2/deployment/scheduler/Scheduler.java (revision 548719)
+++ src/org/apache/axis2/deployment/scheduler/Scheduler.java (working copy)
@@ -63,6 +63,10 @@
}
}
+ public void cleanup(){
+ timer.cancel();
+ }
+
public class SchedulerTimerTask extends TimerTask {
private DeploymentIterator iterator;
private SchedulerTask schedulerTask;
Index: src/org/apache/axis2/context/ConfigurationContext.java
===================================================================
--- src/org/apache/axis2/context/ConfigurationContext.java (revision 548719)
+++ src/org/apache/axis2/context/ConfigurationContext.java (working copy)
@@ -540,6 +540,7 @@
if (listenerManager != null) {
listenerManager.stop();
}
+ axisConfiguration.cleanup();
cleanupTemp();
}
Index: src/org/apache/axis2/engine/AxisConfigurator.java
===================================================================
--- src/org/apache/axis2/engine/AxisConfigurator.java (revision 548719)
+++ src/org/apache/axis2/engine/AxisConfigurator.java (working copy)
@@ -40,4 +40,9 @@
* @throws AxisFault
*/
void engageGlobalModules() throws AxisFault;
+
+ /**
+ * Clean up the mess
+ */
+ void cleanup();
}
Index: src/org/apache/axis2/engine/AxisConfiguration.java
===================================================================
--- src/org/apache/axis2/engine/AxisConfiguration.java (revision 548719)
+++ src/org/apache/axis2/engine/AxisConfiguration.java (working copy)
@@ -127,8 +127,10 @@
private ClusterManager clusterManager;
+ private AxisConfigurator configurator;
+
/**
- * Constructor AxisConfigurationImpl.
+ * Constructor AxisConfiguration.
*/
public AxisConfiguration() {
moduleConfigmap = new HashMap();
@@ -1043,4 +1045,18 @@
setGlobalOutPhase(phasesInfo.getGlobalOutPhaseList());
setOutFaultPhases(phasesInfo.getOUT_FaultPhases());
}
+
+ public AxisConfigurator getConfigurator() {
+ return configurator;
+ }
+
+ public void setConfigurator(AxisConfigurator configurator) {
+ this.configurator = configurator;
+ }
+
+ public void cleanup(){
+ if(configurator != null){
+ configurator.cleanup();
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]