Source Code Cross Referenced for SunDeploymentManager.java in  » IDE-Netbeans » j2ee » org » netbeans » modules » j2ee » sun » ide » dm » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » j2ee » org.netbeans.modules.j2ee.sun.ide.dm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        // <editor-fold defaultstate="collapsed" desc=" License Header ">
0002:        /*
0003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0004:         *
0005:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0006:         *
0007:         * The contents of this file are subject to the terms of either the GNU
0008:         * General Public License Version 2 only ("GPL") or the Common
0009:         * Development and Distribution License("CDDL") (collectively, the
0010:         * "License"). You may not use this file except in compliance with the
0011:         * License. You can obtain a copy of the License at
0012:         * http://www.netbeans.org/cddl-gplv2.html
0013:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0014:         * specific language governing permissions and limitations under the
0015:         * License.  When distributing the software, include this License Header
0016:         * Notice in each file and include the License file at
0017:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
0018:         * particular file as subject to the "Classpath" exception as provided
0019:         * by Sun in the GPL Version 2 section of the License file that
0020:         * accompanied this code. If applicable, add the following below the
0021:         * License Header, with the fields enclosed by brackets [] replaced by
0022:         * your own identifying information:
0023:         * "Portions Copyrighted [year] [name of copyright owner]"
0024:         *
0025:         * Contributor(s):
0026:         *
0027:         * The Original Software is NetBeans. The Initial Developer of the Original
0028:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
0029:         * Microsystems, Inc. All Rights Reserved.
0030:         *
0031:         * If you wish your version of this file to be governed by only the CDDL
0032:         * or only the GPL Version 2, indicate your decision by adding
0033:         * "[Contributor] elects to include this software in this distribution
0034:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
0035:         * single choice of license, a recipient has the option to distribute
0036:         * your version of this file under either the CDDL, the GPL Version 2 or
0037:         * to extend the choice of license to its licensees as provided above.
0038:         * However, if you add GPL Version 2 code and therefore, elected the GPL
0039:         * Version 2 license, then the option applies only if the new code is
0040:         * made subject to such option by the copyright holder.
0041:         */
0042:        // </editor-fold>
0043:        package org.netbeans.modules.j2ee.sun.ide.dm;
0044:
0045:        import java.beans.PropertyChangeListener;
0046:        import java.beans.PropertyChangeSupport;
0047:        import java.io.File;
0048:        import java.io.FileInputStream;
0049:        import java.io.IOException;
0050:        import java.io.InputStream;
0051:        import java.io.OutputStream;
0052:        import java.net.Authenticator;
0053:        import java.util.ArrayList;
0054:        import java.util.Collections;
0055:        import java.util.Locale;
0056:        import java.net.InetAddress;
0057:        import java.rmi.RemoteException;
0058:        import java.rmi.ServerException;
0059:        import java.lang.reflect.Method;
0060:        import java.util.Map;
0061:        import java.util.ResourceBundle;
0062:        import java.util.concurrent.atomic.AtomicBoolean;
0063:        import javax.enterprise.deploy.model.DeployableObject;
0064:        import javax.enterprise.deploy.shared.ActionType;
0065:        import javax.enterprise.deploy.shared.CommandType;
0066:        import javax.enterprise.deploy.shared.StateType;
0067:        import javax.enterprise.deploy.spi.Target;
0068:        import javax.enterprise.deploy.spi.TargetModuleID;
0069:        import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException;
0070:        import javax.enterprise.deploy.spi.status.ClientConfiguration;
0071:        import javax.enterprise.deploy.spi.status.ProgressObject;
0072:        import javax.enterprise.deploy.spi.status.ProgressListener;
0073:        import javax.enterprise.deploy.spi.status.ProgressEvent;
0074:        import javax.enterprise.deploy.spi.status.DeploymentStatus;
0075:        import javax.enterprise.deploy.shared.DConfigBeanVersionType;
0076:        import javax.enterprise.deploy.spi.exceptions.DConfigBeanVersionUnsupportedException;
0077:        import javax.enterprise.deploy.spi.DeploymentManager;
0078:        import javax.enterprise.deploy.spi.DeploymentConfiguration;
0079:        import javax.enterprise.deploy.shared.ModuleType;
0080:        import javax.enterprise.deploy.spi.exceptions.TargetException;
0081:        import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
0082:        import javax.enterprise.deploy.spi.factories.DeploymentFactory;
0083:        import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
0084:        import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
0085:        import org.netbeans.modules.j2ee.sun.api.SunURIManager;
0086:        import org.netbeans.modules.j2ee.sun.appsrvapi.PortDetector;
0087:        import org.netbeans.modules.j2ee.sun.ide.editors.AdminAuthenticator;
0088:        import org.netbeans.modules.j2ee.sun.ide.j2ee.DeploymentManagerProperties;
0089:        import org.netbeans.modules.j2ee.sun.ide.j2ee.ProgressEventSupport;
0090:        import org.netbeans.modules.j2ee.sun.ide.j2ee.runtime.actions.ViewLogAction;
0091:
0092:        import org.netbeans.modules.j2ee.sun.share.configbean.SunONEDeploymentConfiguration;
0093:
0094:        import org.netbeans.modules.j2ee.sun.ide.j2ee.mbmapping.JvmOptions;
0095:        import org.netbeans.modules.j2ee.sun.ide.j2ee.mbmapping.ServerInfo;
0096:
0097:        import java.util.jar.JarOutputStream;
0098:        import java.io.FileOutputStream;
0099:        import java.util.HashMap;
0100:        import org.netbeans.modules.j2ee.sun.share.plan.Util;
0101:
0102:        import org.netbeans.modules.j2ee.sun.ide.j2ee.Utils;
0103:
0104:        import org.netbeans.modules.j2ee.sun.api.ServerInterface;
0105:        import org.netbeans.modules.j2ee.sun.api.SunDeploymentManagerInterface;
0106:        import org.netbeans.modules.j2ee.sun.api.ResourceConfiguratorInterface;
0107:        import java.util.Properties;
0108:        import java.util.logging.Level;
0109:        import java.util.logging.Logger;
0110:        import org.netbeans.modules.j2ee.sun.api.CmpMappingProvider;
0111:        import org.openide.DialogDescriptor;
0112:        import org.openide.DialogDisplayer;
0113:
0114:        import org.openide.ErrorManager;
0115:        import org.netbeans.modules.j2ee.sun.api.ServerLocationManager;
0116:        import org.netbeans.modules.j2ee.sun.ide.j2ee.DomainEditor;
0117:        import org.openide.filesystems.FileLock;
0118:        import org.openide.filesystems.FileObject;
0119:        import org.openide.filesystems.FileUtil;
0120:        import org.openide.util.NbBundle;
0121:        import org.openide.util.RequestProcessor;
0122:
0123:        /**
0124:         *
0125:         * @author  ludo, vkraemer
0126:         */
0127:        public class SunDeploymentManager implements  Constants,
0128:                DeploymentManager, SunDeploymentManagerInterface {
0129:
0130:            private PropertyChangeSupport propertySupport;
0131:            private DeploymentManager innerDM;
0132:            private DeploymentFactory df;
0133:            private String host, userName, password;
0134:            private String uri;
0135:            private boolean isConnected;
0136:            /* map that give a password for a given uri
0137:             **/
0138:            private static Map passwordForURI = Collections
0139:                    .synchronizedMap((Map) new HashMap(2, 1));
0140:
0141:            /* port is the admin port number, ususally 4848*/
0142:
0143:            int adminPortNumber;
0144:            /* httpport is the non admin port number, usually 8080*/
0145:            String nonAdminPortNumber = null; //null, is unknown at this point, will be calculated when is running
0146:
0147:            private static String SECURESTRINGDETECTION = ":https";
0148:            /*
0149:             *flag to see of the secure (SSL) testing on the running server has been done or not
0150:             * this is to avoid too many checks that would cause perf issues
0151:             **/
0152:            private transient boolean secureStatusHasBeenChecked = false;
0153:            private boolean runningState = false;
0154:            private boolean secure = false;
0155:            private boolean goodUserNamePassword = false;
0156:            private boolean maybeRunningButWrongUserName = false;
0157:            private long timeStampCheckingRunning = 0;
0158:            private File platformRoot = null;
0159:            private String domainDir = null;
0160:            private boolean driversdeployed = false;
0161:
0162:            /* cache for local value. Sometimes, the islocal() call can be very long for IP that changed
0163:             * usually when dhcp is used. So we calculate the value in a thread at construct time
0164:             * init value is false, but updated later within a thread.
0165:             **/
0166:            private boolean isLocal = false;
0167:            /* used by a netbeans extension to associatate a StartServer with this DM
0168:             */
0169:            static final ResourceBundle bundle = ResourceBundle
0170:                    .getBundle("org.netbeans.modules.j2ee.sun.ide.dm.Bundle");// NOI18N
0171:
0172:            // This code allows the extra classes missing from the 8.x appserv-cmp.jar to be
0173:            // loaded from the copy in the appsrvbridge module.  If this code were not here, 
0174:            // netbeans rules of one jar per package would prevent those classes from being
0175:            // found.
0176:            static {
0177:                String packageWorkaroundPropName = "org.netbeans.core.startup.specialResource"; // NOI18N
0178:                String existingSysProp = System
0179:                        .getProperty(packageWorkaroundPropName);
0180:                String extraPackageName = "com.sun.jdo.api.persistence.mapping.ejb"; // NOI18N
0181:                if (existingSysProp != null) {
0182:                    existingSysProp += ',';
0183:                }
0184:                existingSysProp += extraPackageName;
0185:                System.setProperty(packageWorkaroundPropName, existingSysProp);
0186:            }
0187:
0188:            /* this is interesting: JMXREMOTE APIs create a factory and load it from the getContext classloader
0189:             * which is a NetBeans class loader that does not know about our App Server Dynamic jars class loader.
0190:             * So we need to hack on the fly the context classloader with the plugin classloader for any jxm calls
0191:             * done in the app server jsr 88 impl!!!
0192:             * this ClassLoader origClassLoader is used to stored the original CL so that NB is happy after a jsr88 call.
0193:             **/
0194:
0195:            public SunDeploymentManager(DeploymentFactory df, String uri,
0196:                    String userName, String password, File platformRootDir)
0197:                    throws DeploymentManagerCreationException {
0198:                propertySupport = new PropertyChangeSupport(this );
0199:                this .df = df;
0200:                this .uri = uri;
0201:                this .platformRoot = platformRootDir;
0202:                secure = uri.endsWith(SECURESTRINGDETECTION);
0203:                String uriNonSecure = uri;
0204:                if (secure) {
0205:                    uriNonSecure = uri.substring(0, uri.length()
0206:                            - SECURESTRINGDETECTION.length());
0207:                }
0208:                host = getHostFromURI(uriNonSecure);
0209:                adminPortNumber = getPortFromURI(uriNonSecure);
0210:                try {
0211:                    InstanceProperties props = SunURIManager
0212:                            .getInstanceProperties(platformRoot, host,
0213:                                    adminPortNumber);
0214:
0215:                    if (userName == null && props != null) {
0216:                        this .userName = props
0217:                                .getProperty(InstanceProperties.USERNAME_ATTR);
0218:                    } else {
0219:                        this .userName = userName;
0220:                    }
0221:                    if (password == null && props != null) {
0222:                        this .password = props
0223:                                .getProperty(InstanceProperties.PASSWORD_ATTR);
0224:                    } else {
0225:                        this .password = password;
0226:                    }
0227:                    if (!"".equals(this .password)) {
0228:                        passwordForURI.put(uri + platformRoot, this .password);
0229:                    } else {
0230:                        this .password = (String) passwordForURI.get(uri
0231:                                + platformRoot);
0232:                        if (this .password == null) {
0233:                            this .password = "";
0234:                        }
0235:
0236:                    }
0237:
0238:                    isConnected = this .userName != null;
0239:                } catch (IllegalStateException ise) {
0240:                    // get before set throws an ISE.  Instance registration time
0241:                    // triggers this
0242:                    ErrorManager.getDefault().notify(
0243:                            ErrorManager.INFORMATIONAL, ise);
0244:                }
0245:                resetInnerDeploymentManager();
0246:                calculateIsLocal();
0247:            }
0248:
0249:            /* return the real dm created from the app server implementation of 88, not our wrapper (ie. not this class
0250:             **
0251:             */
0252:
0253:            private void resetInnerDeploymentManager()
0254:                    throws DeploymentManagerCreationException {
0255:                try {
0256:                    if (isConnected) {
0257:                        if (df != null) {
0258:                            innerDM = df.getDeploymentManager(uri, userName,
0259:                                    password);
0260:                        }
0261:                    } else {
0262:                        if (df != null) {
0263:                            innerDM = df.getDisconnectedDeploymentManager(uri);
0264:                        }
0265:                    }
0266:                    ////////            if(innerDM == null) {
0267:                    ////////                throw new DeploymentManagerCreationException("invalid URI");
0268:                    ////////            }
0269:                } catch (NoClassDefFoundError ee) {
0270:                    throw ee;
0271:                } catch (Exception e) {
0272:                    e.printStackTrace();
0273:                    throw new DeploymentManagerCreationException(
0274:                            "DeploymentManagerCreationException"
0275:                                    + e.getMessage());
0276:                }
0277:                if (secure) {
0278:                    // different classloader!  AppServerBridge.setServerConnectionEnvironment(innerDM);
0279:                    try {
0280:                        Class[] argClass = new Class[1];
0281:                        argClass[0] = DeploymentManager.class;
0282:                        Object[] argObject = new Object[1];
0283:                        argObject[0] = innerDM;
0284:
0285:                        ClassLoader loader = getExtendedClassLoader();
0286:                        if (loader != null) {
0287:                            Class cc = loader
0288:                                    .loadClass("org.netbeans.modules.j2ee.sun.bridge.AppServerBridge");
0289:                            Method setServerConnectionEnvironment = cc
0290:                                    .getMethod(
0291:                                            "setServerConnectionEnvironment",
0292:                                            argClass);//NOI18N
0293:                            setServerConnectionEnvironment.invoke(null,
0294:                                    argObject);
0295:                        }
0296:                    } catch (Exception ex) {
0297:                        //Suppressing exception while trying to obtain admin host port value
0298:                        ex.printStackTrace();
0299:                    }
0300:                }
0301:
0302:            }
0303:
0304:            public String getUserName() {
0305:                InstanceProperties props = SunURIManager.getInstanceProperties(
0306:                        platformRoot, host, adminPortNumber);
0307:                if (null != props) {
0308:                    this .userName = props
0309:                            .getProperty(InstanceProperties.USERNAME_ATTR);
0310:                }
0311:                return userName;
0312:            }
0313:
0314:            public String getPassword() {
0315:                InstanceProperties props = SunURIManager.getInstanceProperties(
0316:                        platformRoot, host, adminPortNumber);
0317:                if (null != props) {
0318:                    this .password = props
0319:                            .getProperty(InstanceProperties.PASSWORD_ATTR);
0320:                }
0321:                if (password.equals("")) {//it means we did not stored the password. Get it from the static in memory cache if available
0322:                    password = (String) passwordForURI.get(uri + platformRoot);
0323:                    if (this .password == null) {
0324:                        this .password = "";
0325:                    }
0326:
0327:                }
0328:                return password;
0329:            }
0330:
0331:            public String getHost() {
0332:                return host;
0333:            }
0334:
0335:            public int getPort() {
0336:                return adminPortNumber;
0337:            }
0338:
0339:            /*
0340:             * return the real http port for the server. Usually, it is "8080", or null if the server is not running
0341:             *
0342:             **/
0343:            public String getNonAdminPortNumber() {
0344:                return nonAdminPortNumber;
0345:            }
0346:
0347:            /*
0348:             *
0349:             *return true is this  deploymment manager needs a restart, because of changes in admin configuration
0350:             */
0351:            synchronized public boolean isRestartNeeded() {
0352:                if (secureStatusHasBeenChecked == false) {
0353:                    return false;
0354:                }
0355:
0356:                if (goodUserNamePassword == false) {
0357:                    return false;
0358:                }
0359:                if (isRunning() == false) {
0360:                    return false;
0361:                }
0362:                if (driversdeployed == true) {
0363:                    setRestartForDriverDeployment(false);
0364:                    return true;
0365:                }
0366:
0367:                boolean retVal;
0368:                try {
0369:                    ServerInfo si = new ServerInfo(getMBeanServerConnection());
0370:                    retVal = si.isRestartRequired();
0371:                } catch (java.rmi.RemoteException e) {
0372:                    retVal = false;//silent assumption: server mgiht not even be running!
0373:                }
0374:                return retVal;
0375:            }
0376:
0377:            public void fixJVMDebugOptions() throws java.rmi.RemoteException {
0378:                JvmOptions jvmInfo = new JvmOptions(getMBeanServerConnection());
0379:                //String addr=
0380:                jvmInfo.getAddressValue();
0381:                if (jvmInfo.isWindows()) {
0382:                    if (jvmInfo.isSharedMemory() == false) {//force shmem on windows system!!!
0383:                        jvmInfo.setDefaultTransportForDebug(getHost()
0384:                                + getPort());
0385:                    }
0386:                }
0387:            }
0388:
0389:            String lastAddress = null;
0390:
0391:            public String getDebugAddressValue()
0392:                    throws java.rmi.RemoteException {
0393:                String retVal = lastAddress;
0394:                JvmOptions jvmInfo = null;
0395:                try {
0396:                    jvmInfo = new JvmOptions(getMBeanServerConnection());
0397:                    retVal = jvmInfo.getAddressValue();
0398:                    lastAddress = retVal;
0399:                } catch (java.rmi.RemoteException re) {
0400:                    if (null == lastAddress) {
0401:                        throw re;
0402:                    }
0403:
0404:                }
0405:                return retVal;
0406:            }
0407:
0408:            boolean lastIsSharedMem = false;
0409:
0410:            public boolean isDebugSharedMemory()
0411:                    throws java.rmi.RemoteException {
0412:                if (!isLocal()) {
0413:                    return false;
0414:                }
0415:                boolean retVal = lastIsSharedMem;
0416:                JvmOptions jvmInfo = null;
0417:                try {
0418:                    jvmInfo = new JvmOptions(getMBeanServerConnection());
0419:                    retVal = jvmInfo.isSharedMemory();
0420:                    lastIsSharedMem = retVal;
0421:                } catch (java.rmi.RemoteException re) {
0422:                    ErrorManager.getDefault().notify(
0423:                            ErrorManager.INFORMATIONAL, re);
0424:                } catch (Exception e) {
0425:                    ErrorManager.getDefault().notify(
0426:                            ErrorManager.INFORMATIONAL, e);
0427:                }
0428:                return retVal;
0429:
0430:            }
0431:
0432:            //   public String getDebugAddressValue() throws java.rmi.RemoteException{
0433:            //       JvmOptions jvmInfo = new JvmOptions(getMBeanServerConnection());
0434:            //        return jvmInfo.getAddressValue();
0435:            //
0436:            //   }
0437:            //   public boolean isDebugSharedMemory() throws java.rmi.RemoteException{
0438:            //        JvmOptions jvmInfo = new JvmOptions(getMBeanServerConnection());
0439:            //        return  jvmInfo.isSharedMemory();
0440:            //
0441:            //
0442:            //   }
0443:            public DeploymentConfiguration createConfiguration(
0444:                    DeployableObject dObj)
0445:                    throws javax.enterprise.deploy.spi.exceptions.InvalidModuleException {
0446:                return new SunONEDeploymentConfiguration(dObj/*, this*/);
0447:                //    return innerDM.createConfiguration(dObj);
0448:            }
0449:
0450:            File getInternalPlanFile(InputStream plan)
0451:                    throws IllegalStateException {
0452:                JarOutputStream jar = null;
0453:                //        InputStream innerPlan = null;
0454:
0455:                try {
0456:                    File tmpFile = File.createTempFile("dplan", "tmp");
0457:                    jar = new JarOutputStream(new FileOutputStream(tmpFile));
0458:                    Util.convert(plan, jar);
0459:                    jar.close();
0460:                    jar = null;
0461:                    tmpFile.deleteOnExit();
0462:                    return tmpFile;
0463:                } catch (java.io.IOException ioe) {
0464:                    IllegalStateException ise = new IllegalStateException(
0465:                            "file handling issues");
0466:                    ise.initCause(ioe);
0467:                    throw ise;
0468:                } finally {
0469:                    if (jar != null) {
0470:                        try {
0471:                            jar.close();
0472:                        } catch (Throwable t) {
0473:                            jsr88Logger.severe("bad one");
0474:                        }
0475:                    }
0476:                }
0477:            }
0478:
0479:            //    // TODO remove once https://glassfish.dev.java.net/issues/show_bug.cgi?id=601601 is not an issue...
0480:            //    // after 8.1, 8.2, and 9.0 PE are no loger supported.
0481:            //    //
0482:            //    private static ProgressObject tempDirFailureObject =
0483:            //            new ShortCircuitProgressObject(CommandType.DISTRIBUTE,
0484:            //            NbBundle.getMessage(SunDeploymentManager.class,"ERR_BAD_TEMP_DIR"),
0485:            //            StateType.FAILED,new TargetModuleID[0]);
0486:            //
0487:            //    private boolean badTempDir() {
0488:            //        if (!Utilities.isWindows()) {
0489:            //            return false;
0490:            //        } else {
0491:            //            // TODO perform the real test here!
0492:            //            return false;
0493:            //        }
0494:            //    }
0495:            //    // end remove after https://glassfish.dev.java.net/issues/show_bug.cgi?id=601 resolved
0496:
0497:            public ProgressObject distribute(Target[] target,
0498:                    InputStream archive, InputStream plan)
0499:                    throws IllegalStateException {
0500:                InputStream innerPlan = null;
0501:                //System.out.println("distribute.");
0502:                ThrowExceptionIfSuspended();
0503:                //  getStartServerInterface().viewLogFile();
0504:                ViewLogAction.viewLog(this );
0505:
0506:                ClassLoader origClassLoader = Thread.currentThread()
0507:                        .getContextClassLoader();
0508:                try {
0509:                    // do a stream distribute
0510:                    //  1. convert the plan into a zip file based plan
0511:                    //
0512:                    final File f = getInternalPlanFile(plan);
0513:                    innerPlan = new FileInputStream(f);
0514:                    //
0515:                    //  2. call the inner DeploymentManager.distribute method
0516:                    //
0517:                    ProgressObject retVal;
0518:                    //            if (badTempDir()) {
0519:                    //                retVal = tempDirFailureObject;
0520:                    //            } else {
0521:                    Thread
0522:                            .currentThread()
0523:                            .setContextClassLoader(
0524:                                    ServerLocationManager
0525:                                            .getServerOnlyClassLoader(getPlatformRoot()));
0526:                    retVal = innerDM.distribute(target, archive, innerPlan);
0527:                    retVal.addProgressListener(new FileDeleter(f));
0528:                    //            }
0529:                    return retVal;
0530:
0531:                } catch (IllegalStateException ise) {
0532:                    throw ise;
0533:                } catch (java.io.IOException ioe) {
0534:                    IllegalStateException ise = new IllegalStateException(
0535:                            "file handling issues");
0536:                    ise.initCause(ioe);
0537:                    throw ise;
0538:                } finally {
0539:                    Thread.currentThread().setContextClassLoader(
0540:                            origClassLoader);
0541:                    if (null != innerPlan) {
0542:                        try {
0543:                            innerPlan.close();
0544:                        } catch (Throwable t) {
0545:                            jsr88Logger.severe("bad two");
0546:                        }
0547:                    }
0548:                }
0549:            }
0550:
0551:            public ProgressObject distribute(Target[] target,
0552:                    ModuleType moduleType, InputStream inputStream,
0553:                    InputStream inputStream0) throws IllegalStateException {
0554:                return distribute(target, inputStream, inputStream0);
0555:            }
0556:
0557:            public ProgressObject distribute(Target[] target, File archive,
0558:                    File plan) throws IllegalStateException {
0559:                ThrowExceptionIfSuspended();
0560:
0561:                File[] resourceDirs = Utils.getResourceDirs(archive);
0562:                if (resourceDirs != null) {
0563:                    Utils.registerResources(resourceDirs,
0564:                            (ServerInterface) getManagement());
0565:                }
0566:
0567:                ClassLoader origClassLoader = Thread.currentThread()
0568:                        .getContextClassLoader();
0569:                try {
0570:                    Thread
0571:                            .currentThread()
0572:                            .setContextClassLoader(
0573:                                    ServerLocationManager
0574:                                            .getServerOnlyClassLoader(getPlatformRoot()));
0575:                    //  getStartServerInterface().viewLogFile();
0576:                    ViewLogAction.viewLog(this );
0577:                    //            if (badTempDir()) {
0578:                    //                return tempDirFailureObject;
0579:                    //            }
0580:                    return innerDM.distribute(target, archive, null);
0581:                    // return distribute(target, a, p);
0582:                    //}
0583:                } catch (/*java.io.FileNotFoundException*/Exception fnfe) {
0584:                    IllegalStateException ise = new IllegalStateException();
0585:                    ise.initCause(fnfe);
0586:                    throw ise;
0587:                } finally {
0588:                    Thread.currentThread().setContextClassLoader(
0589:                            origClassLoader);
0590:                }
0591:
0592:            }
0593:
0594:            public TargetModuleID[] getAvailableModules(ModuleType modType,
0595:                    Target[] target) throws TargetException,
0596:                    IllegalStateException {
0597:
0598:                try {
0599:                    ThrowExceptionIfSuspended();
0600:                } catch (RuntimeException re) {
0601:                    return new TargetModuleID[0];
0602:                }
0603:                ClassLoader origClassLoader = Thread.currentThread()
0604:                        .getContextClassLoader();
0605:                Thread.currentThread().setContextClassLoader(
0606:                        ServerLocationManager
0607:                                .getServerOnlyClassLoader(getPlatformRoot()));
0608:
0609:                try {
0610:                    try {
0611:                        grabInnerDM(false);
0612:                        TargetModuleID[] tm = innerDM.getAvailableModules(
0613:                                modType, target);
0614:                        /*     	System.out.println("in getAvailableModules "+modType);
0615:                                 for(int i = 0; i < target.length; i++) {
0616:                                        System.out.println("Target is "+i+" "+target[i]);
0617:                                 }
0618:                                for(int j = 0; j < tm.length; j++) {
0619:                                        System.out.println("TargetModuleID is "+j+" "+tm[j]);
0620:                                 }
0621:                         */
0622:                        return tm;
0623:                    } finally {
0624:                        releaseInnerDM();
0625:                    }
0626:                } finally {
0627:                    Thread.currentThread().setContextClassLoader(
0628:                            origClassLoader);
0629:                }
0630:            }
0631:
0632:            public Locale getCurrentLocale() {//TODO change the classloader there also!!! Ludo
0633:                //  System.out.println("getCurrentLocale.");
0634:                ThrowExceptionIfSuspended();
0635:                return innerDM.getCurrentLocale();
0636:            }
0637:
0638:            public DConfigBeanVersionType getDConfigBeanVersion() {//TODO change the classloader there also!!! Ludo
0639:                //System.out.println("getDConfigBeanVersion.");
0640:                ThrowExceptionIfSuspended();
0641:                return innerDM.getDConfigBeanVersion();
0642:            }
0643:
0644:            public Locale getDefaultLocale() {
0645:                //System.out.println("getDefaultLocale.");
0646:                ThrowExceptionIfSuspended();
0647:                return innerDM.getDefaultLocale();
0648:            }
0649:
0650:            public TargetModuleID[] getNonRunningModules(ModuleType mType,
0651:                    Target[] target) throws TargetException,
0652:                    IllegalStateException {
0653:                //System.out.println("getNonRunningModules.");
0654:                ThrowExceptionIfSuspended();
0655:                return innerDM.getNonRunningModules(mType, target);
0656:            }
0657:
0658:            public TargetModuleID[] getRunningModules(ModuleType mType,
0659:                    Target[] target) throws TargetException,
0660:                    IllegalStateException {
0661:                ClassLoader origClassLoader = Thread.currentThread()
0662:                        .getContextClassLoader();
0663:                Thread.currentThread().setContextClassLoader(
0664:                        ServerLocationManager
0665:                                .getServerOnlyClassLoader(getPlatformRoot()));
0666:                try {
0667:                    try {
0668:                        grabInnerDM(false);
0669:                        TargetModuleID[] ttt = innerDM.getRunningModules(mType,
0670:                                target);
0671:                        return ttt;
0672:                    } finally {
0673:                        releaseInnerDM();
0674:                    }
0675:                } finally {
0676:                    Thread.currentThread().setContextClassLoader(
0677:                            origClassLoader);
0678:                }
0679:
0680:            }
0681:
0682:            public Locale[] getSupportedLocales() {
0683:                //System.out.println("getSupportedLocales.");
0684:                ThrowExceptionIfSuspended();
0685:                return innerDM.getSupportedLocales();
0686:            }
0687:
0688:            synchronized public Target[] getTargets()
0689:                    throws IllegalStateException {
0690:                try {
0691:                    ThrowExceptionIfSuspended();
0692:                } catch (Exception ex) {
0693:                    return new Target[0];
0694:                }
0695:                Target[] retVal = null;
0696:                if (secureStatusHasBeenChecked == false) { //unknown status. no targets.
0697:                    retVal = null;
0698:                } else {
0699:                    // VBK Hack for getting the configuration editing to in the origClassLoader
0700:                    // J2EE 1.4 RI beta 1 deploytool to appear. It required this call to
0701:                    // return at least 1 target in the return value.
0702:                    if (null == innerDM) {
0703:                        retVal = new Target[1];
0704:                        retVal[0] = new FakeTarget();
0705:                        //            return retVal;
0706:                    } else {
0707:                        try {
0708:                            grabInnerDM(false);
0709:                            if (null == domainDir) {
0710:                                DeploymentManagerProperties dmProps = new DeploymentManagerProperties(
0711:                                        this );
0712:                                domainDir = dmProps.getLocation();
0713:                                if ("".equals(domainDir)) {
0714:                                    isLocal = false;
0715:                                }
0716:                                String domainName = dmProps.getDomainName();
0717:                                domainDir += File.separator + domainName;
0718:                                domainDir = new File(domainDir)
0719:                                        .getCanonicalPath();
0720:                            }
0721:                            if (isLocal()) {// if the server is local, make sure we are talking to the correct one
0722:                                //we do that by testing the server location known by the IDE with the server location known by the
0723:                                // server
0724:
0725:                                try {
0726:                                    Object configDir = getManagement()
0727:                                            .invoke(
0728:                                                    new javax.management.ObjectName(
0729:                                                            "com.sun.appserv:type=domain,category=config"),
0730:                                                    "getConfigDir", null, null);
0731:                                    if (configDir == null) {
0732:                                        mmm = null;
0733:                                        return null;
0734:                                    }
0735:                                    String dir = configDir.toString();
0736:                                    File domainLocationAsReturnedByTheServer = new File(
0737:                                            dir).getParentFile();
0738:
0739:                                    String l1 = domainLocationAsReturnedByTheServer
0740:                                            .getCanonicalPath();
0741:
0742:                                    if (l1.equals(domainDir) == false) { //not the same location, so let's make sure we do not return an invalid target
0743:
0744:                                        return null;
0745:                                    }
0746:                                } catch (java.rmi.RemoteException ee) {
0747:                                    return null;//cannot talk to the admin server->not running well
0748:                                } catch (Throwable ee) {
0749:                                    ErrorManager.getDefault().notify(
0750:                                            ErrorManager.INFORMATIONAL, ee);
0751:                                    return null;//cannot talk to the admin server->not running well
0752:                                }
0753:                            }
0754:                            ClassLoader origClassLoader = Thread
0755:                                    .currentThread().getContextClassLoader();
0756:                            try {
0757:                                Thread
0758:                                        .currentThread()
0759:                                        .setContextClassLoader(
0760:                                                ServerLocationManager
0761:                                                        .getServerOnlyClassLoader(getPlatformRoot()));
0762:                                retVal = innerDM.getTargets();
0763:                            } catch (IllegalStateException ise) {
0764:                                retVal = new Target[0];
0765:                                //	throw ise;
0766:                            } finally {
0767:                                Thread.currentThread().setContextClassLoader(
0768:                                        origClassLoader);
0769:
0770:                            }
0771:                        } catch (IOException ioe) {
0772:                            Logger.getLogger(
0773:                                    SunDeploymentManager.class.getName()).log(
0774:                                    Level.FINER, null, ioe);
0775:                        } finally {
0776:                            releaseInnerDM();
0777:                        }
0778:                    }
0779:                }
0780:
0781:                // help prevent running into GF issue 3693
0782:                //
0783:                // By returning a single target, we prevent the j2eeserver layer from 
0784:                // deciding that the IDE needs to use archive deployment.  If the IDE 
0785:                // uses JSR 88 API's to deploy to GF, the call to dm.start() will 
0786:                // cause problems.
0787:                // 
0788:                // If the plugin needs to support multiple targets, this will need
0789:                // to be revisited.
0790:                //
0791:                if (null != retVal && retVal.length > 1) {
0792:                    return new Target[] { retVal[0] };
0793:                }
0794:                return retVal;
0795:            }
0796:
0797:            public boolean isDConfigBeanVersionSupported(
0798:                    DConfigBeanVersionType vers) {
0799:                //System.out.println("isDConfigBeanVersionSupported.");
0800:                ThrowExceptionIfSuspended();
0801:                return innerDM.isDConfigBeanVersionSupported(vers);
0802:            }
0803:
0804:            public boolean isLocaleSupported(Locale locale) {
0805:                //System.out.println("isLocaleSupported.");
0806:                ThrowExceptionIfSuspended();
0807:                return innerDM.isLocaleSupported(locale);
0808:            }
0809:
0810:            public boolean isRedeploySupported() {
0811:                //System.out.println("isRedeploySupported.");
0812:                ThrowExceptionIfSuspended();
0813:                return innerDM.isRedeploySupported();
0814:            }
0815:
0816:            public ProgressObject redeploy(TargetModuleID[] targetModuleID,
0817:                    InputStream archive, InputStream plan)
0818:                    throws UnsupportedOperationException, IllegalStateException {
0819:                //System.out.println("redeploy.");
0820:                ThrowExceptionIfSuspended();
0821:
0822:                InputStream innerPlan = null;
0823:                //     getStartServerInterface().viewLogFile();
0824:                ViewLogAction.viewLog(this );
0825:
0826:                ClassLoader origClassLoader = Thread.currentThread()
0827:                        .getContextClassLoader();
0828:                try {
0829:                    Thread
0830:                            .currentThread()
0831:                            .setContextClassLoader(
0832:                                    ServerLocationManager
0833:                                            .getServerOnlyClassLoader(getPlatformRoot()));
0834:                    //        File f = getInternalPlanFile(plan);
0835:                    //        innerPlan = new FileInputStream(f);
0836:                    grabInnerDM(false);
0837:                    ProgressObject retVal = innerDM.redeploy(targetModuleID,
0838:                            archive, innerPlan);
0839:                    if (null != retVal) {
0840:                        retVal.addProgressListener(new ReleaseInnerDMPL(Thread
0841:                                .currentThread()));
0842:                    }
0843:                    return retVal;
0844:                } catch (IllegalStateException ise) {
0845:                    releaseInnerDM();
0846:                    throw ise;
0847:                } catch (Exception ioe) {
0848:                    IllegalStateException ise = new IllegalStateException(
0849:                            "file handling issues");
0850:                    ise.initCause(ioe);
0851:                    releaseInnerDM();
0852:                    throw ise;
0853:                } finally {
0854:                    Thread.currentThread().setContextClassLoader(
0855:                            origClassLoader);
0856:                    if (null != innerPlan) {
0857:                        try {
0858:                            innerPlan.close();
0859:                        } catch (Throwable t) {
0860:                            t.printStackTrace();
0861:                            jsr88Logger.severe("bad two");
0862:                        }
0863:                    }
0864:                }
0865:            }
0866:
0867:            public ProgressObject redeploy(TargetModuleID[] targetModuleID,
0868:                    File archive, File plan)
0869:                    throws UnsupportedOperationException, IllegalStateException {
0870:                ThrowExceptionIfSuspended();
0871:
0872:                File[] resourceDirs = Utils.getResourceDirs(archive);
0873:                if (resourceDirs != null) {
0874:                    Utils.registerResources(resourceDirs,
0875:                            (ServerInterface) getManagement());
0876:                }
0877:
0878:                ViewLogAction.viewLog(this );
0879:
0880:                ClassLoader origClassLoader = Thread.currentThread()
0881:                        .getContextClassLoader();
0882:                Thread.currentThread().setContextClassLoader(
0883:                        ServerLocationManager
0884:                                .getServerOnlyClassLoader(getPlatformRoot()));
0885:                try {
0886:                    grabInnerDM(false);
0887:                    ProgressObject retVal = innerDM.redeploy(targetModuleID,
0888:                            archive, null);
0889:                    if (null != retVal) {
0890:                        retVal.addProgressListener(new ReleaseInnerDMPL(Thread
0891:                                .currentThread()));
0892:                    }
0893:                    return retVal;
0894:                } catch (IllegalStateException ise) {
0895:                    releaseInnerDM();
0896:                    throw ise;
0897:                } finally {
0898:                    Thread.currentThread().setContextClassLoader(
0899:                            origClassLoader);
0900:                }
0901:            }
0902:
0903:            public void release() {
0904:                //System.out.println("release.");
0905:                /* try{
0906:                     innerDM.release();
0907:                 }catch (Exception  e){
0908:                     //npe there f called 2 times in a row from studio...
0909:                     //need to talk to Nam
0910:                 }*/
0911:
0912:            }
0913:
0914:            public void setDConfigBeanVersion(DConfigBeanVersionType versionType)
0915:                    throws DConfigBeanVersionUnsupportedException {
0916:                // System.out.println("setDConfigBeanVersion.");
0917:                ThrowExceptionIfSuspended();
0918:                innerDM.setDConfigBeanVersion(versionType);
0919:            }
0920:
0921:            public void setLocale(Locale locale)
0922:                    throws UnsupportedOperationException {
0923:                // System.out.println("setLocale.");
0924:                ThrowExceptionIfSuspended();
0925:                innerDM.setLocale(locale);
0926:            }
0927:
0928:            public ProgressObject start(TargetModuleID[] targetModuleID)
0929:                    throws IllegalStateException {
0930:                ThrowExceptionIfSuspended();
0931:                ClassLoader origClassLoader = Thread.currentThread()
0932:                        .getContextClassLoader();
0933:                Thread.currentThread().setContextClassLoader(
0934:                        ServerLocationManager
0935:                                .getServerOnlyClassLoader(getPlatformRoot()));
0936:                try {
0937:                    // need to weed list of targetModules -- no app clients!
0938:                    // see https://glassfish.dev.java.net/issues/show_bug.cgi?id=641
0939:                    TargetModuleID[] weeded = weedOutAppClientTMID(targetModuleID);
0940:                    ProgressObject retVal = null;
0941:                    if (weeded.length < 1) {
0942:                        retVal = new ShortCircuitProgressObject(
0943:                                CommandType.START, NbBundle.getMessage(
0944:                                        SunDeploymentManager.class,
0945:                                        "MESS_STARTED"), StateType.COMPLETED,
0946:                                targetModuleID);
0947:                    } else {
0948:                        retVal = innerDM.start(weeded);
0949:                    }
0950:                    return retVal;
0951:                } finally {
0952:                    Thread.currentThread().setContextClassLoader(
0953:                            origClassLoader);
0954:                }
0955:            }
0956:
0957:            public ProgressObject stop(TargetModuleID[] targetModuleID)
0958:                    throws IllegalStateException {
0959:                ThrowExceptionIfSuspended();
0960:                ClassLoader origClassLoader = Thread.currentThread()
0961:                        .getContextClassLoader();
0962:                Thread.currentThread().setContextClassLoader(
0963:                        ServerLocationManager
0964:                                .getServerOnlyClassLoader(getPlatformRoot()));
0965:                try {
0966:                    // need to weed list of targetModules -- no app clients!
0967:                    // see https://glassfish.dev.java.net/issues/show_bug.cgi?id=641
0968:                    TargetModuleID[] weeded = weedOutAppClientTMID(targetModuleID);
0969:                    ProgressObject retVal = null;
0970:                    if (weeded.length < 1) {
0971:                        retVal = new ShortCircuitProgressObject(
0972:                                CommandType.STOP, NbBundle.getMessage(
0973:                                        SunDeploymentManager.class,
0974:                                        "MESS_STOPPED"), StateType.COMPLETED,
0975:                                targetModuleID);
0976:                    } else {
0977:                        retVal = innerDM.stop(weeded);
0978:                    }
0979:                    return retVal;
0980:                } finally {
0981:                    Thread.currentThread().setContextClassLoader(
0982:                            origClassLoader);
0983:                }
0984:            }
0985:
0986:            // TODO : remove this method when GFV2/SJSAS9.1 is the "legacy" version 
0987:            // for the plugin.
0988:            private TargetModuleID[] weedOutAppClientTMID(TargetModuleID[] tmids) {
0989:                // the server team resolved 641 and also 3248 in v2... but since we
0990:                // allow users to work with older server versions, we have to dance here.
0991:                if (ServerLocationManager
0992:                        .getAppServerPlatformVersion(platformRoot) > ServerLocationManager.GF_V1) {
0993:                    return tmids;
0994:                }
0995:                ArrayList<TargetModuleID> retList = new ArrayList<TargetModuleID>();
0996:                try {
0997:                    Class[] argClass = new Class[1];
0998:                    argClass[0] = TargetModuleID.class;
0999:                    Object[] argObject = new Object[1];
1000:
1001:                    ClassLoader loader = getExtendedClassLoader();
1002:                    if (loader != null) {
1003:                        Class cc = loader
1004:                                .loadClass("org.netbeans.modules.j2ee.sun.bridge.AppServerBridge");
1005:                        Method isCar = cc.getMethod("isCar", argClass);//NOI18N
1006:                        for (TargetModuleID tmid : tmids) {
1007:                            argObject[0] = tmid;
1008:                            boolean doNotAddToRetList = ((Boolean) isCar
1009:                                    .invoke(null, argObject)).booleanValue();
1010:                            if (!doNotAddToRetList) {
1011:                                retList.add(tmid);
1012:                            }
1013:                        }
1014:                    }
1015:                } catch (Exception ex) {
1016:                    //Suppressing exception while trying to obtain admin host port value
1017:                    ErrorManager.getDefault().notify(
1018:                            ErrorManager.INFORMATIONAL, ex);
1019:                }
1020:                return retList.toArray(new TargetModuleID[retList.size()]);
1021:            }
1022:
1023:            public ProgressObject undeploy(TargetModuleID[] targetModuleID)
1024:                    throws IllegalStateException {
1025:                // System.out.println("undeploy.");
1026:                ThrowExceptionIfSuspended();
1027:                ClassLoader origClassLoader = Thread.currentThread()
1028:                        .getContextClassLoader();
1029:                Thread.currentThread().setContextClassLoader(
1030:                        ServerLocationManager
1031:                                .getServerOnlyClassLoader(getPlatformRoot()));
1032:
1033:                ProgressObject retVal = null;
1034:                try {
1035:                    grabInnerDM(false);
1036:                    retVal = innerDM.undeploy(targetModuleID);
1037:                    if (null != retVal) {
1038:                        retVal.addProgressListener(new ReleaseInnerDMPL(Thread
1039:                                .currentThread()));
1040:                    }
1041:                    return retVal;
1042:                }
1043:
1044:                finally {
1045:                    if (null == retVal) {
1046:                        releaseInnerDM();
1047:                    }
1048:                    Thread.currentThread().setContextClassLoader(
1049:                            origClassLoader);
1050:
1051:                }
1052:            }
1053:
1054:            private void calculateIsLocal() {
1055:                boolean isset = false;
1056:                InstanceProperties ip = SunURIManager.getInstanceProperties(
1057:                        getPlatformRoot(), getHost(), getPort());
1058:                if (ip != null) { //Null is a possible returned value there...
1059:                    Object domainDir = ip.getProperty("LOCATION");
1060:                    if (null != domainDir) {
1061:                        isLocal = true;
1062:                        isset = true;
1063:                    }
1064:                    if ("".equals(domainDir)) {
1065:                        isLocal = false;
1066:                        isset = true; // this may be redundant
1067:                    }
1068:                }
1069:                if (!isset) {
1070:                    if (getHost().equals("localhost")) {
1071:                        isLocal = true;
1072:                    } else {
1073:                        try {
1074:                            new Thread() {
1075:                                public void run() {
1076:                                    try {
1077:                                        String ia = InetAddress.getByName(
1078:                                                getHost()).getHostAddress();
1079:                                        if (ia.equals("127.0.0.1")) {//NOI18N
1080:                                            isLocal = true;
1081:                                        } else {
1082:                                            String localCanonName = InetAddress
1083:                                                    .getLocalHost()
1084:                                                    .getCanonicalHostName();
1085:                                            String currentCanonName = InetAddress
1086:                                                    .getByName(getHost())
1087:                                                    .getCanonicalHostName();
1088:
1089:                                            isLocal = (localCanonName
1090:                                                    .equals(currentCanonName)) ? true
1091:                                                    : false;
1092:                                        }
1093:                                    } catch (Exception e) {
1094:                                        // e.printStackTrace();
1095:                                        jsr88Logger.severe(e.getMessage());
1096:                                    }
1097:                                }
1098:                            }.start();
1099:
1100:                        } catch (Throwable t) {
1101:                            // t.printStackTrace(); wll default to false.
1102:                            return;
1103:                        }
1104:                    }
1105:                }
1106:            }
1107:
1108:            /* return true if the server instance is locale
1109:             **/
1110:            public boolean isLocal() {
1111:
1112:                return isLocal; //the cached value
1113:
1114:            }
1115:
1116:            //  return LOCALHOST.equals(getHost());
1117:
1118:            /* return the status of an instance.
1119:             * It is optimized to return the previous status if called more than twice within
1120:             * a 5 seconds intervall
1121:             * This boosts IDE reactivity
1122:             */
1123:            public synchronized boolean isRunning() {
1124:                return isRunning(false);
1125:
1126:            }
1127:
1128:            /* return the status of an instance.
1129:             * when not forced, It is optimized to return the previous status if called more than twice within
1130:             * a 4 seconds intervall
1131:             * This boosts IDE reactivity
1132:             */
1133:            public boolean isRunning(boolean forced) {
1134:
1135:                boolean retVal = false;
1136:
1137:                if (isSuspended()) {
1138:                    retVal = true;
1139:                } else {
1140:
1141:                    //            if (secureStatusHasBeenChecked==false){
1142:                    //
1143:                    //            }
1144:                    //         if (secureStatusHasBeenChecked&& (goodUserNamePassword==false)){
1145:                    //            System.out.println("ISRUNNING TRUE BUT!!!!WRONG U PA: REFRESH THE NODe Please") ;
1146:                    //            return true;
1147:                    //            }
1148:
1149:                    long current = System.currentTimeMillis();
1150:                    //  System.out.println("in in running call"+ (current-timeStampCheckingRunning));
1151:                    if (forced == false
1152:                            && current - timeStampCheckingRunning < 4000) {
1153:                        //  System.out.println("Cached in in running call");
1154:                        //timeStampCheckingRunning = current;
1155:                        retVal = runningState;
1156:
1157:                    } else {
1158:                        boolean newrunningState = false;
1159:                        timeStampCheckingRunning = current;
1160:
1161:                        try {
1162:                            ThrowExceptionIfSuspended();
1163:
1164:                            Target[] t = getTargets();
1165:                            if (t != null) {
1166:                                if (t.length == 0)
1167:                                    newrunningState = false;
1168:                                else
1169:
1170:                                    newrunningState = true;
1171:                            }
1172:
1173:                            //System.out.println("isRunning" +runningState);
1174:                        } catch (Throwable /*IllegalStateException*/e) {
1175:                            newrunningState = false;
1176:                            //System.out.println(" bisRunning" +runningState);
1177:                        }
1178:                        runningState = newrunningState;
1179:                        if ((runningState) && (nonAdminPortNumber == null)) {
1180:                            try {
1181:                                //  System.out.println("inrunning get admin port number"+(System.currentTimeMillis()-current));
1182:                                nonAdminPortNumber = (String) getManagement()
1183:                                        .getAttribute(
1184:                                                new javax.management.ObjectName(
1185:                                                        "com.sun.appserv:type=http-listener,id=http-listener-1,config=server-config,category=config"),
1186:                                                "port");
1187:                                //  sharedMemoryName = getDebugAddressValueReal();
1188:                                // fix the null http port setting... in the ant properties file.
1189:                                Runnable t = new Runnable() {
1190:                                    public void run() {
1191:                                        try {
1192:                                            storeAntDeploymentProperties(
1193:                                                    getAntDeploymentPropertiesFile(),
1194:                                                    true);
1195:                                        } catch (IOException ioe) {
1196:                                            // what can I do here
1197:                                            ErrorManager.getDefault().notify(
1198:                                                    ErrorManager.INFORMATIONAL,
1199:                                                    ioe);
1200:                                        }
1201:
1202:                                    }
1203:
1204:                                };
1205:                                RequestProcessor.getDefault().post(t);
1206:                            } catch (Throwable /*IllegalStateException*/ee) {
1207:                                ee.printStackTrace();
1208:                            }
1209:                        }
1210:                        timeStampCheckingRunning = System.currentTimeMillis();
1211:                        //        System.out.println("startinsruning"+(timeStampCheckingRunning-current));
1212:
1213:                        retVal = runningState;
1214:                    }
1215:                }
1216:                return retVal;
1217:            }
1218:
1219:            synchronized public void ThrowExceptionIfSuspended() {
1220:
1221:                /* this is called before any remote call, so it's a good place to do this extra check about being secure of not For EE version
1222:                 ** and accordingly set the environment correctly */
1223:
1224:                if (secureStatusHasBeenChecked == false) {
1225:                    // long current=System.currentTimeMillis();
1226:                    mmm = null;
1227:                    try {
1228:                        secure = PortDetector
1229:                                .isSecurePort(getHost(), getPort());
1230:
1231:                        if (secure == true) {
1232:                            if (!uri.endsWith(SECURESTRINGDETECTION)) {
1233:                                uri = uri + SECURESTRINGDETECTION;//make it secure and reset the inner one
1234:                            }
1235:                            resetInnerDeploymentManager();
1236:                            //System.out.println("Setting as Secure!!!!!");
1237:
1238:                        }
1239:                        //System.out.println("secure="+secure);
1240:                        secureStatusHasBeenChecked = true;// check done!!!
1241:
1242:                        //  now we know if we are secure or not, we can check is the username passowrd is good:
1243:                        testCredentials();
1244:
1245:                    } catch (Exception e) {
1246:                        //Cannot detect if it's secure of not yet..
1247:                        // could be IOException, ConnectException, SocketTimeoutException
1248:                        //  System.out.println("timeout "+( System.currentTimeMillis()-current));
1249:                        //  System.out.println("caanot check secure");
1250:                        secureStatusHasBeenChecked = false;
1251:                        //System.out.println("could be IOException, ConnectException, SocketTimeoutException");
1252:                        //e.printStackTrace();
1253:                    }
1254:                }
1255:                if (isSuspended()) {
1256:
1257:                    //System.out.println("CANNOT DO A remote operation  WHILE STOPPED IN A BREAK POINT IN DEBUG MODE...");
1258:                    throw new RuntimeException(bundle
1259:                            .getString("MSG_ServerInDebug"));
1260:                }
1261:                if (secureStatusHasBeenChecked
1262:                        && (goodUserNamePassword == false)) {
1263:                    throw new RuntimeException(bundle
1264:                            .getString("MSG_WRONG_UserPassword"));
1265:                }
1266:
1267:            }
1268:
1269:            /**
1270:             * Returns true if this server is started in debug mode AND debugger is attached to it
1271:             * AND threads are suspended (e.g. debugger stopped on breakpoint)
1272:             */
1273:            public boolean isSuspended() {
1274:                return org.netbeans.modules.j2ee.sun.ide.j2ee.StartSunServer
1275:                        .isSuspended(this );
1276:            }
1277:
1278:            private ServerInterface mmm = null;
1279:
1280:            public ServerInterface getManagement() {
1281:                if (mmm == null) {
1282:
1283:                    try {
1284:                        Class[] argClass = new Class[1];
1285:                        argClass[0] = javax.enterprise.deploy.spi.DeploymentManager.class;
1286:                        Object[] argObject = new Object[1];
1287:                        argObject[0] = this ;
1288:
1289:                        ClassLoader loader = getExtendedClassLoader();
1290:                        if (loader != null) {
1291:                            Class cc = loader
1292:                                    .loadClass("org.netbeans.modules.j2ee.sun.share.management.ServerMEJB");
1293:                            mmm = (ServerInterface) cc.newInstance();
1294:                            mmm.setDeploymentManager(this );
1295:                        }
1296:                    } catch (Exception ex) {
1297:                        mmm = null;
1298:                        //Suppressing exception while trying to obtain admin host port value
1299:                        ex.printStackTrace();
1300:                    }
1301:
1302:                }
1303:                return mmm;
1304:            }
1305:
1306:            public void testCredentials() {
1307:
1308:                Authenticator.setDefault(new AdminAuthenticator(this ));
1309:
1310:                goodUserNamePassword = false;
1311:                maybeRunningButWrongUserName = false;
1312:                try {
1313:                    Class[] argClass = new Class[1];
1314:                    argClass[0] = javax.enterprise.deploy.spi.DeploymentManager.class;
1315:                    Object[] argObject = new Object[1];
1316:                    argObject[0] = this ;
1317:
1318:                    ClassLoader loader = getExtendedClassLoader();
1319:                    if (loader != null) {
1320:                        Class cc = loader
1321:                                .loadClass("org.netbeans.modules.j2ee.sun.share.management.ServerMEJB");
1322:                        ServerInterface si;
1323:
1324:                        si = (ServerInterface) cc.newInstance();
1325:                        si.setDeploymentManager(this );
1326:                        si.checkCredentials();
1327:                        goodUserNamePassword = true;
1328:                    }
1329:
1330:                } catch (ClassNotFoundException ex) {
1331:                    goodUserNamePassword = false;
1332:                } catch (InstantiationException ex) {
1333:                    goodUserNamePassword = false;
1334:                } catch (IllegalAccessException ex) {
1335:                    goodUserNamePassword = false;
1336:                } catch (IOException e) {
1337:                    if (!e.getMessage().contains("500")) {//not an internal error, so user/password error!!!
1338:                        maybeRunningButWrongUserName = true;
1339:                    }
1340:
1341:                    String serverTitle = getInstanceDisplayName();
1342:                    DialogDescriptor desc = new DialogDescriptor(
1343:                            NbBundle
1344:                                    .getMessage(
1345:                                            SunDeploymentManager.class,
1346:                                            "ERR_AUTH_DIALOG_MSG",
1347:                                            new Object[] {
1348:                                                    ((serverTitle != null) ? serverTitle
1349:                                                            : // NOI18N
1350:                                                            NbBundle
1351:                                                                    .getMessage(
1352:                                                                            SunDeploymentManager.class,
1353:                                                                            "WORD_SERVER")), // NOI18N
1354:                                                    stripSlashHtmlAndNewlines(e
1355:                                                            .getLocalizedMessage()) }),
1356:                            NbBundle.getMessage(SunDeploymentManager.class,
1357:                                    "ERR_AUTH_DIALOG_TITLE")); //NOI18N
1358:                    desc.setModal(false);
1359:                    desc.setMessageType(DialogDescriptor.ERROR_MESSAGE);
1360:                    desc
1361:                            .setOptions(new Object[] { DialogDescriptor.OK_OPTION });
1362:                    desc.setOptionsAlign(DialogDescriptor.BOTTOM_ALIGN);
1363:                    DialogDisplayer.getDefault().notify(desc);
1364:                }
1365:
1366:            }
1367:
1368:            /** take the </html> off the end of a string.
1369:             *  makes it easier to embed the strings in a string with 
1370:             * markup safely
1371:             */
1372:            private String stripSlashHtmlAndNewlines(String input) {
1373:                String retVal = null;
1374:                int dex = input.toLowerCase(Locale.ENGLISH).lastIndexOf(
1375:                        "</html>");
1376:                if (dex > -1) {
1377:                    retVal = input.substring(0, dex);
1378:                } else {
1379:                    retVal = input;
1380:                }
1381:                return retVal.replaceAll("\n", " ");
1382:            }
1383:
1384:            private String getInstanceDisplayName() {
1385:                InstanceProperties ip = SunURIManager.getInstanceProperties(
1386:                        getPlatformRoot(), getHost(), getPort());
1387:                return (ip != null) ? ip
1388:                        .getProperty(InstanceProperties.DISPLAY_NAME_ATTR)
1389:                        : null;
1390:            }
1391:
1392:            private ResourceConfiguratorInterface resourceConfigurator = null;
1393:
1394:            public ResourceConfiguratorInterface getResourceConfigurator() {
1395:                if (resourceConfigurator == null) {
1396:                    org.netbeans.modules.j2ee.sun.ide.sunresources.beans.ResourceConfigurator r = new org.netbeans.modules.j2ee.sun.ide.sunresources.beans.ResourceConfigurator();
1397:                    r.setDeploymentManager(this );
1398:                    resourceConfigurator = r;
1399:                    //            try{
1400:                    //                Class[] argClass = new Class[1];
1401:                    //                argClass[0] = javax.enterprise.deploy.spi.DeploymentManager.class;
1402:                    //                Object[] argObject = new Object[1];
1403:                    //                argObject[0] = this;
1404:                    //
1405:                    //                ClassLoader loader = getExtendedClassLoader();
1406:                    //                if(loader != null){
1407:                    //                    Class cc = loader.loadClass("org.netbeans.modules.j2ee.sun.ide.sunresources.beans.ResourceConfigurator");
1408:                    //                    resourceConfigurator = (ResourceConfiguratorInterface)cc.newInstance();
1409:                    //                    java.lang.reflect.Method setDeploymentManager = cc.getMethod("setDeploymentManager", argClass);//NOI18N
1410:                    //                    setDeploymentManager.invoke(resourceConfigurator, argObject);
1411:                    //                }
1412:                    //            }catch(Exception ex){
1413:                    //                //Suppressing exception
1414:                    //                //return will be a null value for resourceConfigurator
1415:                    //                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,
1416:                    //                        ex);
1417:                    //            }
1418:                }
1419:                return resourceConfigurator;
1420:            }
1421:
1422:            private javax.management.MBeanServerConnection getMBeanServerConnection()
1423:                    throws RemoteException, ServerException {
1424:                ServerInterface serverMgmt = getManagement();
1425:                return (javax.management.MBeanServerConnection) serverMgmt
1426:                        .getMBeanServerConnection();
1427:            }
1428:
1429:            public CmpMappingProvider getSunCmpMapper() {
1430:                CmpMappingProvider sunCmpMapper = null;
1431:                try {
1432:                    ClassLoader loader = getExtendedClassLoader();
1433:                    Class cc = loader
1434:                            .loadClass("org.netbeans.modules.j2ee.sun.bridge.cmp.CmpMappingProviderImpl");
1435:
1436:                    sunCmpMapper = (CmpMappingProvider) cc.newInstance();
1437:                } catch (Exception ex) {
1438:                    ErrorManager.getDefault()
1439:                            .notify(ErrorManager.EXCEPTION, ex);
1440:                }
1441:                return sunCmpMapper;
1442:            }
1443:
1444:            public boolean isMaybeRunningButWrongUserName() {
1445:                return maybeRunningButWrongUserName;
1446:            }
1447:
1448:            public boolean isSecure() {
1449:                return secure;
1450:            }
1451:
1452:            static String getHostFromURI(String uri) {
1453:                String retVal = null;
1454:                try {
1455:                    int len1 = uri.lastIndexOf(':');
1456:                    //int uriLength = uri.length();
1457:                    String partial = uri.substring(0, len1);
1458:                    int len2 = partial.lastIndexOf(':');
1459:
1460:                    retVal = uri.substring(len2 + 1, len1);
1461:                } catch (Throwable t) {
1462:                    jsr88Logger.warning("getHostFromURI:: invalid uri: " + uri);
1463:                }
1464:                return retVal;
1465:            }
1466:
1467:            static int getPortFromURI(String uri) {
1468:                int retVal = -1;
1469:                int len1 = uri.lastIndexOf(':');
1470:                if (-1 != len1) {
1471:                    //int uriLength = uri.length();
1472:                    try {
1473:                        retVal = Integer.parseInt(uri.substring(len1 + 1));
1474:                    } catch (NumberFormatException nfe) {
1475:                        jsr88Logger.warning(nfe.getMessage());
1476:                    }
1477:                }
1478:                return retVal;
1479:            }
1480:
1481:            synchronized public void refreshDeploymentManager() {
1482:                try {
1483:                    secureStatusHasBeenChecked = false;
1484:                    resetInnerDeploymentManager();
1485:                } catch (Exception ex) {
1486:                    return;//nothing much
1487:                }
1488:            }
1489:
1490:            public File getPlatformRoot() {
1491:                return platformRoot;
1492:            }
1493:
1494:            private ClassLoader getExtendedClassLoader() {
1495:
1496:                return ServerLocationManager
1497:                        .getNetBeansAndServerClassLoader(getPlatformRoot());
1498:            }
1499:
1500:            synchronized public void setUserName(String name) {
1501:                mmm = null;
1502:                secureStatusHasBeenChecked = false;
1503:                String oldValue = userName;
1504:                userName = name;
1505:                propertySupport.firePropertyChange("name", oldValue, userName);
1506:            }
1507:
1508:            synchronized public void setPassword(String pw) {
1509:                mmm = null;
1510:                secureStatusHasBeenChecked = false;
1511:                String oldValue = password;
1512:                password = pw;
1513:                passwordForURI.put(uri + platformRoot, password);
1514:
1515:                refreshDeploymentManager();
1516:
1517:                propertySupport.firePropertyChange("password", oldValue,
1518:                        password);
1519:
1520:            }
1521:
1522:            public File getAntDeploymentPropertiesFile() {
1523:                return new File(System.getProperty("netbeans.user"),
1524:                        getInstanceID() + ".properties"); // NOI18N
1525:            }
1526:
1527:            public void storeAntDeploymentProperties(File file, boolean create)
1528:                    throws IOException {
1529:                if (!create && !file.exists()) {
1530:                    return;
1531:                }
1532:                Properties antProps = new Properties();
1533:                antProps.setProperty("sjsas.root", getPlatformRoot()
1534:                        .getAbsolutePath()); // NOI18N
1535:                antProps.setProperty("sjsas.url", getWebUrl()); // NOI18N
1536:                antProps.setProperty("sjsas.username", getUserName()); // NOI18N
1537:                antProps.setProperty("sjsas.password", getPassword()); // NOI18N
1538:                antProps.setProperty("sjsas.host", getHost());
1539:                antProps.setProperty("sjsas.port", getPort() + "");
1540:                boolean ret = file.createNewFile();
1541:                FileObject fo = FileUtil.toFileObject(file);
1542:                FileLock lock = null;
1543:                try {
1544:                    lock = fo.lock();
1545:                    OutputStream os = fo.getOutputStream(lock);
1546:                    try {
1547:                        antProps.store(os, "");
1548:                    } finally {
1549:                        if (null != os) {
1550:                            os.close();
1551:                        }
1552:                    }
1553:                } finally {
1554:                    if (null != lock) {
1555:                        lock.releaseLock();
1556:                    }
1557:                }
1558:            }
1559:
1560:            private static String PROP_INSTANCE_ID = "PROP_INSTANCE_ID";
1561:
1562:            // package protected for access from SunDeploymentFactory.
1563:            String getInstanceID() {
1564:                InstanceProperties ip = SunURIManager.getInstanceProperties(
1565:                        platformRoot, host, adminPortNumber);
1566:                String name = null;
1567:                if (null != ip) {
1568:                    name = ip.getProperty(PROP_INSTANCE_ID);
1569:                }
1570:                if (name == null) {
1571:                    boolean isGF = ServerLocationManager
1572:                            .isGlassFish(platformRoot);
1573:                    String prefix = isGF ? "glassfish" : "sjsas8"; // NOI18N
1574:                    String[] instanceURLs = Deployment.getDefault()
1575:                            .getInstancesOfServer("J2EE"); // NOI18N
1576:                    int len = 0;
1577:                    if (null != instanceURLs) {
1578:                        len = instanceURLs.length;
1579:                    }
1580:                    for (int i = 0; name == null; i++) {
1581:                        if (i == 0) {
1582:                            name = prefix;
1583:                        } else {
1584:                            name = prefix + "_" + i; // NOI18N
1585:                        }
1586:
1587:                        for (int j = 0; j < len; j++) { // String url: instanceURLs) {
1588:                            String url = instanceURLs[j];
1589:                            String uri = null;
1590:                            if (null != ip) {
1591:                                uri = ip
1592:                                        .getProperty(InstanceProperties.URL_ATTR);
1593:                            }
1594:                            if (!url.equals(uri)) {
1595:                                InstanceProperties iip = InstanceProperties
1596:                                        .getInstanceProperties(url);
1597:                                if (iip != null) {
1598:                                    String anotherName = iip
1599:                                            .getProperty(PROP_INSTANCE_ID);
1600:                                    if (name.equals(anotherName)) {
1601:                                        name = null;
1602:                                        break;
1603:                                    }
1604:                                }
1605:                            }
1606:                        }
1607:                    }
1608:                    if (null != ip) {
1609:                        ip.setProperty(PROP_INSTANCE_ID, name);
1610:                    }
1611:                }
1612:                return name;
1613:            }
1614:
1615:            private String getWebUrl() {
1616:                return "http://" + host + ":" + nonAdminPortNumber; // NOI18N
1617:            }
1618:
1619:            public HashMap getSunDatasourcesFromXml() {
1620:                DomainEditor dEditor = new DomainEditor(this );
1621:                return dEditor.getSunDatasourcesFromXml();
1622:            }
1623:
1624:            public HashMap getConnPoolsFromXml() {
1625:                DomainEditor dEditor = new DomainEditor(this );
1626:                return dEditor.getConnPoolsFromXml();
1627:            }
1628:
1629:            public HashMap getAdminObjectResourcesFromXml() {
1630:                DomainEditor dEditor = new DomainEditor(this );
1631:                return dEditor.getAdminObjectResourcesFromXml();
1632:            }
1633:
1634:            public void createSampleDataSourceinDomain() {
1635:                DomainEditor dEditor = new DomainEditor(this );
1636:                dEditor.createSampleDatasource();
1637:            }
1638:
1639:            public void addPropertyChangeListener(
1640:                    PropertyChangeListener listener) {
1641:                propertySupport.addPropertyChangeListener(listener);
1642:            }
1643:
1644:            public void removePropertyChangeListener(
1645:                    PropertyChangeListener listener) {
1646:                propertySupport.removePropertyChangeListener(listener);
1647:            }
1648:
1649:            // VBK hack target objects to support configuration prototyping in
1650:            // J2EE 1.4 RI beta 1 deploytool
1651:            class FakeTarget implements  Target {
1652:
1653:                public String getDescription() {
1654:                    return "fakeTargetDescr"; // NOI18N
1655:                }
1656:
1657:                public String getName() {
1658:                    return "fakeTargetName"; // NOI18N
1659:                }
1660:
1661:            }
1662:
1663:            private AtomicBoolean locked = new AtomicBoolean(false);
1664:
1665:            public boolean grabInnerDM(boolean returnInsteadOfWait) {
1666:                while (true) {
1667:                    if (locked.compareAndSet(false, true)) {
1668:                        // I just closed the lock
1669:                        break;
1670:                    } else {
1671:                        try {
1672:                            if (returnInsteadOfWait) {
1673:                                return false;
1674:                            }
1675:                            synchronized (locked) { //(innerDM) {
1676:                                //innerDM.wait();
1677:                                locked.wait(500);
1678:                            }
1679:                        } catch (InterruptedException ie) {
1680:                            // what do I do now?
1681:                        }
1682:                    }
1683:                }
1684:                return true;
1685:            }
1686:
1687:            public void releaseInnerDM() {
1688:                locked.set(false);
1689:                synchronized (locked) { // (innerDM) {
1690:                    //innerDM.notifyAll();
1691:                    locked.notifyAll();
1692:                }
1693:            }
1694:
1695:            private class ReleaseInnerDMPL implements  ProgressListener {
1696:                Thread locker;
1697:
1698:                ReleaseInnerDMPL(Thread locker) {
1699:                    this .locker = locker;
1700:                }
1701:
1702:                public void handleProgressEvent(ProgressEvent progressEvent) {
1703:                    DeploymentStatus dms = progressEvent.getDeploymentStatus();
1704:                    if (!dms.isRunning()) {
1705:                        locked.set(false);
1706:                        synchronized (locked) { //(innerDM) {
1707:                            //innerDM.notifyAll();
1708:                            locked.notifyAll();
1709:                        }
1710:                    }
1711:                }
1712:            }
1713:
1714:            public void setRestartForDriverDeployment(boolean restart) {
1715:                this .driversdeployed = restart;
1716:            }
1717:
1718:            public int getAppserverVersion() {
1719:                return ServerLocationManager
1720:                        .getAppServerPlatformVersion(getPlatformRoot());
1721:            }
1722:
1723:            /** put a file inside this progress listener to get rid of it after
1724:             * it has been used
1725:             */
1726:            // <editor-fold defaultstate="collapsed" desc=" FileDeleter code ">
1727:            class FileDeleter implements  ProgressListener {
1728:                File f;
1729:
1730:                public FileDeleter(File f) {
1731:                    this .f = f;
1732:                }
1733:
1734:                public void handleProgressEvent(ProgressEvent pe) {
1735:                    DeploymentStatus ds = pe.getDeploymentStatus();
1736:                    if (ds.isCompleted() || ds.isFailed()) {
1737:                        // boolean complete = ds.isCompleted();
1738:                        f.delete();
1739:                    }
1740:                }
1741:            }
1742:
1743:            //</editor-fold>
1744:
1745:            /**
1746:             * ProgressObject for use in cases where we need to short circuit the flow of
1747:             * method calls between the plugin and the server's jsr-88 implementation class.
1748:             *
1749:             * This allows the plugin's jsr-88 "interface" to work-around bugs in the
1750:             * server's jsr-88 implementation.
1751:             */
1752:            // <editor-fold defaultstate="collapsed" desc=" ShortCircuitProgressObject code ">
1753:            static class ShortCircuitProgressObject implements  ProgressObject {
1754:
1755:                private CommandType ct;
1756:                private String message;
1757:                private StateType st;
1758:                private TargetModuleID[] tmids;
1759:
1760:                ProgressEventSupport pes = new ProgressEventSupport(this );
1761:
1762:                /**
1763:                 *
1764:                 * @param ct
1765:                 * @param message
1766:                 * @param st
1767:                 * @param tmids
1768:                 */
1769:                ShortCircuitProgressObject(CommandType ct, String message,
1770:                        StateType st, TargetModuleID[] tmids) {
1771:                    this .ct = ct;
1772:                    this .message = message;
1773:                    this .st = st;
1774:                    this .tmids = tmids;
1775:                }
1776:
1777:                /**
1778:                 *
1779:                 * @return
1780:                 */
1781:                public DeploymentStatus getDeploymentStatus() {
1782:                    return new DeploymentStatus() {
1783:                        public ActionType getAction() {
1784:                            return ActionType.EXECUTE;
1785:                        }
1786:
1787:                        public CommandType getCommand() {
1788:                            return ct;
1789:                        }
1790:
1791:                        public String getMessage() {
1792:                            return message;
1793:                        }
1794:
1795:                        public StateType getState() {
1796:                            return st;
1797:                        }
1798:
1799:                        public boolean isCompleted() {
1800:                            return st.equals(StateType.COMPLETED);
1801:                        }
1802:
1803:                        public boolean isFailed() {
1804:                            return st.equals(StateType.FAILED);
1805:                        }
1806:
1807:                        public boolean isRunning() {
1808:                            return st.equals(StateType.RUNNING);
1809:                        }
1810:                    };
1811:                }
1812:
1813:                /**
1814:                 *
1815:                 * @return
1816:                 */
1817:                public TargetModuleID[] getResultTargetModuleIDs() {
1818:                    return tmids;
1819:                }
1820:
1821:                /**
1822:                 *
1823:                 * @param targetModuleID
1824:                 * @return
1825:                 */
1826:                public ClientConfiguration getClientConfiguration(
1827:                        TargetModuleID targetModuleID) {
1828:                    return null;
1829:                }
1830:
1831:                /**
1832:                 *
1833:                 * @return
1834:                 */
1835:                public boolean isCancelSupported() {
1836:                    return false;
1837:                }
1838:
1839:                /**
1840:                 *
1841:                 * @throws javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException
1842:                 */
1843:                public void cancel() throws OperationUnsupportedException {
1844:                }
1845:
1846:                /**
1847:                 *
1848:                 * @return
1849:                 */
1850:                public boolean isStopSupported() {
1851:                    return false;
1852:                }
1853:
1854:                /**
1855:                 *
1856:                 * @throws javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException
1857:                 */
1858:                public void stop() throws OperationUnsupportedException {
1859:                }
1860:
1861:                /**
1862:                 *
1863:                 * @param progressListener
1864:                 */
1865:                public void addProgressListener(
1866:                        ProgressListener progressListener) {
1867:                    pes.addProgressListener(progressListener);
1868:                }
1869:
1870:                /**
1871:                 *
1872:                 * @param progressListener
1873:                 */
1874:                public void removeProgressListener(
1875:                        ProgressListener progressListener) {
1876:                    pes.removeProgressListener(progressListener);
1877:                }
1878:            }
1879:            //</editor-fold>
1880:        }
w__w___w.___j_a_va___2s__.___c_o___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.