KickJava   Java API By Example, From Geeks To Geeks.

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


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 /*
25  * DeploymentTargetFactoryPEImpl.java
26  *
27  * Created on June 22, 2003, 7:57 PM
28  * @author sandhyae
29  * <BR> <I>$Source: /cvs/glassfish/appserv-core/src/java/com/sun/enterprise/deployment/phasing/DeploymentTargetFactoryPEImpl.java,v $
30  *
31  */

32
33 package com.sun.enterprise.deployment.phasing;
34
35 import com.sun.enterprise.config.ConfigContext;
36 import com.sun.enterprise.deployment.backend.IASDeploymentException;
37
38 import com.sun.enterprise.admin.target.TargetBuilder;
39 import com.sun.enterprise.admin.target.Target;
40 import com.sun.enterprise.admin.target.TargetType;
41
42 /**
43  * Target factory used for PE case. In case target name is domain a GroupDeploymentTarget
44  * that acts as an aggregation of servers in the domain is returned.
45  * @author Sandhya E
46  *
47  * Changed by Sridatta for bug fix: 4932179
48  * Target is always ServerDeploymentTarget for PE. There is always only 1 instance
49  * in PE. Changing the implementation to reflect this.
50  */

51 //FIXTHIS: Question. Does this really need to be made pluggable? Everywhere else
52
//(i.e. config and resource operations) we allow all possible targets in both PE, SE, EE.
53
//This would clean this up alot. Currently we need pluggability so that we can
54
//create a subclass of ServerDeploymentTarget (which attempts to shuttle bits).
55
public class DeploymentTargetFactoryPEImpl extends DeploymentTargetFactory {
56         
57     private static final TargetType[] VALID_DEPLOYMENT_TYPES = new TargetType[] {TargetType.DAS};
58     
59     /**
60      * Creates a new instance of DeploymentTargetFactoryPEImpl
61      */

62     public DeploymentTargetFactoryPEImpl() {}
63
64     /**
65      * @return valid deployment target types for this target factory
66      */

67     public TargetType[] getValidDeploymentTargetTypes() {
68         return this.VALID_DEPLOYMENT_TYPES;
69     }
70     
71     /**
72      * Returns the Deployment target for the targetName. If targetName is default_target "domain" then a
73      * GroupDeploymentTarget representing a collection of all servers in this domain is returned.
74      * This method is called from Association/DisassociationPhase
75      * and Start/StopPhase. For PE, when no target name is specified in the deployment commands
76      * association/disassociation/start/stop need to execute for all servers.
77      * @param configContext
78      * @param targetName name of the target
79      * @return DeploymentTarget representing the targetName [ GroupDeploymentTarget is targetName == "domain"]
80      * @throws IASDeploymentException
81      */

82     public DeploymentTarget getTarget(ConfigContext configContext, String JavaDoc domainName, String JavaDoc targetName) throws IASDeploymentException
83     {
84         try{
85             //parse the given target and ensure that it is a valid server instance. Server instance
86
//is the only valid target type for PE.
87
final Target target = TargetBuilder.INSTANCE.createTarget(VALID_DEPLOYMENT_TYPES,
88                 targetName, configContext);
89             if (targetName == null) {
90                 targetName = target.getName();
91             }
92             return new ServerDeploymentTarget(configContext , domainName, targetName);
93         } catch(Throwable JavaDoc t){
94             throw new IASDeploymentException("Error:" + t.getMessage(), t);
95         }
96     }
97
98     /**
99      * Returns the default target. Used incase when deployment command doesnt
100      * get the target name from user
101      * @param configContext config context
102      * @return DeploymentTarget
103      * @throws IASDeploymentException
104      */

105     public DeploymentTarget getTarget(ConfigContext configContext, String JavaDoc domainName) throws IASDeploymentException
106     {
107         return getTarget(configContext, domainName, null);
108     }
109     
110 }
111
Popular Tags