You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/04/06 11:33:56 UTC
svn commit: r1310262 [11/14] - in /archiva/redback/redback-components/trunk:
./ plexus-command-line/ plexus-command-line/src/
plexus-command-line/src/main/ plexus-command-line/src/main/java/
plexus-command-line/src/main/java/org/ plexus-command-line/sr...
Added: archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/spring-context-configurable.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/spring-context-configurable.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/spring-context-configurable.xml (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/spring-context-configurable.xml Fri Apr 6 09:33:40 2012
@@ -0,0 +1,74 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ 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.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+
+ <bean name="jdoFactory" class="org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory">
+ <!-- HSQLDB Configuration -->
+ <!--
+ NOTE: NO NOT USE THIS CONFIGURATION FOR A PRODUCTION SYSTEM.
+ HSQLDB keeps all data in memory at all times.
+
+ NOTE: JPOX 1.1.1 won't create the tables on start
+ http://www.jpox.org/servlet/jira/browse/CORE-2946
+ -->
+ <property name="driverName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:mem:test"/>
+ <property name="userName" value="sa"/>
+
+ <!-- Apache Derby Configuration -->
+ <!--
+ <driverName>org.apache.derby.jdbc.EmbeddedDriver</driverName>
+ <url>jdbc:derby:${plexus.home}/database;create=true</url>
+ <userName>sa</userName>
+ <password></password>
+ -->
+
+ <!-- Postgresql Configuration -->
+ <!--
+ <driverName>org.postgresql.Driver</driverName>
+ <url>jdbc:postgresql://localhost/continuum</url>
+ <userName>username</userName>
+ <password></password>
+ -->
+ <!-- JPOX and JDO configuration -->
+ <property name="persistenceManagerFactoryClass" value="org.jpox.PersistenceManagerFactoryImpl"/>
+
+ <property name="otherProperties">
+ <props>
+ <prop key="org.jpox.autoCreateSchema">true</prop>
+ <prop key="org.jpox.autoStartMechanism">SchemaTable</prop>
+ <prop key="org.jpox.validateTables">false</prop>
+ <prop key="org.jpox.validateConstraints">false</prop>
+ <prop key="org.jpox.autoStartMechanismMode">Ignored</prop>
+ <prop key="org.jpox.transactionIsolation">READ_UNCOMMITTED</prop>
+ <prop key="org.jpox.poid.transactionIsolation">READ_UNCOMMITTED</prop>
+ </props>
+ </property>
+ </bean>
+
+</beans>
\ No newline at end of file
Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/spring-context-configurable.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/spring-context-configurable.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/spring-context.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/spring-context.xml (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/spring-context.xml Fri Apr 6 09:33:40 2012
@@ -0,0 +1,77 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ 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.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+
+ <bean name="jdoUtilsTest" class="org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory"/>
+
+ <bean name="jdoFactory" class="org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory">
+ <!-- HSQLDB Configuration -->
+ <!--
+ NOTE: NO NOT USE THIS CONFIGURATION FOR A PRODUCTION SYSTEM.
+ HSQLDB keeps all data in memory at all times.
+
+ NOTE: JPOX 1.1.1 won't create the tables on start
+ http://www.jpox.org/servlet/jira/browse/CORE-2946
+ -->
+ <property name="driverName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:mem:test"/>
+ <property name="userName" value="sa"/>
+
+ <!-- Apache Derby Configuration -->
+ <!--
+ <driverName>org.apache.derby.jdbc.EmbeddedDriver</driverName>
+ <url>jdbc:derby:${plexus.home}/database;create=true</url>
+ <userName>sa</userName>
+ <password></password>
+ -->
+
+ <!-- Postgresql Configuration -->
+ <!--
+ <driverName>org.postgresql.Driver</driverName>
+ <url>jdbc:postgresql://localhost/continuum</url>
+ <userName>username</userName>
+ <password></password>
+ -->
+ <!-- JPOX and JDO configuration -->
+ <property name="persistenceManagerFactoryClass" value="org.jpox.PersistenceManagerFactoryImpl"/>
+
+ <property name="otherProperties">
+ <props>
+ <prop key="org.jpox.autoCreateSchema">true</prop>
+ <prop key="org.jpox.autoStartMechanism">SchemaTable</prop>
+ <prop key="org.jpox.validateTables">false</prop>
+ <prop key="org.jpox.validateConstraints">false</prop>
+ <prop key="org.jpox.autoStartMechanismMode">Ignored</prop>
+ <prop key="org.jpox.transactionIsolation">READ_UNCOMMITTED</prop>
+ <prop key="org.jpox.poid.transactionIsolation">READ_UNCOMMITTED</prop>
+ </props>
+ </property>
+ </bean>
+
+
+</beans>
\ No newline at end of file
Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-quartz/pom.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-quartz/pom.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-quartz/pom.xml (added)
+++ archiva/redback/redback-components/trunk/spring-quartz/pom.xml Fri Apr 6 09:33:40 2012
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.codehaus.redback.components</groupId>
+ <artifactId>redback-components</artifactId>
+ <version>1.3-SNAPSHOT</version>
+ <relativePath>../redback-components-parent/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>spring-quartz</artifactId>
+ <name>Spring Quartz Component</name>
+ <version>1.1-SNAPSHOT</version>
+
+ <url>http://redback.codehaus.org/components/${project.artifactId}</url>
+
+ <distributionManagement>
+ <site>
+ <id>codehaus.org</id>
+ <url>dav:https://dav.codehaus.org/redback/components/${project.artifactId}</url>
+ </site>
+ </distributionManagement>
+
+ <scm>
+ <connection>scm:svn:https://svn.codehaus.org/redback/components/trunk/spring-quartz</connection>
+ <developerConnection>scm:svn:https://svn.codehaus.org/redback/components/trunk/spring-quartz</developerConnection>
+ <url>http://fisheye.codehaus.org/browse/redback/components/trunk/spring-quartz</url>
+ </scm>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.quartz-scheduler</groupId>
+ <artifactId>quartz</artifactId>
+ <version>2.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>c3p0</groupId>
+ <artifactId>c3p0</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkedProcessTimeoutInSeconds>60</forkedProcessTimeoutInSeconds>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: archiva/redback/redback-components/trunk/spring-quartz/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-quartz/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/AbstractJob.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/AbstractJob.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/AbstractJob.java (added)
+++ archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/AbstractJob.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,96 @@
+package org.codehaus.redback.components.scheduler;
+
+/*
+ * 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.
+ */
+
+import org.quartz.JobDataMap;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.quartz.InterruptableJob;
+import org.quartz.UnableToInterruptJobException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Base class from which all <code>Job</code>s running in the
+ * scheduler should be derived from if they want access to the
+ * ServiceBroker.
+ *
+ * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
+ * @version $Id$
+ */
+public abstract class AbstractJob
+ implements InterruptableJob
+{
+
+ private Logger log = LoggerFactory.getLogger( getClass() );
+
+ /** JobDataMap tag for the job's logger. */
+ public static final String LOGGER = "JOB_LOGGER";
+
+ /** JobDataMap tag for the job's context. */
+ public static final String CONTEXT = "JOB_CONTEXT";
+
+ /** JobDataMap tag for the job's service broker. */
+ public static final String SERVICE_MANAGER = "JOB_SERVICE_MANAGER";
+
+ /** JobDataMap tag for the job's configuration. */
+ public static final String EXECUTION_CONFIGURATION = "JOB_EXECUTION_CONFIGURATION";
+
+ /** Job Data Map */
+ private JobDataMap jobDataMap;
+
+ private boolean interrupted;
+
+ /** Set Job Data Map */
+ public void setJobDataMap(JobDataMap jobDataMap)
+ {
+ this.jobDataMap = jobDataMap;
+ }
+
+ /** Get Job Data Map */
+ public JobDataMap getJobDataMap()
+ {
+ return jobDataMap;
+ }
+
+ /** Get the Logger. */
+ public Logger getLogger()
+ {
+ return (Logger) getJobDataMap().get(LOGGER);
+ }
+
+
+
+ /** Execute the Job. */
+ public abstract void execute(JobExecutionContext context)
+ throws JobExecutionException;
+
+ public boolean isInterrupted()
+ {
+ return interrupted;
+ }
+
+ public void interrupt()
+ throws UnableToInterruptJobException
+ {
+ interrupted = true;
+ }
+}
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/AbstractJob.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/AbstractJob.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/CronExpressionValidator.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/CronExpressionValidator.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/CronExpressionValidator.java (added)
+++ archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/CronExpressionValidator.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,441 @@
+package org.codehaus.redback.components.scheduler;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+import org.apache.commons.lang.StringUtils;
+import org.quartz.CronTrigger;
+import org.quartz.impl.triggers.CronTriggerImpl;
+import org.springframework.stereotype.Service;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+/**
+ * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+@Service
+public final class CronExpressionValidator
+{
+
+ /**
+ * Validates a cron expression.
+ *
+ * @param cronExpression The expression to validate
+ * @return True is expression is valid
+ */
+ public boolean validate( String cronExpression )
+ {
+ try
+ {
+ String[] cronParams = StringUtils.split( cronExpression );
+
+ if ( cronParams.length < 6 || cronParams.length > 7 )
+ {
+ return false;
+ }
+
+ CronTriggerImpl cronTrigger = new CronTriggerImpl();
+
+ cronTrigger.setCronExpression( cronExpression );
+
+ if ( cronParams[3].equals( "?" ) || cronParams[5].equals( "?" ) )
+ {
+ //Check seconds param
+ if ( !checkSecondsField( cronParams[0] ) )
+ {
+ return false;
+ }
+
+ //Check minutes param
+ if ( !checkMinutesField( cronParams[1] ) )
+ {
+ return false;
+ }
+
+ //Check hours param
+ if ( !checkHoursField( cronParams[2] ) )
+ {
+ return false;
+ }
+
+ //Check day-of-month param
+ if ( !checkDayOfMonthField( cronParams[3] ) )
+ {
+ return false;
+ }
+
+ //Check months param
+ if ( !checkMonthsField( cronParams[4] ) )
+ {
+ return false;
+ }
+
+ //Check day-of-week param
+ if ( !checkDayOfWeekField( cronParams[5] ) )
+ {
+ return false;
+ }
+
+ //Check year param
+ if ( cronParams.length == 7 )
+ {
+ if ( !checkYearField( cronParams[6] ) )
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ catch ( ParseException e )
+ {
+ return false;
+ }
+ }
+
+ private boolean checkSecondsField( String secondsField )
+ {
+ return checkField( secondsField, 0, 59 );
+ }
+
+ private boolean checkMinutesField( String minutesField )
+ {
+ return checkField( minutesField, 0, 59 );
+ }
+
+ private boolean checkHoursField( String hoursField )
+ {
+ return checkField( hoursField, 0, 23 );
+ }
+
+ private boolean checkDayOfMonthField( String dayOfMonthField )
+ {
+ if ( "?".equals( dayOfMonthField ) )
+ {
+ return true;
+ }
+
+ if ( dayOfMonthField.indexOf( "L" ) >= 0 )
+ {
+ return checkFieldWithLetter( dayOfMonthField, "L", 1, 7, -1, -1 );
+ }
+ else if ( dayOfMonthField.indexOf( "W" ) >= 0 )
+ {
+ return checkFieldWithLetter( dayOfMonthField, "W", 1, 31, -1, -1 );
+ }
+ else if ( dayOfMonthField.indexOf( "C" ) >= 0 )
+ {
+ return checkFieldWithLetter( dayOfMonthField, "C", 1, 31, -1, -1 );
+ }
+ else
+ {
+ return checkField( dayOfMonthField, 1, 31 );
+ }
+ }
+
+ private boolean checkMonthsField( String monthsField )
+ {
+ monthsField = StringUtils.replace( monthsField, "JAN", "1" );
+ monthsField = StringUtils.replace( monthsField, "FEB", "2" );
+ monthsField = StringUtils.replace( monthsField, "MAR", "3" );
+ monthsField = StringUtils.replace( monthsField, "APR", "4" );
+ monthsField = StringUtils.replace( monthsField, "MAY", "5" );
+ monthsField = StringUtils.replace( monthsField, "JUN", "6" );
+ monthsField = StringUtils.replace( monthsField, "JUL", "7" );
+ monthsField = StringUtils.replace( monthsField, "AUG", "8" );
+ monthsField = StringUtils.replace( monthsField, "SEP", "9" );
+ monthsField = StringUtils.replace( monthsField, "OCT", "10" );
+ monthsField = StringUtils.replace( monthsField, "NOV", "11" );
+ monthsField = StringUtils.replace( monthsField, "DEC", "12" );
+
+ return checkField( monthsField, 1, 31 );
+ }
+
+ private boolean checkDayOfWeekField( String dayOfWeekField )
+ {
+ dayOfWeekField = StringUtils.replace( dayOfWeekField, "SUN", "1" );
+ dayOfWeekField = StringUtils.replace( dayOfWeekField, "MON", "2" );
+ dayOfWeekField = StringUtils.replace( dayOfWeekField, "TUE", "3" );
+ dayOfWeekField = StringUtils.replace( dayOfWeekField, "WED", "4" );
+ dayOfWeekField = StringUtils.replace( dayOfWeekField, "THU", "5" );
+ dayOfWeekField = StringUtils.replace( dayOfWeekField, "FRI", "6" );
+ dayOfWeekField = StringUtils.replace( dayOfWeekField, "SAT", "7" );
+
+ if ( "?".equals( dayOfWeekField ) )
+ {
+ return true;
+ }
+
+ if ( dayOfWeekField.indexOf( "L" ) >= 0 )
+ {
+ return checkFieldWithLetter( dayOfWeekField, "L", 1, 7, -1, -1 );
+ }
+ else if ( dayOfWeekField.indexOf( "C" ) >= 0 )
+ {
+ return checkFieldWithLetter( dayOfWeekField, "C", 1, 7, -1, -1 );
+ }
+ else if ( dayOfWeekField.indexOf( "#" ) >= 0 )
+ {
+ return checkFieldWithLetter( dayOfWeekField, "#", 1, 7, 1, 5 );
+ }
+ else
+ {
+ return checkField( dayOfWeekField, 1, 7 );
+ }
+ }
+
+ private boolean checkYearField( String yearField )
+ {
+ return checkField( yearField, 1970, 2099 );
+ }
+
+ private boolean checkField( String secondsField, int minimal, int maximal )
+ {
+ if ( secondsField.indexOf( "-" ) > -1 )
+ {
+ String startValue = secondsField.substring( 0, secondsField.indexOf( "-" ) );
+ String endValue = secondsField.substring( secondsField.indexOf( "-" ) + 1 );
+
+ if ( !( checkIntValue( startValue, minimal, maximal ) && checkIntValue( endValue, minimal, maximal ) ) )
+ {
+ return false;
+ }
+ try
+ {
+ int startVal = Integer.parseInt( startValue );
+ int endVal = Integer.parseInt( endValue );
+
+ return endVal > startVal;
+
+ }
+ catch ( NumberFormatException e )
+ {
+ return false;
+ }
+ }
+ else if ( secondsField.indexOf( "," ) > -1 )
+ {
+ return checkListField( secondsField, minimal, maximal );
+ }
+ else if ( secondsField.indexOf( "/" ) > -1 )
+ {
+ return checkIncrementField( secondsField, minimal, maximal );
+ }
+ else if ( secondsField.indexOf( "*" ) != -1 )
+ {
+ return true;
+ }
+ else
+ {
+ return checkIntValue( secondsField, minimal, maximal );
+ }
+ }
+
+ private boolean checkFieldWithLetter( String value, String letter, int minimalBefore, int maximalBefore,
+ int minimalAfter, int maximalAfter )
+ {
+ boolean canBeAlone = false;
+ boolean canHaveIntBefore = false;
+ boolean canHaveIntAfter = false;
+ boolean mustHaveIntBefore = false;
+ boolean mustHaveIntAfter = false;
+
+ if ( "L".equals( letter ) )
+ {
+ canBeAlone = true;
+ canHaveIntBefore = true;
+ canHaveIntAfter = false;
+ mustHaveIntBefore = false;
+ mustHaveIntAfter = false;
+ }
+ if ( "W".equals( letter ) || "C".equals( letter ) )
+ {
+ canBeAlone = false;
+ canHaveIntBefore = true;
+ canHaveIntAfter = false;
+ mustHaveIntBefore = true;
+ mustHaveIntAfter = false;
+ }
+ if ( "#".equals( letter ) )
+ {
+ canBeAlone = false;
+ canHaveIntBefore = true;
+ canHaveIntAfter = true;
+ mustHaveIntBefore = true;
+ mustHaveIntAfter = true;
+ }
+
+ String beforeLetter = "";
+ String afterLetter = "";
+
+ if ( value.indexOf( letter ) >= 0 )
+ {
+ beforeLetter = value.substring( 0, value.indexOf( letter ) );
+ }
+
+ if ( !value.endsWith( letter ) )
+ {
+ afterLetter = value.substring( value.indexOf( letter ) + 1 );
+ }
+
+ if ( value.indexOf( letter ) >= 0 )
+ {
+ if ( letter.equals( value ) )
+ {
+ return canBeAlone;
+ }
+
+ if ( canHaveIntBefore )
+ {
+ if ( mustHaveIntBefore && beforeLetter.length() == 0 )
+ {
+ return false;
+ }
+
+ if ( !checkIntValue( beforeLetter, minimalBefore, maximalBefore, true ) )
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if ( beforeLetter.length() > 0 )
+ {
+ return false;
+ }
+ }
+
+ if ( canHaveIntAfter )
+ {
+ if ( mustHaveIntAfter && afterLetter.length() == 0 )
+ {
+ return false;
+ }
+
+ if ( !checkIntValue( afterLetter, minimalAfter, maximalAfter, true ) )
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if ( afterLetter.length() > 0 )
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private boolean checkIncrementField( String value, int minimal, int maximal )
+ {
+ String start = value.substring( 0, value.indexOf( "/" ) );
+
+ String increment = value.substring( value.indexOf( "/" ) + 1 );
+
+ if ( !"*".equals( start ) )
+ {
+ return checkIntValue( start, minimal, maximal ) && checkIntValue( increment, minimal, maximal, false );
+ }
+ else
+ {
+ return checkIntValue( increment, minimal, maximal );
+ }
+ }
+
+ private boolean checkListField( String value, int minimal, int maximal )
+ {
+ StringTokenizer st = new StringTokenizer( value, "," );
+
+ List values = new ArrayList();
+
+ while ( st.hasMoreTokens() )
+ {
+ values.add( st.nextToken() );
+ }
+
+ int previousValue = -1;
+
+ for ( Iterator i = values.iterator(); i.hasNext(); )
+ {
+ String currentValue = (String) i.next();
+
+ if ( !checkIntValue( currentValue, minimal, maximal ) )
+ {
+ return false;
+ }
+
+ try
+ {
+ int val = Integer.parseInt( currentValue );
+
+ if ( val <= previousValue )
+ {
+ return false;
+ }
+ else
+ {
+ previousValue = val;
+ }
+ }
+ catch ( NumberFormatException e )
+ {
+ // we have always an int
+ }
+ }
+
+ return true;
+ }
+
+ private boolean checkIntValue( String value, int minimal, int maximal )
+ {
+ return checkIntValue( value, minimal, maximal, true );
+ }
+
+ private static boolean checkIntValue( String value, int minimal, int maximal, boolean checkExtremity )
+ {
+ try
+ {
+ int val = Integer.parseInt( value );
+
+ if ( checkExtremity )
+ {
+ if ( val < minimal || val > maximal )
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ catch ( NumberFormatException e )
+ {
+ return false;
+ }
+ }
+}
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/CronExpressionValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/CronExpressionValidator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/DefaultJobListener.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/DefaultJobListener.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/DefaultJobListener.java (added)
+++ archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/DefaultJobListener.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,125 @@
+package org.codehaus.redback.components.scheduler;
+
+/* ----------------------------------------------------------------------------
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Plexus", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * ----------------------------------------------------------------------------
+ */
+
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.quartz.JobListener;
+
+/**
+ * Currently the role this class plays is set the value of the <code>JobDataMap</code>
+ * in the job so that the convenience methods for accessing the logger, context,
+ * service broker and configuration will work as expected.
+ *
+ * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
+ * @version $Id$
+ */
+public class DefaultJobListener
+ implements JobListener
+{
+ /**
+ * <p>
+ * <p/>
+ * Get the name of the <code>JobListener</code>.</p>
+ */
+ public String getName()
+ {
+ return "DefaultJobLister";
+ }
+
+ /**
+ * <p>
+ * <p/>
+ * Called by the <code>{@link Scheduler}</code> when a <code>{@link Job}</code>
+ * is about to be executed (an associated <code>{@link org.quartz.Trigger}</code> has
+ * occured).</p>
+ */
+ public void jobToBeExecuted( JobExecutionContext context )
+ {
+ Job job = context.getJobInstance();
+
+ // Only attempt to set the ServiceBroker when we are dealing
+ // with subclasses AbstractJob.
+ if ( job instanceof AbstractJob )
+ {
+ ( (AbstractJob) job ).setJobDataMap( context.getJobDetail().getJobDataMap() );
+ }
+ }
+
+ public void jobExecutionVetoed( JobExecutionContext jobExecutionContext )
+ {
+ }
+
+ /**
+ * <p>
+ * <p/>
+ * Called by the <code>{@link Scheduler}</code> after a <code>{@link Job}</code>
+ * has been executed, and be for the associated <code>Trigger</code>'s
+ * <code>triggered(xx)</code> method has been called.</p>
+ */
+ public void jobWasExecuted( JobExecutionContext context, JobExecutionException jobException )
+ {
+ Job job = context.getJobInstance();
+
+ // Only attempt to null the ServiceBroker when we are dealing
+ // with subclasses AbstractJob.
+ if ( job instanceof AbstractJob )
+ {
+ }
+ }
+}
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/DefaultJobListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/DefaultJobListener.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/DefaultScheduler.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/DefaultScheduler.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/DefaultScheduler.java (added)
+++ archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/DefaultScheduler.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,180 @@
+package org.codehaus.redback.components.scheduler;
+
+/*
+ * 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.
+ */
+
+import org.quartz.JobKey;
+import org.quartz.JobListener;
+import org.quartz.Matcher;
+import org.quartz.SchedulerException;
+import org.quartz.SchedulerFactory;
+import org.quartz.Trigger;
+import org.quartz.TriggerListener;
+import org.quartz.core.QuartzScheduler;
+import org.quartz.impl.JobDetailImpl;
+import org.quartz.impl.StdScheduler;
+import org.quartz.impl.StdSchedulerFactory;
+import org.quartz.utils.Key;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import java.util.Properties;
+
+public class DefaultScheduler
+ implements Scheduler
+{
+
+ private Logger log = LoggerFactory.getLogger( getClass() );
+
+ private Properties properties;
+
+ private StdScheduler scheduler;
+
+ public void scheduleJob( JobDetailImpl jobDetail, Trigger trigger )
+ throws SchedulerException
+ {
+ if ( jobDetail == null || jobDetail.getName() == null )
+ {
+ throw new SchedulerException( "No job or no job name - cannot schedule this job" );
+ }
+
+ if ( jobExists( jobDetail.getName(), jobDetail.getGroup() ) )
+ {
+ log.warn( "Will not schedule this job as a job {" + jobDetail.getName() + ":" + jobDetail.getGroup()
+ + "} already exists." );
+
+ return;
+ }
+
+ try
+ {
+ scheduler.scheduleJob( jobDetail, trigger );
+ }
+ catch ( SchedulerException e )
+ {
+ throw new SchedulerException( "Error scheduling job.", e );
+ }
+ catch ( Exception e )
+ {
+ throw new SchedulerException( "Error scheduling job (Verify your cron expression).", e );
+ }
+ }
+
+ public void addGlobalJobListener( JobListener listener )
+ throws SchedulerException
+ {
+ scheduler.getListenerManager().addJobListener( listener, new AllMatch() );
+ }
+
+ public void addGlobalTriggerListener( TriggerListener listener )
+ throws SchedulerException
+ {
+ scheduler.getListenerManager().addTriggerListener( listener, new AllMatch() );
+ }
+
+ private static class AllMatch<R extends Key<?>> implements Matcher<R>
+ {
+ public boolean isMatch( R key )
+ {
+ return true;
+ }
+ }
+
+ @PostConstruct
+ public void initialize()
+ throws SchedulerException
+ {
+ SchedulerFactory factory = new StdSchedulerFactory( properties );
+
+ scheduler = (StdScheduler) factory.getScheduler();
+
+ scheduler.start();
+
+ }
+
+ @PreDestroy
+ public void stop()
+ {
+ scheduler.shutdown();
+ }
+
+ public void unscheduleJob( String jobName, String groupName )
+ throws SchedulerException
+ {
+ if ( jobName == null )
+ {
+ throw new SchedulerException( "Job name null - cannot unschedule job" );
+ }
+
+ try
+ {
+ if ( jobExists( jobName, groupName ) )
+ {
+ scheduler.deleteJob( new JobKey( jobName, groupName ) );
+ }
+ }
+ catch ( SchedulerException e )
+ {
+ throw new SchedulerException( "Error unscheduling job.", e );
+ }
+ }
+
+ public boolean interruptSchedule( String jobName, String groupName )
+ throws SchedulerException
+ {
+ try
+ {
+ return scheduler.interrupt( new JobKey( jobName, groupName ) );
+ }
+ catch ( Exception e )
+ {
+ throw new SchedulerException( "Can't interrup job \"" + jobName + "\".", e );
+ }
+ }
+
+ private boolean jobExists( String jobName, String jobGroup )
+ throws SchedulerException
+ {
+
+ return ( scheduler.getJobDetail( new JobKey( jobName, jobGroup ) ) != null );
+ }
+
+ public void shutdown( boolean waitForJobsToComplete )
+ {
+ log.info( "call shutdown waitForJobsToComplete : {}", waitForJobsToComplete );
+ scheduler.shutdown( waitForJobsToComplete );
+ }
+
+ public StdScheduler getScheduler()
+ {
+ return scheduler;
+ }
+
+ public void setProperties( Properties properties )
+ {
+ this.properties = properties;
+ }
+
+ public Properties getProperties()
+ {
+ return properties;
+ }
+}
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/DefaultScheduler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/DefaultScheduler.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/Scheduler.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/Scheduler.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/Scheduler.java (added)
+++ archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/Scheduler.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,60 @@
+package org.codehaus.redback.components.scheduler;
+
+/*
+ * 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.
+ */
+
+import org.quartz.JobListener;
+import org.quartz.SchedulerException;
+import org.quartz.Trigger;
+import org.quartz.TriggerListener;
+import org.quartz.impl.JobDetailImpl;
+
+import java.util.Properties;
+
+public interface Scheduler
+{
+
+ void scheduleJob( JobDetailImpl jobDetail, Trigger trigger )
+ throws SchedulerException;
+
+ /**
+ * @param listener
+ */
+ void addGlobalJobListener( JobListener listener )
+ throws SchedulerException;
+
+ /**
+ * @param listener
+ */
+ void addGlobalTriggerListener( TriggerListener listener )
+ throws SchedulerException;
+
+ void unscheduleJob( String jobName, String groupName )
+ throws SchedulerException;
+
+ boolean interruptSchedule( String jobName, String groupName )
+ throws SchedulerException;
+
+ void setProperties( Properties properties );
+
+ Properties getProperties();
+
+ void shutdown( boolean waitForJobsToComplete );
+
+}
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/Scheduler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/Scheduler.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/configuration/SchedulerConfiguration.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/configuration/SchedulerConfiguration.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/configuration/SchedulerConfiguration.java (added)
+++ archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/configuration/SchedulerConfiguration.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,133 @@
+package org.codehaus.redback.components.scheduler.configuration;
+
+/*
+ * 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.
+ */
+
+import org.codehaus.redback.components.scheduler.Scheduler;
+import org.quartz.impl.StdSchedulerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Inject;
+
+/**
+ * Class to represent the configuration file for the proxy
+ *
+ * @author John Tolentino
+ * plexus.component role="org.codehaus.plexus.scheduler.configuration.SchedulerConfiguration"
+ */
+@Service
+public class SchedulerConfiguration
+{
+ /*
+ * plexus.required
+ */
+ @Inject
+ private Scheduler plexusScheduler;
+
+ public String getInstanceName()
+ {
+ return plexusScheduler.getProperties().getProperty( StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME );
+ }
+
+ public void setInstanceName( String instanceName )
+ {
+ plexusScheduler.getProperties().setProperty( StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, instanceName );
+ }
+
+ public String getInstanceId()
+ {
+ return plexusScheduler.getProperties().getProperty( StdSchedulerFactory.PROP_SCHED_INSTANCE_ID );
+ }
+
+ public void setInstanceId( String InstanceId )
+ {
+ plexusScheduler.getProperties().setProperty( StdSchedulerFactory.PROP_SCHED_INSTANCE_ID, InstanceId );
+ }
+
+ public String getThreadName()
+ {
+ return plexusScheduler.getProperties().getProperty( StdSchedulerFactory.PROP_SCHED_THREAD_NAME );
+ }
+
+ public void setThreadName( String threadName )
+ {
+ plexusScheduler.getProperties().setProperty( StdSchedulerFactory.PROP_SCHED_THREAD_NAME, threadName );
+ }
+
+ public String getIdleWaitTime()
+ {
+ return plexusScheduler.getProperties().getProperty( StdSchedulerFactory.PROP_SCHED_IDLE_WAIT_TIME );
+ }
+
+ public void setIdleWaitTime( String idleWaitTime )
+ {
+ plexusScheduler.getProperties().setProperty( StdSchedulerFactory.PROP_SCHED_IDLE_WAIT_TIME, idleWaitTime );
+ }
+
+ public String getDbFailureRetryInterval()
+ {
+ return plexusScheduler.getProperties().getProperty( StdSchedulerFactory.PROP_SCHED_DB_FAILURE_RETRY_INTERVAL );
+ }
+
+ public void setDbFailureRetryInterval( String dbFailureRetryInterval )
+ {
+ plexusScheduler.getProperties().setProperty( StdSchedulerFactory.PROP_SCHED_DB_FAILURE_RETRY_INTERVAL, dbFailureRetryInterval );
+ }
+
+ public String getClassLoadHelper()
+ {
+ return plexusScheduler.getProperties().getProperty( StdSchedulerFactory.PROP_SCHED_CLASS_LOAD_HELPER_CLASS );
+ }
+
+ public void setClassLoadHelper( String classLoadHelper )
+ {
+ plexusScheduler.getProperties().setProperty( StdSchedulerFactory.PROP_SCHED_CLASS_LOAD_HELPER_CLASS, classLoadHelper );
+ }
+
+ public String getContextKey()
+ {
+ return plexusScheduler.getProperties().getProperty( StdSchedulerFactory.PROP_SCHED_CONTEXT_PREFIX );
+ }
+
+ public void setContextKey( String contextKey )
+ {
+ plexusScheduler.getProperties().setProperty( StdSchedulerFactory.PROP_SCHED_CONTEXT_PREFIX, contextKey );
+ }
+
+ public String getUserTransactionURL()
+ {
+ return plexusScheduler.getProperties().getProperty( StdSchedulerFactory.PROP_SCHED_USER_TX_URL );
+ }
+
+ public void setUserTransactionURL( String userTransactionURL )
+ {
+ plexusScheduler.getProperties().setProperty( StdSchedulerFactory.PROP_SCHED_USER_TX_URL, userTransactionURL );
+ }
+
+ public String getWrapJobExecutionInUserTransaction()
+ {
+ return plexusScheduler.getProperties().getProperty( StdSchedulerFactory.PROP_SCHED_WRAP_JOB_IN_USER_TX );
+ }
+
+ public void setWrapJobExecutionInUserTransaction( String wrapJobExecutionInUserTransaction )
+ {
+ plexusScheduler.getProperties().setProperty( StdSchedulerFactory.PROP_SCHED_WRAP_JOB_IN_USER_TX, wrapJobExecutionInUserTransaction );
+ }
+
+}
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/configuration/SchedulerConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/main/java/org/codehaus/redback/components/scheduler/configuration/SchedulerConfiguration.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-quartz/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-quartz/src/main/resources/META-INF/spring-context.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-quartz/src/main/resources/META-INF/spring-context.xml (added)
+++ archiva/redback/redback-components/trunk/spring-quartz/src/main/resources/META-INF/spring-context.xml Fri Apr 6 09:33:40 2012
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ 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.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ default-lazy-init="true">
+
+ <context:annotation-config />
+ <context:component-scan
+ base-package="org.codehaus.redback.components.scheduler"/>
+
+</beans>
\ No newline at end of file
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/main/resources/META-INF/spring-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/main/resources/META-INF/spring-context.xml
------------------------------------------------------------------------------
svn:executable =
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/main/resources/META-INF/spring-context.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/CronExpressionValidatorTest.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/CronExpressionValidatorTest.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/CronExpressionValidatorTest.java (added)
+++ archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/CronExpressionValidatorTest.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,127 @@
+package org.codehaus.redback.components.scheduler;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+import junit.framework.TestCase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml","classpath:/spring-context.xml"} )
+public class CronExpressionValidatorTest
+ extends TestCase
+{
+
+ @Inject
+ CronExpressionValidator validator;
+
+ @Test
+ public void testValidation()
+ throws Exception
+ {
+
+ assertTrue( validator.validate( "0 0 * * * ?" ) );
+
+ assertTrue( validator.validate( "0 0 * ? * *" ) );
+
+ assertFalse( validator.validate( "0 0 4-1 * * ?" ) );
+
+ assertTrue( validator.validate( "0 0 1-4 * * ?" ) );
+
+ assertTrue( validator.validate( "0 0,15,30,45 * * * ?" ) );
+
+ assertFalse( validator.validate( "0 0,45,15,30 * * * ?" ) );
+
+ assertTrue( validator.validate( "0 0 12 * * ?" ) );
+
+ assertTrue( validator.validate( "0 15 10 ? * *" ) );
+
+ assertTrue( validator.validate( "0 15 10 * * ?" ) );
+
+ assertTrue( validator.validate( "0 15 10 * * ? *" ) );
+
+ assertTrue( validator.validate( "0 15 10 * * ? 2005" ) );
+
+ assertFalse( validator.validate( "0 15 10 * * ? 2100" ) );
+
+ assertFalse( validator.validate( "0 15 10 * * ? 1969" ) );
+
+ assertTrue( validator.validate( "0 15 10 * * ? 2005-2007" ) );
+
+ assertFalse( validator.validate( "0 15 10 * * ? 2005-2100" ) );
+
+ assertFalse( validator.validate( "0 15 10 * * ? 1960-2010" ) );
+
+ assertTrue( validator.validate( "0 15 10 * * ? 2005/2" ) );
+
+ assertFalse( validator.validate( "0 15 10 * * ? 2100/3" ) );
+
+ assertFalse( validator.validate( "0 15 10 * * ? 1960/10" ) );
+
+ assertTrue( validator.validate( "0 * 14 * * ?" ) );
+
+ assertTrue( validator.validate( "0 0/5 14 * * ?" ) );
+
+ assertTrue( validator.validate( "0 0/5 14,18 * * ?" ) );
+
+ assertTrue( validator.validate( "0 0-5 14 * * ?" ) );
+
+ assertTrue( validator.validate( "0 10,44 14 ? 3 WED" ) );
+
+ assertTrue( validator.validate( "0 15 10 ? * MON-FRI" ) );
+
+ assertTrue( validator.validate( "0 15 10 15 * ?" ) );
+
+ assertTrue( validator.validate( "0 15 10 L * ?" ) );
+
+ assertFalse( validator.validate( "0 15 10 6#3 * ?" ) );
+
+ assertTrue( validator.validate( "0 15 10 15W * ?" ) );
+
+ assertFalse( validator.validate( "0 15 10 15W1 * ?" ) );
+
+ assertTrue( validator.validate( "0 15 10 ? * 6L" ) );
+
+ assertTrue( validator.validate( "0 15 10 ? * 6L" ) );
+
+ assertTrue( validator.validate( "0 15 10 ? * 6L 2002-2005" ) );
+
+ assertFalse( validator.validate( "0 15 10 ? * 6L3 2002-2005" ) );
+
+ assertTrue( validator.validate( "0 15 10 ? * 6#3" ) );
+
+ assertFalse( validator.validate( "0 15 10 ? * 6#" ) );
+
+ assertFalse( validator.validate( "0 15 10 ? * #3" ) );
+
+ assertFalse( validator.validate( "0 15 10 ? * 8#3" ) );
+
+ assertFalse( validator.validate( "0 15 10 ? * 6#6" ) );
+
+ assertFalse( validator.validate( "0 0" ) );
+
+ assertFalse( validator.validate( "0 0 * * * *" ) );
+
+ assertFalse( validator.validate( "a a a a a a" ) );
+
+ assertFalse( validator.validate( "0 0 0 ? 0 A" ) );
+ }
+}
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/CronExpressionValidatorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/CronExpressionValidatorTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/JobOne.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/JobOne.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/JobOne.java (added)
+++ archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/JobOne.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,79 @@
+package org.codehaus.redback.components.scheduler;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache Turbine", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import java.util.Date;
+
+public class JobOne
+ implements Job
+{
+ public JobOne()
+ {
+ }
+
+ public void execute( JobExecutionContext context )
+ throws JobExecutionException
+ {
+ System.out.println(
+ " --- Testing Scheduler Component\n --- " + context.getJobDetail().getDescription() + " executed.["
+ + new Date() + "]" );
+
+ }
+
+}
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/JobOne.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/JobOne.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/SchedulerTest.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/SchedulerTest.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/SchedulerTest.java (added)
+++ archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/SchedulerTest.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,102 @@
+package org.codehaus.redback.components.scheduler;
+
+import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.quartz.JobDataMap;
+import org.quartz.JobExecutionContext;
+import org.quartz.Trigger;
+import org.quartz.TriggerBuilder;
+import org.quartz.TriggerListener;
+import org.quartz.impl.JobDetailImpl;
+import org.quartz.impl.triggers.SimpleTriggerImpl;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml","classpath:/spring-context.xml"} )
+public class SchedulerTest
+ extends TestCase
+ implements TriggerListener
+{
+ private boolean triggerFired;
+
+ @Inject
+ private Scheduler scheduler;
+
+ @After
+ public void stop()
+ {
+ scheduler.shutdown( true );
+ }
+
+ @Test
+ public void testCreation()
+ throws Exception
+ {
+
+
+ assertNotNull( scheduler );
+
+ JobDataMap dataMap = new JobDataMap();
+
+ dataMap.put( "project", "continuum" );
+
+ JobDetailImpl jobDetail = new JobDetailImpl( "job", "group", JobOne.class );
+
+ jobDetail.setJobDataMap( dataMap );
+
+ TriggerBuilder.newTrigger();
+
+ Trigger trigger = new SimpleTriggerImpl( "trigger", "group" );
+
+ scheduler.addGlobalTriggerListener( this );
+
+ scheduler.scheduleJob( jobDetail, trigger );
+
+ while ( ! triggerFired )
+ {
+ //System.out.println("! triggerFired");
+ Thread.sleep( 10 );
+ }
+ System.out.println("ok triggerFired");
+ }
+
+ public void triggerComplete( Trigger trigger, JobExecutionContext context, int triggerInstructionCode )
+ {
+ }
+
+ public boolean vetoJobExecution( Trigger trigger, JobExecutionContext context )
+ {
+ return false;
+ }
+
+ public void triggerFired( Trigger trigger, JobExecutionContext context )
+ {
+ System.out.println( "Trigger fired!" );
+
+ triggerFired = true;
+ }
+
+ public void triggerMisfired( Trigger trigger )
+ {
+ }
+
+ public void triggerComplete( Trigger trigger, JobExecutionContext context,
+ Trigger.CompletedExecutionInstruction triggerInstructionCode )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public String getName()
+ {
+ return "foo";
+ }
+
+
+
+}
+
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/SchedulerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/test/java/org/codehaus/redback/components/scheduler/SchedulerTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-quartz/src/test/resources/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-quartz/src/test/resources/spring-context.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-quartz/src/test/resources/spring-context.xml (added)
+++ archiva/redback/redback-components/trunk/spring-quartz/src/test/resources/spring-context.xml Fri Apr 6 09:33:40 2012
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ 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.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+ <bean name="scheduler" class="org.codehaus.redback.components.scheduler.DefaultScheduler">
+ <property name="properties">
+ <props>
+ <prop key="org.quartz.scheduler.instanceName">scheduler1</prop>
+ <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop>
+ <prop key="org.quartz.threadPool.threadCount">1</prop>
+ <prop key="org.quartz.threadPool.threadPriority">4</prop>
+ <prop key="org.quartz.jobStore.class">org.quartz.simpl.RAMJobStore</prop>
+ </props>
+ </property>
+ </bean>
+
+</beans>
\ No newline at end of file
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
svn:executable =
Propchange: archiva/redback/redback-components/trunk/spring-quartz/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/pom.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/pom.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/pom.xml (added)
+++ archiva/redback/redback-components/trunk/spring-registry/pom.xml Fri Apr 6 09:33:40 2012
@@ -0,0 +1,126 @@
+<!--
+ ~ Copyright 2007 The Codehaus Foundation.
+ ~
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.codehaus.redback.components</groupId>
+ <artifactId>redback-components</artifactId>
+ <version>1.3-SNAPSHOT</version>
+ <relativePath>../redback-components-parent/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.codehaus.redback.components.registry</groupId>
+ <artifactId>spring-registry</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ <name>Redback Spring Registry Component</name>
+ <packaging>pom</packaging>
+
+ <url>http://redback.codehaus.org/components/${project.artifactId}</url>
+
+ <distributionManagement>
+ <site>
+ <id>codehaus.org</id>
+ <url>dav:https://dav.codehaus.org/redback/components/${project.artifactId}</url>
+ </site>
+ </distributionManagement>
+
+ <scm>
+ <connection>scm:svn:https://svn.codehaus.org/redback/components/trunk/spring-registry</connection>
+ <developerConnection>scm:svn:https://svn.codehaus.org/redback/components/trunk/spring-registry</developerConnection>
+ <url>http://fisheye.codehaus.org/browse/redback/components/trunk/spring-registry</url>
+ </scm>
+
+ <modules>
+ <module>spring-registry-api</module>
+ <module>spring-registry-commons</module>
+ </modules>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.5.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback.components.registry</groupId>
+ <artifactId>spring-registry-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback.components.registry</groupId>
+ <artifactId>spring-registry-test</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <aggregate>true</aggregate>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+</project>
Propchange: archiva/redback/redback-components/trunk/spring-registry/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/pom.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/pom.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/pom.xml (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/pom.xml Fri Apr 6 09:33:40 2012
@@ -0,0 +1,33 @@
+<!--
+ ~ Copyright 2007 The Codehaus Foundation.
+ ~
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.codehaus.redback.components.registry</groupId>
+ <artifactId>spring-registry</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>spring-registry-api</artifactId>
+ <name>Redback Spring Registry Api</name>
+ <packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/Registry.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/Registry.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/Registry.java (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/Registry.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,245 @@
+package org.codehaus.plexus.registry;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * 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.
+ */
+
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * The Plexus registry is a single source of external configuration for Plexus components and applications.
+ * It can be used by components to source configuration, knowing that it can be used from within applications
+ * without the information being hard coded into the component.
+ */
+public interface Registry
+{
+
+ /**
+ * Dump the entire registry to a string, for debugging purposes.
+ *
+ * @return the registry contents
+ */
+ String dump();
+
+ /**
+ * Get a string value from the registry. If not found, <code>null</code> is returned.
+ *
+ * @param key the key in the registry
+ * @return the value
+ */
+ String getString( String key );
+
+ /**
+ * Get a string value from the registry. If not found, the default value is used.
+ *
+ * @param key the key in the registry
+ * @param defaultValue the default value
+ * @return the value
+ */
+ String getString( String key, String defaultValue );
+
+ /**
+ * Set a string value in the registry.
+ *
+ * @param key the key in the registry
+ * @param value the value to set
+ */
+ void setString( String key, String value );
+
+ /**
+ * Get an integer value from the registry. If not found, an exception is thrown.
+ *
+ * @param key the key in the registry
+ * @return the value
+ * @throws java.util.NoSuchElementException
+ * if the key is not found
+ */
+ int getInt( String key );
+
+ /**
+ * Get an integer value from the registry. If not found, the default value is used.
+ *
+ * @param key the key in the registry
+ * @param defaultValue the default value
+ * @return the value
+ */
+ int getInt( String key, int defaultValue );
+
+ /**
+ * Set an integer value in the registry.
+ *
+ * @param key the key in the registry
+ * @param value the value to set
+ */
+ void setInt( String key, int value );
+
+ /**
+ * Get a boolean value from the registry. If not found, an exception is thrown.
+ *
+ * @param key the key in the registry
+ * @return the value
+ * @throws java.util.NoSuchElementException
+ * if the key is not found
+ */
+ boolean getBoolean( String key );
+
+ /**
+ * Get a boolean value from the registry. If not found, the default value is used.
+ *
+ * @param key the key in the registry
+ * @param defaultValue the default value
+ * @return the value
+ */
+ boolean getBoolean( String key, boolean defaultValue );
+
+ /**
+ * Set a boolean value in the registry.
+ *
+ * @param key the key in the registry
+ * @param value the value to set
+ */
+ void setBoolean( String key, boolean value );
+
+ /**
+ * Load configuration from the given classloader resource.
+ *
+ * @param resource the location to load the configuration from
+ * @throws RegistryException if a problem occurred reading the resource to add to the registry
+ */
+ void addConfigurationFromResource( String resource )
+ throws RegistryException;
+
+ /**
+ * Load configuration from the given classloader resource.
+ *
+ * @param resource the location to load the configuration from
+ * @param prefix the location to add the configuration at in the registry
+ * @throws RegistryException if a problem occurred reading the resource to add to the registry
+ */
+ void addConfigurationFromResource( String resource, String prefix )
+ throws RegistryException;
+
+ /**
+ * Load configuration from the given file.
+ *
+ * @param file the location to load the configuration from
+ * @throws RegistryException if a problem occurred reading the resource to add to the registry
+ */
+ void addConfigurationFromFile( File file )
+ throws RegistryException;
+
+ /**
+ * Load configuration from the given file.
+ *
+ * @param file the location to load the configuration from
+ * @param prefix the location to add the configuration at in the registry
+ * @throws RegistryException if a problem occurred reading the resource to add to the registry
+ */
+ void addConfigurationFromFile( File file, String prefix )
+ throws RegistryException;
+
+ /**
+ * Determine if the registry contains any elements.
+ *
+ * @return whether the registry contains any elements
+ */
+ boolean isEmpty();
+
+ /**
+ * Get a list of strings at the given key in the registry.
+ *
+ * @param key the key to lookup
+ * @return the list of strings
+ */
+ List getList( String key );
+
+ /**
+ * TODO move to Map which is more generic ?
+ * Get the properties at the given key in the registry.
+ *
+ * @param key the key to lookup
+ * @return the properties
+ */
+ Properties getProperties( String key );
+
+ /**
+ * Get a subset of the registry, for all keys descended from the given key.
+ *
+ * @param key the key to take the subset from
+ * @return the registry subset
+ */
+ Registry getSubset( String key );
+
+ /**
+ * Get a list of subsets of the registry, for all keys descended from the given key.
+ *
+ * @param key the key to take the subsets from
+ * @return the registry subsets
+ */
+ List getSubsetList( String key );
+
+ /**
+ * Get a subsection of the registry, identified by the given name. If it doesn't exist, <code>null</code> will be
+ * returned.
+ *
+ * @param name registry section name
+ * @return the registry
+ */
+ Registry getSection( String name );
+
+ /**
+ * Save any changes to the registry since it was loaded.
+ *
+ * @throws RegistryException if there was a problem saving the registry
+ * @throws UnsupportedOperationException if the registry is not writable
+ */
+ void save()
+ throws RegistryException, UnsupportedOperationException;
+
+ /**
+ * Add a change listener. Note that settings this on the base registry will only detect 'invalidation' events, not
+ * individual changes. You should retrieve the named sub-registry to listen for changes.
+ *
+ * @param listener the listener
+ * @todo this isn't ideal, so maybe fix combined configuration to re-fire it's events to it's own listeners in the c-c implementation
+ */
+ void addChangeListener( RegistryListener listener );
+
+ /**
+ * Get all the keys in this registry. Keys are only retrieved at a depth of 1.
+ *
+ * @return the set of keys
+ */
+ Collection getKeys();
+
+ /**
+ * Remove a keyed element from the registry.
+ *
+ * @param key the key to remove
+ */
+ void remove( String key );
+
+ /**
+ * Remove a keyed subset of the registry.
+ *
+ * @param key the subset to remove
+ */
+ void removeSubset( String key );
+
+ void initialize() throws RegistryException;
+}
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/Registry.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/Registry.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision