Skip to content

Commit

Permalink
minor stuff
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@1482 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
nickarls committed Feb 11, 2009
1 parent 1c04cd9 commit 0fd96c7
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 23 deletions.
4 changes: 2 additions & 2 deletions webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
Expand Up @@ -176,9 +176,9 @@ protected void checkEnabledDeploymentTypes()

protected void addWebBeansDeploymentTypes()
{
if (!this.enabledDeploymentTypes.contains(WebBeans.class))
if (!this.enabledDeploymentTypes.contains(WebBean.class))
{
this.enabledDeploymentTypes.add(1, WebBeans.class);
this.enabledDeploymentTypes.add(1, WebBean.class);
}
}

Expand Down
Expand Up @@ -20,7 +20,7 @@
@Retention(RUNTIME)
@Documented
@DeploymentType
public @interface WebBeans
public @interface WebBean
{

}
Expand Up @@ -22,7 +22,7 @@
import javax.context.RequestScoped;
import javax.inject.Initializer;

import org.jboss.webbeans.WebBeans;
import org.jboss.webbeans.WebBean;
import org.jboss.webbeans.conversation.bindings.ConversationInactivityTimeout;

/**
Expand All @@ -33,7 +33,7 @@
*/
@RequestScoped
@Named("conversation")
@WebBeans
@WebBean
public class ConversationImpl implements Conversation
{
// The conversation ID
Expand Down
Expand Up @@ -24,7 +24,7 @@

import javax.context.SessionScoped;

import org.jboss.webbeans.WebBeans;
import org.jboss.webbeans.WebBean;

/**
* A ConversationTerminator implementation using Java SE scheduling
Expand All @@ -33,7 +33,7 @@
* @see org.jboss.webbeans.conversation.ConversationTerminator
*/
@SessionScoped
@WebBeans
@WebBean
public class JavaSEConversationTerminator implements ConversationTerminator, Serializable
{
private ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
Expand Down
Expand Up @@ -21,7 +21,7 @@

import javax.context.SessionScoped;

import org.jboss.webbeans.WebBeans;
import org.jboss.webbeans.WebBean;

/**
* A ConversationIdGenerator implementation using running numerical values
Expand All @@ -30,7 +30,7 @@
*
*/
@SessionScoped
@WebBeans
@WebBean
public class NumericConversationIdGenerator implements ConversationIdGenerator, Serializable
{
// The next conversation ID
Expand Down
Expand Up @@ -26,7 +26,7 @@
import javax.inject.Produces;
import javax.servlet.http.HttpSession;

import org.jboss.webbeans.WebBeans;
import org.jboss.webbeans.WebBean;
import org.jboss.webbeans.bootstrap.WebBeansBootstrap;
import org.jboss.webbeans.context.ConversationContext;
import org.jboss.webbeans.conversation.bindings.ConversationConcurrentAccessTimeout;
Expand All @@ -41,7 +41,7 @@
*
*/
@SessionScoped
@WebBeans
@WebBean
public class ServletConversationManager implements ConversationManager, Serializable
{
private static LogProvider log = Logging.getLogProvider(WebBeansBootstrap.class);
Expand Down Expand Up @@ -83,15 +83,15 @@ public ServletConversationManager()

@Produces
@ConversationInactivityTimeout
@WebBeans
@WebBean
public long getConversationTimeoutInMilliseconds()
{
return CONVERSATION_TIMEOUT_IN_MS;
}

@Produces
@ConversationConcurrentAccessTimeout
@WebBeans
@WebBean
public long getConversationConcurrentAccessTimeout()
{
return CONVERSATION_CONCURRENT_ACCESS_TIMEOUT_IN_MS;
Expand Down
Expand Up @@ -4,10 +4,10 @@
import javax.inject.Produces;
import javax.servlet.http.HttpSession;

import org.jboss.webbeans.WebBeans;
import org.jboss.webbeans.WebBean;

@RequestScoped
@WebBeans
@WebBean
public class HttpSessionManager
{
private HttpSession session;
Expand All @@ -19,7 +19,7 @@ public void setSession(HttpSession session)

@Produces
@RequestScoped
@WebBeans
@WebBean
HttpSession produceSession()
{
return session;
Expand Down
Expand Up @@ -35,12 +35,45 @@
* Filter for handling conversation propagation over redirects
*
* @author Nicklas Karlsson
*
*
*/
// TODO: Quick and dirty, not for actual usage yet ;-)
public class WebBeansServletFilter implements Filter
{

private class RedirectUrl
{
private String URL;
private FacesContext context;

public RedirectUrl(String URL)
{
this.URL = URL;
context = FacesContext.getCurrentInstance();
}

public RedirectUrl appendCid(String cid)
{
return new RedirectUrl(URL + (URL.indexOf("?") > 0 ? "&" : "?") + "cid=" + cid);
}

public RedirectUrl getRedirectView()
{
String requestPath = context.getExternalContext().getRequestContextPath();
return new RedirectUrl(URL.substring(URL.indexOf(requestPath) + requestPath.length()));
}

public RedirectUrl getActionUrl()
{
return new RedirectUrl(context.getApplication().getViewHandler().getActionURL(context, URL));
}

public String encode()
{
return context.getExternalContext().encodeActionURL(URL);
}
}

public void destroy()
{
}
Expand All @@ -55,17 +88,14 @@ private ServletResponse wrapResponse(HttpServletResponse response)
return new HttpServletResponseWrapper(response)
{
@Override
public void sendRedirect(String location) throws IOException
public void sendRedirect(String path) throws IOException
{
FacesContext context = FacesContext.getCurrentInstance();
Conversation conversation = CurrentManager.rootManager().getInstanceByType(Conversation.class);
if (conversation.isLongRunning())
{
location = context.getApplication().getViewHandler().getActionURL(context, location);
String appendedConversation = "?cid=" + conversation.getId();
location = context.getExternalContext().encodeActionURL(location + appendedConversation);
path = new RedirectUrl(path).getRedirectView().getActionUrl().appendCid(conversation.getId()).encode();
}
super.sendRedirect(location);
super.sendRedirect(path);
}
};
}
Expand Down

0 comments on commit 0fd96c7

Please sign in to comment.