Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demonstrates the Problem External Libaries and Traits ServletAttributes

Groovy Traits should not use imports from External Libaries. Doing so reduces the possibility of future compatability.

The following situation could have been prevented if def was used instead of ServletContext. Doing so would have ensured either library could have been used in the future.

Preferred

trait ServletAttributes {
    private def servletContext
    
    String sayHello() {
        return "Hello from Jakarta"
    }

    def getServletContext() { servletContext }
}

Not Future Compatable

trait ServletAttributes {
    private def servletContext
    
    String sayHello() {
        return "Hello from Jakarta"
    }

    jakarta.servlet.ServletContext getServletContext() { servletContext }
}

To Run Demo

./initTest.sh javax 3
./runTest.sh jakarta 4

compared to

./initTest.sh pref 3
./runTest.sh jakarta 4

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages