Skip to content
Snippets Groups Projects
Commit cdc51b47 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

First commit

parents
No related branches found
No related tags found
No related merge requests found
target/
classes/
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.hint.j2eeVersion>1.5</netbeans.hint.j2eeVersion>
<org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>ide</org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>
</properties>
</project-shared-configuration>
pom.xml 0 → 100644
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>no.bioforsk</groupId>
<artifactId>VIPSCore</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>VIPSCore</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.0.2.Final</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
package no.bioforsk.vips.core;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("test")
public class VIPSCoreApplication extends Application
{
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> resources = new java.util.HashSet<>();
addRestResourceClasses(resources);
return resources;
}
/**
* Do not modify addRestResourceClasses() method.
* It is automatically re-generated by NetBeans REST support to populate
* given list with all resources defined in the project.
*/
private void addRestResourceClasses(Set<Class<?>> resources) {
resources.add(no.bioforsk.vips.core.service.TestResource.class);
}
}
\ No newline at end of file
package no.bioforsk.vips.core.entities;
import java.util.Date;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author treinar
*/
//@XmlRootElement(name="weather")
//@XmlAccessorType(XmlAccessType.FIELD)
public class Weather {
public Weather()
{
}
public Weather(Date date, String details){
this.setDate(date);
this.setDetails(details);
}
//@XmlAttribute
private Date date;
//@XmlElement
private String details;
/**
* @return the date
*/
public Date getDate() {
return date;
}
/**
* @param date the date to set
*/
public void setDate(Date date) {
this.date = date;
}
/**
* @return the details
*/
public String getDetails() {
return details;
}
/**
* @param details the details to set
*/
public void setDetails(String details) {
this.details = details;
}
}
package no.bioforsk.vips.core.service;
import java.util.Date;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import no.bioforsk.vips.core.entities.Weather;
/**
*
* @author treinar
*/
@Path("/")
public class TestResource {
@GET
@Path("Hello/{name}")
public Response printMessageHolihili(@PathParam("name") String name){
return Response.ok().entity("Neimen heisann, " + name).build();
};
@GET
@Path("weather/xml")
@Produces("application/xml")
public Weather printWeatherXML()
{
return new Weather(new Date(),"Goddag, goddag. Dette her er Meteorologisk institutt.");
}
/**
* Marshalling fra POJO til JSON gjøres automagis (med Jackson)
* @return
*/
@GET
@Path("weather/json")
@Produces("application/json")
public Response printWeatherJSON()
{
return Response.ok().entity(new Weather(new Date(),"Goddag, goddag. Dette her er Meteorologisk institutt.")).build();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<context-root>/VIPSCore</context-root>
</jboss-web>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
</web-app>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment