Seam 21 Migration

  • Upload
    iosjrus

  • View
    220

  • Download
    0

Embed Size (px)

Citation preview

  • 8/3/2019 Seam 21 Migration

    1/5

    Seam 2.1 Migration Guide========================Before you get started with Seam 2.1, there are a few things you should be awareof. This process should not be too painful - if you get stuck, just refer backto the updated Seam examples.

    This migration guide assumes you are using Seam 2.0, if you are migrating from

    Seam 1.2, see the seam2migration guide as well.

    Testing-------

    SeamTest now boots Seam at the start of each suite, rather than the start ofeach class. This is much faster. See the reference manual for how to alter thedefault.

    DTDs and Schemas----------------

    The DTDs for Seam XML files are no longer supported. Please use the XML schemasfor validation. Files that use the Seam 2.0 XSDs should be updated to refer tothe 2.1 XSDs

    Exception Handling------------------

    The caught exception is now available in EL as #{org.jboss.seam.caughtException}rather than #{org.jboss.seam.exception}

    EntityConverter configuration-----------------------------

    If you need to configure which entity manager to use, this is now done on theentity-loader component. See the documentation for details.

    Assumed name for managed Hibernate session------------------------------------------

    Several areas of Seam, including the Seam Application Framework, rely on anaming convention for the Seam-managed persistence context (JPA) and Hibernatesession. Prior to Seam 2.1, the assumed name of the managed Hibernate sessionwas "session". However, session is a very overloaded name in Seam and the JavaServlet API. To make it less ambigous, the default was changed to

    "hibernateSession".

    The benefit now is that when you inject or resolve the Hibernate session, youknow that is the refernece you are getting (rather than the HTTP session, mailsession, or some other "session").

    You would inject it as follows:

    @In private Session hibernateSession;

    or

    @In(name = "hibernateSession") private Session session;

    If the name of your Seam-managed Hibernate session is "session", you can stillinject this reference explictly using the session property:

  • 8/3/2019 Seam 21 Migration

    2/5

    The alternative is to override the getPersistenceContextName() method on anypersistence controller in the Seam Application Framework:

    public String getPersistenceContextName() {"session";

    }

    Security--------

    If you are using rule-based security in your project, the configuration for thesecurity rules in components.xml has changed. Previously, the rules were configuredas a property of the identity component as such:

    In Seam 2.1, rule-based permission checks are now carried out by the ruleBasedPermissionResolvercomponent. You must activate this component and register the security rules withit instead of theidentity component:

    IMPORTANT! The definition of a permission has also changed. Prior to Seam 2.1, apermission

    consisted of three elements:

    * name* action* contextual object (optional)

    The name would typically be the Seam component name, entity class, or view ID. The action would bethe method name, the JSF phase (restore or render), or an assigned term representing the intent ofthe activity. Finally, one or more contextual objects could be inserted directlyinto the workingmemory to help make the decision, typically the target of the activity.

    For example: s:hasPermission('userManager', 'edit', user)

    In Seam 2.1, a permission has been simplified to just two elements:

    * target* action

    In place of the nebulous name element, the target becomes the focus of the permission. The actioncontinues to communicate the intent of the activity being secured. Inside the rules file, most of the

    checking now revolves around the target object.

    For example: s:hasPermission(user, 'edit')

  • 8/3/2019 Seam 21 Migration

    3/5

    This change makes the rules more generally applicable. It also allows Seam to consult a persistentpermission resolver (ACL) in addition to the rule-based resolver.

    Be aware that existing rules may behave oddly. That's because given the following permission check:

    s:hasPermission('userManager', 'edit', user)

    Seam will transpose as follows to bring it inline with the new design.

    s:hasPemrission(user, 'edit')

    Please read the new chapter on security for all the details about this new design.Identity.isLoggedIn()---------------------

    This method has been modified so that it doesn't attempt to perform an authentication if credentialshave been set. Instead, it will simply return true if the user is currently authenticated. If yourequire the previous behaviour, then please use Identity.tryLogin() instead.

    If you are using the token-based "Remember Me" feature of Seam Security, you will need to add the followingsection to components.xml to ensure that the user is automatically logged in when first accessing theapplication:

    PDF (iText)--------

    The documentStore component has been moved from the pdf/itext module into Seam proper. Anyreferences to pdf:document-store in components.xml should be replaced with document:document-store.Similary, if you are currently referencing org.jboss.seam.pdf.DocumentStoreServlet in your web.xml,you should now use org.jboss.seam.document.DocumentStoreServlet.

    Clustering----------

    Seam's ManagedEntityInterceptor (formally ManagedEntityIdentityInterceptor) is now disabled by

    default. If you need the ManagedEntityInterceptor for clustered failover of conversations, you canenable it components.xml:

  • 8/3/2019 Seam 21 Migration

    4/5

    org.jboss.seam.core.SynchronizationInterceptororg.jboss.seam.async.AsynchronousInterceptororg.jboss.seam.ejb.RemoveInterceptororg.jboss.seam.persistence.HibernateSessionProxyInterceptor

    org.jboss.seam.persistence.EntityManagerProxyInterceptororg.jboss.seam.core.MethodContextInterceptororg.jboss.seam.core.EventInterceptororg.jboss.seam.core.ConversationalInterceptororg.jboss.seam.bpm.BusinessProcessInterceptororg.jboss.seam.core.ConversationInterceptororg.jboss.seam.core.BijectionInterceptororg.jboss.seam.transaction.RollbackInterceptororg.jboss.seam.transaction.TransactionInterceptororg.jboss.seam.webservice.WSSecurityInterceptororg.jboss.seam.security.SecurityInterceptororg.jboss.seam.persistence.ManagedEntityInterceptor

    Asynchronous Exception Handling----------------------

    All asynchronous invocations are now wrapped in exception handling. By default,anyexceptions which propagate out of the asynchronous call are caught and logged aterror level. The reference manual describes how to customize this behaviour.

    Redeploy--------

    The org.jboss.seam.postInitialization event is no longer called on redeploy,instead org.jboss.seam.postReInitialization is called.

    Cache Support-------------

    Cache support has be rewritten to support JBoss Cache, JBoss POJO Cache, JBossCache 2 and EHCache. If you are running on JBoss AS 4.2.x JBoss Cache 1.x willbe used or on JBoss 5.x JBoss Cache 2 will be installed. You can find more abouthow to configure the cache provider in the reference manual.

    The use is unchanged, but you can no longer inject the pojoCachecomponent. Instead you should configure JBoss POJO cache as your cache providerin components.xml:

    and inject it using

    @In CacheProvider cacheProvider;

    The CacheProvider provides a Map like interface, and the getDelegate() methodcan be used to retrieve the underling cache.

  • 8/3/2019 Seam 21 Migration

    5/5

    Dependency changes (Maven)--------------------------

    The "provided" platform is now JBoss AS 4.2.3, therefore javasisst:javassist anddom4j:dom4j are now marked as provided.

    Seam Application Framework Changes----------------------------------

    Seam now expects value expressions for a number of properties(entityHome.createdMessage, entityHome.updatedMessage, entityHome.deletedMessageand entityQuery.restrictions); if you are using components.xml to configure yourobjects, you don't need to make any changes. If you are extending the objects inJava, you just need to create a value expression; for example:

    public ValueExpression getCreatedMessage() {return createValueExpression("New person #{person.firstName} #{person.lastNam

    e} created");}