Friday, May 24, 2013

Linux distributions


Linux is one of the leading open source projects in the world, but what is Linux, we have many "Linuxes" - red hat, blue cat, ubuntu, suse so what does it means that all of them are Linux. well, Linux is a standard there are set of rules that if you wish to be Linux you have to satisfy, these rules are in two different standards - POSIX and GNU, POSIX talk about rules for the core of the operating system mainly the kernel and stands for portable operating system interface and GNU stands for gnu not Unix specify applications that complete the Unix standard. Every distribution has to implement these standards so it can be called Linux.
One of the rules is the license of Linux that should be open source and free to download. And usually each Linux distribution builds from a Linux program. The distributers download the code and then add and modify the code for a new Linux, this new version usually called Linux distribution.
I would like to present some of the popular distribution of Linux:

Ubuntu: Ubuntu is distributions that focus on the user and try to provide him easy interface for his work, many feature like plug & play and easy installation are provided in ubuntu. 
Today many users that wish to work at home with Linux work with Ubuntu and it became real (small) competitor for windows.

Red Hat: The biggest distribution for enterprise Linux, the main advantage of the red hat distribution is application called RPM that allow you to update software automatically and in very easy way. the red hat is of course free of charge but if you wish you can be connected to the red hat servers and update your Linux automatically for money. this is highly important feature for enterprise companies who has large number of servers and need to maintain them constantly and be up to date as soon as possible due to critical systems that run on these Linux servers.

Suse: also well known large distributer of Linux, developed by novel and consider to be very reliable and effective Linux distribution. One of the major advantages of Suse Linux is the interoperability with Windows and Microsoft technology so working in this hybrid environment becomes much easy.

Blue cat: this Linux distribution is used for embedded and real-time system it allows you to configure your kernel and customize it to be suitable for embedded systems, remove the mouse and keyboard from the kernel. 

Monday, May 20, 2013

Preform background operation with swing worker

Hi,
I think that one of the suffering things in UI is making a progress bar, you need to update it constantly while the operation is invoked by another thread and calculate the progress of the task.
From java 6.0 we have a new utility that help us with that called SwingWorker.
SwingWorker is an abstract class that you can extend and the abstract method called doInBackground  that allow it to preform background operations. SwingWorker also can update the progress bar with the process method and by firing events for changes in the progress bar.
Let's see an example
In our example, we would like to send mails in the background for large number of users that defined in the Swing application. once the submit button is press the application will send the content of the mail to all the users, let's see the code of the application:

public class Application extends JFrame {
 
  // The UI Components
  private JProgressBar progressBar;
  private JTextArea mails;
  private JTextArea message;
  private JButton sendMails;
  private JLabel status;
 
  public Application(){
   setSize(600, 600);
   message = new JTextArea();
   JPanel rightPanel = new TextAreaPanel(new JLabel("message"), message);
   add(rightPanel, BorderLayout.EAST);
   mails = new JTextArea();
   JPanel leftPanel = new TextAreaPanel(new JLabel("mails"), mails);
   sendMails = new JButton("send it!");
   add(leftPanel, BorderLayout.WEST);
   add(sendMails, BorderLayout.NORTH);
   progressBar = new JProgressBar();
   progressBar.setStringPainted(true);
   add(progressBar, BorderLayout.SOUTH);
   sendMails.addActionListener(new ActionListener() {
  
  @Override
  public void actionPerformed(ActionEvent e) {
   String addresses = mails.getText();
   String[] add = addresses.split("\n");
   SendMailsWorker worker = new SendMailsWorker(message.getText(), add);
   // A property listener used to update the progress bar
      PropertyChangeListener listener = 
                                 new PropertyChangeListener(){
        public void propertyChange(PropertyChangeEvent event) {
          if ("progress".equals(event.getPropertyName())) {
            progressBar.setValue( (Integer)event.getNewValue() );
          }
        }
      };
      worker.addPropertyChangeListener(listener);
   worker.execute();
   
  }
 });
  }
  
 
  // The main method
  public static void main(String[] args){
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        Application app = new Application();
        app.setDefaultCloseOperation(EXIT_ON_CLOSE);
        app.pack();
        app.setVisible(true);
      }
    });
    System.out.println("finish main");
  }
}

