camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/8] camel git commit: CAMEL-8368: Adding new scheduler component
Date Sat, 21 Feb 2015 15:02:31 GMT
CAMEL-8368: Adding new scheduler component


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/44561c98
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/44561c98
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/44561c98

Branch: refs/heads/master
Commit: 44561c98f0914d5d6d66eb7e551a0b687b7e790b
Parents: b9781ad
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sat Feb 21 11:24:59 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Feb 21 11:24:59 2015 +0100

----------------------------------------------------------------------
 camel-core/pom.xml                              |  1 +
 .../component/scheduler/SchedulerComponent.java | 36 ++++++++++++
 .../component/scheduler/SchedulerConsumer.java  | 45 ++++++++++++++
 .../component/scheduler/SchedulerEndpoint.java  | 62 ++++++++++++++++++++
 .../camel/component/scheduler/package.html      | 25 ++++++++
 .../apache/camel/component/timer/package.html   |  2 +-
 .../org/apache/camel/component/scheduler        | 18 ++++++
 7 files changed, 188 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/44561c98/camel-core/pom.xml
----------------------------------------------------------------------
diff --git a/camel-core/pom.xml b/camel-core/pom.xml
index ffb7a5a..e5198f0 100644
--- a/camel-core/pom.xml
+++ b/camel-core/pom.xml
@@ -70,6 +70,7 @@
       org.apache.camel.spi.ComponentResolver;component=ref,
       org.apache.camel.spi.ComponentResolver;component=rest,
       org.apache.camel.spi.ComponentResolver;component=seda,
+      org.apache.camel.spi.ComponentResolver;component=scheduler,
       org.apache.camel.spi.ComponentResolver;component=stub,
       org.apache.camel.spi.ComponentResolver;component=test,
       org.apache.camel.spi.ComponentResolver;component=timer,

http://git-wip-us.apache.org/repos/asf/camel/blob/44561c98/camel-core/src/main/java/org/apache/camel/component/scheduler/SchedulerComponent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/scheduler/SchedulerComponent.java
b/camel-core/src/main/java/org/apache/camel/component/scheduler/SchedulerComponent.java
new file mode 100644
index 0000000..766faa9
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/scheduler/SchedulerComponent.java
@@ -0,0 +1,36 @@
+/**
+ * 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.scheduler;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.UriEndpointComponent;
+
+public class SchedulerComponent extends UriEndpointComponent {
+
+    public SchedulerComponent() {
+        super(SchedulerEndpoint.class);
+    }
+
+    @Override
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
+        SchedulerEndpoint answer = new SchedulerEndpoint(uri, this, remaining);
+        setProperties(answer, parameters);
+        return answer;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/44561c98/camel-core/src/main/java/org/apache/camel/component/scheduler/SchedulerConsumer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/scheduler/SchedulerConsumer.java
b/camel-core/src/main/java/org/apache/camel/component/scheduler/SchedulerConsumer.java
new file mode 100644
index 0000000..6eb5023
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/scheduler/SchedulerConsumer.java
@@ -0,0 +1,45 @@
+/**
+ * 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.scheduler;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.ScheduledPollConsumer;
+
+public class SchedulerConsumer extends ScheduledPollConsumer {
+
+    public SchedulerConsumer(Endpoint endpoint, Processor processor) {
+        super(endpoint, processor);
+    }
+
+    @Override
+    protected int poll() throws Exception {
+        Exchange exchange = getEndpoint().createExchange();
+        try {
+            getProcessor().process(exchange);
+        } catch (Exception e) {
+            exchange.setException(e);
+        }
+
+        if (exchange.getException() != null) {
+            getExceptionHandler().handleException("Error processing exchange", exchange,
exchange.getException());
+        }
+
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/44561c98/camel-core/src/main/java/org/apache/camel/component/scheduler/SchedulerEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/scheduler/SchedulerEndpoint.java
b/camel-core/src/main/java/org/apache/camel/component/scheduler/SchedulerEndpoint.java
new file mode 100644
index 0000000..6ae349d
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/scheduler/SchedulerEndpoint.java
@@ -0,0 +1,62 @@
+/**
+ * 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.scheduler;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.ScheduledPollEndpoint;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriPath;
+
+@UriEndpoint(scheme = "scheduler", consumerOnly = true, consumerClass = SchedulerConsumer.class,
label = "core,scheduling")
+public class SchedulerEndpoint extends ScheduledPollEndpoint {
+
+    @UriPath @Metadata(required = "true")
+    private String name;
+
+    public SchedulerEndpoint(String uri, SchedulerComponent component, String remaining)
{
+        super(uri, component);
+        this.name = remaining;
+    }
+
+    @Override
+    public Producer createProducer() throws Exception {
+        throw new UnsupportedOperationException("Scheduler cannot be used as a producer");
+    }
+
+    @Override
+    public Consumer createConsumer(Processor processor) throws Exception {
+        SchedulerConsumer consumer = new SchedulerConsumer(this, processor);
+        configureConsumer(consumer);
+        return consumer;
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/44561c98/camel-core/src/main/java/org/apache/camel/component/scheduler/package.html
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/scheduler/package.html b/camel-core/src/main/java/org/apache/camel/component/scheduler/package.html
new file mode 100644
index 0000000..8f10722
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/scheduler/package.html
@@ -0,0 +1,25 @@
+<!--
+    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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+The <a href="http://camel.apache.org/scheduler.html">Scheduler Component</a>
to schedule routes
+
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/camel/blob/44561c98/camel-core/src/main/java/org/apache/camel/component/timer/package.html
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/timer/package.html b/camel-core/src/main/java/org/apache/camel/component/timer/package.html
index d573393..ba5ad2c 100644
--- a/camel-core/src/main/java/org/apache/camel/component/timer/package.html
+++ b/camel-core/src/main/java/org/apache/camel/component/timer/package.html
@@ -19,7 +19,7 @@
 </head>
 <body>
 
-The <a href="http://camel.apache.org/timer.html">Timer Component</a> extends
the POJO component to provide a
+The <a href="http://camel.apache.org/timer.html">Timer Component</a> provides
a
 simple timer
 
 </body>

http://git-wip-us.apache.org/repos/asf/camel/blob/44561c98/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/scheduler
----------------------------------------------------------------------
diff --git a/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/scheduler
b/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/scheduler
new file mode 100644
index 0000000..0805ee2
--- /dev/null
+++ b/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/scheduler
@@ -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.scheduler.SchedulerComponent


Mime
View raw message