group and cleanup (#3027)

* move security content from spring-security-rest-full

* swagger update

* move query language to new module

* rename spring-security-rest-full to spring-rest-full

* group persistence modules

* group testing modules

* try fix conflict

* cleanup

* group and cleanup
This commit is contained in:
Doha2012
2017-11-13 17:45:26 +02:00
committed by Grzegorz Piwowarek
parent 2a85b9c96e
commit 2e5531edd0
198 changed files with 20 additions and 15 deletions
@@ -0,0 +1,10 @@
package com.baeldung.arquillian;
import javax.ejb.Stateless;
@Stateless
public class CapsConvertor {
public ConvertToLowerCase getLowerCase(){
return new ConvertToLowerCase();
}
}
@@ -0,0 +1,14 @@
package com.baeldung.arquillian;
import javax.ejb.Stateless;
import javax.inject.Inject;
@Stateless
public class CapsService {
@Inject
private CapsConvertor capsConvertor;
public String getConvertedCaps(final String word){
return capsConvertor.getLowerCase().convert(word);
}
}
@@ -0,0 +1,37 @@
package com.baeldung.arquillian;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
@Entity
public class Car {
@Id
@GeneratedValue
private Long id;
@NotNull
private String name;
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
@Override
public String toString() {
return "Car [id=" + id + ", name=" + name + "]";
}
}
@@ -0,0 +1,35 @@
package com.baeldung.arquillian;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@Stateless
public class CarEJB {
@PersistenceContext(unitName = "defaultPersistenceUnit")
private EntityManager em;
public Car saveCar(final Car car) {
em.persist(car);
return car;
}
@SuppressWarnings("unchecked")
public List<Car> findAllCars() {
final Query query = em.createQuery("SELECT b FROM Car b ORDER BY b.name ASC");
List<Car> entries = query.getResultList();
if (entries == null) {
entries = new ArrayList<Car>();
}
return entries;
}
public void deleteCar(Car car) {
car = em.merge(car);
em.remove(car);
}
}
@@ -0,0 +1,13 @@
package com.baeldung.arquillian;
import java.io.PrintStream;
public class Component {
public void sendMessage(PrintStream to, String msg) {
to.println(message(msg));
}
public String message(String msg) {
return "Message, " + msg;
}
}
@@ -0,0 +1,7 @@
package com.baeldung.arquillian;
public class ConvertToLowerCase {
public String convert(String word){
return word.toLowerCase();
}
}
@@ -0,0 +1,56 @@
package com.baeldung.convListVal;
import java.util.Date;
import javax.faces.bean.ManagedBean;
@ManagedBean
public class ConvListVal {
private Integer age;
private Double average;
private Date myDate;
private String name;
private String surname;
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public Double getAverage() {
return average;
}
public void setAverage(Double average) {
this.average = average;
}
public Date getMyDate() {
return myDate;
}
public void setMyDate(Date myDate) {
this.myDate = myDate;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
}
@@ -0,0 +1,21 @@
package com.baeldung.convListVal;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ValueChangeEvent;
import javax.faces.event.ValueChangeListener;
public class MyListener implements ValueChangeListener {
private static final Logger LOG = Logger.getLogger(MyListener.class.getName());
@Override
public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
if (event.getNewValue() != null) {
LOG.log(Level.INFO, "\tNew Value:{0}", event.getNewValue());
}
}
}
@@ -0,0 +1,76 @@
About the application
---------------------
This application demonstrates the usage of JavaEE Web Annotations.
Contents of the application
---------------------------
1. AccountServlet.java - Demonstrates the @WebServlet and @ServletSecurity annotation.
NOTES: @WebServlet annotation designates the AccountServlet class as a Servlet component.
The usage of its parameters 'urlPatterns' & 'initParams' can be observed.
An initialization parameter 'type' is being set to denote the type of the bank account.
@ServletSecurity annotation imposes security constraints on the AccountServlet based on
the tomcat-users.xml.
 
This code assumes that your tomcat-users.xml looks as follows:
<role rolename="Admin"/>
<role rolename="Member"/>
<role rolename="Guest"/>
<user username="Annie" password="admin" roles="Admin, Member, Guest" />
<user username="Diane" password="coder" roles="Member, Guest" />
<user username="Ted" password="newbie" roles="Guest" />
 
N.B : To see @ServletSecurity annotation in action, please uncomment the annotation code
for @ServletSecurity.
2. BankAppServletContextListener.java - Demonstrates the @WebListener annotation for denoting a class as a ServletContextListener.
NOTES: Sets a Servlet context attribute ATTR_DEFAULT_LANGUAGE to 'english' on web application start up,
which can then be used throughout the application.
3. LogInFilter.java - Demonstrates the @WebFilter annotation.
NOTES: @WebFilter annotation designates the LogInFilter class as a Filter component.
It filters all requests to the bank account servlet and redirects them to
the login page.
N.B : To see @WebFilter annotation in action, please uncomment the annotation code for @WebFilter.
4. UploadCustomerDocumentsServlet.java - Demonstrates the @MultipartConfig annotation.
NOTES: @MultipartConfig anotation designates the UploadCustomerDocumentsServlet Servlet component,
to handle multipart/form-data requests.
To see it in action, deploy the web application an access the url: http://<your host>:<your port>/JavaEEAnnotationsSample/upload.jsp
Once you upload a file from here, it will get uploaded to D:/custDocs (assuming such a folder exists).
5. index.jsp - This is the welcome page.
NOTES: You can enter a deposit amount here and click on the 'Deposit' button to see the AccountServlet in action.
6. login.jsp - All requests to the AccountServlet are redirected to this page, if the LogInFilter is imposed.
7. upload.jsp - Demonstrates the usage of handling multipart/form-data requests by the UploadCustomerDocumentsServlet.
Building and Running the application
------------------------------------
To build the application:
1. Open the project in eclipse
2. Right click on it in eclispe and choose Run As > Maven build
3. Give 'clean install' under Goals
4. This should build the WAR file of the application
To run the application:
1. Right click on the project
2. Run as > Run on Server
3. This will start you Tomcat server and deploy the application (Provided that you have configured Tomcat in your eclipse)
4. You should now be able to access the url : http://<your host>:<your port>/JavaEEAnnotationsSample
@@ -0,0 +1,57 @@
<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>com.baeldung.javaeeannotations</groupId>
<artifactId>JavaEEAnnotationsSample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>JavaEEAnnotationsSample</name>
<description>JavaEEAnnotationsSample</description>
<dependencies>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<warName>SpringFieldConstructorInjection</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<finalName>JavaEEAnnotationsSample</finalName>
</build>
</project>
@@ -0,0 +1,50 @@
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(
name = "BankAccountServlet",
description = "Represents a Bank Account and it's transactions",
urlPatterns = {"/account", "/bankAccount" },
initParams = { @WebInitParam(name = "type", value = "savings") }
)
/*@ServletSecurity(
value = @HttpConstraint(rolesAllowed = {"Member"}),
httpMethodConstraints = {@HttpMethodConstraint(value = "POST", rolesAllowed = {"Admin"})}
)*/
public class AccountServlet extends javax.servlet.http.HttpServlet {
String accountType = null;
public void init(ServletConfig config) throws ServletException {
accountType = config.getInitParameter("type");
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
PrintWriter writer = response.getWriter();
writer.println("<html>Hello, I am an AccountServlet!</html>");
writer.flush();
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
double accountBalance = 1000d;
String paramDepositAmt = request.getParameter("dep");
double depositAmt = Double.parseDouble(paramDepositAmt);
accountBalance = accountBalance + depositAmt;
PrintWriter writer = response.getWriter();
writer.println("<html> Balance of " + accountType + " account is: " + accountBalance + "</html>");
writer.flush();
}
}
@@ -0,0 +1,17 @@
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
@WebListener
public class BankAppServletContextListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent sce) {
sce.getServletContext().setAttribute("ATTR_DEFAULT_LANGUAGE", "english");
}
public void contextDestroyed(ServletContextEvent sce) {
System.out.println("CONTEXT DESTROYED");
}
}
@@ -0,0 +1,36 @@
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/*@WebFilter(
urlPatterns = "/bankAccount/*",
filterName = "LogInFilter",
description = "Filter all account transaction URLs"
)*/
public class LogInFilter implements javax.servlet.Filter {
public void init(FilterConfig filterConfig) throws ServletException {
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse res = (HttpServletResponse) response;
res.sendRedirect(req.getContextPath() + "/login.jsp");
chain.doFilter(request, response);
}
public void destroy() {
}
}
@@ -0,0 +1,34 @@
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
@WebServlet(urlPatterns = { "/uploadCustDocs" })
@MultipartConfig(
fileSizeThreshold = 1024 * 1024 * 20,
maxFileSize = 1024 * 1024 * 20,
maxRequestSize = 1024 * 1024 * 25,
location = "D:/custDocs"
)
public class UploadCustomerDocumentsServlet extends HttpServlet {
protected void doPost(
HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
for (Part part : request.getParts()) {
part.write("myFile");
}
PrintWriter writer = response.getWriter();
writer.println("<html>File uploaded successfully!</html>");
writer.flush();
}
}
@@ -0,0 +1,10 @@
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>default</realm-name>
</login-config>
</web-app>
@@ -0,0 +1,16 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>My Account</title>
</head>
<body>
<form action="bankAccount" method="post">
Amount: <input type="text" size="5" name="dep"/>
&nbsp;&nbsp;
<input type="submit" value="Deposit" />
</form>
</body>
</html>
@@ -0,0 +1,12 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login</title>
</head>
<body>
Login Here...
</body>
</html>
@@ -0,0 +1,16 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="uploadCustDocs" method="post" enctype="multipart/form-data">
<input type="file" name="file" size="50" />
<br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>
@@ -0,0 +1,79 @@
package com.baeldung.jaxws.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for addEmployee complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="addEmployee">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
* &lt;element name="arg1" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "addEmployee", propOrder = {
"arg0",
"arg1"
})
public class AddEmployee {
protected int arg0;
protected String arg1;
/**
* Gets the value of the arg0 property.
*
*/
public int getArg0() {
return arg0;
}
/**
* Sets the value of the arg0 property.
*
*/
public void setArg0(int value) {
this.arg0 = value;
}
/**
* Gets the value of the arg1 property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getArg1() {
return arg1;
}
/**
* Sets the value of the arg1 property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setArg1(String value) {
this.arg1 = value;
}
}
@@ -0,0 +1,62 @@
package com.baeldung.jaxws.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for addEmployeeResponse complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="addEmployeeResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "addEmployeeResponse", propOrder = {
"_return"
})
public class AddEmployeeResponse {
@XmlElement(name = "return")
protected Employee _return;
/**
* Gets the value of the return property.
*
* @return
* possible object is
* {@link Employee }
*
*/
public Employee getReturn() {
return _return;
}
/**
* Sets the value of the return property.
*
* @param value
* allowed object is
* {@link Employee }
*
*/
public void setReturn(Employee value) {
this._return = value;
}
}
@@ -0,0 +1,32 @@
package com.baeldung.jaxws.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for countEmployees complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="countEmployees">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "countEmployees")
public class CountEmployees {
}
@@ -0,0 +1,54 @@
package com.baeldung.jaxws.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for countEmployeesResponse complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="countEmployeesResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="return" type="{http://www.w3.org/2001/XMLSchema}int"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "countEmployeesResponse", propOrder = {
"_return"
})
public class CountEmployeesResponse {
@XmlElement(name = "return")
protected int _return;
/**
* Gets the value of the return property.
*
*/
public int getReturn() {
return _return;
}
/**
* Sets the value of the return property.
*
*/
public void setReturn(int value) {
this._return = value;
}
}
@@ -0,0 +1,52 @@
package com.baeldung.jaxws.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for deleteEmployee complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="deleteEmployee">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "deleteEmployee", propOrder = {
"arg0"
})
public class DeleteEmployee {
protected int arg0;
/**
* Gets the value of the arg0 property.
*
*/
public int getArg0() {
return arg0;
}
/**
* Sets the value of the arg0 property.
*
*/
public void setArg0(int value) {
this.arg0 = value;
}
}
@@ -0,0 +1,54 @@
package com.baeldung.jaxws.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for deleteEmployeeResponse complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="deleteEmployeeResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="return" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "deleteEmployeeResponse", propOrder = {
"_return"
})
public class DeleteEmployeeResponse {
@XmlElement(name = "return")
protected boolean _return;
/**
* Gets the value of the return property.
*
*/
public boolean isReturn() {
return _return;
}
/**
* Sets the value of the return property.
*
*/
public void setReturn(boolean value) {
this._return = value;
}
}
@@ -0,0 +1,79 @@
package com.baeldung.jaxws.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for employee complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="employee">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="firstName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "employee", propOrder = {
"firstName",
"id"
})
public class Employee {
protected String firstName;
protected int id;
/**
* Gets the value of the firstName property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getFirstName() {
return firstName;
}
/**
* Sets the value of the firstName property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setFirstName(String value) {
this.firstName = value;
}
/**
* Gets the value of the id property.
*
*/
public int getId() {
return id;
}
/**
* Sets the value of the id property.
*
*/
public void setId(int value) {
this.id = value;
}
}
@@ -0,0 +1,60 @@
package com.baeldung.jaxws.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for EmployeeAlreadyExists complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="EmployeeAlreadyExists">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "EmployeeAlreadyExists", propOrder = {
"message"
})
public class EmployeeAlreadyExists {
protected String message;
/**
* Gets the value of the message property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMessage() {
return message;
}
/**
* Sets the value of the message property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMessage(String value) {
this.message = value;
}
}
@@ -0,0 +1,54 @@
package com.baeldung.jaxws.client;
import javax.xml.ws.WebFault;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@WebFault(name = "EmployeeAlreadyExists", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/")
public class EmployeeAlreadyExists_Exception
extends Exception
{
/**
* Java type that goes as soapenv:Fault detail element.
*
*/
private EmployeeAlreadyExists faultInfo;
/**
*
* @param faultInfo
* @param message
*/
public EmployeeAlreadyExists_Exception(String message, EmployeeAlreadyExists faultInfo) {
super(message);
this.faultInfo = faultInfo;
}
/**
*
* @param faultInfo
* @param cause
* @param message
*/
public EmployeeAlreadyExists_Exception(String message, EmployeeAlreadyExists faultInfo, Throwable cause) {
super(message, cause);
this.faultInfo = faultInfo;
}
/**
*
* @return
* returns fault bean: com.baeldung.jaxws.client.EmployeeAlreadyExists
*/
public EmployeeAlreadyExists getFaultInfo() {
return faultInfo;
}
}
@@ -0,0 +1,60 @@
package com.baeldung.jaxws.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for EmployeeNotFound complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="EmployeeNotFound">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "EmployeeNotFound", propOrder = {
"message"
})
public class EmployeeNotFound {
protected String message;
/**
* Gets the value of the message property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMessage() {
return message;
}
/**
* Sets the value of the message property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMessage(String value) {
this.message = value;
}
}
@@ -0,0 +1,54 @@
package com.baeldung.jaxws.client;
import javax.xml.ws.WebFault;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@WebFault(name = "EmployeeNotFound", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/")
public class EmployeeNotFound_Exception
extends Exception
{
/**
* Java type that goes as soapenv:Fault detail element.
*
*/
private EmployeeNotFound faultInfo;
/**
*
* @param faultInfo
* @param message
*/
public EmployeeNotFound_Exception(String message, EmployeeNotFound faultInfo) {
super(message);
this.faultInfo = faultInfo;
}
/**
*
* @param faultInfo
* @param cause
* @param message
*/
public EmployeeNotFound_Exception(String message, EmployeeNotFound faultInfo, Throwable cause) {
super(message, cause);
this.faultInfo = faultInfo;
}
/**
*
* @return
* returns fault bean: com.baeldung.jaxws.client.EmployeeNotFound
*/
public EmployeeNotFound getFaultInfo() {
return faultInfo;
}
}
@@ -0,0 +1,139 @@
package com.baeldung.jaxws.client;
import java.util.List;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.Action;
import javax.xml.ws.FaultAction;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@WebService(name = "EmployeeService", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/")
@XmlSeeAlso({
ObjectFactory.class
})
public interface EmployeeService {
/**
*
* @param arg0
* @return
* returns com.baeldung.jaxws.client.Employee
* @throws EmployeeNotFound_Exception
*/
@WebMethod
@WebResult(targetNamespace = "")
@RequestWrapper(localName = "getEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetEmployee")
@ResponseWrapper(localName = "getEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetEmployeeResponse")
@Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getEmployeeResponse", fault = {
@FaultAction(className = EmployeeNotFound_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getEmployee/Fault/EmployeeNotFound")
})
public Employee getEmployee(
@WebParam(name = "arg0", targetNamespace = "")
int arg0)
throws EmployeeNotFound_Exception
;
/**
*
* @param arg1
* @param arg0
* @return
* returns com.baeldung.jaxws.client.Employee
* @throws EmployeeNotFound_Exception
*/
@WebMethod
@WebResult(targetNamespace = "")
@RequestWrapper(localName = "updateEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.UpdateEmployee")
@ResponseWrapper(localName = "updateEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.UpdateEmployeeResponse")
@Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/updateEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/updateEmployeeResponse", fault = {
@FaultAction(className = EmployeeNotFound_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/updateEmployee/Fault/EmployeeNotFound")
})
public Employee updateEmployee(
@WebParam(name = "arg0", targetNamespace = "")
int arg0,
@WebParam(name = "arg1", targetNamespace = "")
String arg1)
throws EmployeeNotFound_Exception
;
/**
*
* @return
* returns java.util.List<com.baeldung.jaxws.client.Employee>
*/
@WebMethod
@WebResult(targetNamespace = "")
@RequestWrapper(localName = "getAllEmployees", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetAllEmployees")
@ResponseWrapper(localName = "getAllEmployeesResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetAllEmployeesResponse")
@Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getAllEmployeesRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getAllEmployeesResponse")
public List<Employee> getAllEmployees();
/**
*
* @param arg0
* @return
* returns boolean
* @throws EmployeeNotFound_Exception
*/
@WebMethod
@WebResult(targetNamespace = "")
@RequestWrapper(localName = "deleteEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.DeleteEmployee")
@ResponseWrapper(localName = "deleteEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.DeleteEmployeeResponse")
@Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/deleteEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/deleteEmployeeResponse", fault = {
@FaultAction(className = EmployeeNotFound_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/deleteEmployee/Fault/EmployeeNotFound")
})
public boolean deleteEmployee(
@WebParam(name = "arg0", targetNamespace = "")
int arg0)
throws EmployeeNotFound_Exception
;
/**
*
* @param arg1
* @param arg0
* @return
* returns com.baeldung.jaxws.client.Employee
* @throws EmployeeAlreadyExists_Exception
*/
@WebMethod
@WebResult(targetNamespace = "")
@RequestWrapper(localName = "addEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.AddEmployee")
@ResponseWrapper(localName = "addEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.AddEmployeeResponse")
@Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/addEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/addEmployeeResponse", fault = {
@FaultAction(className = EmployeeAlreadyExists_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/addEmployee/Fault/EmployeeAlreadyExists")
})
public Employee addEmployee(
@WebParam(name = "arg0", targetNamespace = "")
int arg0,
@WebParam(name = "arg1", targetNamespace = "")
String arg1)
throws EmployeeAlreadyExists_Exception
;
/**
*
* @return
* returns int
*/
@WebMethod
@WebResult(targetNamespace = "")
@RequestWrapper(localName = "countEmployees", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.CountEmployees")
@ResponseWrapper(localName = "countEmployeesResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.CountEmployeesResponse")
@Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/countEmployeesRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/countEmployeesResponse")
public int countEmployees();
}
@@ -0,0 +1,18 @@
package com.baeldung.jaxws.client;
import java.net.URL;
import java.util.List;
public class EmployeeServiceClient {
public static void main(String[] args) throws Exception {
URL url = new URL("http://localhost:8080/employeeservice?wsdl");
EmployeeService_Service employeeService_Service = new EmployeeService_Service(url);
EmployeeService employeeServiceProxy = employeeService_Service.getEmployeeServiceImplPort();
List<Employee> allEmployees = employeeServiceProxy.getAllEmployees();
}
}
@@ -0,0 +1,94 @@
package com.baeldung.jaxws.client;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@WebServiceClient(name = "EmployeeService", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", wsdlLocation = "http://localhost:8080/employeeservice?wsdl")
public class EmployeeService_Service
extends Service
{
private final static URL EMPLOYEESERVICE_WSDL_LOCATION;
private final static WebServiceException EMPLOYEESERVICE_EXCEPTION;
private final static QName EMPLOYEESERVICE_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeService");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("http://localhost:8080/employeeservice?wsdl");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
EMPLOYEESERVICE_WSDL_LOCATION = url;
EMPLOYEESERVICE_EXCEPTION = e;
}
public EmployeeService_Service() {
super(__getWsdlLocation(), EMPLOYEESERVICE_QNAME);
}
public EmployeeService_Service(WebServiceFeature... features) {
super(__getWsdlLocation(), EMPLOYEESERVICE_QNAME, features);
}
public EmployeeService_Service(URL wsdlLocation) {
super(wsdlLocation, EMPLOYEESERVICE_QNAME);
}
public EmployeeService_Service(URL wsdlLocation, WebServiceFeature... features) {
super(wsdlLocation, EMPLOYEESERVICE_QNAME, features);
}
public EmployeeService_Service(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public EmployeeService_Service(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns EmployeeService
*/
@WebEndpoint(name = "EmployeeServiceImplPort")
public EmployeeService getEmployeeServiceImplPort() {
return super.getPort(new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeServiceImplPort"), EmployeeService.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns EmployeeService
*/
@WebEndpoint(name = "EmployeeServiceImplPort")
public EmployeeService getEmployeeServiceImplPort(WebServiceFeature... features) {
return super.getPort(new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeServiceImplPort"), EmployeeService.class, features);
}
private static URL __getWsdlLocation() {
if (EMPLOYEESERVICE_EXCEPTION!= null) {
throw EMPLOYEESERVICE_EXCEPTION;
}
return EMPLOYEESERVICE_WSDL_LOCATION;
}
}
@@ -0,0 +1,32 @@
package com.baeldung.jaxws.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for getAllEmployees complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="getAllEmployees">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "getAllEmployees")
public class GetAllEmployees {
}
@@ -0,0 +1,69 @@
package com.baeldung.jaxws.client;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for getAllEmployeesResponse complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="getAllEmployeesResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "getAllEmployeesResponse", propOrder = {
"_return"
})
public class GetAllEmployeesResponse {
@XmlElement(name = "return")
protected List<Employee> _return;
/**
* Gets the value of the return property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the return property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getReturn().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Employee }
*
*
*/
public List<Employee> getReturn() {
if (_return == null) {
_return = new ArrayList<Employee>();
}
return this._return;
}
}
@@ -0,0 +1,52 @@
package com.baeldung.jaxws.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for getEmployee complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="getEmployee">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "getEmployee", propOrder = {
"arg0"
})
public class GetEmployee {
protected int arg0;
/**
* Gets the value of the arg0 property.
*
*/
public int getArg0() {
return arg0;
}
/**
* Sets the value of the arg0 property.
*
*/
public void setArg0(int value) {
this.arg0 = value;
}
}
@@ -0,0 +1,62 @@
package com.baeldung.jaxws.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for getEmployeeResponse complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="getEmployeeResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "getEmployeeResponse", propOrder = {
"_return"
})
public class GetEmployeeResponse {
@XmlElement(name = "return")
protected Employee _return;
/**
* Gets the value of the return property.
*
* @return
* possible object is
* {@link Employee }
*
*/
public Employee getReturn() {
return _return;
}
/**
* Sets the value of the return property.
*
* @param value
* allowed object is
* {@link Employee }
*
*/
public void setReturn(Employee value) {
this._return = value;
}
}
@@ -0,0 +1,295 @@
package com.baeldung.jaxws.client;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.baeldung.jaxws.client package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
private final static QName _AddEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "addEmployeeResponse");
private final static QName _EmployeeAlreadyExists_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeAlreadyExists");
private final static QName _GetEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getEmployeeResponse");
private final static QName _EmployeeNotFound_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeNotFound");
private final static QName _CountEmployees_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "countEmployees");
private final static QName _UpdateEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "updateEmployee");
private final static QName _DeleteEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "deleteEmployeeResponse");
private final static QName _GetAllEmployeesResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getAllEmployeesResponse");
private final static QName _DeleteEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "deleteEmployee");
private final static QName _UpdateEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "updateEmployeeResponse");
private final static QName _AddEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "addEmployee");
private final static QName _GetAllEmployees_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getAllEmployees");
private final static QName _CountEmployeesResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "countEmployeesResponse");
private final static QName _GetEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getEmployee");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.jaxws.client
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link EmployeeNotFound }
*
*/
public EmployeeNotFound createEmployeeNotFound() {
return new EmployeeNotFound();
}
/**
* Create an instance of {@link CountEmployees }
*
*/
public CountEmployees createCountEmployees() {
return new CountEmployees();
}
/**
* Create an instance of {@link AddEmployeeResponse }
*
*/
public AddEmployeeResponse createAddEmployeeResponse() {
return new AddEmployeeResponse();
}
/**
* Create an instance of {@link EmployeeAlreadyExists }
*
*/
public EmployeeAlreadyExists createEmployeeAlreadyExists() {
return new EmployeeAlreadyExists();
}
/**
* Create an instance of {@link GetEmployeeResponse }
*
*/
public GetEmployeeResponse createGetEmployeeResponse() {
return new GetEmployeeResponse();
}
/**
* Create an instance of {@link DeleteEmployeeResponse }
*
*/
public DeleteEmployeeResponse createDeleteEmployeeResponse() {
return new DeleteEmployeeResponse();
}
/**
* Create an instance of {@link GetAllEmployeesResponse }
*
*/
public GetAllEmployeesResponse createGetAllEmployeesResponse() {
return new GetAllEmployeesResponse();
}
/**
* Create an instance of {@link UpdateEmployee }
*
*/
public UpdateEmployee createUpdateEmployee() {
return new UpdateEmployee();
}
/**
* Create an instance of {@link CountEmployeesResponse }
*
*/
public CountEmployeesResponse createCountEmployeesResponse() {
return new CountEmployeesResponse();
}
/**
* Create an instance of {@link GetEmployee }
*
*/
public GetEmployee createGetEmployee() {
return new GetEmployee();
}
/**
* Create an instance of {@link DeleteEmployee }
*
*/
public DeleteEmployee createDeleteEmployee() {
return new DeleteEmployee();
}
/**
* Create an instance of {@link UpdateEmployeeResponse }
*
*/
public UpdateEmployeeResponse createUpdateEmployeeResponse() {
return new UpdateEmployeeResponse();
}
/**
* Create an instance of {@link AddEmployee }
*
*/
public AddEmployee createAddEmployee() {
return new AddEmployee();
}
/**
* Create an instance of {@link GetAllEmployees }
*
*/
public GetAllEmployees createGetAllEmployees() {
return new GetAllEmployees();
}
/**
* Create an instance of {@link Employee }
*
*/
public Employee createEmployee() {
return new Employee();
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link AddEmployeeResponse }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "addEmployeeResponse")
public JAXBElement<AddEmployeeResponse> createAddEmployeeResponse(AddEmployeeResponse value) {
return new JAXBElement<AddEmployeeResponse>(_AddEmployeeResponse_QNAME, AddEmployeeResponse.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link EmployeeAlreadyExists }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "EmployeeAlreadyExists")
public JAXBElement<EmployeeAlreadyExists> createEmployeeAlreadyExists(EmployeeAlreadyExists value) {
return new JAXBElement<EmployeeAlreadyExists>(_EmployeeAlreadyExists_QNAME, EmployeeAlreadyExists.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetEmployeeResponse }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getEmployeeResponse")
public JAXBElement<GetEmployeeResponse> createGetEmployeeResponse(GetEmployeeResponse value) {
return new JAXBElement<GetEmployeeResponse>(_GetEmployeeResponse_QNAME, GetEmployeeResponse.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link EmployeeNotFound }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "EmployeeNotFound")
public JAXBElement<EmployeeNotFound> createEmployeeNotFound(EmployeeNotFound value) {
return new JAXBElement<EmployeeNotFound>(_EmployeeNotFound_QNAME, EmployeeNotFound.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link CountEmployees }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "countEmployees")
public JAXBElement<CountEmployees> createCountEmployees(CountEmployees value) {
return new JAXBElement<CountEmployees>(_CountEmployees_QNAME, CountEmployees.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link UpdateEmployee }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "updateEmployee")
public JAXBElement<UpdateEmployee> createUpdateEmployee(UpdateEmployee value) {
return new JAXBElement<UpdateEmployee>(_UpdateEmployee_QNAME, UpdateEmployee.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link DeleteEmployeeResponse }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "deleteEmployeeResponse")
public JAXBElement<DeleteEmployeeResponse> createDeleteEmployeeResponse(DeleteEmployeeResponse value) {
return new JAXBElement<DeleteEmployeeResponse>(_DeleteEmployeeResponse_QNAME, DeleteEmployeeResponse.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetAllEmployeesResponse }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getAllEmployeesResponse")
public JAXBElement<GetAllEmployeesResponse> createGetAllEmployeesResponse(GetAllEmployeesResponse value) {
return new JAXBElement<GetAllEmployeesResponse>(_GetAllEmployeesResponse_QNAME, GetAllEmployeesResponse.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link DeleteEmployee }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "deleteEmployee")
public JAXBElement<DeleteEmployee> createDeleteEmployee(DeleteEmployee value) {
return new JAXBElement<DeleteEmployee>(_DeleteEmployee_QNAME, DeleteEmployee.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link UpdateEmployeeResponse }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "updateEmployeeResponse")
public JAXBElement<UpdateEmployeeResponse> createUpdateEmployeeResponse(UpdateEmployeeResponse value) {
return new JAXBElement<UpdateEmployeeResponse>(_UpdateEmployeeResponse_QNAME, UpdateEmployeeResponse.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link AddEmployee }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "addEmployee")
public JAXBElement<AddEmployee> createAddEmployee(AddEmployee value) {
return new JAXBElement<AddEmployee>(_AddEmployee_QNAME, AddEmployee.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetAllEmployees }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getAllEmployees")
public JAXBElement<GetAllEmployees> createGetAllEmployees(GetAllEmployees value) {
return new JAXBElement<GetAllEmployees>(_GetAllEmployees_QNAME, GetAllEmployees.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link CountEmployeesResponse }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "countEmployeesResponse")
public JAXBElement<CountEmployeesResponse> createCountEmployeesResponse(CountEmployeesResponse value) {
return new JAXBElement<CountEmployeesResponse>(_CountEmployeesResponse_QNAME, CountEmployeesResponse.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetEmployee }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getEmployee")
public JAXBElement<GetEmployee> createGetEmployee(GetEmployee value) {
return new JAXBElement<GetEmployee>(_GetEmployee_QNAME, GetEmployee.class, null, value);
}
}
@@ -0,0 +1,79 @@
package com.baeldung.jaxws.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for updateEmployee complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="updateEmployee">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
* &lt;element name="arg1" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "updateEmployee", propOrder = {
"arg0",
"arg1"
})
public class UpdateEmployee {
protected int arg0;
protected String arg1;
/**
* Gets the value of the arg0 property.
*
*/
public int getArg0() {
return arg0;
}
/**
* Sets the value of the arg0 property.
*
*/
public void setArg0(int value) {
this.arg0 = value;
}
/**
* Gets the value of the arg1 property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getArg1() {
return arg1;
}
/**
* Sets the value of the arg1 property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setArg1(String value) {
this.arg1 = value;
}
}
@@ -0,0 +1,62 @@
package com.baeldung.jaxws.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for updateEmployeeResponse complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="updateEmployeeResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "updateEmployeeResponse", propOrder = {
"_return"
})
public class UpdateEmployeeResponse {
@XmlElement(name = "return")
protected Employee _return;
/**
* Gets the value of the return property.
*
* @return
* possible object is
* {@link Employee }
*
*/
public Employee getReturn() {
return _return;
}
/**
* Sets the value of the return property.
*
* @param value
* allowed object is
* {@link Employee }
*
*/
public void setReturn(Employee value) {
this._return = value;
}
}
@@ -0,0 +1,2 @@
@javax.xml.bind.annotation.XmlSchema(namespace = "http://bottomup.server.jaxws.baeldung.com/")
package com.baeldung.jaxws.client;
@@ -0,0 +1,32 @@
package com.baeldung.jaxws.server.bottomup;
import java.util.List;
import javax.jws.WebMethod;
import javax.jws.WebService;
import com.baeldung.jaxws.server.bottomup.exception.EmployeeAlreadyExists;
import com.baeldung.jaxws.server.bottomup.exception.EmployeeNotFound;
import com.baeldung.jaxws.server.bottomup.model.Employee;
@WebService
public interface EmployeeService {
@WebMethod
Employee getEmployee(int id) throws EmployeeNotFound;
@WebMethod
Employee updateEmployee(int id, String name) throws EmployeeNotFound;
@WebMethod
boolean deleteEmployee(int id) throws EmployeeNotFound;
@WebMethod
Employee addEmployee(int id, String name) throws EmployeeAlreadyExists;
@WebMethod
int countEmployees();
@WebMethod
List<Employee> getAllEmployees();
}
@@ -0,0 +1,49 @@
package com.baeldung.jaxws.server.bottomup;
import java.util.List;
import javax.inject.Inject;
import javax.jws.WebMethod;
import javax.jws.WebService;
import com.baeldung.jaxws.server.bottomup.exception.EmployeeAlreadyExists;
import com.baeldung.jaxws.server.bottomup.exception.EmployeeNotFound;
import com.baeldung.jaxws.server.bottomup.model.Employee;
import com.baeldung.jaxws.server.repository.EmployeeRepository;
@WebService(serviceName = "EmployeeService", endpointInterface = "com.baeldung.jaxws.server.bottomup.EmployeeService")
public class EmployeeServiceImpl implements EmployeeService {
@Inject
private EmployeeRepository employeeRepositoryImpl;
@WebMethod
public Employee getEmployee(int id) throws EmployeeNotFound {
return employeeRepositoryImpl.getEmployee(id);
}
@WebMethod
public Employee updateEmployee(int id, String name) throws EmployeeNotFound {
return employeeRepositoryImpl.updateEmployee(id, name);
}
@WebMethod
public boolean deleteEmployee(int id) throws EmployeeNotFound {
return employeeRepositoryImpl.deleteEmployee(id);
}
@WebMethod
public Employee addEmployee(int id, String name) throws EmployeeAlreadyExists {
return employeeRepositoryImpl.addEmployee(id, name);
}
@WebMethod
public int countEmployees() {
return employeeRepositoryImpl.count();
}
@WebMethod
public List<Employee> getAllEmployees() {
return employeeRepositoryImpl.getAllEmployees();
}
}
@@ -0,0 +1,15 @@
package com.baeldung.jaxws.server.bottomup.exception;
import javax.xml.ws.WebFault;
@WebFault
public class EmployeeAlreadyExists extends Exception {
public EmployeeAlreadyExists() {
super("This employee already exists");
}
public EmployeeAlreadyExists(String str) {
super(str);
}
}
@@ -0,0 +1,16 @@
package com.baeldung.jaxws.server.bottomup.exception;
import javax.xml.ws.WebFault;
@WebFault
public class EmployeeNotFound extends Exception {
public EmployeeNotFound() {
super("The specified employee does not exist");
}
public EmployeeNotFound(String str) {
super(str);
}
}
@@ -0,0 +1,31 @@
package com.baeldung.jaxws.server.bottomup.model;
public class Employee {
private int id;
private String firstName;
public Employee() {
}
public Employee(int id, String firstName) {
this.id = id;
this.firstName = firstName;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
}
@@ -0,0 +1,14 @@
package com.baeldung.jaxws.server.config;
import javax.xml.ws.Endpoint;
import com.baeldung.jaxws.server.bottomup.EmployeeServiceImpl;
import com.baeldung.jaxws.server.topdown.EmployeeServiceTopDownImpl;
public class EmployeeServicePublisher {
public static void main(String[] args) {
Endpoint.publish("http://localhost:8080/employeeservicetopdown", new EmployeeServiceTopDownImpl());
Endpoint.publish("http://localhost:8080/employeeservice", new EmployeeServiceImpl());
}
}
@@ -0,0 +1,22 @@
package com.baeldung.jaxws.server.repository;
import java.util.List;
import com.baeldung.jaxws.server.bottomup.exception.EmployeeAlreadyExists;
import com.baeldung.jaxws.server.bottomup.exception.EmployeeNotFound;
import com.baeldung.jaxws.server.bottomup.model.Employee;
public interface EmployeeRepository {
List<Employee> getAllEmployees();
Employee getEmployee(int id) throws EmployeeNotFound;
Employee updateEmployee(int id, String name) throws EmployeeNotFound;
boolean deleteEmployee(int id) throws EmployeeNotFound;
Employee addEmployee(int id, String name) throws EmployeeAlreadyExists;
int count();
}
@@ -0,0 +1,68 @@
package com.baeldung.jaxws.server.repository;
import java.util.ArrayList;
import java.util.List;
import com.baeldung.jaxws.server.bottomup.exception.EmployeeAlreadyExists;
import com.baeldung.jaxws.server.bottomup.exception.EmployeeNotFound;
import com.baeldung.jaxws.server.bottomup.model.Employee;
public class EmployeeRepositoryImpl implements EmployeeRepository {
private List<Employee> employeeList;
public EmployeeRepositoryImpl() {
employeeList = new ArrayList<>();
employeeList.add(new Employee(1, "Jane"));
employeeList.add(new Employee(2, "Jack"));
employeeList.add(new Employee(3, "George"));
}
public List<Employee> getAllEmployees() {
return employeeList;
}
public Employee getEmployee(int id) throws EmployeeNotFound {
for (Employee emp : employeeList) {
if (emp.getId() == id) {
return emp;
}
}
throw new EmployeeNotFound();
}
public Employee updateEmployee(int id, String name) throws EmployeeNotFound {
for (Employee employee1 : employeeList) {
if (employee1.getId() == id) {
employee1.setId(id);
employee1.setFirstName(name);
return employee1;
}
}
throw new EmployeeNotFound();
}
public boolean deleteEmployee(int id) throws EmployeeNotFound {
for (Employee emp : employeeList) {
if (emp.getId() == id) {
employeeList.remove(emp);
return true;
}
}
throw new EmployeeNotFound();
}
public Employee addEmployee(int id, String name) throws EmployeeAlreadyExists {
for (Employee emp : employeeList) {
if (emp.getId() == id) {
throw new EmployeeAlreadyExists();
}
}
Employee employee = new Employee(id, name);
employeeList.add(employee);
return employee;
}
public int count() {
return employeeList.size();
}
}
@@ -0,0 +1,34 @@
package com.baeldung.jaxws.server.topdown;
import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.4-b01
* Generated source version: 2.2
*
*/
@WebService(name = "EmployeeServiceTopDown", targetNamespace = "http://topdown.server.jaxws.baeldung.com/")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({
ObjectFactory.class
})
public interface EmployeeServiceTopDown {
/**
*
* @return
* returns int
*/
@WebMethod(action = "http://topdown.server.jaxws.baeldung.com/EmployeeServiceTopDown/countEmployees")
@WebResult(name = "countEmployeesResponse", targetNamespace = "http://topdown.server.jaxws.baeldung.com/", partName = "parameters")
public int countEmployees();
}
@@ -0,0 +1,19 @@
package com.baeldung.jaxws.server.topdown;
import com.baeldung.jaxws.server.repository.EmployeeRepository;
import javax.inject.Inject;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService(name = "EmployeeServiceTopDown", targetNamespace = "http://topdown.server.jaxws.baeldung.com/", endpointInterface = "com.baeldung.jaxws.server.topdown.EmployeeServiceTopDown")
public class EmployeeServiceTopDownImpl implements EmployeeServiceTopDown {
@Inject private EmployeeRepository employeeRepositoryImpl;
@WebMethod
public int countEmployees() {
return employeeRepositoryImpl.count();
}
}
@@ -0,0 +1,94 @@
package com.baeldung.jaxws.server.topdown;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.4-b01
* Generated source version: 2.2
*
*/
@WebServiceClient(name = "EmployeeServiceTopDown", targetNamespace = "http://topdown.server.jaxws.baeldung.com/", wsdlLocation = "file:/Users/do-enr-lap-4/Developer/baeldung/source/tutorials/jee7/src/main/java/com/baeldung/jaxws/server/topdown/wsdl/employeeservicetopdown.wsdl")
public class EmployeeServiceTopDown_Service
extends Service
{
private final static URL EMPLOYEESERVICETOPDOWN_WSDL_LOCATION;
private final static WebServiceException EMPLOYEESERVICETOPDOWN_EXCEPTION;
private final static QName EMPLOYEESERVICETOPDOWN_QNAME = new QName("http://topdown.server.jaxws.baeldung.com/", "EmployeeServiceTopDown");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("file:/Users/do-enr-lap-4/Developer/baeldung/source/tutorials/jee7/src/main/java/com/baeldung/jaxws/server/topdown/wsdl/employeeservicetopdown.wsdl");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
EMPLOYEESERVICETOPDOWN_WSDL_LOCATION = url;
EMPLOYEESERVICETOPDOWN_EXCEPTION = e;
}
public EmployeeServiceTopDown_Service() {
super(__getWsdlLocation(), EMPLOYEESERVICETOPDOWN_QNAME);
}
public EmployeeServiceTopDown_Service(WebServiceFeature... features) {
super(__getWsdlLocation(), EMPLOYEESERVICETOPDOWN_QNAME, features);
}
public EmployeeServiceTopDown_Service(URL wsdlLocation) {
super(wsdlLocation, EMPLOYEESERVICETOPDOWN_QNAME);
}
public EmployeeServiceTopDown_Service(URL wsdlLocation, WebServiceFeature... features) {
super(wsdlLocation, EMPLOYEESERVICETOPDOWN_QNAME, features);
}
public EmployeeServiceTopDown_Service(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public EmployeeServiceTopDown_Service(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns EmployeeServiceTopDown
*/
@WebEndpoint(name = "EmployeeServiceTopDownSOAP")
public EmployeeServiceTopDown getEmployeeServiceTopDownSOAP() {
return super.getPort(new QName("http://topdown.server.jaxws.baeldung.com/", "EmployeeServiceTopDownSOAP"), EmployeeServiceTopDown.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns EmployeeServiceTopDown
*/
@WebEndpoint(name = "EmployeeServiceTopDownSOAP")
public EmployeeServiceTopDown getEmployeeServiceTopDownSOAP(WebServiceFeature... features) {
return super.getPort(new QName("http://topdown.server.jaxws.baeldung.com/", "EmployeeServiceTopDownSOAP"), EmployeeServiceTopDown.class, features);
}
private static URL __getWsdlLocation() {
if (EMPLOYEESERVICETOPDOWN_EXCEPTION!= null) {
throw EMPLOYEESERVICETOPDOWN_EXCEPTION;
}
return EMPLOYEESERVICETOPDOWN_WSDL_LOCATION;
}
}
@@ -0,0 +1,45 @@
package com.baeldung.jaxws.server.topdown;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.baeldung.jaxws.server.topdown package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
private final static QName _CountEmployeesResponse_QNAME = new QName("http://topdown.server.jaxws.baeldung.com/", "countEmployeesResponse");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.jaxws.server.topdown
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://topdown.server.jaxws.baeldung.com/", name = "countEmployeesResponse")
public JAXBElement<Integer> createCountEmployeesResponse(Integer value) {
return new JAXBElement<Integer>(_CountEmployeesResponse_QNAME, Integer.class, null, value);
}
}
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://topdown.server.jaxws.baeldung.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://topdown.server.jaxws.baeldung.com/"
name="EmployeeServiceTopDown">
<types>
<xsd:schema targetNamespace="http://topdown.server.jaxws.baeldung.com/">
<xsd:element name="countEmployeesResponse" type="xsd:int"/>
</xsd:schema>
</types>
<message name="countEmployees">
</message>
<message name="countEmployeesResponse">
<part name="parameters" element="tns:countEmployeesResponse"/>
</message>
<portType name="EmployeeServiceTopDown">
<operation name="countEmployees">
<input message="tns:countEmployees"/>
<output message="tns:countEmployeesResponse"/>
</operation>
</portType>
<binding name="EmployeeServiceTopDownSOAP" type="tns:EmployeeServiceTopDown">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="countEmployees">
<soap:operation soapAction="http://topdown.server.jaxws.baeldung.com/EmployeeServiceTopDown/countEmployees"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="EmployeeServiceTopDown">
<port name="EmployeeServiceTopDownSOAP" binding="tns:EmployeeServiceTopDownSOAP">
<soap:address location="http://localhost:8080/employeeservicetopdown"/>
</port>
</service>
</definitions>
@@ -0,0 +1,43 @@
package com.baeldung.json;
import java.util.Date;
import java.util.List;
public class Person {
private String firstName;
private String lastName;
private Date birthdate;
private List<String> emails;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Date getBirthdate() {
return birthdate;
}
public void setBirthdate(Date birthdate) {
this.birthdate = birthdate;
}
public List<String> getEmails() {
return emails;
}
public void setEmails(List<String> emails) {
this.emails = emails;
}
}
@@ -0,0 +1,42 @@
package com.baeldung.json;
import javax.json.*;
import java.io.IOException;
import java.io.StringReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.stream.Collectors;
public class PersonBuilder {
private String jsonString;
private SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
public PersonBuilder(String jsonString) {
this.jsonString = jsonString;
}
public Person build() throws IOException, ParseException {
JsonReader reader = Json.createReader(new StringReader(jsonString));
JsonObject jsonObject = reader.readObject();
Person person = new Person();
person.setFirstName(jsonObject.getString("firstName"));
person.setLastName(jsonObject.getString("lastName"));
person.setBirthdate(dateFormat.parse(jsonObject.getString("birthdate")));
JsonArray emailsJson = jsonObject.getJsonArray("emails");
List<String> emails = emailsJson.getValuesAs(JsonString.class).stream()
.map(JsonString::getString)
.collect(Collectors.toList());
person.setEmails(emails);
return person;
}
}
@@ -0,0 +1,60 @@
package com.baeldung.json;
import javax.json.*;
import javax.json.stream.JsonGenerator;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
public class PersonWriter {
private Person person;
private SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
public PersonWriter(Person person) {
this.person = person;
}
public String write() throws IOException {
JsonObjectBuilder objectBuilder = Json
.createObjectBuilder()
.add("firstName", person.getFirstName())
.add("lastName", person.getLastName())
.add("birthdate", dateFormat.format(person.getBirthdate()));
final JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
person.getEmails().forEach(arrayBuilder::add);
objectBuilder.add("emails", arrayBuilder);
JsonObject jsonObject = objectBuilder.build();
JsonWriterFactory writerFactory = createWriterFactory();
return writeToString(jsonObject, writerFactory);
}
private String writeToString(JsonObject jsonObject, JsonWriterFactory writerFactory) throws IOException {
String jsonString;
try (Writer writer = new StringWriter()) {
writerFactory
.createWriter(writer)
.write(jsonObject);
jsonString = writer.toString();
}
return jsonString;
}
private JsonWriterFactory createWriterFactory() {
Map<String, Boolean> config = new HashMap<>();
config.put(JsonGenerator.PRETTY_PRINTING, true);
return Json.createWriterFactory(config);
}
}
@@ -0,0 +1,13 @@
package com.baeldung.springSecurity;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
/**
* Application class required by JAX-RS. If you don't want to have any
* prefix in the URL, you can set the application path to "/".
*/
@ApplicationPath("/")
public class ApplicationConfig extends Application {
}
@@ -0,0 +1,10 @@
package com.baeldung.springSecurity;
import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer {
public SecurityWebApplicationInitializer() {
super(SpringSecurityConfig.class);
}
}
@@ -0,0 +1,46 @@
package com.baeldung.springSecurity;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
@EnableWebSecurity
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("user1")
.password("user1Pass")
.roles("USER")
.and()
.withUser("admin")
.password("adminPass")
.roles("ADMIN");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf()
.disable()
.authorizeRequests()
.antMatchers("/auth/login*")
.anonymous()
.antMatchers("/home/admin*")
.hasRole("ADMIN")
.anyRequest()
.authenticated()
.and()
.formLogin()
.loginPage("/auth/login")
.defaultSuccessUrl("/home", true)
.failureUrl("/auth/login?error=true")
.and()
.logout()
.logoutSuccessUrl("/auth/login");
}
}
@@ -0,0 +1,28 @@
package com.baeldung.springSecurity.controller;
import javax.mvc.annotation.Controller;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@Path("/home")
@Controller
public class HomeController {
@GET
public String home() {
return "home.jsp";
}
@GET
@Path("/user")
public String admin() {
return "user.jsp";
}
@GET
@Path("/admin")
public String user() {
return "admin.jsp";
}
}
@@ -0,0 +1,15 @@
package com.baeldung.springSecurity.controller;
import javax.mvc.annotation.Controller;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@Path("/auth/login")
@Controller
public class LoginController {
@GET
public String login() {
return "login.jsp";
}
}
@@ -0,0 +1,27 @@
package com.baeldung.timer;
import javax.ejb.Schedule;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import java.util.Date;
@Startup
@Singleton
public class AutomaticTimerBean {
@Inject
Event<TimerEvent> event;
/**
* This method will be called every 10 second and will fire an @TimerEvent
*/
@Schedule(hour = "*", minute = "*", second = "*/10", info = "Every 10 second timer")
public void printDate() {
event.fire(new TimerEvent("TimerEvent sent at :" + new Date()));
}
}
@@ -0,0 +1,20 @@
package com.baeldung.timer;
import javax.ejb.*;
/**
* Created by ccristianchiovari on 5/2/16.
*/
@Singleton
public class FixedDelayTimerBean {
@EJB
private WorkerBean workerBean;
@Lock(LockType.READ)
@Schedule(second = "*/5", minute = "*", hour = "*", persistent = false)
public void atSchedule() throws InterruptedException {
workerBean.doTimerWork();
}
}
@@ -0,0 +1,31 @@
package com.baeldung.timer;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.*;
import javax.enterprise.event.Event;
import javax.inject.Inject;
/**
* author: Cristian Chiovari
*/
@Startup
@Singleton
public class ProgrammaticAtFixedRateTimerBean {
@Inject
Event<TimerEvent> event;
@Resource
TimerService timerService;
@PostConstruct
public void initialize() {
timerService.createTimer(0,1000, "Every second timer");
}
@Timeout
public void programmaticTimout(Timer timer) {
event.fire(new TimerEvent(timer.getInfo().toString()));
}
}
@@ -0,0 +1,39 @@
package com.baeldung.timer;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.*;
import javax.enterprise.event.Event;
import javax.inject.Inject;
/**
* author: Jacek Jackowiak
*/
@Startup
@Singleton
public class ProgrammaticTimerBean {
@Inject
Event<TimerEvent> event;
@Resource
TimerService timerService;
@PostConstruct
public void initialize() {
ScheduleExpression scheduleExpression = new ScheduleExpression()
.hour("*")
.minute("*")
.second("*/5");
TimerConfig timerConfig = new TimerConfig();
timerConfig.setInfo("Every 5 second timer");
timerService.createCalendarTimer(scheduleExpression, timerConfig);
}
@Timeout
public void programmaticTimout(Timer timer) {
event.fire(new TimerEvent(timer.getInfo().toString()));
}
}
@@ -0,0 +1,31 @@
package com.baeldung.timer;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.*;
import javax.enterprise.event.Event;
import javax.inject.Inject;
/**
* author: Cristian Chiovari
*/
@Startup
@Singleton
public class ProgrammaticWithInitialFixedDelayTimerBean {
@Inject
Event<TimerEvent> event;
@Resource
TimerService timerService;
@PostConstruct
public void initialize() {
timerService.createTimer(10000l,5000l, "Delay 10 seconds then every 5 second timer");
}
@Timeout
public void programmaticTimout(Timer timer) {
event.fire(new TimerEvent(timer.getInfo().toString()));
}
}
@@ -0,0 +1,27 @@
package com.baeldung.timer;
import javax.ejb.Schedule;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.ejb.Timer;
import javax.enterprise.event.Event;
import javax.inject.Inject;
@Startup
@Singleton
public class ScheduleTimerBean {
@Inject
Event<TimerEvent> event;
@Schedule(hour = "*", minute = "*", second = "*/5", info = "Every 5 second timer")
public void automaticallyScheduled(Timer timer) {
fireEvent(timer);
}
private void fireEvent(Timer timer) {
event.fire(new TimerEvent(timer.getInfo().toString()));
}
}
@@ -0,0 +1,27 @@
package com.baeldung.timer;
public class TimerEvent {
private String eventInfo;
private long time = System.currentTimeMillis();
public TimerEvent(String s) {
this.eventInfo = s;
}
public long getTime() {
return time;
}
public String getEventInfo() {
return eventInfo;
}
@Override
public String toString() {
return "TimerEvent {" +
"eventInfo='" + eventInfo + '\'' +
", time=" + time +
'}';
}
}
@@ -0,0 +1,26 @@
package com.baeldung.timer;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.enterprise.event.Observes;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* This class will listen to all TimerEvent and will collect them
*/
@Startup
@Singleton
public class TimerEventListener {
final List<TimerEvent> events = new CopyOnWriteArrayList<>();
public void listen(@Observes TimerEvent event) {
System.out.println("event = " + event);
events.add(event);
}
public List<TimerEvent> getEvents() {
return events;
}
}
@@ -0,0 +1,33 @@
package com.baeldung.timer;
import javax.ejb.Lock;
import javax.ejb.LockType;
import javax.ejb.Singleton;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* Created by cristianchiovari on 5/2/16.
*/
@Singleton
public class WorkerBean {
private AtomicBoolean busy = new AtomicBoolean(false);
@Lock(LockType.READ)
public void doTimerWork() throws InterruptedException {
System.out.println("Timer method called but not started yet !");
if (!busy.compareAndSet(false, true)) {
return;
}
try {
System.out.println("Timer work started");
Thread.sleep(12000);
System.out.println("Timer work done");
} finally {
busy.set(false);
}
}
}
@@ -0,0 +1,13 @@
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name="defaultPersistenceUnit" transaction-type="JTA">
<class>com.baeldung.arquillian.Car</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:testdb"/>
<property name="javax.persistence.jdbc.user" value="sa"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>
+50
View File
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>Converters, Listeners and Validators</title>
</h:head>
<h:body>
<h1>Testing converters</h1>
<h:form id="myForm">
<h:outputLabel value="Age:"/>
<h:inputText id="age" value="#{convListVal.age}">
<f:converter converterId="javax.faces.Integer" />
</h:inputText>
<h:message id="ageError" for="age" />
<br/>
<h:outputLabel value="Average:"/>
<h:inputText id="average" value="#{convListVal.average}">
<f:converter converterId="javax.faces.Double" />
</h:inputText>
<h:message id = "averageError" for="average" />
<br/>
<h:outputLabel value="Date:"/>
<h:inputText id="myDate" value="#{convListVal.myDate}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:inputText>
<h:message id="myDateError" for="myDate" />
<br/>
<h:outputText value="#{convListVal.myDate}">
<f:convertDateTime dateStyle="full" locale="en"/>
</h:outputText>
<br/>
<h:outputLabel value="Name:"/>
<h:inputText id="name" size="30" value="#{convListVal.name}">
<f:valueChangeListener type="com.baeldung.convListVal.MyListener" />
</h:inputText>
<br/>
<h:outputLabel value="surname" for="surname"/>
<h:panelGroup>
<h:inputText id="surname" value="#{convListVal.surname}">
<f:validateLength minimum="5" maximum="10"/>
</h:inputText>
<h:message id="surnameError" for="surname" errorStyle="color:red" />
</h:panelGroup>
<br/>
<h:commandButton id="send" value="submit" type="submit" />
</h:form>
</h:body>
</html>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<managed-bean>
<managed-bean-name>convListVal</managed-bean-name>
<managed-bean-class>com.baeldung.convListVal.ConvListVal</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<b:beans xmlns="http://www.springframework.org/schema/security"
xmlns:b="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
<authentication-manager>
<authentication-provider>
<user-service>
<user name="user" password="user123" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
<http auto-config='true' use-expressions="true">
<form-login default-target-url="/secure.jsp" />
<intercept-url pattern="/" access="isAnonymous()" />
<intercept-url pattern="/index.jsp" access="isAnonymous()" />
<intercept-url pattern="/secure.jsp" access="hasRole('ROLE_USER')" />
</http>
</b:beans>
@@ -0,0 +1,12 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<html>
<head></head>
<body>
<h1>Welcome to the ADMIN page</h1>
<a href="<c:url value="/logout" />">Logout</a>
</body>
</html>
@@ -0,0 +1,26 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<html>
<head></head>
<body>
<h1>This is the body of the sample view</h1>
<security:authorize access="hasRole('USER')">
This text is only visible to a user
<br/> <br/>
<a href="<c:url value="/home/user" />">Restricted Admin Page</a>
<br/> <br/>
</security:authorize>
<security:authorize access="hasRole('ADMIN')">
This text is only visible to an admin
<br/>
<a href="<c:url value="/home/admin" />">Admin Page</a>
<br/>
</security:authorize>
<a href="<c:url value="/logout" />">Logout</a>
</body>
</html>
@@ -0,0 +1,26 @@
<html>
<head></head>
<body>
<h1>Login</h1>
<form name='f' action="/auth/login" method='POST'>
<table>
<tr>
<td>User:</td>
<td><input type='text' name='username' value=''></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password'/></td>
</tr>
<tr>
<td><input name="submit" type="submit" value="submit"/></td>
</tr>
</table>
</form>
</body>
</html>
@@ -0,0 +1,12 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<html>
<head></head>
<body>
<h1>Welcome to the Restricted Admin page</h1>
<a href="<c:url value="/logout" />">Logout</a>
</body>
</html>
+68
View File
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<!-- The bare minimum needed for JSF 2.2 is a servlet 2.5 or later
declaration (this uses 3.0) and the mapping for the FacesServlet.
Setting PROJECT_STAGE to Development is highly recommended
during initial development so that you get more helpful
error messages. Whether you want server-side state saving
(default) or client-side is a more complicated question:
client-side uses more bandwidth but fewer server resources.
Client-side also helps to avoid the dreaded view expired exceptions.
From JSF 2 and PrimeFaces tutorial
at http://www.coreservlets.com/JSF-Tutorial/jsf2/
-->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<description>State saving method: 'client' or 'server' (default). See JSF Specification section 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<!-- If you go to http://host/project/ (with no file name), it will
try index.jsf first, welcome.jsf next, and so forth.
-->
<!-- UNCOMMENT THE FOLLOWING SECTION FOR SPRING SECURITY XML CONFIGURATION-->
<!--<context-param>-->
<!--<param-name>contextConfigLocation</param-name>-->
<!--<param-value>-->
<!--/WEB-INF/spring/*.xml-->
<!--</param-value>-->
<!--</context-param>-->
<!--<filter>-->
<!--<filter-name>springSecurityFilterChain</filter-name>-->
<!--<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>-->
<!--</filter>-->
<!--<filter-mapping>-->
<!--<filter-name>springSecurityFilterChain</filter-name>-->
<!--<url-pattern>/*</url-pattern>-->
<!--</filter-mapping>-->
<!--<listener>-->
<!--<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>-->
<!--</listener>-->
<!-- END SPRING SECURITY XML CONFIGURATION-->
<welcome-file-list>
<welcome-file>index.jsf</welcome-file>
<welcome-file>welcome.jsf</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
+11
View File
@@ -0,0 +1,11 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Index Page</title>
</head>
<body>
Non-secured Index Page
<br>
<a href="/login">Login</a>
</body>
</html>
+24
View File
@@ -0,0 +1,24 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="sec" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Home Page</title>
</head>
<body>
<h3>Home Page</h3>
<p>
Hello <b><c:out value="${pageContext.request.remoteUser}"/></b><br>
Roles: <b><sec:authentication property="principal.authorities" /></b>
</p>
<form action="logout" method="post">
<input type="submit" value="Logout" />
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
</body>
</html>