/** * Creates a new standard authentication system with the given options. * * @param configLocation The location of the Spring configuration file (Spring context). * @param propertiesFilesBean The name of the properties file bean (Spring context). * @param userPropertyName The property name for the username (Spring context). * @param passwordPropertyName The property name for the password (Spring context). * @param userShort The short form of the command-line option for the username (command-line * context). * @param userLong The long form of the command-line option for the username (command-line * context). * @param passwordShort The short form of the command-line option for the password (command-line * context). * @param passwordLong The long form of the command-line option for the password (command-line * context). * @param cliArgs The command-line arguments (command-line context). */ public StandardAuthentication( String configLocation, String propertiesFilesBean, String userPropertyName, String passwordPropertyName, String userShort, String userLong, String passwordShort, String passwordLong, String[] cliArgs) { mSystem = new AuthenticationSystem(); mUserHolder = new Holder<String>(Messages.NO_USER); mPasswordHolder = new HolderCharArray(Messages.NO_PASSWORD); SpringContext springContext = new SpringContext(true, configLocation, propertiesFilesBean); springContext.add( new SpringSetterString( mUserHolder, new I18NBoundMessage1P(Messages.USER_SPRING_USAGE, userPropertyName), userPropertyName)); springContext.add( new SpringSetterCharArray( mPasswordHolder, new I18NBoundMessage1P(Messages.PASSWORD_SPRING_USAGE, passwordPropertyName), passwordPropertyName)); mSystem.add(springContext); mCliContext = new CliContext(true, cliArgs); mCliContext.add( new CliSetterString( mUserHolder, new I18NBoundMessage2P(Messages.USER_CLI_USAGE, userShort, userLong), userShort, userLong, Messages.USER_DESCRIPTION)); mCliContext.add( new CliSetterCharArray( mPasswordHolder, new I18NBoundMessage2P(Messages.PASSWORD_CLI_USAGE, passwordShort, passwordLong), passwordShort, passwordLong, Messages.PASSWORD_DESCRIPTION)); mSystem.add(mCliContext); ConsoleContext consoleContext = new ConsoleContext(false); consoleContext.add( new ConsoleSetterString(mUserHolder, Messages.USER_CONSOLE_USAGE, Messages.USER_PROMPT)); consoleContext.add( new ConsoleSetterCharArray( mPasswordHolder, Messages.PASSWORD_CONSOLE_USAGE, Messages.PASSWORD_PROMPT)); mSystem.add(consoleContext); }
/** * Constructs the name of the log file to write to for this execution of the step * * @param nestedDiagnosticContext the context returned by getNestedDiagnosticContext() for this * step * @return the name of the log file */ private String getLogFileName(String nestedDiagnosticContext) { return SpringContext.getBean(ConfigurationService.class) .getPropertyValueAsString(OLEConstants.REPORTS_DIRECTORY_KEY) + File.separator + nestedDiagnosticContext + ".log"; }
@SuppressWarnings("deprecation") public void getNonAnnotatedTransactionalServices() { /* We only want to run getNonAnnotatedTransactionalSerivces once. * The tests actually just read the Maps that are generated here. */ if (incorrectlyAnnotatedTransactionalServices != null) { return; } incorrectlyAnnotatedTransactionalServices = new HashMap<String, Class<? extends Object>>(); nonAnnotatedTransactionalServices = new HashMap<String, String>(); doubleAnnotatedTransactionalServices = new HashMap<String, String>(); String[] beanNames = SpringContext.getBeanNames(); for (String beanName : beanNames) { if (beanName.endsWith("-parentBean")) { continue; } Object bean = null; try { bean = SpringContext.getBean(beanName); } catch (BeanIsAbstractException ex) { // do nothing, ignore } catch (Exception e) { LOG.warn("Caught exception while trying to obtain service: " + beanName); LOG.warn(e.getClass().getName() + " : " + e.getMessage(), e); } if (bean != null) { Class<? extends Object> beanClass = bean.getClass(); if (beanClass.getName().matches(".*\\$Proxy.*")) { beanClass = AopUtils.getTargetClass(bean); } if (beanClass.getName().startsWith("org.kuali") && !Modifier.isAbstract(beanClass.getModifiers()) && !beanClass.getName().endsWith("DaoOjb") && !beanClass.getName().endsWith("DaoJdbc") && !beanClass.getName().endsWith("Factory") && !beanClass.getName().contains("Lookupable") && !isClassAnnotated(beanName, beanClass)) { incorrectlyAnnotatedTransactionalServices.put(beanName, beanClass); } } } return; }
public static void main(String[] args) { MeteoLogger.log("Author Johnny Novak > [email protected]"); context = SpringContext.getInstance(); MeteoLogger.log("Scanning folder " + context.getProperty("folder.path.scan")); PhotoGetter photoGetter = new PhotoGetterImpl(); PhotoUploader photoUploader = new PhotoUploaderImpl(); while (true) { photoUploader.uploadPhotos(photoGetter.getNewPhotos()); try { Thread.sleep(500L); } catch (InterruptedException ex) { MeteoLogger.log(ex); } } }
/** @return the nested diagnostic context string for this step's log file */ @SuppressWarnings("unchecked") private String getNestedDiagnosticContext() { Step unProxiedStep = (Step) ProxyUtils.getTargetIfProxied(step); Class stepClass = unProxiedStep.getClass(); ModuleService module = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(stepClass); String nestedDiagnosticContext = StringUtils.substringAfter(module.getModuleConfiguration().getNamespaceCode(), "-") .toLowerCase() + File.separator + step.getName() + "-" + dateTimeService.toDateTimeStringForFilename(dateTimeService.getCurrentDate()); return nestedDiagnosticContext; }