Showing posts with label Java-Groovy-Scala. Show all posts
Showing posts with label Java-Groovy-Scala. Show all posts

Sunday, October 03, 2010

WebSphere no charge

IBM offers WebSphere Application Server "no-charge" edition (registration required):

Version 6.1:
https://www14.software.ibm.com/webapp/iwm/web/reg/download.do?source=swg-wsasfd&S_TACT=109BH2HW&S_CMP=web_dw_rt_swd&lang=en_US&S_PKG=v61&cp=UTF-8&&dlmethod=http

Version 7.0:
https://www14.software.ibm.com/webapp/iwm/web/reg/download.do?source=swg-wsasfd&S_TACT=109BH2HW&S_CMP=web_dw_rt_swd&lang=en_US&S_PKG=v61&cp=UTF-8&&dlmethod=http


Note that this edition is not the "WAS Community Edition", which is basically the Apache Genorimo :-) .
Actually, this edition is the new "Developer" edition. The old Developer edition is the "AE" edition, which can be consider "heavier" than the Base ("Express") edition, but "lighter" than Network Deployment ("AES") edition.


Đang lúc chán mấy tay Tomcat/JBoss giờ nghịch ngợm với Jetty, có thêm WAS sẽ fun lắm đây . Khoái nhất là có phiên bản Linux , khỏi phải đụng tới Windoze :)

./.

Friday, September 17, 2010

GWTDesigner and WindowBuilder become free

Google rulz !

http://java.dzone.com/articles/instantiations-tools-free-all


Java is not very good at UI design, especially desktop applications. But now it may become the past, since the best tools for it became free !

Monday, September 07, 2009

Eclipse WTP Hotswap

One of the reason why JavaEE does not have many succesful projects is that its development time is usually longer than other competitors' time (PHP, Ruby, Python, ASP.NET, ...) . Ok, we all know the burden of overly complicated design and over-engineered implementations from Sun, so let's skip them and go to the one to be resolved: the Hot-Deploy time. In other words, the time for developers to see the web-page refreshed with their changes applied.

The word "hot deploy" used above may not reflect its original meaning, not only because my poor English, but also because (Vietnamese) developers have different concepts of it: "automatic hot swap", "automatic redeploy webapp", "automatic restart container" .

This is how I understand the differences:
1/ Hot deploy container: automatic restart whole servlet container (Tomcat)
2/ Hot deploy webapp: automatic reload context root and all classes of respective webapp.
3/ Hot deploy classes: hot-swap only the re-compiled classes (runtime)
It is obvious that #1 is slower than #2 and #2 is slower than #3: Hot-swap or hot-code replacing .


Ok, now what? Let's try to reduce the hot-deploy time in Java developement in the well-known combination: Eclipse + WTP plugins + Tomcat. Assumed that you already have an Eclipse with WTP/WST plugins installed (e.g. Eclipse JavaEE version).

Create a New Server WTP for your web application
From the New menu, select Other… -> Server -> Server. For your server type (probably "Apache Tomcat 6"), specify the path to your Tomcat installation directory, e.g. "/opt/apache-tomcat-6.0.18" or "D:\USR\apache-tomcat-6.0.18" . Add your web project as a 'Resource' to this server (you may modify the context root first).

