camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1075264 [2/3] - in /camel/trunk: components/ components/camel-hazelcast/ components/camel-hazelcast/src/ components/camel-hazelcast/src/main/ components/camel-hazelcast/src/main/java/ components/camel-hazelcast/src/main/java/org/ component...
Date Mon, 28 Feb 2011 10:13:37 GMT
Added: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapEndpoint.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapEndpoint.java (added)
+++ camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapEndpoint.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast.multimap;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.hazelcast.HazelcastComponent;
+import org.apache.camel.component.hazelcast.HazelcastDefaultEndpoint;
+
+public class HazelcastMultimapEndpoint extends HazelcastDefaultEndpoint {
+
+    public HazelcastMultimapEndpoint(String uri, String cacheName, HazelcastComponent component) {
+        super(uri, component, cacheName);
+    }
+
+    public Consumer createConsumer(Processor processor) throws Exception {
+        return new HazelcastMultimapConsumer(this, processor, cacheName);
+    }
+
+    public Producer createProducer() throws Exception {
+        return new HazelcastMultimapProducer(this, cacheName);
+    }
+
+}

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapEndpoint.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapProducer.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapProducer.java (added)
+++ camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapProducer.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast.multimap;
+
+import java.util.Map;
+
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.MultiMap;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.hazelcast.HazelcastComponentHelper;
+import org.apache.camel.component.hazelcast.HazelcastConstants;
+import org.apache.camel.impl.DefaultProducer;
+
+public class HazelcastMultimapProducer extends DefaultProducer {
+
+    private final MultiMap<Object, Object> cache;
+    private final HazelcastComponentHelper helper = new HazelcastComponentHelper();
+
+    public HazelcastMultimapProducer(Endpoint endpoint, String cacheName) {
+        super(endpoint);
+        this.cache = Hazelcast.getMultiMap(cacheName);
+    }
+
+    public void process(Exchange exchange) throws Exception {
+
+        Map<String, Object> headers = exchange.getIn().getHeaders();
+
+        // get header parameters
+        String oid = null;
+        int operation = -1;
+
+        if (headers.containsKey(HazelcastConstants.OBJECT_ID)) {
+            oid = (String) headers.get(HazelcastConstants.OBJECT_ID);
+        }
+
+        if (headers.containsKey(HazelcastConstants.OPERATION)) {
+            if (headers.get(HazelcastConstants.OPERATION) instanceof String) {
+                operation = helper.lookupOperationNumber((String) headers.get(HazelcastConstants.OPERATION));
+            } else {
+                operation = (Integer) headers.get(HazelcastConstants.OPERATION);
+            }
+        }
+
+        switch (operation) {
+        case HazelcastConstants.PUT_OPERATION:
+            this.put(oid, exchange);
+            break;
+
+        case HazelcastConstants.GET_OPERATION:
+            this.get(oid, exchange);
+            break;
+
+        case HazelcastConstants.DELETE_OPERATION:
+            this.delete(oid);
+            break;
+
+        case HazelcastConstants.REMOVEVALUE_OPERATION:
+            this.removevalue(oid, exchange);
+            break;
+
+        default:
+            throw new IllegalArgumentException(String.format("The value '%s' is not allowed for parameter '%s' on the MULTIMAP cache.", operation, HazelcastConstants.OPERATION));
+        }
+
+        // finally copy headers
+        HazelcastComponentHelper.copyHeaders(exchange);
+    }
+
+    private void put(String oid, Exchange exchange) {
+        Object body = exchange.getIn().getBody();
+        this.cache.put(oid, body);
+    }
+
+    private void get(String oid, Exchange exchange) {
+        exchange.getOut().setBody(this.cache.get(oid));
+    }
+
+    private void delete(String oid) {
+        this.cache.remove(oid);
+    }
+
+    private void removevalue(String oid, Exchange exchange) {
+        this.cache.remove(oid, exchange.getIn().getBody());
+    }
+
+}

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapProducer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueConsumer.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueConsumer.java (added)
+++ camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueConsumer.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast.queue;
+
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.IQueue;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.component.hazelcast.HazelcastDefaultConsumer;
+import org.apache.camel.component.hazelcast.listener.CamelItemListener;
+
+/**
+ *
+ */
+public class HazelcastQueueConsumer extends HazelcastDefaultConsumer {
+
+    public HazelcastQueueConsumer(Endpoint endpoint, Processor processor, String cacheName) {
+        super(endpoint, processor, cacheName);
+
+        IQueue<Object> queue = Hazelcast.getQueue(cacheName);
+        queue.addItemListener(new CamelItemListener(this, cacheName), true);
+    }
+
+}

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueConsumer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueEndpoint.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueEndpoint.java (added)
+++ camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueEndpoint.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast.queue;
+
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.hazelcast.HazelcastDefaultEndpoint;
+
+/**
+ *
+ */
+public class HazelcastQueueEndpoint extends HazelcastDefaultEndpoint {
+
+    public HazelcastQueueEndpoint(String endpointUri, Component component, String cacheName) {
+        super(endpointUri, component, cacheName);
+    }
+
+    @Override
+    public Consumer createConsumer(Processor processor) throws Exception {
+        return new HazelcastQueueConsumer(this, processor, cacheName);
+    }
+
+    @Override
+    public Producer createProducer() throws Exception {
+        return new HazelcastQueueProducer(this, cacheName);
+    }
+
+}

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueEndpoint.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java (added)
+++ camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast.queue;
+
+import java.util.Map;
+
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.IQueue;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.hazelcast.HazelcastComponentHelper;
+import org.apache.camel.component.hazelcast.HazelcastConstants;
+import org.apache.camel.impl.DefaultProducer;
+
+/**
+ *
+ */
+public class HazelcastQueueProducer extends DefaultProducer {
+
+    private IQueue<Object> queue;
+    private HazelcastComponentHelper helper = new HazelcastComponentHelper();
+
+    public HazelcastQueueProducer(Endpoint endpoint, String queueName) {
+        super(endpoint);
+        this.queue = Hazelcast.getQueue(queueName);
+    }
+
+    public void process(Exchange exchange) throws Exception {
+
+        Map<String, Object> headers = exchange.getIn().getHeaders();
+
+        // get header parameters
+        int operation = -1;
+
+        if (headers.containsKey(HazelcastConstants.OPERATION)) {
+            if (headers.get(HazelcastConstants.OPERATION) instanceof String) {
+                operation = helper.lookupOperationNumber((String) headers.get(HazelcastConstants.OPERATION));
+            } else {
+                operation = (Integer) headers.get(HazelcastConstants.OPERATION);
+            }
+        }
+
+        switch (operation) {
+
+        case HazelcastConstants.ADD_OPERATION:
+            this.add(exchange);
+            break;
+
+        case HazelcastConstants.PUT_OPERATION:
+            this.put(exchange);
+            break;
+
+        case HazelcastConstants.POLL_OPERATION:
+            this.poll(exchange);
+            break;
+
+        case HazelcastConstants.PEEK_OPERATION:
+            this.peek(exchange);
+            break;
+
+        case HazelcastConstants.OFFER_OPERATION:
+            this.offer(exchange);
+            break;
+
+        case HazelcastConstants.REMOVEVALUE_OPERATION:
+            this.remove(exchange);
+            break;
+
+        default:
+            throw new IllegalArgumentException(String.format("The value '%s' is not allowed for parameter '%s' on the QUEUE cache.", operation, HazelcastConstants.OPERATION));
+        }
+
+        // finally copy headers
+        HazelcastComponentHelper.copyHeaders(exchange);
+
+    }
+
+    private void add(Exchange exchange) {
+        Object body = exchange.getIn().getBody();
+        this.queue.add(body);
+    }
+
+    private void put(Exchange exchange) throws InterruptedException {
+        Object body = exchange.getIn().getBody();
+        this.queue.put(body);
+    }
+
+    private void poll(Exchange exchange) {
+        exchange.getOut().setBody(this.queue.poll());
+    }
+
+    private void peek(Exchange exchange) {
+        exchange.getOut().setBody(this.queue.peek());
+    }
+
+    private void offer(Exchange exchange) {
+        Object body = exchange.getIn().getBody();
+        this.queue.offer(body);
+    }
+
+    private void remove(Exchange exchange) {
+        Object body = exchange.getIn().getBody();
+        if (body != null) {
+            this.queue.remove(body);
+        } else {
+            this.queue.remove();
+        }
+    }
+}

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConfiguration.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConfiguration.java (added)
+++ camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConfiguration.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast.seda;
+
+/**
+ * Hazelcast SEDA Component configuration.
+ */
+public class HazelcastSedaConfiguration {
+
+    private int concurrentConsumers = 1;
+    private int pollInterval = 1000;
+    private String queueName;
+
+    public HazelcastSedaConfiguration() {
+        super();
+    }
+
+    public int getConcurrentConsumers() {
+        return concurrentConsumers;
+    }
+
+    public void setConcurrentConsumers(final int concurrentConsumers) {
+        this.concurrentConsumers = concurrentConsumers;
+    }
+
+    public String getQueueName() {
+        return queueName;
+    }
+
+    public void setQueueName(final String queueName) {
+        this.queueName = queueName;
+    }
+
+    public int getPollInterval() {
+        return pollInterval;
+    }
+
+    public void setPollInterval(int pollInterval) {
+        this.pollInterval = pollInterval;
+    }
+}

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConfiguration.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java (added)
+++ camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast.seda;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.AsyncCallback;
+import org.apache.camel.AsyncProcessor;
+import org.apache.camel.Consumer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.DefaultConsumer;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.impl.converter.AsyncProcessorTypeConverter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implementation of Hazelcast SEDA {@link Consumer} component.
+ */
+public class HazelcastSedaConsumer extends DefaultConsumer implements Runnable {
+
+    private static final Logger LOG = LoggerFactory.getLogger(HazelcastSedaConsumer.class);
+    private final HazelcastSedaEndpoint endpoint;
+    private final AsyncProcessor processor;
+    private ExecutorService executor;
+
+    public HazelcastSedaConsumer(final Endpoint endpoint, final Processor processor) {
+        super(endpoint, processor);
+        this.endpoint = (HazelcastSedaEndpoint) endpoint;
+        this.processor = AsyncProcessorTypeConverter.convert(processor);
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        int concurrentConsumers = endpoint.getConfiguration().getConcurrentConsumers();
+        executor = endpoint.getCamelContext().getExecutorServiceStrategy().newFixedThreadPool(this, endpoint.getEndpointUri(), concurrentConsumers);
+        for (int i = 0; i < concurrentConsumers; i++) {
+            executor.execute(this);
+        }
+
+        super.doStart();
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        if (executor != null) {
+            endpoint.getCamelContext().getExecutorServiceStrategy().shutdownNow(executor);
+            executor = null;
+        }
+        super.doStop();
+    }
+
+    public void run() {
+        final BlockingQueue queue = endpoint.getQueue();
+
+        while (queue != null && isRunAllowed()) {
+            final Exchange exchange = new DefaultExchange(this.getEndpoint().getCamelContext());
+
+            try {
+                final Object body = queue.poll(endpoint.getConfiguration().getPollInterval(), TimeUnit.MILLISECONDS);
+
+                if (body != null) {
+                    exchange.getIn().setBody(body);
+                    try {
+                        processor.process(exchange, new AsyncCallback() {
+                            public void done(final boolean sync) {
+                            }
+                        });
+
+                        if (exchange.getException() != null) {
+                            getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
+                        }
+
+                    } catch (Exception e) {
+                        LOG.error("Hzlq Exception caught: " + e, e);
+                    }
+                }
+            } catch (InterruptedException e) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Hzlq Consumer Interrupted: " + e, e);
+                }
+                continue;
+            } catch (Throwable e) {
+                getExceptionHandler().handleException("Error processing exchange", exchange, e);
+            }
+        }
+    }
+
+}

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaEndpoint.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaEndpoint.java (added)
+++ camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaEndpoint.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast.seda;
+
+import java.util.concurrent.BlockingQueue;
+
+import com.hazelcast.core.Hazelcast;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.hazelcast.HazelcastComponent;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * Hazelcast SEDA {@link Endpoint} implementation.
+ */
+public class HazelcastSedaEndpoint extends DefaultEndpoint {
+
+    private final BlockingQueue queue;
+    private final HazelcastSedaConfiguration configuration;
+
+    public HazelcastSedaEndpoint(final String uri, final HazelcastComponent component, final HazelcastSedaConfiguration configuration) {
+        super(uri, component);
+        this.queue = Hazelcast.getQueue(configuration.getQueueName());
+        this.configuration = configuration;
+        if (ObjectHelper.isEmpty(configuration.getQueueName())) {
+            throw new IllegalArgumentException("Queue name is missing.");
+        }
+    }
+
+    public Producer createProducer() throws Exception {
+        return new HazelcastSedaProducer(this, getQueue());
+    }
+
+    public Consumer createConsumer(final Processor processor) throws Exception {
+        return new HazelcastSedaConsumer(this, processor);
+    }
+
+    public BlockingQueue getQueue() {
+        return queue;
+    }
+
+    public HazelcastSedaConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+
+}

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaEndpoint.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaProducer.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaProducer.java (added)
+++ camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaProducer.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast.seda;
+
+import java.io.Serializable;
+import java.util.concurrent.BlockingQueue;
+
+import org.apache.camel.AsyncCallback;
+import org.apache.camel.AsyncProcessor;
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultProducer;
+
+/**
+ * Implementation of Hazelcast SEDA {@link Producer} component. Just appends exchange body into a Hazelcast {@link BlockingQueue}.
+ */
+public class HazelcastSedaProducer extends DefaultProducer implements AsyncProcessor {
+
+    private final transient BlockingQueue queue;
+
+    public HazelcastSedaProducer(final HazelcastSedaEndpoint endpoint, final BlockingQueue hzlq) {
+        super(endpoint);
+        this.queue = hzlq;
+    }
+
+    public void process(final Exchange exchange) throws Exception {
+        checkAndStore(exchange);
+    }
+
+    public boolean process(final Exchange exchange, final AsyncCallback callback) {
+        checkAndStore(exchange);
+        callback.done(true);
+        return true;
+    }
+
+    @SuppressWarnings("unchecked")
+    private void checkAndStore(final Exchange exchange) {
+        Object obj;
+        Object body = exchange.getIn().getBody();
+
+        // in case body is not serializable convert to byte array
+        if (!(body instanceof Serializable)) {
+            obj = exchange.getIn().getBody(byte[].class);
+        } else {
+            obj = body;
+        }
+
+        queue.add(obj);
+    }
+
+}

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaProducer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/LICENSE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/LICENSE.txt?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/LICENSE.txt (added)
+++ camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/LICENSE.txt Mon Feb 28 10:13:34 2011
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

