[jboss-cvs] JBossAS SVN: r79341 - in trunk: system/src/main/org/jboss/profileservice/spi and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 10 06:53:48 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-10-10 06:53:47 -0400 (Fri, 10 Oct 2008)
New Revision: 79341

Modified:
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
   trunk/system/src/main/org/jboss/profileservice/spi/AttachmentsSerializer.java
   trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
   trunk/system/src/main/org/jboss/profileservice/spi/Profile.java
   trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractFileAttachmentsSerializer.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaBeanXmlAttachmentsSerializer.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaSerializationAttachmentsSerializer.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
Log:
JBAS-6037, work on restoring attachments serialization

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2008-10-10 10:29:50 UTC (rev 79340)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2008-10-10 10:53:47 UTC (rev 79341)
@@ -21,6 +21,7 @@
  */
 package org.jboss.profileservice.management;
 
+import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.text.MessageFormat;
 import java.util.ArrayList;
@@ -76,6 +77,7 @@
 import org.jboss.metatype.api.values.SimpleValue;
 import org.jboss.profileservice.management.plugins.BasicDeploymentTemplateInfo;
 import org.jboss.profileservice.spi.AttachmentsSerializer;
+import org.jboss.profileservice.spi.DeploymentRepository;
 import org.jboss.profileservice.spi.NoSuchDeploymentException;
 import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.Profile;
@@ -105,15 +107,14 @@
    /** The currently loaded profile */
    private Profile activeProfile;
    private long activeProfileLastModified;
-   /** */
+   /** The MainDeployer used to process profile changes */
    private MainDeployer mainDeployer;
-   /** The attachments serializer used to */
-   private AttachmentsSerializer serializer;
+
    private InvokerLocator locator;
 
    /** */
    private HashMap<String, DeploymentTemplate> templates = new HashMap<String, DeploymentTemplate>();
-   /** */
+   /** The internationalization resource bundle */
    private ResourceBundle i18n;
    /** */
    private Locale currentLocale;
@@ -452,16 +453,6 @@
       this.locator = locator;
    }
 
-   public AttachmentsSerializer getSerializer()
-   {
-      return serializer;
-   }
-
-   public void setSerializer(AttachmentsSerializer serializer)
-   {
-      this.serializer = serializer;
-   }
-
    public MainDeployer getMainDeployer()
    {
       return mainDeployer;
@@ -839,6 +830,9 @@
       activeProfileLastModified = 0;
    }
 
+   /**
+    * Process a component update.
+    */
    public void updateComponent(ManagedComponent comp)
       throws Exception
    {
@@ -848,8 +842,8 @@
          md = md.getParent();
       String name = md.getName();
       DeploymentPhase phase = md.getDeploymentPhase();
-      Deployment mdCtx = activeProfile.getDeployment(name, phase);
-      if( mdCtx == null )
+      VFSDeployment compDeployment = activeProfile.getDeployment(name, phase);
+      if( compDeployment == null )
       {
          formatter.applyPattern(i18n.getString("ManagementView.NoSuchDeploymentException")); //$NON-NLS-1$
          Object[] args = {name};
@@ -857,7 +851,7 @@
          throw new NoSuchDeploymentException(msg);
       }
 
-      // Apply the managed properties
+      // Apply the managed properties to the server ManagedDeployment/ManagedComponent
       ManagedDeployment compMD = managedDeployments.get(md.getName());
       log.debug("updateComponent, profile="+activeProfile+", deploymentName="+name+", phase="+phase+", :"+compMD);
       ManagedComponent serverComp = compMD.getComponent(comp.getName());
@@ -871,6 +865,7 @@
          throw new IllegalArgumentException(msg);
       }
 
+      Map<String, Serializable> attachments = new HashMap<String, Serializable>();
       for(ManagedProperty prop : comp.getProperties().values())
       {
          // Skip null values && non-CONFIGURATION values
@@ -903,10 +898,21 @@
          }
          MetaValue metaValue = (MetaValue)value;
          ctxProp.setValue(metaValue);
+         // Dispatch any runtime component property values
          Object componentName = getComponentName(ctxProp);
          if (componentName != null)
             dispatcher.set(componentName, ctxProp.getName(), metaValue);
