KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > jbi > management > deployment > undeploy > SALifeCycleRetrievalTask


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2006 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: SALifeCycleRetrievalTask.java 154 10 oct. 06 ofabre $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.jbi.management.deployment.undeploy;
23
24 import java.util.HashMap JavaDoc;
25
26 import org.objectweb.petals.jbi.component.lifecycle.ServiceAssemblyLifeCycle;
27 import org.objectweb.petals.jbi.management.deployment.DeploymentContextConstants;
28 import org.objectweb.petals.jbi.management.deployment.ServiceAssemblyDataHandler;
29 import org.objectweb.petals.jbi.management.service.LifeCycleManagerService;
30 import org.objectweb.petals.processor.Task;
31 import org.objectweb.petals.util.LoggingUtil;
32
33 /**
34  * Retrieve service assembly lifecycle.
35  *
36  * @author ofabre - EBM Websourcing
37  *
38  */

39 public class SALifeCycleRetrievalTask implements Task {
40
41     /**
42      * JBI Container :: JMX Agent Admin
43      */

44     protected LifeCycleManagerService managerService;
45
46     /**
47      * logger wrapper
48      */

49     protected LoggingUtil log;
50
51     public SALifeCycleRetrievalTask(LifeCycleManagerService managerService,
52             LoggingUtil log) {
53         super();
54         this.managerService = managerService;
55         this.log = log;
56     }
57
58     @SuppressWarnings JavaDoc("unchecked")
59     public void execute(HashMap JavaDoc context) throws Exception JavaDoc {
60         ServiceAssemblyDataHandler handler = (ServiceAssemblyDataHandler) context
61                 .get(DeploymentContextConstants.SA_DATA_HANDLER);
62
63         ServiceAssemblyLifeCycle saLifeCycle = retrieveServiceAssemblyLifeCycle(handler
64                 .getName());
65
66         /*
67          * Fill context
68          */

69         context.put(DeploymentContextConstants.SA_LIFECYCLE, saLifeCycle);
70
71     }
72
73     /**
74      * Retrieve the {@link ServiceAssemblyLifeCycle} matching the given service
75      * assembly name.
76      *
77      * @param saName
78      * the service assembly name
79      * @return the retrieved {@link ServiceAssemblyLifeCycle}
80      * @throws Exception
81      * if no service assembly can be retrieved
82      */

83     protected ServiceAssemblyLifeCycle retrieveServiceAssemblyLifeCycle(
84             String JavaDoc saName) throws Exception JavaDoc {
85         ServiceAssemblyLifeCycle saLifeCycle = managerService
86                 .getServiceAssemblyByName(saName);
87         if (saLifeCycle == null) {
88             String JavaDoc msg = "The service assembly (" + saName
89                     + ") isn't deployed into the JBI environment.";
90             log.error(msg);
91             throw new Exception JavaDoc(msg);
92         }
93         return saLifeCycle;
94     }
95
96     public void undo(HashMap JavaDoc context) throws Exception JavaDoc {
97         // TODO Auto-generated method stub
98

99     }
100
101 }
102
Popular Tags