KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > jbi > management > deployment > deploy > SALifeCycleRegistrationTask


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: SALifeCycleRegistrationTask.java 154 6 oct. 06 ofabre $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.jbi.management.deployment.deploy;
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.DeploymentUtils;
29 import org.objectweb.petals.jbi.management.service.LifeCycleManagerService;
30 import org.objectweb.petals.jbi.management.service.ManagementException;
31 import org.objectweb.petals.processor.Task;
32 import org.objectweb.petals.tools.jbicommon.descriptor.JBIDescriptor;
33 import org.objectweb.petals.util.LoggingUtil;
34
35 /**
36  * This task registers ServiceAssemblyLifeCycle into manager service map.
37  *
38  * @author ofabre - EBM Websourcing
39  *
40  */

41 public class SALifeCycleRegistrationTask implements Task {
42
43     /**
44      * JBI Container :: JMX Agent Admin
45      */

46     protected LifeCycleManagerService managerService;
47
48     /**
49      * logger wrapper
50      */

51     protected LoggingUtil log;
52
53     public SALifeCycleRegistrationTask(LifeCycleManagerService managerService,
54             LoggingUtil log) {
55         super();
56         this.managerService = managerService;
57         this.log = log;
58     }
59
60     public void execute(HashMap JavaDoc context) throws Exception JavaDoc {
61         JBIDescriptor descriptor = (JBIDescriptor) context
62                 .get(DeploymentContextConstants.SA_DESCRIPTOR);
63
64         ServiceAssemblyLifeCycle lifeCycle = (ServiceAssemblyLifeCycle) context
65                 .get(DeploymentContextConstants.SA_LIFECYCLE);
66
67         managerService.registerServiceAssembly(DeploymentUtils
68                 .getServiceAssemblyName(descriptor), lifeCycle);
69
70     }
71
72     public void undo(HashMap JavaDoc context) {
73         JBIDescriptor descriptor = (JBIDescriptor) context
74                 .get(DeploymentContextConstants.SA_DESCRIPTOR);
75
76         try {
77             managerService.unregisterServiceAssembly(DeploymentUtils
78                     .getServiceAssemblyName(descriptor));
79         } catch (ManagementException e) {
80             String JavaDoc msg = "Failed to revert a SALifeCycleRegistrationTask";
81             log.error(msg, e);
82         }
83     }
84
85 }
86
Popular Tags