SlideShare a Scribd company logo
1 of 38
Download to read offline
Spring
                               Best Practices




Massimiliano Dessì, Pronetics S.p.A.            1
Speaker
Software Engineer and Architect                      ProNetics
Founder                               Spring Italian User Group
Presidente                                 JugSardegna Onlus
Committer/Contributor                   OpenNMS – MongoDB
Autore             Spring 2.5 Aspect Oriented programming




Massimiliano Dessì, Pronetics S.p.a                         2
Agenda


                                      - Configurazione
                                        - Sicurezza
                    - Cache trasparente con l'AOP
                                        -Transazioni
                                        -SpringMVC
                                        -PortletMVC

Massimiliano Dessì, Pronetics S.p.a                          3
Configurazione



              Abbreviare l‘xml con il namespace p
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="due" class="it.jax.java5.Due" p:nome=”Paperino”
  p:cognome=”Paolino”/>




Massimiliano Dessì, Pronetics S.p.a                           4
Configurazione



                                      Wildcard
         <context-param>

               <param-name>contextConfigLocation</param-name>
               <param-value>/WEB-INF/conf/magicbox-*.xml</param-value>
         </context-param>




Massimiliano Dessì, Pronetics S.p.a                                      5
Configurazione
                   Esternalizzare le parti modificabili
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">

<context:property-placeholder location="WEB-INF/config.properties" />

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
   p:url="${jdbc.url}" p:username="${jdbc.username}"
   p:password="${jdbc.password}“ p:maxIdle="3"
   p:driverClassName="${jdbc.driver}" p:maxWait="50” />
  …
  Massimiliano Dessì, Pronetics S.p.a                           6
Configurazione

    Minimizzare l‘XML necessario con le annotazioni
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">

<context:annotation-config />
<context:component-scan base-package=”org.magicbox.ui" />
<context:component-scan base-package=”org.magicbox.services" />
<context:component-scan base-package=”org.magicbox.repositories" />
…
    Massimiliano Dessì, Pronetics S.p.a                               7
Configurazione

                                        Annotazioni
           @Controller                @Component @Service @Repository
            @Autowired                @Qualifier @Configurable @Scope
                                @Transactional @Resource


                                      Annotazioni test
            @Test @RunWith @ContextConfiguration
            @ExpectedException  @IfProfileValue
      @TestExecutionListeners  @TransactionConfiguration




