myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1766458 - in /myfaces/current23/test-webapp-cdi: ./ src/main/java/org/apache/myfaces/example/jsf23/cdi/ src/main/java/org/apache/myfaces/example/jsf23/websocket/ src/main/resources/META-INF/services/ src/main/webapp/WEB-INF/ src/main/webap...
Date Mon, 24 Oct 2016 23:10:45 GMT
Author: lu4242
Date: Mon Oct 24 23:10:45 2016
New Revision: 1766458

URL: http://svn.apache.org/viewvc?rev=1766458&view=rev
Log:
MYFACES-4069 Implement f:websocket and related api (example)

Added:
    myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/cdi/
    myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/cdi/Eager.java
    myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/cdi/EagerExtension.java
    myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/
    myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/ClockBean.java
    myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/ClockPingBean.java
    myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/FakeEndpoint.java
    myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/PushBean.java
    myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/UpdateClockJob.java
    myfaces/current23/test-webapp-cdi/src/main/resources/META-INF/services/
    myfaces/current23/test-webapp-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
    myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/
    myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/push.js
    myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/push_1.js
    myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/websocket.js
    myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/
    myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/clockAjax.xhtml
      - copied, changed from r1758048, myfaces/current23/test-webapp-cdi/src/main/webapp/helloWorld.xhtml
    myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/testws.xhtml
      - copied, changed from r1758048, myfaces/current23/test-webapp-cdi/src/main/webapp/helloWorld.xhtml
    myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/websocket.xhtml
      - copied, changed from r1758048, myfaces/current23/test-webapp-cdi/src/main/webapp/helloWorld.xhtml
Modified:
    myfaces/current23/test-webapp-cdi/pom.xml
    myfaces/current23/test-webapp-cdi/src/main/webapp/WEB-INF/web.xml
    myfaces/current23/test-webapp-cdi/src/test/jetty/override-mojarra-web.xml
    myfaces/current23/test-webapp-cdi/src/test/jetty/override-myfaces-web.xml

Modified: myfaces/current23/test-webapp-cdi/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/pom.xml?rev=1766458&r1=1766457&r2=1766458&view=diff
==============================================================================
--- myfaces/current23/test-webapp-cdi/pom.xml (original)
+++ myfaces/current23/test-webapp-cdi/pom.xml Mon Oct 24 23:10:45 2016
@@ -55,6 +55,8 @@
         <jsf-myfaces.version>2.3.0-SNAPSHOT</jsf-myfaces.version>
         <jsf-mojarra.version>2.3.0-m06</jsf-mojarra.version>        
         <jetty.maven.plugin.version>8.1.3.v20120416</jetty.maven.plugin.version>
+        <!-- 9.3.7.v20160115 9.3.9.v20160517 -->
+        <jetty9.maven.plugin.version>9.3.9.v20160517</jetty9.maven.plugin.version>
         <openwebbeans.version>1.6.3</openwebbeans.version>
     </properties>
 
@@ -256,7 +258,7 @@
                       <!--This plugin allows to run the war using mvn jetty:run -->
                       <groupId>org.eclipse.jetty</groupId>
                       <artifactId>jetty-maven-plugin</artifactId>
-                      <version>9.3.7.v20160115</version>
+                      <version>${jetty9.maven.plugin.version}</version>
                       <configuration>
                           <webApp>
                               <contextPath>/${artifactId}</contextPath>
@@ -458,30 +460,35 @@
                         <!--This plugin allows to run the war using mvn jetty:run -->
                       <groupId>org.eclipse.jetty</groupId>
                       <artifactId>jetty-maven-plugin</artifactId>
-                      <version>9.3.7.v20160115</version>
+                      <version>${jetty9.maven.plugin.version}</version>
                       <configuration>
                           <webApp>
                               <contextPath>/${artifactId}</contextPath>
                               <overrideDescriptor>src/test/jetty/override-mojarra-web.xml</overrideDescriptor>
                           </webApp>
+                          <contextXml>src/main/webapp/WEB-INF/jetty-context.xml</contextXml>
                           <scanIntervalSeconds>5</scanIntervalSeconds>
                       </configuration>
                         <dependencies>
                            <!-- Tld scanning only works when JSF is included
                                 as container dependency. Add other jsf libraries
                                 here, so jetty:run goal can find and process them -->
-                           <dependency>
-                               <groupId>com.sun.faces</groupId>
-                               <artifactId>jsf-api</artifactId>
-                               <version>${jsf-mojarra.version}</version>
-                               <scope>compile</scope>
-                           </dependency>
-                           <dependency>
-                               <groupId>com.sun.faces</groupId>
-                               <artifactId>jsf-impl</artifactId>
-                               <version>${jsf-mojarra.version}</version>
-                               <scope>runtime</scope>
-                           </dependency>
+
+                            <dependency>
+                                <groupId>org.glassfish</groupId>
+                                <artifactId>javax.faces</artifactId>
+                                <version>${jsf-mojarra.version}</version>
+                                <scope>runtime</scope>
+                            </dependency>
+
+                            <dependency>
+                                <groupId>org.jboss.weld.servlet</groupId>
+                                <artifactId>weld-servlet</artifactId>
+                                <version>2.3.5.Final</version>
+                                <scope>runtime</scope>
+                            </dependency>
+                            
+                            <!--
                             <dependency>
                                 <groupId>org.apache.geronimo.specs</groupId>
                                 <artifactId>geronimo-jta_1.1_spec</artifactId>
