[JBoss Seam] - Re: Progress bar for fileUpload
by zaya
A temporary solution:
Overide multipartFilter to put multipartRequest into session(Put this class anywhere in application source):
| @Startup
| @Scope(APPLICATION)
| @Name("org.jboss.seam.web.multipartFilter")
| @Install(precedence = Install.APPLICATION)
| @BypassInterceptors
| @Filter(within={"org.jboss.seam.web.ajax4jsfFilter", "org.jboss.seam.web.exceptionFilter"})
| public class MonitoredMultipartFilter extends MultipartFilter {
|
| @Override
| public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
| throws IOException, ServletException {
| if (!(response instanceof HttpServletResponse)) {
| chain.doFilter(request, response);
| return;
| }
|
| final HttpServletRequest httpRequest = (HttpServletRequest) request;
|
| if (isMultipartRequest(httpRequest)) {
| processMultipart(httpRequest, response, chain);
| } else chain.doFilter(request, response);
| }
|
| private void processMultipart(HttpServletRequest httpRequest, ServletResponse response, FilterChain chain)
| throws IOException, ServletException {
|
| MultipartRequest multipartRequest = new MultipartRequest(httpRequest, getCreateTempFiles(), getMaxRequestSize());
| HttpSession httpSession = httpRequest.getSession(false);
| if (httpSession != null) {
| httpSession.setAttribute("MULITIPART_REQUESET", multipartRequest);
| }
|
| chain.doFilter(multipartRequest, response);
|
| }
|
| private boolean isMultipartRequest(HttpServletRequest request) {
| if (!"post".equals(request.getMethod().toLowerCase())) {
| return false;
| }
|
| String contentType = request.getContentType();
| if (contentType == null) {
| return false;
| }
|
| if (contentType.toLowerCase().startsWith(MULTIPART)) {
| return true;
| }
|
| return false;
| }
| }
|
And in the backing seam component:
| @In(value="MULITIPART_REQUESET",required=false) private MultipartRequest multipartRequest;
| private static final String UPLOAD_COMPONENT_ID_IN_HTML = "uploadForm:upload";
|
| @WebRemote
| public Integer uploadPercentage() {
| int uploadsize = multipartRequest.getFileSize(UPLOAD_COMPONENT_ID_IN_HTML);
| int totalsize = multipartRequest.getContentLength();
| if (uploadsize>=0 && totalsize>=0) {
| Integer progress = (int)Math.floor(((double)uploadsize / (double) totalsize) * 100.0);
| return progress;
| } else return null;
| }
|
Now seam remoting can access uploadPercentage() method to get the progress.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098102#4098102
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098102
18Â years, 8Â months
[JBossCache] - Re: Understanding JBCache 2.0/Hibernate integration
by bstansberryï¼ jboss.com
If you want to use a Provider impl, have a look at TreeCacheProviderHook and OptimisticTreeCacheProviderHook in the AS trunk ejb3 module, org.jboss,ejb3.entity package. Those are based on AS 4.2.0 classes that have some bug fixes in them that aren't in the Hibernate classes, particularly related to classloading issues. In AS trunk I converted them to the JBC 2.0 API. Those classes will be replaced by the new Hibernate stuff, and may have bugs, but they may save you some work.
It's been a while, but IIRC, the biggest problem with the trunk classes is timestamp caching doesn't work properly -- the JBC 2.0 putForExternalRead semantic won't work for timestamps. Timestamps need to be replicated async, so you'd need to use Option.setForceAsynchronous(true) (only in 2.1.0) to make that happen if the cache region is for the timestamps cache.
Another caveat is INVALIDATION shouldn't be used if query caching is enabled. INVALIDATION_SYNC is the best choice for entity/collection caching but is absolutely incorrect for timestamp caching. Hence the move to using different multiplexed JBC instances.
Re: eviction, let's say you've given a region prefix to your session factory of "foo" and are caching an entity of type com.foo.Bar. Query caching is enabled.
With a Provider, you'd end up with these regions in JBC:
/foo/com/foo/Bar
/foo/org/hibernate/cache/StandardQueryCache
/foo/org/hibernate/cache/UpdateTimestampsCache
Typically you'd set up an LRU eviction region config for /foo/com/foo/Bar and probably another for /foo/org/hibernate/cache/StandardQueryCache. What the maxNodes, timeToLiveSeconds etc should be would depend on... well the normal stuff. :-)
You should never set up an eviction region that results in eviction of data under /foo/org/hibernate/cache/UpdateTimestampsCache. This precludes just setting up a region for /foo or just using /_default_ when you are using query caching.
With the new RegionFactory approach, you'd have these JBC regions:
/foo/com/foo/Bar/ENTITY
/foo/com/foo/Bar/COLL
/foo/org/hibernate/cache/StandardQueryCache
/TS/foo/org/hibernate/cache/UpdateTimestampsCache
Typically you'd set up an LRU eviction region config for /foo/com/foo/Bar and probably another for /foo/org/hibernate/cache/StandardQueryCache -- exactly the same as with Provider. The existence of the ENTITY and COLL subtrees is an internal detail you don't need to care about -- unless you want to separately configure eviction of entities vs collections.
Note too that with RegionFactory you could just set up an eviction region for /foo and thereby cover the entities, collections and queries. I deliberately put the timestamps in their own /TS namespace to make this possible.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098101#4098101
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098101
18Â years, 8Â months
[Security & JAAS/JBoss] - 2 strage problems with JAAS
by caijc
I deployed 2 modules to jboss 4.2.0 GA: A EJB3 JAR module using "others" security domain( packed with a jboss.xml and users.properties and roles.properties);A Web WAR module,which only contains several jsp pages(of course,and a configured web.xml and jboss-web.xml,but NO java classes).I don't think this kind of deployment is too strange,right?
Now I try to login from the web module,to access the EJB module,and JBOSS tells me "no users.properties and roles.properties found".Another guy told me to create an empty "classes" folder under WEB-INF in the web module,and this exception disappers.This..sounds a little funny.This brings out my 1st question:
Why can't jboss find the .properties files in JAR module?
Well,I tried to login again,and this time,when I inputed a wrong username or password,JBOSS told me "this is wrong" and redireced me to the err-handling page.This is ok.But..when I uses a correct username and password,I see a HTTP-408 page,which telling me login timeout.
I cleared IE cache,restared IE,restarted JBOSS,and nothing changed.This is my 2nd question:
Why?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098100#4098100
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098100
18Â years, 8Â months