org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer Java Examples

The following examples show how to use org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JdbcDataflowTaskExecutionMetadataDao.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
public JdbcDataflowTaskExecutionMetadataDao(DataSource dataSource,
		DataFieldMaxValueIncrementer incrementer) {

	this.incrementer = incrementer;

	this.jdbcTemplate = new NamedParameterJdbcTemplate(dataSource);

	this.objectMapper = new ObjectMapper();
	SimpleModule module = new SimpleModule();
	module.addDeserializer(Resource.class,
			new ResourceDeserializer(new AppResourceCommon(new MavenProperties(), new DefaultResourceLoader())));
	this.objectMapper.registerModule(module);
	this.objectMapper.addMixIn(Resource.class, ResourceMixin.class);
	this.objectMapper.addMixIn(AppDefinition.class, AppDefinitionMixin.class);
	this.objectMapper.addMixIn(AppDeploymentRequest.class, AppDeploymentRequestMixin.class);
	this.objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);

	this.dataSource = dataSource;
}
 
Example #2
Source File: MaxValueIncrementerFactoryBeanIntegrationTest.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * Tests that the incrementer returned from the factory returns the proper next int, long, and String values.
 */
@Test
public void testGetIncrementer_nextValues() {
    DataFieldMaxValueIncrementer incrementer = (DataFieldMaxValueIncrementer) context.getBean(TEST_INCREMENTER);
    assertNotNull(incrementer);

    // now that we have our incrementer, let's get the next value
    int nextIntValue = incrementer.nextIntValue();
    assertTrue("nextIntValue should be greater than 0", nextIntValue > 0);

    // do it again, should be 1 larger!
    int nextNextIntValue = incrementer.nextIntValue();
    assertEquals("Next value should be one higher", nextIntValue + 1, nextNextIntValue);

    // try getting the next value as a long
    long nextLongValue = incrementer.nextLongValue();
    assertEquals(nextNextIntValue + 1, nextLongValue);

    // try getting it as a String now
    String nextStringValue = incrementer.nextStringValue();
    assertEquals(nextLongValue + 1, Long.parseLong(nextStringValue));
}
 
Example #3
Source File: MaxValueIncrementerFactoryIntegrationTest.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * Tests that the incrementer returned from the factory returns the proper next int, long, and String values.
 */
@Test
public void testGetIncrementer_nextValues() {
    DataSource dataSource = TestHarnessServiceLocator.getDataSource();
    DataFieldMaxValueIncrementer incrementer =
            MaxValueIncrementerFactory.getIncrementer(dataSource, ARBITRARY_SEQUENCE);
    assertNotNull(incrementer);

    // now that we have our incrementer, let's get the next value
    int nextIntValue = incrementer.nextIntValue();
    assertTrue("nextIntValue should be greater than 0", nextIntValue > 0);

    // do it again, should be 1 larger!
    int nextNextIntValue = incrementer.nextIntValue();
    assertEquals("Next value should be one higher", nextIntValue + 1, nextNextIntValue);

    // try getting the next value as a long
    long nextLongValue = incrementer.nextLongValue();
    assertEquals(nextNextIntValue + 1, nextLongValue);

    // try getting it as a String now
    String nextStringValue = incrementer.nextStringValue();
    assertEquals(nextLongValue + 1, Long.parseLong(nextStringValue));
}
 
Example #4
Source File: MaxValueIncrementerFactoryTest.java    From rice with Educational Community License v2.0 6 votes vote down vote up
@Test
public void testCustomIncrementerDatasourceNoVersion() throws Exception {
    SimpleConfig config = new SimpleConfig();
    config.putProperty("rice.krad.data.platform.incrementer.mysql",
            "org.kuali.rice.krad.data.platform.testincrementers.CustomIncrementerMySQLVersion5");
    config.putProperty("rice.krad.data.platform.incrementer.oracle",
            "org.kuali.rice.krad.data.platform.testincrementers.CustomIncrementerOracleVersion11");
    ConfigContext.init(config);

    DataFieldMaxValueIncrementer mySQLMaxVal = MaxValueIncrementerFactory.getIncrementer(mysql,"test_mySQL");
    assertTrue("Found MySQL custom incrementer",mySQLMaxVal != null);
    assertTrue("Custom incrementer for MySQL should be mySQL5 for String val",
            StringUtils.equals(mySQLMaxVal.nextStringValue(),"mySQL5"));

    DataFieldMaxValueIncrementer oracleMaxVal = MaxValueIncrementerFactory.getIncrementer(oracle,"test_oracle");
    assertTrue("Found Oracle custom incrementer", oracleMaxVal != null);
}
 
Example #5
Source File: MaxValueIncrementerFactoryTest.java    From rice with Educational Community License v2.0 6 votes vote down vote up
@Test
public void testCustomIncrementerDatasourceVersion() throws Exception {
    SimpleConfig config = new SimpleConfig();
    config.putProperty("rice.krad.data.platform.incrementer.mysql.5",
            "org.kuali.rice.krad.data.platform.testincrementers.CustomIncrementerMySQLVersion5");
    config.putProperty("rice.krad.data.platform.incrementer.oracle.11",
            "org.kuali.rice.krad.data.platform.testincrementers.CustomIncrementerOracleVersion11");
    ConfigContext.init(config);

    DataFieldMaxValueIncrementer mySQLMaxVal = MaxValueIncrementerFactory.getIncrementer(mysql,"test_mySQL");
    assertTrue("Found MySQL custom incrementer",mySQLMaxVal != null);
    assertTrue("Custom incrementer for MySQL should be mySQL5 for String val",
                    StringUtils.equals(mySQLMaxVal.nextStringValue(),"mySQL5"));

    DataFieldMaxValueIncrementer oracleMaxVal = MaxValueIncrementerFactory.getIncrementer(oracle,"test_oracle");
    assertTrue("Found Oracle custom incrementer", oracleMaxVal != null);
}
 
Example #6
Source File: IdentityManagementRoleDocument.java    From rice with Educational Community License v2.0 5 votes vote down vote up
public void initializeDocumentForNewRole() {
    if (StringUtils.isBlank(this.roleId)) {
        DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(KimImplServiceLocator.getDataSource(), KimConstants.SequenceNames.KRIM_ROLE_ID_S);
        this.roleId = incrementer.nextStringValue();
    }
    if (StringUtils.isBlank(this.roleTypeId)) {
        this.roleTypeId = "1";
    }
}
 
Example #7
Source File: IdentityManagementGroupDocument.java    From rice with Educational Community License v2.0 5 votes vote down vote up
public void initializeDocumentForNewGroup() {
    if (StringUtils.isBlank(this.groupId)) {
        DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(KimImplServiceLocator.getDataSource(), KimConstants.SequenceNames.KRIM_GROUP_ID_S);
        this.groupId = incrementer.nextStringValue();
    }
    if (StringUtils.isBlank(this.groupTypeId)) {
        this.groupTypeId = "1";
    }
}
 
Example #8
Source File: ReviewResponsibilityMaintainable.java    From rice with Educational Community License v2.0 5 votes vote down vote up
private void initializeResponsibilityId(Object dataObject) {
    if (dataObject instanceof ReviewResponsibilityBo) {
        ReviewResponsibilityBo responsibilityBo = (ReviewResponsibilityBo) dataObject;

        if (StringUtils.isBlank(responsibilityBo.getId())) {
            DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(
                    KimImplServiceLocator.getDataSource(), KimConstants.SequenceNames.KRIM_RSP_ID_S);
            responsibilityBo.setId(incrementer.nextStringValue());
        }
    }
}
 
Example #9
Source File: MaxValueIncrementerFactoryTest.java    From rice with Educational Community License v2.0 5 votes vote down vote up
@Test(expected = InstantiationError.class)
public void testCustomIncrementerDatasourceInvalidClass() throws Exception {
    SimpleConfig config = new SimpleConfig();
    config.putProperty("rice.krad.data.platform.incrementer.mysql",
            "org.kuali.rice.krad.data.platform.testincrementers.NonExistent");
    ConfigContext.init(config);

    DataFieldMaxValueIncrementer mySQLMaxVal = MaxValueIncrementerFactory.getIncrementer(mysql,"test_mySQL");
    assertTrue("Cannot create incrementer", mySQLMaxVal == null);
}
 
Example #10
Source File: MaxValueIncrementerFactoryTest.java    From rice with Educational Community License v2.0 5 votes vote down vote up
@Test
public void testGetIncrementer_CaseInsensitive() throws Exception {
    DataFieldMaxValueIncrementer incrementer1 = MaxValueIncrementerFactory.getIncrementer(mysql, "MY_SEQUENCE");
    DataFieldMaxValueIncrementer incrementer2 = MaxValueIncrementerFactory.getIncrementer(mysql, "MY_sequence");
    DataFieldMaxValueIncrementer incrementer3 = MaxValueIncrementerFactory.getIncrementer(mysql, "my_sequence");
    assertSame(incrementer1, incrementer2);
    assertSame(incrementer2, incrementer3);
}
 
Example #11
Source File: MaxValueIncrementerFactoryTest.java    From rice with Educational Community License v2.0 5 votes vote down vote up
@Test
public void testGetIncrementer_MySQL() throws Exception {
    DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(mysql, "MY_SEQUENCE");
    assertTrue(incrementer instanceof MaxValueIncrementerFactory.EnhancedMySQLMaxValueIncrementer);
    MaxValueIncrementerFactory.EnhancedMySQLMaxValueIncrementer mysqlIncrementer =
            (MaxValueIncrementerFactory.EnhancedMySQLMaxValueIncrementer)incrementer;
    assertEquals("MY_SEQUENCE", mysqlIncrementer.getIncrementerName());
    assertEquals("ID", mysqlIncrementer.getColumnName());

    // ensure that it's caching the incrementer
    assertSame(incrementer, MaxValueIncrementerFactory.getIncrementer(mysql, "MY_SEQUENCE"));
    // ensure that different sequence gives a different incrementer
    assertNotSame(incrementer, MaxValueIncrementerFactory.getIncrementer(mysql, "MY_SEQUENCE_2"));

}
 
Example #12
Source File: MaxValueIncrementerFactoryTest.java    From rice with Educational Community License v2.0 5 votes vote down vote up
@Test
public void testGetIncrementer_Oracle() throws Exception {
    DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(oracle, "MY_SEQUENCE");
    assertTrue(incrementer instanceof OracleSequenceMaxValueIncrementer);
    OracleSequenceMaxValueIncrementer oracleIncrementer = (OracleSequenceMaxValueIncrementer)incrementer;
    assertEquals("MY_SEQUENCE", oracleIncrementer.getIncrementerName());

    // ensure that it's caching the incrementer
    assertSame(incrementer, MaxValueIncrementerFactory.getIncrementer(oracle, "MY_SEQUENCE"));
    // ensure that different sequence gives a different incrementer
    assertNotSame(incrementer, MaxValueIncrementerFactory.getIncrementer(oracle, "MY_SEQUENCE_2"));

}
 
Example #13
Source File: KradEclipseLinkCustomizer.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Object getGeneratedValue(Accessor accessor, AbstractSession writeSession, String seqName) {
    DataSource dataSource = ((JNDIConnector) writeSession.getLogin().getConnector()).getDataSource();
    DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(dataSource,
            sequenceName);
    return Long.valueOf(incrementer.nextLongValue());
}
 
Example #14
Source File: GenericPermissionMaintainable.java    From rice with Educational Community License v2.0 5 votes vote down vote up
private void initializePermissionId(Object dataObject) {
    if (dataObject instanceof GenericPermissionBo) {
        GenericPermissionBo permissionBo = (GenericPermissionBo) dataObject;

        if (StringUtils.isBlank(permissionBo.getId())) {
            DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(
                    KimImplServiceLocator.getDataSource(), KimConstants.SequenceNames.KRIM_PERM_ID_S);
            permissionBo.setId(incrementer.nextStringValue());
        }
    }
}
 
Example #15
Source File: MaxValueIncrementerFactory.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * Either constructs a new incrementer or retrieves a cached instance for the given DataSource and target
 * incrementer name.
 *
 * @param dataSource the {@link DataSource} for which to retrieve the incrementer.
 * @param incrementerName the case-insensitive name of the incrementer to use, this will generally be the name of
 *        the database object which is used to implement the incrementer.
 * @return an incrementer that can be used to generate the next incremented value for the given incrementer against
 *         the specified {@link DataSource}.
 *
 * @throws IllegalArgumentException if dataSource or incrementerName are null or blank.
 */
public static DataFieldMaxValueIncrementer getIncrementer(DataSource dataSource, String incrementerName) {
    if (dataSource == null) {
        throw new IllegalArgumentException("DataSource must not be null");
    }
    if (StringUtils.isBlank(incrementerName)) {
        throw new IllegalArgumentException("Incrementer name must not be null or blank");
    }

    // yes, we want to check if it's there first, then put if absent, for max speed! This is like ConcurrentMap's
    // version of double-checked locking.
    ConcurrentMap<String, DataFieldMaxValueIncrementer> incrementerCache = cache.get(dataSource);

    if (incrementerCache == null) {
        cache.put(dataSource,
                new ConcurrentHashMap<String, DataFieldMaxValueIncrementer>(8, 0.9f, 1));
        if (incrementerCache == null) {
            incrementerCache = cache.get(dataSource);
        }
    }

    // now check if we have a cached incrementer
    DataFieldMaxValueIncrementer incrementer = incrementerCache.get(incrementerName.toUpperCase());
    if (incrementer == null) {
        incrementer = incrementerCache.putIfAbsent(incrementerName.toUpperCase(), createIncrementer(dataSource,
                incrementerName));
        if (incrementer == null) {
            incrementer = incrementerCache.get(incrementerName.toUpperCase());
        }
    }
    return incrementer;

}
 
Example #16
Source File: RuleManagementServiceImpl.java    From rice with Educational Community License v2.0 5 votes vote down vote up
private DataFieldMaxValueIncrementer getRuleSequenceIncrementer() {
    if (ruleSequenceIncrementer == null) {
        ruleSequenceIncrementer = MaxValueIncrementerFactory.getIncrementer(dataSource, RULE_SEQ_NAME);
    }

    return ruleSequenceIncrementer;
}
 
Example #17
Source File: RuleManagementServiceImpl.java    From rice with Educational Community License v2.0 5 votes vote down vote up
private DataFieldMaxValueIncrementer getReferenceObjectBindingSequenceIncrementer() {
    if (referenceObjectBindingSequenceIncrementer == null) {
        referenceObjectBindingSequenceIncrementer = MaxValueIncrementerFactory.getIncrementer(dataSource, REF_OBJ_SEQ_NAME);
    }

    return referenceObjectBindingSequenceIncrementer;
}
 
Example #18
Source File: MaxValueIncrementerFactoryIntegrationTest.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * Tests that if you try to use the factory with an invalid sequence name, it will throw a DataAccessException.
 */
@Test(expected = DataAccessException.class)
public void testGetIncrementer_BadSequence() {
    DataSource dataSource = TestHarnessServiceLocator.getDataSource();
    DataFieldMaxValueIncrementer incrementer =
            MaxValueIncrementerFactory.getIncrementer(dataSource, "OH_NO_YOU_DIDNT!");

    // the incrementer *may* still be retrieved successfully (depending on the database this integration test is run against)
    assertNotNull(incrementer);

    // but at the very least it should throw an exception when executed
    incrementer.nextLongValue();
}
 
Example #19
Source File: MaxValueIncrementerFactoryIntegrationTest.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * Tests that the sequence name is case insensitive. We will do this by using the same sequence name as the
 * previous test, but changing the case to all lowercase.
 */
@Test
public void testGetIncrementer_CaseInsensitive() {
    DataSource dataSource = TestHarnessServiceLocator.getDataSource();
    DataFieldMaxValueIncrementer incrementer =
            MaxValueIncrementerFactory.getIncrementer(dataSource, ARBITRARY_SEQUENCE.toLowerCase());
    assertNotNull(incrementer);

    // now that we have our incrementer, let's get the next value
    int nextIntValue = incrementer.nextIntValue();
    assertTrue("nextIntValue should be greater than 0", nextIntValue > 0);
}
 
Example #20
Source File: MaxValueIncrementerFactoryBeanIntegrationTest.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * Tests that if you try to use the factory with an invalid sequence name, it will throw a DataAccessException.
 */
@Test(expected = DataAccessException.class)
public void testGetIncrementer_BadSequence() {
    DataFieldMaxValueIncrementer incrementer = (DataFieldMaxValueIncrementer) context.getBean(INVALID_TEST_INCREMENTER);

    // the incrementer *may* still be retrieved successfully (depending on the database this integration test is run against)
    assertNotNull(incrementer);

    // but at the very least it should throw an exception when executed
    incrementer.nextLongValue();
}
 
Example #21
Source File: MaxValueIncrementerFactoryBeanIntegrationTest.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * Tests that the sequence name is case insensitive. We will do this by using the same sequence name as the
 * previous test, but changing the case to all lowercase.
 */
@Test
public void testGetIncrementer_CaseInsensitive() {
    DataFieldMaxValueIncrementer incrementer = (DataFieldMaxValueIncrementer) context.getBean(TEST_INCREMENTER);
    assertNotNull(incrementer);

    // now that we have our incrementer, let's get the next value
    int nextIntValue = incrementer.nextIntValue();
    assertTrue("nextIntValue should be greater than 0", nextIntValue > 0);
}
 
Example #22
Source File: TestDBUtils.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a incrementer for the DataSource.
 * @param dataSource the datasource that the incrementer will use to record current
 * id.
 * @return a DataFieldMaxValueIncrementer object.
 */
public static DataFieldMaxValueIncrementer getIncrementer(DataSource dataSource) {
	DataFieldMaxValueIncrementerFactory incrementerFactory = new DefaultDataFieldMaxValueIncrementerFactory(
			dataSource);
	String databaseType = null;
	try {
		databaseType = DatabaseType.fromMetaData(dataSource).name();
	}
	catch (MetaDataAccessException e) {
		throw new IllegalStateException(e);
	}
	return incrementerFactory.getIncrementer(databaseType, "TASK_SEQ");
}
 
Example #23
Source File: IdentityManagementKimDocument.java    From rice with Educational Community License v2.0 4 votes vote down vote up
protected String getDelegationId(){
       DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(KimImplServiceLocator.getDataSource(), KimConstants.SequenceNames.KRIM_DLGN_ID_S);
       return incrementer.nextStringValue();
}
 
Example #24
Source File: JdbcTaskExecutionDao.java    From spring-cloud-task with Apache License 2.0 4 votes vote down vote up
public void setTaskIncrementer(DataFieldMaxValueIncrementer taskIncrementer) {
	this.taskIncrementer = taskIncrementer;
}
 
Example #25
Source File: IdentityManagementRoleDocument.java    From rice with Educational Community License v2.0 4 votes vote down vote up
public void addMember(KimDocumentRoleMember member) {
    DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(KimImplServiceLocator.getDataSource(), KimConstants.SequenceNames.KRIM_ROLE_MBR_ID_S);
    member.setRoleMemberId(incrementer.nextStringValue());
    setupMemberRspActions(member);
    getModifiedMembers().add(member);
}
 
Example #26
Source File: RuleTemplateDAOJpa.java    From rice with Educational Community License v2.0 4 votes vote down vote up
public String getNextRuleTemplateId() {
    DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(
            getDataSource(), SEQUENCE_NAME);
    return incrementer.nextStringValue();
}
 
Example #27
Source File: DocumentRouteHeaderDAOJpa.java    From rice with Educational Community License v2.0 4 votes vote down vote up
@Override
public String getNextDocumentId(){
    DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(
                                    getDataSource(), "KREW_DOC_HDR_S");
    return incrementer.nextStringValue();
}
 
