I know this is an old thread, but figured i would add to it since it never got an answer and this is exactly what i am wanting to achieve.
Basically i started by first extending every method in CommonsMultipartResolver and setting a break point on every method.
Next i updated my bean definition to use my new class and did an upload and watched the order of the break points.
The reason i did this was that i wanted to tie in a ProgressListener before the upload started, but i needed a FileUpload object to attach the listener to which is not configurable by a bean
The ProgressListener is talked about here: http://commons.apache.org/fileupload/using.html in the watching progress section.
Here is the method i chose to tie into
Code:
import org.apache.commons.fileupload.FileUpload;
import org.apache.commons.fileupload.ProgressListener;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
public class MyCommonsMultipartResolver extends CommonsMultipartResolver {
@Override
protected FileUpload prepareFileUpload(String encoding) {
FileUpload fileUpload = super.prepareFileUpload(encoding);
ProgressListener progressListener = new ProgressListener() {
public void update(long pBytesRead, long pContentLength, int pItems) {
System.out.println("We are currently reading item " + pItems);
if (pContentLength == -1) {
System.out.println("So far, " + pBytesRead + " bytes have been read.");
} else {
System.out.println("So far, " + pBytesRead + " of " + pContentLength + " bytes have been read.");
}
}
};
fileUpload.setProgressListener(progressListener);
return fileUpload;
}
}
Basically i think i can tie the progress listener into some session status object that ajax dwr can access to report progress for the request. I know i should be injecting the ProgressListener in the constructor, but i will change that later.
Here is how i configured dwr inside spring 2.0 as this took me a while to find and figure out. This will allow me to make an ajax dwr call to retrieve the session status from the ProgressListener and update a progress indicator.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">
<dwr:controller id="dwrController" debug="false" />
<dwr:configuration>
<dwr:convert type="bean" class="com.......domain.Object1">
<dwr:include method="id" />
<dwr:include method="display" />
</dwr:convert>
<dwr:convert type="bean" class="com......domain.Object2">
<dwr:include method="id" />
<dwr:include method="display" />
</dwr:convert>
</dwr:configuration>
<bean id="dwrService" class="com......ui.dwr.service.provider.DwrServiceProvider">
<constructor-arg>
<!-- inject WebContextFactory so JMock unit tests can mock this object -->
<bean class="org.directwebremoting.WebContextFactory" />
</constructor-arg>
<dwr:remote javascript="dwrService">
<dwr:include method="getSomethingMethod" />
<dwr:include method="getSomethingElseMethod" />
</dwr:remote>
</bean>
<!-- keep the dwr mappings separate from other mappings -->
<bean id="dwrMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="order" value="1" />
<property name="alwaysUseFullPath" value="true"></property>
<property name="mappings">
<map>
<entry key="/dwr/**/*" value-ref="dwrController" />
</map>
</property>
</bean>
</beans>
Kevin.
Hopefull someday tomorrow will come and i will let you all know if things worked! Or maybe someone else will have a solution! But now some sleep is needed
but can't contain the excitement, but need sleep.....