[shrinkwrap-issues] [JBoss JIRA] Commented: (SHRINKWRAP-85) Support Event/Listener style callbacks

Aslak Knutsen (JIRA) jira-events at lists.jboss.org
Wed May 12 06:49:26 EDT 2010


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

Aslak Knutsen commented on SHRINKWRAP-85:
-----------------------------------------

In it's simples form: 

Archive:

   /**
    * Add a listener for call back based on a specific filter.
    *  
    * @param filter Filter to match for this {@link Listener}
    * @param listener CallBack on add
    * @return This archive
    */
   T addListener(Filter<ArchivePath> filter, Listener listener);

Listener:

public interface Listener
{
  /**
    * CallBack when a {@link Asset} is added to a specific {@link ArchivePath}.
    * 
    * @param archivePath Where in the {@link Archive} it is being added.
    * @param asset What is being added
    * @return the Asset to insert into the {@link Archive}, null to not add.
    */
   Asset added(ArchivePath archivePath, Asset asset);
}


MemoryMapArchiveBase:

   @Override
   public T add(Asset asset, ArchivePath path)
   {
      Validate.notNull(asset, "No asset was specified");
      Validate.notNull(path, "No path was specified");
      
      Asset listenerAsset = invokeListeners(path, asset);
     ........


   // should support listener chaining, not just the first one found?
   private Asset invokeListeners(ArchivePath path, Asset asset)
   {
      for(Map.Entry<Filter<ArchivePath>, Listener> listenerEntry : listeners.entrySet())
      {
         if(listenerEntry.getKey().include(path))
         {
            return listenerEntry.getValue().added(path, asset);
         }
      }
      return asset;
   }


> Support Event/Listener style callbacks
> --------------------------------------
>
>                 Key: SHRINKWRAP-85
>                 URL: https://jira.jboss.org/jira/browse/SHRINKWRAP-85
>             Project: ShrinkWrap
>          Issue Type: Feature Request
>            Reporter: Aslak Knutsen
>
> A interesting feature would be to be able to add listeners for events on ContainerTypes or paths. 
> /META-INF/* or all events generated via ClassContainer
> usecase 1, if/when we add something like a ManifestDescriptor, instead of having it like the WebArchiveDescriptor.addServlet, adding a addMenifestLibrary that delegates down to addLibrary and update the 'classpath: ' manifest entry..  we could register a listener on the LibraryContainer and get callbacks when a 'normal' addLibrary happens
> usecase 2, could deploy a 'live' archive to embedded.. one could register a listener on all changes in the archive and auto redeploy it on events.. 
> deploy it once, redeploy on change

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the shrinkwrap-issues mailing list