SIRONA-56 adding UniqueIdGenerator
git-svn-id: https://svn.apache.org/repos/asf/incubator/sirona/trunk@1714241 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/agent/javaagent/src/main/java/org/apache/sirona/javaagent/tracking/PathTracker.java b/agent/javaagent/src/main/java/org/apache/sirona/javaagent/tracking/PathTracker.java
index 70782e0..97935b5 100644
--- a/agent/javaagent/src/main/java/org/apache/sirona/javaagent/tracking/PathTracker.java
+++ b/agent/javaagent/src/main/java/org/apache/sirona/javaagent/tracking/PathTracker.java
@@ -24,6 +24,7 @@
import org.apache.sirona.pathtracking.PathTrackingEntry;
import org.apache.sirona.pathtracking.PathTrackingInformation;
import org.apache.sirona.pathtracking.PathTrackingInvocationListener;
+import org.apache.sirona.pathtracking.UniqueIdGenerator;
import org.apache.sirona.spi.Order;
import org.apache.sirona.spi.SPI;
import org.apache.sirona.store.DataStoreFactory;
@@ -50,12 +51,16 @@
IoCs.findOrCreateInstance( DataStoreFactory.class ).getPathTrackingDataStore();
+ private static final UniqueIdGenerator ID_GENERATOR =
+ IoCs.findOrCreateInstance( UniqueIdGenerator.class );
+
+
private static final ThreadLocal<Context> THREAD_LOCAL = new ThreadLocal<Context>()
{
@Override
protected Context initialValue()
{
- return new Context();
+ return new Context(ID_GENERATOR.next());
}
};
diff --git a/api/src/main/java/org/apache/sirona/pathtracking/Context.java b/api/src/main/java/org/apache/sirona/pathtracking/Context.java
index b3932d6..2bf130b 100644
--- a/api/src/main/java/org/apache/sirona/pathtracking/Context.java
+++ b/api/src/main/java/org/apache/sirona/pathtracking/Context.java
@@ -36,9 +36,9 @@
private Object startPathObject;
- public Context()
+ public Context(final String uuid)
{
- this.uuid = "Sirona-" + UUID.randomUUID().toString();
+ this.uuid = uuid;
this.level = new AtomicInteger( 0 );
this.entries = new ArrayList<PathTrackingEntry>();
}
diff --git a/api/src/main/java/org/apache/sirona/pathtracking/DefaultUniqueIdGenerator.java b/api/src/main/java/org/apache/sirona/pathtracking/DefaultUniqueIdGenerator.java
new file mode 100644
index 0000000..136acac
--- /dev/null
+++ b/api/src/main/java/org/apache/sirona/pathtracking/DefaultUniqueIdGenerator.java
@@ -0,0 +1,25 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.sirona.pathtracking;
+
+import java.util.UUID;
+
+public class DefaultUniqueIdGenerator implements UniqueIdGenerator {
+ public String next() {
+ return "Sirona-" + UUID.randomUUID().toString();
+ }
+}
diff --git a/api/src/main/java/org/apache/sirona/pathtracking/UniqueIdGenerator.java b/api/src/main/java/org/apache/sirona/pathtracking/UniqueIdGenerator.java
new file mode 100644
index 0000000..25dae99
--- /dev/null
+++ b/api/src/main/java/org/apache/sirona/pathtracking/UniqueIdGenerator.java
@@ -0,0 +1,21 @@
+/*
+* 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.sirona.pathtracking;
+
+public interface UniqueIdGenerator {
+ String next();
+}