Propchange: camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/NOTICE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/NOTICE.txt?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/NOTICE.txt (added)
+++ camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/NOTICE.txt Mon Feb 28 10:13:34 2011
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

Propchange: camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/NOTICE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/NOTICE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/services/org/apache/camel/component/hazelcast
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/services/org/apache/camel/component/hazelcast?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/services/org/apache/camel/component/hazelcast (added)
+++ camel/trunk/components/camel-hazelcast/src/main/resources/META-INF/services/org/apache/camel/component/hazelcast Mon Feb 28 10:13:34 2011
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class=org.apache.camel.component.hazelcast.HazelcastComponent

Added: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastAtomicnumberProducerForSpringTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastAtomicnumberProducerForSpringTest.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastAtomicnumberProducerForSpringTest.java (added)
+++ camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastAtomicnumberProducerForSpringTest.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast;
+
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class HazelcastAtomicnumberProducerForSpringTest extends CamelSpringTestSupport {
+
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("/META-INF/spring/test-camel-context-atomicnumber.xml");
+    }
+
+    @Test
+    public void testSet() {
+        template.sendBody("direct:set", 4711);
+
+        long body = template.requestBody("direct:get", null, Long.class);
+        assertEquals(4711, body);
+    }
+
+    @Test
+    public void testGet() {
+        template.sendBody("direct:set", 1234);
+
+        long body = template.requestBody("direct:get", null, Long.class);
+        assertEquals(1234, body);
+    }
+
+    @Test
+    public void testIncrement() {
+        template.sendBody("direct:set", 10);
+
+        long body = template.requestBody("direct:increment", null, Long.class);
+        assertEquals(11, body);
+    }
+
+    @Test
+    public void testDecrement() {
+        template.sendBody("direct:set", 10);
+
+        long body = template.requestBody("direct:decrement", null, Long.class);
+        assertEquals(9, body);
+    }
+
+    /*
+     * will be fixed in next hazelcast version (1.9.3). Mail from Talip (21.02.2011):
+     * 
+     * I see. Hazelcast.shutdownAll() should cleanup instances (maps/queues). I just fixed it.
+     * 
+     * AtomicNumber.destroy() should also destroy the number and if you call atomicNumber.get() after the destroy it should throw IllegalStateException. It is also fixed.
+     * 
+     * set test to true by default. TODO: if we'll get the new hazelcast version I'll fix the test.
+     */
+    @Test
+    public void testDestroy() {
+        template.sendBody("direct:set", 10);
+        template.sendBody("direct:destroy", null);
+
+        // assertTrue(Hazelcast.getInstances().isEmpty());
+    }
+
+}

