KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > phasing > DeploymentService


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.deployment.phasing;
25
26 import java.io.File JavaDoc;
27 import java.util.Map JavaDoc;
28
29 import com.sun.enterprise.config.ConfigContext;
30 import com.sun.enterprise.deployment.backend.DeploymentRequest;
31 import com.sun.enterprise.deployment.util.DeploymentProperties;
32 import com.sun.enterprise.deployment.backend.DeploymentStatus;
33 import com.sun.enterprise.deployment.backend.IASDeploymentException;
34 import com.sun.enterprise.deployment.pluggable.DeploymentFactory;
35 import com.sun.enterprise.server.ApplicationServer;
36 import com.sun.enterprise.server.pluggable.PluggableFeatureFactory;
37 import com.sun.enterprise.management.deploy.DeploymentCallback;
38
39 /**
40  * Manages the phases and maps deployment operations to deployment phases
41  * @author deployment dev team
42  */

43 public abstract class DeploymentService {
44
45     private static DeploymentService deployService;
46
47     /**
48      * This is a singleton factory for the DeploymentService implementation. We should revisit
49      * this to make sure this will work in multi-threaded environment, i.e. concurrent deployment.
50      */

51     public static DeploymentService getDeploymentService(
52             ConfigContext configContext) {
53
54         if (deployService != null) {
55             return deployService;
56         }
57
58         PluggableFeatureFactory featureFactory =
59             ApplicationServer.getServerContext().getPluggableFeatureFactory();
60         DeploymentFactory dFactory = featureFactory.getDeploymentFactory();
61         deployService = dFactory.createDeploymentService(configContext);
62         return deployService;
63     }
64
65     public static DeploymentService getDeploymentService() {
66         ConfigContext configContext =
67             DeploymentServiceUtils.getConfigContext();
68         return DeploymentService.getDeploymentService(configContext);
69     }
70
71
72     /**
73      * This method deploys application. Prepares the app, stores it in
74      * central repository and registers with config
75      * @param req DeploymentRequest object
76      */

77     public abstract DeploymentStatus deploy(DeploymentRequest req) throws IASDeploymentException;
78     
79     /**
80      * This method deploys application. Prepares the app, stores it in
81      * It constructs the DeploymentRequest using the parameters first.
82      */

83     public abstract DeploymentStatus deploy(File JavaDoc deployFile,
84         File JavaDoc planFile, String JavaDoc archiveName, String JavaDoc moduleID,
85         DeploymentProperties dProps, DeploymentCallback callback)
86         throws IASDeploymentException;
87
88     /**
89      * This method undeploys application. Removes the application from
90      * central repository and unregisters the application from config
91      * @param req DeploymentRequest object
92      */

93     public abstract DeploymentStatus undeploy(DeploymentRequest req);
94     
95     /**
96      * This method undeploys application. Removes the application from
97      * It constructs the DeploymentRequest using the parameters first.
98      */

99     public abstract DeploymentStatus undeploy(String JavaDoc mModuleID,
100         Map JavaDoc mParams) throws IASDeploymentException;
101
102     /**
103      * This method is used to associate an application to a target.
104      * @param req DeploymentRequest object
105      */

106     public abstract DeploymentStatus associate(DeploymentRequest req)
107         throws IASDeploymentException;
108
109     /**
110      * This method is used to associate an application to a target.
111      * It constructs the DeploymentRequest using the parameters first.
112      */

113     public abstract DeploymentStatus associate(String JavaDoc targetName,
114         boolean enabled, String JavaDoc virtualServers, String JavaDoc referenceName)
115         throws IASDeploymentException;
116     
117     /**
118      * This method is used to associate an application to a target.
119      * It constructs the DeploymentRequest using the parameters first.
120      */

121     public abstract DeploymentStatus associate(String JavaDoc targetName,
122         String JavaDoc referenceName, Map JavaDoc options) throws IASDeploymentException;
123
124     /**
125      * This method removes references of an application on a particular target
126      * @param req DeploymentRequest object
127      */

128     public abstract DeploymentStatus disassociate(DeploymentRequest req)
129         throws IASDeploymentException;
130
131    /**
132      * This method removes references of an application on a particular target
133      * It constructs the DeploymentRequest using the parameters first.
134      */

135     public abstract DeploymentStatus disassociate(String JavaDoc targetName,
136         String JavaDoc referenceName) throws IASDeploymentException;
137
138     public abstract DeploymentStatus disassociate(String JavaDoc targetName,
139         String JavaDoc referenceName, Map JavaDoc options) throws IASDeploymentException;
140
141     public abstract DeploymentStatus start(DeploymentRequest req);
142     
143     public abstract DeploymentStatus stop(DeploymentRequest req)
144         throws IASDeploymentException;
145
146     public abstract DeploymentStatus start(String JavaDoc moduleID, String JavaDoc targetName,
147         Map JavaDoc options) throws IASDeploymentException;
148
149     public abstract DeploymentStatus stop(String JavaDoc moduleID, String JavaDoc targetName,
150         Map JavaDoc options) throws IASDeploymentException;
151
152     public abstract boolean quit(String JavaDoc moduleID);
153
154     /**
155      * This method finds moduleID by explicitly loading the dd for its
156      * display name.
157      * This method is called by the DeployThread if and only if the client
158      * did not provide a moduleID. This is only true when a client is using
159      * JSR88.distribute with InputStream signature.
160      * @@ todo: Ideally we do not want to load the deployment descriptor
161      * more than once. This one is a necessary evil since we need the
162      * moduleID *now* before proceeding with the rest of deployment.
163      * Bigger re-construction is needed if we want to optimize deployment
164      * further for JSR88 using InputStream.
165      * NOTE that we choose to load the dd and use the display name as
166      * the moduleID instead of the uploaded file name for backward
167      * compatibility and clarity (uploaded file name is not descriptive).
168      * @param file the deployed file
169      * @return the moduleID derived from this file using the dd's display name
170      */

171     public abstract String JavaDoc getModuleIDFromDD (File JavaDoc file) throws Exception JavaDoc;
172 }
173
Popular Tags