Permalink
Browse files

updated to 0.1.2

git-svn-id: http://svn.codehaus.org/grails-plugins/grails-cometd/trunk@47170 832c1c66-4827-0410-8465-ccb17913cd09
  • Loading branch information...
1 parent a5719cd commit 76179942a8f724b4a945d62f8e614fee5c2de048 mingfai committed Jan 29, 2009
View
@@ -0,0 +1,3 @@
+
+0.1.2 - 2009-01-30
+ - updated to Grails 1.1 beta 3
View
@@ -1,9 +1,9 @@
-import org.grails.plugins.cometd.listener.ClientListener
import grails.util.GrailsUtil
import org.cometd.Bayeux
+import org.grails.plugins.cometd.CometdService
class CometdGrailsPlugin {
- def version = '0.1.1'
+ def version = '0.1.2'
def dependsOn = [:]
def author = "Mingfai Ma"
@@ -92,19 +92,16 @@ bayeux instance, and provide all demo programs from the cometd-jetty release.
def doWithApplicationContext = { applicationContext ->
+ def cometdService = applicationContext.getBean('cometdService')
def bayeux = applicationContext.getBean('bayeux')
applicationContext.servletContext.setAttribute(Bayeux.DOJOX_COMETD_BAYEUX, bayeux)
if (Boolean.getBoolean('cometd.listener')){
- def loggingListener = new ClientListener()
-
// create a logging client to log all messages
- def loggingClient = bayeux.newClient(ClientListener.class.simpleName)
- bayeux.getChannel('/meta/handshake', true).subscribe(loggingClient)
- bayeux.getChannel('/meta/connect', true).subscribe(loggingClient)
-
- // listen to all client added/removed events
- bayeux.addListener(loggingListener)
+ def agent = bayeux.newClient(CometdService.class.simpleName)
+ agent.addListener(cometdService)
+ bayeux.getChannel('/**', true).subscribe(agent)
+ bayeux.addListener(cometdService)
}
}
View
@@ -0,0 +1,3 @@
+
+Configuration
+ - allow more control over servlet-mapping URL patterns
View
@@ -1,4 +1,7 @@
-#Do not edit app.grails.* properties, they may change automatically. DO NOT put application configuration in here, it is not the right place!
-#Fri Jan 16 00:47:14 CST 2009
-app.grails.version=1.1-beta2
-app.name=cometd
+#utf-8
+#Fri Jan 30 04:21:22 CST 2009
+app.version=0.1
+app.servlet.version=2.4
+app.grails.version=1.1-beta3
+plugins.hibernate=1.1-beta3
+app.name=grails-cometd
@@ -0,0 +1,65 @@
+// locations to search for config files that get merged into the main config
+// config files can either be Java properties files or ConfigSlurper scripts
+
+// grails.config.locations = [ "classpath:${appName}-config.properties",
+// "classpath:${appName}-config.groovy",
+// "file:${userHome}/.grails/${appName}-config.properties",
+// "file:${userHome}/.grails/${appName}-config.groovy"]
+
+// if(System.properties["${appName}.config.location"]) {
+// grails.config.locations << "file:" + System.properties["${appName}.config.location"]
+// }
+grails.mime.file.extensions = true // enables the parsing of file extensions from URLs into the request format
+grails.mime.use.accept.header = false
+grails.mime.types = [html: ['text/html', 'application/xhtml+xml'],
+ xml: ['text/xml', 'application/xml'],
+ text: 'text-plain',
+ js: 'text/javascript',
+ rss: 'application/rss+xml',
+ atom: 'application/atom+xml',
+ css: 'text/css',
+ csv: 'text/csv',
+ all: '*/*',
+ json: ['application/json', 'text/json'],
+ form: 'application/x-www-form-urlencoded',
+ multipartForm: 'multipart/form-data'
+]
+// The default codec used to encode data with ${}
+grails.views.default.codec = "none" // none, html, base64
+grails.views.gsp.encoding = "UTF-8"
+grails.converters.encoding = "UTF-8"
+
+// enabled native2ascii conversion of i18n properties files
+grails.enable.native2ascii = true
+
+// set per-environment serverURL stem for creating absolute links
+environments {
+ production {
+ grails.serverURL = "http://grails.org/Cometd+Plugin"
+ }
+}
+
+// log4j configuration
+log4j = {
+ log4j = {
+ appenders {
+ console name: 'consoleAppender', layout: pattern(conversionPattern: "%d{ABSOLUTE} %-5p [%c{1}][%X{tid}] %m%n")
+ }
+ debug consoleAppender: 'org.grails.plugins.cometd'
+
+ error 'org.codehaus.groovy.grails.web.servlet', // controllers
+ 'org.codehaus.groovy.grails.web.pages', // GSP
+ 'org.codehaus.groovy.grails.web.sitemesh', // layouts
+ 'org.codehaus.groovy.grails."web.mapping.filter', // URL mapping
+ 'org.codehaus.groovy.grails."web.mapping', // URL mapping
+ 'org.codehaus.groovy.grails.commons', // core / classloading
+ 'org.codehaus.groovy.grails.plugins', // plugins
+ 'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
+ 'org.springframework',
+ 'org.hibernate'
+
+ warn 'org.mortbay.log'
+ }
+
+
+
@@ -0,0 +1,32 @@
+package org.grails.plugins.cometd
+
+import org.cometd.ClientBayeuxListener
+import org.cometd.MessageListener
+import org.cometd.Client
+import org.cometd.Message
+import java.util.concurrent.ConcurrentHashMap
+import org.cometd.Bayeux
+
+class CometdService implements ClientBayeuxListener, MessageListener {
+ boolean transactional = false
+
+ def clients = [:] as ConcurrentHashMap
+
+ def getCount() { return clients.size() }
+
+ public void clientAdded(Client client) {
+ clients.put(client.id, client)
+ if (log.isDebugEnabled()) log.debug("clientAdded() - client.id: ${client.id}, count: ${count}")
+ }
+
+ public void clientRemoved(Client client) {
+ clients.remove(client.id)
+ if (log.isDebugEnabled()) log.debug("clientRemoved() - client.id: ${client.id}, count: ${count}")
+ }
+
+ public void deliver(Client from, Client to, Message message) {
+ if (message.get(Bayeux.CHANNEL_FIELD) in ['/meta/handshake', '/meta/connect', '/meta/disconnect'])
+ println "deliver() - message.clientId: ${message.clientId}"
+ if (log.isDebugEnabled()) log.debug("deliver() - message.clientId: ${message.clientId}, message: ${message}")
+ }
+}
View
@@ -1,7 +1,22 @@
-<plugin name='cometd' version='0.1'>
- <author>Mingfai Ma</author>
- <authorEmail>mingfai.ma@gmail.com</authorEmail>
- <title>Enable your Grails application with Comet functions</title>
- <documentation>http://grails.org/Cometd+Plugin</documentation>
- <dependencies />
+<plugin name='cometd' version='0.1.2'>
+ <author>Mingfai Ma</author>
+ <authorEmail>mingfai.ma@gmail.com</authorEmail>
+ <title>Enable your Grails application with Comet functions</title>
+ <description>\
+Cometd is a scalable HTTP-based event routing bus that uses a Ajax Push technology pattern known as Comet. The term
+'Comet' was coined by Alex Russell in his post Comet: Low Latency Data for the Browser.
+
+This plugin provides a SpringCometdServlet and SpringBayeux on top of the Cometd release, and pre-configure the servlet,
+bayeux instance, and provide all demo programs from the cometd-jetty release.
+</description>
+ <documentation>http://grails.org/Cometd+Plugin</documentation>
+ <resources>
+ <resource>BootStrap</resource>
+ <resource>Config</resource>
+ <resource>DataSource</resource>
+ <resource>spring.resources</resource>
+ <resource>UrlMappings</resource>
+ <resource>org.grails.plugins.cometd.CometdService</resource>
+ </resources>
+ <dependencies />
</plugin>

0 comments on commit 7617994

Please sign in to comment.