Propchange: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastAtomicnumberProducerForSpringTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastAtomicnumberProducerForSpringTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastAtomicnumberProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastAtomicnumberProducerTest.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastAtomicnumberProducerTest.java (added)
+++ camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastAtomicnumberProducerTest.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class HazelcastAtomicnumberProducerTest extends CamelTestSupport {
+
+    @Test
+    public void testSet() {
+        template.sendBody("direct:set", 4711);
+
+        long body = template.requestBody("direct:get", null, Long.class);
+        assertEquals(4711, body);
+    }
+
+    @Test
+    public void testGet() {
+        template.sendBody("direct:set", 1234);
+
+        long body = template.requestBody("direct:get", null, Long.class);
+        assertEquals(1234, body);
+    }
+
+    @Test
+    public void testIncrement() {
+        template.sendBody("direct:set", 10);
+
+        long body = template.requestBody("direct:increment", null, Long.class);
+        assertEquals(11, body);
+    }
+
+    @Test
+    public void testDecrement() {
+        template.sendBody("direct:set", 10);
+
+        long body = template.requestBody("direct:decrement", null, Long.class);
+        assertEquals(9, body);
+    }
+
+    /*
+     * will be fixed in next hazelcast version (1.9.3). Mail from Talip (21.02.2011):
+     * 
+     * I see. Hazelcast.shutdownAll() should cleanup instances (maps/queues). I just fixed it.
+     * 
+     * AtomicNumber.destroy() should also destroy the number and if you call atomicNumber.get() after the destroy it should throw IllegalStateException. It is also fixed.
+     * 
+     * set test to true by default. TODO: if we'll get the new hazelcast version I'll fix the test.
+     */
+    @Test
+    public void testDestroy() {
+        template.sendBody("direct:set", 10);
+        template.sendBody("direct:destroy", null);
+
+        // assertTrue(Hazelcast.getInstances().isEmpty());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+
+                from("direct:set").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.SETVALUE_OPERATION))
+                        .to(String.format("hazelcast:%sfoo", HazelcastConstants.ATOMICNUMBER_PREFIX));
+
+                from("direct:get").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.GET_OPERATION)).to(String.format("hazelcast:%sfoo", HazelcastConstants.ATOMICNUMBER_PREFIX));
+
+                from("direct:increment").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.INCREMENT_OPERATION)).to(
+                        String.format("hazelcast:%sfoo", HazelcastConstants.ATOMICNUMBER_PREFIX));
+
+                from("direct:decrement").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.DECREMENT_OPERATION)).to(
+                        String.format("hazelcast:%sfoo", HazelcastConstants.ATOMICNUMBER_PREFIX));
+
+                from("direct:destroy").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.DESTROY_OPERATION)).to(
+                        String.format("hazelcast:%sfoo", HazelcastConstants.ATOMICNUMBER_PREFIX));
+
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastAtomicnumberProducerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastAtomicnumberProducerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java (added)
+++ camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class HazelcastErrorMessagesTest extends CamelTestSupport {
+
+    @Test
+    public void testUriPrefix() {
+        RouteBuilder builder = new RouteBuilder() {
+            public void configure() throws Exception {
+                from("direct:prefix").to("hazelcast:error:foo");
+            }
+        };
+
+        try {
+            context.addRoutes(builder);
+            context.start();
+            fail("Should have thrown exception");
+        } catch (Exception e) {
+            assertTrue(e.getMessage().contains(
+                    "Your URI does not provide a correct 'type' prefix. It should be anything like "
+                            + "'hazelcast:[map:|multimap:|atomicvalue:|instance:|queue:|seda:|list:]name' but is 'hazelcast://error:foo"));
+        }
+    }
+
+    @Test
+    public void testAtomicNumberConsumer() {
+        RouteBuilder builder = new RouteBuilder() {
+            public void configure() throws Exception {
+                from("hazelcast:atomicvalue:foo").to("seda:out");
+            }
+        };
+        try {
+            context.addRoutes(builder);
+            context.start();
+            fail("Should have thrown exception");
+        } catch (Exception e) {
+            assertTrue(e.getMessage().contains("You cannot send messages to this endpoint: hazelcast://atomicvalue:foo"));
+        }
+    }
+
+    @Test
+    public void testInstanceProducer() {
+        RouteBuilder builder = new RouteBuilder() {
+            public void configure() throws Exception {
+                from("direct:foo").to("hazelcast:instance:foo");
+            }
+        };
+
+        try {
+            context.addRoutes(builder);
+            context.start();
+            fail("Should have thrown exception");
+        } catch (Exception e) {
+            assertTrue(e.getMessage().contains("You cannot send messages to this endpoint: hazelcast://instance:foo"));
+        }
+    }
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+}

