[New] added a semi unique id generation to StrolchAgent

This commit is contained in:
Robert von Burg 2013-12-28 12:58:57 +01:00
parent a355452a36
commit 8f056afbb6
1 changed files with 19 additions and 0 deletions

View File

@ -40,6 +40,11 @@ public class StrolchAgent {
public static final String PROP_REALMS = "realms"; //$NON-NLS-1$
private static final Logger logger = LoggerFactory.getLogger(StrolchAgent.class);
/**
* the semi-unique id which is incremented on every {@link #getUniqueId()}-method call
*/
private static long uniqueId = System.currentTimeMillis() - 1119953500000l;
private ComponentContainerImpl container;
private StrolchConfiguration strolchConfiguration;
@ -107,4 +112,18 @@ public class StrolchAgent {
throw new IllegalStateException(msg);
}
}
/**
* @return Returns the pseudo unique Id to be used during object creation from external services.
*/
public static synchronized String getUniqueId() {
if (uniqueId == Long.MAX_VALUE - 1) {
uniqueId = 0;
}
uniqueId += 1;
return Long.toString(uniqueId);
}
}