KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > jbi > component > lifecycle > mock > ServiceUnitManagerMock


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: ServiceUnitManagerMock.java 11:33:24 ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.jbi.component.lifecycle.mock;
23
24 import java.util.HashMap JavaDoc;
25 import java.util.Map JavaDoc;
26
27 import javax.jbi.JBIException;
28 import javax.jbi.component.ServiceUnitManager;
29 import javax.jbi.management.DeploymentException;
30
31 /**
32  * Mock object of the ServiceUnitManager
33  *
34  * @author ddesjardins - eBMWebsourcing
35  */

36 public class ServiceUnitManagerMock implements ServiceUnitManager {
37
38     private Map JavaDoc<String JavaDoc, ServiceUnitMock> units = new HashMap JavaDoc<String JavaDoc, ServiceUnitMock>();
39
40     public String JavaDoc deploy(String JavaDoc serviceUnitName, String JavaDoc serviceUnitRootPath)
41         throws DeploymentException {
42         ServiceUnitMock serviceUnit = new ServiceUnitMock();
43         IdentificationMock identification = new IdentificationMock();
44         identification.setName(serviceUnitName);
45         serviceUnit.setIdentification(identification);
46         units.put(serviceUnitName, serviceUnit);
47         return "Success";
48     }
49
50     public void init(String JavaDoc serviceUnitName, String JavaDoc serviceUnitRootPath)
51         throws DeploymentException {
52     }
53
54     public void shutDown(String JavaDoc serviceUnitName) throws DeploymentException {
55         try {
56             units.get(serviceUnitName).shutDown();
57         } catch (JBIException e) {
58             throw new DeploymentException(e);
59         }
60     }
61
62     public void start(String JavaDoc serviceUnitName) throws DeploymentException {
63         try {
64             units.get(serviceUnitName).start();
65         } catch (JBIException e) {
66             throw new DeploymentException(e);
67         }
68     }
69
70     public void stop(String JavaDoc serviceUnitName) throws DeploymentException {
71         try {
72             units.get(serviceUnitName).stop();
73         } catch (JBIException e) {
74             throw new DeploymentException(e);
75         }
76     }
77
78     public String JavaDoc undeploy(String JavaDoc serviceUnitName, String JavaDoc serviceUnitRootPath)
79         throws DeploymentException {
80         return null;
81     }
82
83     public Map JavaDoc<String JavaDoc, ServiceUnitMock> getUnits() {
84         return units;
85     }
86
87 }
88
Popular Tags