Propchange: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastInstanceConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastInstanceConsumerTest.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastInstanceConsumerTest.java (added)
+++ camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastInstanceConsumerTest.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,96 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast;
+
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.HazelcastInstance;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class HazelcastInstanceConsumerTest extends CamelTestSupport {
+
+    @Test
+    public void testAddInstance() throws InterruptedException {
+
+        MockEndpoint added = getMockEndpoint("mock:added");
+        added.setExpectedMessageCount(2);
+
+        Hazelcast.newHazelcastInstance(null);
+        Hazelcast.newHazelcastInstance(null);
+
+        assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS);
+
+        // check headers
+        Exchange ex = added.getExchanges().get(0);
+        Map<String, Object> headers = ex.getIn().getHeaders();
+
+        this.checkHeaders(headers, HazelcastConstants.ADDED);
+
+        Hazelcast.shutdownAll();
+    }
+
+    @Test
+    @SuppressWarnings("deprecation")
+    @Ignore("Shutdown causes further hazelast tests to fail")
+    public void testRemoveInstance() throws InterruptedException {
+
+        MockEndpoint removed = getMockEndpoint("mock:removed");
+        removed.setExpectedMessageCount(1);
+
+        HazelcastInstance h1 = Hazelcast.newHazelcastInstance(null);
+
+        // TODO --> check how an instance can be killed...
+        h1.shutdown();
+
+        assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS);
+
+        // check headers
+        Exchange ex = removed.getExchanges().get(0);
+        Map<String, Object> headers = ex.getIn().getHeaders();
+
+        this.checkHeaders(headers, HazelcastConstants.REMOVED);
+
+        Hazelcast.shutdownAll();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(String.format("hazelcast:%sfoo", HazelcastConstants.INSTANCE_PREFIX)).log("instance...").choice()
+                        .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED)).log("...added").to("mock:added").otherwise().log("...removed").to("mock:removed");
+            }
+        };
+    }
+
+    private void checkHeaders(Map<String, Object> headers, String action) {
+        assertEquals(action, headers.get(HazelcastConstants.LISTENER_ACTION));
+        assertEquals(HazelcastConstants.INSTANCE_LISTENER, headers.get(HazelcastConstants.LISTENER_TYPE));
+        assertNotNull(headers.get(HazelcastConstants.LISTENER_TIME));
+        assertNotNull(headers.get(HazelcastConstants.INSTANCE_HOST));
+        assertNotNull(headers.get(HazelcastConstants.INSTANCE_PORT));
+    }
+}

Propchange: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastInstanceConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastInstanceConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListConsumerTest.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListConsumerTest.java (added)
+++ camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListConsumerTest.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import com.hazelcast.core.Hazelcast;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class HazelcastListConsumerTest extends CamelTestSupport {
+
+    @Test
+    public void add() throws InterruptedException {
+        MockEndpoint out = getMockEndpoint("mock:added");
+        out.expectedMessageCount(1);
+
+        List<String> list = Hazelcast.getList("mm");
+        list.clear();
+
+        list.add("foo");
+
+        assertMockEndpointsSatisfied(2000, TimeUnit.MILLISECONDS);
+
+        this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.ADDED);
+    }
+
+    @Test
+    public void remove() throws InterruptedException {
+        MockEndpoint out = getMockEndpoint("mock:removed");
+
+        out.expectedMessageCount(1);
+
+        List<String> list = Hazelcast.getList("mm");
+        list.clear();
+
+        list.add("foo");
+        list.remove("foo");
+
+        assertMockEndpointsSatisfied(2000, TimeUnit.MILLISECONDS);
+        this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.REMOVED);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(String.format("hazelcast:%smm", HazelcastConstants.LIST_PREFIX)).log("object...").choice().when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
+                        .log("...added").to("mock:added").when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED)).log("...removed").to("mock:removed").otherwise()
+                        .log("fail!");
+            }
+        };
+    }
+
+    private void checkHeaders(Map<String, Object> headers, String action) {
+        assertEquals(action, headers.get(HazelcastConstants.LISTENER_ACTION));
+        assertEquals(HazelcastConstants.CACHE_LISTENER, headers.get(HazelcastConstants.LISTENER_TYPE));
+        assertEquals(null, headers.get(HazelcastConstants.OBJECT_ID));
+        assertNotNull(headers.get(HazelcastConstants.LISTENER_TIME));
+    }
+}

