KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > j2ee > J2EELogicalServerImplBase


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 package com.sun.enterprise.management.j2ee;
24
25 import java.util.Map JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import java.io.Serializable JavaDoc;
28
29 import javax.management.ObjectName JavaDoc;
30 import javax.management.AttributeNotFoundException JavaDoc;
31
32 import com.sun.appserv.management.deploy.DeploymentStatus;
33 import com.sun.appserv.management.deploy.DeploymentSupport;
34
35 import com.sun.appserv.management.util.misc.TypeCast;
36
37 import com.sun.appserv.management.j2ee.J2EELogicalServer;
38 import com.sun.appserv.management.j2ee.J2EETypes;
39
40 import com.sun.enterprise.management.support.Delegate;
41 import com.sun.enterprise.management.support.oldconfig.OldApplicationsConfigMBean;
42
43 /**
44     Base interface only (for cluster and standalone server)
45  */

46 public class J2EELogicalServerImplBase
47     extends J2EEManagedObjectImplBase
48 {
49         public
50     J2EELogicalServerImplBase(
51         final Delegate delegate)
52     {
53         super( delegate );
54     }
55
56         protected
57     J2EELogicalServerImplBase( String JavaDoc j2eeType, Delegate delegate )
58     {
59         super( j2eeType, delegate );
60     }
61
62         public int
63     getstate()
64     {
65         throw new RuntimeException JavaDoc( new AttributeNotFoundException JavaDoc( "state" ) );
66     }
67     
68         public void
69     start()
70     {
71         throw new RuntimeException JavaDoc( "can't start" );
72     }
73     
74         public void
75     startRecursive()
76     {
77         throw new RuntimeException JavaDoc( "can't startRecursive" );
78     }
79     
80         public void
81     stop()
82     {
83         throw new RuntimeException JavaDoc( "can't stop" );
84     }
85
86     /**
87      * starts the app
88      */

89         public void
90     startApp(String JavaDoc appID, Map JavaDoc<String JavaDoc,Serializable JavaDoc> optional)
91     {
92         final OldApplicationsConfigMBean oldApplicationsMBean =
93             getOldConfigProxies().getOldApplicationsConfigMBean();
94
95         final Map JavaDoc<String JavaDoc,Serializable JavaDoc> m = TypeCast.asMap(
96             oldApplicationsMBean.startAndReturnStatusAsMap( appID, getSelfName(), optional ) );
97         checkDeploymentStatusForExceptions( m );
98     }
99     /**
100      * stops the app
101      */

102         public void
103     stopApp(String JavaDoc appID, Map JavaDoc<String JavaDoc,Serializable JavaDoc> optional)
104     {
105         final OldApplicationsConfigMBean oldApplicationsMBean =
106             getOldConfigProxies().getOldApplicationsConfigMBean();
107
108         final Map JavaDoc<String JavaDoc,Serializable JavaDoc> m = TypeCast.asMap(
109             oldApplicationsMBean.stopAndReturnStatusAsMap( appID, getSelfName(), optional ) );
110         
111         checkDeploymentStatusForExceptions( m );
112     }
113     /**
114      * Checks the DeploymentStatus and all substages.
115      *
116      * Can't depend on SUCCESS or FAILURE as the backend.DeploymentStatus sets
117      * the stageStatus to its own codes. Cannot import backend.DeploymentStatus
118      * to translate the codes.
119      */

120         private void
121     checkDeploymentStatusForExceptions( Map JavaDoc<String JavaDoc,Serializable JavaDoc > m )
122     {
123         DeploymentStatus status = DeploymentSupport.mapToDeploymentStatus( m );
124         
125         Throwable JavaDoc t = status.getStageThrowable();
126         
127         final Iterator JavaDoc<DeploymentStatus> it = status.getSubStagesList().iterator();
128         while ( ( t == null ) && ( it.hasNext() ) )
129         {
130             final DeploymentStatus m1 = it.next();
131             t = status.getThrowable();
132         }
133         if ( null != t )
134         {
135             throw new RuntimeException JavaDoc( status.getStageStatusMessage() );
136         }
137     }
138
139 }
140
141
Popular Tags