Annotations Part 2
19/09/08 21:30 Filed in: J2EE
In this example I have created my own annotation. With
the declaration of the annotation you can add
additional functionality to any Java class.
In this case I have define the possibility to add the toString functionality to the different getter methods of the Java class. The System.out.println with the argument an instance of the Java class is now possible. For each attribute of the Java class the toString() method is defined and therefore the printing of the Java class is translated into printing the individual attributes.
Check-out the code...
In this case I have define the possibility to add the toString functionality to the different getter methods of the Java class. The System.out.println with the argument an instance of the Java class is now possible. For each attribute of the Java class the toString() method is defined and therefore the printing of the Java class is translated into printing the individual attributes.
Check-out the code...
|
Annotations Part 1
19/09/08 21:04 Filed in: J2EE
With annotations the programmer is relieved from
writing boilerplate code. The code becomes more
maintainable.
Annotations are like meta-tags that you can add to your code and apply them to package declarations, type declarations, constructors, methods, fields, parameters, and variables. As a result, you can indicate whether your code has dependencies on other code.
Using annotations lead to declarative programming. The programmer tells the java compiler what should be done and the tool executes the task. With annotations you configure behavior using independent code.
There are two things you need to consider with annotations. One is the "annotation" itself, the other one is the "annotation type". An annotation is the meta-tag that the programmer can use in the java code to give it some life. The annotation type is used for defining an annotation. You will use it when you want to create your own custom annotation. The type is the actual construct used, and the annotation is the specific usage of that type.
In the code example we are using the pre-deined annotations @Deprecated, @SuppressWarnings and @Override:
Check-out the code...
Annotations are like meta-tags that you can add to your code and apply them to package declarations, type declarations, constructors, methods, fields, parameters, and variables. As a result, you can indicate whether your code has dependencies on other code.
Using annotations lead to declarative programming. The programmer tells the java compiler what should be done and the tool executes the task. With annotations you configure behavior using independent code.
There are two things you need to consider with annotations. One is the "annotation" itself, the other one is the "annotation type". An annotation is the meta-tag that the programmer can use in the java code to give it some life. The annotation type is used for defining an annotation. You will use it when you want to create your own custom annotation. The type is the actual construct used, and the annotation is the specific usage of that type.
In the code example we are using the pre-deined annotations @Deprecated, @SuppressWarnings and @Override:
- With @Deprecated you can mark any method to be deprecated. In case the specific method is called from other Java code, the IDE will give a warning “deprecated method used”
- With @SuppressWarnings you can mark any method. In that case the warning “deprecated method used” will be suppressed e.g. in case that method calls another deprecated method
- With marking a method with @Override you need to provide an implementation of the method. Otherwise you will get a warning
Check-out the code...
Reorganize Calendar, Addresses & Bookmarks
19/09/08 13:50 Filed in: Tips &
Tricks
I would suggest to manage your calendar, addresses and
bookmarks on your MacBook.
Of course you can add appointments on your iPhone or MobileMe, but prepare the iCal groups and settings on the computer before that. The same applies to managing groups in your Address Book and setting other options.
You probably gather a lot of Internet bookmarks surfing using the MacBook or your iPhone. However organizing the bookmarks is difficult using the iPhone. So manage them on your MacBook.
An option is creating a Bookmark folder for temporarily holding the Bookmarks created on the iPhone. At regular times you sync the Bookmarks from the iPhone to the MacBook. Now you can organize all the Bookmarks on the MacBook.
Of course you can add appointments on your iPhone or MobileMe, but prepare the iCal groups and settings on the computer before that. The same applies to managing groups in your Address Book and setting other options.
You probably gather a lot of Internet bookmarks surfing using the MacBook or your iPhone. However organizing the bookmarks is difficult using the iPhone. So manage them on your MacBook.
An option is creating a Bookmark folder for temporarily holding the Bookmarks created on the iPhone. At regular times you sync the Bookmarks from the iPhone to the MacBook. Now you can organize all the Bookmarks on the MacBook.
Last resort: Force Restore Mode With iPhone
19/09/08 13:37 Filed in: Tips &
Tricks
It could happen the iPhone isn’t responding at all. No
ordinary documented trick is helping you e.g. pressing
the sleep and home button both for 10 seconds,
connecting to iTunes doesn’t help either.
I found the following instructions for forcing the iPhone to go into restore mode.
WARNING: This solution should be used as a last restort. All the information on your iPhone will be cleared and it will be reset to factory defaults.
Follow the instructions:
I found the following instructions for forcing the iPhone to go into restore mode.
WARNING: This solution should be used as a last restort. All the information on your iPhone will be cleared and it will be reset to factory defaults.
Follow the instructions:
- Turn off the iPhone by either holding down the sleep button, or use sleep together with the home button. Release the buttons as soon as the screen shuts off.
- Hold down the home button while connecting to your computer with iTunes already open and ready for a connection.
- iTunes will prompt you to perform a software restore.
- Your iPhone will obviously be wiped new and be reset as a result and you wil have a working iPhone again.
Using SSL with Tomcat
16/09/08 22:16 Filed in: Software
Sometimes you want to be able to use SSL in combination
with the Tomcat application server.
First you will need to edit the server.xml configuration file for your Tomcat installation. Enable the HTTPS on port 8443 by uncommenting some lines in the file. As part of the change you need to specify the name of the certificate file and the passwords for the files.
maxSpareThreads="75" enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true" sslProtocol="TLS" clientAuth="true"
keystoreFile="d:/keystore/tomcat.keystore" keystorePass="password"
truststoreFile="d:/keystore/tomcat.keystore" truststorePass="password"/>
You also need to create the key & certificate for the Tomcat application server. To create a keystore file for your Tomcat server issue the following command. Change the values for MYCITY (city) and MYORG (organization) and MYSTATE (state) to fit your needs.
After issuing this command you will be asked to provide a password for the certificate and for the store. Enter the same password twice.
%JAVA_HOME%\bin\keytool -genkey -v -alias tomcat -keyalg RSA -validity 3650 -keystore
/path/to/my/tomcat.keystore -dname "CN=localhost, OU=MYOU, O=MYORG, L=MYCITY, ST=MYSTATE, C=MY"
First you will need to edit the server.xml configuration file for your Tomcat installation. Enable the HTTPS on port 8443 by uncommenting some lines in the file. As part of the change you need to specify the name of the certificate file and the passwords for the files.
maxSpareThreads="75" enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true" sslProtocol="TLS" clientAuth="true"
keystoreFile="d:/keystore/tomcat.keystore" keystorePass="password"
truststoreFile="d:/keystore/tomcat.keystore" truststorePass="password"/>
You also need to create the key & certificate for the Tomcat application server. To create a keystore file for your Tomcat server issue the following command. Change the values for MYCITY (city) and MYORG (organization) and MYSTATE (state) to fit your needs.
After issuing this command you will be asked to provide a password for the certificate and for the store. Enter the same password twice.
%JAVA_HOME%\bin\keytool -genkey -v -alias tomcat -keyalg RSA -validity 3650 -keystore
/path/to/my/tomcat.keystore -dname "CN=localhost, OU=MYOU, O=MYORG, L=MYCITY, ST=MYSTATE, C=MY"
Upgrade To MobileMe
12/09/08 20:55 Filed in: Software
MobileMe
The thing I like a lot is the Gallery option. With the Gallery functionality I can maintain my photo albums at a single location. Either view the photo's from any location using the web browser with options for browsing and slideshow, allow downloading or adding photo's by others. Or view the photo's on the television using my Apple TV with no need for iTunes or uploading the photo's to the Apple TV. You can watch my photo collections here...
iPhone
Crash Kart
Late News: Check-out the free game CubicMan Lite...
For more on my experiences...
Spell Checking & Teach Your Dictionary New Words
29/08/08 13:27 Filed in: Tips &
Tricks
I found the following on the Apple website.
Mac OS X offers a really quick way to check the spelling of individual words in Pages, Numbers, Keynote, TextEdit, Mail, Stickies, and other text-based applications. In fact, you can check spelling on the fly without leaving the application you’re using. Here’s how.
Suppose you misspell a word or type one that doesn’t appear in the standard Apple dictionary, like the city of Uithoorn (where I live). Mac OS X will highlight it with a dotted red line. To replace it with the correct spelling, right-click the word with your mouse (or select it with your mouse and Control-click the word). A pop-up menu appears, offering a list of possible replacements. Click the correct spelling of the word to instantly update your document.
Sometimes you know a highlighted term as Uithoorn is spelled correctly and the word is not recognized. You don’t want Mac OS X to highlight it in future occurrences. In that case choose the Ignore Spelling option from the list. Mac OS X removes the highlighting below Uithoorn wherever it appears. In addition Mac OS X won’t underline this word again if you use it subsequently in your current document.
Most likely you want all text-based Mac OS X applications to know the correct spelling of Uithoorn. Therefor you can customize the Mac OS X dictionary to include this correct spelling of the term. To do so, choose the Learn Spelling option. Mac OS X adds this spelling to its dictionary. In future cases Uithoorn appears in the pop-up list of correctly spelled terms. Regardless whether you’re using Pages, Keynote or any other text-based Mac OS X application that uses the spelling dictionary.
Mac OS X offers a really quick way to check the spelling of individual words in Pages, Numbers, Keynote, TextEdit, Mail, Stickies, and other text-based applications. In fact, you can check spelling on the fly without leaving the application you’re using. Here’s how.
Suppose you misspell a word or type one that doesn’t appear in the standard Apple dictionary, like the city of Uithoorn (where I live). Mac OS X will highlight it with a dotted red line. To replace it with the correct spelling, right-click the word with your mouse (or select it with your mouse and Control-click the word). A pop-up menu appears, offering a list of possible replacements. Click the correct spelling of the word to instantly update your document.
Sometimes you know a highlighted term as Uithoorn is spelled correctly and the word is not recognized. You don’t want Mac OS X to highlight it in future occurrences. In that case choose the Ignore Spelling option from the list. Mac OS X removes the highlighting below Uithoorn wherever it appears. In addition Mac OS X won’t underline this word again if you use it subsequently in your current document.
Most likely you want all text-based Mac OS X applications to know the correct spelling of Uithoorn. Therefor you can customize the Mac OS X dictionary to include this correct spelling of the term. To do so, choose the Learn Spelling option. Mac OS X adds this spelling to its dictionary. In future cases Uithoorn appears in the pop-up list of correctly spelled terms. Regardless whether you’re using Pages, Keynote or any other text-based Mac OS X application that uses the spelling dictionary.
Viewing Hidden Files
29/08/08 13:14 Filed in: Tips &
Tricks
Sometimes you want to find and view hidden files on
your computer. Per default OS X will hide these files
with their filename preceded with the . (dot).
The setting is stored in the com.apple.finder.plist file located in Home/Library/Preferences. Open the file with TextEdit and look for the AppleShowAllFiles with the value FALSE.
You can change the setting in the file e.g. change the value into TRUE.
Alternatively you can change the setting using the Terminal application. Enter defaults write com.apple.finder AppleShowAllFiles TRUE followed by killall Finder to restart the Finder application.
To reverse the settings replace the TRUE by FALSE in the file or command.
The setting is stored in the com.apple.finder.plist file located in Home/Library/Preferences. Open the file with TextEdit and look for the AppleShowAllFiles with the value FALSE.
You can change the setting in the file e.g. change the value into TRUE.
Alternatively you can change the setting using the Terminal application. Enter defaults write com.apple.finder AppleShowAllFiles TRUE followed by killall Finder to restart the Finder application.
To reverse the settings replace the TRUE by FALSE in the file or command.
Typing Smart With Your iPhone
17/08/08 20:36 Filed in: Tips &
Tricks
You don’t want to type unnecessary characters on any
telephone. Even with the iPhone keyboard you want to
limit typing.
Typing the URL you can omit the http://www or .com when entering web addresses. Safari is smart enough to know that most Web addresses use that format. So you can leave all that stuff out, and it will supply them automatically. Instead of http://www.cnn.com, for example, just type cnn and hit Go.
For other domains don’t type .net, .org, or .edu, either. Safari’s secret pop-up menu of canned URL choices can save you four keyboard-taps. To see it, hold your finger down on the .com button. Then select the common suffix you want.
When typing on the on-screen keyboard, you can save time by deliberately leaving out the apostrophe in contractions like I’m, don’t, can’t, and so on. Type im, dont, cant, and so on. The iPhone proposes I’m, don’t, or can’t, so you can just tap the Space bar to fix the word and continue.
To produce an accented character (like é, ë, è, ê, and so on), keep your finger pressed on that key for 1 second. A palette of accented alternatives appears; slide onto the one you want. (Keys that sprout these alternative versions: E, Y, U, I, O, S, L, Z, C, N, ?, ', ", $, and !.)
Normally you would switch to the numeric keyboard to add the dot at the end of the line. As an alternative you can hit the spacebar twice.
Safari
Typing the URL you can omit the http://www or .com when entering web addresses. Safari is smart enough to know that most Web addresses use that format. So you can leave all that stuff out, and it will supply them automatically. Instead of http://www.cnn.com, for example, just type cnn and hit Go.
For other domains don’t type .net, .org, or .edu, either. Safari’s secret pop-up menu of canned URL choices can save you four keyboard-taps. To see it, hold your finger down on the .com button. Then select the common suffix you want.
Keyboard Shortcuts
When typing on the on-screen keyboard, you can save time by deliberately leaving out the apostrophe in contractions like I’m, don’t, can’t, and so on. Type im, dont, cant, and so on. The iPhone proposes I’m, don’t, or can’t, so you can just tap the Space bar to fix the word and continue.
To produce an accented character (like é, ë, è, ê, and so on), keep your finger pressed on that key for 1 second. A palette of accented alternatives appears; slide onto the one you want. (Keys that sprout these alternative versions: E, Y, U, I, O, S, L, Z, C, N, ?, ', ", $, and !.)
Normally you would switch to the numeric keyboard to add the dot at the end of the line. As an alternative you can hit the spacebar twice.
Upgrade iPhone Firmware
13/08/08 21:01 Filed in: Software
I upgraded my iPhone firmware to version 2.0 with the
PwnageTool (instructions). Instructions are
simple, although read carefully and don't panic...
NOTE: I used the expert installation to keep the Apple logo's.
Next I connected the iPhone to the computer and upgraded using iTunes to firmware 2.0.1. You will loose the Jailbreak and Cydia for now, but no big loss as few usefull applications are offered currently.
They are working on Jailbreak offering bith Cydia and Installer 4.0....
NOTE: I used the expert installation to keep the Apple logo's.
Next I connected the iPhone to the computer and upgraded using iTunes to firmware 2.0.1. You will loose the Jailbreak and Cydia for now, but no big loss as few usefull applications are offered currently.
They are working on Jailbreak offering bith Cydia and Installer 4.0....