Methods Summary |
---|
public void | addConnectionFactory(java.lang.String appName, java.lang.String connectorName, java.lang.String jndiName, java.lang.String xaRecoveryUser, java.lang.String xaRecoveryPassword, java.util.Properties props)
String serverName = getCurrentServer();
JarInstaller installer = this.getJarInstaller(serverName);
installer.addConnectionFactory(appName, connectorName,
jndiName, xaRecoveryUser,
xaRecoveryPassword, props);
|
public void | addNotificationListener(com.sun.enterprise.util.NotificationListener nl)add a notificationlistsner for server changes.
listeners.addElement(nl);
this.changed(SERVER_LISTENER_ADDED, ""); // NOI18N
|
public void | addServer(java.lang.String serverName)Connect to a new server by hostnamne
JarInstaller jarInstaller = this.getJarInstaller(serverName);
if (serverNameToListenerMap.containsKey(serverName)) {
// already present
this.setCurrentServer(serverName);
this.changed(SERVER_SELECTED, serverName);
} else {
ServerListener serverListener = null;
try {
serverListener = this.createServerListener(serverName);
jarInstaller.addRemoteNotificationListener(serverListener);
} catch (Exception e) {
System.out.println(localStrings.getLocalString(
"enterprise.tools.deployment.main.errorgettingserverlistener",
"Error getting server listener"));
}
serverNameToListenerMap.put(serverName, serverListener);
this.setCurrentServer(serverName);
this.changed(SERVER_ADDED, serverName);
}
|
protected void | changed()Force an update of listeners.
Vector listenersClone = null;
synchronized (listeners) {
listenersClone = (Vector)listeners.clone();
}
for (Enumeration e = listenersClone.elements(); e.hasMoreElements();) {
NotificationListener nl = (NotificationListener) e.nextElement();
nl.notification(new NotificationEvent(this, NOTIFICATION_TYPE));
}
|
protected void | changed(java.lang.String type, java.lang.String name)
Vector listenersClone = null;
synchronized (listeners) {
listenersClone = (Vector)listeners.clone();
}
NotificationEvent event = new NotificationEvent(this, type,
SERVER_PROPERTY, name);
for (Enumeration e = listenersClone.elements(); e.hasMoreElements();) {
NotificationListener nl = (NotificationListener) e.nextElement();
nl.notification(event);
}
|
public com.sun.enterprise.tools.deployment.backend.DeploymentSession | createDeploymentSession(java.lang.String serverName)Creates a Session object for listening to and managing deployment
progress reports.
try {
DeploymentSession ds = new DeploymentSessionImpl();
PortableRemoteObject.exportObject(ds);
Tie servantsTie = javax.rmi.CORBA.Util.getTie(ds);
servantsTie.orb(ORBManager.getORB());
return ds;
} catch (Throwable t) {
throw new ServerException(localStrings.getLocalString(
"enterprise.tools.deployment.main.couldnotgetorbforserver",
"Couldn't get orb for ({0}) {1}",
new Object[] {"createDeploymentSession",serverName})); // NOI18N
}
|
private ServerListener | createServerListener(java.lang.String serverName)
try {
ServerListener listener = new ServerListener(this);
PortableRemoteObject.exportObject(listener);
Tie servantsTie = javax.rmi.CORBA.Util.getTie(listener);
servantsTie.orb(ORBManager.getORB());
return listener;
} catch (Throwable t) {
throw new ServerException(localStrings.getLocalString(
"enterprise.tools.deployment.main.couldnotgetorbforserver",
"Couldn't get orb for ({0}) {1}",
new Object[] {"createCallBack", serverName})); // NOI18N
}
|
public void | deployedApplication(com.sun.enterprise.deployment.Application app)
this.changed(APP_DEPLOYED, app.getName());
|
public void | deployedStandAlone(com.sun.enterprise.deployment.Descriptor desc)
this.changed(SA_DEPLOYED, desc.getName());
|
public java.util.Vector | getApplicationNames()
return this.getApplicationNamesForServer(getCurrentServer());
|
public java.util.Vector | getApplicationNamesForServer(java.lang.String serverName)Return a vector of application names.
Vector v = null;
if (serverName == null) {
return v;
}
JarInstaller installer = this.getJarInstaller(serverName);
if (installer != null) {
try {
v = installer.getApplicationNames();
} catch (RemoteException re) {
throw new ServerException(localStrings.getLocalString(
"enterprise.tools.deployment.main.errorgettingappnamefromserverwithreason",
"Error obtaining application names from {0} \n reason {1}",
new Object[] {serverName,re.getMessage()}));
}
}
return v;
|
public java.util.Vector | getConnectionFactories()
return this.getConnectionFactoriesForServer(getCurrentServer());
|
public java.util.Vector | getConnectionFactoriesForServer(java.lang.String serverName)Return a vector of connection-factory names.
Vector v = null;
if (serverName != null) {
JarInstaller installer = this.getJarInstaller(serverName);
if (installer != null) {
try {
v = new Vector();
ConnectorInfo ci = installer.listConnectors();
for (int i = 0; i < ci.connectionFactories.length; i++) {
v.add(ci.connectionFactories[i].toString());
}
} catch (Exception re) {
throw new ServerException(localStrings.getLocalString(
"enterprise.tools.deployment.main.errorgettingappnamefromserverwithreason",
"Error obtaining application names from {0} \n reason {1}",
new Object[] { serverName, re.toString() }));
}
}
}
return v;
|
public java.util.Set | getConnectionFactoryPropertyTemplate(java.lang.String appName, java.lang.String connectorName)Return a set of EnvironmentProperties that represents
the configuration properties of a connection factory
String serverName = getCurrentServer();
JarInstaller installer = this.getJarInstaller(serverName);
return installer.getConnectionFactoryPropertyTemplate
(appName, connectorName);
|
public java.util.Vector | getConnectorNames()
return this.getConnectorNamesForServer(getCurrentServer());
|
public java.util.Vector | getConnectorNamesForServer(java.lang.String serverName)Return a vector of connector names.
Vector v = null;
if (serverName != null) {
JarInstaller installer = this.getJarInstaller(serverName);
if (installer != null) {
try {
v = new Vector();
ConnectorInfo ci = installer.listConnectors();
for (int i = 0; i < ci.connectors.length; i++) {
v.add(ci.connectors[i].toString());
}
} catch (Exception re) {
throw new ServerException(
localStrings.getLocalString(
"enterprise.tools.deployment.main.errorgettingappnamefromserverwithreason",
"Error obtaining application names from {0} \n reason {1}",
new Object[] { serverName, re.toString() }));
}
}
}
return v;
|
public java.lang.String | getCurrentServer()Return the name of the current server in this manager.
if ((this.currentServer != null) &&
serverNameToListenerMap.containsKey(this.currentServer)) {
return currentServer;
}
return null;
|
public com.sun.ejb.sqlgen.DBInfo | getDBInfo(java.lang.String serverName)Return information about the database under the given server.
try {
if ( serverName.equalsIgnoreCase("local") ) // NOI18N
serverName = "localhost"; // NOI18N
String initialPort = System.getProperty(OMG_ORB_INIT_PORT_PROPERTY);
if (initialPort == null)
initialPort = String.valueOf(ORBManager.getORBInitialPort());
String corbaName = "corbaname:iiop:" + serverName + ":" + // NOI18N
initialPort + "#" + DBInfo.JNDI_NAME; // NOI18N
Object objref = getIC().lookup(corbaName);
Object o = PortableRemoteObject.narrow(objref, DBInfo.class);
DBInfo info = (DBInfo) o;
return info;
} catch (Throwable t) {
throw new ServerException(localStrings.getLocalString(
"enterprise.tools.deployment.main.couldnotgetdbinfofromserver",
"Could not get db info from the J2EE server {0}",
new Object[] {serverName}));
}
|
private javax.naming.Context | getIC()
if ( initialContext == null ) {
Hashtable env = new Hashtable();
env.put("java.naming.corba.orb", ORBManager.getORB()); // NOI18N
try {
initialContext = new InitialContext(env);
} catch ( Exception ex ) {
ex.printStackTrace();
}
}
return initialContext;
|
private com.sun.enterprise.tools.deployment.backend.JarInstaller | getJarInstaller(java.lang.String serverName)
try {
if ( serverName.equalsIgnoreCase("local") ) // NOI18N
serverName = "localhost"; // NOI18N
String initialPort = System.getProperty(OMG_ORB_INIT_PORT_PROPERTY);
if (initialPort == null)
initialPort = String.valueOf(ORBManager.getORBInitialPort());
String corbaName = "corbaname:iiop:" + serverName + ":" + // NOI18N
initialPort + "#" + JarInstaller.JNDI_NAME; // NOI18N
/* IASRI 4691307 commented out by Anissa.
* The following code throws exception from the ORBManager and since we don't need any server
* connection for AT, we will not perform this step.
*
Object objref = getIC().lookup(corbaName);
Object o = PortableRemoteObject.narrow(objref, JarInstaller.class);
JarInstaller installer = (JarInstaller) o;
return installer;
* end of IASRI 4691307
*/
throw new ServerException(""); //NOI18N
} catch (Throwable t) {
String msg = localStrings.getLocalString(
"enterprise.tools.deployment.main.couldnotconnecttoserver",
"Couldn''t connect to {0}",
new Object[] { serverName });
//System.err.println(msg); // IASRI 4691307
//UIUtils.printException(msg, t);
throw new ServerException(msg);
}
|
public com.sun.enterprise.tools.deployment.backend.JarInstaller | getServerForName(java.lang.String serverName)Return a server by name. return null if there is no server of that
name.
return this.getJarInstaller(serverName);
|
public java.util.Vector | getServerNames()Returns a list of server names.
Vector v = new Vector();
for (Enumeration e = this.serverNameToListenerMap.keys();
e.hasMoreElements();) {
v.addElement(e.nextElement());
}
return v;
|
public boolean | isInstalled(java.lang.String applicationName, java.lang.String serverName)
JarInstaller installer = this.getJarInstaller(serverName);
if (installer != null) {
try {
Vector applicationNames = installer.getApplicationNames();
for (int i = 0; i < applicationNames.size(); i++) {
if (applicationName.equals(applicationNames.elementAt(i))) {
return true;
}
}
} catch (Throwable t) {
throw new ServerException(localStrings.getLocalString(
"enterprise.tools.deployment.main.couldnotapplicationlistfromserver",
"Couldn't get application list from {0}",
new Object[] {serverName}));
}
}
return false;
|
public java.util.Set | listConnectorResources()
String serverName = getCurrentServer();
JarInstaller installer = this.getJarInstaller(serverName);
Set res = installer.listConnectorResources();
return res;
|
private java.lang.String | printList()My pretty format.
String s = "Server Manager "; // NOI18N
for (Enumeration e = this.getServerNames().elements();
e.hasMoreElements();) {
s = s + "\n\t" + e.nextElement(); // NOI18N
}
return s;
|
public void | removeConnectionFactory(java.lang.String jndiName)
String serverName = getCurrentServer();
JarInstaller installer = this.getJarInstaller(serverName);
installer.removeConnectionFactory(jndiName);
|
public void | removeNotificationListener(com.sun.enterprise.util.NotificationListener nl)removes a notificationlistsner for server changes.
this.listeners.removeElement(nl);
this.changed(SERVER_LISTENER_REMOVED, ""); // NOI18N
|
public void | removeServer(java.lang.String hostName)Disconnect from new server by hostname
if (serverNameToListenerMap.containsKey(hostName)) {
ServerListener serverListener =
(ServerListener)serverNameToListenerMap.get(hostName);
try {
serverNameToListenerMap.remove(hostName);
if ((this.getCurrentServer() != null) &&
this.getCurrentServer().equals(hostName)) {
this.currentServer = null;
}
this.changed(SERVER_REMOVED, hostName);
JarInstaller jarInstaller = this.getJarInstaller(hostName);
jarInstaller.removeRemoteNotificationListener(serverListener);
} catch (Exception e) {
// leave for debug
//System.out.println("Error removing notification listener from server");
}
}
|
public java.util.Hashtable | restoreFromUserHome()Reconnect to all the servers I knew about in the last session.
Hashtable badServerNamesToExceptions = new Hashtable();
File serversFile = new File(preferencesDirectory, SERVERS_FILENAME);
if (serversFile.exists()) {
FileInputStream fis = new FileInputStream(serversFile);
Properties servers = new Properties();
servers.load(fis);
fis.close();
for (Enumeration e = servers.propertyNames();
e.hasMoreElements();) {
String serverName = (String) e.nextElement();
try {
this.addServer(serverName);
} catch (Throwable ex) {
badServerNamesToExceptions.put(badServerNamesToExceptions,
ex);
}
}
}
return badServerNamesToExceptions;
|
public void | saveToUserHome()Save my current state to my directory.
File serversFile = new File(preferencesDirectory, SERVERS_FILENAME);
FileOutputStream fos = new FileOutputStream(serversFile);
Properties serversP = new Properties();
for (Enumeration e = this.getServerNames().elements();
e.hasMoreElements();) {
String nextServer = (String) e.nextElement();
serversP.put(nextServer, nextServer);
}
serversP.store(fos, "J2EE Servers"); // NOI18N
if( fos != null ) {
fos.close();
}
|
public void | setCurrentServer(java.lang.String serverName)Set the name of the current server in this manager.
this.currentServer = serverName;
String notificationString = ""; // NOI18N
if (serverName != null) {
notificationString = serverName;
}
this.changed(SERVER_SELECTED, notificationString);
|
public java.lang.String | toString()My pretty format as a STring.
return "ServerManager"; // NOI18N
|
public void | undeployApplication(java.lang.String applicationName, java.lang.String serverName)The undeploy method.
JarInstaller installer = this.getJarInstaller(serverName);
try {
installer.undeployApplication(applicationName);
this.changed(APP_UNDEPLOYED, applicationName);
} catch (Throwable t) {
throw new ServerException(localStrings.getLocalString(
"enterprise.tools.deployment.main.erroruninstallingapplicationfromserver",
"Error uninstalling {0} from {1}",
new Object[] {applicationName, serverName}));
}
|
public void | undeployApplication(java.lang.Object[] appList, java.lang.String serverName)
for (int i = 0; i < appList.length; i++) {
if (appList[i] instanceof String) {
this.undeployApplication((String)appList[i], serverName);
} else {
// XXX this should never occur
}
}
|
public void | undeployConnector(java.lang.String rarName, java.lang.String serverName)
JarInstaller installer = this.getJarInstaller(serverName);
try {
installer.undeployConnector(rarName);
this.changed(SA_UNDEPLOYED, rarName);
} catch (Throwable t) {
throw new ServerException(localStrings.getLocalString(
"enterprise.tools.deployment.main.erroruninstallingapplicationfromserver",
"Error uninstalling {0} from {1}",
new Object[] { rarName, serverName }));
}
|
public void | undeployConnector(java.lang.Object[] rarList, java.lang.String serverName)
for (int i = 0; i < rarList.length; i++) {
if (rarList[i] instanceof String) {
this.undeployConnector((String)rarList[i], serverName);
} else {
// XXX this should never occur
}
}
|