Merge remote-tracking branch 'origin/master'

This commit is contained in:
slavisa-baeldung
2017-04-26 08:57:07 +01:00
98 changed files with 3373 additions and 242 deletions
+1 -7
View File
@@ -11,13 +11,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
View File
+76 -19
View File
@@ -165,19 +165,61 @@
<groupId>org.javamoney</groupId>
<artifactId>moneta</artifactId>
<version>1.1</version>
</dependency>
</dependency>
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.1.0.1</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- JDO -->
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>javax.jdo</artifactId>
<version>3.2.0-m6</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>5.1.0-m1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId>
<version>5.1.0-m1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>5.1.0-m1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>5.0.2</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.194</version>
</dependency>
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.1.0.1</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.1.0.1</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
@@ -191,7 +233,6 @@
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -201,7 +242,6 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
@@ -214,7 +254,6 @@
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
@@ -245,7 +284,6 @@
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
@@ -269,7 +307,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
@@ -290,7 +327,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jolira</groupId>
<artifactId>onejar-maven-plugin</artifactId>
@@ -307,7 +343,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
@@ -323,6 +358,28 @@
</execution>
</executions>
</plugin>
<!-- JDO Plugin -->
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>5.0.2</version>
<configuration>
<api>JDO</api>
<props>${basedir}/datanucleus.properties</props>
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
@@ -0,0 +1,83 @@
package com.baeldung.jdo;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Query;
import javax.jdo.Transaction;
public class GuideToJDO {
private static final Logger LOGGER = Logger.getLogger(GuideToJDO.class.getName());
private Random rnd = new Random();
public static void main(String[] args) {
new GuideToJDO();
}
public GuideToJDO() {
CreateProducts();
ListProducts();
}
public void CreateProducts() {
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("Tutorial");
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Product product = new Product("Tablet", 80.0);
pm.makePersistent(product);
Product product2 = new Product("Phone", 20.0);
pm.makePersistent(product2);
Product product3 = new Product("Laptop", 200.0);
pm.makePersistent(product3);
for (int i = 0; i < 100; i++) {
String nam = "Product-" + i;
double price = rnd.nextDouble();
Product productx = new Product(nam, price);
pm.makePersistent(productx);
}
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
@SuppressWarnings("unchecked")
public void ListProducts() {
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("Tutorial");
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
@SuppressWarnings("rawtypes")
Query q = pm.newQuery("SELECT FROM " + Product.class.getName() + " WHERE price < 1");
List<Product> products = (List<Product>) q.execute();
Iterator<Product> iter = products.iterator();
while (iter.hasNext()) {
Product p = iter.next();
LOGGER.log(Level.WARNING, "Product name: {0} - Price: {1}", new Object[] { p.name, p.price });
}
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
}
@@ -0,0 +1,43 @@
package com.baeldung.jdo;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
@PersistenceCapable
public class Product {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.INCREMENT)
long id;
String name = null;
Double price = 0.0;
public Product() {
this.name = null;
this.price = 0.0;
}
public Product(String name, Double price) {
this.name = name;
this.price = price;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
}
@@ -22,11 +22,11 @@ public class Producer implements Runnable {
try {
System.out.println("Producer: " + name + " is waiting to transfer...");
boolean added = transferQueue.tryTransfer("A" + i, 4000, TimeUnit.MILLISECONDS);
if (!added) {
System.out.println("can not add an element due to the timeout");
} else {
if (added) {
numberOfProducedMessages.incrementAndGet();
System.out.println("Producer: " + name + " transferred element: A" + i);
} else {
System.out.println("can not add an element due to the timeout");
}
} catch (InterruptedException e) {
e.printStackTrace();
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" version="2.1">
<!-- JDO tutorial "unit" -->
<persistence-unit name="Tutorial">
<exclude-unlisted-classes/>
<properties>
<property name="javax.jdo.PersistenceManagerFactoryClass" value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory"/>
<property name="javax.jdo.option.ConnectionURL" value="jdbc:h2:mem:mypersistence"/>
<property name="javax.jdo.option.ConnectionDriverName" value="org.h2.Driver"/>
<property name="javax.jdo.option.ConnectionUserName" value="sa"/>
<property name="javax.jdo.option.ConnectionPassword" value=""/>
<property name="datanucleus.schema.autoCreateAll" value="true"/>
</properties>
</persistence-unit>
</persistence>
@@ -0,0 +1,89 @@
package com.baeldung.java.set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ConcurrentModificationException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
import org.junit.Test;
public class SetTest {
@Test
public void givenTreeSet_whenRetrievesObjects_thenNaturalOrder() {
Set<String> set = new TreeSet<>();
set.add("Baeldung");
set.add("is");
set.add("Awesome");
assertEquals(3, set.size());
assertTrue(set.iterator()
.next()
.equals("Awesome"));
}
@Test(expected = NullPointerException.class)
public void givenTreeSet_whenAddNullObject_thenNullPointer() {
Set<String> set = new TreeSet<>();
set.add("Baeldung");
set.add("is");
set.add(null);
}
@Test
public void givenHashSet_whenAddNullObject_thenOK() {
Set<String> set = new HashSet<>();
set.add("Baeldung");
set.add("is");
set.add(null);
assertEquals(3, set.size());
}
@Test
public void givenHashSetAndTreeSet_whenAddObjects_thenHashSetIsFaster() {
Set<String> set = new HashSet<>();
long startTime = System.nanoTime();
set.add("Baeldung");
set.add("is");
set.add("Awesome");
long endTime = System.nanoTime();
long duration1 = (endTime - startTime);
Set<String> set2 = new TreeSet<>();
startTime = System.nanoTime();
set2.add("Baeldung");
set2.add("is");
set2.add("Awesome");
endTime = System.nanoTime();
long duration2 = (endTime - startTime);
assertTrue(duration1 < duration2);
}
@Test
public void givenHashSetAndTreeSet_whenAddDuplicates_thenOnlyUnique() {
Set<String> set = new HashSet<>();
set.add("Baeldung");
set.add("Baeldung");
assertTrue(set.size() == 1);
Set<String> set2 = new TreeSet<>();
set2.add("Baeldung");
set2.add("Baeldung");
assertTrue(set2.size() == 1);
}
@Test(expected = ConcurrentModificationException.class)
public void givenHashSet_whenModifyWhenIterator_thenFailFast() {
Set<String> set = new HashSet<>();
set.add("Baeldung");
Iterator<String> it = set.iterator();
while (it.hasNext()) {
set.add("Awesome");
it.next();
}
}
}
@@ -1,4 +1,5 @@
package com.baeldung.java8.comparator;
/*
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -15,9 +16,10 @@ public class Employee implements Comparable<Employee>{
double salary;
long mobile;
@Override
public int compareTo(Employee argEmployee) {
return name.compareTo(argEmployee.getName());
}
}
*/
@@ -1,5 +1,5 @@
package com.baeldung.java8.comparator;
/*
import java.util.Arrays;
import java.util.Comparator;
@@ -165,3 +165,4 @@ public class Java8ComparatorTest {
}
*/
@@ -0,0 +1,96 @@
package com.baeldung.jdo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.Iterator;
import java.util.List;
import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Query;
import javax.jdo.Transaction;
import org.junit.Test;
public class GuideToJDOTest {
@Test
public void givenProduct_WhenNewThenPerformTransaction() {
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("Tutorial");
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
for (int i = 0; i < 100; i++){
String nam = "Product-" + i;
double price = i;
Product productx = new Product(nam, price);
pm.makePersistent(productx);
}
tx.commit();
} catch (Throwable thr) {
fail("Failed test : " + thr.getMessage());
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pmf.close();
}
@Test
public void givenProduct_WhenQueryThenExist() {
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("Tutorial");
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Product product = new Product("Tablet", 80.0);
pm.makePersistent(product);
Product product2 = new Product("Phone", 20.0);
pm.makePersistent(product2);
Product product3 = new Product("Laptop", 200.0);
pm.makePersistent(product3);
tx.commit();
} catch (Throwable thr) {
fail("Failed test : " + thr.getMessage());
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pmf.close();
PersistenceManagerFactory pmf2 = JDOHelper.getPersistenceManagerFactory("Tutorial");
PersistenceManager pm2 = pmf2.getPersistenceManager();
Transaction tx2 = pm2.currentTransaction();
try {
tx2.begin();
@SuppressWarnings("rawtypes")
Query q = pm2.newQuery("SELECT FROM " + Product.class.getName() + " WHERE price == 200");
@SuppressWarnings("unchecked")
List<Product> products = (List<Product>) q.execute();
Iterator<Product> iter = products.iterator();
while (iter.hasNext()) {
Product p = iter.next();
assertEquals("Laptop", p.name);
}
tx2.commit();
} finally {
if (tx2.isActive()) {
tx2.rollback();
}
pm2.close();
}
}
}
@@ -12,7 +12,7 @@ import static junit.framework.TestCase.assertEquals;
public class TransferQueueTest {
@Test
public void givenTransferQueue_whenUseMultipleConsumersAndMultipleProducers_thenShouldProcessAllMessages() throws InterruptedException {
public void whenMultipleConsumersAndProducers_thenProcessAllMessages() throws InterruptedException {
//given
TransferQueue<String> transferQueue = new LinkedTransferQueue<>();
ExecutorService exService = Executors.newFixedThreadPool(3);
@@ -28,7 +28,7 @@ public class TransferQueueTest {
exService.execute(consumer2);
//then
exService.awaitTermination(10_000, TimeUnit.MILLISECONDS);
exService.awaitTermination(5000, TimeUnit.MILLISECONDS);
exService.shutdown();
assertEquals(producer1.numberOfProducedMessages.intValue(), 3);
@@ -36,7 +36,7 @@ public class TransferQueueTest {
}
@Test
public void givenTransferQueue_whenUseOneConsumerAndOneProducer_thenShouldProcessAllMessages() throws InterruptedException {
public void whenUseOneConsumerAndOneProducer_thenShouldProcessAllMessages() throws InterruptedException {
//given
TransferQueue<String> transferQueue = new LinkedTransferQueue<>();
ExecutorService exService = Executors.newFixedThreadPool(2);
@@ -56,7 +56,7 @@ public class TransferQueueTest {
}
@Test
public void givenTransferQueue_whenUseOneProducerAndNoConsumers_thenShouldFailWithTimeout() throws InterruptedException {
public void whenUseOneProducerAndNoConsumers_thenShouldFailWithTimeout() throws InterruptedException {
//given
TransferQueue<String> transferQueue = new LinkedTransferQueue<>();
ExecutorService exService = Executors.newFixedThreadPool(2);
+1
View File
@@ -171,6 +171,7 @@
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*LongRunningUnitTest.java</exclude>
<exclude>**/*ManualTest.java</exclude>
<exclude>**/*LiveTest.java</exclude>
</excludes>
</configuration>
</plugin>
@@ -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;
}
}

Some files were not shown because too many files have changed in this diff Show More