+         // Collect the affected attachments
+         ManagedObject ctxMO = ctxProp.getManagedObject();
+         String attachmentName = ctxMO.getAttachmentName();
+         Serializable attachment = ctxMO.getAttachment();
+         if(attachment != null)
+            attachments.put(attachmentName, attachment);
       }
+
+      // Update the repository deployment attachments
+      // TODO, this seems to flat to deal with nested deployments
+      activeProfile.updateDeployment(compDeployment, phase, attachments);
    }
 
    /**

Modified: trunk/system/src/main/org/jboss/profileservice/spi/AttachmentsSerializer.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/AttachmentsSerializer.java	2008-10-10 10:29:50 UTC (rev 79340)
+++ trunk/system/src/main/org/jboss/profileservice/spi/AttachmentsSerializer.java	2008-10-10 10:53:47 UTC (rev 79341)
@@ -21,10 +21,9 @@
  */
 package org.jboss.profileservice.spi;
 
+import java.io.Serializable;
 import java.util.Map;
 
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-
 /**
  * An interface that allows externalization of the attachment
  * serialization details.
@@ -34,8 +33,9 @@
  */
 public interface AttachmentsSerializer
 {
-   public void saveAttachments(DeploymentUnit ctx, String deployerID, ClassLoader loader)
+   public void saveAttachments(String baseName, 
+         Map<String, Serializable> attachments)
       throws Exception;
-   public Map<String, Object> loadAttachments(DeploymentUnit ctx, String deployerID, ClassLoader loader)
+   public Map<String, Object> loadAttachments(String baseName, ClassLoader loader)
       throws Exception;
 }

Modified: trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java	2008-10-10 10:29:50 UTC (rev 79340)
+++ trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java	2008-10-10 10:53:47 UTC (rev 79341)
@@ -23,9 +23,11 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.Serializable;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Collection;
+import java.util.Map;
 import java.util.Set;
 
 import org.jboss.deployers.spi.attachments.Attachments;
@@ -163,7 +165,17 @@
     */
    public void addDeployment(String vfsPath, VFSDeployment d, DeploymentPhase phase)
       throws Exception;
-   public void updateDeployment(String vfsPath, VFSDeployment d, DeploymentPhase phase)
+   /**
+    * Update a deployments attachments. This persists the deployments
+    * pre-determined attachments.
+    * 
+    * @param vfsPath - the vfs path relative to the phase root for the deployment
+    * @param phase - the deployment phase
+    * @param attachments - the attachments that have been modified
+    * @throws Exception
+    */
+   public void updateDeployment(VFSDeployment d, DeploymentPhase phase,
+         Map<String, Serializable> attachments)
       throws Exception;
    /**
     * Get a named deployment.

Modified: trunk/system/src/main/org/jboss/profileservice/spi/Profile.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/Profile.java	2008-10-10 10:29:50 UTC (rev 79340)
+++ trunk/system/src/main/org/jboss/profileservice/spi/Profile.java	2008-10-10 10:53:47 UTC (rev 79341)
@@ -21,6 +21,7 @@
  */
 package org.jboss.profileservice.spi;
 
+import java.io.Serializable;
 import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
@@ -100,9 +101,12 @@
     * @param d the deployment
     * @param phase - the phase of the deployment as it relates to when the
     * deployment is loaded
+    * @param attachments - the attachments that have been modified
     * @throws Exception for any error
     */
-   void updateDeployment(VFSDeployment d, DeploymentPhase phase) throws Exception;
+   void updateDeployment(VFSDeployment d, DeploymentPhase phase,
+         Map<String, Serializable> attachments)
+      throws Exception;
 
    /**
     * Remove a deployment

Modified: trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java	2008-10-10 10:29:50 UTC (rev 79340)
+++ trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java	2008-10-10 10:53:47 UTC (rev 79341)
@@ -22,6 +22,7 @@
 package org.jboss.system.server.profile.basic;
 
 import java.io.File;
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -148,7 +149,8 @@
       }
       this.lastModified = System.currentTimeMillis();
    }
-   public void updateDeployment(VFSDeployment d, DeploymentPhase phase)
+   public void updateDeployment(VFSDeployment d, DeploymentPhase phase,
+         Map<String, Serializable> attachments)
       throws Exception
    {
    

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java	2008-10-10 10:29:50 UTC (rev 79340)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java	2008-10-10 10:53:47 UTC (rev 79341)
@@ -21,6 +21,7 @@
  */
 package org.jboss.system.server.profile.repository;
 
+import java.io.Serializable;
 import java.net.URI;
 import java.util.Collection;
 import java.util.Collections;
@@ -146,10 +147,11 @@
       String name = d.getName();
       repository.addDeployment(name, d, phase);
    }
-   public void updateDeployment(VFSDeployment d, DeploymentPhase phase)
+   public void updateDeployment(VFSDeployment d, DeploymentPhase phase,
+         Map<String, Serializable> attachments)
        throws Exception
    {
-      repository.updateDeployment(d.getName(), d, phase);
+      repository.updateDeployment(d, phase, attachments);
    }
    public VFSDeployment getDeployment(String name, DeploymentPhase phase)
        throws Exception, NoSuchDeploymentException

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractFileAttachmentsSerializer.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractFileAttachmentsSerializer.java	2008-10-10 10:29:50 UTC (rev 79340)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractFileAttachmentsSerializer.java	2008-10-10 10:53:47 UTC (rev 79341)
@@ -24,10 +24,12 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.NotSerializableException;
+import java.io.Serializable;
 import java.util.Map;
 import java.util.Map.Entry;
 
 import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.aop.TrackingAdvice;
 import org.jboss.profileservice.spi.AttachmentsSerializer;
@@ -54,15 +56,15 @@
       this.attachmentsStoreDir = attachmentsStoreDir;
    }
 
