Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed unused cron strategy since Camel 2.9.0 we can use CronSchedul…

…edRoutePolicy
  • Loading branch information...
commit 7d7c3577e8150686a1cb19d023d37231ebc0c879 1 parent e5701ce
@ullgren ullgren authored
View
7 .gitignore
@@ -1,4 +1,11 @@
*.class
+target/*
+
+# Eclipse project files #
+.classpath
+.project
+.settings/
+
# Package Files #
*.jar
View
25 pom.xml
@@ -21,7 +21,7 @@
<version>2.9.0-1.0</version>
<name>A Camel SMB Component</name>
- <url>http://www.redpill-linpro.com</url>
+ <url>https://github.com/Redpill-Linpro/camel-smb</url>
<properties>
<camel-version>2.9.0</camel-version>
@@ -33,18 +33,6 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel-version}</version>
- <exclusions>
- <exclusion>
- <artifactId>slf4j-api</artifactId>
- <groupId>org.slf4j</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.quartz-scheduler</groupId>
- <artifactId>quartz</artifactId>
- <version>1.8.3</version>
</dependency>
<dependency>
@@ -67,11 +55,11 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
- <version>${camel-version}</version>
- <scope>test</scope>
- </dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
@@ -86,6 +74,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
View
20 src/main/java/com/redpill_linpro/component/smb/SmbEndpoint.java
@@ -1,7 +1,5 @@
package com.redpill_linpro.component.smb;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
import java.util.Map;
import jcifs.smb.SmbFile;
@@ -18,8 +16,6 @@
protected SmbClient smbClient;
protected Map<String, Object> props;
- private String cron;
-
public SmbEndpoint(String uri, SmbComponent smbComponent, SmbConfiguration configuration) {
super(uri, smbComponent);
this.configuration = configuration;
@@ -76,22 +72,6 @@ public char getFileSeparator() {
public boolean isAbsolute(String name) {
return true;
}
-
- public void setCron(String cron) {
- if (log.isDebugEnabled())
- log.debug("setCron() cron[" + cron + "]");
- String newCron = "";
- try {
- newCron = URLDecoder.decode(cron, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- log.warn("cron expression [" + cron + "] not valid!");
- }
- this.cron = newCron;
- }
-
- public String getCron() {
- return cron;
- }
@Override
public boolean isSingleton(){
View
53 src/main/java/com/redpill_linpro/component/smb/strategy/CronPollStrategy.java
@@ -1,53 +0,0 @@
-package com.redpill_linpro.component.smb.strategy;
-
-import java.util.Date;
-
-import org.apache.camel.Consumer;
-import org.apache.camel.Endpoint;
-import org.apache.camel.impl.DefaultPollingConsumerPollStrategy;
-import org.quartz.CronExpression;
-
-import com.redpill_linpro.component.smb.SmbConsumer;
-import com.redpill_linpro.component.smb.SmbEndpoint;
-
-public class CronPollStrategy extends DefaultPollingConsumerPollStrategy {
- @Override
- public boolean begin(Consumer consumer, Endpoint endpoint) {
- log.trace("CronPolicy begin called");
-
- SmbConsumer smbConsumer = (SmbConsumer) consumer;
-
- try {
- CronExpression cronExpression = lookup((SmbEndpoint) endpoint);
-
- Date now = new Date();
- Date nextTrigger = cronExpression.getNextValidTimeAfter(now);
- Long timeSpan = Math.abs(nextTrigger.getTime() - now.getTime());
-
- if (log.isDebugEnabled()) {
- log.debug(String.format("Now [%1$tH:%1$tM:%1$tS] Next [%2$tH:%2$tM:%2$tS]", now, nextTrigger));
- log.debug(String.format("Span [%d] Delay [%d]", timeSpan, smbConsumer.getDelay()));
- }
-
- return (timeSpan <= smbConsumer.getDelay());
- } catch (Exception e) {
- log.warn("No valid cron expression", e);
- return true;
- }
- }
-
- public boolean rollback(Consumer consumer, Endpoint endpoint, int retryCounter, Exception cause) throws Exception {
- log.info("strategy got an Exception: " + cause);
- log.info("retryCounter [" + retryCounter + "]");
- throw cause;
- }
-
- private CronExpression lookup(SmbEndpoint smbEndpoint) throws Exception {
- String cron = smbEndpoint.getCron();
-
- if (cron == null) throw new Exception("No cron expression available");
- if (!CronExpression.isValidExpression(cron)) throw new Exception("Invalid cron expression [" + cron + "]");
-
- return new CronExpression(cron);
- }
-}
View
2  ...ro/component/smb/FromFtpMoveFileTest.java → ...ro/component/smb/FromSmbMoveFileTest.java
@@ -11,7 +11,7 @@
/**
* Unit test to test both consumer.moveNamePrefix and consumer.moveNamePostfix options.
*/
-public class FromFtpMoveFileTest extends BaseSmbTestSupport {
+public class FromSmbMoveFileTest extends BaseSmbTestSupport {
private String getSmbUrl() {
return "smb://"+getDomain()+";"+getUsername()+"@localhost/"+getShare()+"/camel/"
+getClass().getSimpleName()+"?password="+getPassword()
Please sign in to comment.
Something went wrong with that request. Please try again.