Java 类org.hibernate.id.Configurable 实例源码

项目:gomall.la    文件:UIDGenerator.java   
/**
 * The main method.
 * 
 * @param args
 *            the arguments
 * @throws Exception
 *             the exception
 */
public static void main(String[] args) throws Exception {
    Properties props = new Properties();
    props.setProperty("separator", "");
    IdentifierGenerator gen = new UIDGenerator();
    ((Configurable) gen).configure(Hibernate.STRING, props, null);
    IdentifierGenerator gen2 = new UIDGenerator();
    ((Configurable) gen2).configure(Hibernate.STRING, props, null);

    for (int i = 0; i < 10; i++) {
        String id = (String) gen.generate(null, gen);
        System.out.println(id);
        String id2 = (String) gen2.generate(null, gen2);
        System.out.println(id2);
    }

}
项目:windup-rulesets    文件:CustomBuildIdDelegate.java   
public IdentifierGenerator createIdentifierGenerator(String strategy, Type type, Properties config) {
        try {
            Class clazz = getIdentifierGeneratorClass( strategy );
            CustomGenerator identifierGenerator = ( CustomGenerator ) clazz.newInstance();
            if ( identifierGenerator instanceof Configurable ) {
                ( ( Configurable ) identifierGenerator ).configure( type, config, dialect );
            }
            return identifierGenerator;
        }
        catch ( Exception e ) {
            final String entityName = config.getProperty( IdentifierGenerator.ENTITY_NAME );
            throw new MappingException( String.format( "Could not instantiate id generator [entity-name=%s]", entityName ), e );

   }

}
项目:lams    文件:DefaultIdentifierGeneratorFactory.java   
@Override
public IdentifierGenerator createIdentifierGenerator(String strategy, Type type, Properties config) {
    try {
        Class clazz = getIdentifierGeneratorClass( strategy );
        IdentifierGenerator identifierGenerator = ( IdentifierGenerator ) clazz.newInstance();
        if ( identifierGenerator instanceof Configurable ) {
            ( ( Configurable ) identifierGenerator ).configure( type, config, dialect );
        }
        return identifierGenerator;
    }
    catch ( Exception e ) {
        final String entityName = config.getProperty( IdentifierGenerator.ENTITY_NAME );
        throw new MappingException( String.format( "Could not instantiate id generator [entity-name=%s]", entityName ), e );
    }
}
项目:lams    文件:FileUtil.java   
public static String generateUniqueContentFolderID() {
IdentifierGenerator uuidGen = new UUIDGenerator();
((Configurable) uuidGen).configure(StringType.INSTANCE, new Properties(), null);

// lowercase to resolve OS issues
return ((String) uuidGen.generate(null, null)).toLowerCase();
   }
项目:lams    文件:ForgotPasswordServlet.java   
/**
    * Generates the unique key used for the forgot password request
    *
    * @return a unique key
    * @throws FileUtilException
    * @throws IOException
    */
   public static String generateUniqueKey() {
Properties props = new Properties();

IdentifierGenerator uuidGen = new UUIDGenerator();
((Configurable) uuidGen).configure(StringType.INSTANCE, props, null);

return ((String) uuidGen.generate(null, null)).toLowerCase();
   }
项目:unitimes    文件:UniqueIdGenerator.java   
public void configure(Type type, Properties params, Dialect d) throws MappingException {
    if (getGenerator() instanceof Configurable) {
        if (params.getProperty("schema") == null && sDefaultSchema != null)
            params.setProperty("schema", sDefaultSchema);
        if (params.get("identifier_normalizer") == null && sNormalizer != null)
            params.put("identifier_normalizer", sNormalizer);
        ((Configurable)getGenerator()).configure(type, params, d);
    }
}
项目:unitime    文件:UniqueIdGenerator.java   
public void configure(Type type, Properties params, Dialect d) throws MappingException {
    if (getGenerator() instanceof Configurable) {
        if (params.getProperty("schema") == null && sDefaultSchema != null)
            params.setProperty("schema", sDefaultSchema);
        if (params.get("identifier_normalizer") == null && sNormalizer != null)
            params.put("identifier_normalizer", sNormalizer);
        ((Configurable)getGenerator()).configure(type, params, d);
    }
}