/** * Method resolves the unit remote class of the given unit type. * * @param unitType the unit type to detect the unit class. * @return the unit remote class is returned. * @throws CouldNotPerformException is thrown if something went wrong during class loading. */ public static Class<? extends AbstractUnitRemote> loadUnitRemoteClass(final UnitType unitType) throws CouldNotPerformException { try { String remoteClassName = null; // check unit type and load related class. if (UnitConfigProcessor.isBaseUnit(unitType)) { remoteClassName = AbstractUnitRemote.class.getPackage().getName() + "." + unitType.name().toLowerCase().replaceAll("_", "") + "." + StringProcessor.transformUpperCaseToCamelCase(unitType.name()) + "Remote"; } else if (UnitConfigProcessor.isDalUnit(unitType)) { remoteClassName = AbstractUnitRemote.class.getPackage().getName() + "." + StringProcessor.transformUpperCaseToCamelCase(unitType.name()) + "Remote"; } else { throw new EnumNotSupportedException(unitType, UnitRemoteFactoryImpl.class); } return (Class<? extends AbstractUnitRemote>) UnitRemoteFactoryImpl.class.getClassLoader().loadClass(remoteClassName); } catch (CouldNotPerformException | ClassNotFoundException ex) { throw new CouldNotPerformException("Could not detect unit remote class for UnitType[" + unitType.name() + "]!", ex); } }
break; default: throw new EnumNotSupportedException(serviceConfig.getServiceDescription().getPattern(), this);