Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update cometd to 2.3.1 #6

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions CometdGrailsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ import org.cometd.bayeux.server.BayeuxServer
import org.springframework.web.context.support.ServletContextAttributeExporter

class CometdGrailsPlugin {
def version = "0.2.2"
def version = "0.2.3"
def grailsVersion = "1.2.1 > *"
def dependsOn = [:]
def pluginExcludes = [
'grails-app/services/**/test/',
'grails-app/views/error.gsp',
'scripts',
'web-app/'
'web-app/css/**',
'web-app/images/**',
'web-app/META-INF'
]

def author = 'Marcus Better'
Expand All @@ -46,21 +48,33 @@ CometD and the Bayeux protocol.
def documentation = "http://www.grails.org/plugin/cometd"

def doWithWebDescriptor = { xml ->
xml.setAttribute('version','3.0')

def conf = ConfigurationHolder.config.plugins.cometd
if (!conf.continuationFilter.disable) {
def filters = xml.'filter'
filters[filters.size() - 1] + {
filter {
'filter-name'('cross-origin')
'filter-class'('org.eclipse.jetty.servlets.CrossOriginFilter')
'async-supported'('true')
}
filter {
'filter-name'('continuation')
'filter-class'('org.eclipse.jetty.continuation.ContinuationFilter')
'async-supported'('true')
}
}

def filterMappings = xml.'filter-mapping'
filterMappings[filterMappings.size() - 1] + {
'filter-mapping' {
'filter-name'('cross-origin')
'url-pattern'('/cometd/*')
}
'filter-mapping' {
'filter-name'('continuation')
'servlet-name'('cometd')
'url-pattern'('/cometd/*')
}
}
}
Expand All @@ -80,10 +94,13 @@ CometD and the Bayeux protocol.
'url-pattern'('/cometd/*')
}
}

println xml
}

def doWithSpring = {
bayeux(BayeuxServerImpl, true) { bean ->
bayeux(BayeuxServerImpl) { bean ->
bean.initMethod = 'start'
bean.destroyMethod = 'stop'
}

Expand Down
10 changes: 5 additions & 5 deletions application.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#Grails Metadata file
#Tue Oct 19 04:56:43 GMT+01:00 2010
app.grails.version=1.3.5
#Thu Jan 19 17:02:43 CST 2012
app.grails.version=2.0.0
app.name=grails-cometd
app.servlet.version=2.4
app.servlet.version=2.5
app.version=0.1
plugins.functional-test=1.2.7
plugins.hibernate=1.3.5
plugins.tomcat=1.3.5
plugins.hibernate=2.0.0
plugins.tomcat=2.0.0
3 changes: 2 additions & 1 deletion grails-app/conf/BuildConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ grails.project.dependency.resolution = {
mavenCentral()
}
dependencies {
def cometdVer = '2.0.0'
def cometdVer = '2.3.1'
compile(group: 'org.cometd.java', name: 'cometd-java-server', version: cometdVer) {
excludes 'servlet-api'
}
compile group: 'org.cometd.java', name: 'bayeux-api', version: cometdVer
runtime group: 'org.eclipse.jetty', name: 'jetty-servlets', version: '7.4.4.v20110707'
test group: 'org.cometd.java', name: 'cometd-java-client', version: cometdVer
}
}
8 changes: 8 additions & 0 deletions grails-app/conf/CometDPluginResources.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
modules = {
cometd {
dependsOn 'jquery'

resource url: [plugin:'cometd', dir:'js/org', file:'cometd.js']
resource url: [plugin:'cometd', dir:'js/jquery', file:'jquery.cometd.js']
}
}
63 changes: 37 additions & 26 deletions grails-app/conf/DataSource.groovy
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
dataSource {
pooled = true
driverClassName = "org.hsqldb.jdbcDriver"
username = "sa"
password = ""
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true
cache.provider_class='net.sf.ehcache.hibernate.EhCacheProvider'
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop','update'
url = "jdbc:hsqldb:mem:devDB"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:hsqldb:mem:testDb"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:hsqldb:file:prodDb;shutdown=true"
}
}
}
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:devDb"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb"
// For MySQL production scenarios enable the following settings
// pooled = true
// properties {
// minEvictableIdleTimeMillis=1800000
// timeBetweenEvictionRunsMillis=1800000
// numTestsPerEvictionRun=3
// testOnBorrow=true
// testWhileIdle=true
// testOnReturn=true
// validationQuery="SELECT 1"
// }
}
}
}
Empty file.
13 changes: 2 additions & 11 deletions grails-app/services/grails/plugins/cometd/test/EchoService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,17 @@

package grails.plugins.cometd.test

import org.cometd.bayeux.server.ServerChannel

import org.springframework.beans.factory.InitializingBean
import org.cometd.bayeux.client.ClientSessionChannel

class EchoService implements InitializingBean
{
def bayeux

void afterPropertiesSet()
{
assert bayeux : 'bayeux object must be set'
def localSession = bayeux.newLocalSession('echo')
localSession.handshake()
def serverSession = localSession.getServerSession()
def channel = bayeux.getChannel('/echo', true)
channel.addListener({ from, chan, msg ->
if (from != localSession.getServerSession()) {
from.deliver serverSession, chan.id, [echo: msg.data.msg], null
}
true
} as ServerChannel.MessageListener)
}
}
24 changes: 13 additions & 11 deletions test/functional/CometTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,34 @@ class CometTests extends FunctionalTestCase
super.setUp()
client = new BayeuxClient(makeRequestURL(null, '/cometd').toString(), LongPollingTransport.create(null))
}