Massimiliano Dessì, Pronetics S.p.a                                     8
Sicurezza
                                      SpringSecurity
   <filter>
        <filter-name>
                springSecurityFilterChain
        </filter-name>
         <filter-class>
                org.springframework.web.filter.DelegatingFilterProxy
         </filter-class>
   </filter>
   <filter-mapping>
         <filter-name>springSecurityFilterChain</filter-name>
         <url-pattern>/*</url-pattern>
   </filter-mapping>




Massimiliano Dessì, Pronetics S.p.a                                    9
Sicurezza
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sec="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">

<sec:authentication-provider user-service-ref="sffsUserDetailservice”>
   <sec:password-encoder hash="sha" />
</sec:authentication-provider>

<bean id="sffsUserDetailservice”
    class="it.freshfruits.security.AuthenticationJdbcDaoImpl"
    p:rolePrefix="ROLE_" p:dataSource="dataSource"
    p:usersByUsernameQuery="SELECT username, password, enabled
                            FROM authentication WHERE username = ?"
    p:authoritiesByUsernameQuery="SELECT username, authority
                                  FROM roles WHERE username = ?" />



   Massimiliano Dessì, Pronetics S.p.a                                       10
Sicurezza

    Definire quali ruoli possono invocare gli URL

<sec:http>
   <sec:intercept-url pattern="/log*.jsp" filters="none" />
   <sec:intercept-url pattern="*.htm" access="ROLE_USER,ROLE_ANONYMOUS" />
   <sec:intercept-url pattern="*.page" access="ROLE_USER,ROLE_ADMIN" />
   <sec:intercept-url pattern="*.edit" access="ROLE_USER,ROLE_ADMIN" />
   <sec:intercept-url pattern="*.admin" access="ROLE_ADMIN" />
   <sec:form-login login-page="/login.jsp" default-target-url="/"
        login-processing-url="/j_security_check"
        authentication-failure-url="/loginError.jsp" />
   <sec:logout logout-url="/logout.jsp" logout-success url="/login.jsp" />
   <sec:remember-me />
</sec:http>



  Massimiliano Dessì, Pronetics S.p.a                                  11
Sicurezza


    Definire quali ruoli possono eseguire i metodi
<bean id="accessDecisionManager“ class="org.springframework.security.vote.AffirmativeBased">
    <property name="decisionVoters">
        <list>
             <bean class="org.springframework.security.vote.RoleVoter" />
             <bean class="org.springframework.security.vote.AuthenticatedVoter" />
        </list>
   </property>
</bean>

<sec:global-method-security access-decision-manager-ref="accessDecisionManager">
   <sec:protect-pointcut expression="execution(* it.myapp.domain.entity.*.*(..))"
                     access="ROLE_USER,ROLE_ADMIN" />
</sec:global-method-security>




     Massimiliano Dessì, Pronetics S.p.a                                            12
Cache AOP
@Aspect
public class CacheAspect {

  public Object cacheObject(ProceedingJoinPoint pjp) throws Throwable {

      Object result;
      String cacheKey = getCacheKey(pjp);
      Element element = (Element) cache.get(cacheKey);

      if (element == null) {
          result = pjp.proceed();
          element = new Element(cacheKey, result);
          cache.put(element);
      }
      return element.getValue();
  }

 public void flush() {
     cache.flush();
 }

  Massimiliano Dessì, Pronetics S.p.a                                     13
Cache AOP
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xmlns:p="http://www.springframework.org/schema/p”
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">


<bean id="cache" abstract="true"
     class="org.springframework.cache.ehcache.EhCacheFactoryBean">
     p:cacheManager-ref="cacheManager" />

<bean id="cacheManager”
     class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean”
     p:configLocation-value="classpath:it/ehcache.xml”/>


  Massimiliano Dessì, Pronetics S.p.a                                  14
Cache AOP
<aop:config>
   <aop:pointcut id="read” expression="execution(* it.MyClass.get*(..))" />
   <aop:pointcut id="exit” expression="execution(void it.MyClass.exit())" />

   <aop:aspect id="dummyCacheAspect" ref="rocketCacheAspect">
       <aop:around pointcut-ref="readOperation" method="cacheObject" />
       <aop:after pointcut-ref="exitOperation" method="flush" />
   </aop:aspect>
</aop:config>

<bean id="rocketCacheAspect"
   class=”it.pronetics.cache.CacheAspect" >
   <property name="cache">
       <bean id="bandCache" parent="cache">
           <property name="cacheName" value="methodCache" />
       </bean>
   </property>
 </bean>


   Massimiliano Dessì, Pronetics S.p.a                                    15
Transazioni XML
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx=http://www.springframework.org/schema/tx
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">

  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
   p:url="${jdbc.url}" p:username="${jdbc.username}"
   p:password="${jdbc.password}“ p:driverClassName="${jdbc.driver}” />

  <bean id="transactionManager"
      class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
       p:dataSource-ref="dataSource"/>

   Massimiliano Dessì, Pronetics S.p.a                                    16
Transazioni XML
<tx:advice id="txAdvice" transaction-manager="transactionManager">
 <tx:attributes>
     <tx:method name=”save*" propagation="REQUIRED”
                    no-rollback-for="it.exception.FooException"
                    rollback-for=”it.exception.ItemException"/>
     <tx:method name="delete*" propagation="REQUIRED”
                rollback-for="it.exception.MYException"/>
     <tx:method name="disable*" propagation="REQUIRED” />
     <tx:method name="*" read-only="true” />
 </tx:attributes>
</tx:advice>

<aop:config>
     <aop:pointcut id="repoOperations"
         expression="execution(*it.pronetics.service.*.*(..))" />
     <aop:advisor advice-ref="txAdvice" pointcut-ref="repoOperations"/>
</aop:config>



  Massimiliano Dessì, Pronetics S.p.a                                     17
Transazioni @
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx=http://www.springframework.org/schema/tx
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd”>

<tx:annotation-driven transaction-manager="transactionManager" />

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
   p:url="${jdbc.url}" p:username="${jdbc.username}"
   p:password="${jdbc.password}“ p:driverClassName="${jdbc.driver}” />

<bean id="transactionManager" p:dataSource-ref="dataSource“
  class="org.springframework.jdbc.datasource.DataSourceTransactionManager"/>


   Massimiliano Dessì, Pronetics S.p.a                                   18
Transazioni @


import org.springframework.dao.DataAccessException;

import org.springframework.transaction.annotation.Propagation;

import org.springframework.transaction.annotation.Transactional;


public class MyService implements Service{
...

@Transactional(propagation=Propagation.REQUIRED,
rollbackFor=DataAccessException.class)

 public Boolean release(String idOrder, String idItem) {

 ...



  Massimiliano Dessì, Pronetics S.p.a                              19
SpringMVC




Massimiliano Dessì, Pronetics S.p.a         20
SpringMVC WEB.XML

<servlet>
  <servlet-name>spring</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:applicationContext.xml</param-value>
   <load-on-startup>0</load-on-startup>
</servlet>
 <servlet-mapping>

   <servlet-name>spring</servlet-name>
   <url-pattern>*.page</url-pattern> <!—- estensione preferita -->
   <url-pattern>*.html</url-pattern> <!—- estensione preferita -->
   <url-pattern>*.admin</url-pattern> <!—- estensione preferita -->
 </servlet-mapping>
    Massimiliano Dessì, Pronetics S.p.a                                  21
<?xml version="1.0" encoding="UTF-8"?>
                                                          SpringMVC
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context=http://www.springframework.org/schema/context
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">

    <context:annotation-config/>
    <context:component-scan base-package="it.pronetics.web.ui" />

   <bean id="messageSource” p:basename="it.pronetics.messages.msg"
       class="org.springframework.context.support.ResourceBundleMessageSource”/>

    <bean name="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver"
       p:viewClass="org.springframework.web.servlet.view.JstlView"
       p:prefix="/WEB-INF/jsp/" p:suffix=".jsp"/>


    Massimiliano Dessì, Pronetics S.p.a                                   22
SpringMVC @
@Controller("articleController")
public class ArticleController {

    private ArticleFacade facade;

    @Autowired
    public ArticleController(@Qualifier("articleFacade") ArticleFacade facade) {
       facade = articleFacade;
    }

    @RequestMapping(value = "/articles/{id}", method = RequestMethod.GET)
    public ModelAndView getArticle(@PathVariable("id") String id) {
       return new ModelAndView("articleView", "article", facade.getArticle(id));
    }

    @RequestMapping("/article/delete/{id}")
    public ModelAndView delete(@PathVariable("id") String id) {
       facade.deleteArticle(id);
       return new ModelAndView("redirect:articles");
    }
    Massimiliano Dessì, Pronetics S.p.a                                  23
SpringMVC Form Controller
@Controller("articleFormController")
@SessionAttributes("article")
public class ArticleFormController {

    private ArticleFacade articleFacade;
    private ArticleValidator validator;

   @Autowired
   public ArticleFormController(@Qualifier("articleFacade") ArticleFacade facade,
          @Qualifier("articleValidator") ArticleValidator validator) {
       this.articleFacade = facade;
       this.validator = validator;
   }

   @InitBinder()
   public void initBinder(WebDataBinder binder) throws Exception {
       binder.registerCustomEditor(String.class, new StringTrimmerEditor(false));
   }


    Massimiliano Dessì, Pronetics S.p.a                                 24
SpringMVC Form Controller
@RequestMapping(value= "/article/edit/{id}", method = RequestMethod.POST)
 public String processSubmit(@ModelAttribute("article") ArticleCommand article,
                                     BindingResult result, SessionStatus status) {
        validator.validate(article, result);
        if (result.hasErrors()) {
            return "articleForm";
        } else {
            articleFacade.saveArticle(article);
            status.setComplete();
            return Constants.REDIRECT_LIST_ARTICLES_DEFAULT;
        }
    }

@RequestMapping(value= "/article/edit/{id}", method = RequestMethod.GET)
public String setupForm(@PathVariable("id") String id, ModelMap model) {
   ArticleCommand article = articleFacade.getArticle(id);
   model.addAttribute(Constants.ARTICLE,
                 article != null ? article : new ArticleCommand());
   return "articleForm";
}
    Massimiliano Dessì, Pronetics S.p.a                                    25
SpringMVC Interceptor
public class MyInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest req, HttpServletResponse res,
                                         Object handler) throws Exception {
        ...
    }

    @Override
    public void postHandle(HttpServletRequest req, HttpServletResponse res,
               Object handler, ModelAndView modelAndView) throws Exception {
           ...
    }

    @Override
    public void afterCompletion(HttpServletRequest request,
                               HttpServletResponse response,
               Object handler, Exception ex) throws Exception {
        ..
    }


    Massimiliano Dessì, Pronetics S.p.a                                  26
SpringMVC Interceptor

<bean name="urlMapping”
 class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
        <property name="interceptors">
            <list>
                <ref bean=”myInterceptor"/>
            </list>
        </property>
    </bean>

   <bean name=”myInterceptor" class="it.app.MyInterceptor"/>




     Massimiliano Dessì, Pronetics S.p.a                                      27
Native WebRequest


Non definisco se è in un servlet o portlet environment

 @RequestMapping(”/list.page")
  public ModelAndView list(NativeWebRequest req)




 Massimiliano Dessì, Pronetics S.p.a                     28
SpringPortletMVC




Massimiliano Dessì, Pronetics S.p.a                29
SpringPortletMVC
    <?xml version="1.0" encoding="UTF-8"?>
    <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
    http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0">
    <portlet>
    <portlet-name>aclPortlet</portlet-name>
    <portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
          <init-param>
           <name>contextConfigLocation</name>
            <value>/WEB-INF/aclPortlet-portlet.xml</value>
          </init-param>
          <supports>
               <mime-type>text/html</mime-type>
               <portlet-mode>VIEW</portlet-mode>
          </supports>
          <portlet-info><title>Acl</title></portlet-info>
    </portlet>
…

      Massimiliano Dessì, Pronetics S.p.a                                  30
SpringPortletMVC
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    <context:component-scan base-package="it.pronetics.acl.ui.portlet" />

    <bean name="annotationMapper"
      class="org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping">
      <property name="interceptors">
         <list>
              <bean class="org.springframework.web.portlet.handler.ParameterMappingInterceptor"/>
              <ref bean="userFactoryInterceptor"/>
              <ref bean="authoritiesFactoryInterceptor"/>
         </list>
      </property>
    </bean>

…
        Massimiliano Dessì, Pronetics S.p.a                                            31
SpringPortletMVC
@Controller @RequestMapping("VIEW") @SessionAttributes("role")
public class AuthorityController {

 /*WELCOME method*/
 @RequestMapping
 public ModelAndView handleRenderRequest(RenderRequest req, RenderResponse res)
 throws Exception {
      …
 }

 @RequestMapping(params = "action=authority.delete")
 public void deleteAuthority(ActionRequest req, ActionResponse res) {
  …
 }

 @RequestMapping(params = "action=authority.list")
 public ModelAndView authoritiesList(RenderRequest req) {
   ….
 }

   Massimiliano Dessì, Pronetics S.p.a                                  32