@@ -535,7 +542,7 @@
                                 <artifactId>openwebbeans-resource</artifactId>
                                 <version>${openwebbeans.version}</version>
                                 <scope>runtime</scope>
-                            </dependency>
+                            </dependency>-->
                         </dependencies>
                     </plugin>
                 </plugins>

Added: myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/cdi/Eager.java
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/cdi/Eager.java?rev=1766458&view=auto
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/cdi/Eager.java (added)
+++ myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/cdi/Eager.java Mon Oct 24 23:10:45 2016
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.example.jsf23.cdi;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+/**
+ *
+ */
+@Qualifier
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface Eager
+{
+    
+}

Added: myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/cdi/EagerExtension.java
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/cdi/EagerExtension.java?rev=1766458&view=auto
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/cdi/EagerExtension.java (added)
+++ myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/cdi/EagerExtension.java Mon Oct 24 23:10:45 2016
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.example.jsf23.cdi;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterDeploymentValidation;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessBean;
+
+/**
+ *
+ */
+public class EagerExtension implements Extension
+{
+
+    private List<Bean<?>> eagerBeansList = new ArrayList<Bean<?>>();
+
+    public <T> void collect(@Observes ProcessBean<T> event)
+    {
+        if (event.getAnnotated().isAnnotationPresent(Eager.class)
+                && event.getAnnotated().isAnnotationPresent(ApplicationScoped.class))
+        {
+            eagerBeansList.add(event.getBean());
+        }
+    }
+
+    public void load(@Observes AfterDeploymentValidation event, BeanManager beanManager)
+    {
+        for (Bean<?> bean : eagerBeansList)
+        {
+            // note: toString() is important to instantiate the bean
+            beanManager.getReference(bean, bean.getBeanClass(), beanManager.createCreationalContext(bean)).toString();
+        }
+    }
+}

Added: myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/ClockBean.java
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/ClockBean.java?rev=1766458&view=auto
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/ClockBean.java (added)
+++ myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/ClockBean.java Mon Oct 24 23:10:45 2016
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.example.jsf23.websocket;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.faces.push.Push;
+import javax.faces.push.PushContext;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ *
+ */
+@Named
+@ApplicationScoped
+public class ClockBean implements Serializable
+{
+
+    private static final Logger LOG = Logger.getLogger(ClockBean.class.getName());
+
+    @Inject
+    @Push(channel = "clock")
+    private PushContext push;
+    
+    private String currentTime;
+    
+    private int steps = 0;
+    
+    @PostConstruct
+    public void init()
+    {
+        updateCurrentTime();
+    }
+    
+    public void updateCurrentTime()
+    {
+        Calendar now = Calendar.getInstance();
+
+        String time = now.get(Calendar.HOUR_OF_DAY) + ":"
+                + now.get(Calendar.MINUTE) + ":" + now.get(Calendar.SECOND);
+        LOG.log(Level.INFO, "Time: {0}", time);
+
+        this.setCurrentTime(time);
+    }
+
+    public void clockAction()
+    {
+        updateCurrentTime();
+        
+        steps++;
+        push.send("showCurrentTime");
+        if (steps % 10 == 0)
+        {
+            push.send("showLastEventTime");
+        }
+    }
+
+    /**
+     * @return the currentTime
+     */
+    public String getCurrentTime()
+    {
+        return currentTime;
+    }
+
+    /**
+     * @param currentTime the currentTime to set
+     */
+    public void setCurrentTime(String currentTime)
+    {
+        this.currentTime = currentTime;
+    }
+}

Added: myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/ClockPingBean.java
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/ClockPingBean.java?rev=1766458&view=auto
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/ClockPingBean.java (added)
+++ myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/ClockPingBean.java Mon Oct 24 23:10:45 2016
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.example.jsf23.websocket;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.enterprise.context.ApplicationScoped;
+import javax.faces.push.Push;
+import javax.faces.push.PushContext;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.apache.myfaces.example.jsf23.cdi.Eager;
+
+/**
+ * This job push every second an update over a clock
+ */
+@Named
+@Eager
+@ApplicationScoped
+public class ClockPingBean
+{
+    private ScheduledExecutorService scheduler; 
+    //private Timer timer;
+    
+    @Inject
+    private ClockBean clockBean;
+
+    @PostConstruct
+    public void init() {
+        scheduler = Executors.newSingleThreadScheduledExecutor();
+        scheduler.scheduleAtFixedRate(new UpdateClockJob(clockBean), 0, 1, TimeUnit.SECONDS);
+        //timer = new Timer();
+        //timer.scheduleAtFixedRate(new UpdateClockJob(push), 2000, 1000);
+    }
+
+    @PreDestroy
+    public void destroy() {
+        //timer.cancel();
+        scheduler.shutdownNow();
+    }
+    
+}

Added: myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/FakeEndpoint.java
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/FakeEndpoint.java?rev=1766458&view=auto
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/FakeEndpoint.java (added)
+++ myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/FakeEndpoint.java Mon Oct 24 23:10:45 2016
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.example.jsf23.websocket;
+
+import javax.websocket.Endpoint;
+import javax.websocket.EndpointConfig;
+import javax.websocket.Session;
+
+/**
+ * This class is a hack to detected by websocket implementation to enable the feature for the current web application.
+ */
+public class FakeEndpoint extends Endpoint
+{
+
+    public void onOpen(Session session, EndpointConfig config)
+    {
+    }
+}