Propchange: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListProducerTest.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListProducerTest.java (added)
+++ camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListProducerTest.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,154 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast;
+
+import java.util.List;
+
+import com.hazelcast.core.Hazelcast;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class HazelcastListProducerTest extends CamelTestSupport {
+
+    // @Test
+    public void add() throws InterruptedException {
+        List<Object> list = Hazelcast.getList("bar");
+        list.clear();
+
+        template.sendBody("direct:add", "bar");
+
+        assertTrue(list.contains("bar"));
+
+        list.clear();
+    }
+
+    // @Test
+    public void removeValue() throws InterruptedException {
+        List<String> list = Hazelcast.getList("bar");
+        list.clear();
+
+        list.add("foo1");
+        list.add("foo2");
+        list.add("foo3");
+
+        assertEquals(3, list.size());
+
+        // specify the value to remove
+        template.sendBody("direct:removevalue", "foo2");
+
+        assertEquals(2, list.size());
+        assertTrue(list.contains("foo1") && list.contains("foo3"));
+
+        list.clear();
+    }
+
+    @Test(expected = CamelExecutionException.class)
+    public void get() {
+        // unsupported operation
+
+        List<String> list = Hazelcast.getList("bar");
+        list.clear();
+
+        list.add("foo1");
+        list.add("foo2");
+
+        assertEquals(2, list.size());
+
+        template.sendBodyAndHeader("direct:get", "test", HazelcastConstants.OBJECT_POS, 1);
+
+        assertEquals("test", consumer.receiveBody("seda:out", 5000, String.class));
+
+    }
+
+    @Test(expected = CamelExecutionException.class)
+    public void setValueWithIdx() {
+        // unsupported operation
+
+        List<String> list = Hazelcast.getList("bar");
+        list.clear();
+
+        list.add("foo1");
+        list.add("foo2");
+
+        assertEquals(2, list.size());
+
+        template.sendBodyAndHeader("direct:set", "test", HazelcastConstants.OBJECT_POS, 1);
+
+        assertEquals(2, list.size());
+        assertEquals("test", list.get(1));
+
+    }
+
+    // @Test(expected=CamelExecutionException.class)
+    public void removeValueWithIdx() {
+        // unsupported operation
+
+        List<String> list = Hazelcast.getList("bar");
+        list.clear();
+
+        list.add("foo1");
+        list.add("foo2");
+
+        assertEquals(2, list.size());
+
+        template.sendBodyAndHeader("direct:removevalue", null, HazelcastConstants.OBJECT_POS, 1);
+
+        assertEquals(1, list.size());
+
+    }
+
+    // @Test(expected = CamelExecutionException.class)
+    public void removeNullValue() {
+        // unsupported operation
+
+        /*
+         * TODO: is this case a norm ? should this case handled in a different way ?
+         */
+
+        List<String> list = Hazelcast.getList("bar");
+        list.clear();
+
+        list.add("foo1");
+
+        // do not specify the value to delete (null)
+        template.sendBody("direct:removevalue", null);
+        assertEquals(0, list.size());
+
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:add").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.ADD_OPERATION)).to(String.format("hazelcast:%sbar", HazelcastConstants.LIST_PREFIX));
+
+                from("direct:set").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.SETVALUE_OPERATION)).to(String.format("hazelcast:%sbar", HazelcastConstants.LIST_PREFIX));
+
+                from("direct:get").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.GET_OPERATION)).to(String.format("hazelcast:%sbar", HazelcastConstants.LIST_PREFIX))
+                        .to("seda:out");
+
+                from("direct:removevalue").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.REMOVEVALUE_OPERATION)).to(
+                        String.format("hazelcast:%sbar", HazelcastConstants.LIST_PREFIX));
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListProducerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListProducerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapConsumerTest.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapConsumerTest.java (added)
+++ camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapConsumerTest.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,121 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast;
+
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.IMap;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class HazelcastMapConsumerTest extends CamelTestSupport {
+
+    private IMap<String, Object> map;
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+
+        this.map = Hazelcast.getMap("foo");
+        this.map.clear();
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+
+        this.map.clear();
+    }
+
+    @Test
+    public void testAdd() throws InterruptedException {
+        MockEndpoint out = getMockEndpoint("mock:added");
+        out.expectedMessageCount(1);
+
+        map.put("4711", "my-foo");
+
+        assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS);
+
+        this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.ADDED);
+    }
+
+    @Test
+    public void testEnvict() throws InterruptedException {
+        MockEndpoint out = super.getMockEndpoint("mock:envicted");
+        out.expectedMessageCount(5);
+
+        map.put("1", "my-foo-1");
+        map.put("2", "my-foo-2");
+        map.put("3", "my-foo-3");
+        map.put("4", "my-foo-4");
+        map.put("5", "my-foo-5");
+        map.put("6", "my-foo-6");
+
+        assertMockEndpointsSatisfied(30000, TimeUnit.MILLISECONDS);
+    }
+
+    @Test
+    public void testUpdate() throws InterruptedException {
+        MockEndpoint out = getMockEndpoint("mock:updated");
+        out.expectedMessageCount(1);
+
+        map.put("4711", "my-foo");
+        map.replace("4711", "my-fooo");
+
+        assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS);
+
+        this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.UPDATED);
+    }
+
+    @Test
+    public void testRemove() throws InterruptedException {
+        MockEndpoint out = getMockEndpoint("mock:removed");
+        out.expectedMessageCount(1);
+
+        map.put("4711", "my-foo");
+        map.remove("4711");
+
+        assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS);
+        this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.REMOVED);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(String.format("hazelcast:%sfoo", HazelcastConstants.MAP_PREFIX)).log("object...").choice().when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
+                        .log("...added").to("mock:added").when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ENVICTED)).log("...envicted").to("mock:envicted")
+                        .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.UPDATED)).log("...updated").to("mock:updated")
+                        .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED)).log("...removed").to("mock:removed").otherwise().log("fail!");
+
+            }
+        };
+    }
+
+    private void checkHeaders(Map<String, Object> headers, String action) {
+        assertEquals(action, headers.get(HazelcastConstants.LISTENER_ACTION));
+        assertEquals(HazelcastConstants.CACHE_LISTENER, headers.get(HazelcastConstants.LISTENER_TYPE));
+        assertEquals("4711", headers.get(HazelcastConstants.OBJECT_ID));
+        assertNotNull(headers.get(HazelcastConstants.LISTENER_TIME));
+    }
+}

