OSGi Servlet with HSQLDB - servlets

I am looking for an easy way to use HSQLDB with an OSGi Servlet. I allready created an OSGi Bundle out of the HSQLDB.jar following this guide:
http://www.vogella.com/articles/EclipseJarToPlugin/article.html
But now I can't seem to figure out how to use the HSQLDB from a Servlet inside another Bundle. I can't find any good step by step guides either. I would appreciate if someone could point me into the right direction.
Thanks in advance

HSQLDB has an 'official' bundle in the MvnRepository. Generally it pays off to look around for bundles before converting one yourself. Sometimes it's easy, but often it's trickier to get right.
Mind you, the article you quote is quite old and (while still correct as far as I can see), there are many more possibilities nowadays.
In any case, to work in OSGi, you need to understand how services work. From that point on, servlets are services, and no different than any other service.
When I started fooling around with OSGi, the Felix documentation was a great help to me. I also recommend taking a look at Declarative Services.

Related

More than one Controller - Beginners guide

I just started with symfony 4 and have a question about "multi-controller", if my application got many routes, should i go for more controllers to keep the files tiny and readable or is one controller enough / recommended?
There is no recommended way about multi-controllers on the official documentation.
If multi-controller is a good choice, how to split?
If there a good documentation on the inet?
Absolutely yes, you should have more than one controller. Symfony's best practices recommend to keep your controllers tiny and delegate much of your application logic to services that you create to handle different actions. For this, it is essential that you have a basic understanding of Dependency Injection, the Container pattern and, more specifically, how Symfony's DI Container works (how you can register services, for example).
There's tons of documentation on Symfony in the intenet. This one on controllers.
KnpUniversity has some really good tutorials to get you started. Start with the Symfony series, then follow with Symfony Internals.
Also, you will greatly benefit from the features of the maker bundle, that will generate code for you really quickly. You can install it with composer require maker. Then, you can create a controller running php bin/console make:controller.

How to handle routing in a DukeScript web application

DukeScript looks like a life saver for we Java guys! I am considering it for a serious project. Was curious to know whether it's production ready and well documented. Also, liked to know what would be the best way to support routing in a web application.
I asked this question at the official google forum, but didn't get a reply. So, thought to re-ask here.
Here's a blog post with a little example. It shows a simple integration of location hash based routing with knockout templates. The full example code is available on github.
You might also use one of the javascript libraries like sammy or pagerjs, which would require integration with these frameworks, but I wanted to keep it simple.

Symfony2 - Using old external library without namespaces

Let me preface this by saying that I am normally not a PHP developer, and am a complete beginner when it comes to Symfony2. I was kind of thrown into this project, and we are on a pretty tight deadline.
With that out of the way, here is my problem:
At my company, we have a PHP library for an internal API which is old; it doesn't use namespaces and it doesn't really follow any standard naming convention such as PSR-0 or PEAR. However, I need to use this in our Symfony2 project. Symfony2 obviously relies on namespaces a lot. Am I completely screwed if I don't update the library to follow the "new" conventions, or can I somehow use it anyway? The thing is, it is a pretty huge library, and we simply don't have time to do that right now (someone should have done it ages ago, but that is another topic...).
Theoretically, could I just place the lib under vendor/ and use good old old requires/includes in my bundles? Will this even work? Will I get a mob of angry Symfony/PHP developers after me by doing this?
Or, is there a better way that I'm not aware of?
You can do what you suggested, and you can even use the MapClassLoader, and give it a static map between your classes and your files, so that you don't even need to require files from your library. You don't have to write this map by hand, you can generate it with the class map generator

EJB 2.x to 3.x automatic migration tool

Could someone recommend me an automatic migration tool for EJB?
Preferably some Eclipse plugin... Thanx!
I'd suggest using IntelliJ EJB refactoring tools:
http://www.jetbrains.com/idea/webhelp/migrating-to-ejb-3-0.html
Four years ago I wrote some tooling in perl. But from todays perspective I think going through the sources in a day, removing unneeded stuff and adding annotations by someone who has seen both technologies is the best.
It is at the end not enough to just put #Stateless into a bean class that had its stateless definition in xml before - you also want to use #EJB annotations to inject other beans and most likely remove old CMP or BMP data access with JPA, which uses a different semantics etc.
While some tooling may exist, I think best is going over the existing source with a fine comb so that you know what you are doing.

How to use NHibernate with asp.net 3.5

I want to use NHibernate with Asp.net 3.5 but i don't know how to use it.I search on
Google but couldn't find the complete explanation about why to use NHibernate,Advantages of using it and integration with Asp.net projects.
I would suggest checking out Castle and NHibernate. I recently started using it and was blown away with what it can do. Castle manages all your sessions for you. Also it is easy to use LINQ with it.
Check out
http://davidhayden.com/blog/dave/archive/2008/04/28/NHibernateCastleActiveRecordTutorialUninitiated.aspx
Another great tool to use (Should work with ASP.Net) is the Nhibernate Profiler
http://nhprof.com/ It shows you what queries are being generated and the time its taking to run.
Also if you already have your database created you can download this tool http://www.agilityfororms.com/Home/Products/AfoCastleActiveRecordModelCodeGenerator/ It will create your models based on your database. Its works great for the most part. Although you have to register to download the free version still worth checking out.
Fluent NHibernate is supposed to be good as well although I have no experience with it. Might be worth checking out. http://fluentnhibernate.org/
You could have a look at this :
http://www.codegod.de/WebAppCodeGod/nhibernate-tutorial-1---and-aspnet-AID25.aspx
And this :
http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx
I'm nearing completion of my first project with it, and I've had mixed results. For basic data persistence, and assuming you already knew how to use it, it's much faster to build an application with it. You don't really have to worry about building stored procs and differentiating between new objects and updated objects.
On the other hand, until you're quite comfortable with it, it can take a long time to do something that would have been simple before. I've had a couple of problems, and it has been difficult and time consuming finding solutions to them.
To be fair, I've only written small applications with it and it has made the development process more difficult than I would consider required. The pain of using it is fairly similar from one app to the next, the benefits scale...
The best place to look is at NHibernate Forge. There's Blogs, wikis and groups that will help you out.
As for advantages of using it that is something you need to workout for yourself. Is it more advantageous than LinqToSql or Entity Framework? It depends on the project size and what you are actually looking for.

Resources