04-21-07 12:11 PM
[ https://issues.apache.org/jira/brow...ge=3Dcom.atlas=
sian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Emmanuel Lecharny closed DIRSERVER-431.
---------------------------------------
Closing all issues created in 2005 and before which are marked resolved
> A new GUI to manage server start/shutdown.
> ------------------------------------------
>
> Key: DIRSERVER-431
> URL: https://issues.apache.org/jira/browse/DIRSERVER-431
> Project: Directory ApacheDS
> Issue Type: New Feature
> Environment: Tested on XP SP2 with JDK 1.5
> Reporter: Tony Blanchard
> Assigned To: Alex Karasulu
> Priority: Minor
>
> Here are the changes made to build this new GUI.
> In server main,
> Project.properties :
> Change of this value "maven.javaapp.mainclass=3Dorg.apache.ldap.server.Se=
rverMainGUI" to build an executable jar which launch the new GUI.
> Porject.xml :=20
> Adding in project block
> <build>
> =09<resources>
> =09<resource>
> <directory>${basedir}/src/main/java/res"</directory>
> <targetPath>res</targetPath>
> </resource>
> </resources>
> </build>
> under "main\java" folder :
> Adding a new folder named "res" with to files named "msg.properties" and =
"msg_fr_FR.properties".
> msg.properties :
> #ResourceBundle properties file
> default_conf_msg=3Ddefault
> conf_label=3DConfiguration file:
> conf_button_label=3DConfiguration
> status_label=3DStatus:
> start_button_label=3DStart
> stop_button_label=3DStop
> status_started=3DStarted
> status_stopped=3DStopped
> status_loading_conf=3DLoading configuration...
> status_init_start_env=3DInitializing environment...
> status_init_start=3DStarting server...
> status_init_stop_env=3DInitializing stopping environment...
> status_init_stop=3DStopping server...
> server_main_gui_title=3DLDAP server manager
> status_not_stopped=3DWas unable to stop !
> status_not_started=3DWas unable to start !
> conf_selection_title=3DConfiguration file selection
> msg_fr_FR.properties:
> #ResourceBundle properties file
> default_conf_msg=3DD=C3=A9faut
> conf_label=3DFichier de configuration :
> conf_button_label=3DConfiguration
> status_label=3DStatus :
> start_button_label=3DD=C3=A9marrage
> stop_button_label=3DArr=C3=AAt
> status_started=3DD=C3=A9marr=C3=A9
> status_stopped=3DArr=C3=AAt=C3=A9
> status_loading_conf=3DChargement de la configuration...
> status_init_start_env=3DInitialisation de l''environment...
> status_init_start=3DD=C3=A9marrage du serveur...
> status_init_stop_env=3DInitialisation de l''environement d'arr=C3=AAt...
> status_init_stop=3DArr=C3=AAt du serveur...
> server_main_gui_title=3DGestion du serveur LDAP
> status_not_stopped=3DArr=C3=AAt impossible !
> status_not_started=3DD=C3=A9marrage impossible !
> conf_selection_title=3DConfiguration file selection
> Under the package "org.apache.ldap.server" :
> Addition of the class "org.apache.ldap.server.ServerMainGUI"
> /*
> * ServerMainGUI.java
> *
> * Created on 7 juillet 2005, 15:56
> */
> package org.apache.ldap.server;
> import java.util.Properties;
> import java.util.ResourceBundle;
> import javax.naming.Context;
> import javax.naming.NamingException;
> import javax.naming.directory.InitialDirContext;
> import javax.swing.UIManager;
> import javax.swing.UnsupportedLookAndFeelException;
> import javax.swing.JFileChooser;
> import java.awt.Dimension;
> import java.awt.Insets;
> import java.io.PrintStream;
> import java.io.ByteArrayOutputStream;
> import org.apache.ldap.server.configuration.MutableServerStartupConfigura=
tion;
> import org.apache.ldap.server.configuration.ShutdownConfiguration;
> import org.apache.ldap.server.configuration.ServerStartupConfiguration;
> import org.apache.ldap.server.jndi.ServerContextFactory;
> import org.springframework.context.ApplicationContext;
> import org.springframework.context.support.FileSystemXmlApplicationContex=
t;
> /**
> * A box which enables to choose a server configuration file to start the=
server with.
> * It allows to start or stop the server as needed.
> * The main entry point of the application uses the "LDAP_SERVER_CONF" en=
vironment variable or
> * application argument to locate the configuration file else, default va=
lues are used to start
> * the server.
> * The command line argument is prioritary facing the system environment =
variable.
> * @author Tony Blanchard - 2005
> */
> public class ServerMainGUI extends javax.swing.JDialog
> {
> protected Properties env;
> protected ServerStartupConfiguration cfg;
> private boolean confFileProvided =3D false;
> =20
> /** Creates new form ServerMainGUI. */
> public ServerMainGUI(java.awt.Frame pParent, boolean pModal)
> {
> super(pParent, pModal);
> initComponents();
> =20
> //Default configuration for the first run and while admin passwor=
d is default
> env =3D new Properties();
> env.put( "java.naming.security.authentication", "simple");
> env.put( Context.SECURITY_PRINCIPAL, "uid=3Dadmin,ou=3Dsystem" );
> env.put( Context.SECURITY_CREDENTIALS, "secret" );
> =20
> cfg =3D new MutableServerStartupConfiguration();
> =20
> setLocationRelativeTo(pParent);
> setTitle(ResourceBundle.getBundle("res/msg").getString("server_ma=
in_gui_title"));
> }
> =20
> /**
> * Enlarge the box to show the user what's wrong with it.
> */
> protected void printError(Throwable pError)
> {
> errorOptionalPanel.add(errorScrollPanel);
> Insets lBoxInsets =3D this.getInsets();
> errorOptionalPanel.setPreferredSize(new Dimension(this.getWidth()=
- (lBoxInsets.left + lBoxInsets.right),200));
> =20
> //compute the stack trace...
> ByteArrayOutputStream lOutputStream =3D new ByteArrayOutputStream=
();
> pError.printStackTrace(new PrintStream(lOutputStream));
> errorMessage.append(lOutputStream.toString());
> errorMessage.append(" ---\n");
> pack();
> }
> =20
> /**
> * Changes the configuration file path to use to load LDAP configurat=
ion file.
> */
> public void setConfigurationFile(String pConfFilePath)
> {
> confFieldValue.setText(pConfFilePath);
> confFieldValue.setToolTipText(pConfFilePath);
> confFileProvided =3D true;
> }
> =20
> /**
> * Start button reaction.
> */
> protected void stopServer()
> {
> ResourceBundle lBundle =3D null;
> try//For the case where a shema is missing we could want to catch
> //ClassNotFoundException for instance
> {
> lBundle =3D ResourceBundle.getBundle("res/msg");
> =20
> //Initializing environment
> statusFieldValue.setText(lBundle.getString("status_init_stop_=
env"));
> =20
> env.putAll( new ShutdownConfiguration().toJndiEnvironment() )=
;
> =20
> try
> {
> statusFieldValue.setText(lBundle.getString("status_init_s=
top"));
> InitialDirContext lDir=3D new InitialDirContext( env );
> env.clear();
> statusFieldValue.setText(lBundle.getString("status_stoppe=
d"));
> }
> catch (NamingException pError)
> {
> printError(pError);
> statusFieldValue.setText(lBundle.getString("status_not_st=
opped"));
> }
> finally
> {
> stopServer.setEnabled(false);
> startServer.setEnabled(true);
> }
> }
> catch (Throwable pError)
> {
> printError(pError);
> statusFieldValue.setText(lBundle.getString("status_not_stoppe=
d"));
> }
> }
> =20
> /**
> * Start button reaction.
> */
> protected void startServer()
> {
> ResourceBundle lBundle =3D null;
> try//For the case where a shema is missing we could want to catch
> //ClassNotFoundException for instance
> {
> lBundle =3D ResourceBundle.getBundle("res/msg");
> =20
> //Loading configuration or using the default one.
> if (confFileProvided)
> {
> statusFieldValue.setText(lBundle.getString("status_loadin=
g_conf"));
> ApplicationContext factory =3D new FileSystemXmlApplicati=
onContext( confFieldValue.getText() );
> cfg =3D ( ServerStartupConfiguration ) factory.getBean( "=
configuration" );
> env =3D ( Properties ) factory.getBean( "environment" );
> }
> =20
> //Initializing environment
> statusFieldValue.setText(lBundle.getString("status_init_start=
_env"));
> env.setProperty( Context.PROVIDER_URL, "ou=3Dsystem" );
> env.setProperty( Context.INITIAL_CONTEXT_FACTORY, ServerConte=
xtFactory.class.getName() );
> env.putAll( cfg.toJndiEnvironment() );
> =20
> =20
> try
> {
> statusFieldValue.setText(lBundle.getString("status_init_s=
tart"));
> //Starting server
> new InitialDirContext( env );
> statusFieldValue.setText(lBundle.getString("status_starte=
d"));
> }
> catch (NamingException pError)
> {
> printError(pError);
> statusFieldValue.setText(lBundle.getString("status_not_st=
arted"));
> }
> finally
> {
> stopServer.setEnabled(true);
> startServer.setEnabled(false);
> }
> =20
> }
> catch (Throwable pError)
> {
> printError(pError);
> statusFieldValue.setText(lBundle.getString("status_not_starte=
d"));
> }
> }
> =20
> /** This method is called from within the constructor to
> * initialize the form.
> * WARNING: Do NOT modify this code. The content of this method is
> * always regenerated by the Form Editor.
> */
> // <editor-fold defaultstate=3D"collapsed" desc=3D" Generated Code ">=
//GEN-BEGIN:initComponents
> private void initComponents()
> {
> errorScrollPanel =3D new javax.swing.JScrollPane();
> errorMessage =3D new javax.swing.JTextArea();
> mainPanel =3D new javax.swing.JPanel();
> infoPanel =3D new javax.swing.JPanel();
> confPanel =3D new javax.swing.JPanel();
> confFieldValue =3D new javax.swing.JLabel();
> confTitle =3D new javax.swing.JLabel();
> statusPanel =3D new javax.swing.JPanel();
> statusTitle =3D new javax.swing.JLabel();
> statusFieldValue =3D new javax.swing.JLabel();
> commandPanel =3D new javax.swing.JPanel();
> loadConf =3D new javax.swing.JButton();
> startServer =3D new javax.swing.JButton();
> stopServer =3D new javax.swing.JButton();
> errorOptionalPanel =3D new javax.swing.JPanel();
> errorScrollPanel.setMaximumSize(new java.awt.Dimension(500, 200))=
;
> errorMessage.setEditable(false);
> errorMessage.setFont(new java.awt.Font("Bitstream Vera Sans", 0, =
10));
> errorMessage.setBorder(null);
> errorMessage.setMaximumSize(new java.awt.Dimension(500, 200));
> errorScrollPanel.setViewportView(errorMessage);
> setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_C=
LOSE);
> mainPanel.setLayout(new java.awt.GridLayout(2, 0));
> mainPanel.setPreferredSize(new java.awt.Dimension(400, 95));
> infoPanel.setLayout(new java.awt.GridLayout(2, 0, 0, 2));
> confPanel.setLayout(new java.awt.BorderLayout(4, 0));
> confFieldValue.setText(java.util.ResourceBundle.getBundle("res/ms=
g").getString("default_conf_msg"));
> confPanel.add(confFieldValue, java.awt.BorderLayout.CENTER);
> confTitle.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 11=
));
> confTitle.setText(java.util.ResourceBundle.getBundle("res/msg").g=
etString("conf_label"));
> confPanel.add(confTitle, java.awt.BorderLayout.WEST);
> infoPanel.add(confPanel);
> statusPanel.setLayout(new java.awt.BorderLayout(4, 0));
> statusTitle.setFont(new java.awt.Font("Microsoft Sans Serif", 1, =
11));
> statusTitle.setText(java.util.ResourceBundle.getBundle("res/msg")=
.getString("status_label"));
> statusPanel.add(statusTitle, java.awt.BorderLayout.WEST);
> statusFieldValue.setText(java.util.ResourceBundle.getBundle("res/=
msg").getString("status_stopped"));
> statusPanel.add(statusFieldValue, java.awt.BorderLayout.CENTER);
> infoPanel.add(statusPanel);
> mainPanel.add(infoPanel);
> getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER);
> commandPanel.setLayout(new java.awt.GridLayout(4, 0));
> loadConf.setText(java.util.ResourceBundle.getBundle("res/msg").ge=
tString("conf_button_label"));
> loadConf.addActionListener(new java.awt.event.ActionListener()
> {
> public void actionPerformed(java.awt.event.ActionEvent evt)
> {
> loadConfActionPerformed(evt);
> }
> });
> commandPanel.add(loadConf);
> startServer.setText(java.util.ResourceBundle.getBundle("res/msg")=
.getString("start_button_label"));
> startServer.addActionListener(new java.awt.event.ActionListener()
> {
> public void actionPerformed(java.awt.event.ActionEvent evt)
> {
> startServerActionPerformed(evt);
> }
> });
> commandPanel.add(startServer);
> stopServer.setText(java.util.ResourceBundle.getBundle("res/msg").=
getString("stop_button_label"));
> stopServer.setEnabled(false);
> stopServer.addActionListener(new java.awt.event.ActionListener()
> {
> public void actionPerformed(java.awt.event.ActionEvent evt)
> {
> stopServerActionPerformed(evt);
> }
> });
> commandPanel.add(stopServer);
> getContentPane().add(commandPanel, java.awt.BorderLayout.EAST);
> errorOptionalPanel.setLayout(new java.awt.BorderLayout());
> getContentPane().add(errorOptionalPanel, java.awt.BorderLayout.SO=
UTH);
> pack();
> }
> // </editor-fold>//GEN-END:initComponents
> =20
> private void loadConfActionPerformed(java.awt.event.ActionEvent evt)/=
/GEN- FIRST:event_loadConfActionPerformed[vbco
l=seagreen]
> {//GEN-HEADEREND:event_loadConfActionPerformed
> JFileChooser lConfFileChooser =3D new JFileChooser();
> =20
> lConfFileChooser.setDialogTitle(ResourceBundle.getBundle("res/msg=[/vbcol]
").getString("conf_selection_title"));
> int lReturnVal =3D lConfFileChooser.showOpenDialog(this);
> if(lReturnVal =3D=3D JFileChooser.APPROVE_OPTION)
> {
> setConfigurationFile(lConfFileChooser.getSelectedFile().toStr=
ing());
> }
> }//GEN-LAST:event_loadConfActionPerformed
> =20
> private void stopServerActionPerformed(java.awt.event.ActionEvent evt=
)//GEN- FIRST:event_stopServerActionPerformed[vb
col=seagreen]
> {//GEN- HEADEREND:event_stopServerActionPerforme
d
> stopServer();
> }//GEN-LAST:event_stopServerActionPerformed
> =20
> private void startServerActionPerformed(java.awt.event.ActionEvent ev=[/vbcol]
t)//GEN- FIRST:event_startServerActionPerformed[v
bcol=seagreen]
> {//GEN- HEADEREND:event_startServerActionPerform
ed
> startServer();
> }//GEN-LAST:event_startServerActionPerformed
> =20
> /**
> * The manager main entry point.
> * @param pArgs the command line arguments
> */
> public static void main(String pArgs[])
> {
> try
> {
> //Setting the look and feel to the current system laf
> UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassN=[/vbcol]
ame());
> }
> catch (Throwable pError)
> {
> System.err.println(pError.getMessage());
> }
> =20
> ServerMainGUI lGUI =3D new ServerMainGUI(null, true);
> =20
> String lLDAP_SERVER_CONF =3D System.getenv("LDAP_SERVER_CONF");
> if (lLDAP_SERVER_CONF !=3D null)
> lGUI. setConfigurationFile(lLDAP_SERVER_CONF);
> =20
> if ( pArgs.length > 0 )
> lGUI.setConfigurationFile(pArgs[0]);
> =20
> lGUI.setVisible(true);
> }
> =20
> /**
> * Stop the server when living the GUI manager
> */
> public void dispose()
> {
> stopServer();
> super.dispose();
> }
> =20
> =20
> // Variables declaration - do not modify//GEN-BEGIN:variables
> private javax.swing.JPanel commandPanel;
> private javax.swing.JLabel confFieldValue;
> private javax.swing.JPanel confPanel;
> private javax.swing.JLabel confTitle;
> private javax.swing.JTextArea errorMessage;
> private javax.swing.JPanel errorOptionalPanel;
> private javax.swing.JScrollPane errorScrollPanel;
> private javax.swing.JPanel infoPanel;
> private javax.swing.JButton loadConf;
> private javax.swing.JPanel mainPanel;
> private javax.swing.JButton startServer;
> private javax.swing.JLabel statusFieldValue;
> private javax.swing.JPanel statusPanel;
> private javax.swing.JLabel statusTitle;
> private javax.swing.JButton stopServer;
> // End of variables declaration//GEN-END:variables
> }
> Now you can make a symbolic link under windows with a target like this:
> javaw -cp main.jar confFile.xml
> or main.jar if the environment variable describe below has been defined.
> This GUI can also been feed with LDAP_SERVER_CONF system environment vari=
able.
> Launching it without configuration file will create a new working dir wit=
h admin default password authentication : "secret"
> This GUI is aimed to help non skilled users with apacheds server at deplo=
yment site.
> If you think it is not interseting, just forget it.
> Tony
--=20
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[ Post a follow-up to this message ]
|