Propchange: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerForSpringTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerForSpringTest.java?rev=1075264&view=auto
==============================================================================
--- camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerForSpringTest.java (added)
+++ camel/trunk/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerForSpringTest.java Mon Feb 28 10:13:34 2011
@@ -0,0 +1,144 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast;
+
+import java.io.Serializable;
+import java.util.Collection;
+
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.IMap;
+
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class HazelcastMapProducerForSpringTest extends CamelSpringTestSupport implements Serializable {
+
+    private IMap<String, Object> map;
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+
+        this.map = Hazelcast.getMap("foo");
+        this.map.clear();
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+
+        this.map.clear();
+    }
+
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("/META-INF/spring/test-camel-context-map.xml");
+    }
+
+    @Test
+    public void testPut() throws InterruptedException {
+        template.sendBodyAndHeader("direct:put", "my-foo", HazelcastConstants.OBJECT_ID, "4711");
+
+        assertTrue(map.containsKey("4711"));
+        assertEquals("my-foo", map.get("4711"));
+    }
+
+    @Test
+    public void testUpdate() {
+        template.sendBodyAndHeader("direct:put", "my-foo", HazelcastConstants.OBJECT_ID, "4711");
+
+        assertTrue(map.containsKey("4711"));
+        assertEquals("my-foo", map.get("4711"));
+
+        template.sendBodyAndHeader("direct:update", "my-fooo", HazelcastConstants.OBJECT_ID, "4711");
+        assertEquals("my-fooo", map.get("4711"));
+    }
+
+    @Test
+    public void testGet() {
+        map.put("4711", "my-foo");
+
+        template.sendBodyAndHeader("direct:get", null, HazelcastConstants.OBJECT_ID, "4711");
+        String body = consumer.receiveBody("seda:out", 5000, String.class);
+
+        assertEquals("my-foo", body);
+    }
+
+    @Test
+    public void testDelete() {
+        map.put("4711", "my-foo");
+        assertEquals(1, map.size());
+
+        template.sendBodyAndHeader("direct:delete", null, HazelcastConstants.OBJECT_ID, "4711");
+        assertEquals(0, map.size());
+    }
+
+    @Test
+    public void testQuery() {
+        map.put("1", new Dummy("alpha", 1000));
+        map.put("2", new Dummy("beta", 2000));
+        map.put("3", new Dummy("gamma", 3000));
+
+        String q1 = "bar > 1000";
+        String q2 = "foo LIKE alp%";
+
+        template.sendBodyAndHeader("direct:query", null, HazelcastConstants.QUERY, q1);
+        Collection<Dummy> b1 = consumer.receiveBody("seda:out", 5000, Collection.class);
+
+        assertNotNull(b1);
+        assertEquals(2, b1.size());
+
+        template.sendBodyAndHeader("direct:query", null, HazelcastConstants.QUERY, q2);
+        Collection<Dummy> b2 = consumer.receiveBody("seda:out", 5000, Collection.class);
+
+        assertNotNull(b2);
+        assertEquals(1, b2.size());
+    }
+
+    public class Dummy implements Serializable {
+
+        private static final long serialVersionUID = 3688457704655925278L;
+
+        private String foo;
+        private int bar;
+        
+        public Dummy(String foo, int bar) {
+            this.foo = foo;
+            this.bar = bar;
+        }
+
+        public String getFoo() {
+            return foo;
+        }
+
+        public void setFoo(String foo) {
+            this.foo = foo;
+        }
+
+        public int getBar() {
+            return bar;
+        }
+
+        public void setBar(int bar) {
+            this.bar = bar;
+        }
+
+    }
+
+}



Mime
View raw message