SpringPortletMVC
@RequestMapping(params = "action=authority.detail")
public ModelAndView detailAuthority(RenderRequest req) {
    …
}

@RequestMapping(params = "action=authority.confirm")
public ModelAndView confirmDeleteAuthority(RenderRequest req) {
   …
}

@RequestMapping(params = "action=authority.items")
public ModelAndView authorityItems(RenderRequest req) {
       …
}

@RequestMapping(params = "action=authority.selection")
public void selectionAuthorities(@RequestParam("includedHidden") String ids,
                                      ActionRequest req, ActionResponse res) {
    …
}
Massimiliano Dessì, Pronetics S.p.a                                  33
SpringPortletMVC


/* FORM methods*/
@InitBinder()
public void initBinder(WebDataBinder binder) throws Exception {
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(false));
}

@ModelAttribute("strategies")
public List<PermissionStrategy> populatePermissionStrategy() {
    return roleStrategyService.getPermissions();
}




 Massimiliano Dessì, Pronetics S.p.a                                 34
SpringPortletMVC

// render phase
@RequestMapping(params = "action=authority.edit")
public String showForm(Model model,
               @RequestParam(required = false, value = "aid") Integer id) {
…
}

// action phase
@RequestMapping(params = "action=authority.edit")
public void processSubmit(ActionResponse res,
                      @ModelAttribute("authority") AuthorityDTO authority,
                  BindingResult result, SessionStatus status, Model model) {
   …
}




 Massimiliano Dessì, Pronetics S.p.a                                  35
SpringMVC - SpringPortletMVC




Massimiliano Dessì, Pronetics S.p.a                  36
Database embedded




        Domande ?




Massimiliano Dessì, Pronetics S.p.a                 37
Grazie per l’attenzione !
                            Massimiliano Dessì
                           desmax74 at yahoo.it
                      massimiliano.dessi at pronetics.it

                                    http://twitter.com/desmax74
                                     http://jroller.com/desmax
                              http://www.linkedin.com/in/desmax74
                    http://wiki.java.net/bin/view/People/MassimilianoDessi
               http://www.jugsardegna.org/vqwiki/jsp/Wiki?MassimilianoDessi

                               Spring Framework Italian User Group
                     http://it.groups.yahoo.com/group/SpringFramework-it



