KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > tests > j2eeserver > plugin > jsr88 > ProgObject


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.tests.j2eeserver.plugin.jsr88;
21
22 import javax.enterprise.deploy.spi.*;
23 import javax.enterprise.deploy.shared.*;
24 import javax.enterprise.deploy.model.*;
25 import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException JavaDoc;
26 import javax.enterprise.deploy.spi.status.*;
27 import org.netbeans.modules.j2ee.deployment.plugins.api.ServerProgress;
28 import javax.enterprise.deploy.shared.*;
29
30 import java.io.*;
31 import java.util.*;
32
33 /**
34  *
35  * @author gfink
36  * @author nn136682
37  */

38 public class ProgObject extends ServerProgress {
39
40     private TargetModuleID[] tmIDs;
41     
42     public ProgObject(DeploymentManager dm, Target[] targets, File archive, Object JavaDoc plan) {
43         this(dm, createTargetModuleIDs(targets, archive));
44     }
45
46     public ProgObject(DeploymentManager dm, Target[] targets, Object JavaDoc archive, Object JavaDoc plan) {
47         this(dm, new TargetModuleID[0]);
48     }
49     
50     public ProgObject(DeploymentManager dm, TargetModuleID[] modules) {
51         super(dm);
52         tmIDs = modules;
53     }
54     
55     public static TargetModuleID[] createTargetModuleIDs(Target[] targets, File archive) {
56         TargetModuleID [] ret = new TargetModuleID[targets.length];
57         for (int i=0; i<ret.length; i++) {
58             ret[i] = new TestTargetMoid(targets[i], archive.getName(), getType(archive.getName()));
59             ((Targ)targets[i]).add(ret[i]);
60         }
61         return ret;
62     }
63     static ModuleType getType(String JavaDoc name) {
64         if (name.endsWith(".ear")) return ModuleType.EAR;
65         else if (name.endsWith(".jar")) return ModuleType.EJB; //PENDING: libraries and client
66
else if (name.endsWith(".war")) return ModuleType.WAR;
67         else if (name.endsWith(".rar")) return ModuleType.RAR;
68         else throw new IllegalArgumentException JavaDoc("Invalid archive name: " + name);
69     }
70     public void setStatusDistributeRunning(String JavaDoc message) {
71         notify(createRunningProgressEvent(CommandType.DISTRIBUTE, message));
72     }
73     public void setStatusDistributeFailed(String JavaDoc message) {
74         notify(createFailedProgressEvent(CommandType.DISTRIBUTE, message));
75     }
76     public void setStatusDistributeCompleted(String JavaDoc message) {
77         notify(createCompletedProgressEvent(CommandType.DISTRIBUTE, message));
78     }
79
80     public void setStatusRedeployRunning(String JavaDoc message) {
81         notify(createRunningProgressEvent(CommandType.REDEPLOY, message));
82     }
83     public void setStatusRedeployFailed(String JavaDoc message) {
84         notify(createFailedProgressEvent(CommandType.REDEPLOY, message));
85     }
86     public void setStatusRedeployCompleted(String JavaDoc message) {
87         notify(createCompletedProgressEvent(CommandType.REDEPLOY, message));
88     }
89
90     public void cancel() throws OperationUnsupportedException JavaDoc {
91         throw new OperationUnsupportedException JavaDoc("Test plugin does not support cancel!");
92     }
93     
94     public void stop() throws OperationUnsupportedException JavaDoc {
95         throw new OperationUnsupportedException JavaDoc("Test plugin does not support stop!");
96     }
97     
98     public boolean isCancelSupported() {
99         return false; // PENDING parameterize?
100
}
101     
102     public boolean isStopSupported() {
103         return false; // PENDING see above
104
}
105     
106     public ClientConfiguration getClientConfiguration(TargetModuleID targetModuleID) {
107         return null; // PENDING client support
108
}
109     
110     public DeploymentStatus getDeploymentStatus() {
111         return super.getDeploymentStatus();
112     }
113     
114     public TargetModuleID[] getResultTargetModuleIDs() {
115         List ret = new Vector();
116         for (int i=0; i<tmIDs.length; i++) {
117             if (tmIDs[i].getChildTargetModuleID() != null)
118                 ret.addAll(Arrays.asList(tmIDs[i].getChildTargetModuleID()));
119             ret.add(tmIDs[i]);
120         }
121         return (TargetModuleID[]) ret.toArray(new TargetModuleID[ret.size()]);
122     }
123 }
124
Popular Tags