Lines 62-68
Link Here
|
62 |
*/ |
62 |
*/ |
63 |
public abstract class J2eeModuleProvider { |
63 |
public abstract class J2eeModuleProvider { |
64 |
|
64 |
|
65 |
private InstanceListener il; |
|
|
66 |
private ConfigSupportImpl configSupportImpl; |
65 |
private ConfigSupportImpl configSupportImpl; |
67 |
List listeners = new ArrayList(); |
66 |
List listeners = new ArrayList(); |
68 |
private ConfigFilesListener configFilesListener = null; |
67 |
private ConfigFilesListener configFilesListener = null; |
Lines 77-86
Link Here
|
77 |
private PropertyChangeSupport supp = new PropertyChangeSupport(this); |
76 |
private PropertyChangeSupport supp = new PropertyChangeSupport(this); |
78 |
|
77 |
|
79 |
public J2eeModuleProvider () { |
78 |
public J2eeModuleProvider () { |
80 |
il = new IL (); |
|
|
81 |
ServerRegistry.getInstance ().addInstanceListener ( |
82 |
(InstanceListener) WeakListeners.create( |
83 |
InstanceListener.class, il, ServerRegistry.getInstance ())); |
84 |
} |
79 |
} |
85 |
|
80 |
|
86 |
public abstract J2eeModule getJ2eeModule (); |
81 |
public abstract J2eeModule getJ2eeModule (); |
Lines 432-444
Link Here
|
432 |
return new DefaultSourceMap(this); |
427 |
return new DefaultSourceMap(this); |
433 |
} |
428 |
} |
434 |
|
429 |
|
435 |
/** If the module wants to specify a target server instance for deployment |
|
|
436 |
* it needs to override this method to return false. |
437 |
*/ |
438 |
public boolean useDefaultServer () { |
439 |
return true; |
440 |
} |
441 |
|
442 |
/** |
430 |
/** |
443 |
* Set ID of the server instance that will be used for deployment. |
431 |
* Set ID of the server instance that will be used for deployment. |
444 |
* |
432 |
* |
Lines 447-474
Link Here
|
447 |
*/ |
435 |
*/ |
448 |
public abstract void setServerInstanceID(String severInstanceID); |
436 |
public abstract void setServerInstanceID(String severInstanceID); |
449 |
|
437 |
|
450 |
/** Id of server isntance for deployment. The default implementation returns |
438 |
/** |
451 |
* the default server instance selected in Server Registry. |
439 |
* Id of server instance for deployment or null if the module has no server |
452 |
* The return value may not be null. |
440 |
* instance set. |
453 |
* If modules override this method they also need to override {@link useDefaultServer}. |
441 |
* |
|
|
442 |
* @return Id of server instance for deployment or null if the module has no server |
443 |
* instance set. |
454 |
*/ |
444 |
*/ |
455 |
public String getServerInstanceID () { |
445 |
public abstract String getServerInstanceID(); |
456 |
return ServerRegistry.getInstance ().getDefaultInstance ().getUrl (); |
|
|
457 |
} |
458 |
|
446 |
|
459 |
/** |
447 |
/** |
460 |
* Return InstanceProperties of the server instance |
448 |
* Returns InstanceProperties of the server instance or null if the module has |
461 |
**/ |
449 |
* no server instance set or the given server instance does not exist. |
|
|
450 |
* |
451 |
* @return InstanceProperties of the server instance or null if the module has |
452 |
* no server instance set or the given server instance does not exist. |
453 |
*/ |
462 |
public InstanceProperties getInstanceProperties(){ |
454 |
public InstanceProperties getInstanceProperties(){ |
463 |
return InstanceProperties.getInstanceProperties(getServerInstanceID()); |
455 |
String serverInstanceID = getServerInstanceID(); |
|
|
456 |
if (serverInstanceID == null) { |
457 |
return null; |
458 |
} |
459 |
return InstanceProperties.getInstanceProperties(serverInstanceID); |
464 |
} |
460 |
} |
465 |
|
461 |
|
466 |
/** This method is used to determin type of target server. |
462 |
/** |
467 |
* The return value must correspond to value returned from {@link getServerInstanceID}. |
463 |
* This method is used to determin type of target server. The return value |
|
|
464 |
* must correspond to the value returned from {@link getServerInstanceID}. |
465 |
* |
466 |
* @return the target server type or null if the module has no target server |
467 |
* type set. |
468 |
*/ |
468 |
*/ |
469 |
public String getServerID () { |
469 |
public abstract String getServerID(); |
470 |
return ServerRegistry.getInstance ().getDefaultInstance ().getServer ().getShortName (); |
|
|
471 |
} |
472 |
|
470 |
|
473 |
/** |
471 |
/** |
474 |
* Return name to be used in deployment of the module. |
472 |
* Return name to be used in deployment of the module. |
Lines 602-647
Link Here
|
602 |
return; |
600 |
return; |
603 |
configFilesListener = new ConfigFilesListener(this, listeners); |
601 |
configFilesListener = new ConfigFilesListener(this, listeners); |
604 |
} |
602 |
} |
605 |
|
603 |
|
606 |
private final class IL implements InstanceListener { |
|
|
607 |
|
608 |
public void changeDefaultInstance (String oldInst, String newInst) { |
609 |
ServerInstance oldServerInstance = ServerRegistry.getInstance().getServerInstance(oldInst); |
610 |
ServerInstance newServerInstance = ServerRegistry.getInstance().getServerInstance(newInst); |
611 |
ServerString oldInstance = oldServerInstance != null |
612 |
? new ServerString(oldServerInstance) |
613 |
: null; |
614 |
ServerString newInstance = newServerInstance != null |
615 |
? new ServerString(newServerInstance) |
616 |
: null; |
617 |
if (useDefaultServer () && newInstance != null |
618 |
&& (oldInstance == null || !oldInstance.getPlugin().equals(newInstance.getPlugin()))) { |
619 |
if (J2eeModule.WAR.equals(getJ2eeModule().getModuleType())) { |
620 |
String oldCtxPath = getConfigSupportImpl().getWebContextRoot(); |
621 |
oldCtxPath = "/"+J2eeModuleProvider.this.getDeploymentName(); //NOI18N |
622 |
configSupportImpl.dispose(); |
623 |
J2eeModuleProvider.this.configSupportImpl = null; |
624 |
getConfigSupportImpl().ensureConfigurationReady(); |
625 |
String ctx = getConfigSupportImpl().getWebContextRoot (); |
626 |
if (ctx == null || ctx.equals ("")) { //NOI18N |
627 |
getConfigSupportImpl().setWebContextRoot(oldCtxPath); |
628 |
} |
629 |
} else { |
630 |
configSupportImpl.dispose(); |
631 |
J2eeModuleProvider.this.configSupportImpl = null; |
632 |
getConfigSupportImpl().ensureConfigurationReady(); |
633 |
} |
634 |
} |
635 |
} |
636 |
|
637 |
public void instanceAdded (String instance) { |
638 |
} |
639 |
|
640 |
public void instanceRemoved (String instance) { |
641 |
} |
642 |
|
643 |
} |
644 |
|
645 |
private ConfigSupportImpl getConfigSupportImpl() { |
604 |
private ConfigSupportImpl getConfigSupportImpl() { |
646 |
return (ConfigSupportImpl) getConfigSupport(); |
605 |
return (ConfigSupportImpl) getConfigSupport(); |
647 |
} |
606 |
} |