[shrinkwrap-issues] [JBoss JIRA] (SHRINKWRAP-402) Support method for checking what type of Archive this is

Aslak Knutsen (JIRA) jira-events at lists.jboss.org
Mon Sep 10 06:17:32 EDT 2012


    [ https://issues.jboss.org/browse/SHRINKWRAP-402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12716915#comment-12716915 ] 

Aslak Knutsen commented on SHRINKWRAP-402:
------------------------------------------

I think you answered your own question: specification-defined naming

A ShrinkWrap EnterpriseArchive is intended to map the EAR format:
https://github.com/shrinkwrap/shrinkwrap/blob/master/api/src/main/java/org/jboss/shrinkwrap/api/spec/EnterpriseArchive.java#L28

"... Web modules are packaged as JAR files with a *.war* (Web ARchive) extension."
"... Resource adapter modules are packaged as JAR files with an *.rar* (resource adapter archive) extension."

ShrinkWrap is a convenience wrapper, why can't it be convenient to figure out the intended Type of the archive. The Archive view is just a view, not the type. 

You can't separate between a JAR, WAR or EAR purely based on content.

ShrinkWrap.create(GenericArchive.class, "test.XXX")
  .add(new FileAsset("my.jar"));

Now is that a..
- EAR with a JAR module?
- WAR with a JAR WebResource?
- JAR with a JAR Resource?

                
> Support method for checking what type of Archive this is
> --------------------------------------------------------
>
>                 Key: SHRINKWRAP-402
>                 URL: https://issues.jboss.org/browse/SHRINKWRAP-402
>             Project: ShrinkWrap
>          Issue Type: Feature Request
>          Components: api, impl-base
>    Affects Versions: 1.0.0
>            Reporter: Aslak Knutsen
>            Assignee: Aslak Knutsen
>
> ShrinkWrap has the notion of views to wrap a Archive. While a view can be anything, some of the views describes types of Archives, e.g. WebArchive. A Archive should be able to tell which type it is. Even tho the content structure to some extent define the type, external sources like a Container will determine the type of the Archive soley on the archive name extension. 
> {code}
> ShrinkWrap.create(JavaArchive.class).isOfType(WebArchive.class) == false
> ShrinkWrap.create(JavaArchive.class, "my.war").isOfType(WebArchive.class) == true
> ShrinkWrap.create(MySpecialWebArchive.class, "my.war").isOfType(WebArchive.class) == true
> {code}
> A simple check if the current archive name ends with the Types defined extension mapping should work in most cases. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the shrinkwrap-issues mailing list