jersey-mvc-jasper

Jersey Teplate to integrate Jasper in Jersey Template system, generating PDF files

Лицензия

Лицензия

Категории

Категории

Jersey Межпрограммное взаимодействие REST Frameworks
Группа

Группа

br.uff.sti
Идентификатор

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

jersey-mvc-jasper
Последняя версия

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

0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

jersey-mvc-jasper
Jersey Teplate to integrate Jasper in Jersey Template system, generating PDF files
Ссылка на сайт

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

https://github.com/marcosvpcortes/jersey-mvc-jasper
Система контроля версий

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

https://github.com/marcosvpcortes/jersey-mvc-jasper

Скачать jersey-mvc-jasper

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

<!-- https://jarcasting.com/artifacts/br.uff.sti/jersey-mvc-jasper/ -->
<dependency>
    <groupId>br.uff.sti</groupId>
    <artifactId>jersey-mvc-jasper</artifactId>
    <version>0.2</version>
</dependency>
// https://jarcasting.com/artifacts/br.uff.sti/jersey-mvc-jasper/
implementation 'br.uff.sti:jersey-mvc-jasper:0.2'
// https://jarcasting.com/artifacts/br.uff.sti/jersey-mvc-jasper/
implementation ("br.uff.sti:jersey-mvc-jasper:0.2")
'br.uff.sti:jersey-mvc-jasper:jar:0.2'
<dependency org="br.uff.sti" name="jersey-mvc-jasper" rev="0.2">
  <artifact name="jersey-mvc-jasper" type="jar" />
</dependency>
@Grapes(
@Grab(group='br.uff.sti', module='jersey-mvc-jasper', version='0.2')
)
libraryDependencies += "br.uff.sti" % "jersey-mvc-jasper" % "0.2"
[br.uff.sti/jersey-mvc-jasper "0.2"]

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
com.google.collections : google-collections jar 1.0
org.glassfish.jersey.ext : jersey-mvc jar 2.13
net.sf.jasperreports : jasperreports jar 5.6.1

test (3)

Идентификатор библиотеки Тип Версия
org.testng : testng jar 6.8.8
br.com.six2six : fixture-factory jar 2.2.0
org.mockito : mockito-core jar 1.10.8

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

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

jersey-mvc-jasper

Build Status

Jersey plugin to integrate Jasper Report at Jersey Template system, generating PDF files.

Installing

Install it has two steps:

  • Include the depedency in pom.xml;
  • Register the MvcFeature of the jersey-mvc-jasper;

Include the dependency

    <dependency>
        <groupId>br.uff.sti</groupId>
        <artifactId>jersey-mvc-jasper</artifactId>
        <version>0.1.10</version>
        <exclusions>
            <exclusion>
                <artifactId>jasperreports</artifactId>
                <groupId>net.sf.jasperreports</groupId>
            </exclusion>
        </exclusions>
    </dependency>

Details:

  • You should exclude the Jasper Report dependency od this plugin to avoid conflict with the module insered by yout application or by others dependencies. It is important because Jasper is very sensible to differences between the .jasper compiled version and the jasper module version.

  • Currently, this plugin is not in a maven repository (I am learning do it, sorry...). You should download this plugin and clean/install with maven

    ``mvn clean install``
    

Register the MvcFeature

Register the MvcFeature provide by this module. More details here.

...
register(org.glassfish.jersey.jackson.JacksonFeature.class);
register(MultiPartFeature.class);
register(JasperMvcFeature.class);
...

Usage

Jersey by itself has a lot of ways to define a web-service method (returning a entity, a Response, etc). You using the same syntax to render with jersey-mvc-jasper, but using the annotation @Template with your template name and defining the @Produces type:

@GET
@Path("{id}.pdf")
@Template(name="/jasper/my_template")
@Produces("application/pdf")
public Person getPerson(@PathParam("id") id){
  Person person = this.getPerson(id);//using spring/CDI/etc...
  return person;
}

The jersey-mv-jasper will search in "WEB-INF/jasper/" for a file like my_template.jasper. If it not found, will search by my_template.jrxml" and compile it.

You can return a List to represent multiples entities to be rendered by jasper using $F{...} (field).

@GET
@Path(".pdf")
@Template(name="/jasper/my_template")
@Produces("application/pdf")
public List<Person> getPersons(){
  List<Person> persons = this.getPersons();//using spring/CDI/etc...
  return persons;
}

Return too a instance of JasperModel that can receive the list of entities and a collections of key->value to be used with $P{...} (parameters) in jasper.

@GET
@Path(".pdf")
@Template(name="/jasper/my_template")
@Produces("application/pdf")
public JasperModel getPersons(){
  List<Person> persons = this.getPersons();//using spring/CDI/etc...
  return JasperModel.create(Person.class).putParam("LOGO", "/logo.png").addModels(persons);
}

See more

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

Версия
0.2