-   public Map<String, Object> loadAttachments(DeploymentUnit ctx, String deployerID, ClassLoader loader)
+   public Map<String, Object> loadAttachments(String baseName, ClassLoader loader)
       throws Exception
    {
       if( attachmentsStoreDir == null )
          throw new IllegalStateException("attachmentsStoreDir has not been set");
 
-      String vfsPath = ctx.getSimpleName();
+      String vfsPath = baseName;
       vfsPath += ".attachments";
-      File deployerDir = new File(attachmentsStoreDir, deployerID);
+      File deployerDir = new File(attachmentsStoreDir, vfsPath);
       File attachmentsStore = new File(deployerDir, vfsPath);
       if( attachmentsStore.exists() == false )
       {
@@ -72,18 +74,16 @@
       return loadAttachments(attachmentsStore, loader);
    }
 
-   public void saveAttachments(DeploymentUnit ctx, String deployerID, ClassLoader loader)
+   public void saveAttachments(String baseName, 
+         Map<String, Serializable> attachments)
       throws Exception
    {
       if( attachmentsStoreDir == null )
          throw new IllegalStateException("attachmentsStoreDir has not been set");
 
-      String vfsPath = ctx.getSimpleName();
-      if( vfsPath.length() == 0 )
-         vfsPath = ctx.getSimpleName();
+      String vfsPath = baseName;
       vfsPath += ".attachments";
-      File deployerDir = new File(attachmentsStoreDir, deployerID);
-      File attachmentsStore = new File(deployerDir, vfsPath);
+      File attachmentsStore = new File(attachmentsStoreDir, vfsPath);
       File attachmentsParent = attachmentsStore.getParentFile();
       if( attachmentsParent.exists() == false )
       {
@@ -91,18 +91,17 @@
             throw new IOException("Failed to create attachmentsParent: "+attachmentsParent.getAbsolutePath());
       }
 
-      Map<String, Object> attachments = TrackingAdvice.clearAttachmentsForTarget(ctx.getTransientManagedObjects());
       if( attachments != null )
       {
          try
          {
-            saveAttachments(attachmentsStore, attachments, loader);
+            saveAttachments(attachmentsStore, attachments);
          }
          catch(NotSerializableException e)
          {
             // Log what is in the attachments
             StringBuilder tmp = new StringBuilder("Save failed with NSE, attachments contents: ");
-            for(Entry<String, Object> entry : attachments.entrySet())
+            for(Entry<String, Serializable> entry : attachments.entrySet())
             {
                tmp.append(entry.getKey());
                tmp.append('=');
@@ -116,6 +115,6 @@
 
    protected abstract Map<String, Object> loadAttachments(File attachmentsStore, ClassLoader loader)
       throws Exception;
-   protected abstract void saveAttachments(File attachmentsStore, Map<String, Object> attachments, ClassLoader loader)
+   protected abstract void saveAttachments(File attachmentsStore, Map<String, Serializable> attachments)
       throws Exception;
 }

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaBeanXmlAttachmentsSerializer.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaBeanXmlAttachmentsSerializer.java	2008-10-10 10:29:50 UTC (rev 79340)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaBeanXmlAttachmentsSerializer.java	2008-10-10 10:53:47 UTC (rev 79341)
@@ -26,6 +26,7 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.Serializable;
 import java.util.Map;
 
 import org.jboss.logging.Logger;
@@ -75,7 +76,7 @@
 
    @Override
    protected void saveAttachments(File attachmentsStore,
-         Map<String, Object> map, ClassLoader loader) throws Exception
+         Map<String, Serializable> map) throws Exception
    {
       log.debug("saveAttachments, attachmentsStore="+attachmentsStore);
       if( log.isTraceEnabled() )

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaSerializationAttachmentsSerializer.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaSerializationAttachmentsSerializer.java	2008-10-10 10:29:50 UTC (rev 79340)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/JavaSerializationAttachmentsSerializer.java	2008-10-10 10:53:47 UTC (rev 79341)
@@ -26,6 +26,7 @@
 import java.io.FileOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.util.Arrays;
@@ -83,7 +84,7 @@
    }
 
    protected void saveAttachments(File attachmentsStore,
-         Map<String, Object> map, ClassLoader loader)
+         Map<String, Serializable> map)
       throws Exception
    {
       log.debug("saveAttachments, attachmentsStore="+attachmentsStore);

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java	2008-10-10 10:29:50 UTC (rev 79340)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java	2008-10-10 10:53:47 UTC (rev 79341)
@@ -24,10 +24,12 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.Serializable;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 import java.util.zip.ZipInputStream;
 
@@ -491,7 +493,9 @@
       }      
    }
 
-   public void updateDeployment(String vfsPath, VFSDeployment d, DeploymentPhase phase) throws Exception
+   public void updateDeployment(VFSDeployment d, DeploymentPhase phase,
+         Map<String, Serializable> attachments)
+      throws Exception
    {      
    }
 

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java	2008-10-10 10:29:50 UTC (rev 79340)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java	2008-10-10 10:53:47 UTC (rev 79341)
@@ -27,6 +27,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.ObjectOutputStream;
+import java.io.Serializable;
 import java.io.SyncFailedException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -101,7 +102,7 @@
    private LinkedHashMap<String,VFSDeployment> deployerCtxs = new LinkedHashMap<String,VFSDeployment>();
    /** The application VFSDeployments */
    private LinkedHashMap<String,VFSDeployment> applicationCtxs = new LinkedHashMap<String,VFSDeployment>();
-   /** The {@link VFSDeployment#getTransientManagedObjects()} serializer */
+   /** The {@link VFSDeployment#PredeterminedManagedObjects} serializer */
    private AttachmentsSerializer serializer;
    private Map<String, Integer> contentFlags = new ConcurrentHashMap<String, Integer>();
    /** The last time the profile was modified */
@@ -413,10 +414,17 @@
       }
    }
 
-   public void updateDeployment(String vfsPath, VFSDeployment d, DeploymentPhase phase)
+   // TODO
+   public void updateDeployment(VFSDeployment d, DeploymentPhase phase,
+         Map<String, Serializable> attachments)
       throws Exception
    {
+      String baseName = d.getSimpleName();
+      if(baseName.length() == 0)
+         baseName = d.getName();
+      serializer.saveAttachments(baseName, attachments);
    }
+
    public VFSDeployment getDeployment(String name, DeploymentPhase phase)
       throws Exception, NoSuchDeploymentException
    {
@@ -690,6 +698,7 @@
 
       adminEditsRoot = new File(profileRoot, "profile/edits");
 
+      // TODO: need to load pre-determined attachments using serializer
       if( bootstrapDir != null )
       {
          VFS bootstrapVFS = VFS.getVFS(bootstrapDir.toURI());




More information about the jboss-cvs-commits mailing list