Adjust the server's settings
Double click on the Server in your Server view (its name is something like "Tomcat v6.0 Server at localhost-config"), it will display the "Overview" tab:
- Server location: Use Tomcat installation (actually, either "workspace metadata" or "custom location" can work as well, but let's use the most simple for beginners)
- Port: modify the HTTP port from 8080 to the one you desire. You may also modify the remaining 2 ports respectively to avoid port conflicts between Tomcat instances.
- Timeout: better increase them 100 or 200 seconds more.
- Server options: not necessary to check any options.

Enable classes hot-swap
Ok, the main settings for hot-deploy here:
- Publishing: Auto publish when resources changes (to hot-deploy text resources like .properties, .html, .jsp, ... and packaged resources like .jar, .zip ) , the interval should be small (1 or 0 sec).
- Switch to "Modules" tab, since you already added the web app to the server, there should be at least a "module" with the specified context root (path URL). Select that module, then click "Edit" button, uncheck the "Auto reloading enabled" checkbox, click OK. Now your module should have "Auto Reload" setting as disabled (equivalence to <Context reloadable="false" ... /> in server.xml/context.xml of Tomcat)
- Save the changes (at least make sure the two above has been applied already).

Start the server in Debug mode
Once you started the web-app in Debug (right click -> choose "Debug..."), Changes you make to your JSPs or inside Java methods will be instantly hotswapped into your running webapp, therefore reduce the development time (at least the wasted time looking at console when reloading web-app).

Why?
Since Java 1.4.2 , the JPDA supports hot-swap classes on debug mode, by manipulateing class loaders at runtime. Eclipse makes use of it via WTP under the name Hot Code Replace . Setting auto-publish helps replacing text files and recompiled jar, but not for classes. By default, Tomcat's context reloading will reload all classes using its class loaders and therefore does not take advantage of hot-deployed classes.
Note that JPDA is not the best for hot code replacing, the number one here must be JRebel. Some web frameworks (Tapestry, Stripes, Wicket, Grails, Roo) also has their own classloader handlings to support quick reload. They're all inspired by some standalone JAR files around which I don't remember (probably the pioneers for JRebel). And FYI, Tomcat Sysdeo plugin and Jetty can also support HCR , in case you don't want to use Tomcat WTP.

Some more recommended settings
Running Tomcat in Eclipse (via WTP plugin) is a bit slower than via external command, and running in Debug mode is somehow resource-hogging, which may result in errors like hot-swap failure or OutOfMemoryError . To avoid those issues, you may try some JVM options via Tomcat JRE params: Double-click on your server in the "Servers" view, switch to the "Overview" tab, click on the "Open launch configuration" link, switch to the Arguments tab; there you can add relevant memory settings to the "VM Arguments" section
-client -Djava.awt.headless=true
-Xmx1024m
-Xms512m
-XX:MaxPermSize=1024m
-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -XX:+UseConcMarkSweepGC


Limitations
JPDA HCR not applied: to change the signature of a class (add/remove methods or fields) or to add new classes on the fly. Additionally, some method calls (“stack frames”) can’t be modified, including the main method or any method invoked via reflection, that is, by using java.lang.reflect.Method.invoke().
(JRebel can overcome those limitations)


Good luck & have fun :-) ,



./.

Tuesday, September 01, 2009

Maven Archetype quick notes

maven-archetype-plugin allows the user to create a Maven 2 project from an existing template caled an archetype.

If you just use an IDE to generate Maven project, you can be familiar with default project structure of Maven:




Let's consider an example using it to create a "todo-list" project which contains 2 sub-projects: todo-core and todo-web

cd workspace

mkdir -p todo-list

cd todo-list

Old-fashioned way:
mvn archetype:create -DartifactId=todo-core -DgroupId=org.vnoss

mvn archetype:create -DartifactId=todo-web -DgroupId=org.vnoss -DarchetypeArtifactId=maven-archetype-webapp


New way:
mvn archetype:generate

mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp

Now we can edit the pom.xml to get desired result.

Tuesday, August 11, 2009

VMware acquired SpringSource

VMware announced they have acquired SpringSource for a mix of approximately $362 million in cash and equity plus the assumption of approximately $58 million of unvested stock and options.

$420 millions! Good news !

Saturday, June 20, 2009

Eclipse NetBeans PHP

Eclipse 3.5 (Galileo) new features:
http://infoq.com/news/2009/06/galileo

