1 19 20 package org.netbeans.modules.j2ee.oc4j; 21 22 import java.io.File ; 23 import java.io.InputStream ; 24 import java.lang.reflect.Constructor ; 25 import java.lang.reflect.InvocationTargetException ; 26 import java.lang.reflect.Method ; 27 import java.util.HashMap ; 28 import java.util.Hashtable ; 29 import java.util.Map ; 30 import java.util.Vector ; 31 import javax.enterprise.deploy.model.DeployableObject ; 32 import javax.enterprise.deploy.shared.ActionType ; 33 import javax.enterprise.deploy.shared.CommandType ; 34 import javax.enterprise.deploy.shared.DConfigBeanVersionType ; 35 import javax.enterprise.deploy.shared.ModuleType ; 36 import javax.enterprise.deploy.shared.StateType ; 37 import javax.enterprise.deploy.spi.DeploymentConfiguration ; 38 import javax.enterprise.deploy.spi.DeploymentManager ; 39 import javax.enterprise.deploy.spi.Target ; 40 import javax.enterprise.deploy.spi.TargetModuleID ; 41 import javax.enterprise.deploy.spi.exceptions.DConfigBeanVersionUnsupportedException ; 42 import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException ; 43 import javax.enterprise.deploy.spi.exceptions.InvalidModuleException ; 44 import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException ; 45 import javax.enterprise.deploy.spi.exceptions.TargetException ; 46 import javax.enterprise.deploy.spi.factories.DeploymentFactory ; 47 import javax.enterprise.deploy.spi.status.ClientConfiguration ; 48 import javax.enterprise.deploy.spi.status.DeploymentStatus ; 49 import javax.enterprise.deploy.spi.status.ProgressEvent ; 50 import javax.enterprise.deploy.spi.status.ProgressListener ; 51 import javax.enterprise.deploy.spi.status.ProgressObject ; 52 import javax.management.MBeanServerConnection ; 53 import javax.management.remote.JMXConnector ; 54 import javax.management.remote.JMXConnectorFactory ; 55 import javax.management.remote.JMXServiceURL ; 56 import org.netbeans.api.java.classpath.ClassPath; 57 import org.netbeans.modules.j2ee.dd.api.application.Application; 58 import org.netbeans.modules.j2ee.dd.api.application.DDProvider; 59 import org.netbeans.modules.j2ee.dd.api.application.Module; 60 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; 61 import org.netbeans.modules.j2ee.oc4j.config.EarDeploymentConfiguration; 62 import org.netbeans.modules.j2ee.oc4j.config.EjbDeploymentConfiguration; 63 import org.netbeans.modules.j2ee.oc4j.config.WarDeploymentConfiguration; 64 import org.netbeans.modules.j2ee.oc4j.config.gen.OrionWebApp; 65 import org.netbeans.modules.j2ee.oc4j.ide.OC4JDeploymentStatus; 66 import org.netbeans.modules.j2ee.oc4j.ide.OC4JErrorManager; 67 import org.netbeans.modules.j2ee.oc4j.ide.OC4JJ2eePlatformImpl; 68 import org.netbeans.modules.j2ee.oc4j.util.OC4JPluginProperties; 69 import org.netbeans.modules.j2ee.oc4j.util.OC4JDebug; 70 import org.netbeans.modules.j2ee.oc4j.util.OC4JPluginUtils; 71 import org.netbeans.modules.web.api.webmodule.WebModule; 72 import org.openide.ErrorManager; 73 import org.openide.filesystems.FileObject; 74 import org.openide.filesystems.FileUtil; 75 import org.openide.filesystems.JarFileSystem; 76 import org.openide.util.NbBundle; 77 import org.openide.util.RequestProcessor; 78 79 83 public class OC4JDeploymentManager implements DeploymentManager , ProgressObject , Runnable { 84 85 private static enum COMMAND { DEPLOY, START } 86 87 private String uri; 88 89 private Object oc4jPropDm; 90 private DeploymentManager oc4jDm; 91 private OC4JPluginProperties ip; 92 private InstanceProperties instanceProperties; 93 private OC4JJ2eePlatformImpl oc4jPlatform; 94 95 private OC4JTargetModuleID module_id; 96 private MBeanServerConnection jmxConnection; 97 private Vector listeners = new Vector (); 98 private TargetModuleID [] modules; 99 private DeploymentStatus deploymentStatus; 100 private File file; 101 private COMMAND command; 102 private boolean connected = false; 103 104 109 public OC4JDeploymentManager(String uri) { 110 this.uri = uri; 111 112 ip = new OC4JPluginProperties(this); 113 } 114 115 120 public String getUri() { 121 return uri; 122 } 123 124 128 public String getUsername() { 129 return getInstanceProperties().getProperty(InstanceProperties.USERNAME_ATTR); 130 } 131 132 136 public String getPassword() { 137 return getInstanceProperties().getProperty(InstanceProperties.PASSWORD_ATTR); 138 } 139 140 145 public OC4JPluginProperties getProperties() { 146 return ip; 147 } 148 149 154 public InstanceProperties getInstanceProperties() { 155 if (instanceProperties == null) 156 instanceProperties = InstanceProperties.getInstanceProperties(getUri()); 157 158 return instanceProperties; 159 } 160 161 170 public ProgressObject distribute(Target [] target, File file, File file2) throws IllegalStateException { 171 releaseProprietaryObjects(); 173 174 module_id = new OC4JTargetModuleID(target[0], file.getName()); 175 this.file = file; 176 InstanceProperties ip = getProperties().getInstanceProperties(); 177 178 try{ 179 String server_url = "http://" + ip.getProperty(OC4JPluginProperties.PROPERTY_HOST) + ":" + 180 ip.getProperty(InstanceProperties.HTTP_PORT_NUMBER); 181 if (file.getName().endsWith(".war")) { module_id.setContextURL(server_url + OrionWebApp.createGraph(file2).getContextRoot()); 183 } else if (file.getName().endsWith(".ear")) { JarFileSystem jfs = new JarFileSystem(); 185 jfs.setJarFile(file); 186 FileObject appXml = jfs.getRoot().getFileObject("META-INF/application.xml"); if (appXml != null) { 188 Application ear = DDProvider.getDefault().getDDRoot(appXml); 189 Module modules [] = ear.getModule(); 190 for (int i = 0; i < modules.length; i++) { 191 OC4JTargetModuleID mod_id = new OC4JTargetModuleID(target[0]); 192 if (modules[i].getWeb() != null) { 193 mod_id.setContextURL(server_url + modules[i].getWeb().getContextRoot()); 194 } 195 module_id.addChild(mod_id); 196 } 197 } else { 198 ErrorManager.getDefault().log("Cannot file META-INF/application.xml in " + file); } 200 } 201 } catch (Exception e){ 202 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); 203 } 204 205 command = COMMAND.DEPLOY; 206 fireHandleProgressEvent(null, new OC4JDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.RUNNING, NbBundle.getMessage(OC4JDeploymentManager.class, "MSG_DEPLOYING", file.getAbsolutePath()))); 207 RequestProcessor.getDefault().post(this, 0, Thread.NORM_PRIORITY); 208 209 return this; 210 } 211 212 222 public ProgressObject distribute(Target [] target, ModuleType type, 223 InputStream inputStream, InputStream inputStream2) throws IllegalStateException { 224 return distribute(target, inputStream, inputStream2); 225 } 226 227 233 public DeploymentConfiguration createConfiguration(DeployableObject deployableObject) throws InvalidModuleException { 234 ModuleType type = deployableObject.getType(); 235 if (type == ModuleType.WAR) { 236 return new WarDeploymentConfiguration(deployableObject); 237 } else if (type == ModuleType.EAR) { 238 return new EarDeploymentConfiguration(deployableObject); 239 } else if (type == ModuleType.EJB) { 240 return new EjbDeploymentConfiguration(deployableObject); 241 } else { 242 throw new InvalidModuleException ("Unsupported module type: " + type.toString()); } 244 245 } 246 247 256 public ProgressObject redeploy(TargetModuleID [] targetModuleID, InputStream inputStream, InputStream inputStream2) throws UnsupportedOperationException , IllegalStateException { 257 if (!isConnected()) { 258 throw new IllegalStateException (NbBundle.getMessage( 259 OC4JDeploymentManager.class, "MSG_ERROR_DISC_MANAGER")); } 261 262 releaseProprietaryObjects(); 264 265 DeploymentManager manager = getOC4JDeploymentManager(); 266 267 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).updateLoader(); 268 269 try { 270 return manager.redeploy(targetModuleID, inputStream, inputStream2); 271 } finally { 272 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).restoreLoader(); 273 } 274 } 275 276 284 public ProgressObject distribute(Target [] target, InputStream inputStream, InputStream inputStream2) throws IllegalStateException { 285 if (!isConnected()) { 286 throw new IllegalStateException (NbBundle.getMessage( 287 OC4JDeploymentManager.class, "MSG_ERROR_DISC_MANAGER")); } 289 290 releaseProprietaryObjects(); 292 293 DeploymentManager manager = getOC4JDeploymentManager(); 294 295 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).updateLoader(); 296 297 try { 298 return manager.distribute(target, inputStream, inputStream2); 299 } finally { 300 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).restoreLoader(); 301 } 302 } 303 304 310 public ProgressObject undeploy(TargetModuleID [] targetModuleID) throws IllegalStateException { 311 if (!isConnected()) { 312 throw new IllegalStateException (NbBundle.getMessage( 313 OC4JDeploymentManager.class, "MSG_ERROR_DISC_MANAGER")); } 315 316 releaseProprietaryObjects(); 318 319 DeploymentManager manager = getOC4JDeploymentManager(); 320 321 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).updateLoader(); 322 323 try { 324 return manager.undeploy(targetModuleID); 325 } finally { 326 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).restoreLoader(); 327 } 328 } 329 330 339 public ProgressObject redeploy(TargetModuleID [] targetModuleID, File file, File file2) throws UnsupportedOperationException , IllegalStateException { 340 if (!isConnected()) { 341 throw new IllegalStateException (NbBundle.getMessage( 342 OC4JDeploymentManager.class, "MSG_ERROR_DISC_MANAGER")); } 344 345 releaseProprietaryObjects(); 347 348 DeploymentManager manager = getOC4JDeploymentManager(); 349 350 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).updateLoader(); 351 352 try { 353 return manager.redeploy(targetModuleID, file, file2); 354 } finally { 355 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).restoreLoader(); 356 } 357 } 358 359 365 public ProgressObject stop(TargetModuleID [] targetModuleID) throws IllegalStateException { 366 if (!isConnected()) { 367 throw new IllegalStateException (NbBundle.getMessage( 368 OC4JDeploymentManager.class, "MSG_ERROR_DISC_MANAGER")); } 370 371 releaseProprietaryObjects(); 373 374 DeploymentManager manager = getOC4JDeploymentManager(); 375 376 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).updateLoader(); 377 378 try { 379 return manager.stop(targetModuleID); 380 } finally { 381 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).restoreLoader(); 382 } 383 } 384 385 391 public ProgressObject start(TargetModuleID [] targetModuleID) throws IllegalStateException { 392 releaseProprietaryObjects(); 394 395 modules = targetModuleID; 396 command = COMMAND.START; 397 fireHandleProgressEvent(null, new OC4JDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(OC4JDeploymentManager.class, "MSG_STARTING_APP"))); 398 RequestProcessor.getDefault().post(this, 0, Thread.NORM_PRIORITY); 399 400 return this; 401 } 402 403 408 public void setLocale(java.util.Locale locale) throws UnsupportedOperationException { 409 getOC4JDeploymentManager().setLocale(locale); 410 } 411 412 417 public boolean isLocaleSupported(java.util.Locale locale) { 418 return getOC4JDeploymentManager().isLocaleSupported(locale); 419 } 420 421 429 public TargetModuleID [] getAvailableModules(ModuleType moduleType, Target [] target) throws TargetException , IllegalStateException { 430 if (!isConnected()) { 431 throw new IllegalStateException (NbBundle.getMessage( 432 OC4JDeploymentManager.class, "MSG_ERROR_DISC_MANAGER")); } 434 435 releaseProprietaryObjects(); 437 438 DeploymentManager manager = getOC4JDeploymentManager(); 439 440 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).updateLoader(); 441 442 try { 443 return manager.getAvailableModules(moduleType, target); 444 } finally { 445 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).restoreLoader(); 446 } 447 } 448 449 457 public TargetModuleID [] getNonRunningModules(ModuleType moduleType, Target [] target) throws TargetException , IllegalStateException { 458 if (!isConnected()) { 459 throw new IllegalStateException (NbBundle.getMessage( 460 OC4JDeploymentManager.class, "MSG_ERROR_DISC_MANAGER")); } 462 463 releaseProprietaryObjects(); 465 466 DeploymentManager manager = getOC4JDeploymentManager(); 467 468 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).updateLoader(); 469 470 try { 471 return manager.getNonRunningModules(moduleType, target); 472 } finally { 473 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).restoreLoader(); 474 } 475 } 476 477 485 public TargetModuleID [] getRunningModules(ModuleType moduleType, Target [] target) throws TargetException , IllegalStateException { 486 if (!isConnected()) { 487 throw new IllegalStateException (NbBundle.getMessage( 488 OC4JDeploymentManager.class, "MSG_ERROR_DISC_MANAGER")); } 490 491 releaseProprietaryObjects(); 493 494 DeploymentManager manager = getOC4JDeploymentManager(); 495 496 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).updateLoader(); 497 498 try { 499 return manager.getRunningModules(moduleType, target); 500 } finally { 501 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).restoreLoader(); 502 } 503 } 504 505 510 public void setDConfigBeanVersion(DConfigBeanVersionType dConfigBeanVersionType) throws DConfigBeanVersionUnsupportedException { 511 getOC4JDeploymentManager().setDConfigBeanVersion(dConfigBeanVersionType); 512 } 513 514 519 public boolean isDConfigBeanVersionSupported(DConfigBeanVersionType dConfigBeanVersionType) { 520 return getOC4JDeploymentManager().isDConfigBeanVersionSupported(dConfigBeanVersionType); 521 } 522 523 527 public void setConnected(boolean connected) { 528 this.connected = connected; 529 } 530 531 535 public boolean isConnected() { 536 return connected; 537 } 538 539 542 public void release() { 543 releaseProprietaryObjects(); 544 } 545 546 550 public boolean isRedeploySupported() { 551 return getOC4JDeploymentManager().isRedeploySupported(); 552 } 553 554 558 public java.util.Locale getCurrentLocale() { 559 return getOC4JDeploymentManager().getCurrentLocale(); 560 } 561 562 566 public DConfigBeanVersionType getDConfigBeanVersion() { 567 return getOC4JDeploymentManager().getDConfigBeanVersion(); 568 } 569 570 574 public java.util.Locale getDefaultLocale() { 575 return getOC4JDeploymentManager().getDefaultLocale(); 576 } 577 578 582 public java.util.Locale [] getSupportedLocales() { 583 return getOC4JDeploymentManager().getSupportedLocales(); 584 } 585 586 590 public Target [] getTargets() { 591 OC4JDebug.log(getClass().getName(), "getTargets for Deployment Maneger"); 592 593 releaseProprietaryObjects(); 595 596 try{ 597 return getOC4JDeploymentManager().getTargets(); 598 } catch(Exception e) { 599 OC4JErrorManager.getInstance(this).error(uri, e, OC4JErrorManager.GENERIC_FAILURE); 600 } 601 602 return null; 603 } 604 605 608 private synchronized DeploymentManager getOC4JDeploymentManager() { 609 if (null == oc4jDm) { 610 OC4JDeploymentFactory factory = (OC4JDeploymentFactory) OC4JDeploymentFactory.getDefault(); 611 612 try { 613 if(!OC4JPluginProperties.isRunning(getInstanceProperties().getProperty(OC4JPluginProperties.PROPERTY_HOST), getInstanceProperties().getProperty(InstanceProperties.HTTP_PORT_NUMBER))) 614 throw new DeploymentManagerCreationException (uri); 615 616 DeploymentFactory propFactory = factory.getOC4JDeploymentFactory(uri); 617 618 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).updateLoader(); 619 620 oc4jDm = propFactory.getDeploymentManager(uri, getUsername(), getPassword()); 621 622 setConnected(true); 623 } catch (Exception e) { 624 OC4JErrorManager.getInstance(this).error(uri, e, OC4JErrorManager.GENERIC_FAILURE); 625 626 setConnected(false); 627 } finally { 628 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).restoreLoader(); 629 } 630 } 631 632 return oc4jDm; 633 } 634 635 638 private synchronized Object getOC4JProprietaryDeploymentManager() { 639 if (null == oc4jPropDm) { 640 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).updateLoader(); 641 642 try { 643 Class cls = OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()). 644 loadClass("oracle.oc4j.admin.deploy.api.J2EEDeploymentManager"); 645 Class partypes[] = {String .class, String .class, String .class}; 646 Constructor ct = cls.getConstructor(partypes); 647 Object arglist[] = {uri, getUsername(), getPassword()}; 648 oc4jPropDm = ct.newInstance(arglist); 649 } catch (NoSuchMethodException e) { 650 ErrorManager.getDefault().notify(ErrorManager.ERROR, e); 651 } catch (ClassNotFoundException e) { 652 ErrorManager.getDefault().notify(ErrorManager.ERROR, e); 653 } catch (InstantiationException e) { 654 ErrorManager.getDefault().notify(ErrorManager.ERROR, e); 655 } catch (IllegalAccessException e) { 656 ErrorManager.getDefault().notify(ErrorManager.ERROR, e); 657 } catch (InvocationTargetException e) { 658 ErrorManager.getDefault().notify(ErrorManager.ERROR, e); 659 } catch (Exception e) { 660 ErrorManager.getDefault().notify(ErrorManager.ERROR, e); 661 } finally { 662 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).restoreLoader(); 663 } 664 } 665 666 return oc4jPropDm; 667 } 668 669 672 private void invoke(String methodName, Class [] paramNames, Object [] args) throws Exception { 673 Object manager = getOC4JProprietaryDeploymentManager(); 674 675 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).updateLoader(); 676 677 Method m = manager.getClass().getMethod(methodName, paramNames); 678 m.invoke(manager, args); 679 680 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).restoreLoader(); 681 } 682 683 public void run() { 684 switch(command) { 685 case DEPLOY: 686 fireHandleProgressEvent(module_id, new OC4JDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.RUNNING, NbBundle.getMessage(OC4JDeploymentManager.class, "MSG_DEPLOYING", file.getAbsolutePath()))); 687 String moduleID = module_id.getModuleID(); 688 689 WebModule w = WebModule.getWebModule(FileUtil.toFileObject(file)); 691 692 if (null != w && OC4JPluginUtils.isJSFInWebModule(w)) { 693 ClassPath cp = ClassPath.getClassPath(w.getDocumentBase(), ClassPath.COMPILE); 694 695 if (null == cp.findResource("javax/faces/FacesException.class") 697 || null == cp.findResource("javax/servlet/jsp/jstl/core/Config.class")) { 698 fireHandleProgressEvent(module_id, new OC4JDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED, NbBundle.getMessage(OC4JDeploymentManager.class, "MSG_DEPLOY_FAILED"))); 699 OC4JErrorManager.getInstance(this).reaction("com.evermind.server.http.deployment.WARAnnotationParser"); 700 return; 701 } 702 } 703 704 try{ 705 invoke("deploy", new Class [] {String .class, String .class, Map .class, boolean.class}, new Object [] {file.getAbsolutePath(), moduleID, new HashMap (), true}); 707 if(moduleID.endsWith(".war") || moduleID.endsWith(".ear")) { invoke("bindWebApp", new Class [] {String .class, String .class}, 711 new Object [] {moduleID, ip.getInstanceProperties().getProperty(OC4JPluginProperties.PROPERTY_WEB_SITE) + "-web-site"}); } 713 } catch (Exception e) { 714 fireHandleProgressEvent(module_id, new OC4JDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED, NbBundle.getMessage(OC4JDeploymentManager.class, "MSG_DEPLOY_FAILED"))); 715 OC4JErrorManager.getInstance(this).error(uri, e, OC4JErrorManager.GENERIC_FAILURE); 716 return; 717 } 718 719 fireHandleProgressEvent(module_id, new OC4JDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.COMPLETED, NbBundle.getMessage(OC4JDeploymentManager.class, "MSG_DEPLOYED"))); 720 break; 721 case START: 722 fireHandleProgressEvent(module_id, new OC4JDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(OC4JDeploymentManager.class, "MSG_STARTING_APP"))); 723 for(int i = 0; i < modules.length; i++) { 724 TargetModuleID module = modules[i]; 725 try{ 726 invoke("startApplication", new Class [] {String .class}, new Object [] {module.getModuleID()}); 727 } catch(Exception e) { 728 fireHandleProgressEvent(module_id, new OC4JDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED, NbBundle.getMessage(OC4JDeploymentManager.class, "MSG_DEPLOY_FAILED"))); 729 OC4JErrorManager.getInstance(this).error(uri, e, OC4JErrorManager.GENERIC_FAILURE); 730 return; 731 } 732 } 733 734 fireHandleProgressEvent(module_id, new OC4JDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.COMPLETED, NbBundle.getMessage(OC4JDeploymentManager.class, "MSG_STARTING_APP"))); 735 break; 736 } 737 } 738 739 744 public MBeanServerConnection getJMXConnector() { 745 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).updateLoader(); 746 747 if(jmxConnection == null) { 748 try { 749 if(!OC4JPluginProperties.isRunning(getInstanceProperties().getProperty(OC4JPluginProperties.PROPERTY_HOST), getInstanceProperties().getProperty(InstanceProperties.HTTP_PORT_NUMBER))) 750 return null; 751 752 Hashtable credentials= new Hashtable (); 753 credentials.put("login", ip.getInstanceProperties().getProperty(InstanceProperties.USERNAME_ATTR)); credentials.put("password", ip.getInstanceProperties().getProperty(InstanceProperties.PASSWORD_ATTR)); Hashtable env = new Hashtable (); 756 env.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "oracle.oc4j.admin.jmx.remote"); 757 env.put(JMXConnector.CREDENTIALS, credentials); 758 759 JMXServiceURL serviceUrl= new JMXServiceURL ( "rmi", ip.getInstanceProperties().getProperty(OC4JPluginProperties.PROPERTY_HOST), 761 Integer.parseInt(ip.getInstanceProperties().getProperty(OC4JPluginProperties.PROPERTY_ADMIN_PORT)), 762 "/oc4j"); JMXConnector connection = JMXConnectorFactory.newJMXConnector(serviceUrl, env); 764 connection.connect(); 765 jmxConnection = connection.getMBeanServerConnection(); 766 } catch(Exception e) { 767 OC4JErrorManager.getInstance(this).error(uri, e, OC4JErrorManager.GENERIC_FAILURE); 768 } finally { 769 OC4JClassLoader.getInstance(getProperties().getOC4JHomeLocation()).restoreLoader(); 770 } 771 } 772 773 return jmxConnection; 774 } 775 776 779 public void releaseProprietaryObjects() { 780 if (null != oc4jDm) { 781 oc4jDm.release(); 782 oc4jDm = null; 783 } 784 785 if (null != oc4jPropDm) 786 oc4jPropDm = null; 787 788 if (null != jmxConnection) 789 jmxConnection = null; 790 } 791 792 796 public OC4JJ2eePlatformImpl getOC4JPlatform() { 797 if (oc4jPlatform == null) { 798 oc4jPlatform = (OC4JJ2eePlatformImpl) new OC4JJ2eePlatformImpl(this); 799 } 800 return oc4jPlatform; 801 } 802 803 807 public void addProgressListener(ProgressListener pl) { 808 listeners.add(pl); 809 } 810 811 815 public void removeProgressListener(ProgressListener pl) { 816 listeners.remove(pl); 817 } 818 819 823 public void stop() throws OperationUnsupportedException { 824 throw new OperationUnsupportedException (""); 825 } 826 827 831 public boolean isStopSupported() { 832 return false; 833 } 834 835 839 public void cancel() throws OperationUnsupportedException { 840 throw new OperationUnsupportedException (""); 841 } 842 843 847 public boolean isCancelSupported() { 848 return false; 849 } 850 851 856 public ClientConfiguration getClientConfiguration(TargetModuleID targetModuleID) { 857 return null; 858 } 859 860 864 public TargetModuleID [] getResultTargetModuleIDs() { 865 return new TargetModuleID []{ module_id }; 866 } 867 868 872 public DeploymentStatus getDeploymentStatus() { 873 return deploymentStatus; 874 } 875 876 881 public void fireHandleProgressEvent(TargetModuleID targetModuleID, DeploymentStatus deploymentStatus) { 882 this.deploymentStatus = deploymentStatus; 883 Vector targets = null; 884 ProgressEvent evt = new ProgressEvent (this, targetModuleID, deploymentStatus); 885 886 synchronized (this) { 887 if (listeners != null) { 888 targets = (Vector ) listeners.clone(); 889 } 890 } 891 892 if (targets != null) { 893 for (int i = 0; i < targets.size(); i++) { 894 ProgressListener target = (ProgressListener )targets.elementAt(i); 895 target.handleProgressEvent(evt); 896 } 897 } 898 } 899 } | Popular Tags |