Job opportunity at the Cologne/Bonn area

This site is home of my personal blog. But today I’m going to write about my principal occupation. I am the division manager software development at the German DRG institute [1]. In this role, I’m looking forward for a software developer to join the team.

If you fluently speak Java or C# (best: both of it) as well as SQL, then you might be a perfect candidate for this challenging job. Experience in web development with Java is most welcome. Join an engaged and agile team.

This opportunity is a mostly inhouse job. It is a permanent position. The software we create is used to develop the hospital reimbursement system. It is used within the institute a well as for hospital communication via a web based data portal. Thus, the dialogs of the software have an almost German interface.  If you do not speak German, fluent English and the willingness to learn German are precondition.

If you’re interested, let me know. For further information, I added a link to the job advertisement [2].

Freelancer and recruiter shall not response to this job advertisement. Thank you for understanding.

I am looking forward to meet you.

All the best,
Michael

 

[1] inek-drg.de

[2] inek-drg.de/content/download/6821/51586/version/3/file/Anzeige_InEK_Softwareentwickler.pdf

Retrieve ViewScoped bean from session map

Since JSF 2.0 it is preferred to use CDI beans over JSF managed beans [1]. Different annotations are available to support different scopes, e.g. @RequestScope or @SessionScope. Sometimes you need to access such a bean from a piece of software where you don’t have direct access to the FacesContext.

Lets assume, you run a different, non-JSF servlet and you need to access an instance of MyBean which is a JSF CDI bean.

public class MyServlet extends HttpServlet {

  @Override
  protected void doPost(HttpServletRequest request, 
                        HttpServletResponse response) {
    HttpSession session = request.getSession();
    MyBean myBean = ???
  }

}

The HttpSession object contains a map of all session objects. This includes instances of the CDI @SessionScoped objects. Accessing such an object is pretty easy. Bauke Sholz described this in [2].

MyBean myBean = (MyBean) session.getAttribute("myBean");

But, if we need to access a CDI @ViewScoped bean?

Within the session map, an entry “com.sun.faces.application.view.activeViewMaps” exists containing a map of maps of beans. We can iterate through it to extract the wanted bean.

    Map map = (Map) session.getAttribute(
               "com.sun.faces.application.view.activeViewMaps");
    MyBean myBean = null;
    for (Object entry : map.values()) {
      if (entry instanceof Map) {
        Map viewScopes = (Map) entry;
        if (viewScopes.containsKey(name)) {
          myBean = (MyBean) viewScopes.get(name);
          break;
        }
      }
    }

Using generics, we may create a small method to retrieve any @ViewScoped bean.

    ...
    MyBean myBean = retrieveBean(MyBean.class, session);
    ...
  }  


  private <T> T retrieveBean (Class<T> clazz, HttpSession session) {
    String name = clazz.getSimpleName().substring(0, 1).toLowerCase() 
                + clazz.getSimpleName().substring(1);
    Map map = (Map) session.getAttribute(
            "com.sun.faces.application.view.activeViewMaps");
    for (Object entry : map.values()) {
      if (entry instanceof Map) {
        Map viewScopes = (Map) entry;
        if (viewScopes.containsKey(name)) {
          return (T) viewScopes.get(name);
        }
      }
    }
    return null;
  }

Enjoy!

 

[1] Read about this in Web Development with Java and JSF

[2] stackoverflow.com/questions/2633112/get-jsf-managed-bean-by-name-in-any-servlet-related-class

Publication page updated

I updated the list of my publications [1]. I’ve been astonished, how much articles I wrote beside the articles of this blog during the last few years. Most articles dealing about software development. Some of them describing NetBeans or dedicated features of this great IDE.

I hope, I could provide a lot of useful information with my articles. Beside that, with every article I write, I learn some new aspects of the described subjects. Thus, writing articles is not only helpful to my readers, but to myself too. A kind of win-win situation  😉

Yes, and I’m going to update my review list [2] soon.

Thank you for reading and stay tuned!

[1] blog.mueller-bruehl.de/publications

[2] it-rezension.de

Java Shell plugins for NetBeans 8.2

A few days before, I reported about the Java Shell which is integrated within the NetBeans nightly builds [1].

There is another project, called prototypes-repl9 [2] which is compiled only once or twice a month. Until today, I only downloaded some full zip versions of this project. This seemed to be less stable and less up-to-date than the development version. But, due to a tip (from @OMihalyi) I tried the plugins only: And they integrate well with NetBeans 8.2 [applause]. The latest build is only few days old and seems to be really up-to-date.

The screenshot above shows the project page (as is today). You’ll find five links to the nbm files. Simply click and download them.

Next within NetBeans open the plugin editor (Tools, Plugins) and choose the download tab. Click Add Plugins and browse for the downloaded files. Finally choose Install.

Have fun with your Java Shell! For instructions refer to my former post [1].

 

[1] blog.mueller-bruehl.de/netbeans/netbeans-and-the-java-shell

[2] deadlock.netbeans.org/job/prototypes-repl9/?