Skip to content

Instantly share code, notes, and snippets.

View cemartins's full-sized avatar

Carlos Martins cemartins

View GitHub Profile
@cemartins
cemartins / ClientManager
Created October 5, 2014 23:11
Starting Tyrus ClientManager
ClientManager client = AccessController.doPrivileged(new PrivilegedExceptionAction<ClientManager>() {
@Override
public ClientManager run() throws Exception {
ThreadPoolConfig workerThreadPoolConfig = ThreadPoolConfig.defaultConfig();
workerThreadPoolConfig.setInitialClassLoader(this.getClass().getClassLoader());
workerThreadPoolConfig.setDaemon(false);
workerThreadPoolConfig.setMaxPoolSize(4);
workerThreadPoolConfig.setCorePoolSize(3);
@cemartins
cemartins / ServerEndpointAddress.java
Created October 5, 2014 22:58
Method to calculate the server address based on the server-url parameter in the JNLP file
private URI getServerEndpointAddress() {
String serverEndpointStr = SERVER_URL;
Parameters parameters = getParameters();
if(parameters != null && parameters.getNamed().get("server-url") != null) {
serverEndpointStr = parameters.getNamed().get("server-url");
if(serverEndpointStr.startsWith("https"))
serverEndpointStr = serverEndpointStr.replaceFirst("https", "wss");
else
serverEndpointStr = serverEndpointStr.replaceFirst("http", "ws");
serverEndpointStr = serverEndpointStr + "/wstest";
@cemartins
cemartins / pom.xml
Created October 5, 2014 18:29
webstart-maven-plugin configuration
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.juffrou.test</groupId>
<artifactId>websocket-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>websocket-server</artifactId>
@cemartins
cemartins / jfx-jnlp-template.vm
Last active August 29, 2015 14:07
webstart-maven-plugin jnlp template
TS: ${buildTS}
<?xml version="1.0" encoding="$encoding"?>
<jnlp
spec="$jnlpspec"
xmlns:jfx="http://javafx.com"
codebase="$$codebase"
href="$outputFile">
<information>
<title>Websocket JavaFX Test</title>
<vendor>Carlos Martins</vendor>
@Component
public class MyEndpoint extends Endpoint {
@Autowired
MyService myService;
@Override
public void onOpen(Session session, EndpointConfig config) {
session.addMessageHandler(new MyMessageHandler(session));
@cemartins
cemartins / application-1-context.xml
Last active August 29, 2015 13:56
Node 1 setup - wildfly 8 hosting application 1 that holds a durable subscription to the event messages topic through a remote connection to Node 2
<!-- Local connection factory that "points" to Node2's hornetq broker -->
<bean id="jmsEventsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:/Node2Broker" />
</bean>
<!-- Listener container to establish a durable subscrition to the EventsTopic in Node2 -->
<bean id="node2EventListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="concurrentConsumers" value="1"/>
<property name="connectionFactory" ref="jmsEventsConnectionFactory"/>
<property name="destinationName" value="EventsTopic"/> <!-- Note: must use this name and not "jms/topic/SunsetEventsTopic" -->
@cemartins
cemartins / application-2-context.xml
Last active August 29, 2015 13:56
Node 2 messaging subsystem setup - wildfly 8 hosting application 2 that publishes event messages to the embedded hornetq broker
<bean id="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>ConnectionFactory</value>
</property>
<property name="resourceRef"><value>true</value></property>
</bean>
<bean id="myBrokerSendDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>jms/topic/EventsTopic</value>
</property>