void tearDown()
{
super.tearDown()
client.disconnect();
client.waitFor(1000, BayeuxClient.State.DISCONNECTED);
}

void testHandshake()
{
def connectedLatch = new CountDownLatch(1)
client.getChannel(Channel.META_HANDSHAKE).addListener({ channel, message ->
connectedLatch.countDown()
} as ClientSessionChannel.MessageListener)
client.handshake()
assert connectedLatch.await(1, SECONDS) : 'handshake timeout'
assert client.waitFor(1000, BayeuxClient.State.CONNECTED) : 'handshake timeout'
}

// Simple echo service test to make sure that the bayeux bean was hooked up correctly to the CometdServlet.
void testEcho()
{
def latch = new CountDownLatch(1)
client.handshake()
client.waitFor(1000, BayeuxClient.State.CONNECTED)
def echoChannel = client.getChannel('/echo')
client.getChannel(Channel.META_HANDSHAKE).addListener({ channel, message ->
echoChannel.publish([msg: 'hello'])
} as ClientSessionChannel.MessageListener)
echoChannel.addListener({ channel, message ->
echoChannel.subscribe({ channel, message ->
if (message.data?.echo) {
assert message.data.echo == 'hello'
latch.countDown()
}
} as ClientSessionChannel.MessageListener)
client.handshake()
assert latch.await(2, SECONDS) : 'timeout'
echoChannel.publish([echo: 'hello'])
assert latch.await(4, SECONDS) : 'timeout'
}
}
41 changes: 16 additions & 25 deletions web-app/WEB-INF/applicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,28 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem

<bean id="grailsApplication" class="org.codehaus.groovy.grails.commons.GrailsApplicationFactoryBean">
<description>Grails application factory bean</description>
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
<property name="grailsResourceLoader" ref="grailsResourceLoader" />
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
<property name="grailsResourceLoader" ref="grailsResourceLoader" />
</bean>

<bean id="pluginManager" class="org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean">
<description>A bean that manages Grails plugins</description>
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
<property name="application" ref="grailsApplication" />
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
<property name="application" ref="grailsApplication" />
</bean>

<bean id="grailsConfigurator" class="org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator">
<constructor-arg>
<ref bean="grailsApplication" />
</constructor-arg>
<property name="pluginManager" ref="pluginManager" />
</bean>
<bean id="grailsConfigurator" class="org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator">
<constructor-arg>
<ref bean="grailsApplication" />
</constructor-arg>
<property name="pluginManager" ref="pluginManager" />
</bean>

<bean id="grailsResourceLoader" class="org.codehaus.groovy.grails.commons.GrailsResourceLoaderFactoryBean">
<property name="grailsResourceHolder" ref="grailsResourceHolder" />
</bean>
<bean id="grailsResourceLoader" class="org.codehaus.groovy.grails.commons.GrailsResourceLoaderFactoryBean" />

<bean id="grailsResourceHolder" scope="prototype" class="org.codehaus.groovy.grails.commons.spring.GrailsResourceHolder">
<property name="resources">
<value>classpath*:**/grails-app/**/*.groovy</value>
</property>
</bean>

<bean id="characterEncodingFilter"
class="org.springframework.web.filter.CharacterEncodingFilter">
<property name="encoding">
<value>utf-8</value>
</property>
</bean>
<bean id="characterEncodingFilter" class="org.springframework.web.filter.CharacterEncodingFilter">
<property name="encoding">
<value>utf-8</value>
</property>
</bean>
</beans>
2 changes: 1 addition & 1 deletion web-app/WEB-INF/sitemesh.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parser content-type="text/html;charset=ISO-8859-1"
class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" />
<parser content-type="text/html;charset=UTF-8"
class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" />
class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" />
</page-parsers>

<decorator-mappers>
Expand Down
25 changes: 17 additions & 8 deletions web-app/WEB-INF/tld/c.tld
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>

<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
<taglib xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<description>JSTL 1.1 core library</description>
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
version="2.1">

<description>JSTL 1.2 core library</description>
<display-name>JSTL core</display-name>
<tlib-version>1.1</tlib-version>
<tlib-version>1.2</tlib-version>
<short-name>c</short-name>
<uri>http://java.sun.com/jsp/jstl/core</uri>

Expand Down Expand Up @@ -74,7 +74,7 @@ not the body content should be processed.
<description>
Name of the exported scoped variable for the
resulting value of the test condition. The type
of the scoped variable is Boolean.
of the scoped variable is Boolean.
</description>
<name>var</name>
<required>false</required>
Expand Down Expand Up @@ -174,6 +174,9 @@ Collection of items to iterate over.
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.Object</type>
<deferred-value>
<type>java.lang.Object</type>
</deferred-value>
</attribute>
<attribute>
<description>
Expand Down Expand Up @@ -253,6 +256,9 @@ String of tokens to iterate over.
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
<deferred-value>
<type>java.lang.String</type>
</deferred-value>
</attribute>
<attribute>
<description>
Expand Down Expand Up @@ -322,7 +328,7 @@ visibility.
<tag>
<description>
Like &lt;%= ... &gt;, but for expressions.
</description>
</description>
<name>out</name>
<tag-class>org.apache.taglibs.standard.tag.rt.core.OutTag</tag-class>
<body-content>JSP</body-content>
Expand Down Expand Up @@ -467,6 +473,9 @@ Expression to be evaluated.
<name>value</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<deferred-value>
<type>java.lang.Object</type>
</deferred-value>
</attribute>
<attribute>
<description>
Expand Down
Loading