├── 9781430224990.jpg ├── LICENSE.txt ├── README.md ├── Spring Recipes 2nd Ed ├── advancedioc │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── shop │ │ │ ├── BannerLoader.java │ │ │ ├── Battery.java │ │ │ ├── Cashier.java │ │ │ ├── CheckoutEvent.java │ │ │ ├── CheckoutListener.java │ │ │ ├── Disc.java │ │ │ ├── DiscountFactoryBean.java │ │ │ ├── Main.java │ │ │ ├── PathCheckingBeanPostProcessor.java │ │ │ ├── Product.java │ │ │ ├── ProductCreator.java │ │ │ ├── ProductEditor.java │ │ │ ├── ProductRanking.java │ │ │ ├── ShoppingCart.java │ │ │ ├── StorageConfig.java │ │ │ └── banner.txt │ │ └── resources │ │ ├── beans.xml │ │ ├── config.properties │ │ └── messages_en_US.properties ├── aspectj │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── calculator │ │ │ ├── ArithmeticCalculator.java │ │ │ ├── ArithmeticCalculatorImpl.java │ │ │ ├── CalculatorIntroduction.java │ │ │ ├── CalculatorLoggingAspect.java │ │ │ ├── CalculatorPointcuts.java │ │ │ ├── CalculatorValidationAspect.java │ │ │ ├── Complex.java │ │ │ ├── ComplexCachingAspect.java │ │ │ ├── ComplexCalculator.java │ │ │ ├── ComplexCalculatorImpl.java │ │ │ ├── ComplexFormatter.java │ │ │ ├── Counter.java │ │ │ ├── CounterImpl.java │ │ │ ├── LoggingRequired.java │ │ │ ├── Main.java │ │ │ ├── MaxCalculator.java │ │ │ ├── MaxCalculatorImpl.java │ │ │ ├── MinCalculator.java │ │ │ ├── MinCalculatorImpl.java │ │ │ ├── UnitCalculator.java │ │ │ └── UnitCalculatorImpl.java │ │ └── resources │ │ ├── META-INF │ │ └── aop.xml │ │ ├── beans.xml │ │ └── log4j.properties ├── beanconfig │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── sequence │ │ │ ├── DatePrefixGenerator.java │ │ │ ├── Main.java │ │ │ ├── PrefixGenerator.java │ │ │ ├── ReverseGenerator.java │ │ │ ├── Sequence.java │ │ │ ├── SequenceDao.java │ │ │ ├── SequenceDaoImpl.java │ │ │ ├── SequenceGenerator.java │ │ │ └── SequenceService.java │ │ └── resources │ │ ├── seq_declaration.xml │ │ └── seq_scan.xml ├── dataaccess │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ ├── course │ │ │ ├── Course.hbm.xml │ │ │ ├── Course.java │ │ │ ├── CourseDao.java │ │ │ ├── Main.java │ │ │ ├── hibernate │ │ │ │ └── HibernateCourseDao.java │ │ │ └── jpa │ │ │ │ └── JpaCourseDao.java │ │ │ ├── embedded │ │ │ ├── EmbeddedDatabaseBuilderExample.java │ │ │ └── EmbeddedMain.java │ │ │ └── vehicle │ │ │ ├── JdbcVehicleDao.java │ │ │ ├── Main.java │ │ │ ├── MyDuplicateKeyException.java │ │ │ ├── Vehicle.java │ │ │ ├── VehicleCountOperation.java │ │ │ ├── VehicleDao.java │ │ │ ├── VehicleInsertOperation.java │ │ │ ├── VehicleQueryOperation.java │ │ │ └── VehicleRowMapper.java │ │ └── resources │ │ ├── META-INF │ │ └── persistence.xml │ │ ├── beans-hibernate.xml │ │ ├── beans-jpa.xml │ │ ├── beans.xml │ │ ├── jdbc-ns.xml │ │ ├── sql-error-codes.xml │ │ └── vehicle.sql ├── distributedspring │ ├── deps │ │ └── pojo-archetype-1.2.3-bin.zip │ ├── gridgain │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── distributedspring │ │ │ │ └── gridgain │ │ │ │ ├── Main.java │ │ │ │ ├── MultipleSalutationTask.java │ │ │ │ ├── SalutationGridJob.java │ │ │ │ ├── SalutationService.java │ │ │ │ └── SalutationServiceImpl.java │ │ │ └── resources │ │ │ └── gridservice.xml │ ├── pom.xml │ └── terracotta │ │ ├── README.txt │ │ ├── bin │ │ └── run.sh │ │ ├── pom.xml │ │ ├── src │ │ └── main │ │ │ ├── assembly │ │ │ ├── bin.xml │ │ │ └── src.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── distributedspring │ │ │ │ └── terracotta │ │ │ │ └── customerconsole │ │ │ │ ├── MainWithSpring.java │ │ │ │ ├── entity │ │ │ │ └── Customer.java │ │ │ │ ├── service │ │ │ │ ├── CustomerService.java │ │ │ │ └── CustomerServiceImpl.java │ │ │ │ └── view │ │ │ │ └── CustomerConsole.java │ │ │ └── resources │ │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ │ └── customerconsole-context.xml │ │ └── tc-customerconsole-w-spring.xml ├── enterprise │ ├── .classpath │ ├── .project │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── replicator │ │ │ ├── Client.java │ │ │ ├── EmailErrorNotifier.java │ │ │ ├── EmailMain.java │ │ │ ├── ErrorNotifier.java │ │ │ ├── FileCopier.java │ │ │ ├── FileCopierImpl.java │ │ │ ├── FileCopierJMXImpl.java │ │ │ ├── FileReplicator.java │ │ │ ├── FileReplicatorImpl.java │ │ │ ├── FileReplicatorJMXImpl.java │ │ │ ├── JMXMain.java │ │ │ ├── QuartzMain.java │ │ │ ├── ReplicationNotificationListener.java │ │ │ └── TimerMain.java │ │ └── resources │ │ ├── beans-email.xml │ │ ├── beans-jmx-client.xml │ │ ├── beans-jmx.xml │ │ ├── beans-quartz.xml │ │ └── beans-replicator-scheduler.xml ├── flex │ ├── pom.xml │ └── src │ │ └── main │ │ ├── flex │ │ └── test1 │ │ │ ├── .actionScriptProperties │ │ │ ├── .flexProperties │ │ │ ├── .project │ │ │ ├── .settings │ │ │ └── org.eclipse.core.resources.prefs │ │ │ ├── html-template │ │ │ ├── AC_OETags.js │ │ │ ├── history │ │ │ │ ├── history.css │ │ │ │ ├── history.js │ │ │ │ └── historyFrame.html │ │ │ ├── index.template.html │ │ │ └── playerProductInstall.swf │ │ │ ├── libs │ │ │ ├── PureMVC_AS3_2_0_4.swc │ │ │ ├── as3commons-lang-0.1.swc │ │ │ ├── as3commons-logging-1.1.swc │ │ │ ├── as3commons-reflect-1.1.swc │ │ │ ├── flexlib.swc │ │ │ ├── flexunit-0.90.swc │ │ │ └── spring-actionscript-core-0.8.1.swc │ │ │ └── src │ │ │ ├── app-context1.xml │ │ │ ├── app-context2.xml │ │ │ ├── app-context3.xml │ │ │ ├── app-context4.xml │ │ │ ├── com │ │ │ ├── apress │ │ │ │ └── springrecipes │ │ │ │ │ ├── Main1WithoutMXML.as │ │ │ │ │ ├── Person.as │ │ │ │ │ ├── Pet.as │ │ │ │ │ └── auction │ │ │ │ │ ├── ItemsDisplay.mxml │ │ │ │ │ ├── PostItem.mxml │ │ │ │ │ ├── SignIn.mxml │ │ │ │ │ ├── components │ │ │ │ │ └── ItemRenderer.mxml │ │ │ │ │ └── model │ │ │ │ │ └── Item.as │ │ │ └── config │ │ │ │ └── config.xml │ │ │ ├── test1.mxml │ │ │ ├── test10.mxml │ │ │ ├── test2.mxml │ │ │ ├── test3.mxml │ │ │ ├── test4.mxml │ │ │ ├── test5.mxml │ │ │ ├── test6.mxml │ │ │ ├── test7.mxml │ │ │ ├── test8.mxml │ │ │ └── test9.mxml │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── flex │ │ │ └── auction │ │ │ ├── AuctionService.java │ │ │ ├── AuctionServiceImpl.java │ │ │ ├── integrations │ │ │ ├── FileSystemInitializer.java │ │ │ ├── FileToItemTransformer.java │ │ │ ├── ItemCreationServiceActivator.java │ │ │ └── MessageAbsorber.java │ │ │ └── model │ │ │ ├── Bid.java │ │ │ └── Item.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── .faces-config.xml.jsfdia │ │ ├── auction-context.xml │ │ ├── auction-flex-context.xml │ │ ├── crm-integration-context.xml │ │ ├── crm-service.xml │ │ ├── crm-servlet.xml │ │ ├── flex │ │ │ └── services-config.xml │ │ └── web.xml │ │ ├── crossdomain.xml │ │ ├── images │ │ ├── boat.jpg │ │ ├── car.jpg │ │ ├── carpet.jpg │ │ └── motorbike.jpg │ │ ├── index.jsp │ │ └── test.txt ├── jbpm │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── jbpm │ │ │ └── jbpm4 │ │ │ ├── CustomSpringFactory.java │ │ │ ├── Main.java │ │ │ ├── customers │ │ │ ├── Customer.java │ │ │ ├── CustomerService.java │ │ │ └── CustomerServiceImpl.java │ │ │ └── helloworld │ │ │ └── Saluter.java │ │ └── resources │ │ ├── context1.xml │ │ ├── hibernate.cfg.xml │ │ ├── info.txt │ │ ├── jbpm.cfg.xml │ │ ├── jbpm4-context.xml │ │ ├── jbpm4.properties │ │ └── process-definitions │ │ ├── HelloWorld.jpdl.xml │ │ ├── RegisterCustomer.jpdl.xml │ │ └── Registration.jpdl.xml ├── messaging │ ├── pom.xml │ ├── readme.txt │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── post │ │ │ ├── BackOffice.java │ │ │ ├── BackOfficeImpl.java │ │ │ ├── BackOfficeMain.java │ │ │ ├── FrontDesk.java │ │ │ ├── FrontDeskImpl.java │ │ │ ├── FrontDeskMain.java │ │ │ ├── Mail.java │ │ │ ├── MailListener.java │ │ │ └── MailMessageConverter.java │ │ └── resources │ │ ├── beans-back.xml │ │ └── beans-front.xml ├── mvc │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── court │ │ │ ├── domain │ │ │ ├── Member.java │ │ │ ├── PeriodicReservation.java │ │ │ ├── PeriodicReservationValidator.java │ │ │ ├── Player.java │ │ │ ├── Reservation.java │ │ │ ├── ReservationValidator.java │ │ │ ├── SportType.java │ │ │ └── SportTypeEditor.java │ │ │ ├── service │ │ │ ├── MemberService.java │ │ │ ├── MemberServiceImpl.java │ │ │ ├── ReservationNotAvailableException.java │ │ │ ├── ReservationService.java │ │ │ └── ReservationServiceImpl.java │ │ │ └── web │ │ │ ├── .MemberController.java.swp │ │ │ ├── AboutController.java │ │ │ ├── ExtensionInterceptor.java │ │ │ ├── MeasurementInterceptor.java │ │ │ ├── MemberController.java │ │ │ ├── PeriodicReservationController.java │ │ │ ├── ReservationBindingInitializer.java │ │ │ ├── ReservationFormController.java │ │ │ ├── ReservationQueryController.java │ │ │ ├── ReservationSuccessController.java │ │ │ ├── ReservationSummaryController.java │ │ │ ├── ReservationWebException.java │ │ │ ├── WelcomeController.java │ │ │ └── view │ │ │ ├── ExcelReservationSummary.java │ │ │ └── PdfReservationSummary.java │ │ ├── log4j.properties │ │ └── webapp │ │ ├── WEB-INF │ │ ├── court-service.xml │ │ ├── court-servlet.xml │ │ ├── jsp │ │ │ ├── about.jsp │ │ │ ├── error.jsp │ │ │ ├── memberList.jsp │ │ │ ├── notfound.jsp │ │ │ ├── reservationCourtForm.jsp │ │ │ ├── reservationForm.jsp │ │ │ ├── reservationNotAvailable.jsp │ │ │ ├── reservationPlayerForm.jsp │ │ │ ├── reservationQuery.jsp │ │ │ ├── reservationSuccess.jsp │ │ │ ├── reservationSummary.jsp │ │ │ ├── reservationTimeForm.jsp │ │ │ ├── reservationWebException.jsp │ │ │ └── welcome.jsp │ │ └── web.xml │ │ ├── messages.properties │ │ ├── messages_de.properties │ │ ├── secondaryviews.properties │ │ └── views.properties ├── osgi │ ├── helloworld │ │ ├── helloworld-client │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── osgi │ │ │ │ └── helloworld │ │ │ │ └── client │ │ │ │ └── Activator.java │ │ ├── helloworld-service │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── osgi │ │ │ │ └── helloworld │ │ │ │ └── service │ │ │ │ ├── Activator.java │ │ │ │ ├── GreeterService.java │ │ │ │ └── GreeterServiceImpl.java │ │ └── pom.xml │ ├── infrastructure │ │ └── felix-1.8.0 │ │ │ ├── LICENSE │ │ │ ├── LICENSE.kxml2 │ │ │ ├── NOTICE │ │ │ ├── bin │ │ │ └── felix.jar │ │ │ ├── bundle │ │ │ ├── org.apache.felix.bundlerepository-1.4.0.jar │ │ │ ├── org.apache.felix.shell-1.2.0.jar │ │ │ └── org.apache.felix.shell.tui-1.2.0.jar │ │ │ ├── conf │ │ │ └── config.properties │ │ │ └── doc │ │ │ ├── apache-felix-framework-launching-and-embedding.html │ │ │ ├── apache-felix-framework-launching-and-embedding_files │ │ │ ├── apache.png │ │ │ ├── button.html │ │ │ ├── button_data │ │ │ │ ├── 2008-usa-125x125.png │ │ │ │ └── 2009-europe-125x125.png │ │ │ ├── forbidden.gif │ │ │ ├── linkext7.gif │ │ │ ├── logo.png │ │ │ ├── mail_small.gif │ │ │ └── site.css │ │ │ ├── apache-felix-osgi-bundle-repository-obr.html │ │ │ ├── apache-felix-osgi-bundle-repository-obr_files │ │ │ ├── apache-felix-small.png │ │ │ ├── apache.png │ │ │ ├── linkext7.gif │ │ │ ├── logo.png │ │ │ ├── mail_small.gif │ │ │ ├── obr-entities.png │ │ │ ├── obr-high-level.png │ │ │ └── site.css │ │ │ ├── apache-felix-shell-service.html │ │ │ ├── apache-felix-shell-service_files │ │ │ ├── apache-felix-small.png │ │ │ ├── apache.png │ │ │ ├── button.html │ │ │ ├── button_data │ │ │ │ └── 2008-usa-125x125.png │ │ │ ├── linkext7.gif │ │ │ ├── logo.png │ │ │ ├── mail_small.gif │ │ │ └── site.css │ │ │ ├── apache-felix-shell-tui.html │ │ │ ├── apache-felix-shell-tui_files │ │ │ ├── apache-felix-small.png │ │ │ ├── apache.png │ │ │ ├── button.html │ │ │ ├── button_data │ │ │ │ └── 2008-usa-125x125.png │ │ │ ├── linkext7.gif │ │ │ ├── logo.png │ │ │ └── site.css │ │ │ ├── apache-felix-usage-documentation.html │ │ │ ├── apache-felix-usage-documentation_files │ │ │ ├── apache.png │ │ │ ├── button.html │ │ │ ├── button_data │ │ │ │ ├── 2008-usa-125x125.png │ │ │ │ └── 2009-europe-125x125.png │ │ │ ├── information.gif │ │ │ ├── linkext7.gif │ │ │ ├── logo.png │ │ │ ├── mail_small.gif │ │ │ └── site.css │ │ │ ├── changelog.txt │ │ │ ├── changelog_bundlerepository.txt │ │ │ ├── changelog_framework.txt │ │ │ ├── changelog_shell.txt │ │ │ └── changelog_shell_tui.txt │ ├── pom.xml │ ├── springdm-helloworld-client │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── osgi │ │ │ │ └── springdmhelloworld │ │ │ │ ├── Activator.java │ │ │ │ └── impl │ │ │ │ └── SpringDMGreeterClient.java │ │ │ └── resources │ │ │ ├── META-INF │ │ │ └── spring │ │ │ │ ├── bundle-context-osgi.xml │ │ │ │ ├── bundle-context.xml │ │ │ │ └── readme.txt │ │ │ └── log4j.properties │ └── springdm-helloworld-service │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── osgi │ │ │ └── helloworld │ │ │ └── service │ │ │ ├── Activator.java │ │ │ ├── GreeterService.java │ │ │ ├── GreeterServiceImpl.java │ │ │ └── GreetingRecorderService.java │ │ └── resources │ │ ├── META-INF │ │ └── spring │ │ │ ├── bundle-context.xml │ │ │ └── bundle-osgi-context.xml │ │ └── log4j.properties ├── pom.xml ├── portletmvc │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── travel │ │ │ ├── flight │ │ │ ├── Flight.java │ │ │ ├── FlightHelpController.java │ │ │ ├── FlightPreferencesController.java │ │ │ ├── FlightService.java │ │ │ ├── FlightServiceImpl.java │ │ │ └── FlightViewController.java │ │ │ ├── tour │ │ │ ├── BookingForm.java │ │ │ ├── BookingFormController.java │ │ │ ├── BookingFormValidator.java │ │ │ ├── TourService.java │ │ │ └── TourServiceImpl.java │ │ │ └── weather │ │ │ ├── WeatherController.java │ │ │ ├── WeatherService.java │ │ │ └── WeatherServiceImpl.java │ │ ├── resources │ │ └── messages.properties │ │ └── webapp │ │ └── WEB-INF │ │ ├── applicationContext.xml │ │ ├── flight-portlet.xml │ │ ├── jsp │ │ ├── bookingForm.jsp │ │ ├── bookingSuccess.jsp │ │ ├── flightDetail.jsp │ │ ├── flightHelp.jsp │ │ ├── flightList.jsp │ │ ├── flightPreferences.jsp │ │ └── weatherView.jsp │ │ ├── portlet.xml │ │ ├── tour-portlet.xml │ │ ├── weather-portlet.xml │ │ └── web.xml ├── rest │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── court │ │ │ ├── domain │ │ │ ├── FeedContent.java │ │ │ ├── Member.java │ │ │ ├── PeriodicReservation.java │ │ │ ├── PeriodicReservationValidator.java │ │ │ ├── Player.java │ │ │ ├── Reservation.java │ │ │ ├── ReservationValidator.java │ │ │ ├── SportType.java │ │ │ └── SportTypeEditor.java │ │ │ ├── feeds │ │ │ ├── AtomFeedView.java │ │ │ ├── RSSFeedView.java │ │ │ └── TournamentContent.java │ │ │ ├── service │ │ │ ├── MemberService.java │ │ │ ├── MemberServiceImpl.java │ │ │ ├── ReservationNotAvailableException.java │ │ │ ├── ReservationService.java │ │ │ └── ReservationServiceImpl.java │ │ │ └── web │ │ │ ├── AboutController.java │ │ │ ├── ExtensionInterceptor.java │ │ │ ├── FeedController.java │ │ │ ├── MeasurementInterceptor.java │ │ │ ├── MemberController.java │ │ │ ├── PeriodicReservationController.java │ │ │ ├── ReservationBindingInitializer.java │ │ │ ├── ReservationFormController.java │ │ │ ├── ReservationQueryController.java │ │ │ ├── ReservationSuccessController.java │ │ │ ├── ReservationSummaryController.java │ │ │ ├── ReservationWebException.java │ │ │ ├── RestMemberController.java │ │ │ ├── RestNewsController.java │ │ │ ├── WelcomeController.java │ │ │ └── view │ │ │ ├── ExcelReservationSummary.java │ │ │ └── PdfReservationSummary.java │ │ ├── resources │ │ ├── log4j.properties │ │ ├── messages.properties │ │ └── messages_de.properties │ │ └── webapp │ │ ├── WEB-INF │ │ ├── court-service.xml │ │ ├── court-servlet.xml │ │ ├── jsp │ │ │ ├── about.jsp │ │ │ ├── error.jsp │ │ │ ├── memberList.jsp │ │ │ ├── nationalweathertemplate.jsp │ │ │ ├── newstemplate.jsp │ │ │ ├── notfound.jsp │ │ │ ├── reservationCourtForm.jsp │ │ │ ├── reservationForm.jsp │ │ │ ├── reservationNotAvailable.jsp │ │ │ ├── reservationPlayerForm.jsp │ │ │ ├── reservationQuery.jsp │ │ │ ├── reservationSuccess.jsp │ │ │ ├── reservationSummary.jsp │ │ │ ├── reservationTimeForm.jsp │ │ │ ├── reservationWebException.jsp │ │ │ ├── welcome.jsp │ │ │ └── worldnewstemplate.jsp │ │ └── web.xml │ │ ├── secondaryviews.properties │ │ └── views.properties ├── rpc │ ├── pom.xml │ ├── post-ejb2 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── post │ │ │ │ ├── FrontDesk.java │ │ │ │ ├── FrontDeskImpl.java │ │ │ │ ├── FrontDeskMain.java │ │ │ │ ├── PostageService.java │ │ │ │ ├── PostageServiceBean.java │ │ │ │ ├── PostageServiceHome.java │ │ │ │ ├── PostageServiceImpl.java │ │ │ │ └── PostageServiceRemote.java │ │ │ └── resources │ │ │ ├── META-INF │ │ │ └── ejb-jar.xml │ │ │ ├── beans-ejb.xml │ │ │ └── beans-front.xml │ ├── post-ejb3 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── post │ │ │ │ ├── FrontDesk.java │ │ │ │ ├── FrontDeskImpl.java │ │ │ │ ├── FrontDeskMain.java │ │ │ │ ├── PostageService.java │ │ │ │ └── PostageServiceBean.java │ │ │ └── resources │ │ │ └── beans-front.xml │ ├── weather-remoting-soap-standalone │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── weather │ │ │ │ ├── StandaloneServer.java │ │ │ │ ├── TemperatureInfo.java │ │ │ │ ├── WeatherService.java │ │ │ │ ├── WeatherServiceClient.java │ │ │ │ └── WeatherServiceImpl.java │ │ │ └── resources │ │ │ └── standalone-server.xml │ ├── weather-remoting-soap │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── weather │ │ │ │ ├── Client.java │ │ │ │ ├── TemperatureInfo.java │ │ │ │ ├── WeatherService.java │ │ │ │ ├── WeatherServiceClient.java │ │ │ │ └── WeatherServiceImpl.java │ │ │ ├── resources │ │ │ └── client.xml │ │ │ └── webapp │ │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ │ └── WEB-INF │ │ │ ├── applicationContext.xml │ │ │ ├── weather-servlet.xml │ │ │ └── web.xml │ ├── weather-remoting │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── weather │ │ │ │ ├── Client.java │ │ │ │ ├── RmiServer.java │ │ │ │ ├── TemperatureInfo.java │ │ │ │ ├── WeatherService.java │ │ │ │ ├── WeatherServiceClient.java │ │ │ │ └── WeatherServiceImpl.java │ │ │ ├── resources │ │ │ ├── client.xml │ │ │ └── rmi-server.xml │ │ │ └── webapp │ │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ │ └── WEB-INF │ │ │ ├── applicationContext.xml │ │ │ ├── weather-servlet.xml │ │ │ └── web.xml │ └── weather-ws │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── weather │ │ │ ├── Client.java │ │ │ ├── DateFieldHandler.java │ │ │ ├── GetTemperaturesRequest.java │ │ │ ├── GetTemperaturesResponse.java │ │ │ ├── TemperatureDom4jEndpoint.java │ │ │ ├── TemperatureInfo.java │ │ │ ├── TemperatureMarshallingEndpoint.java │ │ │ ├── WeatherService.java │ │ │ ├── WeatherServiceClient.java │ │ │ ├── WeatherServiceImpl.java │ │ │ └── WeatherServiceProxy.java │ │ ├── resources │ │ ├── client.xml │ │ ├── mapping.xml │ │ ├── request.xml │ │ └── response.xml │ │ └── webapp │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ └── WEB-INF │ │ ├── temperature.xsd │ │ ├── weather-servlet.xml │ │ └── web.xml ├── security │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── board │ │ │ ├── domain │ │ │ └── Message.java │ │ │ ├── security │ │ │ └── IpAddressVoter.java │ │ │ ├── service │ │ │ ├── MessageBoardService.java │ │ │ └── MessageBoardServiceImpl.java │ │ │ └── web │ │ │ ├── MessageDeleteController.java │ │ │ ├── MessageListController.java │ │ │ └── MessagePostController.java │ │ └── webapp │ │ └── WEB-INF │ │ ├── board-acl.xml │ │ ├── board-security.xml │ │ ├── board-service.xml │ │ ├── board-servlet.xml │ │ ├── jsp │ │ ├── login.jsp │ │ ├── messageList.jsp │ │ └── messagePost.jsp │ │ └── web.xml ├── springbatch │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── springbatch │ │ │ ├── UserRegistration.java │ │ │ ├── UserRegistrationService.java │ │ │ ├── scheduler │ │ │ └── ScheduledMain.java │ │ │ ├── solution1 │ │ │ └── Main.java │ │ │ └── solution2 │ │ │ ├── ConditionalTasklet.java │ │ │ ├── HoroscopeDecider.java │ │ │ ├── RetryableUserRegistrationServiceItemWriter.java │ │ │ ├── UserRegistrationItemReader.java │ │ │ ├── UserRegistrationServiceItemWriter.java │ │ │ └── UserRegistrationValidationItemProcessor.java │ │ └── resources │ │ ├── batch.properties │ │ ├── batch.xml │ │ ├── sample │ │ └── registrations.csv │ │ ├── scheduled_batch.xml │ │ ├── solution1.xml │ │ ├── solution2.xml │ │ ├── solution3.xml │ │ └── sql │ │ ├── create_schema.sql │ │ ├── drop_all.sql │ │ ├── reset_user_registration.sql │ │ └── truncate_all.sql ├── springintegration │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── springintegration │ │ │ ├── AdditionService.java │ │ │ ├── Customer.java │ │ │ ├── CustomerBatchFileSplitter.java │ │ │ ├── CustomerCreditScoreRouter.java │ │ │ ├── CustomerDeletionServiceActivator.java │ │ │ ├── CustomerIdToCustomerTransformer.java │ │ │ ├── DefaultCustomerServiceActivator.java │ │ │ ├── DefaultErrorHandlingServiceActivator.java │ │ │ ├── InboundCustomerServiceActivator.java │ │ │ ├── InboundFileMessageServiceActivator.java │ │ │ ├── InboundFileMessageServiceActivatorWithHeadersMap.java │ │ │ ├── InboundHelloWorldFileMessageProcessor.java │ │ │ ├── InboundHelloWorldJMSMessageProcessor.java │ │ │ ├── InboundHelloWorldJMSMessageProcessorHeaderInterrogationExample.java │ │ │ ├── InboundJMSMessageToCustomerTransformer.java │ │ │ ├── InboundJMSMessageToCustomerWithExtraMetadataTransformer.java │ │ │ ├── Main.java │ │ │ ├── MessagePayloadAggregator.java │ │ │ ├── MyCustomException.java │ │ │ ├── Operands.java │ │ │ ├── ServiceActivatorThatSpecifiesErrorChannel.java │ │ │ ├── SimpleMessagingGatewayExample.java │ │ │ ├── myholiday │ │ │ ├── HotelReservation.java │ │ │ ├── HotelReservationSearch.java │ │ │ ├── Main.java │ │ │ ├── VacationService.java │ │ │ └── VacationServiceImpl.java │ │ │ └── twitter │ │ │ ├── Tweet.java │ │ │ ├── TwitterMessageConstants.java │ │ │ ├── TwitterMessageOutput.java │ │ │ ├── TwitterMessageProducer.java │ │ │ └── TwitterMessageSource.java │ │ └── resources │ │ ├── 01-1-integratingtwosystemsusingjms.xml │ │ ├── 01-integratingtwosystemsusingjms.xml │ │ ├── 03-integratingtwosystemsusingafilesystem.xml │ │ ├── 04-1-transformingamessagefromonetypetoanother.xml │ │ ├── 04-transformingamessagefromonetypetoanother.xml │ │ ├── 05-1-errorhandlingusingspringintegration.xml │ │ ├── 05-errorhandlingusingspringintegration.xml │ │ ├── 06-1-forkingintegrationcontrolsplittersandaggregators.xml │ │ ├── 06-forkingintegrationcontrolsplittersandaggregators.xml │ │ ├── 07-conditionalroutingwithrouters.xml │ │ ├── 08-1-adaptingexternalsystemstothebus.xml │ │ ├── 08-2-adaptingexternalsystemstothebus.xml │ │ ├── 08-adaptingexternalsystemstothebus.properties │ │ ├── 09-1-gateways_client.xml │ │ ├── 09-1-gateways_service.xml │ │ ├── 09-1-sicomponents.xml │ │ └── 09-gateways.xml ├── springintro │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── hello │ │ │ ├── HelloWorld.java │ │ │ ├── Holiday.java │ │ │ └── Main.java │ │ └── resources │ │ └── beans.xml ├── springweb │ ├── city-dwr │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── city │ │ │ │ ├── CityService.java │ │ │ │ └── CityServiceImpl.java │ │ │ └── webapp │ │ │ ├── WEB-INF │ │ │ ├── applicationContext.xml │ │ │ └── web.xml │ │ │ └── distance.html │ ├── city-jsf │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── city │ │ │ │ ├── CityService.java │ │ │ │ ├── CityServiceImpl.java │ │ │ │ └── jsf │ │ │ │ └── DistanceBean.java │ │ │ ├── resources │ │ │ └── log4j.properties │ │ │ └── webapp │ │ │ ├── WEB-INF │ │ │ ├── applicationContext.xml │ │ │ ├── faces-config.xml │ │ │ └── web.xml │ │ │ └── distance.jsp │ ├── city-servlets │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── city │ │ │ │ ├── CityService.java │ │ │ │ ├── CityServiceImpl.java │ │ │ │ ├── CityServiceRequestAuditor.java │ │ │ │ ├── filter │ │ │ │ └── CityServiceRequestFilter.java │ │ │ │ └── servlet │ │ │ │ ├── DistanceHttpRequestHandler.java │ │ │ │ └── DistanceServlet.java │ │ │ └── webapp │ │ │ └── WEB-INF │ │ │ ├── applicationContext.xml │ │ │ ├── jsp │ │ │ └── distance.jsp │ │ │ └── web.xml │ ├── city-struts │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── city │ │ │ │ ├── CityService.java │ │ │ │ ├── CityServiceImpl.java │ │ │ │ └── struts │ │ │ │ ├── DistanceAction.java │ │ │ │ └── DistanceForm.java │ │ │ └── webapp │ │ │ └── WEB-INF │ │ │ ├── action-servlet.xml │ │ │ ├── applicationContext.xml │ │ │ ├── jsp │ │ │ └── distance.jsp │ │ │ ├── struts-config.xml │ │ │ └── web.xml │ └── pom.xml ├── testing │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── bank │ │ │ │ └── com │ │ │ │ └── apress │ │ │ │ └── springrecipes │ │ │ │ └── bank │ │ │ │ ├── Account.java │ │ │ │ ├── AccountDao.java │ │ │ │ ├── AccountNotFoundException.java │ │ │ │ ├── AccountService.java │ │ │ │ ├── AccountServiceImpl.java │ │ │ │ ├── AccountServiceImplMockTests.java │ │ │ │ ├── AccountServiceImplStubTests.java │ │ │ │ ├── AccountServiceTests.java │ │ │ │ ├── DepositController.java │ │ │ │ ├── DuplicateAccountException.java │ │ │ │ ├── InMemoryAccountDao.java │ │ │ │ ├── InsufficientBalanceException.java │ │ │ │ ├── InterestCalculator.java │ │ │ │ ├── JdbcAccountDao.java │ │ │ │ └── SimpleInterestCalculator.java │ │ └── resources │ │ │ ├── bank.sql │ │ │ └── beans.xml │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── bank │ │ │ ├── AccountServiceJUnit38ContextTests.java │ │ │ ├── AccountServiceJUnit38LegacyTests.java │ │ │ ├── AccountServiceJUnit4ContextTests.java │ │ │ ├── AccountServiceTestNGContextTests.java │ │ │ ├── DepositControllerTests.java │ │ │ ├── InMemoryAccountDaoTests.java │ │ │ ├── SimpleInterestCalculatorJUnit38Tests.java │ │ │ ├── SimpleInterestCalculatorJUnit4Tests.java │ │ │ └── SimpleInterestCalculatorTestNG5Tests.java │ │ └── resources │ │ ├── bank.sql │ │ └── beans.xml ├── transactions │ ├── pom.xml │ ├── readme.txt │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── bookshop │ │ │ └── spring │ │ │ ├── Book.java │ │ │ ├── BookShop.java │ │ │ ├── BookShopCashier.java │ │ │ ├── Cashier.java │ │ │ ├── JdbcBookShop.java │ │ │ ├── Main.java │ │ │ └── TransactionalJdbcBookShop.java │ │ └── resources │ │ ├── aspectj-beans.xml │ │ ├── bookstore.sql │ │ ├── classic-beans.xml │ │ └── spring-beans.xml └── web_flow │ ├── jsf │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── library │ │ │ ├── domain │ │ │ └── BorrowingRecord.java │ │ │ └── web │ │ │ └── PropertyEditors.java │ │ ├── resources │ │ └── META-INF │ │ │ └── persistence.xml │ │ └── webapp │ │ ├── WEB-INF │ │ ├── .faces-config.xml.jsfdia │ │ ├── faces-config.xml │ │ ├── library-security.xml │ │ ├── library-service.xml │ │ ├── library-servlet.xml │ │ ├── library-webflow.xml │ │ ├── template.xhtml │ │ └── web.xml │ │ └── flows │ │ └── borrowBook │ │ ├── borrowBook-flow.xml │ │ ├── borrowForm.xhtml │ │ └── borrowReview.xhtml │ ├── jsf_richfaces │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── apress │ │ │ └── springrecipes │ │ │ └── signup │ │ │ └── web │ │ │ └── CounterBean.java │ │ └── webapp │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ ├── WEB-INF │ │ ├── .faces-config.xml.jsfdia │ │ ├── counter-servlet.xml │ │ ├── counter-webflow.xml │ │ ├── faces-config.xml │ │ ├── template │ │ │ └── default.xhtml │ │ └── web.xml │ │ └── flows │ │ └── counter │ │ ├── counter-flow.xml │ │ └── counter.xhtml │ ├── pom.xml │ └── web_flow_mvc │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── apress │ │ └── springrecipes │ │ └── library │ │ ├── domain │ │ ├── Book.java │ │ ├── BookCriteria.java │ │ └── BorrowingRecord.java │ │ ├── service │ │ ├── BookService.java │ │ ├── BookServiceImpl.java │ │ ├── LibraryService.java │ │ └── LibraryServiceImpl.java │ │ └── web │ │ └── PropertyEditors.java │ ├── resources │ └── META-INF │ │ └── persistence.xml │ └── webapp │ ├── WEB-INF │ ├── .faces-config.xml.jsfdia │ ├── flows │ │ ├── bookDetails │ │ │ ├── bookDetails.jsp │ │ │ └── bookDetails.xml │ │ ├── bookSearch │ │ │ ├── bookCriteria.jsp │ │ │ ├── bookList.jsp │ │ │ └── bookSearch.xml │ │ ├── borrowBook │ │ │ ├── borrowBook.xml │ │ │ ├── borrowForm.jsp │ │ │ └── borrowReview.jsp │ │ └── welcome │ │ │ ├── introduction.jsp │ │ │ ├── menu.jsp │ │ │ ├── welcome.jsp │ │ │ └── welcome.xml │ ├── library-security.xml │ ├── library-service.xml │ ├── library-servlet.xml │ ├── library-webflow.xml │ └── web.xml │ └── index.jsp └── contributing.md /9781430224990.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/9781430224990.jpg -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/LICENSE.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Apress Source Code 2 | 3 | This repository accompanies [*Spring Recipes*](http://www.apress.com/9781430224990) by Gary Mak, Daniel Rubio, and Josh Long (Apress, 2010). 4 | 5 | ![Cover image](9781430224990.jpg) 6 | 7 | Download the files as a zip using the green button, or clone the repository to your machine using Git. 8 | 9 | ## Releases 10 | 11 | Release v1.0 corresponds to the code in the published book, without corrections or updates. 12 | 13 | ## Contributions 14 | 15 | See the file Contributing.md for more information on how you can contribute to this repository. 16 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/advancedioc/src/main/java/com/apress/springrecipes/shop/Battery.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.shop; 2 | 3 | public class Battery extends Product { 4 | 5 | private boolean rechargeable; 6 | 7 | public Battery() { 8 | super(); 9 | } 10 | 11 | public Battery(String name, double price) { 12 | super(name, price); 13 | } 14 | 15 | public boolean isRechargeable() { 16 | return rechargeable; 17 | } 18 | 19 | public void setRechargeable(boolean rechargeable) { 20 | this.rechargeable = rechargeable; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/advancedioc/src/main/java/com/apress/springrecipes/shop/CheckoutEvent.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.shop; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.context.ApplicationEvent; 6 | 7 | public class CheckoutEvent extends ApplicationEvent { 8 | 9 | private double amount; 10 | private Date time; 11 | 12 | public CheckoutEvent(Object source, double amount, Date time) { 13 | super(source); 14 | this.amount = amount; 15 | this.time = time; 16 | } 17 | 18 | public double getAmount() { 19 | return amount; 20 | } 21 | 22 | public Date getTime() { 23 | return time; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/advancedioc/src/main/java/com/apress/springrecipes/shop/CheckoutListener.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.shop; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.context.ApplicationEvent; 6 | import org.springframework.context.ApplicationListener; 7 | 8 | public class CheckoutListener implements ApplicationListener { 9 | 10 | public void onApplicationEvent(ApplicationEvent event) { 11 | if (event instanceof CheckoutEvent) { 12 | double amount = ((CheckoutEvent) event).getAmount(); 13 | Date time = ((CheckoutEvent) event).getTime(); 14 | 15 | // Do anything you like with the checkout amount and time 16 | System.out.println("Checkout event [" + amount + ", " + time + "]"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/advancedioc/src/main/java/com/apress/springrecipes/shop/Disc.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.shop; 2 | 3 | public class Disc extends Product { 4 | 5 | private int capacity; 6 | 7 | public Disc() { 8 | super(); 9 | } 10 | 11 | public Disc(String name, double price) { 12 | super(name, price); 13 | } 14 | 15 | public int getCapacity() { 16 | return capacity; 17 | } 18 | 19 | public void setCapacity(int capacity) { 20 | this.capacity = capacity; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/advancedioc/src/main/java/com/apress/springrecipes/shop/DiscountFactoryBean.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.shop; 2 | 3 | import org.springframework.beans.factory.config.AbstractFactoryBean; 4 | 5 | public class DiscountFactoryBean extends AbstractFactoryBean { 6 | 7 | private Product product; 8 | private double discount; 9 | 10 | public void setProduct(Product product) { 11 | this.product = product; 12 | } 13 | 14 | public void setDiscount(double discount) { 15 | this.discount = discount; 16 | } 17 | 18 | public Class getObjectType() { 19 | return product.getClass(); 20 | } 21 | 22 | protected Object createInstance() throws Exception { 23 | product.setPrice(product.getPrice() * (1 - discount)); 24 | return product; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/advancedioc/src/main/java/com/apress/springrecipes/shop/ProductCreator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.shop; 2 | 3 | import java.util.Map; 4 | 5 | public class ProductCreator { 6 | 7 | private Map products; 8 | 9 | public void setProducts(Map products) { 10 | this.products = products; 11 | } 12 | 13 | public Product createProduct(String productId) { 14 | Product product = products.get(productId); 15 | if (product != null) { 16 | return product; 17 | } 18 | throw new IllegalArgumentException("Unknown product"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/advancedioc/src/main/java/com/apress/springrecipes/shop/ProductRanking.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.shop; 2 | 3 | import java.util.Date; 4 | 5 | public class ProductRanking { 6 | 7 | private Product bestSeller; 8 | private Date fromDate; 9 | private Date toDate; 10 | 11 | public Product getBestSeller() { 12 | return bestSeller; 13 | } 14 | 15 | public Date getFromDate() { 16 | return fromDate; 17 | } 18 | 19 | public Date getToDate() { 20 | return toDate; 21 | } 22 | 23 | public void setBestSeller(Product bestSeller) { 24 | this.bestSeller = bestSeller; 25 | } 26 | 27 | public void setFromDate(Date fromDate) { 28 | this.fromDate = fromDate; 29 | } 30 | 31 | public void setToDate(Date toDate) { 32 | this.toDate = toDate; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/advancedioc/src/main/java/com/apress/springrecipes/shop/ShoppingCart.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.shop; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class ShoppingCart { 7 | 8 | private List items = new ArrayList(); 9 | 10 | public void addItem(Product item) { 11 | items.add(item); 12 | } 13 | 14 | public List getItems() { 15 | return items; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/advancedioc/src/main/java/com/apress/springrecipes/shop/StorageConfig.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.shop; 2 | 3 | public interface StorageConfig { 4 | 5 | public String getPath(); 6 | } 7 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/advancedioc/src/main/java/com/apress/springrecipes/shop/banner.txt: -------------------------------------------------------------------------------- 1 | *********************** 2 | * Welcome to My Shop! * 3 | *********************** 4 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/advancedioc/src/main/resources/config.properties: -------------------------------------------------------------------------------- 1 | cashier.path=c:/cashier -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/advancedioc/src/main/resources/messages_en_US.properties: -------------------------------------------------------------------------------- 1 | alert.checkout=A shopping cart costing {0} dollars has been checked out at {1}. -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/java/com/apress/springrecipes/calculator/ArithmeticCalculator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.calculator; 2 | 3 | public interface ArithmeticCalculator { 4 | 5 | public double add(double a, double b); 6 | public double sub(double a, double b); 7 | public double mul(double a, double b); 8 | public double div(double a, double b); 9 | } 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/java/com/apress/springrecipes/calculator/CalculatorPointcuts.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.calculator; 2 | 3 | import org.aspectj.lang.annotation.Aspect; 4 | import org.aspectj.lang.annotation.Pointcut; 5 | 6 | @Aspect 7 | public class CalculatorPointcuts { 8 | 9 | @Pointcut("within(ArithmeticCalculator+)") 10 | public void arithmeticOperation() {} 11 | 12 | @Pointcut("within(UnitCalculator+)") 13 | public void unitOperation() {} 14 | 15 | @Pointcut("arithmeticOperation() || unitOperation()") 16 | public void loggingOperation() {} 17 | 18 | @Pointcut("execution(* *.*(..)) && target(target) && args(a,b)") 19 | public void parameterPointcut(Object target, double a, double b) {} 20 | } 21 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/java/com/apress/springrecipes/calculator/CalculatorValidationAspect.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.calculator; 2 | 3 | import org.aspectj.lang.JoinPoint; 4 | import org.aspectj.lang.annotation.Aspect; 5 | import org.aspectj.lang.annotation.Before; 6 | import org.springframework.core.annotation.Order; 7 | 8 | @Aspect 9 | @Order(0) 10 | public class CalculatorValidationAspect { 11 | 12 | @Before("execution(* *.*(double, double))") 13 | public void validateBefore(JoinPoint joinPoint) { 14 | for (Object arg : joinPoint.getArgs()) { 15 | validate((Double) arg); 16 | } 17 | } 18 | 19 | private void validate(double a) { 20 | if (a < 0) { 21 | throw new IllegalArgumentException("Positive numbers only"); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/java/com/apress/springrecipes/calculator/ComplexCalculator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.calculator; 2 | 3 | public interface ComplexCalculator { 4 | 5 | public Complex add(Complex a, Complex b); 6 | public Complex sub(Complex a, Complex b); 7 | } 8 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/java/com/apress/springrecipes/calculator/ComplexCalculatorImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.calculator; 2 | 3 | public class ComplexCalculatorImpl implements ComplexCalculator { 4 | 5 | public Complex add(Complex a, Complex b) { 6 | Complex result = new Complex(a.getReal() + b.getReal(), 7 | a.getImaginary() + b.getImaginary()); 8 | System.out.println(a + " + " + b + " = " + result); 9 | return result; 10 | } 11 | 12 | public Complex sub(Complex a, Complex b) { 13 | Complex result = new Complex(a.getReal() - b.getReal(), 14 | a.getImaginary() - b.getImaginary()); 15 | System.out.println(a + " - " + b + " = " + result); 16 | return result; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/java/com/apress/springrecipes/calculator/ComplexFormatter.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.calculator; 2 | 3 | public class ComplexFormatter { 4 | 5 | private String pattern; 6 | 7 | public void setPattern(String pattern) { 8 | this.pattern = pattern; 9 | } 10 | 11 | public String format(Complex complex) { 12 | return pattern.replaceAll("a", Integer.toString(complex.getReal())) 13 | .replaceAll("b", Integer.toString(complex.getImaginary())); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/java/com/apress/springrecipes/calculator/Counter.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.calculator; 2 | 3 | public interface Counter { 4 | 5 | public void increase(); 6 | public int getCount(); 7 | } 8 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/java/com/apress/springrecipes/calculator/CounterImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.calculator; 2 | 3 | public class CounterImpl implements Counter { 4 | 5 | private int count; 6 | 7 | public void increase() { 8 | count++; 9 | } 10 | 11 | public int getCount() { 12 | return count; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/java/com/apress/springrecipes/calculator/LoggingRequired.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.calculator; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | @Target( { ElementType.METHOD, ElementType.TYPE }) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Documented 12 | public @interface LoggingRequired { 13 | } 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/java/com/apress/springrecipes/calculator/MaxCalculator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.calculator; 2 | 3 | public interface MaxCalculator { 4 | 5 | public double max(double a, double b); 6 | } 7 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/java/com/apress/springrecipes/calculator/MaxCalculatorImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.calculator; 2 | 3 | public class MaxCalculatorImpl implements MaxCalculator { 4 | 5 | public double max(double a, double b) { 6 | double result = (a >= b) ? a : b; 7 | System.out.println("max(" + a + ", " + b + ") = " + result); 8 | return result; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/java/com/apress/springrecipes/calculator/MinCalculator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.calculator; 2 | 3 | public interface MinCalculator { 4 | 5 | public double min(double a, double b); 6 | } 7 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/java/com/apress/springrecipes/calculator/MinCalculatorImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.calculator; 2 | 3 | public class MinCalculatorImpl implements MinCalculator { 4 | 5 | public double min(double a, double b) { 6 | double result = (a <= b) ? a : b; 7 | System.out.println("min(" + a + ", " + b + ") = " + result); 8 | return result; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/java/com/apress/springrecipes/calculator/UnitCalculator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.calculator; 2 | 3 | public interface UnitCalculator { 4 | 5 | public double kilogramToPound(double kilogram); 6 | public double kilometerToMile(double kilometer); 7 | } 8 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/java/com/apress/springrecipes/calculator/UnitCalculatorImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.calculator; 2 | 3 | public class UnitCalculatorImpl implements UnitCalculator { 4 | 5 | public double kilogramToPound(double kilogram) { 6 | double pound = kilogram * 2.2; 7 | System.out.println(kilogram + " kilogram = " + pound + " pound"); 8 | return pound; 9 | } 10 | 11 | public double kilometerToMile(double kilometer) { 12 | double mile = kilometer * 0.62; 13 | System.out.println(kilometer + " kilometer = " + mile + " mile"); 14 | return mile; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/resources/META-INF/aop.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/aspectj/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | ### direct log messages to stdout ### 2 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 3 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 4 | log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%n 5 | 6 | ### set root logger level ### 7 | log4j.rootLogger=error, stdout 8 | 9 | ### set application logger level ### 10 | log4j.logger.com.apress.springrecipes.calculator=info 11 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/beanconfig/src/main/java/com/apress/springrecipes/sequence/DatePrefixGenerator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.sequence; 2 | 3 | import java.text.DateFormat; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 6 | 7 | public class DatePrefixGenerator implements PrefixGenerator { 8 | 9 | private DateFormat formatter; 10 | 11 | public void setPattern(String pattern) { 12 | this.formatter = new SimpleDateFormat(pattern); 13 | } 14 | 15 | public String getPrefix() { 16 | return formatter.format(new Date()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/beanconfig/src/main/java/com/apress/springrecipes/sequence/Main.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.sequence; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | public class Main { 7 | 8 | public static void main(String[] args) { 9 | ApplicationContext context = 10 | new ClassPathXmlApplicationContext("beans.xml"); 11 | 12 | SequenceGenerator generator = 13 | (SequenceGenerator) context.getBean("sequenceGenerator"); 14 | 15 | System.out.println(generator.getSequence()); 16 | System.out.println(generator.getSequence()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/beanconfig/src/main/java/com/apress/springrecipes/sequence/PrefixGenerator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.sequence; 2 | 3 | public interface PrefixGenerator { 4 | 5 | public String getPrefix(); 6 | } 7 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/beanconfig/src/main/java/com/apress/springrecipes/sequence/ReverseGenerator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.sequence; 2 | 3 | public class ReverseGenerator { 4 | 5 | private int initial; 6 | 7 | public void setInitial(int initial) { 8 | this.initial = initial; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/beanconfig/src/main/java/com/apress/springrecipes/sequence/SequenceDao.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.sequence; 2 | 3 | public interface SequenceDao { 4 | 5 | public Sequence getSequence(String sequenceId); 6 | public int getNextValue(String sequenceId); 7 | } 8 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/beanconfig/src/main/java/com/apress/springrecipes/sequence/SequenceService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.sequence; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | 6 | @Service("sequenceService") 7 | public class SequenceService { 8 | 9 | private SequenceDao sequenceDao; 10 | 11 | @Autowired 12 | public void setSequenceDao(SequenceDao sequenceDao) { 13 | this.sequenceDao = sequenceDao; 14 | } 15 | 16 | public String generate(String sequenceId) { 17 | Sequence sequence = sequenceDao.getSequence(sequenceId); 18 | int value = sequenceDao.getNextValue(sequenceId); 19 | return sequence.getPrefix() + value + sequence.getSuffix(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/dataaccess/src/main/java/com/apress/springrecipes/course/Course.hbm.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/dataaccess/src/main/java/com/apress/springrecipes/course/CourseDao.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.course; 2 | 3 | import java.util.List; 4 | 5 | 6 | public interface CourseDao { 7 | public void store(Course course); 8 | 9 | public void delete(Long courseId); 10 | 11 | public Course findById(Long courseId); 12 | 13 | public List findAll(); 14 | } 15 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/dataaccess/src/main/java/com/apress/springrecipes/embedded/EmbeddedMain.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.embedded; 2 | 3 | import org.springframework.context.support.ClassPathXmlApplicationContext; 4 | 5 | import javax.sql.DataSource; 6 | 7 | /** 8 | * Demonstrates using the embedded database functionality inside of the Spring framework. 9 | * 10 | */ 11 | public class EmbeddedMain { 12 | public static void main (String [] args) throws Throwable { 13 | 14 | ClassPathXmlApplicationContext classPathXmlApplicationContext = 15 | new ClassPathXmlApplicationContext("jdbc-ns.xml"); 16 | classPathXmlApplicationContext.start(); 17 | 18 | DataSource dataSource = classPathXmlApplicationContext.getBean(DataSource.class); 19 | 20 | System.out.println( "buildDataSource: " + dataSource ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/dataaccess/src/main/java/com/apress/springrecipes/vehicle/MyDuplicateKeyException.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.vehicle; 2 | 3 | import org.springframework.dao.DataIntegrityViolationException; 4 | 5 | 6 | public class MyDuplicateKeyException extends DataIntegrityViolationException { 7 | public MyDuplicateKeyException(String msg) { 8 | super(msg); 9 | } 10 | 11 | public MyDuplicateKeyException(String msg, Throwable cause) { 12 | super(msg, cause); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/dataaccess/src/main/java/com/apress/springrecipes/vehicle/VehicleCountOperation.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.vehicle; 2 | 3 | import org.springframework.jdbc.object.SqlFunction; 4 | 5 | import javax.sql.DataSource; 6 | 7 | 8 | public class VehicleCountOperation extends SqlFunction { 9 | public VehicleCountOperation(DataSource dataSource) { 10 | setDataSource(dataSource); 11 | setSql("SELECT COUNT(*) FROM VEHICLE"); 12 | compile(); 13 | } 14 | 15 | public int perform() { 16 | return run(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/dataaccess/src/main/java/com/apress/springrecipes/vehicle/VehicleDao.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.vehicle; 2 | 3 | import java.util.List; 4 | 5 | 6 | public interface VehicleDao { 7 | public void insert(Vehicle vehicle); 8 | 9 | public void update(Vehicle vehicle); 10 | 11 | public void delete(Vehicle vehicle); 12 | 13 | public Vehicle findByVehicleNo(String vehicleNo); 14 | 15 | public void insertBatch(List vehicles); 16 | 17 | public List findAll(); 18 | 19 | public String getColor(String vehicleNo); 20 | 21 | public int countAll(); 22 | } 23 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/dataaccess/src/main/java/com/apress/springrecipes/vehicle/VehicleRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.vehicle; 2 | 3 | import org.springframework.jdbc.core.simple.ParameterizedRowMapper; 4 | 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | 8 | 9 | public class VehicleRowMapper implements ParameterizedRowMapper { 10 | public Vehicle mapRow(ResultSet rs, int rowNum) throws SQLException { 11 | Vehicle vehicle = new Vehicle(); 12 | vehicle.setVehicleNo(rs.getString("VEHICLE_NO")); 13 | vehicle.setColor(rs.getString("COLOR")); 14 | vehicle.setWheel(rs.getInt("WHEEL")); 15 | vehicle.setSeat(rs.getInt("SEAT")); 16 | 17 | return vehicle; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/dataaccess/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/dataaccess/src/main/resources/jdbc-ns.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/dataaccess/src/main/resources/vehicle.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE VEHICLE ( 2 | VEHICLE_NO VARCHAR(10) NOT NULL, 3 | COLOR VARCHAR(10), 4 | WHEEL INT, 5 | SEAT INT, 6 | PRIMARY KEY (VEHICLE_NO) 7 | ); 8 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/distributedspring/deps/pojo-archetype-1.2.3-bin.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/distributedspring/deps/pojo-archetype-1.2.3-bin.zip -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/distributedspring/gridgain/src/main/java/com/apress/springrecipes/distributedspring/gridgain/SalutationService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.distributedspring.gridgain; 2 | 3 | public interface SalutationService { 4 | String saluteSomeoneInForeignLanguage(String recipient); 5 | 6 | String[] saluteManyPeopleInRandomForeignLanguage(String[] recipients); 7 | } 8 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/distributedspring/terracotta/README.txt: -------------------------------------------------------------------------------- 1 | How to run these examples: 2 | 3 | the manual way (using the dso-env.sh and so on) works fine for production. However, during development there are better, more convenient options, not the least of which is the Maven Terracotta plugin. 4 | 5 | To run the examples you need only change the configuration file that's used and then run the server and then as many clients as you want. 6 | 7 | I've included in this folder's bin directory a script called run.sh. This in turn simpply runs Maven and will invoke a server if need be. 8 | 9 | usage looks like: 10 | 11 | ----------------------------------------------------------- 12 | 13 | cd bin; 14 | chmod a+x run.sh ; 15 | ./run.sh 16 | 17 | ----------------------------------------------------------- 18 | 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/distributedspring/terracotta/bin/run.sh: -------------------------------------------------------------------------------- 1 | mvn -f ../pom.xml -Dtcconfig=tc-customerconsole-w-spring.xml clean install tc:run ; 2 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/distributedspring/terracotta/src/main/java/com/apress/springrecipes/distributedspring/terracotta/customerconsole/service/CustomerService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.distributedspring.terracotta.customerconsole.service; 2 | 3 | import com.apress.springrecipes.distributedspring.terracotta.customerconsole.entity.Customer; 4 | 5 | import java.util.Collection; 6 | import java.util.Date; 7 | 8 | 9 | public interface CustomerService { 10 | Customer getCustomerById(String id); 11 | 12 | Customer createCustomer(String firstName, String lastName, Date birthdate); 13 | 14 | Customer removeCustomer(String id); 15 | 16 | Customer updateCustomer(String id, String firstName, String lastName, Date birthdate); 17 | 18 | Collection getAllCustomers(); 19 | } 20 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/distributedspring/terracotta/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: com.apress.springenterpriserecipes.distributedspring.terracotta.customerconsole.view.CustomerConsole -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/enterprise/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/enterprise/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | enterprise 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.wst.common.project.facet.core.builder 15 | 16 | 17 | 18 | 19 | org.maven.ide.eclipse.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.maven.ide.eclipse.maven2Nature 27 | org.eclipse.wst.common.project.facet.core.nature 28 | 29 | 30 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/enterprise/src/main/java/com/apress/springrecipes/replicator/EmailMain.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.replicator; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | 7 | public class EmailMain { 8 | public static void main(String[] args) { 9 | ApplicationContext context = new ClassPathXmlApplicationContext("beans-email.xml"); 10 | 11 | ErrorNotifier errorNotifier = (ErrorNotifier) context.getBean("errorNotifier"); 12 | errorNotifier.notifyCopyError("c:/documents", "d:/documents", "spring.doc"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/enterprise/src/main/java/com/apress/springrecipes/replicator/ErrorNotifier.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.replicator; 2 | 3 | public interface ErrorNotifier { 4 | public void notifyCopyError(String srcDir, String destDir, String filename); 5 | } 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/enterprise/src/main/java/com/apress/springrecipes/replicator/FileCopier.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.replicator; 2 | 3 | import java.io.IOException; 4 | 5 | 6 | public interface FileCopier { 7 | public void copyFile(String srcDir, String destDir, String filename) 8 | throws IOException; 9 | } 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/enterprise/src/main/java/com/apress/springrecipes/replicator/FileCopierImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.replicator; 2 | 3 | import org.springframework.util.FileCopyUtils; 4 | 5 | import java.io.File; 6 | import java.io.IOException; 7 | 8 | 9 | public class FileCopierImpl implements FileCopier { 10 | public void copyFile(String srcDir, String destDir, String filename) 11 | throws IOException { 12 | File srcFile = new File(srcDir, filename); 13 | File destFile = new File(destDir, filename); 14 | FileCopyUtils.copy(srcFile, destFile); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/enterprise/src/main/java/com/apress/springrecipes/replicator/FileReplicator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.replicator; 2 | 3 | import java.io.IOException; 4 | 5 | 6 | public interface FileReplicator { 7 | public String getSrcDir(); 8 | 9 | public void setSrcDir(String srcDir); 10 | 11 | public String getDestDir(); 12 | 13 | public void setDestDir(String destDir); 14 | 15 | public void replicate() throws IOException; 16 | } 17 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/enterprise/src/main/java/com/apress/springrecipes/replicator/JMXMain.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.replicator; 2 | 3 | import org.springframework.context.support.ClassPathXmlApplicationContext; 4 | 5 | 6 | public class JMXMain { 7 | public static void main(String[] args) throws Throwable { 8 | ClassPathXmlApplicationContext services = new ClassPathXmlApplicationContext("beans-jmx.xml"); 9 | services.start(); 10 | System.out.println("Started JMX instance..."); 11 | 12 | ClassPathXmlApplicationContext client = new ClassPathXmlApplicationContext("beans-jmx-client.xml"); 13 | client.start(); 14 | System.out.println("Started JMX client..."); 15 | 16 | FileReplicator fileReplicator = client.getBean("fileReplicatorProxy", FileReplicator.class); 17 | fileReplicator.replicate(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/enterprise/src/main/java/com/apress/springrecipes/replicator/QuartzMain.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.replicator; 2 | 3 | import org.springframework.context.support.ClassPathXmlApplicationContext; 4 | 5 | 6 | public class QuartzMain { 7 | static public void main(String[] args) { 8 | ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans-quartz.xml"); 9 | applicationContext.start(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/enterprise/src/main/java/com/apress/springrecipes/replicator/ReplicationNotificationListener.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.replicator; 2 | 3 | import javax.management.Notification; 4 | import javax.management.NotificationListener; 5 | 6 | 7 | public class ReplicationNotificationListener implements NotificationListener { 8 | public void handleNotification(Notification notification, Object handback) { 9 | if (notification.getType().startsWith("replication")) { 10 | System.out.println(notification.getSource() + " " + notification.getType() + " #" + notification.getSequenceNumber()); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/enterprise/src/main/java/com/apress/springrecipes/replicator/TimerMain.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.replicator; 2 | 3 | import org.springframework.context.support.ClassPathXmlApplicationContext; 4 | 5 | 6 | public class TimerMain { 7 | public static void main(String[] args) { 8 | ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans-replicator-scheduler.xml"); 9 | applicationContext.start(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/.flexProperties: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | test1 4 | 5 | 6 | 7 | 8 | 9 | com.adobe.flexbuilder.project.flexbuilder 10 | 11 | 12 | 13 | 14 | 15 | com.adobe.flexbuilder.project.flexnature 16 | com.adobe.flexbuilder.project.actionscriptnature 17 | 18 | 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | #Thu Dec 10 01:29:09 PST 2009 2 | eclipse.preferences.version=1 3 | encoding/=utf-8 4 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/html-template/history/history.css: -------------------------------------------------------------------------------- 1 | /* This CSS stylesheet defines styles used by required elements in a flex application page that supports browser history */ 2 | 3 | #ie_historyFrame { 4 | width: 0px; 5 | height: 0px; 6 | display: none 7 | } 8 | 9 | #firefox_anchorDiv { 10 | width: 0px; 11 | height: 0px; 12 | display: none 13 | } 14 | 15 | #safari_formDiv { 16 | width: 0px; 17 | height: 0px; 18 | display: none 19 | } 20 | 21 | #safari_rememberDiv { 22 | width: 0px; 23 | height: 0px; 24 | display: none 25 | } 26 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/html-template/index.template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Auction 4 | 5 | 11 | 12 | 17 | 18 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/html-template/playerProductInstall.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/flex/src/main/flex/test1/html-template/playerProductInstall.swf -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/libs/PureMVC_AS3_2_0_4.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/flex/src/main/flex/test1/libs/PureMVC_AS3_2_0_4.swc -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/libs/as3commons-lang-0.1.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/flex/src/main/flex/test1/libs/as3commons-lang-0.1.swc -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/libs/as3commons-logging-1.1.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/flex/src/main/flex/test1/libs/as3commons-logging-1.1.swc -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/libs/as3commons-reflect-1.1.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/flex/src/main/flex/test1/libs/as3commons-reflect-1.1.swc -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/libs/flexlib.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/flex/src/main/flex/test1/libs/flexlib.swc -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/libs/flexunit-0.90.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/flex/src/main/flex/test1/libs/flexunit-0.90.swc -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/libs/spring-actionscript-core-0.8.1.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/flex/src/main/flex/test1/libs/spring-actionscript-core-0.8.1.swc -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/src/app-context1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/src/app-context2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/src/com/apress/springrecipes/Pet.as: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes 2 | { 3 | public class Pet 4 | { 5 | 6 | private var _name : String; 7 | 8 | public function get name() : String { 9 | return _name; 10 | } 11 | 12 | public function set name(n : String) : void { 13 | _name = n; 14 | } 15 | 16 | public function Pet(n : String) 17 | { 18 | _name = n; 19 | } 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/src/com/apress/springrecipes/auction/ItemsDisplay.mxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/src/com/apress/springrecipes/auction/SignIn.mxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/flex/test1/src/com/config/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/java/com/apress/springrecipes/flex/auction/AuctionService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.flex.auction; 2 | 3 | import com.apress.springrecipes.flex.auction.model.Bid; 4 | import com.apress.springrecipes.flex.auction.model.Item; 5 | 6 | import java.util.Set; 7 | 8 | 9 | /** 10 | * provides an implementation of an auction house 11 | * 12 | * @author Josh Long 13 | */ 14 | public interface AuctionService { 15 | Item postItem(String sellerEmail, String item, String description, double minPrice, String imageUrl); 16 | 17 | Bid bid(Item item, double price); 18 | 19 | void acceptBid(Item item, Bid bid); 20 | 21 | Set getItemsForAuction(); 22 | } 23 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/java/com/apress/springrecipes/flex/auction/integrations/FileSystemInitializer.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.flex.auction.integrations; 2 | 3 | import org.springframework.core.io.Resource; 4 | 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.io.File; 8 | 9 | import javax.annotation.PostConstruct; 10 | 11 | 12 | @Component 13 | public class FileSystemInitializer { 14 | @javax.annotation.Resource(name = "itemFilesMount") 15 | private Resource itemFilesMount; 16 | 17 | @PostConstruct 18 | public void setup() throws Throwable { 19 | File file = itemFilesMount.getFile(); 20 | 21 | if (!file.exists()) { 22 | file.mkdirs(); 23 | } 24 | 25 | System.out.println("file system is setup at " + file.getAbsolutePath()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/webapp/WEB-INF/crm-service.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/flex/src/main/webapp/WEB-INF/crm-service.xml -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/webapp/WEB-INF/crm-servlet.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/flex/src/main/webapp/WEB-INF/crm-servlet.xml -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/webapp/WEB-INF/flex/services-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/webapp/crossdomain.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/webapp/images/boat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/flex/src/main/webapp/images/boat.jpg -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/webapp/images/car.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/flex/src/main/webapp/images/car.jpg -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/webapp/images/carpet.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/flex/src/main/webapp/images/carpet.jpg -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/webapp/images/motorbike.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/flex/src/main/webapp/images/motorbike.jpg -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/flex/src/main/webapp/test.txt: -------------------------------------------------------------------------------- 1 | Hello, world! -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/jbpm/src/main/resources/hibernate.cfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | false 7 | 8 | 9 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/jbpm/src/main/resources/info.txt: -------------------------------------------------------------------------------- 1 | 2 | http://www.jboss.org/index.html?module=bb&op=viewtopic&t=159013 | interesting walk through of how somebody got their version working.. 3 | http://www.inze.be/andries/ | the guy who's responsible for the original jBPM implementation 4 | http://docs.jboss.com/jbpm/v4.0/devguide/html_single/#springIntegration | the dev guide covering mr andries' work on integrating jbpm and Spring 5 | http://www.slideshare.net/ainze/spring-integration-with-jbpm4 slideshow by author of itnegration 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/jbpm/src/main/resources/jbpm4.properties: -------------------------------------------------------------------------------- 1 | hibernate.configFile=hibernate.cfg.xml 2 | dataSource.password=sep 3 | dataSource.username=sep 4 | dataSource.databaseName=sep 5 | dataSource.driverClassName=org.postgresql.Driver 6 | dataSource.dialect=org.hibernate.dialect.PostgreSQLDialect 7 | dataSource.serverName=sep 8 | dataSource.url=jdbc:postgresql://${dataSource.serverName}/${dataSource.databaseName} 9 | dataSource.properties=user=${dataSource.username};databaseName=${dataSource.databaseName};serverName=${dataSource.serverName};password=${dataSource.password} 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/jbpm/src/main/resources/process-definitions/HelloWorld.jpdl.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/messaging/src/main/java/com/apress/springrecipes/post/BackOffice.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | public interface BackOffice { 4 | public Mail receiveMail(); 5 | } 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/messaging/src/main/java/com/apress/springrecipes/post/BackOfficeImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | import org.springframework.jms.core.support.JmsGatewaySupport; 4 | 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | 8 | public class BackOfficeImpl extends JmsGatewaySupport implements BackOffice { 9 | @Transactional 10 | public Mail receiveMail() { 11 | return (Mail) getJmsTemplate().receiveAndConvert(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/messaging/src/main/java/com/apress/springrecipes/post/BackOfficeMain.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | import org.springframework.context.support.ClassPathXmlApplicationContext; 4 | 5 | 6 | public class BackOfficeMain { 7 | public static void main(String[] args) { 8 | new ClassPathXmlApplicationContext("beans-back.xml"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/messaging/src/main/java/com/apress/springrecipes/post/FrontDesk.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | public interface FrontDesk { 4 | public void sendMail(Mail mail); 5 | } 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/messaging/src/main/java/com/apress/springrecipes/post/FrontDeskImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | import org.springframework.jms.core.support.JmsGatewaySupport; 4 | 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | 8 | public class FrontDeskImpl extends JmsGatewaySupport implements FrontDesk { 9 | @Transactional 10 | public void sendMail(final Mail mail) { 11 | getJmsTemplate().convertAndSend(mail); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/messaging/src/main/java/com/apress/springrecipes/post/FrontDeskMain.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | 7 | public class FrontDeskMain { 8 | public static void main(String[] args) { 9 | ApplicationContext context = new ClassPathXmlApplicationContext("beans-front.xml"); 10 | 11 | FrontDesk frontDesk = (FrontDesk) context.getBean("frontDesk"); 12 | frontDesk.sendMail(new Mail("1234", "US", 1.5)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/messaging/src/main/java/com/apress/springrecipes/post/MailListener.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | public class MailListener { 4 | public void displayMail(Mail mail) { 5 | System.out.println("Mail #" + mail.getMailId() + " received"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/java/com/apress/springrecipes/court/domain/Player.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.court.domain; 2 | 3 | public class Player { 4 | 5 | private String name; 6 | private String phone; 7 | 8 | public Player() {} 9 | 10 | public Player(String name, String phone) { 11 | this.name = name; 12 | this.phone = phone; 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public String getPhone() { 20 | return phone; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public void setPhone(String phone) { 28 | this.phone = phone; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/java/com/apress/springrecipes/court/domain/SportType.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.court.domain; 2 | 3 | public class SportType { 4 | 5 | private int id; 6 | private String name; 7 | 8 | public SportType() {} 9 | 10 | public SportType(int id, String name) { 11 | this.id = id; 12 | this.name = name; 13 | } 14 | 15 | public int getId() { 16 | return id; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setId(int id) { 24 | this.id = id; 25 | } 26 | 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/java/com/apress/springrecipes/court/domain/SportTypeEditor.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.court.domain; 2 | 3 | import java.beans.PropertyEditorSupport; 4 | 5 | import com.apress.springrecipes.court.service.ReservationService; 6 | 7 | public class SportTypeEditor extends PropertyEditorSupport { 8 | 9 | private ReservationService reservationService; 10 | 11 | public SportTypeEditor(ReservationService reservationService) { 12 | this.reservationService = reservationService; 13 | } 14 | 15 | public void setAsText(String text) throws IllegalArgumentException { 16 | int sportTypeId = Integer.parseInt(text); 17 | SportType sportType = reservationService.getSportType(sportTypeId); 18 | setValue(sportType); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/java/com/apress/springrecipes/court/service/MemberService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.court.service; 2 | 3 | import java.util.List; 4 | 5 | import com.apress.springrecipes.court.domain.Member; 6 | 7 | public interface MemberService { 8 | 9 | public void add(Member member); 10 | public void remove(String memberName); 11 | public List list(); 12 | } 13 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/java/com/apress/springrecipes/court/service/MemberServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.court.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Map; 6 | import java.util.TreeMap; 7 | 8 | import com.apress.springrecipes.court.domain.Member; 9 | 10 | 11 | public class MemberServiceImpl implements MemberService { 12 | 13 | private Map members = new TreeMap(); 14 | 15 | public void add(Member member) { 16 | members.put(member.getName(), member); 17 | } 18 | 19 | public void remove(String memberName) { 20 | members.remove(memberName); 21 | } 22 | 23 | public List list() { 24 | return new ArrayList(members.values()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/java/com/apress/springrecipes/court/service/ReservationNotAvailableException.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.court.service; 2 | 3 | import java.util.Date; 4 | 5 | public class ReservationNotAvailableException extends RuntimeException { 6 | 7 | 8 | public static final long serialVersionUID = 1L; 9 | private String courtName; 10 | private Date date; 11 | private int hour; 12 | 13 | public ReservationNotAvailableException(String courtName, Date date, int hour) { 14 | this.courtName = courtName; 15 | this.date = date; 16 | this.hour = hour; 17 | } 18 | 19 | public String getCourtName() { 20 | return courtName; 21 | } 22 | 23 | public Date getDate() { 24 | return date; 25 | } 26 | 27 | public int getHour() { 28 | return hour; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/java/com/apress/springrecipes/court/web/.MemberController.java.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/mvc/src/main/java/com/apress/springrecipes/court/web/.MemberController.java.swp -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/java/com/apress/springrecipes/court/web/ReservationSuccessController.java: -------------------------------------------------------------------------------- 1 | // FINAL 2 | package com.apress.springrecipes.court.web; 3 | 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | @Controller 8 | public class ReservationSuccessController { 9 | // Method is bound directly to URL /reservationSuccess 10 | @RequestMapping("/reservationSuccess") 11 | public String reservationSuccess() { 12 | // Return view reservationSuccess. Via resolver the view 13 | // will be mapped to /WEB-INF/jsp/reservationSuccess.jsp 14 | return "reservationSuccess"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/java/com/apress/springrecipes/court/web/ReservationWebException.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.court.web; 2 | 3 | import java.util.Date; 4 | 5 | public class ReservationWebException extends RuntimeException { 6 | public static final long serialVersionUID = 1L; 7 | private String message; 8 | private String stack; 9 | private Date date; 10 | 11 | public ReservationWebException(String message, Date date, String stack) { 12 | this.message = message; 13 | this.date = date; 14 | this.stack = stack; 15 | } 16 | 17 | public String getMessage() { 18 | return message; 19 | } 20 | 21 | public Date getDate() { 22 | return date; 23 | } 24 | 25 | public String getStack() { 26 | return stack; 27 | } 28 | } -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/log4j.properties: -------------------------------------------------------------------------------- 1 | ### direct log messages to stdout ### 2 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 3 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 4 | log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%n 5 | 6 | ### set root logger level ### 7 | log4j.rootLogger=error, stdout 8 | 9 | ### set application logger level ### 10 | log4j.logger.com.apress.springrecipes.calculator=info 11 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/webapp/WEB-INF/court-service.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 8 | 9 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/webapp/WEB-INF/jsp/about.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | About 4 | 5 | 6 | 7 |

Court Reservation System

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
Version:1.0
Email:${email}
18 | 19 | 20 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/webapp/WEB-INF/jsp/error.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | Error 4 | 5 | 6 | 7 | An error has occurred. Please contact our administrator for details. 8 | 9 | 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/webapp/WEB-INF/jsp/notfound.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | Page Not Found 4 | 5 | 6 | 7 | Page Not Found 8 | 9 | 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/webapp/WEB-INF/jsp/reservationCourtForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> 2 | 3 | 4 | 5 | Reservation Court Form 6 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 28 | 29 |
Court Name
24 | 25 | 26 | 27 |
30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/webapp/WEB-INF/jsp/reservationNotAvailable.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 2 | 3 | 4 | 5 | Reservation Not Available 6 | 7 | 8 | 9 | Your reservation for ${exception.courtName} is not available on 10 | at 11 | ${exception.hour}:00. 12 | 13 | 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/webapp/WEB-INF/jsp/reservationSuccess.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | Reservation Success 4 | 5 | 6 | 7 | Your reservation has been made successfully. 8 | 9 | 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/webapp/WEB-INF/jsp/reservationSummary.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | 3 | 4 | Reservations 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/webapp/WEB-INF/jsp/reservationWebException.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | 3 | 4 | 5 | Reservation Web Exception 6 | 7 | 8 | 9 |

The following error has occurred:

10 |
    11 |
  • Message:
  • 12 |
  • Date:
  • 13 |
14 |

Please contact our administrator for details

15 |

As a reference you can add the following information:

16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/webapp/WEB-INF/jsp/welcome.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 2 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 3 | 4 | 5 | 6 | <spring:message code="welcome.title" text="Welcome" /> 7 | 8 | 9 | 10 |

12 | 13 | Today is . 14 |
15 | Handling time : ${handlingTime} ms 16 |
17 | Locale : ${pageContext.response.locale} 18 | 19 | 20 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/webapp/messages.properties: -------------------------------------------------------------------------------- 1 | welcome.title=Welcome 2 | welcome.message=Welcome to Court Reservation System 3 | 4 | typeMismatch.date=Invalid date format 5 | typeMismatch.hour=Invalid hour format 6 | 7 | required.courtName=Court name is required 8 | required.date=Date is required 9 | required.hour=Hour is required 10 | required.playerName=Player name is required 11 | required.sportType=Sport type is required 12 | invalid.holidayHour=Invalid holiday hour 13 | invalid.weekdayHour=Invalid weekday hour 14 | 15 | admin.email=reservation@court.com -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/webapp/messages_de.properties: -------------------------------------------------------------------------------- 1 | welcome.title=Willkommen 2 | welcome.message=Willkommen zum Spielplatz-Reservierungssystem 3 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/webapp/secondaryviews.properties: -------------------------------------------------------------------------------- 1 | reservationSummary.(class)=com.apress.springrecipes.court.web.view.PdfReservationSummary -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/mvc/src/main/webapp/views.properties: -------------------------------------------------------------------------------- 1 | welcomeRedirect.(class)=org.springframework.web.servlet.view.RedirectView 2 | welcomeRedirect.url=welcome.htm 3 | 4 | reservationSuccessRedirect.(class)=org.springframework.web.servlet.view.RedirectView 5 | reservationSuccessRedirect.url=reservationSuccess.htm 6 | 7 | reservationSummary.(class)=com.apress.springrecipes.court.web.view.ExcelReservationSummary 8 | 9 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/helloworld/helloworld-service/src/main/java/com/apress/springrecipes/osgi/helloworld/service/GreeterService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.osgi.helloworld.service; 2 | 3 | public interface GreeterService { 4 | String greet(String language, String name); 5 | } 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/bin/felix.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/bin/felix.jar -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/bundle/org.apache.felix.bundlerepository-1.4.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/bundle/org.apache.felix.bundlerepository-1.4.0.jar -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/bundle/org.apache.felix.shell-1.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/bundle/org.apache.felix.shell-1.2.0.jar -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/bundle/org.apache.felix.shell.tui-1.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/bundle/org.apache.felix.shell.tui-1.2.0.jar -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-framework-launching-and-embedding_files/apache.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-framework-launching-and-embedding_files/apache.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-framework-launching-and-embedding_files/button.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-framework-launching-and-embedding_files/button_data/2008-usa-125x125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-framework-launching-and-embedding_files/button_data/2008-usa-125x125.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-framework-launching-and-embedding_files/button_data/2009-europe-125x125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-framework-launching-and-embedding_files/button_data/2009-europe-125x125.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-framework-launching-and-embedding_files/forbidden.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-framework-launching-and-embedding_files/forbidden.gif -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-framework-launching-and-embedding_files/linkext7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-framework-launching-and-embedding_files/linkext7.gif -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-framework-launching-and-embedding_files/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-framework-launching-and-embedding_files/logo.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-framework-launching-and-embedding_files/mail_small.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-framework-launching-and-embedding_files/mail_small.gif -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-osgi-bundle-repository-obr_files/apache-felix-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-osgi-bundle-repository-obr_files/apache-felix-small.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-osgi-bundle-repository-obr_files/apache.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-osgi-bundle-repository-obr_files/apache.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-osgi-bundle-repository-obr_files/linkext7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-osgi-bundle-repository-obr_files/linkext7.gif -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-osgi-bundle-repository-obr_files/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-osgi-bundle-repository-obr_files/logo.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-osgi-bundle-repository-obr_files/mail_small.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-osgi-bundle-repository-obr_files/mail_small.gif -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-osgi-bundle-repository-obr_files/obr-entities.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-osgi-bundle-repository-obr_files/obr-entities.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-osgi-bundle-repository-obr_files/obr-high-level.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-osgi-bundle-repository-obr_files/obr-high-level.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-service_files/apache-felix-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-service_files/apache-felix-small.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-service_files/apache.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-service_files/apache.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-service_files/button.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-service_files/button_data/2008-usa-125x125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-service_files/button_data/2008-usa-125x125.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-service_files/linkext7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-service_files/linkext7.gif -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-service_files/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-service_files/logo.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-service_files/mail_small.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-service_files/mail_small.gif -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-tui_files/apache-felix-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-tui_files/apache-felix-small.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-tui_files/apache.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-tui_files/apache.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-tui_files/button.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-tui_files/button_data/2008-usa-125x125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-tui_files/button_data/2008-usa-125x125.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-tui_files/linkext7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-tui_files/linkext7.gif -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-tui_files/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-shell-tui_files/logo.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-usage-documentation_files/apache.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-usage-documentation_files/apache.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-usage-documentation_files/button.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-usage-documentation_files/button_data/2008-usa-125x125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-usage-documentation_files/button_data/2008-usa-125x125.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-usage-documentation_files/button_data/2009-europe-125x125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-usage-documentation_files/button_data/2009-europe-125x125.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-usage-documentation_files/information.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-usage-documentation_files/information.gif -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-usage-documentation_files/linkext7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-usage-documentation_files/linkext7.gif -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-usage-documentation_files/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-usage-documentation_files/logo.png -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-usage-documentation_files/mail_small.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/spring-recipes/fd9cc360897c3e259e7e92bb0bc10ab872e9b320/Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/apache-felix-usage-documentation_files/mail_small.gif -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/infrastructure/felix-1.8.0/doc/changelog_shell_tui.txt: -------------------------------------------------------------------------------- 1 | Changes from 1.0.2 to 1.2.0 2 | --------------------------- 3 | 4 | ** Bug 5 | * [FELIX-729] - Shell-TUI causes 100% CPU load when using javaw launcher 6 | 7 | Changes from 1.0.1 to 1.0.2 8 | --------------------------- 9 | 10 | * [2008-08-12] Added OBR descriptor and updated to bundle plugin version 11 | 1.4.3. (FELIX-669) 12 | 13 | Changes from 1.0.0 to 1.0.1 14 | --------------------------- 15 | 16 | * [2008-04-21] Re-release to make bytecode executable on jre 1.3. 17 | 18 | Changes from 0.8.0-incubator to 1.0.0 19 | ------------------------------------- 20 | 21 | * None. 22 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/springdm-helloworld-client/src/main/java/com/apress/springrecipes/osgi/springdmhelloworld/Activator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.osgi.springdmhelloworld; 2 | 3 | import org.osgi.framework.BundleActivator; 4 | import org.osgi.framework.BundleContext; 5 | 6 | 7 | public class Activator implements BundleActivator { 8 | public void start(BundleContext bundleContext) throws Exception { 9 | } 10 | 11 | public void stop(BundleContext bundleContext) throws Exception { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/springdm-helloworld-client/src/main/java/com/apress/springrecipes/osgi/springdmhelloworld/impl/SpringDMGreeterClient.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.osgi.springdmhelloworld.impl; 2 | 3 | import com.apress.springrecipes.osgi.helloworld.service.GreeterService; 4 | 5 | import org.springframework.beans.factory.InitializingBean; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | import java.util.Arrays; 9 | import java.util.Locale; 10 | 11 | 12 | public class SpringDMGreeterClient implements InitializingBean { 13 | @Autowired 14 | private GreeterService greeterService; 15 | 16 | public void afterPropertiesSet() throws Exception { 17 | for (String name : Arrays.asList("Mario", "Fumiko", "Makani")) { 18 | System.out.println(greeterService.greet(Locale.FRENCH.toString(), name)); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/springdm-helloworld-client/src/main/resources/META-INF/spring/bundle-context-osgi.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/springdm-helloworld-client/src/main/resources/META-INF/spring/bundle-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/springdm-helloworld-client/src/main/resources/META-INF/spring/readme.txt: -------------------------------------------------------------------------------- 1 | To facilitate OSGi bundle manifest generation, the archetype uses Felix maven plugin. 2 | The manifest will be generated when building the project. To trigger this, run: 3 | 4 | mvn package 5 | 6 | Please see http://felix.apache.org/site/maven-bundle-plugin-bnd.html for more information. -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/springdm-helloworld-client/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootCategory=INFO, stdout 2 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 3 | log4j.appender.stdout.layout.ConversionPattern=%t %p [%c] - %m%n 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.threshold=TRACE 6 | 7 | #log4j.logger.org.springframework.osgi=DEBUG 8 | #log4j.logger.org.springframework=DEBUG -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/springdm-helloworld-service/src/main/java/com/apress/springrecipes/osgi/helloworld/service/GreeterService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.osgi.helloworld.service; 2 | 3 | public interface GreeterService { 4 | String greet(String language, String name); 5 | } 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/springdm-helloworld-service/src/main/java/com/apress/springrecipes/osgi/helloworld/service/GreetingRecorderService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.osgi.helloworld.service; 2 | 3 | public interface GreetingRecorderService { 4 | int getCountOfGreetingsFor(String name); 5 | 6 | int getCountOfGreetingsIn(String language); 7 | } 8 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/osgi/springdm-helloworld-service/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootCategory=INFO, stdout 2 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 3 | log4j.appender.stdout.layout.ConversionPattern=%t %p [%c] - %m%n 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.threshold=TRACE 6 | 7 | #log4j.logger.org.springframework.osgi=DEBUG 8 | #log4j.logger.org.springframework=DEBUG -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/portletmvc/src/main/java/com/apress/springrecipes/travel/flight/FlightHelpController.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.travel.flight; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | @Controller 7 | @RequestMapping("HELP") 8 | public class FlightHelpController { 9 | 10 | @RequestMapping 11 | public String showHelp() { 12 | return "flightHelp"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/portletmvc/src/main/java/com/apress/springrecipes/travel/flight/FlightService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.travel.flight; 2 | 3 | import java.util.List; 4 | 5 | public interface FlightService { 6 | 7 | public List findTodayFlights(); 8 | public Flight findFlight(String flightNo); 9 | } 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/portletmvc/src/main/java/com/apress/springrecipes/travel/flight/FlightServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.travel.flight; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Date; 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class FlightServiceImpl implements FlightService { 10 | 11 | private Map flights; 12 | 13 | public FlightServiceImpl() { 14 | flights = new HashMap(); 15 | flights.put("CX888", new Flight("CX888", "HKG", "YVR", new Date())); 16 | flights.put("CX889", new Flight("CX889", "HKG", "JFK", new Date())); 17 | } 18 | 19 | public List findTodayFlights() { 20 | return new ArrayList(flights.values()); 21 | } 22 | 23 | public Flight findFlight(String flightNo) { 24 | return flights.get(flightNo); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/portletmvc/src/main/java/com/apress/springrecipes/travel/tour/TourService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.travel.tour; 2 | 3 | import java.util.List; 4 | 5 | public interface TourService { 6 | 7 | public List getLocations(); 8 | public void processBooking(BookingForm form); 9 | } 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/portletmvc/src/main/java/com/apress/springrecipes/travel/tour/TourServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.travel.tour; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class TourServiceImpl implements TourService { 7 | 8 | private List forms = new ArrayList(); 9 | private List locations; 10 | 11 | public List getLocations() { 12 | return locations; 13 | } 14 | 15 | public void setLocations(List locations) { 16 | this.locations = locations; 17 | } 18 | 19 | public void processBooking(BookingForm form) { 20 | forms.add(form); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/portletmvc/src/main/java/com/apress/springrecipes/travel/weather/WeatherService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.travel.weather; 2 | 3 | import java.util.Map; 4 | 5 | public interface WeatherService { 6 | 7 | public Map getMajorCityTemperatures(); 8 | } 9 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/portletmvc/src/main/java/com/apress/springrecipes/travel/weather/WeatherServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.travel.weather; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class WeatherServiceImpl implements WeatherService { 7 | 8 | public Map getMajorCityTemperatures() { 9 | Map temperatures = new HashMap(); 10 | temperatures.put("New York", 6.0); 11 | temperatures.put("London", 10.0); 12 | temperatures.put("Beijing", 5.0); 13 | return temperatures; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/portletmvc/src/main/resources/messages.properties: -------------------------------------------------------------------------------- 1 | typeMismatch.java.util.Date=Invalid date format. 2 | required.tourist=Tourist is required. 3 | required.phone=Phone is required. 4 | required.origin=Origin is required. 5 | required.destination=Destination is required. 6 | required.departureDate=Departure date is required. 7 | required.returnDate=Return date is required. 8 | invalid.destination=Destination cannot be the same as origin. 9 | invalid.returnDate=Return date must be later than departure date. 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/portletmvc/src/main/webapp/WEB-INF/jsp/bookingSuccess.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="portlet" uri="http://java.sun.com/portlet" %> 2 | 3 | Your booking has been made successfully. 4 |
5 | Return 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/portletmvc/src/main/webapp/WEB-INF/jsp/flightDetail.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 2 | <%@ taglib prefix="portlet" uri="http://java.sun.com/portlet" %> 3 | 4 |
CourtDateHourPlayer NamePlayer Phone
${reservation.courtName}${reservation.date}${reservation.hour}${reservation.player.name}${reservation.player.phone}
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 26 | 27 |
Flight Number${flight.number}
Origin${flight.origin}
Destination${flight.destination}
Departure Time
24 | ">Return 25 |
28 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/portletmvc/src/main/webapp/WEB-INF/jsp/flightHelp.jsp: -------------------------------------------------------------------------------- 1 | This portlet lists flights departed today. -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/portletmvc/src/main/webapp/WEB-INF/jsp/flightPreferences.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="portlet" uri="http://java.sun.com/portlet" %> 2 | 3 |
4 | Time Zone 5 | 6 | 7 |
8 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/portletmvc/src/main/webapp/WEB-INF/jsp/weatherView.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%@ taglib prefix="portlet" uri="http://java.sun.com/portlet" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
CityTemperature
${temperature.key}${temperature.value}
15 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/portletmvc/src/main/webapp/WEB-INF/weather-portlet.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/java/com/apress/springrecipes/court/domain/FeedContent.java: -------------------------------------------------------------------------------- 1 | // Final 2 | package com.apress.springrecipes.court.domain; 3 | 4 | public class FeedContent { 5 | private String title; 6 | private String link; 7 | 8 | public FeedContent(String title, String link) { 9 | this.title = title; 10 | this.link = link; 11 | } 12 | 13 | public String getTitle() { 14 | return title; 15 | } 16 | 17 | public String getLink() { 18 | return link; 19 | } 20 | 21 | public void setTitle(String title) { 22 | this.title = title; 23 | } 24 | 25 | public void setLink(String link) { 26 | this.link = link; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/java/com/apress/springrecipes/court/domain/Player.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.court.domain; 2 | 3 | public class Player { 4 | private String name; 5 | private String phone; 6 | 7 | public Player() { 8 | } 9 | 10 | public Player(String name, String phone) { 11 | this.name = name; 12 | this.phone = phone; 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public String getPhone() { 20 | return phone; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public void setPhone(String phone) { 28 | this.phone = phone; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/java/com/apress/springrecipes/court/domain/SportType.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.court.domain; 2 | 3 | public class SportType { 4 | private int id; 5 | private String name; 6 | 7 | public SportType() { 8 | } 9 | 10 | public SportType(int id, String name) { 11 | this.id = id; 12 | this.name = name; 13 | } 14 | 15 | public int getId() { 16 | return id; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setId(int id) { 24 | this.id = id; 25 | } 26 | 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/java/com/apress/springrecipes/court/domain/SportTypeEditor.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.court.domain; 2 | 3 | import com.apress.springrecipes.court.service.ReservationService; 4 | 5 | import java.beans.PropertyEditorSupport; 6 | 7 | 8 | public class SportTypeEditor extends PropertyEditorSupport { 9 | private ReservationService reservationService; 10 | 11 | public SportTypeEditor(ReservationService reservationService) { 12 | this.reservationService = reservationService; 13 | } 14 | 15 | public void setAsText(String text) throws IllegalArgumentException { 16 | int sportTypeId = Integer.parseInt(text); 17 | SportType sportType = reservationService.getSportType(sportTypeId); 18 | setValue(sportType); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/java/com/apress/springrecipes/court/service/MemberService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.court.service; 2 | 3 | import com.apress.springrecipes.court.domain.Member; 4 | 5 | import java.util.List; 6 | 7 | 8 | public interface MemberService { 9 | public void add(Member member); 10 | 11 | public void remove(String memberName); 12 | 13 | public List list(); 14 | } 15 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/java/com/apress/springrecipes/court/service/MemberServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.court.service; 2 | 3 | import com.apress.springrecipes.court.domain.Member; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.Map; 8 | import java.util.TreeMap; 9 | 10 | 11 | public class MemberServiceImpl implements MemberService { 12 | private Map members = new TreeMap(); 13 | 14 | public void add(Member member) { 15 | members.put(member.getName(), member); 16 | } 17 | 18 | public void remove(String memberName) { 19 | members.remove(memberName); 20 | } 21 | 22 | public List list() { 23 | return new ArrayList(members.values()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/java/com/apress/springrecipes/court/service/ReservationNotAvailableException.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.court.service; 2 | 3 | import java.util.Date; 4 | 5 | 6 | public class ReservationNotAvailableException extends RuntimeException { 7 | public static final long serialVersionUID = 1L; 8 | private String courtName; 9 | private Date date; 10 | private int hour; 11 | 12 | public ReservationNotAvailableException(String courtName, Date date, int hour) { 13 | this.courtName = courtName; 14 | this.date = date; 15 | this.hour = hour; 16 | } 17 | 18 | public String getCourtName() { 19 | return courtName; 20 | } 21 | 22 | public Date getDate() { 23 | return date; 24 | } 25 | 26 | public int getHour() { 27 | return hour; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/java/com/apress/springrecipes/court/service/ReservationService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.court.service; 2 | 3 | import com.apress.springrecipes.court.domain.PeriodicReservation; 4 | import com.apress.springrecipes.court.domain.Reservation; 5 | import com.apress.springrecipes.court.domain.SportType; 6 | 7 | import java.util.Date; 8 | import java.util.List; 9 | 10 | 11 | public interface ReservationService { 12 | public List query(String courtName); 13 | 14 | public void make(Reservation reservation) throws ReservationNotAvailableException; 15 | 16 | public List getAllSportTypes(); 17 | 18 | public SportType getSportType(int sportTypeId); 19 | 20 | public void makePeriodic(PeriodicReservation periodicReservation) 21 | throws ReservationNotAvailableException; 22 | 23 | public List findByDate(Date date); 24 | } 25 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/java/com/apress/springrecipes/court/web/ReservationSuccessController.java: -------------------------------------------------------------------------------- 1 | // FINAL 2 | package com.apress.springrecipes.court.web; 3 | 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | 8 | @Controller 9 | public class ReservationSuccessController { 10 | // Method is bound directly to URL /reservationSuccess 11 | @RequestMapping("/reservationSuccess") 12 | public String reservationSuccess() { 13 | // Return view reservationSuccess. Via resolver the view 14 | // will be mapped to /WEB-INF/jsp/reservationSuccess.jsp 15 | return "reservationSuccess"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/java/com/apress/springrecipes/court/web/ReservationWebException.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.court.web; 2 | 3 | import java.util.Date; 4 | 5 | 6 | public class ReservationWebException extends RuntimeException { 7 | public static final long serialVersionUID = 1L; 8 | private String message; 9 | private String stack; 10 | private Date date; 11 | 12 | public ReservationWebException(String message, Date date, String stack) { 13 | this.message = message; 14 | this.date = date; 15 | this.stack = stack; 16 | } 17 | 18 | public String getMessage() { 19 | return message; 20 | } 21 | 22 | public Date getDate() { 23 | return date; 24 | } 25 | 26 | public String getStack() { 27 | return stack; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | ### direct log messages to stdout ### 2 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 3 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 4 | log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%n 5 | 6 | ### set root logger level ### 7 | log4j.rootLogger=error, stdout 8 | 9 | ### set application logger level ### 10 | log4j.logger.com.apress.springrecipes.calculator=info 11 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/resources/messages.properties: -------------------------------------------------------------------------------- 1 | welcome.title=Welcome 2 | welcome.message=Welcome to Court Reservation System 3 | 4 | typeMismatch.date=Invalid date format 5 | typeMismatch.hour=Invalid hour format 6 | 7 | required.courtName=Court name is required 8 | required.date=Date is required 9 | required.hour=Hour is required 10 | required.playerName=Player name is required 11 | required.sportType=Sport type is required 12 | invalid.holidayHour=Invalid holiday hour 13 | invalid.weekdayHour=Invalid weekday hour 14 | 15 | admin.email=reservation@court.com -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/resources/messages_de.properties: -------------------------------------------------------------------------------- 1 | welcome.title=Willkommen 2 | welcome.message=Willkommen zum Spielplatz-Reservierungssystem 3 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/webapp/WEB-INF/court-service.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 8 | 9 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/webapp/WEB-INF/jsp/about.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | About 4 | 5 | 6 | 7 |

Court Reservation System

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
Version:1.0
Email:${email}
18 | 19 | 20 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/webapp/WEB-INF/jsp/error.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | Error 4 | 5 | 6 | 7 | An error has occurred. Please contact our administrator for details. 8 | 9 | 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/webapp/WEB-INF/jsp/nationalweathertemplate.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | 3 | 4 | National weather feed by The Weather Channel 5 | 6 | 7 | 8 |

National weather feed by The Weather Channel

9 | 10 | 11 | 12 | 13 | 14 | 15 |
${item.title}
16 |

Information obtained through ${feedtype} ${feedversion}

17 | 18 | 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/webapp/WEB-INF/jsp/newstemplate.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sports news feed by Yahoo 4 | 5 | 6 | 7 |

Sports news feed by Yahoo

8 | 9 | 10 | 11 | 12 |
${newsfeed}
13 | 14 | 15 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/webapp/WEB-INF/jsp/notfound.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | Page Not Found 4 | 5 | 6 | 7 | Page Not Found 8 | 9 | 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/webapp/WEB-INF/jsp/reservationCourtForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> 2 | 3 | 4 | 5 | Reservation Court Form 6 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 28 | 29 |
Court Name
24 | 25 | 26 | 27 |
30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/webapp/WEB-INF/jsp/reservationNotAvailable.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 2 | 3 | 4 | 5 | Reservation Not Available 6 | 7 | 8 | 9 | Your reservation for ${exception.courtName} is not available on 10 | at 11 | ${exception.hour}:00. 12 | 13 | 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/webapp/WEB-INF/jsp/reservationSuccess.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | Reservation Success 4 | 5 | 6 | 7 | Your reservation has been made successfully. 8 | 9 | 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/webapp/WEB-INF/jsp/reservationSummary.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | 3 | 4 | Reservations 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/webapp/WEB-INF/jsp/reservationWebException.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | 3 | 4 | 5 | Reservation Web Exception 6 | 7 | 8 | 9 |

The following error has occurred:

10 |
    11 |
  • Message:
  • 12 |
  • Date:
  • 13 |
14 |

Please contact our administrator for details

15 |

As a reference you can add the following information:

16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/webapp/WEB-INF/jsp/welcome.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 2 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 3 | 4 | 5 | 6 | <spring:message code="welcome.title" text="Welcome" /> 7 | 8 | 9 | 10 |

12 | 13 | Today is . 14 |
15 | Handling time : ${handlingTime} ms 16 |
17 | Locale : ${pageContext.response.locale} 18 | 19 | 20 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/webapp/WEB-INF/jsp/worldnewstemplate.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | World news feed by Google 4 | 5 | 6 | 7 |

World news feed by Google

8 |
CourtDateHourPlayer NamePlayer Phone
${reservation.courtName}${reservation.date}${reservation.hour}${reservation.player.name}${reservation.player.phone}
9 | 10 | 11 | 12 |
${worldnewsfeed}
13 | 14 | 15 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/webapp/secondaryviews.properties: -------------------------------------------------------------------------------- 1 | reservationSummary.(class)=com.apress.springrecipes.court.web.view.PdfReservationSummary -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rest/src/main/webapp/views.properties: -------------------------------------------------------------------------------- 1 | welcomeRedirect.(class)=org.springframework.web.servlet.view.RedirectView 2 | welcomeRedirect.url=welcome.htm 3 | 4 | reservationSuccessRedirect.(class)=org.springframework.web.servlet.view.RedirectView 5 | reservationSuccessRedirect.url=reservationSuccess.htm 6 | 7 | reservationSummary.(class)=com.apress.springrecipes.court.web.view.ExcelReservationSummary 8 | 9 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.apress.springrecipes 6 | core 7 | 1.0-SNAPSHOT 8 | 9 | pom 10 | rpc 11 | RPC 12 | 13 | 14 | post-ejb3 15 | post-ejb2 16 | weather-remoting 17 | weather-remoting-soap 18 | weather-remoting-soap-standalone 19 | weather-ws 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/post-ejb2/src/main/java/com/apress/springrecipes/post/FrontDesk.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | public interface FrontDesk { 4 | public double calculatePostage(String country, double weight); 5 | } 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/post-ejb2/src/main/java/com/apress/springrecipes/post/FrontDeskImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | public class FrontDeskImpl implements FrontDesk { 4 | private PostageService postageService; 5 | 6 | public void setPostageService(PostageService postageService) { 7 | this.postageService = postageService; 8 | } 9 | 10 | public double calculatePostage(String country, double weight) { 11 | return postageService.calculatePostage(country, weight); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/post-ejb2/src/main/java/com/apress/springrecipes/post/FrontDeskMain.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | 7 | public class FrontDeskMain { 8 | public static void main(String[] args) { 9 | ApplicationContext context = new ClassPathXmlApplicationContext("beans-front.xml"); 10 | 11 | FrontDesk frontDesk = (FrontDesk) context.getBean("frontDesk"); 12 | double postage = frontDesk.calculatePostage("US", 1.5); 13 | System.out.println(postage); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/post-ejb2/src/main/java/com/apress/springrecipes/post/PostageService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | public interface PostageService { 4 | public double calculatePostage(String country, double weight); 5 | } 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/post-ejb2/src/main/java/com/apress/springrecipes/post/PostageServiceBean.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | import org.springframework.ejb.support.AbstractStatelessSessionBean; 4 | 5 | import javax.ejb.CreateException; 6 | 7 | 8 | public class PostageServiceBean extends AbstractStatelessSessionBean implements PostageService { 9 | private PostageService postageService; 10 | 11 | protected void onEjbCreate() throws CreateException { 12 | postageService = (PostageService) getBeanFactory().getBean("postageService"); 13 | } 14 | 15 | public double calculatePostage(String country, double weight) { 16 | return postageService.calculatePostage(country, weight); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/post-ejb2/src/main/java/com/apress/springrecipes/post/PostageServiceHome.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | import java.rmi.RemoteException; 4 | 5 | import javax.ejb.CreateException; 6 | import javax.ejb.EJBHome; 7 | 8 | 9 | public interface PostageServiceHome extends EJBHome { 10 | public PostageServiceRemote create() throws RemoteException, CreateException; 11 | } 12 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/post-ejb2/src/main/java/com/apress/springrecipes/post/PostageServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | public class PostageServiceImpl implements PostageService { 4 | public double calculatePostage(String country, double weight) { 5 | return 1.0; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/post-ejb2/src/main/java/com/apress/springrecipes/post/PostageServiceRemote.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | import java.rmi.RemoteException; 4 | 5 | import javax.ejb.EJBObject; 6 | 7 | 8 | public interface PostageServiceRemote extends EJBObject { 9 | public double calculatePostage(String country, double weight) 10 | throws RemoteException; 11 | } 12 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/post-ejb2/src/main/resources/beans-ejb.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 8 | 9 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/post-ejb3/src/main/java/com/apress/springrecipes/post/FrontDesk.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | public interface FrontDesk { 4 | public double calculatePostage(String country, double weight); 5 | } 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/post-ejb3/src/main/java/com/apress/springrecipes/post/FrontDeskImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | public class FrontDeskImpl implements FrontDesk { 4 | private PostageService postageService; 5 | 6 | public void setPostageService(PostageService postageService) { 7 | this.postageService = postageService; 8 | } 9 | 10 | public double calculatePostage(String country, double weight) { 11 | return postageService.calculatePostage(country, weight); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/post-ejb3/src/main/java/com/apress/springrecipes/post/FrontDeskMain.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | 7 | public class FrontDeskMain { 8 | public static void main(String[] args) { 9 | ApplicationContext context = new ClassPathXmlApplicationContext("beans-front.xml"); 10 | 11 | FrontDesk frontDesk = (FrontDesk) context.getBean("frontDesk"); 12 | double postage = frontDesk.calculatePostage("US", 1.5); 13 | System.out.println(postage); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/post-ejb3/src/main/java/com/apress/springrecipes/post/PostageService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | public interface PostageService { 4 | public double calculatePostage(String country, double weight); 5 | } 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/post-ejb3/src/main/java/com/apress/springrecipes/post/PostageServiceBean.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.post; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | 5 | import org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor; 6 | 7 | import org.springframework.jdbc.core.JdbcTemplate; 8 | 9 | import javax.ejb.Remote; 10 | import javax.ejb.Stateless; 11 | 12 | import javax.interceptor.Interceptors; 13 | 14 | 15 | @Stateless 16 | @Remote({PostageService.class}) 17 | @Interceptors(SpringBeanAutowiringInterceptor.class) 18 | public class PostageServiceBean implements PostageService { 19 | @Autowired 20 | private JdbcTemplate jdbcTemplate; 21 | 22 | public double calculatePostage(String country, double weight) { 23 | return 1.0; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting-soap-standalone/src/main/java/com/apress/springrecipes/weather/StandaloneServer.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | 7 | /** 8 | * @author Josh Long 9 | */ 10 | public class StandaloneServer { 11 | public static void main(String[] args) { 12 | ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("standalone-server.xml"); 13 | applicationContext.start(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting-soap-standalone/src/main/java/com/apress/springrecipes/weather/WeatherService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import javax.jws.WebService; 7 | 8 | 9 | @WebService 10 | public interface WeatherService { 11 | public List getTemperatures(String city, List dates); 12 | } 13 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting-soap-standalone/src/main/java/com/apress/springrecipes/weather/WeatherServiceClient.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import java.util.Arrays; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | 8 | public class WeatherServiceClient { 9 | private WeatherService weatherService; 10 | 11 | public void setWeatherService(WeatherService weatherService) { 12 | this.weatherService = weatherService; 13 | } 14 | 15 | public TemperatureInfo getTodayTemperature(String city) { 16 | List dates = Arrays.asList(new Date[] { new Date() }); 17 | List temperatures = weatherService.getTemperatures(city, dates); 18 | 19 | return temperatures.get(0); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting-soap-standalone/src/main/java/com/apress/springrecipes/weather/WeatherServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | import javax.jws.WebMethod; 8 | import javax.jws.WebService; 9 | 10 | 11 | @WebService(serviceName = "WeatherService") 12 | public class WeatherServiceImpl implements WeatherService { 13 | @WebMethod(operationName = "getTemperatures") 14 | public List getTemperatures(String city, List dates) { 15 | List temperatures = new ArrayList(); 16 | 17 | for (Date date : dates) { 18 | temperatures.add(new TemperatureInfo(city, date, 5.0, 10.0, 8.0)); 19 | } 20 | 21 | return temperatures; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting-soap-standalone/src/main/resources/standalone-server.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting-soap/src/main/java/com/apress/springrecipes/weather/Client.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | 7 | public class Client { 8 | public static void main(String[] args) { 9 | ApplicationContext context = new ClassPathXmlApplicationContext("client.xml"); 10 | WeatherServiceClient client = (WeatherServiceClient) context.getBean("client"); 11 | 12 | TemperatureInfo temperature = client.getTodayTemperature("Houston"); 13 | System.out.println("Min temperature : " + temperature.getMin()); 14 | System.out.println("Max temperature : " + temperature.getMax()); 15 | System.out.println("Average temperature : " + temperature.getAverage()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting-soap/src/main/java/com/apress/springrecipes/weather/WeatherService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import javax.jws.WebService; 7 | 8 | 9 | @WebService 10 | public interface WeatherService { 11 | public List getTemperatures(String city, List dates); 12 | } 13 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting-soap/src/main/java/com/apress/springrecipes/weather/WeatherServiceClient.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import java.util.Arrays; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | 8 | public class WeatherServiceClient { 9 | private WeatherService weatherService; 10 | 11 | public void setWeatherService(WeatherService weatherService) { 12 | this.weatherService = weatherService; 13 | } 14 | 15 | public TemperatureInfo getTodayTemperature(String city) { 16 | List dates = Arrays.asList(new Date[] { new Date() }); 17 | List temperatures = weatherService.getTemperatures(city, dates); 18 | 19 | return temperatures.get(0); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting-soap/src/main/java/com/apress/springrecipes/weather/WeatherServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | import javax.jws.WebMethod; 8 | import javax.jws.WebService; 9 | 10 | 11 | @WebService(serviceName = "WeatherService", endpointInterface = "com.apress.springrecipes.weather.WeatherService") 12 | public class WeatherServiceImpl implements WeatherService { 13 | @WebMethod(operationName = "getTemperatures") 14 | public List getTemperatures(String city, List dates) { 15 | List temperatures = new ArrayList(); 16 | 17 | for (Date date : dates) { 18 | temperatures.add(new TemperatureInfo(city, date, 5.0, 10.0, 8.0)); 19 | } 20 | 21 | return temperatures; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting-soap/src/main/webapp/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting-soap/src/main/webapp/WEB-INF/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting/src/main/java/com/apress/springrecipes/weather/Client.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | 7 | public class Client { 8 | public static void main(String[] args) { 9 | ApplicationContext context = new ClassPathXmlApplicationContext("client.xml"); 10 | WeatherServiceClient client = (WeatherServiceClient) context.getBean("client"); 11 | 12 | TemperatureInfo temperature = client.getTodayTemperature("Houston"); 13 | System.out.println("Min temperature : " + temperature.getMin()); 14 | System.out.println("Max temperature : " + temperature.getMax()); 15 | System.out.println("Average temperature : " + temperature.getAverage()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting/src/main/java/com/apress/springrecipes/weather/RmiServer.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import org.springframework.context.support.ClassPathXmlApplicationContext; 4 | 5 | 6 | public class RmiServer { 7 | public static void main(String[] args) { 8 | new ClassPathXmlApplicationContext("rmi-server.xml"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting/src/main/java/com/apress/springrecipes/weather/WeatherService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | 7 | public interface WeatherService { 8 | public List getTemperatures(String city, List dates); 9 | } 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting/src/main/java/com/apress/springrecipes/weather/WeatherServiceClient.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import java.util.Arrays; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | 8 | public class WeatherServiceClient { 9 | private WeatherService weatherService; 10 | 11 | public void setWeatherService(WeatherService weatherService) { 12 | this.weatherService = weatherService; 13 | } 14 | 15 | public TemperatureInfo getTodayTemperature(String city) { 16 | List dates = Arrays.asList(new Date()); 17 | List temperatures = weatherService.getTemperatures(city, dates); 18 | 19 | return temperatures.get(0); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting/src/main/java/com/apress/springrecipes/weather/WeatherServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | import javax.jws.WebMethod; 8 | import javax.jws.WebService; 9 | 10 | 11 | public class WeatherServiceImpl implements WeatherService { 12 | public List getTemperatures(String city, List dates) { 13 | List temperatures = new ArrayList(); 14 | 15 | for (Date date : dates) { 16 | temperatures.add(new TemperatureInfo(city, date, 5.0, 10.0, 8.0)); 17 | } 18 | 19 | return temperatures; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting/src/main/resources/rmi-server.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting/src/main/webapp/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting/src/main/webapp/WEB-INF/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-remoting/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | org.springframework.web.context.ContextLoaderListener 8 | 9 | 10 | 11 | 12 | weather 13 | 14 | org.springframework.web.servlet.DispatcherServlet 15 | 16 | 1 17 | 18 | 19 | 20 | weather 21 | /services/* 22 | 23 | 24 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-ws/src/main/java/com/apress/springrecipes/weather/Client.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | 7 | public class Client { 8 | public static void main(String[] args) { 9 | ApplicationContext context = new ClassPathXmlApplicationContext("client.xml"); 10 | WeatherServiceClient client = (WeatherServiceClient) context.getBean("client"); 11 | 12 | TemperatureInfo temperature = client.getTodayTemperature("Houston"); 13 | System.out.println("Min temperature : " + temperature.getMin()); 14 | System.out.println("Max temperature : " + temperature.getMax()); 15 | System.out.println("Average temperature : " + temperature.getAverage()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-ws/src/main/java/com/apress/springrecipes/weather/GetTemperaturesRequest.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | 7 | public class GetTemperaturesRequest { 8 | private String city; 9 | private List dates; 10 | 11 | public GetTemperaturesRequest() { 12 | } 13 | 14 | public GetTemperaturesRequest(String city, List dates) { 15 | this.city = city; 16 | this.dates = dates; 17 | } 18 | 19 | public String getCity() { 20 | return city; 21 | } 22 | 23 | public List getDates() { 24 | return dates; 25 | } 26 | 27 | public void setCity(String city) { 28 | this.city = city; 29 | } 30 | 31 | public void setDates(List dates) { 32 | this.dates = dates; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-ws/src/main/java/com/apress/springrecipes/weather/GetTemperaturesResponse.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import java.util.List; 4 | 5 | 6 | public class GetTemperaturesResponse { 7 | private List temperatures; 8 | 9 | public GetTemperaturesResponse() { 10 | } 11 | 12 | public GetTemperaturesResponse(List temperatures) { 13 | this.temperatures = temperatures; 14 | } 15 | 16 | public List getTemperatures() { 17 | return temperatures; 18 | } 19 | 20 | public void setTemperatures(List temperatures) { 21 | this.temperatures = temperatures; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-ws/src/main/java/com/apress/springrecipes/weather/WeatherService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | 7 | public interface WeatherService { 8 | public List getTemperatures(String city, List dates); 9 | } 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-ws/src/main/java/com/apress/springrecipes/weather/WeatherServiceClient.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import java.util.Arrays; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | 8 | public class WeatherServiceClient { 9 | private WeatherService weatherService; 10 | 11 | public void setWeatherService(WeatherService weatherService) { 12 | this.weatherService = weatherService; 13 | } 14 | 15 | public TemperatureInfo getTodayTemperature(String city) { 16 | List dates = Arrays.asList(new Date[] { new Date() }); 17 | List temperatures = weatherService.getTemperatures(city, dates); 18 | 19 | return temperatures.get(0); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-ws/src/main/java/com/apress/springrecipes/weather/WeatherServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | 8 | public class WeatherServiceImpl implements WeatherService { 9 | public List getTemperatures(String city, List dates) { 10 | List temperatures = new ArrayList(); 11 | 12 | for (Date date : dates) { 13 | temperatures.add(new TemperatureInfo(city, date, 5.0, 10.0, 8.0)); 14 | } 15 | 16 | return temperatures; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-ws/src/main/java/com/apress/springrecipes/weather/WeatherServiceProxy.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.weather; 2 | 3 | import org.springframework.ws.client.core.support.WebServiceGatewaySupport; 4 | 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | 9 | public class WeatherServiceProxy extends WebServiceGatewaySupport implements WeatherService { 10 | public List getTemperatures(String city, List dates) { 11 | GetTemperaturesRequest request = new GetTemperaturesRequest(city, dates); 12 | GetTemperaturesResponse response = (GetTemperaturesResponse) getWebServiceTemplate().marshalSendAndReceive(request); 13 | 14 | return response.getTemperatures(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-ws/src/main/resources/request.xml: -------------------------------------------------------------------------------- 1 | 3 | Houston 4 | 2007-12-01 5 | 2007-12-08 6 | 2007-12-15 7 | 8 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-ws/src/main/resources/response.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5.0 5 | 10.0 6 | 8.0 7 | 8 | 9 | 4.0 10 | 13.0 11 | 7.0 12 | 13 | 14 | 10.0 15 | 18.0 16 | 15.0 17 | 18 | 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-ws/src/main/webapp/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/rpc/weather-ws/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | weather 8 | 9 | org.springframework.ws.transport.http.MessageDispatcherServlet 10 | 11 | 1 12 | 13 | 14 | 15 | weather 16 | /services/* 17 | 18 | 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/security/src/main/java/com/apress/springrecipes/board/service/MessageBoardService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.board.service; 2 | 3 | import java.util.List; 4 | 5 | import com.apress.springrecipes.board.domain.Message; 6 | 7 | public interface MessageBoardService { 8 | 9 | public List listMessages(); 10 | public void postMessage(Message message); 11 | public void deleteMessage(Message message); 12 | public Message findMessageById(Long messageId); 13 | } 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/security/src/main/webapp/WEB-INF/board-servlet.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/security/src/main/webapp/WEB-INF/jsp/messagePost.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 2 | 3 | 4 | 5 | Message Post 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
Title
Body
23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springbatch/src/main/java/com/apress/springrecipes/springbatch/UserRegistrationService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springbatch; 2 | 3 | import java.util.Collection; 4 | import java.util.Date; 5 | 6 | public interface UserRegistrationService { 7 | Collection getOutstandingUserRegistrationBatchForDate(int quantity, Date date); 8 | UserRegistration registerUser(UserRegistration userRegistrationRegistration); 9 | } 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springbatch/src/main/java/com/apress/springrecipes/springbatch/solution2/ConditionalTasklet.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springbatch.solution2; 2 | 3 | import org.springframework.batch.core.StepContribution; 4 | import org.springframework.batch.core.scope.context.ChunkContext; 5 | import org.springframework.batch.core.step.tasklet.Tasklet; 6 | import org.springframework.batch.repeat.RepeatStatus; 7 | 8 | 9 | public class ConditionalTasklet implements Tasklet { 10 | @Override 11 | public RepeatStatus execute(StepContribution arg0, ChunkContext arg1) 12 | throws Exception { 13 | RepeatStatus status = (Math.random() > .5) ? RepeatStatus.FINISHED : null; 14 | 15 | return status; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springbatch/src/main/java/com/apress/springrecipes/springbatch/solution2/HoroscopeDecider.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springbatch.solution2; 2 | 3 | import org.springframework.batch.core.JobExecution; 4 | import org.springframework.batch.core.StepExecution; 5 | import org.springframework.batch.core.job.flow.FlowExecutionStatus; 6 | import org.springframework.batch.core.job.flow.JobExecutionDecider; 7 | 8 | 9 | public class HoroscopeDecider implements JobExecutionDecider { 10 | private boolean mercuryIsInRetrograde = Math.random() > .5; 11 | 12 | public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { 13 | if (mercuryIsInRetrograde) { 14 | return FlowExecutionStatus.FAILED; 15 | } 16 | 17 | return FlowExecutionStatus.COMPLETED; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springbatch/src/main/resources/batch.properties: -------------------------------------------------------------------------------- 1 | hibernate.configFile=hibernate.cfg.xml 2 | dataSource.password=sep 3 | dataSource.username=sep 4 | dataSource.databaseName=sep 5 | dataSource.driverClassName=org.postgresql.Driver 6 | dataSource.dialect=org.hibernate.dialect.PostgreSQLDialect 7 | dataSource.serverName=studio:5432 8 | dataSource.url=jdbc:postgresql://${dataSource.serverName}/${dataSource.databaseName} 9 | dataSource.properties=user=${dataSource.username};databaseName=${dataSource.databaseName};serverName=${dataSource.serverName};password=${dataSource.password} 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springbatch/src/main/resources/sample/registrations.csv: -------------------------------------------------------------------------------- 1 | Josh,Long,Apress,2343 Street St,Los Angeles,CA,90211,Los Angeles County,http://www.joshlong.com,222.232.2322,342.232.5333 2 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springbatch/src/main/resources/sql/drop_all.sql: -------------------------------------------------------------------------------- 1 | begin; 2 | 3 | drop table batch_job_execution cascade ; 4 | drop table batch_job_execution_context cascade; 5 | drop table batch_job_instance cascade; 6 | drop table batch_job_params cascade; 7 | drop table batch_step_execution cascade; 8 | drop table batch_step_execution_context cascade ; 9 | 10 | DROP SEQUENCE batch_job_execution_seq; 11 | DROP SEQUENCE batch_job_seq; 12 | DROP SEQUENCE batch_step_execution_seq; 13 | 14 | commit; -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springbatch/src/main/resources/sql/reset_user_registration.sql: -------------------------------------------------------------------------------- 1 | drop table USER_REGISTRATION; 2 | 3 | create table USER_REGISTRATION 4 | ( 5 | ID bigserial not null , 6 | FIRST_NAME character varying(255) not null, 7 | LAST_NAME character varying(255) not null, 8 | COMPANY character varying(255) not null, 9 | ADDRESS character varying(255) not null, 10 | CITY character varying(255) not null, 11 | STATE character varying(255) not null, 12 | ZIP character varying(255) not null, 13 | COUNTY character varying(255) not null, 14 | URL character varying(255) not null, 15 | PHONE_NUMBER character varying(255) not null, 16 | FAX character varying(255) not null, 17 | constraint USER_REGISTRATION_PKEY primary key (id) 18 | ) ; 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springbatch/src/main/resources/sql/truncate_all.sql: -------------------------------------------------------------------------------- 1 | -- this script is meant to truncate the Spring Batch-specific tables 2 | begin ; 3 | truncate batch_job_execution cascade ; 4 | truncate batch_job_execution_context cascade; 5 | truncate batch_job_instance cascade; 6 | truncate batch_job_params cascade; 7 | truncate batch_step_execution cascade; 8 | truncate batch_step_execution_context cascade ; 9 | commit; 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintegration/src/main/java/com/apress/springrecipes/springintegration/AdditionService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springintegration; 2 | 3 | 4 | /** 5 | * simple example designed to demonstrate adding over queues! Horribly inefficient, but it demonstrates a point. 6 | */ 7 | public class AdditionService { 8 | public Number add(Operands ops) { 9 | return (ops.getA().floatValue() + ops.getB().floatValue()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintegration/src/main/java/com/apress/springrecipes/springintegration/CustomerCreditScoreRouter.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springintegration; 2 | 3 | import org.springframework.integration.annotation.Router; 4 | 5 | 6 | public class CustomerCreditScoreRouter { 7 | @Router 8 | public String routeByCustomerCreditScore(Customer customer) { 9 | if (customer.getCreditScore() > 770) { 10 | System.out.println("Credit score > 770, routing to safeCustomerChannel"); 11 | 12 | return "safeCustomerChannel"; 13 | } else { 14 | System.out.println("Credit score <= 770, routing to riskyCustomerChannel"); 15 | 16 | return "riskyCustomerChannel"; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintegration/src/main/java/com/apress/springrecipes/springintegration/CustomerDeletionServiceActivator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springintegration; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | import org.springframework.integration.annotation.ServiceActivator; 6 | import org.springframework.integration.core.Message; 7 | 8 | public class CustomerDeletionServiceActivator { 9 | static private Logger logger = Logger.getLogger(CustomerDeletionServiceActivator.class); 10 | 11 | @ServiceActivator 12 | public void deleteCustomer(Message customerIdPayload) { 13 | logger.debug(String.format("the id of the customer to delete is %s", customerIdPayload.getPayload())); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintegration/src/main/java/com/apress/springrecipes/springintegration/CustomerIdToCustomerTransformer.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springintegration; 2 | 3 | import org.springframework.integration.annotation.Transformer; 4 | 5 | 6 | public class CustomerIdToCustomerTransformer { 7 | @Transformer 8 | public Customer fromCustomerId(String id) { 9 | // in a real integration you'd probably use this point to look up the 10 | // Customer in the DB 11 | Customer customer = new Customer(); 12 | customer.setId(Long.parseLong(id)); 13 | customer.setCreditScore((float) (Math.random() * 1000)); 14 | 15 | // customer.set* 16 | return customer; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintegration/src/main/java/com/apress/springrecipes/springintegration/DefaultCustomerServiceActivator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springintegration; 2 | 3 | import org.springframework.integration.annotation.ServiceActivator; 4 | 5 | 6 | public class DefaultCustomerServiceActivator { 7 | @ServiceActivator 8 | public void handleCustomer(Customer customer) { 9 | System.out.println("customer.creditScore=" + customer.getCreditScore()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintegration/src/main/java/com/apress/springrecipes/springintegration/InboundCustomerServiceActivator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springintegration; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | import org.springframework.integration.annotation.ServiceActivator; 6 | import org.springframework.integration.core.Message; 7 | 8 | 9 | public class InboundCustomerServiceActivator { 10 | private static final Logger logger = Logger.getLogger(InboundCustomerServiceActivator.class); 11 | 12 | @ServiceActivator 13 | public void doSomethingWithCustomer(Message customerMessage) { 14 | Customer customer = customerMessage.getPayload(); 15 | logger.debug(String.format("id=%s, firstName:%s, lastName:%s", customer.getId(), customer.getFirstName(), customer.getLastName())); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintegration/src/main/java/com/apress/springrecipes/springintegration/InboundHelloWorldFileMessageProcessor.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springintegration; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | import org.springframework.integration.annotation.ServiceActivator; 6 | import org.springframework.integration.core.Message; 7 | 8 | import java.io.File; 9 | 10 | 11 | public class InboundHelloWorldFileMessageProcessor { 12 | private static final Logger logger = Logger.getLogger(InboundHelloWorldFileMessageProcessor.class); 13 | 14 | @ServiceActivator 15 | public void handleIncomingFileMessage(Message inboundJmsMessage) 16 | throws Throwable { 17 | File filePayload = inboundJmsMessage.getPayload(); 18 | System.out.println(String.format("absolute path: %s, size: %s", filePayload.getAbsolutePath(), filePayload.length())); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintegration/src/main/java/com/apress/springrecipes/springintegration/Main.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springintegration; 2 | 3 | import org.springframework.context.support.ClassPathXmlApplicationContext; 4 | 5 | 6 | public class Main { 7 | public static void main(String[] args) { 8 | String contextName = "09-1-gateways_service.xml"; 9 | 10 | ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(contextName); 11 | applicationContext.start(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintegration/src/main/java/com/apress/springrecipes/springintegration/MessagePayloadAggregator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springintegration; 2 | 3 | import org.springframework.integration.annotation.Aggregator; 4 | import org.springframework.integration.core.Message; 5 | import org.springframework.integration.message.MessageBuilder; 6 | 7 | import java.util.List; 8 | 9 | 10 | public class MessagePayloadAggregator { 11 | @Aggregator 12 | public Message joinMessages(List> customers) { 13 | if (customers.size() > 0) { 14 | return MessageBuilder.withPayload(customers).copyHeadersIfAbsent(customers.get(0).getHeaders()).build(); 15 | } 16 | 17 | return null; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintegration/src/main/java/com/apress/springrecipes/springintegration/MyCustomException.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springintegration; 2 | 3 | public class MyCustomException extends Exception { 4 | } 5 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintegration/src/main/java/com/apress/springrecipes/springintegration/myholiday/VacationService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springintegration.myholiday; 2 | 3 | import org.springframework.integration.annotation.Gateway; 4 | 5 | import java.util.List; 6 | 7 | 8 | public interface VacationService { 9 | @Gateway(requestChannel = "requests", replyChannel = "responses") 10 | List findHotels(HotelReservationSearch hotelReservationSearch); 11 | } 12 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintegration/src/main/java/com/apress/springrecipes/springintegration/twitter/TwitterMessageConstants.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springintegration.twitter; 2 | 3 | 4 | /** 5 | * I'm not sure if this will ever get used. .... 6 | */ 7 | public class TwitterMessageConstants { 8 | // ... 9 | } 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintegration/src/main/java/com/apress/springrecipes/springintegration/twitter/TwitterMessageOutput.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.springintegration.twitter; 2 | 3 | public class TwitterMessageOutput { 4 | public void announce(Tweet tweet) { 5 | System.out.println(tweet.toString()); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintegration/src/main/resources/08-adaptingexternalsystemstothebus.properties: -------------------------------------------------------------------------------- 1 | twitter.userId=twitterUser 2 | twitter.password=twitterPassword 3 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintro/src/main/java/com/apress/springrecipes/hello/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.hello; 2 | 3 | import java.util.List; 4 | 5 | public class HelloWorld { 6 | 7 | private String message; 8 | private List holidays; 9 | 10 | public void setMessage(String message) { 11 | this.message = message; 12 | } 13 | 14 | public void setHolidays(List holidays) { 15 | this.holidays = holidays; 16 | } 17 | 18 | public void hello() { 19 | System.out.println("Hello! " + message); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintro/src/main/java/com/apress/springrecipes/hello/Holiday.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.hello; 2 | 3 | public class Holiday { 4 | 5 | private int month; 6 | private int day; 7 | private String greeting; 8 | 9 | public int getMonth() { 10 | return month; 11 | } 12 | 13 | public void setMonth(int month) { 14 | this.month = month; 15 | } 16 | 17 | public int getDay() { 18 | return day; 19 | } 20 | 21 | public void setDay(int day) { 22 | this.day = day; 23 | } 24 | 25 | public String getGreeting() { 26 | return greeting; 27 | } 28 | 29 | public void setGreeting(String greeting) { 30 | this.greeting = greeting; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springintro/src/main/java/com/apress/springrecipes/hello/Main.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.hello; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | public class Main { 7 | 8 | public static void main(String[] args) { 9 | ApplicationContext context = 10 | new ClassPathXmlApplicationContext("beans.xml"); 11 | 12 | HelloWorld helloWorld = (HelloWorld) context.getBean("helloWorld"); 13 | helloWorld.hello(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springweb/city-dwr/src/main/java/com/apress/springrecipes/city/CityService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.city; 2 | 3 | public interface CityService { 4 | double findDistance(String srcCity, String destCity); 5 | } 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springweb/city-dwr/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | org.springframework.web.context.ContextLoaderListener 9 | 10 | 11 | 12 | 13 | dwr 14 | org.directwebremoting.spring.DwrSpringServlet 15 | 16 | 17 | 18 | dwr 19 | /dwr/* 20 | 21 | 22 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springweb/city-jsf/src/main/java/com/apress/springrecipes/city/CityService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.city; 2 | 3 | public interface CityService { 4 | double findDistance(String srcCity, String destCity); 5 | } 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springweb/city-jsf/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # Set root logger level to DEBUG and its only appender to A1. 2 | log4j.rootLogger=INFO, A1 3 | 4 | # A1 is set to be a ConsoleAppender. 5 | log4j.appender.A1=org.apache.log4j.ConsoleAppender 6 | 7 | # A1 uses PatternLayout. 8 | log4j.appender.A1.layout=org.apache.log4j.PatternLayout 9 | log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n 10 | 11 | # Print messages up to level INFO 12 | log4j.logger.net.jawr=DEBUG 13 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springweb/city-servlets/src/main/java/com/apress/springrecipes/city/CityService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.city; 2 | 3 | public interface CityService { 4 | 5 | double findDistance(String srcCity, String destCity); 6 | } 7 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springweb/city-servlets/src/main/java/com/apress/springrecipes/city/CityServiceRequestAuditor.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.city; 2 | 3 | import java.util.Map; 4 | 5 | 6 | /** 7 | * A bean designed only to note inbound request signiatures 8 | */ 9 | public class CityServiceRequestAuditor { 10 | public void log(Map attributes) { 11 | for (String k : attributes.keySet()) { 12 | System.out.println(String.format("%s=%s", k, attributes.get(k))); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springweb/city-servlets/src/main/webapp/WEB-INF/jsp/distance.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | City Distance 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
Source City
Destination City
Distance${distance}
25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springweb/city-struts/src/main/java/com/apress/springrecipes/city/CityService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.city; 2 | 3 | public interface CityService { 4 | double findDistance(String srcCity, String destCity); 5 | } 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springweb/city-struts/src/main/java/com/apress/springrecipes/city/struts/DistanceForm.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.city.struts; 2 | 3 | import org.apache.struts.action.ActionForm; 4 | 5 | 6 | public class DistanceForm extends ActionForm { 7 | 8 | private String srcCity; 9 | private String destCity; 10 | 11 | public String getDestCity() { 12 | return destCity; 13 | } 14 | 15 | public String getSrcCity() { 16 | return srcCity; 17 | } 18 | 19 | public void setDestCity(String destCity) { 20 | this.destCity = destCity; 21 | } 22 | 23 | public void setSrcCity(String srcCity) { 24 | this.srcCity = srcCity; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springweb/city-struts/src/main/webapp/WEB-INF/action-servlet.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springweb/city-struts/src/main/webapp/WEB-INF/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springweb/city-struts/src/main/webapp/WEB-INF/jsp/distance.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %> 2 | 3 | 4 | 5 | City Distance 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
Source City
Destination City
Distance${distance}
27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springweb/city-struts/src/main/webapp/WEB-INF/struts-config.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/springweb/city-struts/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | org.springframework.web.context.ContextLoaderListener 9 | 10 | 11 | 12 | 13 | action 14 | 15 | org.apache.struts.action.ActionServlet 16 | 17 | 18 | 19 | 20 | action 21 | *.do 22 | 23 | 24 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/testing/src/main/java/com/apress/springrecipes/bank/com/apress/springrecipes/bank/AccountDao.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.bank; 2 | 3 | public interface AccountDao { 4 | 5 | public void createAccount(Account account); 6 | public void updateAccount(Account account); 7 | public void removeAccount(Account account); 8 | public Account findAccount(String accountNo); 9 | } 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/testing/src/main/java/com/apress/springrecipes/bank/com/apress/springrecipes/bank/AccountNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.bank; 2 | 3 | public class AccountNotFoundException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/testing/src/main/java/com/apress/springrecipes/bank/com/apress/springrecipes/bank/AccountService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.bank; 2 | 3 | public interface AccountService { 4 | 5 | public void createAccount(String accountNo); 6 | public void removeAccount(String accountNo); 7 | public void deposit(String accountNo, double amount); 8 | public void withdraw(String accountNo, double amount); 9 | public double getBalance(String accountNo); 10 | } 11 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/testing/src/main/java/com/apress/springrecipes/bank/com/apress/springrecipes/bank/DuplicateAccountException.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.bank; 2 | 3 | public class DuplicateAccountException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/testing/src/main/java/com/apress/springrecipes/bank/com/apress/springrecipes/bank/InsufficientBalanceException.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.bank; 2 | 3 | public class InsufficientBalanceException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/testing/src/main/java/com/apress/springrecipes/bank/com/apress/springrecipes/bank/InterestCalculator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.bank; 2 | 3 | public interface InterestCalculator { 4 | 5 | public void setRate(double rate); 6 | public double calculate(double amount, double year); 7 | } 8 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/testing/src/main/java/com/apress/springrecipes/bank/com/apress/springrecipes/bank/SimpleInterestCalculator.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.bank; 2 | 3 | public class SimpleInterestCalculator implements InterestCalculator { 4 | 5 | private double rate; 6 | 7 | public void setRate(double rate) { 8 | this.rate = rate; 9 | } 10 | 11 | public double calculate(double amount, double year) { 12 | if (amount < 0 || year < 0) { 13 | throw new IllegalArgumentException("Amount or year must be positive"); 14 | } 15 | return amount * year * rate; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/testing/src/main/resources/bank.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE ACCOUNT ( 2 | ACCOUNT_NO VARCHAR(10) NOT NULL, 3 | BALANCE DOUBLE NOT NULL, 4 | PRIMARY KEY (ACCOUNT_NO) 5 | ); 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/testing/src/test/java/com/apress/springrecipes/bank/SimpleInterestCalculatorJUnit4Tests.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.bank; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | 8 | public class SimpleInterestCalculatorJUnit4Tests { 9 | 10 | private InterestCalculator interestCalculator; 11 | 12 | @Before 13 | public void init() { 14 | interestCalculator = new SimpleInterestCalculator(); 15 | interestCalculator.setRate(0.05); 16 | } 17 | 18 | @Test 19 | public void calculate() { 20 | double interest = interestCalculator.calculate(10000, 2); 21 | assertEquals(interest, 1000.0, 0); 22 | } 23 | 24 | @Test(expected = IllegalArgumentException.class) 25 | public void illegalCalculate() { 26 | interestCalculator.calculate(-10000, 2); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/testing/src/test/resources/bank.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE ACCOUNT ( 2 | ACCOUNT_NO VARCHAR(10) NOT NULL, 3 | BALANCE DOUBLE NOT NULL, 4 | PRIMARY KEY (ACCOUNT_NO) 5 | ); 6 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/transactions/src/main/java/com/apress/springrecipes/bookshop/spring/BookShop.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.bookshop.spring; 2 | 3 | public interface BookShop { 4 | public void purchase(String isbn, String username); 5 | 6 | public void increaseStock(String isbn, int stock); 7 | 8 | public int checkStock(String isbn); 9 | } 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/transactions/src/main/java/com/apress/springrecipes/bookshop/spring/BookShopCashier.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.bookshop.spring; 2 | 3 | import org.springframework.transaction.annotation.Propagation; 4 | import org.springframework.transaction.annotation.Transactional; 5 | 6 | import java.util.List; 7 | 8 | 9 | public class BookShopCashier implements Cashier { 10 | private BookShop bookShop; 11 | 12 | public void setBookShop(BookShop bookShop) { 13 | this.bookShop = bookShop; 14 | } 15 | 16 | @Transactional(propagation = Propagation.REQUIRED) 17 | public void checkout(List isbns, String username) { 18 | for (String isbn : isbns) { 19 | bookShop.purchase(isbn, username); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/transactions/src/main/java/com/apress/springrecipes/bookshop/spring/Cashier.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.bookshop.spring; 2 | 3 | import java.util.List; 4 | 5 | 6 | public interface Cashier { 7 | public void checkout(List isbns, String username); 8 | } 9 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/transactions/src/main/resources/bookstore.sql: -------------------------------------------------------------------------------- 1 | -- DROP TABLE ACCOUNT; DROP TABLE BOOK_STOCK; DROP TABLE BOOK; 2 | 3 | CREATE TABLE BOOK ( 4 | ISBN VARCHAR(50) NOT NULL, 5 | BOOK_NAME VARCHAR(100) NOT NULL, 6 | PRICE INT, 7 | PRIMARY KEY (ISBN) 8 | ); 9 | 10 | CREATE TABLE BOOK_STOCK ( 11 | ISBN VARCHAR(50) NOT NULL, 12 | STOCK INT NOT NULL, 13 | PRIMARY KEY (ISBN), 14 | CHECK (STOCK >= 0) 15 | ); 16 | 17 | CREATE TABLE ACCOUNT ( 18 | USERNAME VARCHAR(50) NOT NULL, 19 | BALANCE INT NOT NULL, 20 | PRIMARY KEY (USERNAME), 21 | CHECK (BALANCE >= 0) 22 | ); 23 | 24 | INSERT INTO BOOK( ISBN, BOOK_NAME, PRICE ) VALUES( '0001', 'The First Book', 30); 25 | INSERT INTO BOOK_STOCK(ISBN, STOCK) VALUES('0001', 10) ; 26 | INSERT INTO ACCOUNT(USERNAME, BALANCE) VALUES('user1',20); 27 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/jsf/src/main/java/com/apress/springrecipes/library/web/PropertyEditors.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.library.web; 2 | 3 | import org.springframework.beans.PropertyEditorRegistrar; 4 | import org.springframework.beans.PropertyEditorRegistry; 5 | import org.springframework.beans.propertyeditors.CustomDateEditor; 6 | 7 | import java.text.SimpleDateFormat; 8 | 9 | import java.util.Date; 10 | 11 | 12 | public class PropertyEditors implements PropertyEditorRegistrar { 13 | public void registerCustomEditors(PropertyEditorRegistry registry) { 14 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); 15 | dateFormat.setLenient(false); 16 | registry.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/jsf/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/jsf/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/jsf/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | com.sun.facelets.FaceletViewHandler 7 | org.springframework.web.jsf.el.SpringBeanFacesELResolver 8 | 9 | 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/jsf/src/main/webapp/WEB-INF/library-security.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/jsf/src/main/webapp/WEB-INF/library-servlet.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/jsf/src/main/webapp/WEB-INF/template.xhtml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 6 | 7 | <ui:insert name="title">Library</ui:insert> 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/jsf_richfaces/src/main/java/com/apress/springrecipes/signup/web/CounterBean.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.signup.web; 2 | 3 | import java.io.Serializable; 4 | 5 | 6 | /** 7 | * This is a simple bean that we use to demonstrate RichFaces' ability to update state via Ajax 8 | */ 9 | public class CounterBean implements Serializable { 10 | private static final long serialVersionUID = 1L; 11 | private int count; 12 | 13 | public void updateCount() { 14 | this.count += 1; 15 | } 16 | 17 | public void setCount(int count) { 18 | this.count = count; 19 | } 20 | 21 | public int getCount() { 22 | return count; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/jsf_richfaces/src/main/webapp/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/jsf_richfaces/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/jsf_richfaces/src/main/webapp/WEB-INF/counter-servlet.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/jsf_richfaces/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | com.sun.facelets.FaceletViewHandler 7 | org.springframework.web.jsf.el.SpringBeanFacesELResolver 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/jsf_richfaces/src/main/webapp/WEB-INF/template/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | <ui:insert name="title"/> 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/jsf_richfaces/src/main/webapp/flows/counter/counter-flow.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 4.0.0 6 | 7 | 8 | com.apress.springrecipes 9 | web_flow 10 | 1.0-SNAPSHOT 11 | 12 | web_flow_mvc 13 | Web Flow - MVC 14 | war 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/java/com/apress/springrecipes/library/domain/BookCriteria.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.library.domain; 2 | 3 | import java.io.Serializable; 4 | 5 | 6 | public class BookCriteria implements Serializable { 7 | private String keyword; 8 | private String author; 9 | 10 | public String getAuthor() { 11 | return author; 12 | } 13 | 14 | public String getKeyword() { 15 | return keyword; 16 | } 17 | 18 | public void setAuthor(String author) { 19 | this.author = author; 20 | } 21 | 22 | public void setKeyword(String keyword) { 23 | this.keyword = keyword; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/java/com/apress/springrecipes/library/service/BookService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.library.service; 2 | 3 | import com.apress.springrecipes.library.domain.Book; 4 | import com.apress.springrecipes.library.domain.BookCriteria; 5 | 6 | import java.util.List; 7 | 8 | 9 | public interface BookService { 10 | public List search(BookCriteria criteria); 11 | 12 | public Book findByIsbn(String isbn); 13 | } 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/java/com/apress/springrecipes/library/service/LibraryService.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.library.service; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | 7 | public interface LibraryService { 8 | public List getHolidays(); 9 | } 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/java/com/apress/springrecipes/library/service/LibraryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.library.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Date; 5 | import java.util.GregorianCalendar; 6 | import java.util.List; 7 | 8 | 9 | public class LibraryServiceImpl implements LibraryService { 10 | public List getHolidays() { 11 | List holidays = new ArrayList(); 12 | holidays.add(new GregorianCalendar(2007, 11, 25).getTime()); 13 | holidays.add(new GregorianCalendar(2008, 0, 1).getTime()); 14 | 15 | return holidays; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/java/com/apress/springrecipes/library/web/PropertyEditors.java: -------------------------------------------------------------------------------- 1 | package com.apress.springrecipes.library.web; 2 | 3 | import org.springframework.beans.PropertyEditorRegistrar; 4 | import org.springframework.beans.PropertyEditorRegistry; 5 | import org.springframework.beans.propertyeditors.CustomDateEditor; 6 | 7 | import java.text.SimpleDateFormat; 8 | 9 | import java.util.Date; 10 | 11 | 12 | public class PropertyEditors implements PropertyEditorRegistrar { 13 | public void registerCustomEditors(PropertyEditorRegistry registry) { 14 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); 15 | dateFormat.setLenient(false); 16 | registry.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/webapp/WEB-INF/flows/bookDetails/bookDetails.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 3 | 4 | 5 | 6 | Book Details 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
ISBN${book.isbn}
Book Name${book.name}
Author${book.author}
Publish Date
28 | New Search 29 | 30 | 31 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/webapp/WEB-INF/flows/bookDetails/bookDetails.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/webapp/WEB-INF/flows/bookSearch/bookCriteria.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 2 | 3 | 4 | 5 | Book Criteria 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 24 |
Keyword
Author
21 | 22 |
25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/webapp/WEB-INF/flows/welcome/introduction.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 3 | 4 | 5 | 6 | Introduction 7 | 8 | 9 | 10 |

Library Holidays

11 | 12 |
13 |
14 | Next 15 | 16 | 17 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/webapp/WEB-INF/flows/welcome/menu.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | Menu 4 | 5 | 6 | 7 |

Menu

8 | 9 | 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/webapp/WEB-INF/flows/welcome/welcome.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | Welcome 4 | 5 | 6 | 7 |

Welcome!

8 | Next 9 | Skip 10 | 11 | 12 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/webapp/WEB-INF/flows/welcome/welcome.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/webapp/WEB-INF/library-servlet.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Spring Recipes 2nd Ed/web_flow/web_flow_mvc/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing to Apress Source Code 2 | 3 | Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. 4 | 5 | ## How to Contribute 6 | 7 | 1. Make sure you have a GitHub account. 8 | 2. Fork the repository for the relevant book. 9 | 3. Create a new branch on which to make your change, e.g. 10 | `git checkout -b my_code_contribution` 11 | 4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. 12 | 5. Submit a pull request. 13 | 14 | Thank you for your contribution! --------------------------------------------------------------------------------