org.hibernate.service.spi.ServiceException Java Examples
The following examples show how to use
org.hibernate.service.spi.ServiceException.
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: PersisterFactoryInitiator.java From lams with GNU General Public License v2.0 | 6 votes |
@Override @SuppressWarnings( {"unchecked"}) public PersisterFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) { final Object customImpl = configurationValues.get( IMPL_NAME ); if ( customImpl == null ) { return new PersisterFactoryImpl(); } if ( PersisterFactory.class.isInstance( customImpl ) ) { return (PersisterFactory) customImpl; } final Class<? extends PersisterFactory> customImplClass = Class.class.isInstance( customImpl ) ? ( Class<? extends PersisterFactory> ) customImpl : locate( registry, customImpl.toString() ); try { return customImplClass.newInstance(); } catch (Exception e) { throw new ServiceException( "Could not initialize custom PersisterFactory impl [" + customImplClass.getName() + "]", e ); } }
Example #2
Source File: PersisterClassResolverInitiator.java From lams with GNU General Public License v2.0 | 6 votes |
@Override @SuppressWarnings( {"unchecked"}) public PersisterClassResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) { final Object customImpl = configurationValues.get( IMPL_NAME ); if ( customImpl == null ) { return new StandardPersisterClassResolver(); } if ( PersisterClassResolver.class.isInstance( customImpl ) ) { return (PersisterClassResolver) customImpl; } final Class<? extends PersisterClassResolver> customImplClass = Class.class.isInstance( customImpl ) ? (Class<? extends PersisterClassResolver>) customImpl : locate( registry, customImpl.toString() ); try { return customImplClass.newInstance(); } catch (Exception e) { throw new ServiceException( "Could not initialize custom PersisterClassResolver impl [" + customImplClass.getName() + "]", e ); } }
Example #3
Source File: DriverManagerConnectionProviderImpl.java From lams with GNU General Public License v2.0 | 6 votes |
private Driver loadDriverIfPossible(String driverClassName) { if ( driverClassName == null ) { log.debug( "No driver class specified" ); return null; } if ( serviceRegistry != null ) { final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); final Class<Driver> driverClass = classLoaderService.classForName( driverClassName ); try { return driverClass.newInstance(); } catch ( Exception e ) { throw new ServiceException( "Specified JDBC Driver " + driverClassName + " could not be loaded", e ); } } try { return (Driver) Class.forName( driverClassName ).newInstance(); } catch ( Exception e1 ) { throw new ServiceException( "Specified JDBC Driver " + driverClassName + " could not be loaded", e1 ); } }
Example #4
Source File: BatchBuilderInitiator.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public BatchBuilder initiateService(Map configurationValues, ServiceRegistryImplementor registry) { final Object builder = configurationValues.get( BUILDER ); if ( builder == null ) { return new BatchBuilderImpl( ConfigurationHelper.getInt( Environment.STATEMENT_BATCH_SIZE, configurationValues, 1 ) ); } if ( BatchBuilder.class.isInstance( builder ) ) { return (BatchBuilder) builder; } final String builderClassName = builder.toString(); try { return (BatchBuilder) registry.getService( ClassLoaderService.class ).classForName( builderClassName ).newInstance(); } catch (Exception e) { throw new ServiceException( "Could not build explicit BatchBuilder [" + builderClassName + "]", e ); } }
Example #5
Source File: GlobalExceptionHandler.java From Spring-Boot-Book with Apache License 2.0 | 5 votes |
/** * 业务层需要自己声明异常的情况 */ @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ExceptionHandler(ServiceException.class) public String handleServiceException(ServiceException e, Model model) { logger.error("业务逻辑异常", e); String message = "【业务逻辑异常】" + e.getMessage(); model.addAttribute("message", message); return viewName; }
Example #6
Source File: GlobalExceptionHandler.java From Spring-Boot-Book with Apache License 2.0 | 5 votes |
/** * 业务层需要自己声明异常的情况 */ @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ExceptionHandler(ServiceException.class) public String handleServiceException(ServiceException e, Model model) { logger.error("业务逻辑异常", e); String message = "【业务逻辑异常】" + e.getMessage(); model.addAttribute("message", message); return viewName; }
Example #7
Source File: UserController.java From SpringBootUnity with MIT License | 5 votes |
/** * 处理激活 */ @ApiOperation(value = "处理激活", notes = "处理激活", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "validateEmail", method = RequestMethod.POST) public Result validateEmail(@RequestBody UserModel user ) throws ServiceException { //数据访问层,通过email获取用户信息 UserModel userModel = service.findUserByEmail(user.getEmail()); if (userModel != null) { return new Result(CodeConst.USER_REPEAT.getResultCode(), CodeConst.USER_REPEAT.getMessage()); } //验证码是否过期 if (user.getRegisterTime() + TimeUtil.ONE_DAY_IN_MILLISECONDS < TimeUtil.getNowOfMills()) { LOGGER.info("用户{}使用己过期的激活码{}激活邮箱失败!", user.getEmail(), user.getEmail()); return new Result(CodeConst.TIME_PASSED.getResultCode(), CodeConst.TIME_PASSED.getMessage()); } //激活 String salt = RandomUtil.createSalt(); userModel = new UserModel(); userModel.setNickName(user.getNickName()); userModel.setEmail(user.getEmail()); userModel.setGender(GenderConst.SECRET); userModel.setValidateCode(Md5Util.encode(user.getEmail(), salt)); userModel.setPhone(0L); userModel.setSalt(salt); userModel.setAddress(""); userModel.setPassword(Md5Util.encode(user.getPassword(), salt)); userModel = service.addUser(userModel); LOGGER.info("用户{}使用激活码{}激活邮箱成功!", userModel.getEmail(), userModel.getValidateCode()); return new Result<>(userModel); }
Example #8
Source File: MultiTenantConnectionProviderInitiator.java From lams with GNU General Public License v2.0 | 4 votes |
@Override @SuppressWarnings( {"unchecked"}) public MultiTenantConnectionProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) { final MultiTenancyStrategy strategy = MultiTenancyStrategy.determineMultiTenancyStrategy( configurationValues ); if ( !strategy.requiresMultiTenantConnectionProvider() ) { // nothing to do, but given the separate hierarchies have to handle this here. return null; } final Object configValue = configurationValues.get( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER ); if ( configValue == null ) { // if they also specified the data source *name*, then lets assume they want // DataSourceBasedMultiTenantConnectionProviderImpl final Object dataSourceConfigValue = configurationValues.get( AvailableSettings.DATASOURCE ); if ( dataSourceConfigValue != null && String.class.isInstance( dataSourceConfigValue ) ) { return new DataSourceBasedMultiTenantConnectionProviderImpl(); } return null; } if ( MultiTenantConnectionProvider.class.isInstance( configValue ) ) { return (MultiTenantConnectionProvider) configValue; } else { final Class<MultiTenantConnectionProvider> implClass; if ( Class.class.isInstance( configValue ) ) { implClass = (Class) configValue; } else { final String className = configValue.toString(); final ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class ); try { implClass = classLoaderService.classForName( className ); } catch (ClassLoadingException cle) { log.warn( "Unable to locate specified class [" + className + "]", cle ); throw new ServiceException( "Unable to locate specified multi-tenant connection provider [" + className + "]" ); } } try { return implClass.newInstance(); } catch (Exception e) { log.warn( "Unable to instantiate specified class [" + implClass.getName() + "]", e ); throw new ServiceException( "Unable to instantiate specified multi-tenant connection provider [" + implClass.getName() + "]" ); } } }
Example #9
Source File: BootstrapServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public <R extends Service> R initiateService(ServiceInitiator<R> serviceInitiator) { throw new ServiceException( "Boot-strap registry should only contain provided services" ); }
Example #10
Source File: BootstrapServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public <R extends Service> void configureService(ServiceBinding<R> binding) { throw new ServiceException( "Boot-strap registry should only contain provided services" ); }
Example #11
Source File: BootstrapServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public <R extends Service> void injectDependencies(ServiceBinding<R> binding) { throw new ServiceException( "Boot-strap registry should only contain provided services" ); }
Example #12
Source File: BootstrapServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public <R extends Service> void startService(ServiceBinding<R> binding) { throw new ServiceException( "Boot-strap registry should only contain provided services" ); }
Example #13
Source File: FIXServer.java From sailfish-core with Apache License 2.0 | 2 votes |
@Override public void setServiceHandler(IServiceHandler handler) { throw new ServiceException("Unsupported operation"); }