|
|
||
Michael Nascimento Santos's BlogPerformance ArchivesMaking your components work nicer inside MatissePosted by mister__m on February 20, 2008 at 07:20 AM | Permalink | Comments (4)A co-worker had been developing some nice-looking custom components for a customer project. It was tightly integrated with the backend logic, though, so he tried to use it with Matisse, there were several issues, from class loading errors to slowness, since the component was trying to do its "real task" inside the designer. So, when he told me that, I immediately recalled a trick I came to know way back in 1999, while I was struggling with Java and Swing for the first time. The He changed the component constructor to check for design time and skip the "black magic" section. It worked like a charm and he said it was the best tip I gave him last year. So now I've finally had the time to blog again, I thought it would be an interesting tip to share :-) Announcing genesisPosted by mister__m on December 13, 2004 at 10:27 AM | Permalink | Comments (1)A few weeks ago, we've silently released the first public beta version of genesis. But what is genesis about? genesis is open-source software (LGPL) and its main objective is to allow you to build powerful, scalable applications in a simple, productive and testable way. Although its long term goals are much more ambitious, right now it focuses on two main areas:
genesis does not try to reinvent the wheel, but rather builds on top of several other open-source projects to deliver its functionalities. Besides Thinlet, this release relies heavily on AspectWerkz and AOP to implement a flexible core so that new ways to do remoting or to configure a form - using xml, for example - are easy to write and don't require any changes to existent genesis code. So, if you are looking for practical ways of using AOP, check out genesis sources. genesis is already running on production environments and, in one of them, the server-side application is capable of handling more than 1.125 million transactions per day with a single box. You can access genesis docs and download it at https://genesis.dev.java.net UPDATE: genesis was the 2nd largest java.net project by commits last month according to this report, so it is really worth a quick look. ;-) Playing with the Tiger: Measuring the size of your objectsPosted by mister__m on February 05, 2004 at 07:14 PM | Permalink | Comments (4)As I said, I'm back with more on the new JDK 1.5. There is a new package called
import java.lang.instrument.*;
import java.util.*;
public class InstrumentationTest {
private static Instrumentation inst;
public static void premain(String options, Instrumentation inst) {
InstrumentationTest.inst = inst;
System.out.println("options= " + options);
// Get all classes currently loaded by VM
Class[] loaded = inst.getAllLoadedClasses();
// Sort them by name
Arrays.sort(loaded, new Comparator
Save it as javac -source 1.5 InstrumentationTest.java To allow our class to be useful, we have to start the VM using this verbose command: java -ea -javaagent:InstrumentationTest -cp . InstrumentationTest Someone might be asking how it could be useful. As a friend of mine, Bruno Borges, suggested to me, it could give you a good idea if Prevayler is the right tool for your needs. Hope you've enjoyed it. More to come! Playing with the Tiger: Measuring nanosPosted by mister__m on February 05, 2004 at 06:41 PM | Permalink | Comments (10)Ok, sorry for not blogging for so long, but I have to work, date etc. :-D I hope this is the start of a series of small, but informative blog entries about new features available in Tiger, especially the ones a hundred people haven't mentioned before me :-D To begin with, I'll show you how to use the new nanoTime() method in Here's the code:
import static java.lang.System.*;
public class Nano {
public static void main(String[] args) {
long time = 0;
long newTime;
long smaller = 9999999999999L;
for (int i = 0; i < 100000; i++) {
time = nanoTime();
newTime = nanoTime();
smaller = Math.min(smaller, newTime - time);
}
out.println("Smallest nano interval measured: " + smaller);
out.println("Current time millis: " + currentTimeMillis());
out.println("Nano time: " + nanoTime());
}
}
Save it in javac -source 1.5 Nano.java Then run it normally with: java -cp . Nano My results (P4, 1GB RAM, Windows 2000 Pro) are: Smallest nano interval measured: 1116 Current time millis: 1076038988125 Nano time: 8736336585045 This method is intended to be used as a way to measure performance, for instance. Here, I just tried to get its precision in my current box configuration. Please let me know if you get smallest nano intervals in your platform/configuration. See you soon ;-) Stop the hype about webservices!Posted by mister__m on January 09, 2004 at 07:44 AM | Permalink | Comments (31)I know, I have never been really aggressive in any of my posts. The problem is that, even though there are some wise people - I am not wise, I am just reasonable - telling people they are doing bad things, they keep on doing it. I ought to speak out, then. I have no choice. I can't see people doing something so irrational and still remain silently. Sorry folks, if this entry offends you, but this time it is necessary. It is for your own good. It's like taking medicine that tastes horrible; you don't like it, but it is for your own good. So, what are webservices for? No, I am _not_ talking about technical definitions here. The real question is: what are webservices meant to be used for? That's hard to answer. So, I'll explain to you what most are missing by answering the simpler question, in my opinion: what are webservices not meant for? Let's go for a couple of examples:
In my own experience - and what my friends have been telling me just proves me I am not wrong -, XML processing takes from 25% to 95% of the total processing time for most usages people are making of it. It is perfectly ok to use XML for configuration; it is generally parsed while your application is starting up, so, there is no real overhead to the end user if it's correctly implemented. But people are using XML - not just webservices - for a lot of reasons; they are using it for generating HTML when JSPs, Velocity or whatever would be faster and simpler by far. Then, they say: "it is easier, because designers don't have to deal with Java". Is it really a good reason? Let me see: you have to convert all your objects to XML - a slow marshalling operation, in most cases -, then someone has to write XSL - if it is the designer who writes it, I am sure s/he would get JSP, JSTL and Velocity; if it is the developer, s/he has to constantly rewrite it as page design/flow changes - and a big bloated XSLT processor has to run - don't tell me that just because now you can compile xsl it is better than plain old Java code. Are there any advantages if you are using Java in both ends? Don't tell me about future uses; future uses may require overhead. I am talking about the system you are writing right now. There are some situations where using webservices might be wise; if you are integrating with .NET, they might be a good choice - note that they might; it does not automatically mean they are the only technology for the job. There are some other uses, which I am not going to talk about here - as I said, this post is about when not to use webservices. There are some binary formats for webservices, but as far as I could use them and heard people talking about them, the only impression I get is they are still slower than RMI. Webservices might be a good choice for situations where you don't know in what language your clients will be written. Even in such cases, it won't hurt if you expose some plain old interfaces and maybe RMI interfaces too. In fact, a lot of systems will perform better. No, there is no maintainance nightmare here because RMI interfaces and WSDL should be automatically generated. Period. If you are still concerned about loosely coupling, think: What really makes systems loosely coupled? Interfaces. That is it. Integrate your systems using interfaces and provide them for whomever wants to call your code. If you are using EJBs, use local interfaces until something forces you to use remote interfaces. Use business delegates to access them and make each of their methods throw a CommunicationException and have a factory for building their instances. Why? If your backend implementation uses local interfaces, CommunicationExceptions will never be thrown, but your code will have to handle them. When - if necessary - you change to remote calls, your system will keep working, because it was ready for handling those exceptions! Then, if you have to use webservices because someone decided your backend should be written in .NET, you are still safe! Isn't that great? I'll give you one more tip: if you design your systems using naming conventions and standards, you may be able to implement all your factories and business delegates using dynamic proxies! It'll take less than 100 lines of code and your architecture will be prepared for future changes! To sum up, If you are going to use webservices, think before doing so; it is very likely there are better options. | ||
|
|