Java tutorial
package edu.byu.softwareDistribution.web.controller; import edu.byu.security.userdetails.IdentityDetails; import edu.byu.softwareDist.dao.*; import edu.byu.softwareDist.domain.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import java.util.List; /** * @author Tyler Southwick (tyler_southwick@byu.edu) */ @Controller @RequestMapping("/admin") public class ListingController { private final ProductDao productDao; private final VendorDao vendorDao; private final FileSetDao fileSetDao; private final CommonTextDao commonTextDao; private final SoftwareGroupDao softwareGroupDao; private final LicenseSetDao licenseSetDao; private final MessageDao messageDao; @Autowired public ListingController(ProductDao productDao, VendorDao vendorDao, FileSetDao fileSetDao, CommonTextDao commonTextDao, SoftwareGroupDao softwareGroupDao, LicenseSetDao licenseSetDao, MessageDao messageDao) { this.productDao = productDao; this.vendorDao = vendorDao; this.fileSetDao = fileSetDao; this.commonTextDao = commonTextDao; this.softwareGroupDao = softwareGroupDao; this.licenseSetDao = licenseSetDao; this.messageDao = messageDao; } @RequestMapping("/products") public @ModelAttribute("products") List<Product> products(Model model) { model.addAttribute("signedInName", IdentityDetails.getCurrentIdentityDetails().getName()); return productDao.findAll(); } @RequestMapping("/vendors") public @ModelAttribute("vendors") List<Vendor> vendors(Model model) { model.addAttribute("signedInName", IdentityDetails.getCurrentIdentityDetails().getName()); return vendorDao.findAll(); } @RequestMapping("/fileSets") public @ModelAttribute("fileSets") List<FileSet> fileSets(Model model) { model.addAttribute("signedInName", IdentityDetails.getCurrentIdentityDetails().getName()); return fileSetDao.findAll(); } @RequestMapping("/commonText") public @ModelAttribute("commonText") List<CommonText> commonText(Model model) { model.addAttribute("signedInName", IdentityDetails.getCurrentIdentityDetails().getName()); return commonTextDao.findAll(); } @RequestMapping("/groups") public @ModelAttribute("softwareGroups") List<SoftwareGroup> softwareGroups(Model model) { model.addAttribute("signedInName", IdentityDetails.getCurrentIdentityDetails().getName()); return softwareGroupDao.findAll(); } @RequestMapping("/licenses") public @ModelAttribute("licenses") List<LicenseSet> licenseSets(Model model) { model.addAttribute("signedInName", IdentityDetails.getCurrentIdentityDetails().getName()); return licenseSetDao.findAll(); } @RequestMapping("/messages") public @ModelAttribute("messages") List<Message> messages(Model model) { model.addAttribute("signedInName", IdentityDetails.getCurrentIdentityDetails().getName()); return messageDao.findAll(); } }