List of usage examples for org.springframework.context ApplicationContext getBean
Object getBean(String name) throws BeansException;
From source file:util.Main.java
public static void main(String[] args) { ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml"); SpecificTAAService genericTAAService = (SpecificTAAService) appContext.getBean("specificTAAService"); SpecificTAA genericTAA = new SpecificTAA(); genericTAA.setApprovedByDos(new Date()); genericTAA.setDraft(new Date()); genericTAA.setFullyExecuted(new Date()); genericTAA.setSubmissionToDoS(new Date()); genericTAA.setLicenseNumber("test2"); genericTAA.setSubject("test2"); genericTAA.setVersionNumber("test2"); genericTAAService.save(genericTAA);/* w ww. j a v a2 s . c om*/ }
From source file:com.mir00r.jdbc_test.Test.java
public static void main(String[] args) { ApplicationContext ac = new ClassPathXmlApplicationContext("com/mir00r/jdbc_test/Spring-JDBC.xml"); EmployeeDao employeeDao = (EmployeeDao) ac.getBean("employeeDao"); EdSupportDao edSupportDao = (EdSupportDao) ac.getBean("edSupprotDao"); HibernateDao hibernateDao = (HibernateDao) ac.getBean("hiebernateDao"); //int res = employeeDao.SaveEmployee(new Employee("Abdur Razzak", 40000)); //int res = employeeDao.SaveEmployeeByPS(new Employee("James Bond", 40000)); // int res = employeeDao.SaveEmployeeByNPS(new Employee("Shathi", 500000)); // String ans = employeeDao.getEmployeeId(1); // System.out.println(res); // System.out.println(employeeDao.getAllEmployeeInfo(1).getName() + " " + // employeeDao.getAllEmployeeInfo(1).getSalary()); // System.out.println(employeeDao.getAllEmployeeList(1).get(0).getName() ); //System.out.println(edSupportDao.getEmployeeId(1) ); System.out.println(hibernateDao.getEmployee()); }
From source file:com.plugtree.spotplug.impl.Server.java
public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "/core.xml" });//, "/connection.xml" Configuration configuration = (Configuration) context.getBean("Configuration"); EventInputManager eventInputManager = configuration.getEventInputManager(); configuration.configure();/*from w ww.j a v a 2 s.com*/ eventInputManager.start(); }
From source file:pl.mariuszczarny.springbatchforslask.main.fromdb.CoachImport.java
/** * @param args the command line arguments */// w w w . ja va2s . com public static void main(String[] args) { fLogger.log(Level.INFO, "Import coach csv from mysql"); String[] springConfig = { "spring/batch/config/database.xml", "spring/batch/config/context.xml", "spring/batch/jobs/fromdb/coach.xml" }; ApplicationContext context = new ClassPathXmlApplicationContext(springConfig); JobLauncher jobCoachLauncher = (JobLauncher) context.getBean("jobLauncher"); Job coachJob = (Job) context.getBean("coachImportJob"); try { JobExecution execution = jobCoachLauncher.run(coachJob, new JobParameters()); fLogger.log(Level.INFO, "Exit Status : {0}", execution.getStatus()); } catch (JobParametersInvalidException e) { e.getMessage(); } catch (JobExecutionAlreadyRunningException e) { e.getMessage(); } catch (JobInstanceAlreadyCompleteException e) { e.getMessage(); } catch (JobRestartException e) { e.getMessage(); } fLogger.log(Level.INFO, "Done"); }
From source file:pl.mariuszczarny.springbatchforslask.main.fromdb.StaffImport.java
/** * @param args the command line arguments *//*ww w.ja v a2 s.co m*/ public static void main(String[] args) { fLogger.log(Level.INFO, "Import staff csv from mysql"); String[] springConfig = { "spring/batch/config/database.xml", "spring/batch/config/context.xml", "spring/batch/jobs/fromdb/staff.xml" }; ApplicationContext context = new ClassPathXmlApplicationContext(springConfig); JobLauncher jobStaffLauncher = (JobLauncher) context.getBean("jobLauncher"); Job staffJob = (Job) context.getBean("staffImportJob"); try { JobExecution execution = jobStaffLauncher.run(staffJob, new JobParameters()); fLogger.log(Level.INFO, "Exit Status : {0}", execution.getStatus()); } catch (JobParametersInvalidException e) { e.getMessage(); } catch (JobExecutionAlreadyRunningException e) { e.getMessage(); } catch (JobInstanceAlreadyCompleteException e) { e.getMessage(); } catch (JobRestartException e) { e.getMessage(); } fLogger.log(Level.INFO, "Done"); }
From source file:co.id.ipb.ilkom.training.db.CustomerServiceJpaExample.java
public static void main(String[] args) { ApplicationContext applicationContext = new AnnotationConfigApplicationContext( SpringDataJpaConfiguration.class); CustomerService customerService = applicationContext.getBean(CustomerService.class); Customer customer = new Customer(); customer.setId(10);/* ww w .j a v a 2 s.com*/ customer.setName("Fulan"); customer.setEmail("fulan@email.com"); customer.setAddress("kampus IPB"); customer.setBirthDate(new Date()); customerService.saveOrUpdate(customer); }
From source file:pl.mariuszczarny.springbatchforslask.main.fromdb.PersonImport.java
/** * @param args the command line arguments *///w ww. j a va 2 s .co m public static void main(String[] args) { fLogger.log(Level.INFO, "Import person csv from mysql"); String[] springConfig = { "spring/batch/config/database.xml", "spring/batch/config/context.xml", "spring/batch/jobs/fromdb/person.xml" }; ApplicationContext context = new ClassPathXmlApplicationContext(springConfig); JobLauncher jobPersonLauncher = (JobLauncher) context.getBean("jobLauncher"); Job personJob = (Job) context.getBean("personImportJob"); try { JobExecution execution = jobPersonLauncher.run(personJob, new JobParameters()); fLogger.log(Level.INFO, "Exit Status : {0}", execution.getStatus()); } catch (JobParametersInvalidException e) { e.getMessage(); } catch (JobExecutionAlreadyRunningException e) { e.getMessage(); } catch (JobInstanceAlreadyCompleteException e) { e.getMessage(); } catch (JobRestartException e) { e.getMessage(); } fLogger.log(Level.INFO, "Done"); }
From source file:pl.mariuszczarny.springbatchforslask.main.fromdb.PlayerImport.java
/** * @param args the command line arguments *//* w ww . j a va2 s . c om*/ public static void main(String[] args) { fLogger.log(Level.INFO, "Import player csv from mysql"); String[] springConfig = { "spring/batch/config/database.xml", "spring/batch/config/context.xml", "spring/batch/jobs/fromdb/player.xml" }; ApplicationContext context = new ClassPathXmlApplicationContext(springConfig); JobLauncher jobPlayerLauncher = (JobLauncher) context.getBean("jobLauncher"); Job playerJob = (Job) context.getBean("playerImportJob"); try { JobExecution execution = jobPlayerLauncher.run(playerJob, new JobParameters()); fLogger.log(Level.INFO, "Exit Status : {0}", execution.getStatus()); } catch (JobParametersInvalidException e) { e.getMessage(); } catch (JobExecutionAlreadyRunningException e) { e.getMessage(); } catch (JobInstanceAlreadyCompleteException e) { e.getMessage(); } catch (JobRestartException e) { e.getMessage(); } fLogger.log(Level.INFO, "Done"); }
From source file:com.mycompany.beanstests.MainApp.java
public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("/com/mycompany/beanstests/Beans.xml"); HelloWorld objA = (HelloWorld) context.getBean("helloWorld"); System.out.println(LINE);/*from w w w . j a va 2 s . c o m*/ objA.setMessage("I'm object A"); objA.getMessage(); objA.getName(); objA.getLast(); objA.setLast("Changed last"); System.out.println(LINE); HelloWorld objB = (HelloWorld) context.getBean("helloWorld"); objB.getMessage(); objB.getName(); objB.getLast(); System.out.println(LINE); HelloWorld protoA = (HelloWorld) context.getBean("helloWorldPrototype"); protoA.getMessage(); protoA.getName(); protoA.getLast(); System.out.println(LINE); HelloWorld templateA = (HelloWorld) context.getBean("helloTemplate"); templateA.getMessage(); templateA.getName(); templateA.getLast(); }
From source file:com.pos.spatobiz.app.Main.java
/** * @param args the command line arguments *///from ww w . j ava 2 s . c o m public static void main(String[] args) { // change bright color DesktopManager.setBrightColor(new Color(141, 223, 0)); // change dark color DesktopManager.setDarkColor(new Color(32, 52, 0)); // get ApplicationContext ApplicationContext applicationContext = SpringUtilities.getApplicationContext(); // get Application Application application = (Application) applicationContext.getBean("application"); // start Application DesktopManager.startApplication(application); }