Added: myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/PushBean.java
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/PushBean.java?rev=1766458&view=auto
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/PushBean.java (added)
+++ myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/PushBean.java Mon Oct 24 23:10:45 2016
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.example.jsf23.websocket;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.enterprise.context.ApplicationScoped;
+import javax.faces.push.Push;
+import javax.faces.push.PushContext;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ *
+ */
+@Named
+@ApplicationScoped
+public class PushBean implements Serializable
+{
+
+    private static final Logger LOG = Logger.getLogger(PushBean.class.getName());
+
+    @Inject
+    @Push(channel = "clock")
+    private PushContext push;
+
+    public void clockAction()
+    {
+        Calendar now = Calendar.getInstance();
+
+        String time = now.get(Calendar.HOUR_OF_DAY) + ":"
+                + now.get(Calendar.MINUTE) + ":" + now.get(Calendar.SECOND);
+        LOG.log(Level.INFO, "Time: {0}", time);
+
+        push.send(time);
+    }
+}

Added: myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/UpdateClockJob.java
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/UpdateClockJob.java?rev=1766458&view=auto
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/UpdateClockJob.java (added)
+++ myfaces/current23/test-webapp-cdi/src/main/java/org/apache/myfaces/example/jsf23/websocket/UpdateClockJob.java Mon Oct 24 23:10:45 2016
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.example.jsf23.websocket;
+
+import java.util.TimerTask;
+
+/**
+ *
+ */
+public class UpdateClockJob extends TimerTask
+{
+    private ClockBean clockBean;
+
+    public UpdateClockJob(ClockBean clockBean)
+    {
+        this.clockBean = clockBean;
+    }
+
+    @Override
+    public void run()
+    {
+        clockBean.clockAction();
+    }
+
+}

Added: myfaces/current23/test-webapp-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension?rev=1766458&view=auto
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension (added)
+++ myfaces/current23/test-webapp-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension Mon Oct 24 23:10:45 2016
@@ -0,0 +1 @@
+org.apache.myfaces.example.jsf23.cdi.EagerExtension
\ No newline at end of file

Modified: myfaces/current23/test-webapp-cdi/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/main/webapp/WEB-INF/web.xml?rev=1766458&r1=1766457&r2=1766458&view=diff
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/current23/test-webapp-cdi/src/main/webapp/WEB-INF/web.xml Mon Oct 24 23:10:45 2016
@@ -83,13 +83,25 @@
         <param-name>org.apache.myfaces.annotation.SCAN_PACKAGES</param-name>
         <param-value>org.apache.myfaces.example.jsf23</param-value>
     </context-param>
+    
+
+
+    <context-param>
+     <param-name>javax.faces.ENABLE_CDI_RESOLVER_CHAIN</param-name>
+     <param-value>true</param-value>
+    </context-param>   
+    <context-param>
+     <param-name>javax.faces.ENABLE_WEBSOCKET_ENDPOINT</param-name>
+     <param-value>true</param-value>
+    </context-param>
 
 	<!-- Listener for OpenWebBeans configuration -->
+        <!--
     <listener>
         <listener-class>
             org.apache.webbeans.servlet.WebBeansConfigurationListener
         </listener-class>
-    </listener>
+    </listener>-->
 
     <!-- Faces Servlet -->
     <servlet>
@@ -109,4 +121,7 @@
         <welcome-file>index.html</welcome-file>
     </welcome-file-list>
 
+    <session-config>
+        <session-timeout>3</session-timeout>
+    </session-config>
 </web-app>