Massimiliano Dessì, Pronetics S.p.a                                           38

More Related Content

What's hot

OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchAppsBradley Holt
 
OrientDB the graph database
OrientDB the graph databaseOrientDB the graph database
OrientDB the graph databaseArtem Orobets
 
Validating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentationValidating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentationDave Stokes
 
Scalany mongodb aug10
Scalany mongodb aug10Scalany mongodb aug10
Scalany mongodb aug10bwmcadams
 
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...mfrancis
 
Open Source World June '21 -- JSON Within a Relational Database
Open Source World June '21 -- JSON Within a Relational DatabaseOpen Source World June '21 -- JSON Within a Relational Database
Open Source World June '21 -- JSON Within a Relational DatabaseDave Stokes
 
Php &amp; my sql - how do pdo, mysq-li, and x devapi do what they do
Php &amp; my sql  - how do pdo, mysq-li, and x devapi do what they doPhp &amp; my sql  - how do pdo, mysq-li, and x devapi do what they do
Php &amp; my sql - how do pdo, mysq-li, and x devapi do what they doDave Stokes
 
Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Scott Leberknight
 
Scala with mongodb
Scala with mongodbScala with mongodb
Scala with mongodbKnoldus Inc.
 
MongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaMongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaScott Hernandez
 
MySQL without the SQL -- Cascadia PHP
MySQL without the SQL -- Cascadia PHPMySQL without the SQL -- Cascadia PHP
MySQL without the SQL -- Cascadia PHPDave Stokes
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDBNate Abele
 
Using Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into CassandraUsing Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into CassandraJim Hatcher
 
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScriptJavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScriptDave Stokes
 
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...Dave Stokes
 
CouchDB at New York PHP
CouchDB at New York PHPCouchDB at New York PHP
CouchDB at New York PHPBradley Holt
 
An introduction to CouchDB
An introduction to CouchDBAn introduction to CouchDB
An introduction to CouchDBDavid Coallier
 
OrientDB introduction - NoSQL
OrientDB introduction - NoSQLOrientDB introduction - NoSQL
OrientDB introduction - NoSQLLuca Garulli
 

What's hot (20)

OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchApps
 
OrientDB the graph database
OrientDB the graph databaseOrientDB the graph database
OrientDB the graph database
 
Validating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentationValidating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentation
 
2012 phoenix mug
2012 phoenix mug2012 phoenix mug
2012 phoenix mug
 
Scalany mongodb aug10
Scalany mongodb aug10Scalany mongodb aug10
Scalany mongodb aug10
 
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
 
Intro To Couch Db
Intro To Couch DbIntro To Couch Db
Intro To Couch Db
 
Open Source World June '21 -- JSON Within a Relational Database
Open Source World June '21 -- JSON Within a Relational DatabaseOpen Source World June '21 -- JSON Within a Relational Database
Open Source World June '21 -- JSON Within a Relational Database
 
Php &amp; my sql - how do pdo, mysq-li, and x devapi do what they do
Php &amp; my sql  - how do pdo, mysq-li, and x devapi do what they doPhp &amp; my sql  - how do pdo, mysq-li, and x devapi do what they do
Php &amp; my sql - how do pdo, mysq-li, and x devapi do what they do
 
Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0
 
Scala with mongodb
Scala with mongodbScala with mongodb
Scala with mongodb
 
MongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaMongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with Morphia
 
MySQL without the SQL -- Cascadia PHP
MySQL without the SQL -- Cascadia PHPMySQL without the SQL -- Cascadia PHP
MySQL without the SQL -- Cascadia PHP
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDB
 
Using Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into CassandraUsing Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into Cassandra
 
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScriptJavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
 
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
 
CouchDB at New York PHP
CouchDB at New York PHPCouchDB at New York PHP
CouchDB at New York PHP
 
An introduction to CouchDB
An introduction to CouchDBAn introduction to CouchDB
An introduction to CouchDB
 
OrientDB introduction - NoSQL
OrientDB introduction - NoSQLOrientDB introduction - NoSQL
OrientDB introduction - NoSQL
 

Viewers also liked

Magic Box 3 In Action (Jug Avis Web)
Magic Box 3 In Action (Jug Avis Web)Magic Box 3 In Action (Jug Avis Web)
Magic Box 3 In Action (Jug Avis Web)Massimiliano Dessì
 
MongoDB Scala Roma SpringFramework Meeting2009
MongoDB Scala Roma SpringFramework Meeting2009MongoDB Scala Roma SpringFramework Meeting2009
MongoDB Scala Roma SpringFramework Meeting2009Massimiliano Dessì
 
Scala Programming Linux Day 2009
Scala Programming Linux Day 2009Scala Programming Linux Day 2009
Scala Programming Linux Day 2009Massimiliano Dessì
 
Introduzione a scala prima parte
Introduzione a scala   prima parteIntroduzione a scala   prima parte
Introduzione a scala prima parteOnofrio Panzarino
 
Scala Primi Passi
Scala Primi PassiScala Primi Passi
Scala Primi PassiUgo Landini
 
Spring Security
Spring SecuritySpring Security
Spring SecurityBoy Tech
 
Spring Framework - Spring Security
Spring Framework - Spring SecuritySpring Framework - Spring Security
Spring Framework - Spring SecurityDzmitry Naskou
 

Viewers also liked (9)

Spring security
Spring securitySpring security
Spring security
 
Magic Box 3 In Action (Jug Avis Web)
Magic Box 3 In Action (Jug Avis Web)Magic Box 3 In Action (Jug Avis Web)
Magic Box 3 In Action (Jug Avis Web)
 
Spring @Aspect e @Controller
Spring @Aspect e @Controller Spring @Aspect e @Controller
Spring @Aspect e @Controller
 
MongoDB Scala Roma SpringFramework Meeting2009
MongoDB Scala Roma SpringFramework Meeting2009MongoDB Scala Roma SpringFramework Meeting2009
MongoDB Scala Roma SpringFramework Meeting2009
 