// and another class for handling the panel is
public class TextAreaPanel extends JPanel{

 public TextAreaPanel(JLabel label, JTextArea text) {
  text.setPreferredSize(new Dimension(120, 120));
  add(label, BorderLayout.WEST);
  add(text, BorderLayout.CENTER);
 }
}

The action of sending the mail should be in the background, therefore, we should create a swing worker that handle the task, let's see it
public class SendMailsWorker extends SwingWorker {

 private final String message;
 private final String[] addresses;

 public SendMailsWorker(String mes, String[] mails) {
  message = mes;
  addresses = mails;
 }

 @Override
 protected Integer doInBackground() throws Exception {
  int matches = 0;
  for (int i = 0, size = addresses.length; i < size; i++) {
   // Update the status: the keep an eye on thing
   publish("send mail to: " + addresses[i]);
   matches += sendMail(message, addresses[i]);
   setProgress((i + 1) * 100 / size);
  }
  return matches;
 }

 private int sendMail(String message2, String string) {
  // sending the mail
  try {
   Thread.sleep(10000);
  } catch (InterruptedException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  return 1;
 }

 @Override
 protected void process(List chunks) {
  for (String message : chunks) {
   System.out.println(message);
  }
 }
 
 @Override
 protected void done() {
  System.out.println("finish sending mails");
  super.done();
 }
}
as you can see from the code, the operation of sending the mail is done by the SendMailWorker that extend SwingWorker. the method doInBackground preform the operation and set the progress so than you can write to the console or to any other place the progress of the writing. I think SwingWorker is very nice utility that simplify the ability to preform background operations.

Sunday, May 12, 2013

What is my problem with Microsoft technology

As an architect that working in the software industry almost 15 years I came across many technologies some are great and some of them are not so great...
In this post i would like to refer to technologies that came from specific vendor - Microsoft.
As you probably can see from my blog name i'm a java person and i don't have a lot of experience in Microsoft technology. I did some projects that related to .NET and Microsoft but i'm not expert.
Generally, i can say that .NET is pretty good framework, some of the things i like some are not but I think this framework contribute a lot to the software industry.
However, The Microsoft technology has one big flow, it refuses to collaborate with many other technologies that exist in the world. for example, last week i lectured about ALM and architecture and one of the listeners ask me if TFS (the Microsoft ALM tool) can work with subversion. The ALM guy that run the user group ask her why she would like to use subversion you can use Microsoft tools instead. this is of course a Microsoft user group...
The philosophy of we will provide you anything that you need and you can't use any other technology is annoying. I personally believe that each framework, tool or language are means to do my job better and every one of them should be used differently according to the circumstances.
If you are eating steak you should do it with fork and knife and not with spoon. it doesn't mean the spoon is redundant t just means that it doesn't feet for me right now.
No company not matter how big it is can't provide solutions to all the use cases in the world, therefore, good technology is a technology that can integrate easily with other technologies.
More than that, Microsoft prove that when it is important for them they can do it better than anyone else, you can see it in the integration inside Microsoft technology and also in there cloud solution, azure.
So i hope Azure is a good start in this direction and hopefully Microsoft technology will be more open for integration with other technologies in the near future.  

Tuesday, May 7, 2013

My lecture about SOLR in the SDP

Hi,
Yesterday i was lecturing about SOLR in the SDP, it's the larget confrence of sela with international speakers about many technology mainly in Microsoft technology - www.seladeveloperpractice.com 
The presentation of Solr can be found here.
Enjoy :-)


Wednesday, May 1, 2013

cloud & ALM

I wrote nice presentation about the changes of the cloud and the implications about ALM and architecture.
You can find the presentation here:

enjoy!