Any JMX library / framework that makes development easier? - jmx

I am wondering, do we have any framework / library that makes development easier?
For example, Apache Mina or Netty makes NIO programming easier.
I heard of Spring JMX, MX4J, are they very easy to use?

I've used Spring for it. It's very easy to use (especially if you already use Spring in your project) but it cannot handle some more advanced things (like MXBeans). In my current project we use a lot of the things that Spring offers but have implemented some parts ourselves.
http://static.springsource.org/spring/docs/3.0.5.RELEASE/reference/jmx.html

I like servo which was opensourced by netflix.
See [1].
[1] http://techblog.netflix.com/2012/02/announcing-servo.html?m=1

Related

EJB 3.1 or Spring 3.. When to choose which one?

EJB achieved many improvements in 3.x versions, Spring is also commonly used and version 3 is a good alternative.
There are many articles on web, but no exact comparison about ejb3x versus spring3x.. Do you have any ideas about them, in real world examples which one is better at which conditions?
For example, we want to separate db and server, which means our application will be on a server, our database will be in another server.. EJB remoting vs Cluster4Spring etc ?
Doing everyting #Annotation is always good? configuration never needed?
For your use case where the application runs on one server and the database runs on another, the choice between EJB and Spring is irrelevant. Every platforms supports this, be it a Java SE application, a simple Servlet container like Tomcat or Jetty, PHP, Ruby on Rails, or whatever.
You don't need any kind of explicit remoting for that. You just define a datasource, provide the URL where your DB server lives and that's it.
That said, both EJB and Spring Beans do make it easier to work with datasources. They both help you defining a datasource, injecting it in beans and managing transactions associated with them.
Of the two, EJB (and Java EE in general) is more lightweight and adheres more to the convention over configuration principle. Spring requires more verbosity to get the same things and depends a lot on XML files which can quickly become very big and unwieldy. The flip side of the coin is that Spring can be less magical and you might feel more in control after having everything you want spelled out.
Another issue is the way EJB and Spring are developed.
EJB is free (as in free beer), open-source and non-proprietary. There are implementations of EJB being made by non profit organizations (Apache), open source companies (Redhat/JBoss) and deeply commercial closed source enterprises (IBM). I personally would avoid the latter, but to each his own.
Spring on the other hand is free and open-source, but strongly proprietary. There is only one company making Spring and that's Springsource. If you don't agree with Rod, then tough luck for you. This is not necessarily a bad thing, but a difference you might want to be aware of.
Doing everyting #Annotation is always good? configuration never needed?
It's an endless debate really. Some argue that XML is hard to maintain, others argue that annotations pollute an otherwise pure POJO model.
I think that annotating a bean as being an EJB stateless bean (#Stateless) or a JPA entity (#Entity) is more cleanly done using annotations. Same goes for the #EJB or #Inject dependency injections. On the other hand, I prefer JPQL named queries to be in XML files instead of annotations, and injections that represent pure configuration data (like a max value for something) to be in XML as well.
In Java EE, every annotation can also be specified in XML. If both the annotation and the XML equivalent are present, the XML overrules the annotation. This makes it really convenient to start with an annotation for the default case, but override it later via XML for a specific use case.
The current preference in Java EE seems to be more towards (simple) annotations combined with a large amount of convention over configuration.
The real question you should be asking is CDI/EJB or Spring
It's often not Spring vs EJB, but Spring vs Java EE. EJB itself compares to Spring Beans. Both of them are a kind of managed beans running inside a container (the EJB container resp. Spring container).
Overall the two technologies are rather similar. Reza Rahman did a great comparison between the two a while back.
EJB's are more advantageous because of standardization. If you are working with a lightweight application I think going with Spring is fine but if you expect that your application will be big and will require lots of memory access and data connections access you may consider starting your development with EJBs. The main reason being clustering and load balancing are built into the EJB framework.
In an EJB environment, when an EAR ('E'nterprise 'AR'chive) is deployed, it may be deployed with multiple EJBs beans that each could have a specific purpose. Let say you wrote a bean for user management and another bean for product management. Maybe one day you find that your user services way exceed your products access services, and you want to move your user bean to a different server on a different machine. This can actually be done in runtime without altering your code. Beans can be moved between servers and databases, to accomodate clustering and load/data balancing without affecting your developers or your users because most of it can be configured at the deployment level.
Another reason for supporting a standard is knowing that most large third party vendors will likely support it resulting in less issues when integrating with new standard/service/technology - and let's face it, those come out like new flavours of ice-cream. And if it is in a public specification new start-up companies or kind developers can create an open-source version.
http://www.onjava.com/pub/a/onjava/2005/06/29/spring-ejb3.html
It is most unfortunate that even the most intelligent designers or programmers cannot predict which of their features may or may not be embraced by the development community which is the main reason software becomes bloated... Java EE is definitely that!
Choose one or the other, but not both.
My personal preference is Spring. I've used on projects with great success for the past six years. It's as solid as any software out there.
Spring can work with EJBs if you choose to have them in your app, but I don't believe the reverse is true.
I would recommend separate physical machines for web, app, and database servers if you can afford it.
Spring can work with several remoting options, including SOAP and REST web services. A comparison of Spring beans with EJB is beyond the scope of this question. I don't see what it has to do with your implementation. If you use Spring POJO services they're in-memory rather than requiring another network hop like remote EJBs. Think of Fowler's Law of Distributed Objects: "Don't". Only introduce latency with good reason.
I'd mention unit testing here.
In common web application (controller->service->data->...->view) EJB and Spring both provide similar result, but spring offers easier testing.
In my humble experience the way you develop is different in couple of aspects:
Unit test (spring wins). In spring its done pretty stright forward, while in ejb you have to use Arqullian with ShrinkWrap (sic!) which is slow to run on every build.
Persistence (ejb wins). In spring there is struggle around it, i.e. google "how to autowire persistence in entity listener" http://bit.ly/1P6u5WO
Configuration (ejb wins). As newbie coming to spring from ejb I was surprised by swarm of annotations and .xml files.
EJB 3.1 is the best while being the standard for Java 6 EE applications.
Spring still does not support Java 6 CDI(weld) also still depends a lot on XML configuration. EJB 3.1 is powerful and smart.
I think that Spring 3.1 doesn't need any XML configuration. You have the option to use annotations for configuration.

Integrating a Thrift ruby server and a Ruby on Rails web app

In my free time, I'm currently working on a web app written with Rails, and planning on writing "thick" clients for the desktop and various mobile platforms (who doesn't ?).
I like the concept of Thrift for its multi-language support, and the concept of having one IDL file generating appropriate code for clients (DRY !)
I was wondering what would be the best way / architecture to integrate the Thrift server and Rails.
The only options that come to mind seems sup-optimal :
call the wepapp APIs from the Thrift server to return data to the thick clients
plug the thrift server to the DB of the Rails app and do its thing.
For obvious reasons, this seems overkill, redundant and not flexible.
Any suggestion ?
thanks !
I'm not sure if its overkill :) But I suggest if you want to explore this topic even more that you also look into this thread.

Comaprison of Liferay ServiceBuilder to other Code generation tools like AndroMDA

I started digging into the liferay 6.x ServiceBuilder framework and really liked its code generation approach. A simple service.xml file can generate ready to use powerful services without even writing a single line of code.
I also tried looking into AndroMDA which can generate similar services from the UML model, which sounds even more interesting since it will link my business model directly without me needing to learn a new xml config for service.xml (in case of liferay ServiceBuilder)
now I am in the process of deciding which tool should I use. Based on your experience with any of these tools Please let me know what are Pros/Cons of using any of this library,
I am interested to know these aspects, along with your own thoughts
Which is better to keep my development more productive in long term.
If I use ServiceBuilder will I be able to use the services outside portal env (lets say running same service from a non-portal app server.
Is UML driven approach always good or there are some practical cons/challenges of it.
Do you know of any other code generation library which is better than these two for liferay 6.x development? I also checked these SO Threads
Do You Use Code Generators
Java Code Generation
Following few problems I have experienced with Servicebuilder (I am using liferay 5.2.3) :
Not able to make use ORM framework. There is no way to generate
relations among objects. Because of this I am effectively working
just object mapper. It is not generating onetomany kind of relations
Can not use basic object oriented things like inheritance with domain or services
It is quite hard to write unit test cases
I still didn't understand what is the need of complex domain structure
I feel the code it is generating can be quickly written using an IDE
But definitely it has its own benefits like Egar said, it is specifically made for Liferay. So it can quickly generate everything that is needed for liferay. I heard in latest versions of liferay few of above problems are fixed.
Overall it depends on your requirement. If you need more control over your ORM layer and you have complex business logic which needs quite a lot of unit testing, go for normal spring services which can be exposed as webservices or REST services to your portlets.
Otherwise service builder is also good for simple portlets. Other approach could be using both. All complex services as a separate project and simple ones with service builder.
There is an important fact that you should be aware of. ServiceBuilder has been used to help building the portal itself and it is tightly integrated into it. You cannot use it outside of Liferay...I mean it probably could be taken and modified for general usage, but I doubt it would make sense.
Most importantly because Portal and each plugin that you are developing have their own web application context in a servlet container - each has its own classloader. Plugins are using Portal classloader and portal services, etc. etc.
Simply put, ServiceBuilder generated code and spring context can exist only if there is a webapp/ROOT/ which is Liferay Portal with portal classloader etc.
AndroMDA is a MDA framework for general usage. I don't know it much, so that I'm rather not going to make comparisons. The power of ServiceBuilder is that it is not a framework for general usage - the more powerful it is for liferay plugin development.

Node.js as Rails replacement? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Could node.js replace Ruby on Rails completely in the future?
I'm doing bad in understanding the sense of node.js. I understand what it does regarding IO etc., but is it for example a Ruby on Rails replacement? Can I do the same database operations etc.? What about authentication?
what kind of web or other applications get build on basis of node.js?
is it for example a ruby on rails replacement?
IMHO RoR has much longer history/experience/functionality for website development. Node.js itself is a lightweight (low level) framework from which you can take off to build various types of server-side applications (not just web oriented). One of its main advantages is in wide spectrum of modules provided by community of open source developers.
Can i do the same database operations etc.?
Yes, just find the right module for your type of database.
What about authentication?
Modules like connect offers built-in authentication functionality.
Node.js is a totally separate technology to Ruby on Rails, built on a different technology stack. In its current state it's not a replacement for Rails, and certainly not a drop-in replacement
AIUI Node.js is a bit more low-level than that, in particular it has no support for typical high level web development (MVC model, db integration, etc). Look at it as a javascripty basis to write networking software on (including web frameworks).
There are some web frameworks out there built on Node.js. The only one I know is geddy.
Node.JS is to Javascript as EventMachine is to Ruby (and Twisted to Python). It's something completely different from Rails.
To illustrate: the Thin webserver that is often used to serve Rails application was built using EventMachine. So you would need a complete web framework on top of Node.JS to make it a Rails replacement.
You are comparing apples and pears.
Ruby on Rails is a MVC Framework to build websites.
Nodejs is a framework to build evented I/O operations.
You can build a port of RoR on top of nodejs if you want.

How is Spring.Net making my life easier?

"Spring.NET is an open source application framework that makes building enterprise .NET applications easier."
Springframework
They say that Spring makes .Net development easier. Then I see the manual which is long as anything.
Chapter 5. The IoC container
And then I see some mysterious stack trace errors when I run a project that has Spring. How is Spring making my life easier, when everything is so hard?
Edit: The errors come when I run the project, not when I compile like I first wrote. I understand that Enterprise applications need more complex frameworks than normal applications. But they shouldn't be complicated even in that case. I mean, if I want to write some logic, I shouldn't need to go through lots of other stuff.
Edit: I don't have a choice but use Spring, if I start using an existing project that has it.
Note that it says it makes enterprise .net applications easier. Enterprise applications are not really the same as normal applications. They are very large scale applications, requiring designing around massive scalability, portability and extremely flexible configuration. Frameworks that simplify this process are still going to be difficult to use, but are less difficult and more reliable than doing all of that work from scratch.
I would be dubious of using an enterprise framework in a 'normal' project though, as it is most likely extremely overengineered for non-enterprise requirements and could end up being more difficult than coding from scratch in that circumstance.
It provides an IoC container. Yes, using that to its full requires reading quite a lot. The same is true of almost any powerful tool. If you're going to use LINQ, that needs some study too - does that make LINQ useless in your view?
It provides useful utility classes for various things. Often these are things you might roll yourself in other circumstances.
Now, as for why you're getting mysterious stack trace errors when compiling a project which uses Spring.NET... that sounds very odd. We'd need to hear more about the errors to know what's going on.
If you don't understand, you might ought not use spring.....
But Spring.NET is a good framework. It is more than IoC, alot more....
If you don't understand dependency injection/IOC or Aspect Oriented Concepts, spring may not do too much for you and you might as well stick to service locator type things and explicit try/catch blocks all over your code....
I agree with you that it has some learning curve, but that alone should not discourage anybody from learning this really awesome tool.

Resources