Scala Programming Linux Day 2009
Scala Programming Linux Day 2009Scala Programming Linux Day 2009
Scala Programming Linux Day 2009
 
Introduzione a scala prima parte
Introduzione a scala   prima parteIntroduzione a scala   prima parte
Introduzione a scala prima parte
 
Scala Primi Passi
Scala Primi PassiScala Primi Passi
Scala Primi Passi
 
Spring Security
Spring SecuritySpring Security
Spring Security
 
Spring Framework - Spring Security
Spring Framework - Spring SecuritySpring Framework - Spring Security
Spring Framework - Spring Security
 

Similar to Jaxitalia09 Spring Best Practices

JavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンJavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンharuki ueno
 
자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)
자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)
자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)DK Lee
 
#34.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자교육,국...
#34.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자교육,국...#34.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자교육,국...
#34.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자교육,국...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
spring3.2 java config Servler3
spring3.2 java config Servler3spring3.2 java config Servler3
spring3.2 java config Servler3YongHyuk Lee
 
Message properties component in mule
Message properties component in muleMessage properties component in mule
Message properties component in muleKhan625
 
JBoss AS Upgrade
JBoss AS UpgradeJBoss AS Upgrade
JBoss AS Upgradesharmami
 
Service Oriented Integration with ServiceMix
Service Oriented Integration with ServiceMixService Oriented Integration with ServiceMix
Service Oriented Integration with ServiceMixghessler
 
Ajax, JSF, Facelets, Eclipse & Maven tutorials
Ajax, JSF, Facelets, Eclipse & Maven tutorialsAjax, JSF, Facelets, Eclipse & Maven tutorials
Ajax, JSF, Facelets, Eclipse & Maven tutorialsRaghavan Mohan
 
Jlook web ui framework
Jlook web ui frameworkJlook web ui framework
Jlook web ui frameworkHongSeong Jeon
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixBruce Snyder
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring FrameworkRaveendra R
 
Summit2014 topic 0066 - 10 enhancements that require 10 lines of code
Summit2014 topic 0066 - 10 enhancements that require 10 lines of codeSummit2014 topic 0066 - 10 enhancements that require 10 lines of code
Summit2014 topic 0066 - 10 enhancements that require 10 lines of codeAngel Borroy López
 

Similar to Jaxitalia09 Spring Best Practices (20)

Spring3.0 JaxItalia09
Spring3.0 JaxItalia09Spring3.0 JaxItalia09
Spring3.0 JaxItalia09
 
JavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンJavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオン
 
자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)
자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)
자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)
 
#34.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자교육,국...
#34.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자교육,국...#34.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자교육,국...
#34.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자교육,국...
 
Soap Component
Soap ComponentSoap Component
Soap Component
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
 
How to use soap component
How to use soap componentHow to use soap component
How to use soap component
 
Property place holder
Property place holderProperty place holder
Property place holder
 
spring3.2 java config Servler3
spring3.2 java config Servler3spring3.2 java config Servler3
spring3.2 java config Servler3
 
Message properties component in mule
Message properties component in muleMessage properties component in mule
Message properties component in mule
 
Wildcard Filter
Wildcard FilterWildcard Filter
Wildcard Filter
 
JBoss AS Upgrade
JBoss AS UpgradeJBoss AS Upgrade
JBoss AS Upgrade
 
Service Oriented Integration with ServiceMix
Service Oriented Integration with ServiceMixService Oriented Integration with ServiceMix
Service Oriented Integration with ServiceMix
 
Ajax, JSF, Facelets, Eclipse & Maven tutorials
Ajax, JSF, Facelets, Eclipse & Maven tutorialsAjax, JSF, Facelets, Eclipse & Maven tutorials
Ajax, JSF, Facelets, Eclipse & Maven tutorials
 
Jlook web ui framework
Jlook web ui frameworkJlook web ui framework
Jlook web ui framework
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMix
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Summit2014 topic 0066 - 10 enhancements that require 10 lines of code
Summit2014 topic 0066 - 10 enhancements that require 10 lines of codeSummit2014 topic 0066 - 10 enhancements that require 10 lines of code
Summit2014 topic 0066 - 10 enhancements that require 10 lines of code
 

More from Massimiliano Dessì

When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...
When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...
When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...Massimiliano Dessì
 
Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome
Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome
Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome Massimiliano Dessì
 
Dessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudDessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudMassimiliano Dessì
 
Web Marketing Training 2014 Community Online
Web Marketing Training 2014 Community OnlineWeb Marketing Training 2014 Community Online
Web Marketing Training 2014 Community OnlineMassimiliano Dessì
 
Vert.X like Node.js but polyglot and reactive on JVM
Vert.X like Node.js but polyglot and reactive on JVMVert.X like Node.js but polyglot and reactive on JVM
Vert.X like Node.js but polyglot and reactive on JVMMassimiliano Dessì
 
Reactive applications Linux Day 2013
Reactive applications Linux Day 2013Reactive applications Linux Day 2013
Reactive applications Linux Day 2013Massimiliano Dessì
 
Scala Italy 2013 extended Scalatra vs Spring MVC
Scala Italy 2013 extended Scalatra vs Spring MVCScala Italy 2013 extended Scalatra vs Spring MVC
Scala Italy 2013 extended Scalatra vs Spring MVCMassimiliano Dessì
 
Codemotion 2013 scalatra_play_spray
Codemotion 2013 scalatra_play_sprayCodemotion 2013 scalatra_play_spray
Codemotion 2013 scalatra_play_sprayMassimiliano Dessì
 
Why we cannot ignore functional programming
Why we cannot ignore functional programmingWhy we cannot ignore functional programming
Why we cannot ignore functional programmingMassimiliano Dessì
 
Three languages in thirty minutes
Three languages in thirty minutesThree languages in thirty minutes
Three languages in thirty minutesMassimiliano Dessì
 

More from Massimiliano Dessì (20)

Code One 2018 maven
Code One 2018   mavenCode One 2018   maven
Code One 2018 maven
 
