[New] added a semi unique id generation to StrolchAgent
This commit is contained in:
parent
a355452a36
commit
8f056afbb6
|
@ -40,6 +40,11 @@ public class StrolchAgent {
|
||||||
public static final String PROP_REALMS = "realms"; //$NON-NLS-1$
|
public static final String PROP_REALMS = "realms"; //$NON-NLS-1$
|
||||||
private static final Logger logger = LoggerFactory.getLogger(StrolchAgent.class);
|
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 ComponentContainerImpl container;
|
||||||
private StrolchConfiguration strolchConfiguration;
|
private StrolchConfiguration strolchConfiguration;
|
||||||
|
|
||||||
|
@ -107,4 +112,18 @@ public class StrolchAgent {
|
||||||
throw new IllegalStateException(msg);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue