Thursday, September 27, 2012

From Ruby to Java with interactive Tutor canal.

Main difference with Java

As with Java, in Ruby,...

  • Memory is managed for you via a garbage collector.
  • Objects are strongly typed.
  • There are public, private, and protected methods.
  • There are embedded doc tools (Ruby's is called RDoc). The docs generated by rdoc look very similar to those generated by javadoc.

Differences

Unlike Java, in Ruby,...
  • You don't need to compile your code. You just run it directly.
  • There are several different popular third-party GUI toolkits. Ruby users can try WxRuby, FXRuby, Ruby-GNOME2, or the bundled-in Ruby Tk for example.
  • You use the end keyword after defining things like classes, instead of having to put braces around blocks of code.
  • You have require instead of import.
  • All member variables are private. From the outside, you access everything via methods.
  • Parentheses in method calls are usually optional and often omitted.
  • Everything is an object, including numbers like 2 and 3.14159.
  • There's no static type checking.
  • Variable names are just labels. They don't have a type associated with them.
  • There are no type declarations. You just assign to new variable names as-needed and they just "spring up" (i.e. a = [1,2,3] rather than int[] a = {1,2,3};).
  • There's no casting. Just call the methods. Your unit tests should tell you before you even run the code if you're going to see an exception.
  • It's foo = Foo.new( "hi") instead of Foo foo = new Foo( "hi" ).
  • The constructor is always named "initialize" instead of the name of the class.
  • You have "mixin's" instead of interfaces.
  • YAML tends to be favored over XML.
  • It's nil instead of null.
  • == and equals() are handled differently in Ruby. Use == when you want to test equivalence in Ruby (equals() is Java). Use equal?() when you want to know if two objects are the same (== in Java).
If you're really want to Ruby has a Kick Start , here is the interactive Tutor session given by Ruby. Learn Ruby within 20mins  http://tryruby.org/levels/1/challenges/0 

Get Familiar with Apache Ant Commands :-)

How to do following tasks in ant file?
  1. Make zip file.
  2. Run command.
  3. Copy files to remote machine.
  4. Run commands on Remote Linux machine.
  5. Open an input box and respond to input value.
  6. Make an ant call.
Answers:

1. Make zip file:

Following is the xml for making zip file in ant:

1 <zip destfile='${destination.folder}/zipName.zip'>
2      <fileset dir= '${Source.folder}' />
3 </zip>
In here "destfile" is the name and location of the created zip file. Inside fileset tag the dir attricute is used to specify source folder form where all files will be zipped.

2. Run commands:

Here I will show you how to start tomcat in ant file to demonstrate how to run commands in ant. Following is the xml for this:

1 <exec dir='${tomcat.home}/bin' executable='cmd' os='Windows XP'>
2      <arg line='/c startup.bat'/>
3 </exec>
Here "${tomcat.home}" is the path of the tomcat folder. The command is given in "<arg>" tag in "line" attribute.

Note: To run following commands you will need JSCH jar.

3. Copy files to remote machine:

1 <copy file='${source.folder.file} ' todir='\\remote\path'>
2 </copy>
To copy files on remote machine that supports SCP use following tag:

1 <scp file='${source.folder.file} ' todir='${remote.user}@${remote.host}:${remote.path.where.to.do.copy}'
2        password='${remote.password}' trust='true'>
3 </scp>
In above both commands "file" is the source file which you want to copy with its path. And "todir" is the remote machine folder path where you want to copy the file.

4. Run commands on remote machine:

You can use following tag to execute commands on remote Linux machine.

1 <sshexec host='${remote.host}' username='${remote.username}' password='${remote.password}'
2      command='${command.to.run}' trust='true' />

1 <sshexec host='${remote.host}' username='${remote.user}' password='${remote.password}'
2          command='sh ${tomcat.home}/startup.sh' trust='true' />

5. Open an input box and respond to input value:

To open an input dialog use following tag:

1 <input message='Enter id: ' addproperty='my.id'>
2 </input>
Here "my.id" in "addproperty" is the variable name which holds input value. Now to check if user has denied to enter value in input:
1 <condition property='do.abort'>
2      <equals arg1='n' arg2='${my.id}'/>
3 </condition>
4 <fail if='do.abort'>Build aborted by user.</fail>
And if user enters value and press OK then after you can refer to entered value as "${my.id}".

6. Make an ant call:
1 <antcall target='targetName'>
2 </antcall>
Here "target" is the name of the target that will be executed.

Note: In above examples all values starting with "${"and ending with "}'' are variables and you may have to put appropriate values in them to successfully run them.

Monday, September 24, 2012

what is coming in EJB 3.2 ?

  • Support for the following features has been made optional in this release and their description is moved to a separate EJB Optional Features document:

    • EJB 2.1 and earlier Entity Bean Component Contract for Container-Managed Persistence

    • EJB 2.1 and earlier Entity Bean Component Contract for Bean-Managed Persistence

    • Client View of an EJB 2.1 and earlier Entity Bean

    • EJB QL: Query Language for Container-Managed Persistence Query Methods

    • JAX-RPC Based Web Service Endpoints

    • JAX-RPC Web Service Client View


  • Support for local asynchronous session bean invocations and non-persistent EJB Timer Service has been added to the EJB 3.2 Lite set of features

  • Restriction on obtaining the current class loader has been removed

  • Access to Java I/O has been relaxed, replacing 'must not' with 'should exercise caution'

  • Lifecycle callback interceptor methods of stateful session beans can now be executed in a transaction context (determined by the lifecycle callback method's transaction attribute)

  • It is now possible to completely disable passivation of a specific stateful session bean

  • TimerService API has been extended for an ability to query all active timers in the same EJB module

  • Default rules for designating implemented interfaces for a session bean as local or as remote business interfaces has been relaxed to include more than one interface (see examples in the document for the detailed rules)

  • List of standard activation properties for JMS message-driven beans has been extended to match the changes in the JMS 2.0 specification

  • A unique identifier of a JMS message-driven bean can be now looked up by a standard name by the JMS resource adapter to construct a subscription name








--

Regards
Ganesh Babu G


Tuesday, September 18, 2012

News: Convert Your Java byte Code to path to iPad, iPhone apps

With the open source release of J2ObjC, Google has authored a translator to convert Java source code into Objective-C source for iPhone and iPad applications. The intent is to enable developers to write an application's non-UI code, such as data access code or application logic, in Java. Apple has not permitted Java to run on its iOS systems (though Java code can be part of an iOS application build), while Objective-C is Apple's development language of choice for the devices.

"J2ObjC is not a Java emulator but instead converts Java classes to Objective-C classes that directly use the iOS Foundation Framework," Google engineer Tom Ball said in a blog post. "It supports the full Java 6 language and most of its runtime features that are required by client-side application developers, including exceptions, inner and anonymous classes, generic types, threads, and reflection. JUnit test translation and execution is also supported. J2ObjC can be used with most build tools, including Xcode and Make."

New URL : - http://www.computerworld.com/s/article/9231282/Google_s_Java_translator_eases_path_to_iPad_iPhone_apps?source=CTWNLE_nlt_app_2012-09-17


Wednesday, September 12, 2012