Index: provider/src/main/java/org/hippoecm/repository/dataprovider/HippoNodeId.java
===================================================================
--- provider/src/main/java/org/hippoecm/repository/dataprovider/HippoNodeId.java	(revision 30862)
+++ provider/src/main/java/org/hippoecm/repository/dataprovider/HippoNodeId.java	(working copy)
@@ -44,9 +44,10 @@
     public Name name;
     private final HippoVirtualProvider provider;
     private StateProviderContext context;
+    
 
     public HippoNodeId(HippoVirtualProvider provider, NodeId parent, StateProviderContext context, Name name) {
-        super(UUID.randomUUID());
+        super(provider.getDataProviderContext().getVirtualUuidGenerator().generateUuid());
         this.provider = provider;
         if(context != null) {
             this.context = context;
Index: provider/src/main/java/org/hippoecm/repository/dataprovider/DataProviderContext.java
===================================================================
--- provider/src/main/java/org/hippoecm/repository/dataprovider/DataProviderContext.java	(revision 30862)
+++ provider/src/main/java/org/hippoecm/repository/dataprovider/DataProviderContext.java	(working copy)
@@ -34,6 +34,7 @@
 
 import org.hippoecm.repository.FacetedNavigationEngine;
 import org.hippoecm.repository.FacetedNavigationEngine.Context;
+import org.hippoecm.repository.api.UuidGenerator;
 
 public interface DataProviderContext {
     @SuppressWarnings("unused")
@@ -42,6 +43,8 @@
     public HippoVirtualProvider lookupProvider(String moduleName);
 
     public HippoVirtualProvider lookupProvider(Name nodeTypeName);
+    
+    public UuidGenerator getVirtualUuidGenerator();
 
     public void registerProvider(Name nodeTypeName, HippoVirtualProvider provider);
 
Index: engine/src/main/java/org/hippoecm/repository/jackrabbit/HippoLocalItemStateManager.java
===================================================================
--- engine/src/main/java/org/hippoecm/repository/jackrabbit/HippoLocalItemStateManager.java	(revision 30862)
+++ engine/src/main/java/org/hippoecm/repository/jackrabbit/HippoLocalItemStateManager.java	(working copy)
@@ -60,12 +60,14 @@
 import org.hippoecm.repository.FacetedNavigationEngine.Query;
 import org.hippoecm.repository.Modules;
 import org.hippoecm.repository.SessionStateThresholdEnum;
+import org.hippoecm.repository.api.UuidGenerator;
 import org.hippoecm.repository.dataprovider.DataProviderContext;
 import org.hippoecm.repository.dataprovider.DataProviderModule;
 import org.hippoecm.repository.dataprovider.HippoNodeId;
 import org.hippoecm.repository.dataprovider.HippoVirtualProvider;
 import org.hippoecm.repository.dataprovider.ParameterizedNodeId;
 import org.hippoecm.repository.dataprovider.StateProviderContext;
+import org.hippoecm.repository.util.uuid.IncrementalUuidGenerator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -116,6 +118,7 @@
     private static Modules<DataProviderModule> dataProviderModules = null;
     private boolean editFakeMode = false;
     private boolean editRealMode = false;
+    private UuidGenerator virtualUuidGenerator = new IncrementalUuidGenerator();
 
     public HippoLocalItemStateManager(SharedItemStateManager sharedStateMgr, EventStateCollectionFactory factory,
                                       ItemStateCacheFactory cacheFactory, String attributeName, NodeTypeRegistry ntReg, boolean enabled,
@@ -181,6 +184,10 @@
         return virtualNodeNames.get(nodeTypeName);
     }
 
+    public UuidGenerator getVirtualUuidGenerator() {
+        return virtualUuidGenerator;
+    }
+
     public Name getQName(String name) throws IllegalNameException, NamespaceException {
         return session.getQName(name);
     }
Index: api/src/main/java/org/hippoecm/repository/api/UuidGenerator.java
===================================================================
--- api/src/main/java/org/hippoecm/repository/api/UuidGenerator.java	(revision 0)
+++ api/src/main/java/org/hippoecm/repository/api/UuidGenerator.java	(revision 0)
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2011 Hippo.
+ *
+ * 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.
+ */
+package org.hippoecm.repository.api;
+
+import java.util.UUID;
+
+/**
+ * Generator to generate UUID strings.
+ */
+public interface UuidGenerator {
+
+    /** @exclude */
+    static final String SVN_ID = "$Id$";
+
+    /**
+     * Generates a UUID string representation.  
+     * 
+     * @return the unique id.
+     */
+    UUID generateUuid();
+}

Property changes on: api/src/main/java/org/hippoecm/repository/api/UuidGenerator.java
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Index: utilities/src/main/java/org/hippoecm/repository/util/uuid/IncrementalUuidGenerator.java
===================================================================
--- utilities/src/main/java/org/hippoecm/repository/util/uuid/IncrementalUuidGenerator.java	(revision 0)
+++ utilities/src/main/java/org/hippoecm/repository/util/uuid/IncrementalUuidGenerator.java	(revision 0)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011 Hippo.
+ *
+ * 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.
+ */
+package org.hippoecm.repository.util.uuid;
+
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.hippoecm.repository.api.UuidGenerator;
+
+/**
+ * Uuid generator that increases the least significant bytes by one.
+ * This is thread safe and non synchronize, but it's not safe to use
+ * for uuid generation across cluster nodes (different jvms).
+ */
+public class IncrementalUuidGenerator implements UuidGenerator {
+
+    /** @exclude */
+    static final String SVN_ID = "$Id$";
+
+    private final AtomicLong lsb = new AtomicLong(1);
+    private static long msb;
+    private static final String prefix = "cafeface-0000-0000";
+    
+    static {
+        String[] components = prefix.split("-");
+        msb = Long.decode("0x"+components[0]).longValue();
+        msb <<= 16;
+        msb |= Long.decode("0x"+components[1]).longValue();
+        msb <<= 16;
+        msb |= Long.decode("0x"+components[2]).longValue();
+    }
+
+    @Override
+    public UUID generateUuid() {
+        return new UUID(msb,lsb.getAndIncrement());
+    }
+
+}

Property changes on: utilities/src/main/java/org/hippoecm/repository/util/uuid/IncrementalUuidGenerator.java
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Index: utilities/src/main/java/org/hippoecm/repository/util/uuid/JavaUuidGenerator.java
===================================================================
--- utilities/src/main/java/org/hippoecm/repository/util/uuid/JavaUuidGenerator.java	(revision 0)
+++ utilities/src/main/java/org/hippoecm/repository/util/uuid/JavaUuidGenerator.java	(revision 0)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2011 Hippo.
+ *
+ * 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.
+ */
+package org.hippoecm.repository.util.uuid;
+
+import java.util.UUID;
+
+import org.hippoecm.repository.api.UuidGenerator;
+
+/**
+ * Uuid generator based on the standard java implementation. The 
+ * java implementation is synchronized.
+ */
+public class JavaUuidGenerator implements UuidGenerator {
+
+    /** @exclude */
+    static final String SVN_ID = "$Id$";
+
+    @Override
+    public UUID generateUuid() {
+        return UUID.randomUUID();
+    }
+
+}

Property changes on: utilities/src/main/java/org/hippoecm/repository/util/uuid/JavaUuidGenerator.java
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

