Showing posts with label development. Show all posts
Showing posts with label development. Show all posts

Wednesday, May 9, 2012

DbSchema - An impressive DB Tool!

Today, while I was looking for a suitable tool to reverse engineer a PostgresSQL database to an ERD, I came across with this amazing tool:

DbSchema by WiseCoders.com

It turns out to be an impressive tool. The neat and crisp layout and the ease with which I was able to reverse engineer the database to an ERD was simply amazing!

Saturday, October 22, 2011

Pitching my Idea, “SPAM” @ Karachi Startup Weekend in IBA, Karachi University

I pitched my idea “SPAM – Software Project Artifacts Management” System on 21st of October 2011 @ Karachi Startup Weekend in IBA, Karachi University. My idea did not make it to the final list of 12 short listed ideas Sad smile. However, I was successful in forming a Team during the Networking Phase and will be working with the Team in next 2 days to come up with a comprehensive Proposal Plan for the VCs and Judges Smile

Thursday, January 14, 2010

Setting Null value (reflectively) using Apache Common’s PropertyUtils

If you have a requirement to set a Null value (reflectively) to a property of an object using Apache Commons than following method won’t work for you:

BeanUtils.setProperty(Object bean, String propertyName, Object value);

And neither does this one:

PropertyUtils.setProperty(Object bean, String propertyName, Object value);

The reason is that both method uses ConvertUtils to convert values of source type to a destination type. The default set of converters which are registered with BeanUtils have a default value specified and this is why you can’t set a null value using default settings. If you want null values to be set then you need to register converter implementations for those types with a default value of null. So for example you would do something like...

ConvertUtils.register(new IntegerConverter(null), Integer.class);
ConvertUtils.register(new DoubleConverter(null), Double.class);


(Note: the "null" value in the constructors is the default value)

Alternatively, you can also achieve this by following statement:

PropertyUtils.getWriteMethod(PropertyUtils.getPropertyDescriptor(this,propertyName)).invoke(this, new Object[]{null});

Monday, August 10, 2009

Development by Example: Maven & Archiva

Setup Maven:

  1. Download and Install latest Maven bundle.
  2. If you are accessing Internet via some proxy on your home and/or office networks than make sure you configured these proxy server settings in Maven Settings file.
  3. For example I’ve two proxy servers at my office network and one at home, and part of my maven settings file looks like this:
    proxy
  4. Notice how I enabled my desired proxy server using <active>true</active>. There were cases when I have direct access to internet with out any proxy servers in between and in such cases all I had to do is to make sure “active” property of all of my proxy server settings are set to ‘false’.

Setup Archiva:

  1. Pre-requisite Tomcat 5.5+
  2. Download latest Archiva
  3. Install it as a WAR, the easiest way.
  4. Use embedded derby DB, no fancy stuff.
  5. Goto Archiva web administration area http://<server>:<port>/archiva/ and configure your admin user
  6. By clicking on “Repositories” button from the lhs menu, you can view following preconfigured repositories:
    1. Two Managed Repositories
      1. Archiva Managed Internal Repository
        int-repo1
      2. Archiva Managed Snapshots Repository
        int-repo2
    2. Two Remote Repositories
      1. Central Repository
      2. Java.net Repository for Maven 2
        remote-repos
  7. Although, we can use above preconfigured repositories as it is, but for more clarity, we’ll going to do following changes
    1. Repository name of “Archiva Managed Internal Repository” to “Archiva Managed Internal Release Repository”
    2. Repository directory from “../internal” to “../releases”
    3. Repository URL from
      “http://server:port/archiva/repository/internal/”
      to
      “http://server:port/archiva/repository/releases/”
    4. Repository name of “Archiva Managed Snapshots Repository” to “Archiva Managed Internal Snapshot Repository”
  8. While changes to name and directory can be done by simply editing the repository record, the changes to URL can’t. So we will going to delete “Archiva Managed Internal Repository” and create a new record as follows:
    1. Select “Repositories” from the left hand side menu of Archiva web application. Then from the list of repositories click on “Delete” option of “Archiva Managed Internal Repository”del-internal-repo
      Click on “Delete Configuration and Contents”.
    2. Again, select “Repositories” from the left hand side menu. Then click on “Add” option on the top right hand side of the page. Create new “Archiva Managed Internal Release Repository as follows
      internal-releases-repo
  9. Because we don’t have to change the URL of “Archiva Managed Snapshots Repository” we can simply edit to make needed changes. Goto “Repositories”, click on “Edit” option from the “Archiva Managed Snapshots Repository” and change name from “Archiva Managed Snapshots Repository” to “Archiva Managed Snapshot Repository”:
    edit-snapshot-repo
  10. As shown in diagram below, all artifact requests from your maven clients should be directed to Archiva server which, on the bases of artifact type, release or snapshot, try to search in (local) internal repositories. If a matching artifact found than Archiva will serve the request directly, else, it will forward this request to other Remote repositories available over internet for resolution. Once, an artifact is recieved from remote repository, it will be cached first, in (local) internal repositories and then sent to the client as a response to its initial request.
    maven
  11. Next, we’ll going to configure network proxies. Select “Network Proxies” from left hand side menu of Archiva web application. Then, click on “Add” button on the top right hand side of the page. Fill the form with your network’s proxy information and click “Save Network Proxy”.
    add-network-proxy
  12. Repeat step 11 to create as many proxies as you wish
  13. Now, we’ll going to create proxy connectors where each local or internal repository will be configured as a proxy to external or remote repositories.
  14. Click on “Proxy Connectors” from the left hand side menu, then select “Add” option from the top right hand side of the page and fill the form as follows:
    add-proxy-con1
    Do note “White List” entry
  15. Repeat the step again with following values
    add-proxy-con2 Do note “White List” entries
  16. Repeat the step again with following values
    add-proxy-con3
  17. Repeat the step again with following values
    add-proxy-con4
  18. Now your Proxy Connectors list will look like this
    proxy-con-list1
    proxy-con-list2