1. P2 provisioning which provides for a more efficient update process for Eclipse
2. OSGi Declarative Services, which allow OSGi services to be configured and installed based on XML prior to the start of the bundle's service
3. Improved target platform management, which allows the runtime platform to be configured easier
4. Mylyn WikiText, which can be used to edit bugs via Mylyn or transform into other documentation formats like DocBook
5. The addition of the Eclipse Memory Analyser, which can analyse the JVM's heap usage
6. Install into Self, which allows plugins to be developed and installed into the currently running Eclipse platform
7. Eclipse Modeling Project refinements, which reduces the size of the EMF runtime requirements
8. Improved RAP styles to allow your RAP based application to be customised
9. Enhanced JAvaScript bridge, which allows embedding of widgets like Google Maps into an SWT browser
10. Java compare editor enhancements which allow JavaDoc hovers, hyperlinking and other goodness from the compare page



NetBeans 6.7 new features:
http://wiki.netbeans.org/NewAndNoteWorthyNB67



PHP 5.3 new features:
http://vn.php.net/releases/5_3_0.php




:-)

Wednesday, May 20, 2009

Static vs Singleton

Ever wonder the advantages of using static methods or static class or Singleton class ?

IMHO, each approach has some benefits and disadvantages, you may choose your own depending on the situation.


Benefits of static methods :



Benefits of Singleton :

Sunday, April 19, 2009

Sunday, March 08, 2009

Java mess detector

OK guys, I have used CheckStyle and PMD, either one of them seems good enough.

But do you have any comparision or advice for me about other tools: FindBugs, Hammurapi, TFTP, JLint, ...

I just want to make a list of Top 5 tools that is really useful in each catergories of software development (in a certain language, such as Java).

RANK ? : PMD

RANK ? : Checkstyle

RANK ? : FindBugs

RANK ? : Hammurapi

RANK ? : TFTP

Wednesday, February 18, 2009

Saturday, February 14, 2009

Eclipse Flex formatting

FlexBuilder cheapest license is around 500$ , and it does not support auto-formatting or Refactoring ?!!



OK, Adobe guys should improve those features fast, since Eclipse community begins to pay attention to Flex and Spring/BlazedDS integration :

http://sourceforge.net/projects/flexformatter/

Finally found ! No longer pain refactoring with stupid FlexBuilder stuff...

Monday, February 09, 2009

JUnit auto SetGet

Using reflection and generics in Java, you can now automatically test Getters and Setters (accessors and mutators) of your class with JUnit/TestNG.

Of course normally many developers do not bother testing setters and getters, but if your customer insists on high test coverage you will find this auto one is useful to avoid boilerplate code :-) .
And maybe it can help to avoid some nasty bugs (I myself feel ashamed when reading my "sleepy" code, too) !


Some fragments :

public void invokeSettersAndGetters() {
Classextends Object> targetClass = testTarget.getClass();
Method[] methods = targetClass.getMethods();
for (int i = 0; i < methods.length; i++) { Method method = methods[i]; if (method.getName().startsWith("set")) { Class[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length == 1) { Object testValue = testValueFactory.createValue(parameterTypes[0]); try { method.invoke(testTarget, testValue); if (testValue instanceof Boolean) { invokeGetter(targetClass, testValue, "is" + method.getName().substring(3)); } else { invokeGetter(targetClass, testValue, "get" + method.getName().substring(3)); } } catch (IllegalAccessException e) { Assert.fail("failed to access setter method: " + method.toString() + " - " + e.getMessage()); } catch (InvocationTargetException e) { Assert.fail("failed to invoke setter method: " + method.toString() + " - " + e.getMessage()); } } } } }





private void invokeGetter(Class targetClass, Object expectedValue, String getterName) {
try {
Method getterMethod = targetClass.getMethod(getterName);
if (log.isDebugEnabled()) {
log.debug("invoke get method: " + getterMethod.toString());
}
Object retrievedValue = getterMethod.invoke(testTarget);
Class returnType = getterMethod.getReturnType();
if (returnType.isPrimitive()) {
Assert.assertEquals("return value of " + getterName + " incorrect", expectedValue, retrievedValue);
} else {
Assert.assertSame("return value of " + getterName + " incorrect", expectedValue, retrievedValue);
}
} catch (NoSuchMethodException ignore) {
// ignore if getter does not exist
if (log.isDebugEnabled()) {
log.debug("getter does not exist: " + getterName);
}
} catch (IllegalAccessException e) {
Assert.fail("failed to access getter method: " + getterName + " - " + e.getMessage());
} catch (InvocationTargetException e) {
Assert.fail("failed to invoke getter method: " + getterName + " - " + e.getMessage());
}
}



basic JUnit test:

@Test
public void testSetterGetter() {
Cat cat = new Cat();
MutatorAccessorInvoker invoker = new MutatorAccessorInvoker(cat);
invoker.invokeSettersAndGetters();
}


Full credit of this invoker should belong to Koert Zeilstra , however you should see that his class can be improved ;-) .

@Test
public void setAndGetAll() {
MutatorAccessorInvoker mutatorAccessorInvoker = new MutatorAccessorInvoker(new MyGuess());
mutatorAccessorInvoker.invokeSettersAndGetters();
}




Have fun,

Friday, February 06, 2009

Aptech VN books

Dưới đây là link tải bộ ACCP 7.1 , tài liệu chính mới nhất của các học viện Aptech VN, được chia thành 17 phần :

http://www.mediafire.com/?gme9tgtyttz
http://www.mediafire.com/?t1y1tzo3zcm
http://www.mediafire.com/?ugg0hmycgcf
http://www.mediafire.com/?xovz2x1n0wm
http://www.mediafire.com/?wx9mbtmfomg
http://www.mediafire.com/?2gtbheelyau
http://www.mediafire.com/?zynv4jdxyym
http://www.mediafire.com/?mw1obhzmtky
http://www.mediafire.com/?lyzbly0syrl
http://www.mediafire.com/?dnn11m2r2ke
http://www.mediafire.com/?mnkymd9pwfm
http://www.mediafire.com/?k3y240jxngn
http://www.mediafire.com/?kwdgemmx4mm
http://www.mediafire.com/?nf2fmde9zmp
http://www.mediafire.com/?m0hnmymzjrw
http://www.mediafire.com/?jm3m2y3wily
http://www.mediafire.com/?xnscysmmzbm


Mirror:

http://www.adrive.com/public/eebc6d67f5f41b225e22ae26cfbe14044dd2fbce9e50e62b56c86a5736eadc94.html
http://www.adrive.com/public/6a892301907e9a9604289e9dc39e304ef7932e5340e24f57f30f1670936c6b7a.html
http://www.adrive.com/public/af7c3c712b07af12581156445ee3145e3544bdf1b830c9da3e0a9d81f5d7beb7.html
http://www.adrive.com/public/f3d21fb5cfb9ca0a2f8b817a03cfd237c5a9ec49764d77a688bc496b97717e7e.html
http://www.adrive.com/public/272fc5bf56f86f758d391f5a8aff4fb756edf02cddd81db306ae2f31c4eb05c1.html
http://www.adrive.com/public/aa399b353659d62a371c2cb24239828d97b3472bbfd4e7f6ab2c4bccfbf8661a.html
http://www.adrive.com/public/7b1b91da3e2bac6f57817c380a4cd9a6000843f11964fc9fa8a2fce5ac696fb2.html
http://www.adrive.com/public/1c75d1c3ed7401789ec4b73b9e8a882e0d9ca6aa0c4e702503b7a197444eabbc.html
http://www.adrive.com/public/3ed3877ff7210661a6c6e244ad309a864154e08921b631064bc0f6961e933f09.html
http://www.adrive.com/public/69ad9df24493ecf48e8de0a69993fed072b308e289738f37be9dc2a5e70c7823.html
http://www.adrive.com/public/eafc4f6927d8e70a27d850c219bf7c56e1ccbb38928aa8e5e26c23b34a6b41e1.html
http://www.adrive.com/public/7ea9dfc164db0776ad58a7c3dae145f8629ccb435d53e52eac831f41c6d2b041.html
http://www.adrive.com/public/c12e3a1a5fa492d539eb03112ba2126d2ae740010bfcda6c3e81611d08f1246a.html
http://www.adrive.com/public/5653d968b8dc6d8c04e13ac444e14d136400bad4273465e4f87a89517050dab0.html
http://www.adrive.com/public/ce93f7afc7d9d4b414566bbe0ae30e7011191b1d338eff2e4f9b1d434029230a.html
http://www.adrive.com/public/ca2ad64261bf802a48bb30372c514759c78e01d1d0aa8931acc148b6e9f64dec.html
http://www.adrive.com/public/411be0801872549d82132ccd3bcf6332fedec4b2d65f4bf4ff8bfd5d9b850e88.html


Mirror 2:

http://www.mediafire.com/?gxzjaeggvos
http://www.mediafire.com/?1odw3omydoi
http://www.mediafire.com/?mybbnhhoncx
http://www.mediafire.com/?tvfeobyvvny
http://www.mediafire.com/?lvmwinrzwnv
http://www.mediafire.com/?kpmdutjl6nv
http://www.mediafire.com/?wwymtmhptbs
http://www.mediafire.com/?i0vlsxmzsz3
http://www.mediafire.com/?bmtxybxpim1
http://www.mediafire.com/?wrirfuhdjrd
http://www.mediafire.com/?wvrt2mynmbz
http://www.mediafire.com/?zzbbbydjocz
http://www.mediafire.com/?zerbnfubfyh
http://www.mediafire.com/?pmfrlx3ztiq
http://www.mediafire.com/?xyvgbnoyh0y
http://www.mediafire.com/?w4zr6m0eaiw
http://www.mediafire.com/?0gnwqcm5zqm


Enjoy !

Sunday, February 01, 2009

JUnit mock frameworks

The main reason for using mock objects to write unit tests is so that they are unit tests. Without mock implementations, unit tests quickly become integration tests, which are much more costly and time-consuming.

Here is my ranking list for Java mock frameworks (supporting JUnit, TestNG) :

1/ PowerMock

2/ EasyMock

3/ Mockito

4/ FEST-mocks

5/ jMock


Which is the best mock framework to you ?

Saturday, January 31, 2009

Cloud Computing basics

=== Needs ===

Nguyên nhân cho sự ra đời của Cloud Computing :

- Mỗi doanh nghiệp làm business bao giờ cũng cần xây dựng một hệ thống thông tin cho riêng mình, thông thường bao gồm các hệ thống: web pages, payroll, email management, CRM,... Để thiết kế và duy trì hệ thống này, các doanh nghiệp phải chi ra một số tiền không nhỏ, nhất là tiền lương trả cho DBAs. Với các doanh nghiệp nhỏ thì đây là một khoản đầu tư đáng kể. Có một cách tiếp cận khác là thay vì tự xây dựng một hệ thống như thế cho riêng mình thì việc outsource bằng cách thuê lại của đơn vị khác để giảm chi phí build và management.

- Khi mà internet bandwidth không còn là vấn đề nữa thì các ông lớn như MS, IBM, Google, Yahoo,... ngửi thấy mối hàng béo bở này liền bắt tay xây dựng một hệ thống có thể cung cấp cho khách hàng tất cả các loại dịch vụ trên thông qua các web services.




=== Problems ===

Khi xây dựng một thống centralized để phục vụ cho hệ thống trên thì dễ thấy các vấn đề nổi bật sẽ xuất hiện là:

- Cần phải lưu trữ một khối lượng dữ liệu lớn đến rất lớn.

- Dữ liệu đa định dạng, phân tán

- Cần phải có một hệ thống tính toán đủ mạnh để có thể xử lý hàng ngàn ứng dụng (phép toán) 1 lúc cho 1 lượng dữ liệu khổng lồ .




=== Solutions===

Cloud Computing ra đời để giải quyết 2 vấn đề này:

- Dữ liệu được lưu trữ ở các Data Center khổng lồ. Mỗi một công ty lớn như MS, Google có hàng chục data center như vậy nằm rải rác khắp nước Mỹ và các nơi trên thế giới. Vấn đề chính cho các data center này chủ yếu là công suất tiêu thụ và sự tản nhiệt. Vì thế gần đây các data centers thường được xây dựng ở gần các con sông lớn (như dọc sống Colorado) .

- Còn vấn đề về computing power thì có 2 giải pháp: 1 là mua các supercomputer từ Gray, Sun, Teradata,.. và 2 là dùng hệ thống tính toán song song với các commodity hardware. Tất nhiên cách thứ 2 là cách rẻ tiền nên được ưa chuộng hơn. Tuy nhiên, cách này yêu cầu có một cách phân chia công việc, scheduling và failure management một cách hợp lý. Có rất nhiều mô hình tính toán song song được phát triển, nhưng gần đây mô hình MapReduce của Google thu hút được nhiều sự chú ý về tính đơn giản và hiệu quả. Hadoop là một giải pháp open source của Apache Foundation (xuất phát từ Yahoo) lấy ý tưởng từ cái MapReduce này. Hiện tại MapReduce và Hadoop đang là những keyword khá hot.


- Ngoài ra thì để quản lý hệ thống cơ sở dữ liệu khổng lồ này cần có cách lưu trữ, truy nhập hiệu quả mà các DBMS thông thường không đáp ứng được.

+ MS đang chuẩn bị cho ra đời một hệ thống như thế gọi là CloudDB và 1 hệ điều hành tên là Windows Cloud OS. Yahoo thì chưa có CC theo đúng nghĩa, vì nó chỉ có các computing cloud chạy được mỗi app của chúng nó, còn không open và không customize được. Cái này gần với Sever Clustering hơn là Cloud Computing.

+ IBM có Cloud Computing trên nền Linux và AIX, gọi là Blue Cloud, nhưng lại bị giới hạn bởi phạm vi địa lý và computing resrource.

+ Google có App Cloud, nhưng chạy được mỗi Python App, không có database và không cài thêm được app.

+ Sun và HP cũng có Cloud Computing offering nhưng còn trong giai đoạn thử nghiệm bởi tính ứng dụng còn ở dạng "tiềm năng".

+ Hiện tại chỉ có Cloud Computing của Amazon (EC2) là được đánh giá phát triển đáng kể nhất. Amazon có lợi thế lớn là có một sever farm khổng lồ ở hầu hết mọi zone trên thế giới, các team dev hiện cũng đang sử dụng Amazon Web Services để phát triển phần mềm và deploy phần mềm. Amazon S3 cung cấp dịch vụ lưu trữ với unlimited space, có thể lưu trữ tại bất kỳ vùng địa lý nào, ví dụ như Nam Mỹ, Bắc Mỹ, Châu Âu, Châu Phi, Châu Á ..., nên hạn chế được sự chậm trễ do khoảng cách. Nếu như một công ty nào đó có nhiều chi nhánh trên thế giới, có thể dùng nhiều S3 để lưu trữ.


Amazon EC2 cho phép người dùng chọn bất kỳ hệ điều hành nào, ví dụ như Linux (Fedora, Ubuntu ...), BSD. Hình như giờ mới có cả Window server. Mỗi EC2 instance là một virtual server, có RAM nhiều hay ít, một hay nhiều processor tùy theo loại của instance, và người dùng có thể dùng EC2 tools hoặc SSH vào, cài bất kỳ software nào mình thích lên, như là một computer bình thường. Hoặc có thể setup một EC2 instance image, rồi khi cần có thể chạy một loạt server có cấu hình giống hệt như cái instance image đấy, số lượng server là bao nhiêu là tùy ở mình.


Amazon Persistence Service cho phép người dùng sử dụng như một đĩa cứng ảo gắn vào máy tính ảo EC2.


Theo đánh giá của 1 số dev đang phát triển bằng Amazone Web services, Amazon WS rất an toàn, vì nó dựa trên RESTful Web Services, SSL và độc đáo hơn nữa là time-based URL, nghĩa là URL để download hay upload hay truy cập site trong AWS có thể expire sau một thời gian nhất định.




(theo IBM developerWorksblog Alibobo)

Monday, January 12, 2009

Java coding convention [2]

Trong bài đề cập về coding convention của Java (http://mediocre-ninja.blogspot.com/2008/11/java-coding-convention.html), hầu như các điểm đã nêu đều phù hợp với convention của Sun và bao quát gần hết các điểm đáng chú ý. Tuy nhiên thực tế cho thấy còn vài vấn đề thường gặp về coding style mà quy ước của Sun cũng chưa đề cập, hoặc ngay cả bộ sun-JDK cũng không nhất quán (inconsistent).

Chẳng hạn, một vấn đề về quy ước đặt tên (naming convention) khi đặt tên lớp (class name) hoặc tên phương thức (method name), theo Sun thì class sẽ capitalize theo PascalCase (UpperCamelCase), còn method thì theo camelCase (lowerCamelCase) :

Class names should be nouns, in mixed case with the first letter of each internal word capitalized.
Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized.


nhưng trường hợp class/method có dùng các từ viết tắt (quen thuộc) như: HTTP, XML, URL,... thì sao? Liệu chúng ta nên viết hoa toàn bộ (all uppercase) cụm từ đó, hay là chuyển nó thành CamelCase ? Trong bộ JDK thì Sun có dùng cả 2 cách, trong đó cách thứ nhất chiếm số lượng nhiều hơn.

Theo tôi thì 2 chọn lựa trên mỗi cách đều có ưu và khuyết điểm :

+ Viết hoa toàn bộ cụm viết tắt: đang được Sun ủng hộ, các ưu nhược điểm: ...

+ Viết cụm đó thành dạng CamelCase : được cộng đồng Open Source (Apache, Spring, Hibernate, ... ) ủng hộ, có các ưu nhược điểm: ...


Vậy chúng ta nên chọn cách nào ?



Well, tôi ủng hộ cách thứ 2, tức là cách always use strict camelCase for naming method, bởi vì:

Saturday, January 10, 2009

JavaCard quick notes [4]

=== JavaCard architecture overview ===

Smart cards represent one of the smallest computing platforms in use today. The greatest challenge of Java Card technology design is to fit Java system software in a smart card while conserving enough space for applications. The solution is to support only a subset of the features of the Java language and to apply a split model to implement the Java virtual machine - JavaCard virtual machine.

The Java Card virtual machine is split into two part: one that runs off-card and the other that runs on-card. Smart cards differ from desktop computers in several ways. The memory configuration of a smart card might have on the order of 1K of RAM, 16K of EEPROM, and 24K of ROM. In addition to providing Java language support, Java Card technology defines a runtime environment that supports the smart card memory, communication, security, and application execution model. The Java Card runtime environment conforms to the smart card international standard ISO 7816.


Java Card technology essentially defines a platform on which appli-
cations written in the Java programming language can run in smart cards and other
memory-constrained devices. (Applications written for the Java Card platform are
referred to as applets.) Because of the split virtual machine architecture, this plat-
form is distributed between the smart card and desktop environment in both space
and time. It consists of three parts, each defined in a specification.

• The Java Card 2.1 Virtual Machine (JCVM) Specification defines a subset of the Java programming language and virtual machine definition suitable for smart card applications.

• The Java Card 2.1 Runtime Environment (JCRE) Specification precisely describes Java Card runtime behavior, including memory management, applet management, and other runtime features.

• The Java Card 2.1 Application Programming Interface (API) Specification describes the set of core and extension Java packages and classes for programming smart card applications.


Supported and Unsupported features in JavaCard :





:-)

Thursday, January 08, 2009

BlazeDS quick notes

=== What is BlazeDS? ===

+ Java remoting and Messaging Technology.

+ Enables developers to connect to back-end distributed data and push data in real-time to Adobe Flex and Adobe AIR applications

+ Open Source

+ From SOAP to AMF (Action Message Format)

+ 10 times faster than XML based protocols, how?

+ Previously known as Adobe LCDS







=== Remoting (RPC) ===

+ Instead of Contacting services, RPC components contact 'Destinations'

+ Destination: Manageable Service Endpoints

+ Managed using XML based configuration file

+ 'Remote Object' not possible without BlazeDS
( Adobe Flash Player blocks request to any external hosts, solution? )


+ crossdomain.xml required ( For apps that are not using BlazeDS )

+ XML file that indicates:
- Data and documents are available to SWF files served from certain/all domains
- Must be in 'web root' of the server


=== AMF (10 times faster!) ===

+ Compact binary format for data serialization/ deserialization and remote method invocation.

+ Object encoding controls how objects are represented in Action Message Format (AMF).

+ Representation that can be transferred over HTTP/HTTPS.

+ As data size increases the performance benefits of using BlazeDS increase exponentially.

+ AMF improves performance by
- Dramatically compressing the size of data transferred.
- Parsing binary data into objects in memory far more efficiently than parsing XML data.


=== Quick Brief ===

+ Message Agents:
- Message Producers & Consumers
- Exchange messages through a common destination

+ Channel and endpoints
- Formats, Translates messages into network-specific form.
- Delivers to the endpoint (on the server)
- Server-Side Channel Unmarshals messages
- Configuration settings ( XML files) at runtime

+ Message Broker
- Routes messages to the appropriate service based on its type

+ Channel Types



=== Channel Configuration ===

+ Configure channels using services-config.xml

+ AMF protocol use an optimization technique

+ Assign channel at runtime( AS Code) by creating a ChannelSet object, and adding a channel to it.

var cs:ChannelSet = new ChannelSet();
var channel:Channel = new AMFChannel(“name”, endpoint)
cs.addChannel(channel);
Remoteobject.channelSet = cs;



=== Remote Object components ===

+ Access methods of server-side java objects.

+ No need to specify 0bjects as operations in web services

+ Use RemoteObject component in MXML/AS

+ Server - Proxied access to an RPC service

+ Communication happens over a 'destination'

+ Configured in the remoting-config.xml
- RPC method or URL, channel, adapter

+ Asynchronous communication
- AsyncToken object

+ Http Service and web service use proxy-service.xml for configuration.
- Limit access to specific URL
- Provide Security


=== BlazeDS with Tomcat ===
+ Unzip the blazeds-turnkey file on to your C: drive
(Blazeds comes with Tomcat default.)

+ Create a new application: C:\blazeds\tomcat\webapps

+ Copy & paste the META-INF, WEB-INF folder from the samples (zip) file.

+ Store all your java class files in WEB-INF/classes folder

+ Configure remoting-config.xml under WEB-INF/flex/ for all your remoting related details (destinations) . Create a and a specify a

+ Configure messaging-config.xml under WEB-INF/flex for all your messaging (real-time) by adding your destination

+ For all other service related details use the proxy-config.xml

+ Give references of all these xml files in services-config.xml (done by default)

+ Run your application http://:/


:-)

Wednesday, January 07, 2009

Basic Eclipse plugins

Some update sites of useful plugins for Eclipse 3.4 (Ganymede) , but most of them can work with Eclipse 3.3 (Europa) and even 3.2 !
Just for not having to google them again :D


1/ SubVersioN client: Subversive Subclipse

http://subclipse.tigris.org/update_1.4.x/


2/ Project build: Ant Maven2 (m2eclipse)

http://m2eclipse.sonatype.org/update/


3/ Coding style: Checkstyle PMD

http://pmd.sourceforge.net/eclipse/


4/ Code coverage: Cobertura Emma (eclemma)

http://update.eclemma.org/


5/ Continuous integration: LuntBuild Hudson (hudson-eclipse)

http://hudson-eclipse.googlecode.com/svn/trunk/hudson-update/


6/ Unit test: JUnit TestNG

http://beust.com/eclipse/


7/ ORM framework: iBatis Hibernate (HibernateTools)

http://download.jboss.org/jbosstools/updates/stable/


8/ POJO framework: Seam Spring (SpringIDE)

http://springide.org/updatesite/


... (FlexBuilder, WTP, Unitils, DbUnit, liquidBase, etc ) ...