Skip to content

Commit

Permalink
MYFACES-4445
Browse files Browse the repository at this point in the history
  • Loading branch information
tandraschko committed Aug 29, 2022
1 parent 0e6109e commit 7d3f827
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Map;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
import jakarta.enterprise.inject.spi.BeanManager;
import jakarta.enterprise.inject.spi.InjectionPoint;
import jakarta.faces.annotation.ApplicationMap;
import jakarta.faces.annotation.HeaderMap;
Expand Down Expand Up @@ -229,11 +230,11 @@ public FlowBuilder getFlowBuilderInstance()

@Produces
@Push
public PushContext getPushContext(InjectionPoint ip)
public PushContext getPushContext(InjectionPoint ip, BeanManager beanManager)
{
Push push = ip.getAnnotated().getAnnotation(Push.class);
String channel = push.channel().isEmpty() ? ip.getMember().getName() : push.channel();
return new PushContextImpl(channel);
return new PushContextImpl(channel, beanManager);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@
import java.util.Set;
import java.util.concurrent.Future;
import jakarta.enterprise.inject.spi.BeanManager;
import jakarta.enterprise.inject.spi.CDI;
import jakarta.faces.FacesException;
import jakarta.faces.context.FacesContext;
import jakarta.faces.push.PushContext;
import org.apache.myfaces.cdi.util.CDIUtils;

public class PushContextImpl implements PushContext
{
private final String channel;
private final BeanManager beanManager;

public PushContextImpl(String channel)
public PushContextImpl(String channel, BeanManager beanManager)
{
this.channel = channel;
this.beanManager = beanManager;
}

public String getChannel()
Expand All @@ -53,17 +53,7 @@ public Set<Future<Void>> send(Object message)
{
//1. locate the channel and define the context
String channel = getChannel();
BeanManager beanManager = null;
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext != null)
{
beanManager = CDIUtils.getBeanManager(facesContext);
}
else
{
beanManager = CDI.current().getBeanManager();
}


WebsocketApplicationBean appTokenBean = CDIUtils.get(beanManager,
WebsocketApplicationBean.class, false);
WebsocketViewBean viewTokenBean = null;
Expand Down Expand Up @@ -142,17 +132,7 @@ public <S extends Serializable> Map<S, Set<Future<Void>>> send(Object message, C
{
//1. locate the channel and define the context
String channel = getChannel();
BeanManager beanManager = null;
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext != null)
{
beanManager = CDIUtils.getBeanManager(facesContext);
}
else
{
beanManager = CDI.current().getBeanManager();
}


WebsocketApplicationBean appTokenBean = CDIUtils.get(beanManager,
WebsocketApplicationBean.class, false);
WebsocketViewBean viewTokenBean = null;
Expand Down

0 comments on commit 7d3f827

Please sign in to comment.