Skip to content

Instantly share code, notes, and snippets.

View altfatterz's full-sized avatar
👨‍💻
Playing

Zoltan Altfatter altfatterz

👨‍💻
Playing
View GitHub Profile
git clone https://github.com/altfatterz/atmosphere-fun
cd atmosphere-fun
mvn clean install
mvn jetty:run
public enum Event {
ACCOUNT_DEBITED, ACCOUNT_CREDITED, ACCOUNT_LOCKED
}
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="timer://foo?fixedRate=true&amp;period=10s"/>
<process ref="accountBalanceProcessor" />
<to uri="bean:atmospherePublishService?method=publish"/>
</route>
</camelContext>
<servlet>
<description>AtmosphereServlet</description>
<servlet-name>AtmosphereServlet</servlet-name>
<servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
<!-- limit classpath scanning for ManagedService instances to speed up boostrapping -->
<init-param>
<param-name>org.atmosphere.cpr.packages</param-name>
<param-value>com.backbase.progfun.atmosphere</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
var request = { url: document.location.toString() + 'event',
contentType : "application/json",
logLevel : 'debug',
transport : 'websocket',
fallbackTransport : 'long-polling' ,
trackMessageLength : true,
reconnectInterval : 5000,
enableXDR: true,
timeout : 60000,
headers : {sessionId : sessionId} // 0 for firefox, 1 for chrome, 2 for IE
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(auth.getAuthorities());
authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
Authentication newAuth = new UsernamePasswordAuthenticationToken(auth.getPrincipal(), auth.getCredentials(), authorities);
SecurityContextHolder.getContext().setAuthentication(newAuth);
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/signup", "/static/**").permitAll()
.antMatchers("/code").hasRole("PRE_AUTH_USER")
.antMatchers("/home").hasRole("USER")
.anyRequest().authenticated();
http.formLogin()
.loginPage("/login")
public class UserDetailsServiceAdapter implements UserDetailsService {
@Autowired
private AccountRepository accountRepository;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
Account account = accountRepository.findByEmail(username);
if (account == null) {
throw new UsernameNotFoundException(username);
@Configuration
@EnableCaching
@Profile("ehcache")
public class EhCacheConfiguration {
@Bean
EhCacheCacheManager ehCacheCacheManager() {
return new EhCacheCacheManager(ehCacheManagerFactoryBean().getObject());
}
@Configuration
@EnableCaching
@Profile("hazelcast")
public class HazelcastConfiguration {
@Bean
HazelcastCacheManager hazelcastcacheManager() throws Exception {
return new HazelcastCacheManager(hazelcastInstance());
}