When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...
When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...
When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...
 
Hacking Maven Linux day 2017
Hacking Maven Linux day 2017Hacking Maven Linux day 2017
Hacking Maven Linux day 2017
 
Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome
Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome
Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome
 
Dessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudDessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloud
 
Docker dDessi november 2015
Docker dDessi november 2015Docker dDessi november 2015
Docker dDessi november 2015
 
Docker linuxday 2015
Docker linuxday 2015Docker linuxday 2015
Docker linuxday 2015
 
Openshift linuxday 2014
Openshift linuxday 2014Openshift linuxday 2014
Openshift linuxday 2014
 
Web Marketing Training 2014 Community Online
Web Marketing Training 2014 Community OnlineWeb Marketing Training 2014 Community Online
Web Marketing Training 2014 Community Online
 
Vert.X like Node.js but polyglot and reactive on JVM
Vert.X like Node.js but polyglot and reactive on JVMVert.X like Node.js but polyglot and reactive on JVM
Vert.X like Node.js but polyglot and reactive on JVM
 
Reactive applications Linux Day 2013
Reactive applications Linux Day 2013Reactive applications Linux Day 2013
Reactive applications Linux Day 2013
 
Scala Italy 2013 extended Scalatra vs Spring MVC
Scala Italy 2013 extended Scalatra vs Spring MVCScala Italy 2013 extended Scalatra vs Spring MVC
Scala Italy 2013 extended Scalatra vs Spring MVC
 
Codemotion 2013 scalatra_play_spray
Codemotion 2013 scalatra_play_sprayCodemotion 2013 scalatra_play_spray
Codemotion 2013 scalatra_play_spray
 
Why we cannot ignore functional programming
Why we cannot ignore functional programmingWhy we cannot ignore functional programming
Why we cannot ignore functional programming
 
Scala linux day 2012
Scala linux day 2012 Scala linux day 2012
Scala linux day 2012
 
Three languages in thirty minutes
Three languages in thirty minutesThree languages in thirty minutes
Three languages in thirty minutes
 
MongoDB dessi-codemotion
MongoDB dessi-codemotionMongoDB dessi-codemotion
MongoDB dessi-codemotion
 
MongoDB Webtech conference 2010
MongoDB Webtech conference 2010MongoDB Webtech conference 2010
MongoDB Webtech conference 2010
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
Spring Roo Internals Javaday IV
Spring Roo Internals Javaday IVSpring Roo Internals Javaday IV
Spring Roo Internals Javaday IV
 

Recently uploaded

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