Configure local internal repositories in your Maven Settings file:

  1. Create a new profile to configure newly created archiva managed repositories as follows:
    profile1
    profile2
  2. Profiles and their activation is a very handy feature because you can create as many profiles as you like and can activate or deactivate them based on different network environments.
  3. For example, there were cases when our Archiva Server hosting both internal Releases and Snapshots repositories was unavailable for some time. I simply deactivated “archiva” profile from my system’s maven settings file. I was then using remote maven repositories directly via internet. No idle time, no delay, no hurdles.
  4. Do note that we are using same repositories for plugins as well.

Ok, now you are all set to start using local internet repositories. Go ahead create a new project. Once done, point your browser to archiva web application. Click “Browse” from the left hand side menu, you can view all those groups, sub groups and artifacts which have been cached and served to the maven client up till now.

The story doesn’t ends here. We are still short of deploying our custom artifacts to local internal repositories.

Deploying to local internal repositories:

  1. In order to deploy your custom artifacts to local internet repositories, you need network access to machine hosting archiva repositories.
  2. Open your maven’s settings file and add server credentials as follows:
    server
  3. Now, open your project’s POM file add following:
    dm
  4. All set, run maven’s deploy command and then browse your project’s artifact on archiva web application to verify that your it is uploaded successfully.

Saturday, August 8, 2009

Project Lombok – Rich Beans without any clutter

Project Lombok modifies your development environment to enable extra java language features. Right now lombok can inject itself into both javac and eclipse and offers both Automatic Resource Management and generating getters, setters, equals, hashCode, and toString, and a couple of other features. A screencast takes you through how it works and even shows you how to install it, and clocks in at less than 4 minutes. It's open source (MIT license).

Tuesday, January 8, 2008

Persistence (JDBC, Hibernate, JPA, EJB) Tier Code Generator

FireStorm/DAO is a Java Code Generator that can import existing database schemas (from a SQL script or from a live JDBC connection) and can then generate a complete persistence tier based on any of the following Java persistence technologies:

  • Java Database Connectivity (JDBC)
  • Java Persistence API (JPA)
  • Enterprise JavaBeans (EJB)
  • Hibernate Java Persistence

FireStorm/DAO generates Java source code and configuration files that developers would otherwise have to write by hand. FireStorm/DAO generates code that is compliant with the Data Access Object (DAO) design pattern (DAO is a core J2EE design pattern). FireStorm/DAO can also generate native persistence code for Object Relational Mapping (ORM) products (such as Hibernate or JDO-based products).

Tuesday, December 25, 2007

JAXX: New way to Swing

A very promising framework for Swing based development. Check out its key features that separates it from the rest. A look at the roadmap might also help to determine its future course of direction.

Thursday, November 15, 2007

J2ME Development with NetBeans + J2mePolish + BlackBerry


Working with J2ME, NetBeans, NetBeans Mobility Pack, J2mePolish and BlackBerry is not an easy task for sure. After spending nights I've managed to put up a workable development environment "that works". For all those out there, who are working on the same or planning to work in near future, following is a step by step procedure which will be helpful in setting up things quickly.

Pre-Requisites:

  1. NetBeans 5.5
    1. Download: http://www.netbeans.info/downloads/index.php?rs=11
    2. Installation Instructions: http://www.netbeans.org/community/releases/55/install.html

  2. NetBeans Mobility Pack for CLDC
    1. Download: http://www.netbeans.info/downloads/index.php?p=4
    2. Installation Instructions: http://www.netbeans.org/community/releases/55/1/mobility-install.html

  3. J2mePolish 2.0 RC4
    1. Download: http://www.j2mepolish.org/download.html
    2. Installation Instructions: http://www.j2mepolish.org/docs/install.html

  4. BlackBerry JDE 4.2.1
    1. Download: https://www.blackberry.com/CorpDevZone/sd2integration.do?file=https://www.blackberry.com/Downloads/contactFormPreload.do?code=00EC53C4682D36F5C4359F4AE7BD7BA1&dl=082B317A6A9BDCF567A66673A23C2763
    2. NOTE: You need to sign in to download (Sign up is Free)
    3. Installation Instructions: Follow the installation wizard instructions.
  5. BlackBerry Email and MDS Services Simulator
    1. Download: https://www.blackberry.com/CorpDevZone/sd2integration.do?file=https://www.blackberry.com/Downloads/contactFormPreload.do?code=00EC53C4682D36F5C4359F4AE7BD7BA1&dl=A863E2C10B7E517A09C80F83418E8B2D
    2. NOTE: You need to sign in to download (Sign up is Free)
    3. Installation Instructions: Follow the installation wizard instructions.

Configuration:

  1. Adding BlackBerry JDE 4.2.1 as a Custom Emulator:
    1. Open NetBeans IDE
    2. Select Tools > Java Platform Manager
    3. Click the Add Platform button
    4. Select Custom Java Micro Edition Platform Emulator. Click Next.
    5. Browse BlackBerry JDE 4.2.1 installation directory (C:\Program Files\Research In Motion\BlackBerry JDE 4.2.1)
    6. Enter desired Platform Name (RIM BlackBerry JDE 4.2.1)
    7. Enter desired Device Name (8800)
    8. Keep the Preverify command as it is
    9. Modify Execution and Debugger command as follows:
      1. Execution Command:
        cmd /C "cd /D {platformhome}{/}simulator&{device}"
      2. Debugger Command:
        cmd /C "cd /D {platformhome}{/}bin&jdwp"
    10. Click Next
    11. Select all listed files except net_rim_api.jar and click Remove.
    12. Click Next.
    13. Click the Add button next to JavaDoc panel and browse to /docs/api folder inside the BlackBerry JDE Installation directory (C:\Program Files\Research In Motion\BlackBerry JDE 4.2.1\docs\api)
    14. Click Finish and then click Close.

Creating a New Project:

  1. Select File > New Project
  2. Click Next
  3. Enter Project Name, select Project Location and click Next
  4. Select desired Configurations, Profiles/Platforms, Libraries and Devices. Click Next.
  5. Leave Specify Project Properties panel as it is and click Next.
  6. Click on the Files tab and create /dist and /source/src folders under the project root folder.
  7. Click on the Projects tab, then right click on TestProject and select New > Java Package
  8. From the Projects tab, right click on newly created test package and select New > Midlet
  9. Enter desired Midlet Name, Midlet Class Name and select Package. Click Finish.
  10. From the Projects tab, right click on TestProject and select Properties.
  11. From the Category list, click on Platform, select BlackBerry JDE 4.2.1 from the Emulator Platform drop down list and select Ok.
  12. From the Category list, select MIDlets under Application Descriptor and make sure TestMidlet entry is there.
  13. From the Category list, select Libraries & Resources and make sure enough-j2mepolish-client.jar is there with its correct path. For example, C:\Program Files\J2ME-Polish\import\enough-j2mepolish-client.jar. You may witness incorrect path like C:\Program Files\J2ME-Polish\import\C:\Program Files\J2ME-Polish\import\enough-j2mepolish-client.jar
  14. Click Ok.
  15. From the Files tab, double click on build.xml to open it in editor.
  16. Enter two new properties blackberry.home and polish.blackberry.verbose in the build.xml file as show below:
  17. Update general settings to match your desired settings
  18. Set your desired Device Requirement
  19. Remove /base from resources and root dir paths. Also comment out ProGuard obfuscator.
  20. For testing purpose, write code to connect to http://www.google.com/ and then print the google’s home page’s html on the debugger console.
    p16
    p16-2
    Click here to download TestMidlet.java
  21. Run the BlackBerry MDS Simulator, a console window will open, minimize it and do not close it during development and testing.
  22. Run the JDWP module i.e. the BlackBerry debugger
  23. Now, from the Projects tab in the NetBeans IDE, right click on the TestProject node and select Debug Project.
  24. You will notice activities in the debug window and then debug console. Finally, the BlackBerry emulator will start; it will then try to connect to the debugger and then display the blackberry menu.
  25. Click on the console icon named “Blank” and then watch the JDWP’s debugger console, which shows all activities and console logs. You will notice that Google’s home page’s html is printed on the console.
  26. Finish.