Added: myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/push.js
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/push.js?rev=1766458&view=auto
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/push.js (added)
+++ myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/push.js Mon Oct 24 23:10:45 2016
@@ -0,0 +1,257 @@
+if (!jsf.push) {
+
+    /**
+    * @namespace jsf.ajax
+    */
+    jsf.push = new function() {
+
+    // "Constant" fields ----------------------------------------------------------------------------------------------
+
+    var URL_PROTOCOL = window.location.protocol.replace("http", "ws") + "//";
+    var RECONNECT_INTERVAL = 500;
+    var MAX_RECONNECT_ATTEMPTS = 25;
+    var REASON_EXPIRED = "Expired";
+
+    // Private static fields ------------------------------------------------------------------------------------------
+
+    /* socket map by token */
+    var sockets = {};
+    /* component attributes by clientId */
+    var components = {};
+    /* client ids by token (share websocket connection) */
+    var clientIdsByTokens = {}; 
+    var self = {};
+
+    // Private constructor functions ----------------------------------------------------------------------------------
+
+    /**
+     * Creates a reconnecting web socket. When the web socket successfully connects on first attempt, then it will
+     * automatically reconnect on timeout with cumulative intervals of 500ms with a maximum of 25 attempts (~3 minutes).
+     * The <code>onclose</code> function will be called with the error code of the last attempt.
+     * @constructor
+     * @param {string} url The URL of the web socket 
+     * @param {string} channel The name of the web socket channel.
+     * @param {function} onopen The function to be invoked when the web socket is opened.
+     * @param {function} onmessage The function to be invoked when a message is received.
+     * @param {function} onclose The function to be invoked when the web socket is closed.
+     */
+    function Socket(channelToken, url, channel) {
+
+        // Private fields -----------------------------------------------------------------------------------------
+
+        var socket;
+        var reconnectAttempts;
+        var self = this;
+
+        // Public functions ---------------------------------------------------------------------------------------
+
+        /**
+         * Opens the reconnecting web socket.
+         */
+        self.open = function() {
+            if (socket && socket.readyState == 1) {
+                return;
+            }
+
+            socket = new WebSocket(url);
+
+            socket.onopen = function(event) {
+                if (reconnectAttempts == null) {
+                    var clientIds = clientIdsByTokens[channelToken];
+                    for (var i = clientIds.length - 1; i >= 0; i--){
+                        var socketClientId = clientIds[i];
+                        components[socketClientId]['onopen'](channel);
+                    }
+                }
+                reconnectAttempts = 0;
+            }
+
+            socket.onmessage = function(event) {
+                var message = JSON.parse(event.data);
+                for (var i = clientIdsByTokens[channelToken].length - 1; i >= 0; i--){
+                    var socketClientId = clientIdsByTokens[channelToken][i];
+                    if(document.getElementById(socketClientId)) {
+                        try{
+                            components[socketClientId]['onmessage'](message, channel, event);
+                        }catch(e){
+                            //Ignore
+                        }
+                        var behaviors = components[socketClientId]['behaviors'];
+                        var functions = behaviors[message];
+                        if (functions && functions.length) {
+                            for (var j = 0; j < functions.length; j++) {
+                                try{
+                                    functions[j](null);
+                                }catch(e){
+                                    //Ignore
+                                }
+                            }
+                        }
+                    } else {
+                        clientIdsByTokens[channelToken].splice(i,1);
+                    }
+                }
+                if (clientIdsByTokens[channelToken].length == 0){
+                    //tag dissapeared
+                    self.close();
+                }
+                
+            }
+
+            socket.onclose = function(event) {
+                if (!socket
+                    || (event.code == 1000 && event.reason == REASON_EXPIRED) 
+                    || (event.code == 1008) 
+                    || (reconnectAttempts == null) 
+                    || (reconnectAttempts >= MAX_RECONNECT_ATTEMPTS))
+                {
+                    var clientIds = clientIdsByTokens[channelToken];
+                    for (var i = clientIds.length - 1; i >= 0; i--){
+                        var socketClientId = clientIds[i];
+                        components[socketClientId]['onclose'](event.code, channel, event);
+                    }
+                }
+                else {
+                    setTimeout(self.open, RECONNECT_INTERVAL * reconnectAttempts++);
+                }
+            }
+        }
+
+        /**
+         * Closes the reconnecting web socket.
+         */
+        self.close = function() {
+            if (socket) {
+                var s = socket;
+                socket = null;
+                s.close();
+            }
+        }
+
+    }
+
+    // Public static functions ----------------------------------------------------------------------------------------
+
+    /**
+     * Initialize a web socket on the given channel. When connected, it will stay open and reconnect as long as channel
+     * is valid and <code>OmniFaces.Push.close()</code> hasn't explicitly been called on the same channel.
+     * @param {string} host The host of the web socket in either the format <code>example.com:8080/context</code>, or
+     * <code>:8080/context</code>, or <code>/context</code>.
+     * If the value is falsey, then it will default to <code>window.location.host</code>.
+     * If the value starts with <code>:</code>, then <code>window.location.hostname</code> will be prepended.
+     * If the value starts with <code>/</code>, then <code>window.location.host</code> will be prepended.
+     * @param {string} uri The uri of the web socket representing the channel name and identifier, separated by a 
+     * question mark. All open websockets on the same uri will receive the same push notification from the server.
+     * @param {function} onopen The JavaScript event handler function that is invoked when the web socket is opened.
+     * The function will be invoked with one argument: the channel name.
+     * @param {function} onmessage The JavaScript event handler function that is invoked when a message is received from
+     * the server. The function will be invoked with three arguments: the push message, the channel name and the raw
+     * <code>MessageEvent</code> itself.
+     * @param {function} onclose The JavaScript event handler function that is invoked when the web socket is closed.
+     * The function will be invoked with three arguments: the close reason code, the channel name and the raw
+     * <code>CloseEvent</code> itself. Note that this will also be invoked on errors and that you can inspect the
+     * close reason code if an error occurred and which one (i.e. when the code is not 1000). See also
+     * <a href="http://tools.ietf.org/html/rfc6455#section-7.4.1">RFC 6455 section 7.4.1</a> and
+     * <a href="http://docs.oracle.com/javaee/7/api/javax/websocket/CloseReason.CloseCodes.html">CloseCodes</a> API
+     * for an elaborate list.
+     * @param {boolean} autoconnect Whether or not to immediately open the socket. Defaults to <code>false</code>.
+     */
+    this.init = function(socketClientId, uri, onopen, onmessage, onclose, behaviorScripts, autoconnect) {
+            
+        /* jsf.push.init(8080,'clock?6dcd2736c937f644fc35c5b3f03fd91c',socketOpen,socketListener,socketClose,true); */
+        onclose = resolveFunction(onclose);
+        var channel = uri.split(/\?/)[0];
+
+        if (!window.WebSocket) { // IE6-9.
+            onclose(-1, channel);
+            return;
+        }
+                
+        var channelToken = uri.substr(uri.indexOf('?')+1);
+        
+        if (!components[socketClientId]) {
+            components[socketClientId] = {
+                'channelToken': channelToken,
+                'onopen': resolveFunction(onopen), 
+                'onmessage' : resolveFunction(onmessage),
+                'onclose': onclose, 
+                'behaviors': behaviorScripts, 
+                'autoconnect': autoconnect};
+            if (!clientIdsByTokens[channelToken]) {
+                clientIdsByTokens[channelToken] = [];
+            } 
+            clientIdsByTokens[channelToken].push(socketClientId);
+            if (!sockets[channelToken]){
+                sockets[channelToken] = new Socket(channelToken,
+                                    getBaseURL(uri), channel);
+            }
+        }
+
+        if (autoconnect) {
+            this.open(socketClientId);
+        }
+    }
+
+    /**
+     * Open the web socket on the given channel.
+     * @param {string} channel The name of the web socket channel.
+     * @throws {Error} When channel is unknown.
+     */
+    this.open = function(socketClientId) {
+        getSocket(components[socketClientId]['channelToken']).open();
+    }
+
+    /**
+     * Close the web socket on the given channel.
+     * @param {string} channel The name of the web socket channel.
+     * @throws {Error} When channel is unknown.
+     */
+    this.close = function(socketClientId) {
+        getSocket(components[socketClientId]['channelToken']).close();
+    }
+
+    // Private static functions ---------------------------------------------------------------------------------------
+
+    /**
+     * Get base URL from given host.
+     * @param {string} host The host of the web socket in either the format 
+     * <code>example.com:8080/context</code>, or <code>:8080/context</code>, or <code>/context</code>.
+     * If the value is falsey, then it will default to <code>window.location.host</code>.
+     * If the value starts with <code>:</code>, then <code>window.location.hostname</code> will be prepended.
+     * If the value starts with <code>/</code>, then <code>window.location.host</code> will be prepended.
+     */
+    function getBaseURL(url) {
+        if (url.indexOf("://") < 0)
+        {
+            var base = window.location.hostname+":"+window.location.port
+            return URL_PROTOCOL + base + url;
+        }else
+        {
+            return url;
+        }
+    }
+
+    /**
+     * Get socket associated with given channelToken.
+     * @param {string} channelToken The name of the web socket channelToken.
+     * @return {Socket} Socket associated with given channelToken.
+     * @throws {Error} When channelToken is unknown, you may need to initialize 
+     *                 it first via <code>init()</code> function.
+     */
+    function getSocket(channelToken) {
+        var socket = sockets[channelToken];
+        if (socket) {
+            return socket;
+        } else {
+            throw new Error("Unknown channelToken: " + channelToken);
+        }
+    }
+        
+    function resolveFunction(fn) {
+        return (typeof fn !== "function") && (fn = window[fn] || function(){}), fn;
+    }
+    // Expose self to public ------------------------------------------------------------------------------------------
+
+    //return self;
+    }
+}
\ No newline at end of file

