You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2010/10/11 08:54:14 UTC
svn commit: r1021247 [1/6] - in /sling/branches/eventing-3.0: ./ .settings/
src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/sling/ src/main/java/org/apache/sling/event/
src/main/java/org/apache/sling/...
Author: cziegeler
Date: Mon Oct 11 06:54:12 2010
New Revision: 1021247
URL: http://svn.apache.org/viewvc?rev=1021247&view=rev
Log:
Initial import of the 3.0 version
Added:
sling/branches/eventing-3.0/.classpath (with props)
sling/branches/eventing-3.0/.project (with props)
sling/branches/eventing-3.0/.settings/
sling/branches/eventing-3.0/.settings/org.eclipse.jdt.core.prefs (with props)
sling/branches/eventing-3.0/pom.xml (with props)
sling/branches/eventing-3.0/src/
sling/branches/eventing-3.0/src/main/
sling/branches/eventing-3.0/src/main/java/
sling/branches/eventing-3.0/src/main/java/org/
sling/branches/eventing-3.0/src/main/java/org/apache/
sling/branches/eventing-3.0/src/main/java/org/apache/sling/
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventPropertiesMap.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventUtil.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobProcessor.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobStatusProvider.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobsIterator.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/TimedEventStatusProvider.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/DistributingEventHandler.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/EnvironmentComponent.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/JobEvent.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/JobStatusNotifier.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/JobsIteratorImpl.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/StatisticsImpl.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/Utility.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/config/
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/config/ConfigurationConstants.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/config/InternalQueueConfiguration.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/config/QueueConfigurationManager.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/console/
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/jcr/
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/jcr/JCRHelper.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/jcr/JCRJobEvent.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/jcr/JobStatusProviderImpl.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/jcr/JobsIteratorImpl.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/jcr/PersistenceHandler.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/queues/
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractJobQueue.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractParallelJobQueue.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/queues/ParallelJobQueue.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/jobs/queues/TopicRoundRobinJobQueue.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/support/
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/support/Environment.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/jobs/
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/jobs/JobManager.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/jobs/JobProcessor.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/jobs/JobUtil.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/jobs/JobsIterator.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/jobs/Queue.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/jobs/QueueConfiguration.java (with props)
sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/jobs/Statistics.java (with props)
sling/branches/eventing-3.0/src/main/resources/
sling/branches/eventing-3.0/src/main/resources/META-INF/
sling/branches/eventing-3.0/src/main/resources/OSGI-INF/
sling/branches/eventing-3.0/src/main/resources/OSGI-INF/metatype/
sling/branches/eventing-3.0/src/main/resources/OSGI-INF/metatype/metatype.properties (with props)
sling/branches/eventing-3.0/src/main/resources/SLING-INF/
sling/branches/eventing-3.0/src/main/resources/SLING-INF/nodetypes/
sling/branches/eventing-3.0/src/main/resources/SLING-INF/nodetypes/event.cnd (with props)
sling/branches/eventing-3.0/src/test/
sling/branches/eventing-3.0/src/test/java/
sling/branches/eventing-3.0/src/test/java/org/
sling/branches/eventing-3.0/src/test/java/org/apache/
sling/branches/eventing-3.0/src/test/java/org/apache/sling/
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/EventUtilTest.java (with props)
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/impl/
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/impl/AbstractRepositoryEventHandlerTest.java (with props)
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/impl/AbstractTest.java (with props)
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/impl/Barrier.java (with props)
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/impl/DistributingEventHandlerTest.java (with props)
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/impl/RepositoryTestUtil.java (with props)
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/impl/SimpleEventAdmin.java (with props)
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/impl/SimpleScheduler.java (with props)
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/impl/jobs/
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/impl/jobs/AbstractJobEventHandlerTest.java (with props)
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/impl/jobs/JobEventHandlerTest.java (with props)
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/impl/jobs/StatisticsImplTest.java (with props)
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/impl/jobs/config/
sling/branches/eventing-3.0/src/test/java/org/apache/sling/event/impl/jobs/config/InternalQueueConfigurationTest.java (with props)
Modified:
sling/branches/eventing-3.0/ (props changed)
Propchange: sling/branches/eventing-3.0/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Oct 11 06:54:12 2010
@@ -0,0 +1,2 @@
+
+
Added: sling/branches/eventing-3.0/.classpath
URL: http://svn.apache.org/viewvc/sling/branches/eventing-3.0/.classpath?rev=1021247&view=auto
==============================================================================
--- sling/branches/eventing-3.0/.classpath (added)
+++ sling/branches/eventing-3.0/.classpath Mon Oct 11 06:54:12 2010
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.5.2/slf4j-api-1.5.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/jcr/jcr/2.0/jcr-2.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/sling/org.apache.sling.commons.classloader/1.1.4/org.apache.sling.commons.classloader-1.1.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/sling/org.apache.sling.jcr.api/2.0.6/org.apache.sling.jcr.api-2.0.6.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/sling/org.apache.sling.settings/1.0.0/org.apache.sling.settings-1.0.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/osgi/org.osgi.compendium/4.2.0/org.osgi.compendium-4.2.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/osgi/org.osgi.core/4.2.0/org.osgi.core-4.2.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/4.8.1/junit-4.8.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/sling/org.apache.sling.commons.osgi/2.0.6/org.apache.sling.commons.osgi-2.0.6.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/felix/org.apache.felix.scr.annotations/1.3.1-R965433/org.apache.felix.scr.annotations-1.3.1-R965433.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-jcr-commons/2.0.0/jackrabbit-jcr-commons-2.0.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/sling/org.apache.sling.commons.threads/3.0.3-SNAPSHOT/org.apache.sling.commons.threads-3.0.3-SNAPSHOT.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/sling/org.apache.sling.commons.scheduler/2.2.0/org.apache.sling.commons.scheduler-2.2.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/sling/org.apache.sling.api/2.0.8/org.apache.sling.api-2.0.8.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/sling/org.apache.sling.jcr.resource/2.0.6/org.apache.sling.jcr.resource-2.0.6.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jmock/jmock-junit4/2.5.1/jmock-junit4-2.5.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit-addons/junit-addons/1.4/junit-addons-1.4.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Propchange: sling/branches/eventing-3.0/.classpath
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/branches/eventing-3.0/.classpath
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/branches/eventing-3.0/.project
URL: http://svn.apache.org/viewvc/sling/branches/eventing-3.0/.project?rev=1021247&view=auto
==============================================================================
--- sling/branches/eventing-3.0/.project (added)
+++ sling/branches/eventing-3.0/.project Mon Oct 11 06:54:12 2010
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>sling-eventing-3.0</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Propchange: sling/branches/eventing-3.0/.project
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/branches/eventing-3.0/.project
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/branches/eventing-3.0/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/sling/branches/eventing-3.0/.settings/org.eclipse.jdt.core.prefs?rev=1021247&view=auto
==============================================================================
--- sling/branches/eventing-3.0/.settings/org.eclipse.jdt.core.prefs (added)
+++ sling/branches/eventing-3.0/.settings/org.eclipse.jdt.core.prefs Mon Oct 11 06:54:12 2010
@@ -0,0 +1,77 @@
+#Fri Oct 08 18:48:55 CEST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.5
Propchange: sling/branches/eventing-3.0/.settings/org.eclipse.jdt.core.prefs
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/branches/eventing-3.0/pom.xml
URL: http://svn.apache.org/viewvc/sling/branches/eventing-3.0/pom.xml?rev=1021247&view=auto
==============================================================================
--- sling/branches/eventing-3.0/pom.xml (added)
+++ sling/branches/eventing-3.0/pom.xml Mon Oct 11 06:54:12 2010
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ 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.
+-->
+<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">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>9</version>
+ <relativePath>../../../parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>org.apache.sling.event</artifactId>
+ <packaging>bundle</packaging>
+ <version>3.0.0-SNAPSHOT</version>
+
+ <name>Apache Sling Event Support</name>
+ <description>
+ Support for eventing.
+ </description>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/event</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/event</developerConnection>
+ <url>http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event</url>
+ </scm>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ <version>1.4.5-SNAPSHOT</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.apache.sling.event;version=2.4.0,
+ org.apache.sling.event.jobs;version=1.0.0
+ </Export-Package>
+ <Private-Package>
+ org.apache.sling.event.impl.*
+ </Private-Package>
+ <Sling-Nodetypes>
+ SLING-INF/nodetypes/event.cnd
+ </Sling-Nodetypes>
+ <Sling-Namespaces>
+ slingevent=http://sling.apache.org/jcr/event/1.0
+ </Sling-Namespaces>
+ <Embed-Dependency>
+ jackrabbit-jcr-commons;inline="org/apache/jackrabbit/util/ISO9075.*|org/apache/jackrabbit/util/ISO8601.*|org/apache/jackrabbit/util/XMLChar.*",
+ org.apache.sling.commons.osgi;inline="org/apache/sling/commons/osgi/OsgiUtil.*"
+ </Embed-Dependency>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <excludePackageNames>
+ org.apache.sling.event.impl,org.apache.sling.event.impl.job,org.apache.sling.event.impl.jobs,org.apache.sling.event.impl.jobs.console,org.apache.sling.event.impl.jobs.queue
+ </excludePackageNames>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+ <dependencies>
+ <!-- We have to put this test dependency first, to make sure this version is
+ used for testing! -->
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ <version>1.3.1-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ <version>2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.settings</artifactId>
+ <version>1.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.api</artifactId>
+ <version>2.0.6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.osgi</artifactId>
+ <version>2.0.6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.scheduler</artifactId>
+ <version>2.1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.threads</artifactId>
+ <version>3.0.3-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.classloader</artifactId>
+ <version>1.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-jcr-commons</artifactId>
+ <version>2.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <!-- Webconsole -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <!-- Testing -->
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.resource</artifactId>
+ <version>2.0.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit-addons</groupId>
+ <artifactId>junit-addons</artifactId>
+ <version>1.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jmock</groupId>
+ <artifactId>jmock-junit4</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-core</artifactId>
+ <version>2.0.0</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Propchange: sling/branches/eventing-3.0/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/branches/eventing-3.0/pom.xml
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: sling/branches/eventing-3.0/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventPropertiesMap.java
URL: http://svn.apache.org/viewvc/sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventPropertiesMap.java?rev=1021247&view=auto
==============================================================================
--- sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventPropertiesMap.java (added)
+++ sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventPropertiesMap.java Mon Oct 11 06:54:12 2010
@@ -0,0 +1,196 @@
+/*
+ * 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.sling.event;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.osgi.service.event.Event;
+
+/**
+ * An implementation of a map that helps in dealing with properties
+ * of an OSGi event.
+ * This map implements both, the map and the dictionary interfaces.
+ */
+public class EventPropertiesMap
+ extends Dictionary<String, Object>
+ implements Map<String, Object>, Serializable {
+
+ private static final long serialVersionUID = 835179638502569708L;
+
+ /** The delegatee map. */
+ private final Map<String, Object> delegatee;
+
+ /**
+ * Construct a new map out of an event object.
+ * The resulting map is modifiable. But any modification has
+ * no influence on the original properties of the event!
+ * @param event The event object.
+ */
+ public EventPropertiesMap(final Event event) {
+ // create a map out of the event properties
+ final Map<String, Object> props = new HashMap<String, Object>();
+ if ( event.getPropertyNames() != null ) {
+ for(final String key : event.getPropertyNames() ) {
+ props.put(key, event.getProperty(key));
+ }
+ }
+ this.delegatee = props;
+ }
+
+ /**
+ * Construct a new map out of another map.
+ * @param props The properties map object.
+ */
+ public EventPropertiesMap(final Map<String, Object> props) {
+ this.delegatee = props;
+ }
+
+ /**
+ * Construct a new map.
+ */
+ public EventPropertiesMap() {
+ this.delegatee = new HashMap<String, Object>();
+ }
+
+ /**
+ * @see java.util.Map#clear()
+ */
+ public void clear() {
+ delegatee.clear();
+ }
+
+ /**
+ * @see java.util.Map#containsKey(java.lang.Object)
+ */
+ public boolean containsKey(Object key) {
+ return delegatee.containsKey(key);
+ }
+
+ /**
+ * @see java.util.Map#containsValue(java.lang.Object)
+ */
+ public boolean containsValue(Object value) {
+ return delegatee.containsValue(value);
+ }
+
+ /**
+ * @see java.util.Map#entrySet()
+ */
+ public Set<java.util.Map.Entry<String, Object>> entrySet() {
+ return delegatee.entrySet();
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object o) {
+ return delegatee.equals(o);
+ }
+
+ /**
+ * @see java.util.Dictionary#get(java.lang.Object)
+ */
+ public Object get(Object key) {
+ return delegatee.get(key);
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return delegatee.hashCode();
+ }
+
+ /**
+ * @see java.util.Dictionary#isEmpty()
+ */
+ public boolean isEmpty() {
+ return delegatee.isEmpty();
+ }
+
+ /**
+ * @see java.util.Map#keySet()
+ */
+ public Set<String> keySet() {
+ return delegatee.keySet();
+ }
+
+ /**
+ * @see java.util.Dictionary#put(java.lang.Object, java.lang.Object)
+ */
+ public Object put(String key, Object value) {
+ return delegatee.put(key, value);
+ }
+
+ /**
+ * @see java.util.Map#putAll(java.util.Map)
+ */
+ public void putAll(Map<? extends String, ? extends Object> t) {
+ delegatee.putAll(t);
+ }
+
+ /**
+ * @see java.util.Dictionary#remove(java.lang.Object)
+ */
+ public Object remove(Object key) {
+ return delegatee.remove(key);
+ }
+
+ /**
+ * @see java.util.Dictionary#size()
+ */
+ public int size() {
+ return delegatee.size();
+ }
+
+ /**
+ * @see java.util.Map#values()
+ */
+ public Collection<Object> values() {
+ return delegatee.values();
+ }
+
+ /**
+ * @see java.util.Dictionary#elements()
+ */
+ public Enumeration<Object> elements() {
+ return Collections.enumeration(this.values());
+ }
+
+ /**
+ * @see java.util.Dictionary#keys()
+ */
+ public Enumeration<String> keys() {
+ return Collections.enumeration(this.keySet());
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return this.delegatee.toString();
+ }
+}
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventPropertiesMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventPropertiesMap.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventPropertiesMap.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventUtil.java
URL: http://svn.apache.org/viewvc/sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventUtil.java?rev=1021247&view=auto
==============================================================================
--- sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventUtil.java (added)
+++ sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventUtil.java Mon Oct 11 06:54:12 2010
@@ -0,0 +1,374 @@
+/*
+ * 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.sling.event;
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.apache.sling.event.impl.support.Environment;
+import org.apache.sling.event.jobs.JobUtil;
+import org.osgi.service.event.Event;
+
+/**
+ * The <code>EventUtil</code> class is an utility class for
+ * clustered environments.
+ */
+public abstract class EventUtil {
+
+ /** This event property indicates, if the event should be distributed in the cluster (default false). */
+ public static final String PROPERTY_DISTRIBUTE = "event.distribute";
+
+ /** This event property specifies the application node. */
+ public static final String PROPERTY_APPLICATION = "event.application";
+
+ /**
+ * Job Handling
+ */
+
+ /** The job topic property.
+ * @deprecated Use {@link JobUtil#PROPERTY_JOB_TOPIC}
+ */
+ @Deprecated
+ public static final String PROPERTY_JOB_TOPIC = "event.job.topic";
+
+ /** The property for the unique event id. Value is of type String (This is optional).
+ * @deprecated Use {@link JobUtil#PROPERTY_JOB_NAME}
+ * */
+ @Deprecated
+ public static final String PROPERTY_JOB_ID = "event.job.id";
+
+ /** The property to set if a job can be run parallel to any other job.
+ * The following values are supported:
+ * - boolean value <code>true</code> and <code>false</code>
+ * - string value <code>true</code> and <code>false</code>
+ * - integer value higher than 1 - if this is specified jobs are run in
+ * parallel but never more than the specified number.
+ *
+ * We might want to use different values in the future for enhanced
+ * parallel job handling.
+ *
+ * This value is only used, if {@link JobUtil#PROPERTY_JOB_QUEUE_NAME} is
+ * specified and the referenced queue is not started yet.
+ * @deprecated Use {@link JobUtil#PROPERTY_JOB_PARALLEL}
+ */
+ @Deprecated
+ public static final String PROPERTY_JOB_PARALLEL = "event.job.parallel";
+
+ /**
+ * The property to set if a job should only be run on the same app it has been created.
+ * @deprecated Use {@link JobUtil#PROPERTY_JOB_RUN_LOCAL}
+ */
+ @Deprecated
+ public static final String PROPERTY_JOB_RUN_LOCAL = "event.job.run.local";
+
+ /**
+ * The property to track the retry count for jobs. Value is of type Integer.
+ * @deprecated Use {@link JobUtil#PROPERTY_JOB_RETRY_COUNT}
+ */
+ @Deprecated
+ public static final String PROPERTY_JOB_RETRY_COUNT = "event.job.retrycount";
+
+ /**
+ * The property for setting the maximum number of retries. Value is of type Integer.
+ * @deprecated Use {@link JobUtil#PROPERTY_JOB_RETRIES}
+ */
+ @Deprecated
+ public static final String PROPERTY_JOB_RETRIES = "event.job.retries";
+
+ /**
+ * The property to set a retry delay. Value is of type Long and specifies milliseconds.
+ * @deprecated Use {@link JobUtil#PROPERTY_JOB_RETRY_DELAY}
+ */
+ @Deprecated
+ public static final String PROPERTY_JOB_RETRY_DELAY = "event.job.retrydelay";
+
+ /** The property to set to put the jobs into a separate job queue. This property
+ * specifies the name of the job queue. If the job queue does not exists yet
+ * a new queue is created.
+ * If a ordered job queue is used, the jobs are never executed in parallel
+ * from this queue! For non ordered queues the {@link JobUtil#PROPERTY_JOB_PARALLEL}
+ * with an integer value higher than 1 can be used to specify the maximum number
+ * of parallel jobs for this queue.
+ * @deprecated Use {@link JobUtil#PROPERTY_JOB_QUEUE_NAME}
+ */
+ @Deprecated
+ public static final String PROPERTY_JOB_QUEUE_NAME = "event.job.queuename";
+
+ /**
+ * If this property is set with any value, the queue processes the jobs in the same
+ * order as they have arrived.
+ * This property has only an effect if {@link #PROPERTY_JOB_QUEUE_NAME} is specified
+ * and the job queue has not been started yet.
+ * @deprecated Use {@link JobUtil#PROPERTY_JOB_QUEUE_ORDERED}
+ */
+ @Deprecated
+ public static final String PROPERTY_JOB_QUEUE_ORDERED = "event.job.queueordered";
+
+ /**
+ * This property allows to override the priority for the thread used to start this job.
+ * The property is evaluated by the {@link JobUtil#processJob(Event, org.apache.sling.event.jobs.JobProcessor)} method.
+ * If another way of executing the job is used, it is up to the client to ensure
+ * the job priority.
+ * For possible values see {@link JobPriority}.
+ * @since 2.4
+ * @deprecated Use {@link JobUtil#PROPERTY_JOB_PRIORITY}
+ */
+ @Deprecated
+ public static final String PROPERTY_JOB_PRIORITY = "event.job.priority";
+
+ /**
+ * The priority for jobs.
+ * @since 2.4
+ * @deprecated Use {@link JobUtil.JobPriority}
+ */
+ public enum JobPriority {
+ NORM,
+ MIN,
+ MAX
+ }
+
+ /**
+ * The topic for jobs.
+ * @deprecated Use {@link JobUtil#TOPIC_JOB}
+ */
+ @Deprecated
+ public static final String TOPIC_JOB = "org/apache/sling/event/job";
+
+ /**
+ * Timed Events
+ */
+
+ /** The topic for timed events. */
+ public static final String TOPIC_TIMED_EVENT = "org/apache/sling/event/timed";
+
+ /** The real topic of the event. */
+ public static final String PROPERTY_TIMED_EVENT_TOPIC = "event.topic.timed";
+
+ /** The property for the unique event id. */
+ public static final String PROPERTY_TIMED_EVENT_ID = "event.timed.id";
+
+ /** The scheduler expression for the timed event. */
+ public static final String PROPERTY_TIMED_EVENT_SCHEDULE = "event.timed.scheduler";
+
+ /** The period for the timed event. */
+ public static final String PROPERTY_TIMED_EVENT_PERIOD = "event.timed.period";
+
+ /** The date for the timed event. */
+ public static final String PROPERTY_TIMED_EVENT_DATE = "event.timed.date";
+
+ /**
+ * Notification events for jobs.
+ */
+
+ /** Asynchronous notification event when a job is started.
+ * The property {@link #PROPERTY_NOTIFICATION_JOB} contains the job event and the
+ * property {@link org.osgi.service.event.EventConstants#TIMESTAMP} contains the
+ * timestamp of the event (as a Long).
+ * @since 2.2
+ * @deprecated Use {@link JobUtil#TOPIC_JOB_STARTED}
+ */
+ @Deprecated
+ public static final String TOPIC_JOB_STARTED = "org/apache/sling/event/notification/job/START";
+
+ /** Asynchronous notification event when a job is finished.
+ * The property {@link #PROPERTY_NOTIFICATION_JOB} contains the job event and the
+ * property {@link org.osgi.service.event.EventConstants#TIMESTAMP} contains the
+ * timestamp of the event (as a Long).
+ * @since 2.2
+ * @deprecated Use {@link JobUtil#TOPIC_JOB_FINISHED}
+ */
+ @Deprecated
+ public static final String TOPIC_JOB_FINISHED = "org/apache/sling/event/notification/job/FINISHED";
+
+ /** Asynchronous notification event when a job failed.
+ * If a job execution fails, it is rescheduled for another try.
+ * The property {@link #PROPERTY_NOTIFICATION_JOB} contains the job event and the
+ * property {@link org.osgi.service.event.EventConstants#TIMESTAMP} contains the
+ * timestamp of the event (as a Long).
+ * @since 2.2
+ * @deprecated Use {@link JobUtil#TOPIC_JOB_FAILED}
+ */
+ @Deprecated
+ public static final String TOPIC_JOB_FAILED = "org/apache/sling/event/notification/job/FAILED";
+
+ /** Asynchronous notification event when a job is cancelled.
+ * If a job execution is cancelled it is not rescheduled.
+ * The property {@link #PROPERTY_NOTIFICATION_JOB} contains the job event and the
+ * property {@link org.osgi.service.event.EventConstants#TIMESTAMP} contains the
+ * timestamp of the event (as a Long).
+ * @since 2.2
+ * @deprecated Use {@link JobUtil#TOPIC_JOB_CANCELLED}
+ */
+ @Deprecated
+ public static final String TOPIC_JOB_CANCELLED = "org/apache/sling/event/notification/job/CANCELLED";
+
+ /** Property containing the job event.
+ * @since 2.2
+ * @deprecated Use {@link JobUtil#PROPERTY_NOTIFICATION_JOB}
+ */
+ @Deprecated
+ public static final String PROPERTY_NOTIFICATION_JOB = "event.notification.job";
+
+ /**
+ * Utility Methods
+ */
+
+ /**
+ * Create a distributable event.
+ * A distributable event is distributed across the cluster.
+ * @param topic
+ * @param properties
+ * @return An OSGi event.
+ */
+ public static Event createDistributableEvent(final String topic,
+ final Dictionary<String, Object> properties) {
+ final Dictionary<String, Object> newProperties;
+ // create a new dictionary
+ newProperties = new Hashtable<String, Object>();
+ if ( properties != null ) {
+ final Enumeration<String> e = properties.keys();
+ while ( e.hasMoreElements() ) {
+ final String key = e.nextElement();
+ newProperties.put(key, properties.get(key));
+ }
+ }
+ // for now the value has no meaning, so we just put an empty string in it.
+ newProperties.put(PROPERTY_DISTRIBUTE, "");
+ return new Event(topic, newProperties);
+ }
+
+ /**
+ * Should this event be distributed in the cluster?
+ * @param event
+ * @return <code>true</code> if the event should be distributed.
+ */
+ public static boolean shouldDistribute(final Event event) {
+ return event.getProperty(PROPERTY_DISTRIBUTE) != null;
+ }
+
+ /**
+ * Is this a local event?
+ * @param event
+ * @return <code>true</code> if this is a local event
+ */
+ public static boolean isLocal(final Event event) {
+ final String appId = getApplicationId(event);
+ return appId == null || appId.equals(Environment.APPLICATION_ID);
+ }
+
+ /**
+ * Return the application id the event was created at.
+ * @param event
+ * @return The application id or null if the event has been created locally.
+ */
+ public static String getApplicationId(final Event event) {
+ return (String)event.getProperty(PROPERTY_APPLICATION);
+ }
+
+ /**
+ * Improved toString method for an Event.
+ * This method prints out the event topic and all of the properties.
+ */
+ public static String toString(final Event e) {
+ if ( e == null ) {
+ return "<null>";
+ }
+ final StringBuilder buffer = new StringBuilder(e.getClass().getName());
+ buffer.append('(');
+ buffer.append(e.hashCode());
+ buffer.append(") [topic=");
+ buffer.append(e.getTopic());
+ buffer.append(", properties=");
+ final String[] names = e.getPropertyNames();
+ if ( names != null ) {
+ for(int i=0;i<names.length;i++) {
+ if ( i>0) {
+ buffer.append(",");
+ }
+ buffer.append(names[i]);
+ buffer.append('=');
+ buffer.append(e.getProperty(names[i]));
+ }
+ }
+ buffer.append("]");
+ return buffer.toString();
+ }
+
+ /**
+ * Is this a job event?
+ * This method checks if the event contains the {@link #PROPERTY_JOB_TOPIC}
+ * property.
+ * @param event The event to check.
+ * @return <code>true></code> if this is a job event.
+ * @deprecated Use {@link JobUtil#isJobEvent(Event)}
+ */
+ @Deprecated
+ public static boolean isJobEvent(final Event event) {
+ return JobUtil.isJobEvent(event);
+ }
+
+ /**
+ * Send an acknowledge.
+ * This signals the job handler that someone is starting to process the job. This method
+ * should be invoked as a first command during job processing.
+ * If this method returns <code>false</code> this means someone else is already
+ * processing this job, and the caller should not process the event anymore.
+ * @return Returns <code>true</code> if the acknowledge could be sent
+ * @throws IllegalArgumentException If the event is a job event but does not have a notifier context.
+ * @since 2.3
+ * @deprecated Use {@link JobUtil#acknowledgeJob(Event)}
+ */
+ @Deprecated
+ public static boolean acknowledgeJob(final Event job) {
+ return JobUtil.acknowledgeJob(job);
+ }
+
+ /**
+ * Notify a finished job.
+ * @throws IllegalArgumentException If the event is a job event but does not have a notifier context.
+ * @deprecated Use {link {@link JobUtil#finishedJob(Event)}
+ */
+ @Deprecated
+ public static void finishedJob(final Event job) {
+ JobUtil.finishedJob(job);
+ }
+
+ /**
+ * Notify a failed job.
+ * @return <code>true</code> if the job has been rescheduled, <code>false</code> otherwise.
+ * @throws IllegalArgumentException If the event is a job event but does not have a notifier context.
+ * @deprecated Use {@link JobUtil#rescheduleJob(Event)}
+ */
+ @Deprecated
+ public static boolean rescheduleJob(final Event job) {
+ return JobUtil.rescheduleJob(job);
+ }
+
+ /**
+ * Process a job in the background and notify its success.
+ * This method also sends an acknowledge message to the job event handler.
+ * @throws IllegalArgumentException If the event is a job event but does not have a notifier context.
+ * @deprecated Use {@link JobUtil#processJob(Event, org.apache.sling.event.jobs.JobProcessor)}
+ */
+ @Deprecated
+ public static void processJob(final Event job, final JobProcessor processor) {
+ JobUtil.processJob(job, processor);
+ }
+}
\ No newline at end of file
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventUtil.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/EventUtil.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobProcessor.java
URL: http://svn.apache.org/viewvc/sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobProcessor.java?rev=1021247&view=auto
==============================================================================
--- sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobProcessor.java (added)
+++ sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobProcessor.java Mon Oct 11 06:54:12 2010
@@ -0,0 +1,32 @@
+/*
+ * 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.sling.event;
+
+import org.osgi.service.event.Event;
+
+/**
+ * A job processor processes a job in the background.
+ * It is used by {@link EventUtil#processJob(Event, JobProcessor)}.
+ * @deprecated Use org.apache.sling.event.jobs.JobProcessor
+ */
+@Deprecated
+public interface JobProcessor extends org.apache.sling.event.jobs.JobProcessor {
+
+ // just for compatibility
+}
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobProcessor.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobProcessor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobStatusProvider.java
URL: http://svn.apache.org/viewvc/sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobStatusProvider.java?rev=1021247&view=auto
==============================================================================
--- sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobStatusProvider.java (added)
+++ sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobStatusProvider.java Mon Oct 11 06:54:12 2010
@@ -0,0 +1,205 @@
+/*
+ * 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.sling.event;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.osgi.service.event.Event;
+
+/**
+ * This service provides the current job processing status.
+ * @deprecated
+ */
+@Deprecated
+public interface JobStatusProvider {
+
+ /**
+ * Cancel this job.
+ * Cancelling a job might fail if the job is currently in processing.
+ * @param jobId The unique identifer as found in the property {@link #PROPERTY_EVENT_ID}.
+ * @return <code>true</code> if the job could be cancelled or does not exist anymore.
+ * <code>false</code> otherwise.
+ * @since 2.4.0
+ */
+ boolean removeJob(String jobId);
+
+ /**
+ * Cancel this job.
+ * Cancelling a job might fail if the job is currently in processing.
+ * This method can be used if the topic and the provided job id is known.
+ * @param topic The job topic as put into the property {@link org.apache.sling.event.jobs.JobUtil#PROPERTY_JOB_TOPIC}.
+ * @param jobId The unique identifer as put into the property {@link org.apache.sling.event.jobs.JobUtil#PROPERTY_JOB_NAME}.
+ * @return <code>true</code> if the job could be cancelled or does not exist anymore.
+ * <code>false</code> otherwise.
+ * @since 2.4.0
+ */
+ boolean removeJob(String topic, String jobId);
+
+ /**
+ * Cancel this job.
+ * This method acts like {@link #removeJob(String)} with the exception that it waits
+ * for a job to finish. The job will be removed when this method returns - however
+ * this method blocks until the job is finished!
+ * @param jobId The unique identifer as found in the property {@link #PROPERTY_EVENT_ID}.
+ * @since 2.4.0
+ */
+ void forceRemoveJob(String jobId);
+
+ /**
+ * Cancel this job.
+ * This method acts like {@link #removeJob(String, String)} with the exception that it waits
+ * for a job to finish. The job will be removed when this method returns - however
+ * this method blocks until the job is finished!
+ * This method can be used if the topic and the provided job id is known.
+ * @param topic The job topic as put into the property {@link org.apache.sling.event.jobs.JobUtil#PROPERTY_JOB_TOPIC}.
+ * @param jobId The unique identifer as put into the property {@link org.apache.sling.event.jobs.JobUtil#PROPERTY_JOB_NAME}.
+ * @since 2.4.0
+ */
+ void forceRemoveJob(String topic, String jobId);
+
+ /**
+ * Wake up the named job queue.
+ * If a job failed, the job queue waits (sleeps) for a configured time. By calling this
+ * method, the job queue can be woken up and force an immediate reprocessing.
+ * @param jobQueueName The name of the queue.
+ */
+ void wakeUpJobQueue(final String jobQueueName);
+
+ /**
+ * Return a list of currently scheduled jobs.
+ * @param topic Topic can be used as a filter, if it is non-null, only jobs with this topic will be returned.
+ * @param filterProps A list of filter property maps. Each map acts like a template. The searched job
+ * must match the template (AND query). By providing several maps, different filters
+ * are possible (OR query).
+ * @return A non null collection.
+ * @since 2.4
+ */
+ JobsIterator queryScheduledJobs(String topic, Map<String, Object>... filterProps);
+
+ /**
+ * Return the jobs which are currently in processing. If there are several application nodes
+ * in the cluster, there could be more than one job in processing
+ * @param topic Topic can be used as a filter, if it is non-null, only jobs with this topic will be returned.
+ * @param filterProps A list of filter property maps. Each map acts like a template. The searched job
+ * must match the template (AND query). By providing several maps, different filters
+ * are possible (OR query).
+ * @return A non null collection.
+ * @since 2.4
+ */
+ JobsIterator queryCurrentJobs(String topic, Map<String, Object>... filterProps);
+
+ /**
+ * Return all jobs either running or scheduled.
+ * This is actually a convenience method and collects the results from {@link #queryScheduledJobs(String, Map...)}
+ * and {@link #queryCurrentJobs(String, Map...)}
+ * @param topic Topic can be used as a filter, if it is non-null, only jobs with this topic will be returned.
+ * @param filterProps A list of filter property maps. Each map acts like a template. The searched job
+ * must match the template (AND query). By providing several maps, different filters
+ * are possible (OR query).
+ * @return A non null collection.
+ * @since 2.4
+ */
+ JobsIterator queryAllJobs(String topic, Map<String, Object>... filterProps);
+
+ /**
+ * This is a unique identifer which can be used to cancel the job.
+ * @deprecated Use {@link org.apache.sling.event.jobs.JobUtil#JOB_ID}
+ */
+ @Deprecated
+ String PROPERTY_EVENT_ID = "slingevent:eventId";
+
+ /**
+ * Return a list of currently scheduled jobs.
+ * @param topic Topic can be used as a filter, if it is non-null, only jobs with this topic will be returned.
+ * @return A non null collection.
+ * @deprecated Use {@link #queryScheduledJobs(String, Map...)} instead.
+ */
+ @Deprecated
+ Collection<Event> getScheduledJobs(String topic);
+
+ /**
+ * Return the jobs which are currently in processing. If there are several application nodes
+ * in the cluster, there could be more than one job in processing
+ * @param topic Topic can be used as a filter, if it is non-null, only jobs with this topic will be returned.
+ * @return A non null collection.
+ * @deprecated Use {@link #queryCurrentJobs(String, Map...)} instead.
+ */
+ @Deprecated
+ Collection<Event> getCurrentJobs(String topic);
+
+ /**
+ * Return a list of currently scheduled jobs.
+ * @param topic Topic can be used as a filter, if it is non-null, only jobs with this topic will be returned.
+ * @param filterProps A list of filter property maps. Each map acts like a template. The searched job
+ * must match the template (AND query). By providing several maps, different filters
+ * are possible (OR query).
+ * @return A non null collection.
+ * @deprecated Use {@link #queryScheduledJobs(String, Map...)} instead.
+ */
+ @Deprecated
+ Collection<Event> getScheduledJobs(String topic, Map<String, Object>... filterProps);
+
+ /**
+ * Return the jobs which are currently in processing. If there are several application nodes
+ * in the cluster, there could be more than one job in processing
+ * @param topic Topic can be used as a filter, if it is non-null, only jobs with this topic will be returned.
+ * @param filterProps A list of filter property maps. Each map acts like a template. The searched job
+ * must match the template (AND query). By providing several maps, different filters
+ * are possible (OR query).
+ * @return A non null collection.
+ * @deprecated Use {@link #queryCurrentJobs(String, Map...)} instead.
+ */
+ @Deprecated
+ Collection<Event> getCurrentJobs(String topic, Map<String, Object>... filterProps);
+
+ /**
+ * Return all jobs either running or scheduled.
+ * This is actually a convenience method and collects the results from {@link #getScheduledJobs(String, Map...)}
+ * and {@link #getCurrentJobs(String, Map...)}
+ * @param topic Topic can be used as a filter, if it is non-null, only jobs with this topic will be returned.
+ * @param filterProps A list of filter property maps. Each map acts like a template. The searched job
+ * must match the template (AND query). By providing several maps, different filters
+ * are possible (OR query).
+ * @return A non null collection.
+ * @deprecated Use {@link #queryAllJobs(String, Map...)} instead.
+ */
+ @Deprecated
+ Collection<Event> getAllJobs(String topic, Map<String, Object>... filterProps);
+
+ /**
+ * Cancel this job.
+ * Cancelling a job might fail if the job is currently in processing.
+ * @param jobId The unique identifer as found in the property {@link #PROPERTY_EVENT_ID}.
+ * @deprecated Use {@link #removeJob(String)} instead.
+ */
+ @Deprecated
+ void cancelJob(String jobId);
+
+ /**
+ * Cancel this job.
+ * Cancelling a job might fail if the job is currently in processing.
+ * This method can be used if the topic and the provided job id is known.
+ * @param topic The job topic as put into the property {@link EventUtil#PROPERTY_JOB_TOPIC}.
+ * @param jobId The unique identifer as put into the property {@link EventUtil#PROPERTY_JOB_ID}.
+ * @deprecated Use {@link #removeJob(String, String)} instead.
+ */
+ @Deprecated
+ void cancelJob(String topic, String jobId);
+}
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobStatusProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobStatusProvider.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobStatusProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobsIterator.java
URL: http://svn.apache.org/viewvc/sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobsIterator.java?rev=1021247&view=auto
==============================================================================
--- sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobsIterator.java (added)
+++ sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobsIterator.java Mon Oct 11 06:54:12 2010
@@ -0,0 +1,42 @@
+/*
+ * 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.sling.event;
+
+import org.osgi.service.event.Event;
+
+/**
+ * This <code>Iterator</code> allows to iterate over {@link Event}s.
+ * In addition to an iterator it might return the number of elements
+ * in the collection and allows to skip several elements.
+ * If the iterator is not used to iterate through the whole collection
+ * of jobs, the {@link #close()} method must be called in order to
+ * free resources!
+ * @deprecated
+ */
+@Deprecated
+public interface JobsIterator extends org.apache.sling.event.jobs.JobsIterator {
+
+ /**
+ * Releases this iterators resources immediately instead of waiting for this
+ * to happen when it is automatically closed. After a call to close, this
+ * iterator should not be used anymore.
+ * The iterator is closed automatically when it reaches it's end.
+ */
+ void close();
+}
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobsIterator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobsIterator.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/JobsIterator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/TimedEventStatusProvider.java
URL: http://svn.apache.org/viewvc/sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/TimedEventStatusProvider.java?rev=1021247&view=auto
==============================================================================
--- sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/TimedEventStatusProvider.java (added)
+++ sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/TimedEventStatusProvider.java Mon Oct 11 06:54:12 2010
@@ -0,0 +1,57 @@
+/*
+ * 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.sling.event;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.osgi.service.event.Event;
+
+/**
+ * This service provides the current timed events status.
+ */
+public interface TimedEventStatusProvider {
+
+ /**
+ * This is a unique identifer which can be used to cancel the job.
+ */
+ String PROPERTY_EVENT_ID = "slingevent:eventId";
+
+ /**
+ * Return a list of currently schedulded events.
+ * @param topic Topic can be used as a filter, if it is non-null, only jobs with this topic will be returned.
+ * @param filterProps A list of filter property maps. Each map acts like a template. The searched event
+ * must match the template (AND query). By providing several maps, different filters
+ * are possible (OR query).
+ * @return A non null collection.
+ */
+ Collection<Event> getScheduledEvents(String topic, Map<String, Object>... filterProps);
+
+ /**
+ * Return the scheduled event with the given id.
+ * @return The scheduled event or null.
+ */
+ Event getScheduledEvent(String topic, String eventId, String jobId);
+
+ /**
+ * Cancel this timed event.
+ * @param jobId The unique identifer as found in the property {@link #PROPERTY_EVENT_ID}.
+ */
+ void cancelTimedEvent(String jobId);
+}
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/TimedEventStatusProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/TimedEventStatusProvider.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/TimedEventStatusProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
URL: http://svn.apache.org/viewvc/sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java?rev=1021247&view=auto
==============================================================================
--- sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java (added)
+++ sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java Mon Oct 11 06:54:12 2010
@@ -0,0 +1,347 @@
+/*
+ * 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.sling.event.impl;
+
+import java.util.Calendar;
+import java.util.Dictionary;
+import java.util.StringTokenizer;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.observation.EventListener;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.commons.osgi.OsgiUtil;
+import org.apache.sling.event.impl.jobs.jcr.JCRHelper;
+import org.apache.sling.event.impl.support.Environment;
+import org.apache.sling.event.jobs.JobUtil;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Abstract base class for all event handlers in this package.
+ *
+ */
+@Component(componentAbstract=true)
+@Service(value=EventHandler.class)
+public abstract class AbstractRepositoryEventHandler
+ implements EventHandler, EventListener {
+
+ /** Default log. */
+ protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ /** Default path for the {@link #CONFIG_PROPERTY_REPO_PATH} */
+ private static final String DEFAULT_PROPERTY_REPO_PATH = "/sling/events";
+
+ @Property(value=DEFAULT_PROPERTY_REPO_PATH)
+ protected static final String CONFIG_PROPERTY_REPO_PATH = "repository.path";
+
+ /** The repository session to write into the repository. */
+ protected Session writerSession;
+
+ /** Sync lock */
+ protected final Object writeLock = new Object();
+
+ /** The path in the repository. */
+ protected String repositoryPath;
+
+ /** Is the background task still running? */
+ protected volatile boolean running;
+
+ /** A local queue for serialising the event processing. */
+ protected final BlockingQueue<EventInfo> queue = new LinkedBlockingQueue<EventInfo>();
+
+ /** A local queue for writing received events into the repository. */
+ protected final BlockingQueue<Event> writeQueue = new LinkedBlockingQueue<Event>();
+
+ /**
+ * Environment component.
+ */
+ @Reference
+ protected EnvironmentComponent environment;
+
+ /** The root node for writing. */
+ private Node writeRootNode;
+
+ /**
+ * Activate this component.
+ * @param context
+ */
+ protected void activate(final ComponentContext context) {
+ this.repositoryPath = OsgiUtil.toString(context.getProperties().get(
+ CONFIG_PROPERTY_REPO_PATH), DEFAULT_PROPERTY_REPO_PATH);
+
+ this.running = true;
+ // start writer thread
+ final Thread writerThread = new Thread(new Runnable() {
+ public void run() {
+ try {
+ synchronized ( writeLock ) {
+ startWriterSession();
+ }
+ } catch (RepositoryException e) {
+ // there is nothing we can do except log!
+ logger.error("Error during session starting.", e);
+ running = false;
+ }
+ try {
+ processWriteQueue();
+ } catch (Throwable t) { //NOSONAR
+ logger.error("Writer thread stopped with exception: " + t.getMessage(), t);
+ running = false;
+ }
+ synchronized ( writeLock ) {
+ stopWriterSession();
+ }
+ }
+ });
+ writerThread.start();
+ final Thread backgroundThread = new Thread(new Runnable() {
+ public void run() {
+ try {
+ runInBackground();
+ } catch (Throwable t) { //NOSONAR
+ logger.error("Background thread stopped with exception: " + t.getMessage(), t);
+ running = false;
+ }
+ }
+ });
+ backgroundThread.start();
+ }
+
+ protected abstract void runInBackground() throws RepositoryException;
+
+ protected abstract void processWriteQueue();
+
+ /**
+ * Deactivate this component.
+ * @param context
+ */
+ protected void deactivate(final ComponentContext context) {
+ // stop background threads by putting empty objects into the queue
+ this.running = false;
+ try {
+ this.writeQueue.put(new Event("some", (Dictionary<String, Object>)null));
+ } catch (InterruptedException e) {
+ this.ignoreException(e);
+ }
+ try {
+ this.queue.put(new EventInfo());
+ } catch (InterruptedException e) {
+ this.ignoreException(e);
+ }
+ this.writeRootNode = null;
+ }
+
+ /**
+ * Start the repository session and add this handler as an observer
+ * for new events created on other nodes.
+ * @throws RepositoryException
+ */
+ protected void startWriterSession() throws RepositoryException {
+ this.writerSession = this.environment.createAdminSession();
+ this.writeRootNode = this.createPath(this.writerSession.getRootNode(),
+ this.repositoryPath.substring(1),
+ JCRHelper.NODETYPE_ORDERED_FOLDER);
+ this.writerSession.save();
+ }
+
+ /**
+ * Stop the session.
+ */
+ protected void stopWriterSession() {
+ if ( this.writerSession != null ) {
+ try {
+ this.writerSession.getWorkspace().getObservationManager().removeEventListener(this);
+ } catch (RepositoryException e) {
+ // we just ignore it
+ this.logger.warn("Unable to remove event listener.", e);
+ }
+ this.writerSession.logout();
+ this.writerSession = null;
+ }
+ }
+
+ /**
+ * Return the node type for the event.
+ */
+ protected String getEventNodeType() {
+ return JCRHelper.EVENT_NODE_TYPE;
+ }
+
+ /**
+ * Get the root node from the writer session.
+ */
+ protected Node getWriterRootNode() {
+ return this.writeRootNode;
+ }
+
+ /**
+ * Write an event to the repository.
+ * @param e The event
+ * @param suggestName A suggest name/path for the node.
+ * @throws RepositoryException
+ */
+ protected Node writeEvent(Event e, String suggestedName)
+ throws RepositoryException {
+ // create new node with name of topic
+ final Node rootNode = this.getWriterRootNode();
+
+ final String nodeType = this.getEventNodeType();
+ final String nodeName;
+ if ( suggestedName != null ) {
+ nodeName = suggestedName;
+ } else {
+ final Calendar now = Calendar.getInstance();
+ final int sepPos = nodeType.indexOf(':');
+ nodeName = nodeType.substring(sepPos+1) + "-" + Environment.APPLICATION_ID + "-" + now.getTime().getTime();
+ }
+ final Node eventNode = this.createPath(rootNode,
+ nodeName,
+ nodeType);
+
+ eventNode.setProperty(JCRHelper.NODE_PROPERTY_CREATED, Calendar.getInstance());
+ eventNode.setProperty(JCRHelper.NODE_PROPERTY_TOPIC, e.getTopic());
+ eventNode.setProperty(JCRHelper.NODE_PROPERTY_APPLICATION, Environment.APPLICATION_ID);
+
+ JCRHelper.writeEventProperties(eventNode, e);
+ this.addNodeProperties(eventNode, e);
+ writerSession.save();
+
+ return eventNode;
+ }
+
+ /**
+ * Read an event from the repository.
+ * @return
+ * @throws RepositoryException
+ * @throws ClassNotFoundException
+ */
+ protected Event readEvent(Node eventNode)
+ throws RepositoryException, ClassNotFoundException {
+ final String topic = eventNode.getProperty(JCRHelper.NODE_PROPERTY_TOPIC).getString();
+ final ClassLoader cl = this.environment.getDynamicClassLoader();
+ final Dictionary<String, Object> eventProps = JCRHelper.readEventProperties(eventNode, cl, false);
+
+ eventProps.put(JobUtil.JOB_ID, eventNode.getPath());
+ this.addEventProperties(eventNode, eventProps);
+ try {
+ final Event event = new Event(topic, eventProps);
+ return event;
+ } catch (IllegalArgumentException iae) {
+ // this exception occurs if the topic is not correct (it should never happen,
+ // but you never know)
+ throw new RepositoryException("Unable to read event: " + iae.getMessage(), iae);
+ }
+ }
+
+ /**
+ * Add properties from the node to the event properties.
+ * @param eventNode The repository node.
+ * @param properties The event properties.
+ * @throws RepositoryException
+ */
+ protected void addEventProperties(Node eventNode, Dictionary<String, Object> properties)
+ throws RepositoryException {
+ // nothing to do
+ }
+
+ /**
+ * Add properties when storing event in repository.
+ * This method can be enhanced by sub classes.
+ * @param eventNode
+ * @param event
+ * @throws RepositoryException
+ */
+ protected void addNodeProperties(Node eventNode, Event event)
+ throws RepositoryException {
+ // nothing to do here
+ }
+
+ /**
+ * Helper method which just logs the exception in debug mode.
+ * @param e
+ */
+ protected void ignoreException(Exception e) {
+ if ( this.logger.isDebugEnabled() ) {
+ this.logger.debug("Ignored exception " + e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Creates or gets the {@link javax.jcr.Node Node} at the given Path.
+ * In case it has to create the Node all non-existent intermediate path-elements
+ * will be create with the given intermediate node type and the returned node
+ * will be created with the given nodeType
+ *
+ * @param parentNode starting node
+ * @param relativePath to create
+ * @param intermediateNodeType to use for creation of intermediate nodes (or null)
+ * @param nodeType to use for creation of the final node (or null)
+ * @param autoSave Should save be called when a new node is created?
+ * @return the Node at path
+ * @throws RepositoryException in case of exception accessing the Repository
+ */
+ private Node createPath(Node parentNode,
+ String relativePath,
+ String nodeType)
+ throws RepositoryException {
+ if (!parentNode.hasNode(relativePath)) {
+ Node node = parentNode;
+ int pos = relativePath.lastIndexOf('/');
+ if ( pos != -1 ) {
+ final StringTokenizer st = new StringTokenizer(relativePath.substring(0, pos), "/");
+ while ( st.hasMoreTokens() ) {
+ final String token = st.nextToken();
+ if ( !node.hasNode(token) ) {
+ try {
+ node.addNode(token, JCRHelper.NODETYPE_FOLDER);
+ node.getSession().save();
+ } catch (RepositoryException re) {
+ // we ignore this as this folder might be created from a different task
+ node.refresh(false);
+ }
+ }
+ node = node.getNode(token);
+ }
+ relativePath = relativePath.substring(pos + 1);
+ }
+ if ( !node.hasNode(relativePath) ) {
+ node.addNode(relativePath, nodeType);
+ }
+ return node.getNode(relativePath);
+ }
+ return parentNode.getNode(relativePath);
+ }
+
+ public static final class EventInfo {
+ public String nodePath;
+ public Event event;
+ }
+
+}
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: sling/branches/eventing-3.0/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain