HHH-8159 - Apply fixups indicated by analysis tools

This commit is contained in:
Steve Ebersole 2013-04-26 11:19:54 -05:00
parent e09d6855a2
commit 42fd32a81a
8 changed files with 151 additions and 4 deletions

View File

@ -24,6 +24,8 @@
package org.hibernate.engine;
/**
* Describes how an entity should be optimistically locked.
*
* @author Steve Ebersole
*/
public enum OptimisticLockStyle {

View File

@ -35,10 +35,14 @@ import org.hibernate.engine.query.spi.sql.NativeSQLQueryReturn;
* @author Emmanuel Bernard
*/
public class ResultSetMappingDefinition implements Serializable {
private final String name;
private final List<NativeSQLQueryReturn> queryReturns = new ArrayList<NativeSQLQueryReturn>();
/**
* Constructs a ResultSetMappingDefinition
*
* @param name The mapping name
*/
public ResultSetMappingDefinition(String name) {
this.name = name;
}
@ -47,6 +51,11 @@ public class ResultSetMappingDefinition implements Serializable {
return name;
}
/**
* Adds a return.
*
* @param queryReturn The return
*/
public void addQueryReturn(NativeSQLQueryReturn queryReturn) {
queryReturns.add( queryReturn );
}

View File

@ -36,6 +36,8 @@ import org.hibernate.service.spi.ServiceRegistryAwareService;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* The standard ConfigurationService implementation
*
* @author Steve Ebersole
*/
public class ConfigurationServiceImpl implements ConfigurationService, ServiceRegistryAwareService {
@ -43,9 +45,15 @@ public class ConfigurationServiceImpl implements ConfigurationService, ServiceRe
CoreMessageLogger.class,
ConfigurationServiceImpl.class.getName()
);
private final Map settings;
private ServiceRegistryImplementor serviceRegistry;
/**
* Constructs a ConfigurationServiceImpl
*
* @param settings The map of settings
*/
@SuppressWarnings( "unchecked" )
public ConfigurationServiceImpl(Map settings) {
this.settings = Collections.unmodifiableMap( settings );
@ -75,18 +83,25 @@ public class ConfigurationServiceImpl implements ConfigurationService, ServiceRe
return converter.convert( value );
}
@Override
public <T> T getSetting(String name, Class<T> expected, T defaultValue) {
Object value = settings.get( name );
T target = cast( expected, value );
final Object value = settings.get( name );
final T target = cast( expected, value );
return target !=null ? target : defaultValue;
}
@Override
@SuppressWarnings("unchecked")
public <T> T cast(Class<T> expected, Object candidate){
if(candidate == null) return null;
if (candidate == null) {
return null;
}
if ( expected.isInstance( candidate ) ) {
return (T) candidate;
}
Class<T> target;
if ( Class.class.isInstance( candidate ) ) {
target = Class.class.cast( candidate );

View File

@ -30,11 +30,17 @@ import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* The ServiceInitiator for the ConfigurationService
*
* @author Steve Ebersole
*/
public class ConfigurationServiceInitiator implements StandardServiceInitiator<ConfigurationService> {
/**
* Singleton access
*/
public static final ConfigurationServiceInitiator INSTANCE = new ConfigurationServiceInitiator();
@Override
public ConfigurationService initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
return new ConfigurationServiceImpl( configurationValues );
}

View File

@ -0,0 +1,28 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
/**
* Internal support for the configuration service implementation
*/
package org.hibernate.engine.config.internal;

View File

@ -0,0 +1,29 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
/**
* Package for the configuration service, which provides access to configuration settings as part of a
* ServiceRegistry
*/
package org.hibernate.engine.config;

View File

@ -0,0 +1,28 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
/**
* SPI Package for the configuration service.
*/
package org.hibernate.engine.config.spi;

View File

@ -0,0 +1,30 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
/**
* Support for many of the internal workings of Hibernate.
*
* See also the {@link org.hibernate.internal} package.
*/
package org.hibernate.engine.internal;