Skip to content

Instantly share code, notes, and snippets.

View iocanel's full-sized avatar

Ioannis Canellos iocanel

View GitHub Profile
@iocanel
iocanel / gist:1979271
Created March 5, 2012 16:58
Using camel-mail component to send an email
<to uri="smtps://{{smtp.username}}@{{smtp.server}}?password={{smtp.password}}"/>
@iocanel
iocanel / gist:1979295
Created March 5, 2012 17:01
Sending commands and getting a result back via Hazelcast
public Map<node,result> execute(Command command) throws Exception {
if (command == null) {
throw new Exception("Command store not found");
} else {
//store the command to correlate it with the result.
commandStore.getPending().put(command.getId(), command);
//I create a timeout task and schedule it
TimeoutTask timeoutTask = new TimeoutTask(command, commandStore);
ScheduledFuture timeoutFuture = timeoutScheduler.schedule(timeoutTask, command.getTimeout(), TimeUnit.MILLISECONDS);
}
@iocanel
iocanel / gist:1979317
Created March 5, 2012 17:02
Installing the old version of cellar to karaf
features:addurl mvn:net.cellar/assembly/1.0/xml/features
features:install spring-dm
features:install cellar
cluster:list
@iocanel
iocanel / gist:1979397
Created March 5, 2012 17:06
Exporting Hazelcast as an OSGi service via spring-dm
<bean class="com.hazelcast.core.Hazelcast" destroy-method="shutdown" factory-method="newHazelcastInstance" id="hazelcast">
<constructor-arg ref="config"/>
</bean>
<bean class="com.hazelcast.config.Config" id="config">
<property name="groupConfig" ref="groupConfig"/>
</bean>
<bean class="com.hazelcast.config.GroupConfig" id="groupConfig">
<property name="name">karaf</property>
@iocanel
iocanel / gist:1979471
Created March 5, 2012 17:12
Installing Hazelcast & Monitoring on Karaf
osgi:install -s mvn:com.hazelcast/hazelcast/1.9.3
osgi:install -s war:mvn:com.hazelcast/hazelcast-monitoring/1.9.3/war
@iocanel
iocanel / gist:1979509
Created March 5, 2012 17:14
Importing Hazelcast instance as a service and creating a topic
<reference id="instance" interface="com.hazelcast.core.HazelcastInstance">
<bean factory-method="getTopic" factory-ref="instance" id="echoTopic">
<argument value="ECHO"/>
</bean>
@iocanel
iocanel / gist:1979554
Created March 5, 2012 17:15
A listener which echos messages added to a Hazelcast topic
public class EchoListener implements MessageListener<string> {
private ITopic topic;
public void onMessage(String message) {
System.out.println(message);
}
public ITopic getTopic() {
return topic;
@iocanel
iocanel / gist:1979562
Created March 5, 2012 17:17
Registering a Hazelcast MessageListener
<reference id="instance" interface="com.hazelcast.core.HazelcastInstance"/>
<bean factory-method="getTopic" factory-ref="instance" id="echoTopic">
<argument value="ECHO"/>
</bean>
<bean class="net.iocanel.karaf.hazelcast.shell.EchoListener" id="listener">
<property name="topic" ref="echoTopic"/>
</bean>
@iocanel
iocanel / gist:1979570
Created March 5, 2012 17:18
A karaf command which echos messages to cluster nodes via Hazelcast
@Command(scope = "hazelcast", name = "echo", description = "Echos a message to all cluster nodes")
public class EchoCommand extends HazelcastCommandSupport {
@Argument(index=0,name="message", description = "The message to echo", required = true, multiValued = false)
private String message;
private ITopic topic;
@Override
protected Object doExecute() throws Exception {
if(topic != null) {
@iocanel
iocanel / gist:1979581
Created March 5, 2012 17:21
Creating a table for simple JAAS authentication
CREATE TABLE users (
username varchar(255) NOT NULL,
password varchar(255) NOT NULL,
PRIMARY KEY (username)
);
CREATE TABLE roles (
username varchar(255) NOT NULL,
role varchar(255) NOT NULL,
PRIMARY KEY (username,role)
)