Jaxitalia09 Spring Best Practices

  • 1. Spring Best Practices Massimiliano Dessì, Pronetics S.p.A. 1
  • 2. Speaker Software Engineer and Architect ProNetics Founder Spring Italian User Group Presidente JugSardegna Onlus Committer/Contributor OpenNMS – MongoDB Autore Spring 2.5 Aspect Oriented programming Massimiliano Dessì, Pronetics S.p.a 2
  • 3. Agenda - Configurazione - Sicurezza - Cache trasparente con l'AOP -Transazioni -SpringMVC -PortletMVC Massimiliano Dessì, Pronetics S.p.a 3
  • 4. Configurazione Abbreviare l‘xml con il namespace p <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="due" class="it.jax.java5.Due" p:nome=”Paperino” p:cognome=”Paolino”/> Massimiliano Dessì, Pronetics S.p.a 4
  • 5. Configurazione Wildcard <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/conf/magicbox-*.xml</param-value> </context-param> Massimiliano Dessì, Pronetics S.p.a 5
  • 6. Configurazione Esternalizzare le parti modificabili <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <context:property-placeholder location="WEB-INF/config.properties" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" p:url="${jdbc.url}" p:username="${jdbc.username}" p:password="${jdbc.password}“ p:maxIdle="3" p:driverClassName="${jdbc.driver}" p:maxWait="50” /> … Massimiliano Dessì, Pronetics S.p.a 6
  • 7. Configurazione Minimizzare l‘XML necessario con le annotazioni <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <context:annotation-config /> <context:component-scan base-package=”org.magicbox.ui" /> <context:component-scan base-package=”org.magicbox.services" /> <context:component-scan base-package=”org.magicbox.repositories" /> … Massimiliano Dessì, Pronetics S.p.a 7
  • 8. Configurazione Annotazioni @Controller @Component @Service @Repository @Autowired @Qualifier @Configurable @Scope @Transactional @Resource Annotazioni test @Test @RunWith @ContextConfiguration @ExpectedException @IfProfileValue @TestExecutionListeners @TransactionConfiguration Massimiliano Dessì, Pronetics S.p.a 8
  • 9. Sicurezza SpringSecurity <filter> <filter-name> springSecurityFilterChain </filter-name> <filter-class> org.springframework.web.filter.DelegatingFilterProxy </filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> Massimiliano Dessì, Pronetics S.p.a 9
  • 10. Sicurezza <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://www.springframework.org/schema/security" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"> <sec:authentication-provider user-service-ref="sffsUserDetailservice”> <sec:password-encoder hash="sha" /> </sec:authentication-provider> <bean id="sffsUserDetailservice” class="it.freshfruits.security.AuthenticationJdbcDaoImpl" p:rolePrefix="ROLE_" p:dataSource="dataSource" p:usersByUsernameQuery="SELECT username, password, enabled FROM authentication WHERE username = ?" p:authoritiesByUsernameQuery="SELECT username, authority FROM roles WHERE username = ?" /> Massimiliano Dessì, Pronetics S.p.a 10
  • 11. Sicurezza Definire quali ruoli possono invocare gli URL <sec:http> <sec:intercept-url pattern="/log*.jsp" filters="none" /> <sec:intercept-url pattern="*.htm" access="ROLE_USER,ROLE_ANONYMOUS" /> <sec:intercept-url pattern="*.page" access="ROLE_USER,ROLE_ADMIN" /> <sec:intercept-url pattern="*.edit" access="ROLE_USER,ROLE_ADMIN" /> <sec:intercept-url pattern="*.admin" access="ROLE_ADMIN" /> <sec:form-login login-page="/login.jsp" default-target-url="/" login-processing-url="/j_security_check" authentication-failure-url="/loginError.jsp" /> <sec:logout logout-url="/logout.jsp" logout-success url="/login.jsp" /> <sec:remember-me /> </sec:http> Massimiliano Dessì, Pronetics S.p.a 11
  • 12. Sicurezza Definire quali ruoli possono eseguire i metodi <bean id="accessDecisionManager“ class="org.springframework.security.vote.AffirmativeBased"> <property name="decisionVoters"> <list> <bean class="org.springframework.security.vote.RoleVoter" /> <bean class="org.springframework.security.vote.AuthenticatedVoter" /> </list> </property> </bean> <sec:global-method-security access-decision-manager-ref="accessDecisionManager"> <sec:protect-pointcut expression="execution(* it.myapp.domain.entity.*.*(..))" access="ROLE_USER,ROLE_ADMIN" /> </sec:global-method-security> Massimiliano Dessì, Pronetics S.p.a 12
  • 13. Cache AOP @Aspect public class CacheAspect { public Object cacheObject(ProceedingJoinPoint pjp) throws Throwable { Object result; String cacheKey = getCacheKey(pjp); Element element = (Element) cache.get(cacheKey); if (element == null) { result = pjp.proceed(); element = new Element(cacheKey, result); cache.put(element); } return element.getValue(); } public void flush() { cache.flush(); } Massimiliano Dessì, Pronetics S.p.a 13
  • 14. Cache AOP <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:p="http://www.springframework.org/schema/p” xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <bean id="cache" abstract="true" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> p:cacheManager-ref="cacheManager" /> <bean id="cacheManager” class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean” p:configLocation-value="classpath:it/ehcache.xml”/> Massimiliano Dessì, Pronetics S.p.a 14
  • 15. Cache AOP <aop:config> <aop:pointcut id="read” expression="execution(* it.MyClass.get*(..))" /> <aop:pointcut id="exit” expression="execution(void it.MyClass.exit())" /> <aop:aspect id="dummyCacheAspect" ref="rocketCacheAspect"> <aop:around pointcut-ref="readOperation" method="cacheObject" /> <aop:after pointcut-ref="exitOperation" method="flush" /> </aop:aspect> </aop:config> <bean id="rocketCacheAspect" class=”it.pronetics.cache.CacheAspect" > <property name="cache"> <bean id="bandCache" parent="cache"> <property name="cacheName" value="methodCache" /> </bean> </property> </bean> Massimiliano Dessì, Pronetics S.p.a 15
  • 16. Transazioni XML <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx=http://www.springframework.org/schema/tx xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" p:url="${jdbc.url}" p:username="${jdbc.username}" p:password="${jdbc.password}“ p:driverClassName="${jdbc.driver}” /> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" p:dataSource-ref="dataSource"/> Massimiliano Dessì, Pronetics S.p.a 16
  • 17. Transazioni XML <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name=”save*" propagation="REQUIRED” no-rollback-for="it.exception.FooException" rollback-for=”it.exception.ItemException"/> <tx:method name="delete*" propagation="REQUIRED” rollback-for="it.exception.MYException"/> <tx:method name="disable*" propagation="REQUIRED” /> <tx:method name="*" read-only="true” /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="repoOperations" expression="execution(*it.pronetics.service.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="repoOperations"/> </aop:config> Massimiliano Dessì, Pronetics S.p.a 17
  • 18. Transazioni @ <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx=http://www.springframework.org/schema/tx xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd”> <tx:annotation-driven transaction-manager="transactionManager" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" p:url="${jdbc.url}" p:username="${jdbc.username}" p:password="${jdbc.password}“ p:driverClassName="${jdbc.driver}” /> <bean id="transactionManager" p:dataSource-ref="dataSource“ class="org.springframework.jdbc.datasource.DataSourceTransactionManager"/> Massimiliano Dessì, Pronetics S.p.a 18
  • 19. Transazioni @ import org.springframework.dao.DataAccessException; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; public class MyService implements Service{ ... @Transactional(propagation=Propagation.REQUIRED, rollbackFor=DataAccessException.class) public Boolean release(String idOrder, String idItem) { ... Massimiliano Dessì, Pronetics S.p.a 19
  • 21. SpringMVC WEB.XML <servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>*.page</url-pattern> <!—- estensione preferita --> <url-pattern>*.html</url-pattern> <!—- estensione preferita --> <url-pattern>*.admin</url-pattern> <!—- estensione preferita --> </servlet-mapping> Massimiliano Dessì, Pronetics S.p.a 21
  • 22. <?xml version="1.0" encoding="UTF-8"?> SpringMVC <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context=http://www.springframework.org/schema/context xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <context:annotation-config/> <context:component-scan base-package="it.pronetics.web.ui" /> <bean id="messageSource” p:basename="it.pronetics.messages.msg" class="org.springframework.context.support.ResourceBundleMessageSource”/> <bean name="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:viewClass="org.springframework.web.servlet.view.JstlView" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp"/> Massimiliano Dessì, Pronetics S.p.a 22
  • 23. SpringMVC @ @Controller("articleController") public class ArticleController { private ArticleFacade facade; @Autowired public ArticleController(@Qualifier("articleFacade") ArticleFacade facade) { facade = articleFacade; } @RequestMapping(value = "/articles/{id}", method = RequestMethod.GET) public ModelAndView getArticle(@PathVariable("id") String id) { return new ModelAndView("articleView", "article", facade.getArticle(id)); } @RequestMapping("/article/delete/{id}") public ModelAndView delete(@PathVariable("id") String id) { facade.deleteArticle(id); return new ModelAndView("redirect:articles"); } Massimiliano Dessì, Pronetics S.p.a 23
  • 24. SpringMVC Form Controller @Controller("articleFormController") @SessionAttributes("article") public class ArticleFormController { private ArticleFacade articleFacade; private ArticleValidator validator; @Autowired public ArticleFormController(@Qualifier("articleFacade") ArticleFacade facade, @Qualifier("articleValidator") ArticleValidator validator) { this.articleFacade = facade; this.validator = validator; } @InitBinder() public void initBinder(WebDataBinder binder) throws Exception { binder.registerCustomEditor(String.class, new StringTrimmerEditor(false)); } Massimiliano Dessì, Pronetics S.p.a 24
  • 25. SpringMVC Form Controller @RequestMapping(value= "/article/edit/{id}", method = RequestMethod.POST) public String processSubmit(@ModelAttribute("article") ArticleCommand article, BindingResult result, SessionStatus status) { validator.validate(article, result); if (result.hasErrors()) { return "articleForm"; } else { articleFacade.saveArticle(article); status.setComplete(); return Constants.REDIRECT_LIST_ARTICLES_DEFAULT; } } @RequestMapping(value= "/article/edit/{id}", method = RequestMethod.GET) public String setupForm(@PathVariable("id") String id, ModelMap model) { ArticleCommand article = articleFacade.getArticle(id); model.addAttribute(Constants.ARTICLE, article != null ? article : new ArticleCommand()); return "articleForm"; } Massimiliano Dessì, Pronetics S.p.a 25
  • 26. SpringMVC Interceptor public class MyInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest req, HttpServletResponse res, Object handler) throws Exception { ... } @Override public void postHandle(HttpServletRequest req, HttpServletResponse res, Object handler, ModelAndView modelAndView) throws Exception { ... } @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { .. } Massimiliano Dessì, Pronetics S.p.a 26
  • 27. SpringMVC Interceptor <bean name="urlMapping” class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> <property name="interceptors"> <list> <ref bean=”myInterceptor"/> </list> </property> </bean> <bean name=”myInterceptor" class="it.app.MyInterceptor"/> Massimiliano Dessì, Pronetics S.p.a 27
  • 28. Native WebRequest Non definisco se è in un servlet o portlet environment @RequestMapping(”/list.page") public ModelAndView list(NativeWebRequest req) Massimiliano Dessì, Pronetics S.p.a 28
  • 30. SpringPortletMVC <?xml version="1.0" encoding="UTF-8"?> <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0"> <portlet> <portlet-name>aclPortlet</portlet-name> <portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class> <init-param> <name>contextConfigLocation</name> <value>/WEB-INF/aclPortlet-portlet.xml</value> </init-param> <supports> <mime-type>text/html</mime-type> <portlet-mode>VIEW</portlet-mode> </supports> <portlet-info><title>Acl</title></portlet-info> </portlet> … Massimiliano Dessì, Pronetics S.p.a 30
  • 31. SpringPortletMVC <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <context:component-scan base-package="it.pronetics.acl.ui.portlet" /> <bean name="annotationMapper" class="org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping"> <property name="interceptors"> <list> <bean class="org.springframework.web.portlet.handler.ParameterMappingInterceptor"/> <ref bean="userFactoryInterceptor"/> <ref bean="authoritiesFactoryInterceptor"/> </list> </property> </bean> … Massimiliano Dessì, Pronetics S.p.a 31
  • 32. SpringPortletMVC @Controller @RequestMapping("VIEW") @SessionAttributes("role") public class AuthorityController { /*WELCOME method*/ @RequestMapping public ModelAndView handleRenderRequest(RenderRequest req, RenderResponse res) throws Exception { … } @RequestMapping(params = "action=authority.delete") public void deleteAuthority(ActionRequest req, ActionResponse res) { … } @RequestMapping(params = "action=authority.list") public ModelAndView authoritiesList(RenderRequest req) { …. } Massimiliano Dessì, Pronetics S.p.a 32
  • 33. SpringPortletMVC @RequestMapping(params = "action=authority.detail") public ModelAndView detailAuthority(RenderRequest req) { … } @RequestMapping(params = "action=authority.confirm") public ModelAndView confirmDeleteAuthority(RenderRequest req) { … } @RequestMapping(params = "action=authority.items") public ModelAndView authorityItems(RenderRequest req) { … } @RequestMapping(params = "action=authority.selection") public void selectionAuthorities(@RequestParam("includedHidden") String ids, ActionRequest req, ActionResponse res) { … } Massimiliano Dessì, Pronetics S.p.a 33
  • 34. SpringPortletMVC /* FORM methods*/ @InitBinder() public void initBinder(WebDataBinder binder) throws Exception { binder.registerCustomEditor(String.class, new StringTrimmerEditor(false)); } @ModelAttribute("strategies") public List<PermissionStrategy> populatePermissionStrategy() { return roleStrategyService.getPermissions(); } Massimiliano Dessì, Pronetics S.p.a 34
  • 35. SpringPortletMVC // render phase @RequestMapping(params = "action=authority.edit") public String showForm(Model model, @RequestParam(required = false, value = "aid") Integer id) { … } // action phase @RequestMapping(params = "action=authority.edit") public void processSubmit(ActionResponse res, @ModelAttribute("authority") AuthorityDTO authority, BindingResult result, SessionStatus status, Model model) { … } Massimiliano Dessì, Pronetics S.p.a 35
  • 36. SpringMVC - SpringPortletMVC Massimiliano Dessì, Pronetics S.p.a 36
  • 37. Database embedded Domande ? Massimiliano Dessì, Pronetics S.p.a 37
  • 38. Grazie per l’attenzione ! Massimiliano Dessì desmax74 at yahoo.it massimiliano.dessi at pronetics.it http://twitter.com/desmax74 http://jroller.com/desmax http://www.linkedin.com/in/desmax74 http://wiki.java.net/bin/view/People/MassimilianoDessi http://www.jugsardegna.org/vqwiki/jsp/Wiki?MassimilianoDessi Spring Framework Italian User Group http://it.groups.yahoo.com/group/SpringFramework-it Massimiliano Dessì, Pronetics S.p.a 38