本文整理汇总了Java中com.fasterxml.uuid.Generators.timeBasedGenerator方法的典型用法代码示例。如果您正苦于以下问题:Java Generators.timeBasedGenerator方法的具体用法?Java Generators.timeBasedGenerator怎么用?Java Generators.timeBasedGenerator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.uuid.Generators
的用法示例。
在下文中一共展示了Generators.timeBasedGenerator方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureGeneratorInitialized
import com.fasterxml.uuid.Generators; //导入方法依赖的package包/类
private static void ensureGeneratorInitialized() {
if (timeGenerator == null) {
synchronized (UUIDUtils.class) {
if (timeGenerator == null) {
timeGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
}
}
}
if (randomGenerator == null) {
synchronized (com.fasterxml.uuid.UUIDGenerator.class) {
if (randomGenerator == null) {
randomGenerator = Generators.randomBasedGenerator();
}
}
}
}
示例2: preStart
import com.fasterxml.uuid.Generators; //导入方法依赖的package包/类
/**
* Establishes a connection with the webtrends stream api
* @see akka.actor.UntypedActor#preStart()
*/
public void preStart() throws Exception {
// initialize the uuid generator which is based on time and ethernet address
this.uuidGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
// authenticate with the webtrends service
WebtrendsTokenRequest tokenRequest = new WebtrendsTokenRequest(this.authUrl, this.authAudience, this.authScope, this.clientId, this.clientSecret);
this.oAuthToken = tokenRequest.execute();
// initialize the webtrends stream socket client and connect the listener
this.webtrendsStreamSocketClient = new WebSocketClient();
try {
this.webtrendsStreamSocketClient.start();
ClientUpgradeRequest upgradeRequest = new ClientUpgradeRequest();
this.webtrendsStreamSocketClient.connect(this, new URI(this.eventStreamUrl), upgradeRequest);
await(5, TimeUnit.SECONDS);
} catch(Exception e) {
throw new RuntimeException("Unable to connect to web socket: " + e.getMessage(), e);
}
this.componentRegistryRef.tell(new ComponentRegistrationMessage(EVENT_SOURCE_ID, ComponentType.STREAM_LISTENER, getSelf()), getSelf());
}
示例3: ensureGeneratorInitialized
import com.fasterxml.uuid.Generators; //导入方法依赖的package包/类
protected void ensureGeneratorInitialized() {
if (timeBasedGenerator == null) {
synchronized (UuidIdGenerator.class) {
if (timeBasedGenerator == null) {
timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
}
}
}
}
示例4: ensureGeneratorInitialized
import com.fasterxml.uuid.Generators; //导入方法依赖的package包/类
protected void ensureGeneratorInitialized() {
if (timeBasedGenerator == null) {
synchronized (StrongUuidGenerator.class) {
if (timeBasedGenerator == null) {
timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
}
}
}
}
示例5: ensureGeneratorInitialized
import com.fasterxml.uuid.Generators; //导入方法依赖的package包/类
protected void ensureGeneratorInitialized() {
if (timeBasedGenerator == null) {
synchronized (StrongUuidGenerator.class) {
if (timeBasedGenerator == null) {
timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
}
}
}
}
示例6: getUuidGenerator
import com.fasterxml.uuid.Generators; //导入方法依赖的package包/类
@Override
public TimeBasedGenerator getUuidGenerator() {
if (uuidGenerator == null) {
EthernetAddress nic = EthernetAddress.fromInterface();
if (nic == null) {
// construct address with a random number
nic = EthernetAddress.constructMulticastAddress();
}
uuidGenerator = Generators.timeBasedGenerator(nic);
}
return uuidGenerator;
}
示例7: UUIDTimeIDGenerator
import com.fasterxml.uuid.Generators; //导入方法依赖的package包/类
public UUIDTimeIDGenerator() {
try {
uuid1 = new File(System.getProperty("java.io.tmpdir") + File.separator + "uuid1.lck");
uuid2 = new File(System.getProperty("java.io.tmpdir") + File.separator + "uuid2.lck");
synchronizer = new FileBasedTimestampSynchronizer(uuid1, uuid2);
generator = Generators.timeBasedGenerator(EthernetAddress.fromInterface(), synchronizer);
} catch (IOException e) {
log.error("error initialising time-based UUID generator",e);
}
}
示例8: generateV1Uuid
import com.fasterxml.uuid.Generators; //导入方法依赖的package包/类
public static String generateV1Uuid(){
EthernetAddress addr = EthernetAddress.fromInterface();
TimeBasedGenerator uuidGenerator = Generators.timeBasedGenerator(addr);
UUID uuid = uuidGenerator.generate();
return uuid.toString();
}