Created
December 7, 2011 16:22
-
-
Save survivant/1443431 to your computer and use it in GitHub Desktop.
exemple de AtmosphereConfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<atmosphere-handlers> | |
<atmosphere-handler support-session="true" | |
context-root="/dispatch" class-name="org.atmosphere.handler.ReflectorServletProcessor" | |
broadcaster="org.atmosphere.samples.twitter.TwitterBroadcaster" | |
broadcasterCache="" | |
broadcastFilterClasses="" | |
comet-support=""> | |
<property name="servletClassName" | |
value="com.sun.jersey.spi.container.servlet.ServletContainer" /> | |
<applicationConfig> | |
<param-name>org.atmosphere.jersey.servlet-mapping</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.useBlocking</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.useNative</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.useWebSocket</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.useStream</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.broadcasterFactory</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.broadcasterClass</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.cometSupport</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.sessionSupport</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.resumeOnBroadcast</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.noCacheHeaders</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.dropAccessControlAllowOriginHeader | |
</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.broadcasterLifeCyclePolicy | |
</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.websocket.WebSocketProcessor</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.websocket.messageContentType</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.websocket.messageMethod</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.websocket.maxIdleTime</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.websocket.bufferSize</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.websocket.pathDelimiter</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.AtmosphereResource</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.broadcastFilterClasses</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.AtmosphereServlet.resumeAndKeepAlive | |
</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.AtmosphereServlet.resumedOnTimeout | |
</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.disableOnStateEvent</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.CometSupport.maxInactiveActivity | |
</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.Trackable</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.allowQueryStreamAsPostOrGet | |
</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<applicationConfig> | |
<param-name>org.atmosphere.cpr.customCometSupport</param-name> | |
<param-value></param-value> | |
</applicationConfig> | |
<frameworkConfig> | |
<param-name>org.atmosphere.jersey.JerseyBroadcaster</param-name> | |
<param-value></param-value> | |
</frameworkConfig> | |
<frameworkConfig> | |
<param-name>org.atmosphere.plugin.redis.RedisBroadcaster</param-name> | |
<param-value></param-value> | |
</frameworkConfig> | |
<frameworkConfig> | |
<param-name>org.atmosphere.plugin.jms.JMSBroadcaster</param-name> | |
<param-value></param-value> | |
</frameworkConfig> | |
<frameworkConfig> | |
<param-name>org.atmosphere.plugin.jgroups.JGroupsBroadcaster | |
</param-name> | |
<param-value></param-value> | |
</frameworkConfig> | |
<frameworkConfig> | |
<param-name>org.atmosphere.plugin.xmpp.XMPPBroadcaster</param-name> | |
<param-value></param-value> | |
</frameworkConfig> | |
<frameworkConfig> | |
<param-name>com.sun.jersey.spi.container.servlet.ServletContainer | |
</param-name> | |
<param-value></param-value> | |
</frameworkConfig> | |
<frameworkConfig> | |
<param-name>org.atmosphere.cpr.AtmosphereServlet</param-name> | |
<param-value></param-value> | |
</frameworkConfig> | |
<frameworkConfig> | |
<param-name>org.atmosphere.cpr.AtmosphereResource</param-name> | |
<param-value></param-value> | |
</frameworkConfig> | |
<frameworkConfig> | |
<param-name>org.atmosphere.cpr.AsynchronousProcessor.supportSession | |
</param-name> | |
<param-value></param-value> | |
</frameworkConfig> | |
<frameworkConfig> | |
<param-name>org.atmosphere.cpr.AtmosphereHandler</param-name> | |
<param-value></param-value> | |
</frameworkConfig> | |
<frameworkConfig> | |
<param-name>org.atmosphere.jersey.containerResponse</param-name> | |
<param-value></param-value> | |
</frameworkConfig> | |
<frameworkConfig> | |
<param-name>org.atmosphere.cpr.AtmosphereResource.writeHeader | |
</param-name> | |
<param-value></param-value> | |
</frameworkConfig> | |
</atmosphere-handler> | |
</atmosphere-handlers> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Load AtmosphereHandler defined under META-INF/atmosphere.xml | |
* | |
* @param stream The input stream we read from. | |
* @param c The classloader | |
*/ | |
protected void loadAtmosphereDotXml(InputStream stream, URLClassLoader c) | |
throws IOException, ServletException { | |
if (stream == null) { | |
return; | |
} | |
org.atmosphere.config.AtmosphereConfig atmoConfig = AtmosphereConfigParser.getInstance().parse(stream); | |
for (org.atmosphere.config.AtmosphereHandler atmoHandler : atmoConfig.getAtmosphereHandler()) { | |
try { | |
AtmosphereHandler handler; | |
if(!ReflectorServletProcessor.class.getName().equals(atmoHandler.getClassName())){ | |
handler = (AtmosphereHandler) c.loadClass(atmoHandler.getClassName()).newInstance(); | |
InjectorProvider.getInjector().inject(handler); | |
} else { | |
handler = new ReflectorServletProcessor(); | |
} | |
logger.info("Installed AtmosphereHandler {} mapped to context-path: {}", handler, atmoHandler.getContextRoot()); | |
boolean isJersey = false; | |
for (AtmosphereHandlerProperty handlerProperty : atmoHandler.getProperties()) { | |
if(handlerProperty.getName()!= null && handlerProperty.getName().indexOf("jersey") != -1){ | |
isJersey = true; | |
initParams.put(DISABLE_ONSTATE_EVENT, "true"); | |
useStreamForFlushingComments = true; | |
broadcasterClassName = lookupDefaultBroadcasterType(); | |
} | |
IntrospectionUtils.setProperty(handler, handlerProperty.getName(), handlerProperty.getValue()); | |
IntrospectionUtils.addProperty(handler, handlerProperty.getName(), handlerProperty.getValue()); | |
} | |
config.supportSession = !isJersey; | |
if (!atmoHandler.getSupportSession().equals("")) { | |
sessionSupport(Boolean.valueOf(atmoHandler.getSupportSession())); | |
} | |
String broadcasterClass = atmoHandler.getBroadcaster(); | |
Broadcaster b; | |
/** | |
* If there is more than one AtmosphereHandler defined, their Broadcaster | |
* may clash each other with the BroadcasterFactory. In that case we will use the | |
* last one defined. | |
*/ | |
if (broadcasterClass != null) { | |
broadcasterClassName = broadcasterClass; | |
ClassLoader cl = Thread.currentThread().getContextClassLoader(); | |
Class<? extends Broadcaster> bc = (Class<? extends Broadcaster>) cl.loadClass(broadcasterClassName); | |
broadcasterFactory = new DefaultBroadcasterFactory(bc, broadcasterLifeCyclePolicy, config); | |
BroadcasterFactory.setBroadcasterFactory(broadcasterFactory, config); | |
} | |
b = BroadcasterFactory.getDefault().get(atmoHandler.getContextRoot()); | |
AtmosphereHandlerWrapper wrapper = new AtmosphereHandlerWrapper(handler, b); | |
addMapping(atmoHandler.getContextRoot(), wrapper); | |
String bc = atmoHandler.getBroadcasterCache(); | |
if (bc != null) { | |
broadcasterCacheClassName = bc; | |
} | |
if (atmoHandler.getCometSupport() != null) { | |
cometSupport = (CometSupport) c.loadClass(atmoHandler.getCometSupport()) | |
.getDeclaredConstructor(new Class[]{AtmosphereConfig.class}) | |
.newInstance(new Object[]{config}); | |
} | |
if (atmoHandler.getBroadcastFilterClasses() != null) { | |
broadcasterFilters = atmoHandler.getBroadcastFilterClasses().split(","); | |
} | |
} catch(Throwable t) { | |
logger.warn("unable to load AtmosphereHandler class: " + atmoHandler.getClassName(), t); | |
throw new ServletException(t); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment