org.apache.cxf.endpoint.Client client = ClientProxy.getClient(service);
Map inProps = new HashMap();
inProps.put(WSHandlerConstants.ACTION, "UsernameToken Timestamp");
inProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
inProps.put(WSHandlerConstants.PW_CALLBACK_CLASS,
"com.roche.xp2.content.lowlevel.alfresco.util.AlfrescoRepositoryProviderCallback");
inProps.put(WSHandlerConstants.USER, "ticket");
WSS4JOutInterceptor wssIn = new WSS4JOutInterceptor(inProps);
client.getEndpoint().getOutInterceptors().add(
new org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor());
client.getEndpoint().getOutInterceptors().add(wssIn);
Thursday, 22 December 2011
Apache CXF connector to Alfresco
Thursday, 15 December 2011
Spring 3.1 Released
Download available here: http://www.springsource.com/download/community?project=Spring%20Framework&version=3.1.0.RELEASE
Sunday, 4 December 2011
How to log Garbage collection in java?
- -XX:+PringGC - switching on summary of every run of Garbage collection
- -XX:+PringGCDetails - switching on detail summary of every run of Garbage collection
- -Xloggc:filename - filename to which logs will be put
Logging application behavior, whose are deployed on tomcat
More information can be read in the article: http://www.tomcatexpert.com/blog/2011/11/11/finer-point-apache-tomcat-valves
ListPreference with values number type
<ListPreference android:key="poll_list" android:title="@string/preference_poll_list" android:summary="@string/preference_poll_list_summary" android:entries="@array/poll_option" android:entryValues="@array/poll_option_values" android:dialogTitle="@string/preference_poll_list" />I had to define lists in arrays.xml. But I had to define list poll_option_values as a string-array, like here:
<resources> <array name="poll_option"> <item>1 Minute</item> <item>2 Minutes</item> <item>5 Minutes</item> <item>10 Minutes</item> <item>20 Minutes</item> </array> <string-array name="poll_option_values"> <item>60</item> <item>120</item> <item>300</item> <item>600</item> <item>1200</item> </string-array> </resources>I couldn't use array type. Just another Android feature ;)
Saturday, 3 December 2011
Testing asynchronous actions using WebDriver (f.e. AJAX)
WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(new ExpectedCondition() { public Object apply(Object input) { try { WebElement elem = driver.findElement(By.id(changedElem)); boolean condition = Here you can state condition return condition; } catch (StaleElementReferenceException e) { return false; } } });
Tuesday, 29 November 2011
Alfresco documentation for connecting using WebServices
http://wiki.alfresco.com/wiki/Alfresco_Content_Management_Web_Services
http://wiki.alfresco.com/wiki/Web_Service_Samples_for_Java
Monday, 28 November 2011
Spring Roo 1.2.0.RC1 released
- Multi-module Maven project support
- Enhancements in Entity model
Sunday, 27 November 2011
ProGuard - obfuscator for Android
Use Proguard.
ProGuard is a free Java class file shrinker, optimizer, obfuscator, and preverifier. It detects and removes unused classes, fields, methods, and attributes. It optimizes bytecode and removes unused instructions. It renames the remaining classes, fields, and methods using short meaningless names. Finally, it preverifies the processed code for Java 6 or for Java Micro Edition.
More information on the product page: http://proguard.sourceforge.net/Wednesday, 16 November 2011
How to change MANIFEST.MF generated by maven?
Here is an example of configuring default class run when executing generated jar:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>package.Class</mainClass> </manifest> </archive> </configuration> </plugin>Here is an example of using already generated MANIFEST.MF file as the manifest file of the jar:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile> </archive> </configuration> </plugin>
More info about plugin parameters on: http://maven.apache.org/maven-1.x/plugins/jar/manifest.html
Loading properties file in java
Properties properties = new Properties(); properties.load(is);
Linux console tools for measuring performance
- top, htop - processes measurement
- df - storage space info
- hdparm - storage performance
- cat /proc/cpuinfo - CPU info
- cat /proc/meminfo - RAM info
- vmstat, dstat - processes, memory, swap, IO, CPU info
- netstat - network info
- mpstat - CPU summary
- iostat - IO info
- iptraf - many metrics
Latency and Responsiveness
- Latency - a measure of time delay experienced in a system
- Responsiveness - ability of a functional unit to complete assigned tasks within a given time
Tuesday, 15 November 2011
Runing ChromeDriver on Linux
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.5.0</version> </dependency>I have created a simple java code in my main method:
WebDriver driver = new ChromeDriver(); driver.get("http://google.pl"); driver.findElement(By.name("q")).sendKeys("Selenium"); driver.findElement(By.name("q")).submit();My program did not manage to connect to Chrome web browser. I needed to download chromedriver from http://code.google.com/p/chromium/downloads/list and add a system property webdriver.chrome.driver with path to this file.
It did work!
Thursday, 10 November 2011
CXF - maven plug-in
I was implementing a Webservice client. I used Apache CXF (http://cxf.apache.org/) an open source services framework. It is a natural successor of Axis library.
After some time spent with CFX I can say that it uses Collections over Arrays (that is a big plus). On the other hand it hasn't got as good documentation as I expected. I tried to use maven task for generating java classes from WSDL definition files. When I got an error I had to use wsdl2java from command line to get detailed error message. Also I couldn't find syntax for wsdl2java task. I wished to use more parameters. I spent some time on finding how to do it. Underneath you can see an example to define configuration in pom.xml for wsdl2java operation. You can use more wsdlOption tags for generating classes from more then one WSDL file.
<build> <plugins> <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> <version>${cxf.version}</version> <executions> <execution> <id>generate-sources</id> <phase>generate-sources</phase> <configuration> <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot> <wsdlOptions> <wsdlOption> <wsdl>${basedir}/src/main/wsdl/authentication-service.wsdl</wsdl> <extraargs> <extraarg>-client</extraarg> <extraarg>-p</extraarg> <extraarg>http://www.alfresco.org/ws/service/authentication/1.0=org.alfresco.ws.service.authentication</extraarg> </extraargs> </wsdlOption> </wsdlOptions> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
Sunday, 6 November 2011
Saturday, 5 November 2011
Java Decompiler for Eclipse - JD-Eclipse
Here are instructions how to install it:
http://java.decompiler.free.fr/?q=jdeclipse
Friday, 28 October 2011
Tuesday, 25 October 2011
How to create java object in Freemarker?
- Application - servlet context attributes hash model
- JspTaglibs - jsp tag lib factory model
- Request - request attributes hash model
- Session - session attributes hash model
- request - the HttpServletRequst object for direct access
- response - the HttpServletResponse object for direct access
- stack - the OgnLValueStack instance for direct access
- ognl - the instance of the OgnlTool
- action - the action itself
- exception - optional : the JSP or Servlet exception as per the servlet spec (for JSP Exception pages)
- struts - instance of the StrutsUtil class
In the ftl code you can use struts variable:
struts.bean("java.util.Date")It will return object of this type, constructed with zero parameter constructor.
Format date in java with months' name changed
I was given the task to format dates. The requester needed months' name appropriate case endings.
It can be done be SimpleDateFormat class: (this example is for Polish language)
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMMM-yyyy"); DateFormatSymbols dfs = new DateFormatSymbols(); dfs.setMonths(new String[]{"stycznia","lutego","marca","kwietnia","maja","czerwca","lipca","sierpnia","września","października","listopada","grudnia"}); sdf.setDateFormatSymbols(dfs); String output = sdf.format(new Date());
Heap pollution
Java Language Specification, Third Edition
§4.12.2.1 Heap Pollution
It is possible that a variable of a parameterized type refers to an object that is not of that parameterized type. This situation is known as heap pollution. This situation can only occur if the program performed some operation that would give rise to an unchecked warning at compile-time.
Here is an example:
List l = new ArrayList(); List l1 = l; l.add("one"); Integer i = l1.get(0);
In java 7 the following additions help to deal with Heap Pollution:
- A new mandatory compiler warning is generated on declaration sites of problematic varargs methods that are able to induce contributory heap pollution.
- The ability to suppress those mandatory warnings at a declaration site using an @SuppressWarnings("varargs") annotation. The warnings may also be suppressing using the -Xlint:-varargs option to the compiler.
- If the @SuppressWarnings("varargs") annotation is used on a problematic varargs method declaration, the unchecked warnings at call sites of that method are also suppressed.
Saturday, 22 October 2011
SpeakIt! - Chrome extension
Limit on Post Request - maxPostSize
I've found in the Tomcat and Jboss Connector configuration that we can define a constant maxPostSize that is the maximum size in bytes of the POST request that is handled by the container FORM parameter parsing. The limit can be disabled by setting this attribute to a value less than or equal to 0. If not specified, this attribute is set to 2097152 (2 megabytes).
Wednesday, 19 October 2011
STS 2.8.0 released. Supports Java 7
For more details browse to: http://www.springsource.org/node/3287
How to exclude folders from searches in Eclipse?
Class Currency
java.util.Currency
It represents a currency. The currencies are identified by their ISO 4217 currency codes. Visit the ISO web site for more information, including a table of currency codes.
http://download.oracle.com/javase/7/docs/api/java/util/Currency.htmlJRebel Newsletter
LiveRebel is also worth mentioning. This product allows Java EE Hot Update without downtime, no lost session, no OutOfMemoryErrors, fully automated. Here is the demo.
Wednesday, 12 October 2011
Download AppDynamics Lite 2.0
- monitor JMX metrics
- include proactive email alerts when errors are found
Alfresco Certification
More details here: http://university.alfresco.com/accreditation.html
Tuesday, 11 October 2011
Spring roo fixes bugs.
Thursday, 6 October 2011
Use Tomcat for EJB?
Alfresco 4
Alfresco Community 4, the first open platform for social content publishing is now available to download for free. Alfresco 4 includes new tools which allow developers to create social and cloud-scale, content-rich applications. Further, it includes a new, extensible service to publish content and status updates to social sites, including YouTube, Facebook, LinkedIn, Twitter, Flickr and SlideShare.
See details here
IBM SDK Java Technology Edition Version 7
Wednesday, 5 October 2011
Assertiveness training
Remark: This advice is relevant to Polish language and culture. In many others it could be seen as impolite or without any sense. ;-)
Assertive refusal has to have three parts:- The word No
- Information on how you will behave
- Short explanation
- Expression of your being sorry
It is important not to excuse yourself to much. If not, it will be harder to stop repeated requests. There are some techniques that can be used if you are asked for something again and again:
- Broken record - repeat still the same explanation
- "I am elephant" technique - Say slowly, ask, paraphrase.
- Jujitsu - If you are faced with the argument that a he/she has helped you in past, but now you are not willing to help him. Remember to thank him, but tell him that this time you cannot help.
- authority - refer to the standards or authority
- Think what will happen if you don't succeed.
- State your request in a short and logic way.
- End with a question about the actual decision (time or price).
Reaction for judging critique
You have two possibilities. You can say:- I agree. That's what I think.
- I do not agree. I don't think about myself that way.
Feedback can be positive and negative. It has to contain 3 parts:
- Fact - that has happened
- Attitude - how do I feel about it
- Expectation - what do I expect, how this person should behave.
Caching requests with status 301 in the browser
Tuesday, 4 October 2011
Astah version 6.5
Monday, 3 October 2011
Alfresco Mobile
Free version of JRebel
Sunday, 2 October 2011
Cloud Foundry Deployments with Maven
Friday, 16 September 2011
Spring Roo 1.2.0.M1 released
- Ten times faster
- Now Apache licensed
- Moved to GitHub
- Adding service layer
Wednesday, 14 September 2011
Some thoughts about plans
Tuesday, 6 September 2011
Friends of Astah
You can profit from it in the following ways:
- 1-year license of Astah Professional
- The use of Friends of Astah logo
- Publishing your activity (links to blog/articles/books)
- Friend of Astah membership sticker
Forcing a download dialog in the browser
Content-Disposition: attachment;filename="our_file_name"
To read more about http headers look at: http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
Saturday, 3 September 2011
LOGBack
It allows us to have an abstraction level of logging, so we can use API for logging and change only configuration to use an other framework in runtime producing logging.
Some new features: parameterized logging statements, abstraction of configurable encoders, Mapped Diagnostic Context (adding useful context information to every log line e.g. user who started current operation), event filtering
If you want to learn how to migrate to LOGBack read: http://logback.qos.ch/manual/migrationFromLog4j.html
Javaagent
To create your java agent you must implement method:
public static void premain(String agentArgs, Instrumentation inst);
and you have to archive this class into a jar file, that contains also file META-INF/MANIFEST.MF, with additional attribute Premain-Class with value of class that will be intercepted.
Then just run your application adding parameter -javaagent:your-jar-file.jar
Friday, 2 September 2011
Google App Engine changes!
- reduction uptime to 99.95%
- have 3 year deprecation policy, to plan application changes more easily due to API changes.
Thursday, 1 September 2011
How to add Facebook button to your site?
Similar integration for Google Plus is available here http://www.bloggerplugins.org/2011/06/add-google-plus-one-button-on-blogger.html
Wednesday, 31 August 2011
What is not possible with JRebel?
- Replacing superclass
- Adding and removing implemented interfaces
Tuesday, 30 August 2011
How to change classes in the running java application?
- Hot deploy - Application is redeployed by application servers after the update of code. Usually after a few redeploys application server has to be restated because of possible memory leaks.
- HotSwap - Allowed since Java 1.4. We can change the methods' definitions in classes during debug session. We cannot change class fields or add new methods, constructors or classes.
- OSGI - Allows us to change modules of application. It is faster then Hot deploy, but we need to design our application to be OSGI modular, which requires more expensive and more difficult development process.
- Throwaway class loaders - Many frameworks use components that are loaded in separate class loaders.The whole class loader is reloaded after the change, e.g. Tapestry, Seam, ...
- Use JRebel - a tool updating class definitions. JRebel operates on class loaders.
Monday, 29 August 2011
java.util.Objects - new util class in Java 7
We have the following methods:
- compare(T a, T b, Comparator c):int Returns 0 if the arguments are identical and c.compare(a, b) otherwise. Consequently, if both arguments are null 0 is returned
- deepEquals(Object a, Object b):boolean Compares objects or Arrays
- hash(Object... values):int Generates a hash code for a sequence of input values
- T nonNull(T obj) If obj is not null, return obj else throw a NullPointerException
and other useful methods.
Look for more in javadoc: http://download.oracle.com/javase/7/docs/api/java/util/Objects.html
Sunday, 28 August 2011
AppDynamics Lite - measuring performance
It has some limitations, e.g. limited number of monitoring transaction types, but you can easily start using it. I have successfully connected it to three different applications on different servers: ATG on Jboss, one based on Spring framework on Tomcat, and CQ Day CMS instance.
Try for yourself: http://www.appdynamics.com/lite.php
Friday, 26 August 2011
How to lead self career?
- Do not start to many things. Focus on a reasonable amount.
- Share your knowledge and responsibilities, so that you have time to learn new things.
- Think how to capitalize your knowledge, activities. Make a plan. Maybe you will profit from it in a few years' time.
- Specialize in areas that will make you a more valuable employee.
- Prepare a long-term strategy for your career and revise it regularly.
Wednesday, 24 August 2011
Compressed oops in the Hotspot JVM 7 - new optimization
So unfortunately, on a 64 bites platform, applications need bigger heap.
In Java 7 by default, for heap smaller than 32GB, pointers are saved as 32 bites offset from the address of heap beginning. For bigger heaps pointers are addressed with 64 bites.
Wednesday, 17 August 2011
Questions to the employer on an interview
Some of the suggestions:
- What time does work start and ends?
- Which IDE and CI are used?
- Are there any internal trainings?
- Is unit testing used?
- Is wiki used?
- Which libraries and frameworks are used?
- Are there many own libraries created?
- Which work methodologies are used?
- Why does previous employee quit?
- Does work concern more maintenance or new projects?
- What trainings are possible?
- Are there any overtime if so how are they paid?
There is also a question which to choose as we wouldn't have time for many of them.
For me three most important are: 3,6, 10.
Tuesday, 16 August 2011
Tools for drawing UML
First an on-line website http://yuml.me/. It just create an image file with an UML diagram based on simple test instructions. Check it!
Other tools for creating UML based on textual notation:
Spring Roo 1.1.5 released
New release has 95 improvements and bug fixes.
More details on: http://www.springsource.org/node/3173
Monday, 15 August 2011
Apache Tomcat 5.5 end of support
That means that after October 1, 2012 bugs and security issues will not be fixed for version 5.5.x.
After December 31, 2012 download pages will not be available any more.
Users of those tomcat version should proceed with migration to the newer version.
Sunday, 14 August 2011
JRebel for MyEclipse
This version will work only with this IDE. It is cheaper, so if you use only myEclipse or thinking of buying JRebel license for it you can save money.
Now it is 165$ a year. Full version costs from 200$.
More info on http://www.zeroturnaround.com/jrebel/myeclipse
Saturday, 13 August 2011
News from the JavaBlackBelt
Everyone can test their knowledge now also in exams concerning Java 7, Android, Oracle SQL.
To see more go to http://www.blackbeltfactory.com
Sunday, 24 July 2011
JRebel changes prices
So new prices are:
JRebel Personal: $130
* Same as JRebel Base, but for individuals, students, and non-profit organizations
JRebel Base: $265 / user license per year
* Previously titled JRebel Standard, this version is for most small-medium sized teams. It supports all major IDEs, containers, application servers, and over 35 frameworks; plus we like that it makes us think of a galaxy far far away...
JRebel Enterprise: $365 / floating license per year
* This is the version of JRebel suitable for most enterprises. It includes everything from JRebel Base, then adds a License Server for Centralized Management and Reporting. Plus, multiple people can use the same license across an enterprise, as long as they’re not using it at the exact same time.
Premium Support Add-On: +$50 / license per year
* Only available for orders over 10 licenses, we’ll provide your organization with “Getting Started” and “Advanced JRebel Usage” webinars for your team, using the same technology you have in your environment. Any support cases you have will receive priority treatment, and we’ll ensure 1-hour response times during business hours.
If you consider buying you can do it cheaper and even for few years with multi year license.
And if you want to see what the new changes are in list of supporting frameworks, look at:
http://www.zeroturnaround.com/jrebel/changelog/4-x/
Saturday, 23 July 2011
How to export variables by a script in bash?
Just run script with preceding . or source
. ./script.sh
source ./script.sh
This time script will run within the existing shell. This is what we wanted!
Friday, 22 July 2011
Eclipse shortcuts
List of useful ones :
Assistant - Ctrl + 3
Content Assist - Ctrl + Space
Find Next - Ctrl + K
Find Previous - Ctrl + Shift + K
Find and Replace - Ctrl + F
Quick Fix - Ctrl + 1
Undo - Ctrl + Z
Redo - Ctrl + Y
Select Enclosing Element - Alt + Shift + Down
Select Next Element - Alt + Shift + Right
Select Previous Element - Alt + Shift + Left
Word Completion - Alt + /
Close All Files - Ctrl + Shift + W
New File - Ctrl + N
Properties - Alt + Enter
Declaration in Workspace - Ctrl + G
Find Text in Workspace - Ctrl + G
Open Search Dialog - Ctrl + H
References in Workspace - Ctrl + Shift + G
Change Method Signature - Alt + Shift + C
Extract Local Variable - Alt + Shift + L
Extract Method - Alt + Shift + M
Inline - Alt + Shift + I
Refactoring, Move - Alt + Shift + V
Refactoring, Rename - Alt + Shift + R
Refactoring Menu - Alt + Shift + T
Delete Line - Ctrl + D
Delete Next Word - Ctrl + Delete
Delete Previous Word - Ctrl + Backspace
Expand - Ctrl + Numpad_Add
Expand All - Ctrl + Numpad_Multiply
Move Lines Down - Alt + Down
Move Lines Up - Alt + Up
To Lower Case - Ctrl + Shift + Y
To Upper Case - Ctrl + Shift + X
Add Javadoc Comment - Alt + Shift + J
Format - Ctrl + Shift + F
Organize Imports - Ctrl + Shift + O
Source Quick Menu - Alt + Shift + S
Tooltip Description - F2
Comment - Ctrl + /
All Generic Views - Alt + Shift + Q
Debug Menu - Alt + Shift + D
Debug Last Launched - F11
Run Menu - Alt + Shift + X
Run Last Launched - Ctrl + F11
Run to Line (In Debug) - Ctrl + R
Navigate Backward History - Alt + Left
Navigate Forward History - Alt + Right
Go to Line - Ctrl + L
Go to Matching Bracket - Ctrl + Shift + P
Last Edit Location - Ctrl + Q
Call Hierarchy - Ctrl + Alt + H
Open Declaration - F3
Open Resource - Ctrl + Shift + R
Open Structure - Ctrl + F3
Open Type - Ctrl + Shift + T
Open Type Hierarchy - F4
Open Type in Hierarchy - Ctrl + Shift + H
Quick Hierarchy - Ctrl + T
Quick Outline - Ctrl + O
Activate Editor - F12
Maximize Active View - Ctrl + M
Next Perspective - Ctrl + F8
Next view - Ctrl + F7
Switch Editor - Ctrl + E
Key Assist - Ctrl + Shift + L
It is worth to remember some of them!
Thursday, 21 July 2011
Website for managing tasks - RememberTheMilk
I can recommend the website for managing tasks.
Try http://www.rememberthemilk.com/
You can use it for free in the browser. Only smartphone applications are paid. But it is a big plus to have the access not only on the computer, but as well on your phone.
It is owned by Yahoo, so don't be afraid that all you have typed in may one day disappear!
Usability of this site is also quite good. Just give it a try!
Wednesday, 20 July 2011
Revolution with JRebel
It really makes java development faster. You do not have to restart application or application server after changes in Java classes any more.
To see how to install it in your IDE, go to:
http://www.zeroturnaround.com/jrebel/documentation/
To quote statistics from JRebel site:
* 17.5% - the average percentage of coding time spent redeploying (this varies on the size of the app, of course)
* 10.5 - the # of minutes wasted per hour of coding
* 4.38 - the # of hours wasted per week
* 5.25 - number of full work weeks wasted per year (40-hour weeks).
* ...and over 18 hours per month of preventable redeploys during your JRebel LiquidMetal license period!
So you can try 30-day trial license and if you want to buy it look at:
http://sales.zeroturnaround.com/
Thursday, 14 July 2011
Vaadin Plugin for Spring Roo
It seems that Roo starts to be the platform for fast production and deployment prototypes for many web frameworks.
More info on:
http://vaadin.com/blog/-/blogs/spring-roo-tutorial and http://vaadin.com/book/-/page/rapid.html
Wednesday, 13 July 2011
Alfresco Team
Alfresco Team™ is a pro-tool for content collaboration. If your team creates and collaborates on content - business documents, spreadsheets, presentations, designs, images, videos, or audio - Alfresco Team handles it. From the whiteboard to the final version, from your desktop to your mobile tablet, Alfresco Team has you covered.
This full install of Team includes 5 users and up to 500 documents (for free), runs on a Windows or Linux server, and can be easily upgraded to a paid subscription when you are ready to buy more users or support.
http://team.alfresco.com/
Monday, 11 July 2011
Thrift alternative for Web Services
History:
It was created by Facebook team, to exchange data between modules written in different languages (C++,Java,Python,PHP, ...)
They found a few alternatives to use: SOAP (excessive XML parsing), CORBA (heavyweight, over-designed), COM by Microsoft (not open source), Pillar (missing versioning, abstraction), Protocol Buffers (closed source, owned by Google).
Due to those cons they started project Thrift.
In April 2007 they made it opensource and in May 2008 it was moved to Apache Incubator.
Now it is used by Facebook, Twitter, Amazon, Recaptcha.
Thrift is written in C++. They have not found any suitable library to use in C++ for thread management, so they developed also that part in the library, using Java Thread Library concepts as template.
Protocols:
Thrift allows to use following protocols: binary, dense encoding, json, useful for debugging. Protocol abstraction can be easily changed transparently from other parts of system.
Transport:
On the transport level we can used blocking/non-blocking sockets, files, shared memory.
Servers:
We have blocking, non-blocking, single threaded and multi-threaded servers.
Supported languages:
C++, C#, Erlang, Haskell, Java, Objective C/Cocoa, OCaml, Perl, PHP, Python, Ruby, Squeak.
Types:
Thrift does not add own types, but uses key types used in most languages and maps them to the ones used in the target language.
We have base types: bool, byte, i16 (signed 16-bit integer), i32, i64, double (64-bit floating point value), string ( UTF-8 encoding), binary: a sequence of unencoded bytes.
We have also containers of types: ordered list with duplicates (target ArrayList in Java), unordered set of unique elements (target HashSet in Java), map of unique keys to values. With compiler directives we can change container types for target languages.
We can declare structures, that will be mapped for classes in target languages. Every structure has a list of fields. Every field has unique name and numeric identifier. If can also have default value. If we do not specify identifier, than it will be added by Thrift. Identifiers are used for versioning. In the generated structure we have fields that inform whether the value was set by the other side of communication or not. Developer can decide how to treat this situation as an error or resolve inconsistencies.
f.e.
struct Book
{
1: string name,
2: i32 pages = 100,
3: Author op,
4: optional string comment,
}
We can define enums and exceptions, that will be compiled to abstract exception class in the target languages.
We declare services that are equal to defining interfaces. Compiler generates stubs implementing interface. Then in servers and clients we implements communication.
We can declare methods as void or async void. The first provides that the execution of method on the server was done, and the second only that the request to execute was done.
The scheme of usage Thrift is as follows:
create thrift script, generate code by compiler, write servers and clients using library objects.
Thrift do not support: cyclic structs, struct inheritance, overloading, heterogeneous containers, null return.
It gives: lower overhead due to the usage of binary format, simplify usage (no framework to code to, no XML), application-level wire format and the serialization-level wire format cleanly separated, soft versioning of the protocol, no build dependencies.
It can be recomenended for creating high-performance services, called from multiple languages when speed is a concern, but clients and servers are co-located.
http://thrift.apache.org/
Wednesday, 6 July 2011
Java not yet dead!
I have recently read an article about Thrift architecture, where authors concluded, that Java thread architecture was the pattern for their solution. In C++ there were no library, that allowed them to get equal performance.
It looks like Ruby on Rails have similar problem.
Twitter after such change gained triple drop in search latency.
Ctrl + Space in Windows 7
So after installation of Eclipse I was faced with a problem of not working shortcut CTRL+SPACE.
This shortcut is used by Windows7 to change system language.
I have found a webpage with description how to fix it:
http://www.mkyong.com/java/content-assist-ctrl-space-is-not-working-eclipse/
Now it works!
Monday, 27 June 2011
Changes to Java certificates. Not August 1, but September 30
But I have read today, that deadline was postponed to September 30.
So changes apply to following certificates:
Java Architect, Java Developer, Solaris System Administrator and Solaris Security Administrator
Details on:
http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=449
Sunday, 19 June 2011
Astah for UML
I have found that ArgoUML hasn't had any new releases for a few years.
However, I found Astah. It is quite a useful tool.
http://astah.change-vision.com/en/index.html
The community version is free.
So if you need to build UML diagrams, I can recommend it.
Friday, 17 June 2011
Problem with preferredMapping in Spring roo
In command controller class I used attribute --preferredMapping createSimple
So attribute consist capital letter, it cannot have as a value with capital letter.
In generated controller mappings on controller and to view names was not correct. In html it was generated lower case, but in mapping was with a capital ones. I have to fix them by had for it running.
Monday, 13 June 2011
Problem with roo + gwt
It ended with the problem using gwt web frontend, with an error:
GWT module's gwt.xml file not found; cannot continue
I have found the cause: https://jira.springsource.org/browse/ROO-2445
So in Spring roo ver. 1.1.4 generating gwt web is not working
Friday, 10 June 2011
Referer
f.e. I used Referer header to know which from which page new request comes.
I have discovered that it is not always true. On Firefox it was, but on Chrome and IE when the link was clicked in the Flash object Referer was set to the address of that flash object.
So be careful, Referer can be
- url of the page on which link was clicked,
- url for the flash object on which link was clicked.
Wednesday, 16 March 2011
Principles of object-oriented design
introduced by Robert C. Martin
- Single responsibility principle (S) - that an object should have only a single responsibility
- Open/closed principle (O) - “software entities … should be open for extension, but closed for modification
- Liskov substitution principle (L) - objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program
- Interface separation (I) - many client specific interfaces are better than one general purpose interface.
Dependency inversion principle (D) - Depend upon Abstractions. Do not depend upon concretions.