Accessing WURFL Repository

The following sample shows how to access the WURFL repository from the servlet context. To understand how to use the GroupType to obtain capabilities, take a look the provisioning-wurfl-converter package for an example.

                public void service(HttpServletRequest request, HttpServletResponse response)
                throws IOException, ServletException {

                    ProvisioningContext provisioningContext = (ProvisioningContext)
                        this.getServletContext().getAttribute("javax.provisioning.ProvisioningContext");
                    DeliveryContext deliveryContext = provisioningContext.getDeliveryContext(request);
                    Capabilities capabilities = deliverycontext.getDeviceCapabilities();
                    List deviceIds = capabilities.getCapability(Constants.HardwarePlatform_DeviceIdentifier);
                    String deviceId = (String) deviceIds.get(0);

                    HibernateDAORegistry hibernateRegistry = (HibernateDAORegistry) this.getServletContext()
                    .getAttribute("org.jvending.registry.hibernate.HibernateDAORegistry");
                    WurflRepository wurflRepo = (WurflRepository) hibernateRegistry.find("wurfl");
                    List<GroupType> groups = wurflRepo.getGroupsByDeviceId(deviceId);
                }