Added: myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/push_1.js
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/push_1.js?rev=1766458&view=auto
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/push_1.js (added)
+++ myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/push_1.js Mon Oct 24 23:10:45 2016
@@ -0,0 +1,221 @@
+if (!jsf.push) {
+    /**
+    * @namespace jsf.ajax
+    */
+    jsf.push = new function() {
+
+    // "Constant" fields ----------------------------------------------------------------------------------------------
+
+    var URL_PROTOCOL = window.location.protocol.replace("http", "ws") + "//";
+    var RECONNECT_INTERVAL = 500;
+    var MAX_RECONNECT_ATTEMPTS = 25;
+    var REASON_EXPIRED = "Expired";
+
+    // Private static fields ------------------------------------------------------------------------------------------
+
+    var sockets = {};
+    var clientIds = {};
+    var self = {};
+
+    // Private constructor functions ----------------------------------------------------------------------------------
+
+    /**
+     * Creates a reconnecting web socket. When the web socket successfully connects on first attempt, then it will
+     * automatically reconnect on timeout with cumulative intervals of 500ms with a maximum of 25 attempts (~3 minutes).
+     * The <code>onclose</code> function will be called with the error code of the last attempt.
+     * @constructor
+     * @param {string} url The URL of the web socket 
+     * @param {string} channel The name of the web socket channel.
+     * @param {function} onopen The function to be invoked when the web socket is opened.
+     * @param {function} onmessage The function to be invoked when a message is received.
+     * @param {function} onclose The function to be invoked when the web socket is closed.
+     */
+    function Socket(socketClientId, url, channel, onopen, onmessage, onclose, behaviors) {
+
+        // Private fields -----------------------------------------------------------------------------------------
+
+        var socket;
+        var reconnectAttempts;
+        var self = this;
+
+        // Public functions ---------------------------------------------------------------------------------------
+
+        /**
+         * Opens the reconnecting web socket.
+         */
+        self.open = function() {
+            if (socket && socket.readyState == 1) {
+                return;
+            }
+
+            socket = new WebSocket(url);
+
+            socket.onopen = function(event) {
+                if (reconnectAttempts == null) {
+                    onopen(channel);
+                }
+
+                reconnectAttempts = 0;
+            }
+
+            socket.onmessage = function(event) {
+                            if(document.getElementById(socketClientId)) {
+                                var message = JSON.parse(event.data);
+                onmessage(message, channel, event);
+                                if (behaviors.length){
+                                    var functions = behaviors[message];
+                                    if (functions && functions.length) {
+                                        for (var i = 0; i < functions.length; i++) {
+                                            functions[i]();
+                                        }
+                                    }
+                                }
+                            } else {
+                                //tag dissapeared
+                                self.close();
+                            }
+            }
+
+            socket.onclose = function(event) {
+                if (!socket
+                    || (event.code == 1000 && event.reason == REASON_EXPIRED) 
+                    || (event.code == 1008) 
+                    || (reconnectAttempts == null) 
+                    || (reconnectAttempts >= MAX_RECONNECT_ATTEMPTS))
+                {
+                    onclose(event.code, channel, event);
+                }
+                else {
+                    setTimeout(self.open, RECONNECT_INTERVAL * reconnectAttempts++);
+                }
+            }
+        }
+
+        /**
+         * Closes the reconnecting web socket.
+         */
+        self.close = function() {
+            if (socket) {
+                var s = socket;
+                socket = null;
+                s.close();
+            }
+        }
+
+    }
+
+    // Public static functions ----------------------------------------------------------------------------------------
+
+    /**
+     * Initialize a web socket on the given channel. When connected, it will stay open and reconnect as long as channel
+     * is valid and <code>OmniFaces.Push.close()</code> hasn't explicitly been called on the same channel.
+     * @param {string} host The host of the web socket in either the format <code>example.com:8080/context</code>, or
+     * <code>:8080/context</code>, or <code>/context</code>.
+     * If the value is falsey, then it will default to <code>window.location.host</code>.
+     * If the value starts with <code>:</code>, then <code>window.location.hostname</code> will be prepended.
+     * If the value starts with <code>/</code>, then <code>window.location.host</code> will be prepended.
+     * @param {string} uri The uri of the web socket representing the channel name and identifier, separated by a 
+     * question mark. All open websockets on the same uri will receive the same push notification from the server.
+     * @param {function} onopen The JavaScript event handler function that is invoked when the web socket is opened.
+     * The function will be invoked with one argument: the channel name.
+     * @param {function} onmessage The JavaScript event handler function that is invoked when a message is received from
+     * the server. The function will be invoked with three arguments: the push message, the channel name and the raw
+     * <code>MessageEvent</code> itself.
+     * @param {function} onclose The JavaScript event handler function that is invoked when the web socket is closed.
+     * The function will be invoked with three arguments: the close reason code, the channel name and the raw
+     * <code>CloseEvent</code> itself. Note that this will also be invoked on errors and that you can inspect the
+     * close reason code if an error occurred and which one (i.e. when the code is not 1000). See also
+     * <a href="http://tools.ietf.org/html/rfc6455#section-7.4.1">RFC 6455 section 7.4.1</a> and
+     * <a href="http://docs.oracle.com/javaee/7/api/javax/websocket/CloseReason.CloseCodes.html">CloseCodes</a> API
+     * for an elaborate list.
+     * @param {boolean} autoconnect Whether or not to immediately open the socket. Defaults to <code>false</code>.
+     */
+    this.init = function(socketClientId, host, uri, onopen, onmessage, onclose, behaviorScripts, autoconnect) {
+            
+        /* jsf.push.init(8080,'clock?6dcd2736c937f644fc35c5b3f03fd91c',socketOpen,socketListener,socketClose,true); */
+        onclose = resolveFunction(onclose);
+        var channel = uri.split(/\?/)[0];
+
+        if (!window.WebSocket) { // IE6-9.
+            onclose(-1, channel);
+            return;
+        }
+                
+        var channelToken = uri.substr(uri.indexOf('?')+1);
+                
+        if (!sockets[socketClientId]) {
+            sockets[socketClientId] = new Socket(socketClientId,
+                                getBaseURL(host) + uri, channel, resolveFunction(onopen), 
+                                resolveFunction(onmessage), onclose, behaviorScripts );
+        }
+
+        if (autoconnect) {
+            this.open(socketClientId);
+        }
+    }
+
+    /**
+     * Open the web socket on the given channel.
+     * @param {string} channel The name of the web socket channel.
+     * @throws {Error} When channel is unknown.
+     */
+    this.open = function(socketClientId) {
+        getSocket(socketClientId).open();
+    }
+
+    /**
+     * Close the web socket on the given channel.
+     * @param {string} channel The name of the web socket channel.
+     * @throws {Error} When channel is unknown.
+     */
+    this.close = function(socketClientId) {
+        getSocket(socketClientId).close();
+    }
+
+    // Private static functions ---------------------------------------------------------------------------------------
+
+    /**
+     * Get base URL from given host.
+     * @param {string} host The host of the web socket in either the format 
+     * <code>example.com:8080/context</code>, or <code>:8080/context</code>, or <code>/context</code>.
+     * If the value is falsey, then it will default to <code>window.location.host</code>.
+     * If the value starts with <code>:</code>, then <code>window.location.hostname</code> will be prepended.
+     * If the value starts with <code>/</code>, then <code>window.location.host</code> will be prepended.
+     */
+    function getBaseURL(host) {
+                if (typeof host == 'number'){
+                    host = ":"+host;
+                }
+        host = host || "";
+        var base = (!host || host.indexOf("/") == 0) ? window.location.host
+                : (host.indexOf(":") == 0) ? window.location.hostname
+                : "";
+        return URL_PROTOCOL + base + host;
+    }
+
+    /**
+     * Get socket associated with given channel.
+     * @param {string} channel The name of the web socket channel.
+     * @return {Socket} Socket associated with given channel.
+     * @throws {Error} When channel is unknown. You may need to initialize it first via <code>init()</code> function.
+     */
+    function getSocket(socketClientId) {
+        var socket = sockets[socketClientId];
+
+        if (socket) {
+            return socket;
+        }
+        else {
+            throw new Error("Unknown socketClientId: " + socketClientId);
+        }
+    }
+        
+        function resolveFunction(fn) {
+            return (typeof fn !== "function") && (fn = window[fn] || function(){}), fn;
+        }        
+
+    // Expose self to public ------------------------------------------------------------------------------------------
+
+    //return self;
+    }
+}
\ No newline at end of file

