Tag: spring

Why not use RESTeasy to create REST services?

Posted by – February 9, 2009

After few days using RESTeasy in my project I found a very annoying issue related with its Spring support, please consider the bean declaration below:

1
2
3
4
5
6
<bean id="remoteAuthenticationService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
    <property name="serviceUrl"
            value="http://${host}:${port}/adminserver/remoteAuthenticationService.esp"/>
    <property name="serviceInterface" value="com.fastsearch.esp.admin.RemoteAuthenticationService"/>
    <property name="httpInvokerRequestExecutor" ref="executor"/>
</bean>

For some reason the RESTeasy ContextLoaderListener implementation is unable to resolve property placeholders used by some properties of beans at singleton scope, when I read these properties from my bean logic I see all properties placeholders there as they weren’t resolved.

So I decided to try Jersey since it uses the standard implementation of ContextLoaderListener that comes with Spring, now my application works as expected, all properties placeholders are being correctly resolved on my Spring singleton beans.

Share

bodyguard – Facelets EL functions for Spring Security

Posted by – November 9, 2008

Yesterday I wrote a small set of EL functions to use with spring security, now I can get easy access to spring security roles and authentication info as well.

Here’s an example of how bodyguard can be used in your facelets code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<html xmlns="http://www.w3.org/1999/xhtml"
   xmlns:bg="http://faces.eti.br/bodyguard">
 <body>
   <!-- Display logged message if the user is authenticated -->
   <t:div rendered="#{bg:isAuthenticated()}">
       <h:outputText rendered="#{bg:remoteUser()}" value="Logged!"/>
   </t:div>

   <!-- Display a message indicating if the user is a user or admin -->
   <t:div rendered="#{bg:isUserInAnyRoles('ROLE_USER,ROLE_ADMIN')}">
       <h:outputText
         value="The user #{bg:remoteUser()} is a user or admin."/>
   </t:div>

   <!-- Display a message indicating if the user isn't a user or admin -->
   <t:div rendered="#{bg:isUserNotInRoles('ROLE_USER,ROLE_ADMIN')}">
       <h:outputText
         value="The user #{bg:remoteUser()} isn't a user or admin."/>
   </t:div>

   <!-- Display a message indicating if the user is a user and admin -->
   <t:div rendered="#{bg:isUserInAllRoles('ROLE_USER,ROLE_ADMIN')}">
       <h:outputText
          value="The user #{bg:remoteUser()} is a user and admin."/>
   </t:div>
 </body>
</html>

You can download the bodyguard by clicking here and sources here.

Share

Creating JSF applications with JRuby and ActiveRecord-JDBC (Part 2)

Posted by – March 16, 2008

My last article about this topic showed how can we start the development of an JSF webapp with JRuby and ActiveRecord-JDBC, we will discuss on this article how can we create the dao, domain class and the view used to show costumer data.

In this example, CostumerDao illustrate how can we perform some data persistence/retrieval using ActiveRecord domain classes, we defined MyCostumer JRuby class to act as a proxy of our domain class:
More

Share

Creating JSF applications with JRuby and ActiveRecord-JDBC (Part 1)

Posted by – March 16, 2008

Is there any way to create JSF applications using scripting languages and its own persistence engines? The answer is: Yes! After some hours trying to integrate JSF + JRuby + ActiveRecord I finally could get a very simple application working, this application contains only one page where the user can add some costumer data, we have jsp as view, spring as IoC container and integration point with JRuby, ActiveRecord-JDBC as ORM.

The page has a managedbean defined as Ruby class, each Ruby bean must implement a Java interface to allow integration with Java/Spring, when the bean is requested by Spring a Java proxy class is instantiated based on its Java interface and then all Ruby code can be consumed properly.

If you wanna try by yourself you must create a webapplication and add the jars described on my previous post (except groovy-1.5.4.jar) plus these jars below on WEB/lib folder:
More

Share

Usando o Spring para gerenciar beans do JSF

Posted by – September 22, 2007

Eu estava conversando alguns dias atrás com um colega commiter do projeto MyFaces sobre padrões de projeto, melhores práticas e etc, em um dado momento ele me disse da possibilidade de se definir beans no Spring que podiam ser usados dentro do JSF obtendo o mesmo resultado quando se define um bean no faces-config.xml porém com todo um suporte de AOP e outras funcionalidades que só se encontram no Spring. Maiores detalhes aqui.

Share