KickJava   Java API By Example, From Geeks To Geeks.

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


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 com.sun.enterprise.deployment.backend.DeploymentStatus;
27 import com.sun.enterprise.deployment.backend.DeploymentRequest;
28 import com.sun.enterprise.deployment.backend.DeploymentLogger;
29 import com.sun.enterprise.deployment.backend.DeploymentEventInfo;
30 import com.sun.enterprise.deployment.backend.DeploymentEvent;
31 import com.sun.enterprise.deployment.backend.DeploymentEventType;
32 import com.sun.enterprise.deployment.backend.IASDeploymentException;
33 import com.sun.enterprise.deployment.util.DeploymentProperties;
34
35 import com.sun.enterprise.resource.Resource;
36 import com.sun.enterprise.resource.ResourcesXMLParser;
37 import com.sun.enterprise.util.i18n.StringManager;
38
39 import java.util.List JavaDoc;
40 import java.util.ArrayList JavaDoc;
41 import java.util.logging.Level JavaDoc;
42 import java.util.logging.Logger JavaDoc;
43
44 /**
45  * This class manages the creation of the resources from
46  * sun-resource.xml that need to created after resource adapter loading
47  */

48 public class PostResCreationPhase extends ResourcePhase {
49
50     /** Deployment Logger object for this class */
51     public static final Logger sLogger = DeploymentLogger.get();
52     
53     /** string manager */
54     private static StringManager localStrings =
55         StringManager.getManager(PostResCreationPhase.class);
56    
57     /**
58      * Creates a new instance of PostResCreationPhase
59      * @param deploymentCtx context object for the deployment
60      */

61     public PostResCreationPhase(DeploymentContext deploymentCtx)
62     {
63         this.deploymentCtx = deploymentCtx;
64         this.name = POST_RES_CREATION;
65     }
66
67     /**
68      * Phase specific execution logic will go in this method.
69      * Any phase implementing
70      * this class will provide its implementation for this method.
71      * @param req Deployment request object
72      * @param phaseCtx the DeploymentPhaseContext object
73      */

74     public void runPhase(DeploymentPhaseContext phaseCtx)
75     {
76         try {
77             DeploymentRequest req = phaseCtx.getDeploymentRequest();
78                                                                       
79             prePhaseNotify(getPrePhaseEvent(req));
80             doResourceOperation(req);
81             postPhaseNotify(getPostPhaseEvent(req));
82                                                                       
83             phaseCtx.getDeploymentStatus().setStageStatus(DeploymentStatus.SUCCESS);
84         } catch(Exception JavaDoc e) {
85             // add rollback logic
86
phaseCtx.getDeploymentStatus().setStageStatus(DeploymentStatus.WARNING);
87             if (e.getCause()!=null) {
88                 phaseCtx.getDeploymentStatus().setStageStatusMessage(e.getCause().getMessage());
89             }
90         }
91     }
92
93    /**
94      * Event that will be broadcasted at the start of the phase
95      * @param req Deployment request object
96      * @return DeploymentEvent
97      */

98     private DeploymentEvent getPrePhaseEvent(DeploymentRequest req)
99     {
100         return new DeploymentEvent(DeploymentEventType.PRE_RES_CREATE, new DeploymentEventInfo(req));
101     }
102                                                                       
103     /**
104      * Event that will be broadcasted at the end of the phase
105      * @return DeploymentEvent
106      */

107     private DeploymentEvent getPostPhaseEvent(DeploymentRequest req) {
108         return new DeploymentEvent(DeploymentEventType.POST_RES_CREATE, new DeploymentEventInfo(req));
109     }
110
111     // redeployment for resource creation phase is same as deployment
112
public void handleRedeployment(List JavaDoc<String JavaDoc> targetList,
113         List JavaDoc<Resource> resourceList) throws Exception JavaDoc {
114         handleDeployment(targetList, resourceList);
115     }
116                                                                       
117     public List JavaDoc<Resource> getRelevantResources(List JavaDoc<Resource> allResources) {
118         return ResourcesXMLParser.getConnectorResourcesList(allResources, true);
119     }
120 }
121
Popular Tags