View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.cxf.employee;
8   
9   import org.mule.example.employee.Employee;
10  import org.mule.example.employee.EmployeeDirectory;
11  
12  import java.io.IOException;
13  import java.io.InputStream;
14  import java.util.ArrayList;
15  import java.util.List;
16  
17  import javax.jws.WebService;
18  
19  @WebService(serviceName = "EmployeeDirectory", portName = "EmployeeDirectoryPort", endpointInterface = "org.mule.example.employee.EmployeeDirectory")
20  public class EmployeeDirectoryImpl implements EmployeeDirectory
21  {
22  
23      private int invocationCount;
24      private List<Employee> employees = new ArrayList<Employee>();
25  
26      public List<Employee> getEmployees()
27      {
28          return employees;
29      }
30  
31      public void addEmployee(Employee employee)
32      {
33          // Read the picture, otherwise the other side never finishes writing
34          try
35          {
36              InputStream is = employee.getPicture().getInputStream();
37              
38              while (is.read() != -1);
39          }
40          catch (IOException e)
41          {
42              e.printStackTrace();
43          }
44          
45          
46          
47          System.out.println("Added " + employee.getName() + " in division " + employee.getDivision()
48                             + " with a picture " + employee.getPicture());
49          employees.add(employee);
50          invocationCount++;
51      }
52  
53      public int getInvocationCount()
54      {
55          return invocationCount;
56      }
57  
58  }