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