Example #28
Source File: MaxValueIncrementerFactoryTest.java    From rice with Educational Community License v2.0 4 votes vote down vote up
@Test
public void testGetIncrementer_CacheByDataSource() throws Exception {
    DataFieldMaxValueIncrementer incrementer1 = MaxValueIncrementerFactory.getIncrementer(mysql, "MY_SEQUENCE");
    DataFieldMaxValueIncrementer incrementer2 = MaxValueIncrementerFactory.getIncrementer(oracle, "MY_SEQUENCE");
    assertNotSame(incrementer1, incrementer2);
}
 
Example #29
Source File: MaxValueIncrementerFactory.java    From rice with Educational Community License v2.0 4 votes vote down vote up
/**
 * Checks the config file for any references to
 * {@code rice.krad.data.platform.incrementer.(DATASOURCE, ex mysql, oracle).(VERSION optional)}.
 *
 * <p>If matching one found attempts to instantiate it to return back to factory for use.</p>
 *
 * @param platformInfo the {@link DatabasePlatformInfo}.
 * @param dataSource the {@link DataSource} for which to retrieve the incrementer.
 * @param incrementerName the name of the incrementer.
 * @param columnName the name of the column to increment.
 * @return a config set customized incrementer that matches and can be used to generate the next incremented value
 *         for the given incrementer against the specified {@link DataSource}
 * @throws InstantiationError if cannot instantiate passed in class.
 */
private static DataFieldMaxValueIncrementer getCustomizedIncrementer(DatabasePlatformInfo platformInfo, DataSource dataSource, String incrementerName, String columnName){
    if(platformInfo == null){
        throw new  IllegalArgumentException("DataSource platform must not be null");
    }
    if(ConfigContext.getCurrentContextConfig() == null){
        return null;
    }
    Map<String,String> incrementerPropToIncrementer = ConfigContext.getCurrentContextConfig().
                            getPropertiesWithPrefix(PLATFORM_INCREMENTER_PREFIX, true);
    String platformNameVersion = platformInfo.getName().toLowerCase() + "." + platformInfo.getMajorVersion();
    String incrementerClassName = "";

     if(incrementerPropToIncrementer.containsKey(platformNameVersion)){
        incrementerClassName = incrementerPropToIncrementer.get(platformNameVersion);
     } else if(incrementerPropToIncrementer.containsKey(platformInfo.getName().toLowerCase())){
         incrementerClassName = incrementerPropToIncrementer.get(platformInfo.getName().toLowerCase());
     }

    if(StringUtils.isNotBlank(incrementerClassName)){
        try {
            Class incrementerClass = Class.forName(incrementerClassName);
            if(AbstractSequenceMaxValueIncrementer.class.isAssignableFrom(incrementerClass)){
                AbstractSequenceMaxValueIncrementer abstractSequenceMaxValueIncrementer = (AbstractSequenceMaxValueIncrementer)incrementerClass.newInstance();
                abstractSequenceMaxValueIncrementer.setDataSource(dataSource);
                abstractSequenceMaxValueIncrementer.setIncrementerName(incrementerName);
                return abstractSequenceMaxValueIncrementer;

            } else if(AbstractColumnMaxValueIncrementer.class.isAssignableFrom(incrementerClass)){
                AbstractColumnMaxValueIncrementer abstractColumnMaxValueIncrementer = (AbstractColumnMaxValueIncrementer)incrementerClass.newInstance();
                abstractColumnMaxValueIncrementer.setDataSource(dataSource);
                abstractColumnMaxValueIncrementer.setIncrementerName(incrementerName);
                abstractColumnMaxValueIncrementer.setColumnName(columnName);
                return abstractColumnMaxValueIncrementer;
            } else {
                throw new InstantiationError("Cannot create incrementer class "+incrementerClassName +" it has to extend "
                        + "AbstractSequenceMaxValueIncrementer or AbstractColumnMaxValueIncrementer");
            }
        } catch (Exception e){
            throw new InstantiationError("Could not instantiate custom incrementer "+incrementerClassName);
        }
    }
    return null;
}
 
Example #30
Source File: MaxValueIncrementerFactoryBean.java    From rice with Educational Community License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Class<DataFieldMaxValueIncrementer> getObjectType() {
    return DataFieldMaxValueIncrementer.class;
}