Skip to content

Instantly share code, notes, and snippets.

View billyyarosh's full-sized avatar

Billy Yarosh billyyarosh

View GitHub Profile
@billyyarosh
billyyarosh / atmo_maven_dependency_runtime
Created May 9, 2012 01:10
Atmosphere Maven Dependency
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>0.9.5</version>
</dependency>
@billyyarosh
billyyarosh / atmo-context-tomcat.xml
Created May 15, 2012 21:03
Required atmosphere context.xml file for Tomcat
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Loader delegate="true"/>
</Context>
@billyyarosh
billyyarosh / atmo_socket_request.js
Created May 15, 2012 21:07
The gist of creating a websocket connection
var request = new $.atmosphere.AtmosphereRequest();
request.transport = 'websocket';
request.url = "<c:url value='/twitter/concurrency'/>";
request.contentType = "application/json";
request.fallbackTransport = 'streaming';
request.onMessage = function(response){
buildTemplate(response);
};
@billyyarosh
billyyarosh / concurrentControllerMethod.java
Last active October 4, 2015 21:48
controller gist for atmosphere concurrency
@RequestMapping(value="/twitter/concurrency")
@ResponseBody
public void twitterAsync(AtmosphereResource atmosphereResource){
final ObjectMapper mapper = new ObjectMapper();
this.suspend(atmosphereResource);
final Broadcaster bc = atmosphereResource.getBroadcaster();
logger.info("Atmo Resource Size: " + bc.getAtmosphereResources().size());
@billyyarosh
billyyarosh / connector_server_atmo.xml
Created May 15, 2012 21:11
connector for atmosphere on tomcat
<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="600000"
redirectPort="8443" />
@billyyarosh
billyyarosh / web_atmo_spring.xml
Created May 15, 2012 21:41
Configuration of Meteor servlet in web.xml
<servlet>
<servlet-name>feeds</servlet-name>
<servlet-class>org.atmosphere.cpr.MeteorServlet</servlet-class>
<init-param>
<param-name>org.atmosphere.servlet</param-name>
<param-value>org.springframework.web.servlet.DispatcherServlet</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.broadcasterClass</param-name>
<param-value>org.atmosphere.cpr.DefaultBroadcaster</param-value>
@billyyarosh
billyyarosh / Comparator.java
Created June 5, 2012 15:10
java.util.Comparator
package java.util;
public interface Comparator<T> {
public int compare(T t, T t1);
}
@billyyarosh
billyyarosh / Animal.java
Created June 5, 2012 18:50
Animal interface and a simple implemntation
package com.keaplogik.examples.model.animals;
import java.awt.Color;
public interface Animal {
public enum AnimalClass {
MAMMAL,
BIRD,
FISH,
@billyyarosh
billyyarosh / RunAnimalStrategyDemo.java
Created June 5, 2012 18:54
Simple sort strategy on an object of animals. Group by animal class type.
/**
*
* Run a demo for supplying different strategies to sort a list
* of animals.
*
* @author keaplogik
*/
public class RunAnimalStrategyDemo {
public static void main(String[] args) {
@billyyarosh
billyyarosh / AnimalListStrategy.java
Created June 5, 2012 18:59
Example of using concrete strategies.
package com.keaplogik.examples.design.patterns.strategy;
import com.keaplogik.examples.model.animals.Animal;
import java.util.Comparator;
/**
* Holds concrete strategies for working with animal lists.
* @keaplogik
*/
public enum AnimalListStrategy {