springmvc-uadetector

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

Лицензия

Лицензия

Группа

Группа

com.github.mjeanroy
Идентификатор

Идентификатор

springmvc-uadetector
Последняя версия

Последняя версия

0.1.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

springmvc-uadetector
Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Ссылка на сайт

Ссылка на сайт

https://github.com/mjeanroy/springmvc-uadetector
Система контроля версий

Система контроля версий

https://github.com/mjeanroy/springmvc-uadetector

Скачать springmvc-uadetector

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.mjeanroy/springmvc-uadetector/ -->
<dependency>
    <groupId>com.github.mjeanroy</groupId>
    <artifactId>springmvc-uadetector</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.mjeanroy/springmvc-uadetector/
implementation 'com.github.mjeanroy:springmvc-uadetector:0.1.1'
// https://jarcasting.com/artifacts/com.github.mjeanroy/springmvc-uadetector/
implementation ("com.github.mjeanroy:springmvc-uadetector:0.1.1")
'com.github.mjeanroy:springmvc-uadetector:jar:0.1.1'
<dependency org="com.github.mjeanroy" name="springmvc-uadetector" rev="0.1.1">
  <artifact name="springmvc-uadetector" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.mjeanroy', module='springmvc-uadetector', version='0.1.1')
)
libraryDependencies += "com.github.mjeanroy" % "springmvc-uadetector" % "0.1.1"
[com.github.mjeanroy/springmvc-uadetector "0.1.1"]

Зависимости

compile (4)

Идентификатор библиотеки Тип Версия
net.sf.uadetector : uadetector-resources jar 2014.08
org.springframework : spring-webmvc jar 4.1.0.RELEASE
com.google.guava : guava Необязательный jar 17.0
net.sf.ehcache : ehcache Необязательный jar 2.8.4

provided (1)

Идентификатор библиотеки Тип Версия
javax.servlet : javax.servlet-api jar 3.1.0

test (4)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.11
org.mockito : mockito-all jar 1.9.5
org.assertj : assertj-core jar 1.6.1
org.apache.commons : commons-lang3 jar 3.3.2

Модули Проекта

Данный проект не имеет модулей.

SpringMVC-UADetectors


Simple library that can be used to wrap awesome uadetector library into your springmvc project.

Java Configuration

Just add EnableUADetector to be able to inject ReadableUserAgent arguments to your controller methods. This annotation can be configured with following parameters:

Parameter Values Description
cache NONE Do not use any cache.
DEFAULT Use simple cache provided by springmvc-uadetector (use a concurrent hashmap internally).
GUAVA Use guava cache (guava must be on classpath).
AUTO Use guava cache if guava is available or switch to simple cache implementation. This is the default.
autowire true Allow ReadableUserAgent and Browser arguments to be autowired.
false Disable autowiring of ReadableUserAgent and Browser arguments. This is the default.

Additions

In addition to ReadableUserAgent object, springmvc-uadetector allow you to use a Browser object that contains shortcuts on top of ReadableUserAgent to easily check well known browsers and specific Internet Explorer versions.

Here is a sample:

Browser browser = new Browser(readableUserAgent);

browser.isIE();
browser.isFirefox();
browser.isOpera();
browser.isSafari();
browser.isGoogleChrome();
browser.isChromium();

browser.isIE6();
browser.isIE7();
// And more...

Sample

Here is a standard spring configuration:

package com.myApp;

import org.springframework.web.servlet.config.annotation.EnableWebMvc
import com.github.mjeanroy.springmvc.uadetector.configuration.EnableUADetector;
import com.github.mjeanroy.springmvc.uadetector.configuration.UACacheProvider;

@EnableWebMvc
@EnableUADetector(autowire = true, cache = UACacheProvider.AUTO)
public class MyAppConfiguration() {
}

Here is a spring mvc controller using arguments resolvers:

package com.myApp;

import net.sf.uadetector.ReadableUserAgent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMethod;

@RestController
public class FirstController {

    /**
     * Return browser family.
     * See how an instance of ReadableUserAgent can be used as
     * a method parameter.
     *
     * @param userAgent Current user agent.
     * @return Browser Family.
     */
    @RequestMapping(value = "/ua/name", method = RequestMethod.GET)
    public String index(ReadableUserAgent userAgent) {
        return userAgent.getFamily().toString();
    }
}

Here is a spring mvc controller using autowiring:

package com.myApp;

import net.sf.uadetector.ReadableUserAgent;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMethod;

@RestController
public class SecondController {

    @Autowire
    private ReadableUserAgent userAgent;

    /**
     * Return browser family.
     * See how an instance of ReadableUserAgent is automatically
     * autowired.
     *
     * @return Browser Family.
     */
    @RequestMapping(value = "/ua/name", method = RequestMethod.GET)
    public String index() {
        return userAgent.getFamily().toString();
    }
}

Версии библиотеки

Версия
0.1.1
0.1.0