KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > simpl > SimpleInstanceIdGenerator


1 /*
2  * Copyright 2004-2005 OpenSymphony
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy
6  * of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations
14  * under the License.
15  *
16  */

17 package org.quartz.simpl;
18
19 import java.net.InetAddress JavaDoc;
20
21 import org.quartz.SchedulerException;
22 import org.quartz.spi.InstanceIdGenerator;
23
24 /**
25  * The default InstanceIdGenerator used by Quartz when instance id is to be
26  * automatically generated. Instance id is of the form HOSTNAME + CURRENT_TIME.
27  *
28  * @see InstanceIdGenerator
29  * @see HostnameInstanceIdGenerator
30  */

31 public class SimpleInstanceIdGenerator implements InstanceIdGenerator {
32     public String JavaDoc generateInstanceId() throws SchedulerException {
33         try {
34             return InetAddress.getLocalHost().getHostName() + System.currentTimeMillis();
35         } catch (Exception JavaDoc e) {
36             throw new SchedulerException("Couldn't get host name!", e);
37         }
38     }
39 }
Popular Tags