Added: myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/websocket.js
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/websocket.js?rev=1766458&view=auto
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/websocket.js (added)
+++ myfaces/current23/test-webapp-cdi/src/main/webapp/resources/js/websocket.js Mon Oct 24 23:10:45 2016
@@ -0,0 +1,21 @@
+var wsUri = "ws://" + document.location.host + "/test-webapp-cdi/" + "javax.faces.push";
+var websocket = new WebSocket(wsUri);
+
+websocket.onerror = function(evt) { onError(evt) };
+
+function onError(evt) {
+    writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data);
+}
+
+// For testing purposes
+var output = document.getElementById("output");
+websocket.onopen = function(evt) { onOpen(evt) };
+
+function writeToScreen(message) {
+    output.innerHTML += message + "<br>";
+}
+
+function onOpen() {
+    writeToScreen("Connected to " + wsUri);
+}
+// End test functions
\ No newline at end of file

Copied: myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/clockAjax.xhtml (from r1758048, myfaces/current23/test-webapp-cdi/src/main/webapp/helloWorld.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/clockAjax.xhtml?p2=myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/clockAjax.xhtml&p1=myfaces/current23/test-webapp-cdi/src/main/webapp/helloWorld.xhtml&r1=1758048&r2=1766458&rev=1766458&view=diff
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/main/webapp/helloWorld.xhtml (original)
+++ myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/clockAjax.xhtml Mon Oct 24 23:10:45 2016
@@ -20,15 +20,19 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"
-      xmlns:h="http://java.sun.com/jsf/html"
-      xmlns:f="http://java.sun.com/jsf/core"
-      xmlns:ui="http://java.sun.com/jsf/facelets">
+      xmlns:h="http://xmlns.jcp.org/jsf/html"
+      xmlns:f="http://xmlns.jcp.org/jsf/core"
+      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
 <body>
 <ui:composition template="/META-INF/templates/example.xhtml">
   <ui:define name="container">
     <f:view>
+    <h:outputScript library="javax.faces" name="jsf.js" target="head"/>
+    <!--
+    <h:outputScript library="js" name="push.js" target="head"/>-->
+        
     <h1>MyFaces Hello World</h1>
-    <h:form id="mainForm">
+    <h:form id="mainForm">        
         <h:panelGrid columns="2">
             <h:outputLabel for="name" value="Please enter your name"/>
             <h:inputText id="name" value="#{helloWorld.name}" required="true"/>
@@ -40,7 +44,51 @@
             <h:outputText value="#{helloWorld.name}"/>
             <h:messages showDetail="true" showSummary="false"/>
         </h:panelGrid>
-    </h:form>
+
+        <h:commandButton value="Clock" action="#{clockBean.clockAction()}">
+           <f:ajax />
+        </h:commandButton>
+        
+        <div>
+            <h:outputText id="currentTime" value="#{clockBean.currentTime}" style="background-color: lightcyan "/>
+        </div>
+
+        <f:websocket channel="clock" scope="application" 
+                     onopen="socketOpen" 
+                     onclose="socketClose">
+            <f:ajax event="showCurrentTime" 
+                    execute="currentTime" 
+                    render="currentTime"/>
+        </f:websocket>
+
+        <div>
+            <h:outputText id="currentTime2" value="#{clockBean.currentTime}" style="background-color: lightcyan "/>
+        </div>
+        
+        <f:websocket channel="clock" scope="application">
+            <f:ajax event="showLastEventTime" 
+                    execute="currentTime2" 
+                    render="currentTime2"/>
+        </f:websocket>        
+
+        <hr/>
+        <div id="clockId"></div>
+        
+        <script type="text/javascript">
+         function socketListener(message, channel, event) {                      
+             document.getElementById("clockId").innerHTML += message + "<br/>";
+         }
+         function socketOpen(channelName) {                      
+             document.getElementById("clockId").innerHTML += channelName + "<br/>";
+         }
+         function socketClose(closeReason, channelName, closeEvent) {                      
+             document.getElementById("clockId").innerHTML += closeReason + "<br/>";
+         }
+         
+
+        </script>      
+        
+ </h:form>
     </f:view>
   </ui:define>
 </ui:composition>    

Copied: myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/testws.xhtml (from r1758048, myfaces/current23/test-webapp-cdi/src/main/webapp/helloWorld.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/testws.xhtml?p2=myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/testws.xhtml&p1=myfaces/current23/test-webapp-cdi/src/main/webapp/helloWorld.xhtml&r1=1758048&r2=1766458&rev=1766458&view=diff
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/main/webapp/helloWorld.xhtml (original)
+++ myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/testws.xhtml Mon Oct 24 23:10:45 2016
@@ -20,27 +20,43 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"
-      xmlns:h="http://java.sun.com/jsf/html"
-      xmlns:f="http://java.sun.com/jsf/core"
-      xmlns:ui="http://java.sun.com/jsf/facelets">
+      xmlns:h="http://xmlns.jcp.org/jsf/html"
+      xmlns:f="http://xmlns.jcp.org/jsf/core"
+      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
 <body>
 <ui:composition template="/META-INF/templates/example.xhtml">
   <ui:define name="container">
     <f:view>
     <h1>MyFaces Hello World</h1>
-    <h:form id="mainForm">
-        <h:panelGrid columns="2">
-            <h:outputLabel for="name" value="Please enter your name"/>
-            <h:inputText id="name" value="#{helloWorld.name}" required="true"/>
-            <h:commandLink value="Press me" action="#{helloWorld.send}"/>
-            <h:commandButton value="PostBack"/>
-            <h:commandButton value="Submit Ajax">
-                <f:ajax execute="@form" render="@form" />
-            </h:commandButton>
-            <h:outputText value="#{helloWorld.name}"/>
-            <h:messages showDetail="true" showSummary="false"/>
-        </h:panelGrid>
-    </h:form>
+    
+    <div id="output"></div>    
+    
+    <script type="text/javascript">//<![CDATA[
+        
+        var wsUri = "ws://" + document.location.host + "/test-webapp-cdi/" + "javax.faces.push/channel";
+        var websocket = new WebSocket(wsUri);
+
+        websocket.onerror = function(evt) { onError(evt) };
+
+        function onError(evt) {
+            writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data);
+        }
+
+        // For testing purposes
+        var output = document.getElementById("output");
+        websocket.onopen = function(evt) { onOpen(evt) };
+
+        function writeToScreen(message) {
+            output.innerHTML += message + "<br>";
+        }
+
+        function onOpen() {
+            writeToScreen("Connected to " + wsUri);
+        }
+        // End test functions
+        
+    //]]></script>
+    
     </f:view>
   </ui:define>
 </ui:composition>    

Copied: myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/websocket.xhtml (from r1758048, myfaces/current23/test-webapp-cdi/src/main/webapp/helloWorld.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/websocket.xhtml?p2=myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/websocket.xhtml&p1=myfaces/current23/test-webapp-cdi/src/main/webapp/helloWorld.xhtml&r1=1758048&r2=1766458&rev=1766458&view=diff
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/main/webapp/helloWorld.xhtml (original)
+++ myfaces/current23/test-webapp-cdi/src/main/webapp/websocket/websocket.xhtml Mon Oct 24 23:10:45 2016
@@ -20,15 +20,19 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"
-      xmlns:h="http://java.sun.com/jsf/html"
-      xmlns:f="http://java.sun.com/jsf/core"
-      xmlns:ui="http://java.sun.com/jsf/facelets">
+      xmlns:h="http://xmlns.jcp.org/jsf/html"
+      xmlns:f="http://xmlns.jcp.org/jsf/core"
+      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
 <body>
 <ui:composition template="/META-INF/templates/example.xhtml">
   <ui:define name="container">
     <f:view>
+    <h:outputScript library="javax.faces" name="jsf.js" target="head"/>
+    <!--
+    <h:outputScript library="js" name="push.js" target="head"/>-->
+        
     <h1>MyFaces Hello World</h1>
-    <h:form id="mainForm">
+    <h:form id="mainForm">        
         <h:panelGrid columns="2">
             <h:outputLabel for="name" value="Please enter your name"/>
             <h:inputText id="name" value="#{helloWorld.name}" required="true"/>
@@ -40,7 +44,33 @@
             <h:outputText value="#{helloWorld.name}"/>
             <h:messages showDetail="true" showSummary="false"/>
         </h:panelGrid>
-    </h:form>
+
+        <h:commandButton value="Clock" action="#{pushBean.clockAction()}">
+           <f:ajax />
+        </h:commandButton>
+
+        <f:websocket channel="clock" port="8080" scope="session" user="leo"
+                     onopen="socketOpen" onmessage="socketListener" 
+                     onclose="socketClose" connected="true" />
+
+        <hr/>
+        <div id="clockId"></div>
+
+        <script type="text/javascript">
+         function socketListener(message, channel, event) {                      
+             document.getElementById("clockId").innerHTML += message + "<br/>";
+         }
+         function socketOpen(channelName) {                      
+             document.getElementById("clockId").innerHTML += channelName + "<br/>";
+         }
+         function socketClose(closeReason, channelName, closeEvent) {                      
+             document.getElementById("clockId").innerHTML += closeReason + "<br/>";
+         }
+         
+
+        </script>      
+        
+ </h:form>
     </f:view>
   </ui:define>
 </ui:composition>    

Modified: myfaces/current23/test-webapp-cdi/src/test/jetty/override-mojarra-web.xml
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/test/jetty/override-mojarra-web.xml?rev=1766458&r1=1766457&r2=1766458&view=diff
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/test/jetty/override-mojarra-web.xml (original)
+++ myfaces/current23/test-webapp-cdi/src/test/jetty/override-mojarra-web.xml Mon Oct 24 23:10:45 2016
@@ -29,6 +29,17 @@
   </context-param>
 
   <listener>
+        <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
+  </listener>
+  <!--
+    <listener>
+        <listener-class>
+            org.apache.webbeans.servlet.WebBeansConfigurationListener
+        </listener-class>
+    </listener>  
+	-->
+	
+  <listener>
     <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
   </listener>
 

Modified: myfaces/current23/test-webapp-cdi/src/test/jetty/override-myfaces-web.xml
URL: http://svn.apache.org/viewvc/myfaces/current23/test-webapp-cdi/src/test/jetty/override-myfaces-web.xml?rev=1766458&r1=1766457&r2=1766458&view=diff
==============================================================================
--- myfaces/current23/test-webapp-cdi/src/test/jetty/override-myfaces-web.xml (original)
+++ myfaces/current23/test-webapp-cdi/src/test/jetty/override-myfaces-web.xml Mon Oct 24 23:10:45 2016
@@ -29,6 +29,11 @@
   </context-param>
 
   <listener>
+	<listener-class>
+		org.apache.webbeans.servlet.WebBeansConfigurationListener
+	</listener-class>
+  </listener>
+  <listener>
     <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
   </listener>
 



Mime
View raw message