[jboss-cvs] JBossAS SVN: r59069 - in trunk/system/src: main/org/jboss/deployers/spi/management main/org/jboss/profileservice/spi main/org/jboss/system/server/profile main/org/jboss/system/server/profile/repository main/org/jboss/system/server/profileservice main/org/jboss/system/server/profileservice/basic main/org/jboss/system/server/profileservice/repository tests/org/jboss/test/profileservice/simple1 tests/org/jboss/test/profileservice/support tests/org/jboss/test/server/profileservice

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Dec 18 03:07:00 EST 2006


Author: scott.stark at jboss.org
Date: 2006-12-18 03:06:42 -0500 (Mon, 18 Dec 2006)
New Revision: 59069

Added:
   trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
   trunk/system/src/main/org/jboss/profileservice/spi/ProfileRepository.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/
   trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/DeploymentRecord.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/FileProfleRepository.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileServiceImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
Modified:
   trunk/system/src/main/org/jboss/deployers/spi/management/ManagementView.java
   trunk/system/src/main/org/jboss/profileservice/spi/ProfileService.java
   trunk/system/src/main/org/jboss/system/server/profileservice/ManagementViewImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
   trunk/system/src/main/org/jboss/system/server/profileservice/VFSScanner.java
   trunk/system/src/main/org/jboss/system/server/profileservice/basic/ProfileServiceImpl.java
   trunk/system/src/tests/org/jboss/test/profileservice/simple1/ManagementViewImpl.java
   trunk/system/src/tests/org/jboss/test/profileservice/simple1/ProfileServiceImpl.java
   trunk/system/src/tests/org/jboss/test/profileservice/support/Simple1PSBootstrap.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/MainTestCase.java
Log:
Checkpoint of the profile repository

Modified: trunk/system/src/main/org/jboss/deployers/spi/management/ManagementView.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/ManagementView.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/ManagementView.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -46,7 +46,7 @@
     * @throws NoSuchProfileException
     * @throws NoSuchDeploymentException 
     */
-   public ManagedObject getView(ProfileKey key, String deploymentName)
+   public ManagedObject getView(ProfileKey key, String deploymentName, String version)
       throws NoSuchProfileException, NoSuchDeploymentException;
 
 }

Added: trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.spi;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Collection;
+import java.util.zip.ZipInputStream;
+
+import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * An interface for managing the contents of a Profile.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface DeploymentRepository
+{
+   public URI getBootstrapURI();
+   public void setBootstrapURI(URI uri);
+   public URI getDeployersURI();
+   public void setDeployersURI(URI uri);
+   public URI getDeploymentURI();
+   public void setDeploymentURI(URI rootURI);
+
+   // Upload a raw deployment
+   public VirtualFile addDeploymentFile(String name, ZipInputStream contentIS)
+      throws IOException;
+   // Get the raw deployment
+   public VirtualFile getDeploymentFile(String name);
+
+   // Bootstrap
+   public void addBootstrap(String vfsPath, DeploymentContext ctx)
+      throws IOException;
+   public DeploymentContext getBootstrap(String vfsPath);
+   public Collection<DeploymentContext> getBootstraps();
+   public void removeBootstrap(String vfsPath)
+      throws IOException;
+
+   // Deployers
+   public void addDeployer(String vfsPath, DeploymentContext ctx)
+      throws IOException;
+   public DeploymentContext getDeployer(String vfsPath);
+   public Collection<DeploymentContext> getDeployers();
+   public void removeDeployer(String vfsPath)
+      throws IOException;
+
+   // Deployments
+   public void addDeployment(String vfsPath, DeploymentContext ctx)
+      throws IOException;
+   public DeploymentContext getDeployment(String vfsPath);
+   public void removeDeployment(String vfsPath)
+      throws IOException;
+   public Collection<DeploymentContext> getDeployments();
+
+   // Managed object attachments for a deployment
+   public void addManagedObject(String vfsPath, Attachments edits)
+      throws IOException;
+}

Added: trunk/system/src/main/org/jboss/profileservice/spi/ProfileRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/ProfileRepository.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/main/org/jboss/profileservice/spi/ProfileRepository.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.spi;
+
+import java.io.IOException;
+
+/**
+ * An interface for obtaining DeploymentRepository for a Profile.
+ *  
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface ProfileRepository
+{
+   /**
+    * Create a new DeploymentRepository for a profile.
+    * 
+    * @param key - the key for the Profile to create the DeploymentRepository for.
+    * @return the profile DeploymentRepository
+    * @throws IOException thrown if the repository cannot be created or
+    *    already exists
+    */
+   public DeploymentRepository createProfileDeploymentRepository(ProfileKey key)
+      throws IOException;
+
+   /**
+    * Get the DeploymentRepository for the given profile key.
+    * 
+    * @param key - the key for the Profile to obtain the DeploymentRepository for.
+    * @return the profile DeploymentRepository
+    * @throws NoSuchProfileException thrown if there is no such profile.
+    */
+   public DeploymentRepository getProfileDeploymentRepository(ProfileKey key)
+      throws IOException, NoSuchProfileException;
+
+   /**
+    * Remove the DeploymentRepository for the given profile key.
+    * @param key - the key for the Profile to obtain the DeploymentRepository for.
+    * @throws IOException thrown on error removing the repository
+    * @throws NoSuchProfileException thrown if there is no such profile.
+    */
+   public void removeProfileDeploymentRepository(ProfileKey key)
+      throws IOException, NoSuchProfileException;
+}

Modified: trunk/system/src/main/org/jboss/profileservice/spi/ProfileService.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/ProfileService.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/main/org/jboss/profileservice/spi/ProfileService.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -55,7 +55,7 @@
     * @return the matching profile.
     * @throws NoSuchProfileException
     */
-   public Profile getProfile(ProfileKey key)
+   public Profile getProfile(ProfileKey key, String version)
       throws NoSuchProfileException;
 
    /**
@@ -74,8 +74,9 @@
    public ManagementView getViewManager();
 
    // Admin of profiles @todo could be an option plugin
-   public Profile newProfile(ProfileKey key);
-   public void removeProfile(ProfileKey key)
-      throws NoSuchProfileException;
+   public Profile newProfile(ProfileKey key, String version)
+      throws Exception;
+   public void removeProfile(ProfileKey key, String version)
+      throws Exception;
 
 }

Added: trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -0,0 +1,152 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profile.repository;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.DeploymentTemplate;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.util.JBossObject;
+
+/**
+ * A basic profile implementation that uses the DeploymentRepository to store
+ * deployments and admin metadata.
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ProfileImpl extends JBossObject
+   implements Profile
+{
+   private String name;
+   private String version;
+   /** The repository containing the deployment contents */
+   private DeploymentRepository repository;
+
+   /**
+    * 
+    * @param repository
+    * @param name
+    */
+   public ProfileImpl(DeploymentRepository repository, String name)
+   {
+      this(repository, name, null);
+   }
+   public ProfileImpl(DeploymentRepository repository, String name, String version)
+   {
+      this.name = name;
+      this.version = version;
+      this.repository = repository;
+      log.info("Using repository:"+repository);
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+   
+   public String getVersion()
+   {
+      return version;
+   }
+   
+   public void addBootstrap(DeploymentContext d) throws Exception
+   {
+      repository.addBootstrap(d.getRelativePath(), d);
+   }
+   
+   public void removeBootstrap(String name) throws Exception
+   {
+      repository.removeBootstrap(name);
+   }
+   
+   public DeploymentContext getBootstrap(String name) throws NoSuchDeploymentException
+   {
+      DeploymentContext deployment = repository.getBootstrap(name);
+      return deployment;
+   }
+   
+   public Collection<DeploymentContext> getBootstraps()
+   {
+      return Collections.unmodifiableCollection(repository.getBootstraps());
+   }
+
+   public void addDeployer(DeploymentContext d) throws Exception
+   {
+      repository.addDeployer(d.getRelativePath(), d);
+   }
+   
+   public void removeDeployer(String name) throws Exception
+   {
+      repository.removeDeployer(name);
+   }
+   
+   public DeploymentContext getDeployer(String name) throws NoSuchDeploymentException
+   {
+      DeploymentContext deployment = repository.getDeployer(name);
+      return deployment;
+   }
+   
+   public Collection<DeploymentContext> getDeployers()
+   {
+      return Collections.unmodifiableCollection(repository.getDeployers());
+   }
+   
+   public DeploymentTemplate getTemplate(String name)
+         throws NoSuchDeploymentException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+   
+   public void addDeployment(DeploymentContext d) throws Exception
+   {
+      repository.addDeployment(d.getRelativePath(), d);
+   }
+   
+   public void removeDeployment(String name) throws Exception
+   {
+      repository.removeDeployment(name);
+   }
+   
+   public DeploymentContext getDeployment(String name)
+         throws NoSuchDeploymentException
+   {
+      DeploymentContext deployment = repository.getDeployment(name);
+      return deployment;
+   }
+
+   public Collection<DeploymentContext> getDeployments()
+   {
+      return Collections.unmodifiableCollection(repository.getDeployments());
+   }
+   
+   public Map<String, Object> getConfig()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+}

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/ManagementViewImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/ManagementViewImpl.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/ManagementViewImpl.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -49,10 +49,10 @@
       this.ps = ps;
    }
 
-   public ManagedObject getView(ProfileKey key, String deploymentName)
+   public ManagedObject getView(ProfileKey key, String deploymentName, String version)
       throws NoSuchProfileException, NoSuchDeploymentException
    {
-      Profile profile = ps.getProfile(key);
+      Profile profile = ps.getProfile(key, version);
       DeploymentContext d = profile.getDeployment(deploymentName);
       // TODO ManagedObject mo = d.getManagedObject();
       // return mo;

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -328,7 +328,7 @@
 
       // Load the named profile
       ProfileKey key = new ProfileKey(name);
-      Profile profile = ps.getProfile(key);
+      Profile profile = ps.getProfile(key, null);
 
       // HACK
       DeploymentContext first = null;

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/VFSScanner.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/VFSScanner.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/VFSScanner.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -567,7 +567,7 @@
       DeploymentContext deployment = null;
       try
       {
-         Profile profile = profileService.getProfile(profileKey);
+         Profile profile = profileService.getProfile(profileKey, null);
          deployment = add(profile, component);
       }
       catch (Exception e)
@@ -618,7 +618,7 @@
             log.trace("Undeploying: " + component);
          }
          String name = deployedSet.remove(component);         
-         Profile profile = profileService.getProfile(profileKey);
+         Profile profile = profileService.getProfile(profileKey, null);
          remove(profile, name);
       }
       catch (Exception e)

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/basic/ProfileServiceImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/basic/ProfileServiceImpl.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/basic/ProfileServiceImpl.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -90,7 +90,7 @@
    /**
     * Always returns the default profile.
     */
-   public Profile getProfile(ProfileKey key)
+   public Profile getProfile(ProfileKey key, String version)
       throws NoSuchProfileException
    {
       return defaultImpl;
@@ -113,12 +113,12 @@
    }
 
    // Admin of profiles @todo could be an option plugin
-   public Profile newProfile(ProfileKey key)
+   public Profile newProfile(ProfileKey key, String version)
    {
       return new ProfileImpl(profileRoot, name);
    }
 
-   public void removeProfile(ProfileKey key)
+   public void removeProfile(ProfileKey key, String version)
       throws NoSuchProfileException
    {
    }

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/DeploymentRecord.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/DeploymentRecord.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/DeploymentRecord.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profileservice.repository;
+
+import java.io.Serializable;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DeploymentRecord implements Serializable
+{
+   private static final long serialVersionUID = 1;
+   
+}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/FileProfleRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/FileProfleRepository.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/FileProfleRepository.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profileservice.repository;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.NoSuchProfileException;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileRepository;
+
+/**
+ * An implementation of ProfileRepository that uses the following
+ * file system structure for storing deployments and admin
+ * edits.
+ * 
+ * root-file
+ * + server/{name}/conf/bootstrap.xml - the bootstrap beans
+ * + server/{name}/deployers - profile deployers
+ * + server/{name}/deploy - installed deployments
+ * + server/{name}/apps - post install deployments
+ * + server/{name}/admin - admin edits to deployments
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class FileProfleRepository implements ProfileRepository
+{
+   private File root;
+
+   public FileProfleRepository(File root)
+   {
+      this.root = root;
+   }
+
+   public File getRoot()
+   {
+      return root;
+   }
+
+   public DeploymentRepository createProfileDeploymentRepository(ProfileKey key) throws IOException
+   {
+      SerializableDeploymentRepository repository = new SerializableDeploymentRepository(root, key);
+      repository.create();
+      return repository;
+   }
+
+   public DeploymentRepository getProfileDeploymentRepository(ProfileKey key)
+      throws IOException, NoSuchProfileException
+   {
+      SerializableDeploymentRepository repository = new SerializableDeploymentRepository(root, key);
+      repository.load();
+      return repository;
+   }
+
+   public void removeProfileDeploymentRepository(ProfileKey key) throws IOException, NoSuchProfileException
+   {      
+      SerializableDeploymentRepository repository = new SerializableDeploymentRepository(root, key);
+      repository.remove();  
+   }
+
+}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileServiceImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileServiceImpl.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileServiceImpl.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -0,0 +1,165 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profileservice.repository;
+
+import java.io.IOException;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.NoSuchProfileException;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileRepository;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.system.server.profile.repository.ProfileImpl;
+
+
+/**
+ * A ProfileService impl that uses a ProfileRepository/DeploymentRepository
+ * based Profile implementation.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class ProfileServiceImpl
+   implements ProfileService
+{
+   /** The name of the profile to use */
+   private String name;
+   /** The version of the profile to use */
+   private String version;
+   private ProfileRepository profileRepository;
+   private DeploymentRepository deploymentRepository;
+   private Profile profile;
+   private ManagementView mgtView;
+
+   public ProfileServiceImpl(String name) throws IOException
+   {
+      this.name = name;
+   }
+   // Properties ------------------------
+
+   public String getName()
+   {
+      return this.name;
+   }
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+
+   public String getVersion()
+   {
+      return version;
+   }
+
+   public void setVersion(String version)
+   {
+      this.version = version;
+   }
+
+   public ProfileRepository getProfileRepository()
+   {
+      return profileRepository;
+   }
+
+   public void setProfileRepository(ProfileRepository profileRepository)
+   {
+      this.profileRepository = profileRepository;
+   }
+
+   public DeploymentRepository getDeploymentRepository()
+   {
+      return deploymentRepository;
+   }
+
+   public void setDeploymentRepository(DeploymentRepository repository)
+   {
+      this.deploymentRepository = repository;
+   }
+
+   public void start()
+      throws Exception
+   {
+      if( profileRepository == null )
+         throw new IllegalStateException("No profileRepository specified");
+      // Obtain the deployment repository for the profile
+      if( deploymentRepository == null )
+      {
+         ProfileKey key = new ProfileKey(name);
+         deploymentRepository = profileRepository.getProfileDeploymentRepository(key);
+      }
+      profile = new ProfileImpl(deploymentRepository, name, version);
+   }
+
+   // ProfileService implementation --------------------
+   public String[] getDomains()
+   {
+      String[] domains = {ProfileKey.DEFAULT};
+      return domains;
+   }
+
+   public ProfileKey[] getProfileKeys()
+   {
+      ProfileKey[] keys = {new ProfileKey(name)};
+      return keys;
+   }
+
+   /**
+    * Always returns the default profile.
+    */
+   public Profile getProfile(ProfileKey key, String version)
+      throws NoSuchProfileException
+   {
+      return profile;
+   }
+
+   public String[] getProfileDeploymentNames(ProfileKey key)
+      throws NoSuchProfileException
+   {
+      String[] names = {"default"};
+      return names;
+   }
+
+   public ManagementView getViewManager()
+   {
+      return mgtView;
+   }
+   public void setViewManager(ManagementView mgtView)
+   {
+      this.mgtView = mgtView;
+   }
+
+   public Profile newProfile(ProfileKey key, String version)
+      throws Exception
+   {
+      DeploymentRepository repo = profileRepository.createProfileDeploymentRepository(key);
+      return new ProfileImpl(repo, key.getName(), version);
+   }
+
+   public void removeProfile(ProfileKey key, String version)
+      throws IOException, NoSuchProfileException
+   {
+      profileRepository.removeProfileDeploymentRepository(key);
+   }
+}
+

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -0,0 +1,294 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profileservice.repository;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectOutputStream;
+import java.net.URI;
+import java.util.Collection;
+import java.util.Map;
+import java.util.zip.ZipInputStream;
+
+import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.NoSuchProfileException;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.util.file.Files;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * An implementation of DeploymentRepository that relies on java
+ * serialization to store contents on the file system.
+ * 
+ * root-file
+ * + server/{name}/conf/bootstrap.xml - the bootstrap beans
+ * + server/{name}/deployers - profile deployers
+ * + server/{name}/deploy - installed deployments
+ * + server/{name}/apps - post install deployments
+ * + server/{name}/admin - admin edits to deployments
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SerializableDeploymentRepository implements DeploymentRepository
+{
+   private File root;
+   private File confDir;
+   private File libDir;
+   private File deployersDir;
+   private File deployDir;
+   private File metaDataRoot;
+   private File adminEditsRoot;
+   private ProfileKey key;
+
+   public SerializableDeploymentRepository(File root, ProfileKey key)
+   {
+      this.root = root;
+      this.key = key;
+   }
+
+   void create() throws IOException
+   {
+      File profileRoot = new File(root, "server/"+key.getName());
+      if( profileRoot.exists() == true )
+         throw new IOException("Profile root alread exists: "+profileRoot);
+      if( profileRoot.mkdirs() == false )
+         throw new IOException("Failed to create profile root: "+profileRoot);
+      // server/{name}/conf
+      confDir = new File(profileRoot, "conf");
+      if( confDir.mkdirs() == false )
+         throw new IOException("Failed to create profile conf dir: "+confDir);
+      // server/{name}/deployers
+      deployersDir = new File(profileRoot, "deployers");
+      if( deployersDir.mkdirs() == false )
+         throw new IOException("Failed to create profile deployers dir: "+deployersDir);
+      // server/{name}/deploy
+      deployDir = new File(profileRoot, "deploy");
+      if( deployDir.mkdirs() == false )
+         throw new IOException("Failed to create profile deploy dir: "+deployDir);
+      // server/{name}/lib
+      libDir = new File(profileRoot, "lib");
+      if( libDir.mkdirs() == false )
+         throw new IOException("Failed to create profile lib dir: "+libDir);
+      metaDataRoot = new File(profileRoot, "metaData");
+      if( metaDataRoot.mkdirs() == false )
+         throw new IOException("Failed to create profile metaData dir: "+metaDataRoot);
+      
+      adminEditsRoot = new File(profileRoot, "adminEdits");
+      if( adminEditsRoot.mkdirs() == false )
+         throw new IOException("Failed to create profile adminEdits dir: "+adminEditsRoot);
+   }
+
+   void load() throws IOException, NoSuchProfileException
+   {
+      File profileRoot = new File(root, "server/"+key.getName());
+      if( profileRoot.exists() == true )
+         throw new NoSuchProfileException("Profile root alread exists: "+profileRoot);
+      //
+      
+   }
+
+   void remove() throws IOException, NoSuchProfileException
+   {
+      File profileRoot = new File(root, "server/"+key.getName());
+      if( profileRoot.exists() == true )
+         throw new NoSuchProfileException("Profile root alread exists: "+profileRoot);
+      //
+      Files.delete(profileRoot);
+   }
+
+   public boolean exists()
+   {
+      File profileRoot = new File(root, "server/"+key.getName());
+      return profileRoot.exists();
+   }
+
+   public VirtualFile addDeploymentFile(String name, ZipInputStream contentIS)
+      throws IOException
+   {
+      return null;
+   }
+
+   public void addBootstrap(String vfsPath, DeploymentContext ctx)
+      throws IOException
+   {
+      // Write out the base transient metadata
+      saveAttachments(vfsPath, ctx);
+   }
+
+   // Managed object attachments for a deployment
+   public void addManagedObject(String vfsPath, Attachments edits)
+      throws IOException
+   {
+      Map<String, Object> map = edits.getAttachments();
+      File attachments = new File(adminEditsRoot, vfsPath+".edits");
+      FileOutputStream fos = new FileOutputStream(attachments);
+      ObjectOutputStream oos = new ObjectOutputStream(fos);
+      oos.writeObject(map);
+      oos.close();
+      fos.close();
+
+   }
+
+   public void addDeployer(String vfsPath, DeploymentContext ctx) throws IOException
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void addDeployment(String vfsPath, DeploymentContext ctx) throws IOException
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public DeploymentContext getBootstrap(String vfsPath)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public Collection<DeploymentContext> getBootstraps()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public URI getBootstrapURI()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public DeploymentContext getDeployer(String vfsPath)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public Collection<DeploymentContext> getDeployers()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public URI getDeployersURI()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public DeploymentContext getDeployment(String vfsPath)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public VirtualFile getDeploymentFile(String name)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public Collection<DeploymentContext> getDeployments()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public URI getDeploymentURI()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public void removeBootstrap(String vfsPath) throws IOException
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void removeDeployer(String vfsPath) throws IOException
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void removeDeployment(String vfsPath) throws IOException
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void setBootstrapURI(URI uri)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void setDeployersURI(URI uri)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void setDeploymentURI(URI rootURI)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   private void saveAttachments(String vfsPath, DeploymentContext ctx)
+      throws IOException
+   {
+      // Write out the base transient metadata
+      Attachments transientAttachments = ctx.getTransientAttachments();
+      if( transientAttachments.getAttachments().size() > 0 )
+      {
+         Map<String, Object> map = transientAttachments.getAttachments();
+         File attachments = new File(metaDataRoot, vfsPath+".transientAttachments");
+         FileOutputStream fos = new FileOutputStream(attachments);
+         ObjectOutputStream oos = new ObjectOutputStream(fos);
+         oos.writeObject(map);
+         oos.close();
+         fos.close();
+      }
+   
+      // Write out the base transient managed objects
+      Attachments transientManagedObjects = ctx.getTransientManagedObjects();
+      if( transientManagedObjects.getAttachments().size() > 0 )
+      {
+         Map<String, Object> map = transientManagedObjects.getAttachments();
+         File attachments = new File(metaDataRoot, vfsPath+".transientManagedObjects");
+         FileOutputStream fos = new FileOutputStream(attachments);
+         ObjectOutputStream oos = new ObjectOutputStream(fos);
+         oos.writeObject(map);
+         oos.close();
+         fos.close();
+      }
+   }
+
+}

Modified: trunk/system/src/tests/org/jboss/test/profileservice/simple1/ManagementViewImpl.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/profileservice/simple1/ManagementViewImpl.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/tests/org/jboss/test/profileservice/simple1/ManagementViewImpl.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -49,10 +49,10 @@
       this.ps = ps;
    }
 
-   public ManagedObject getView(ProfileKey key, String deploymentName)
+   public ManagedObject getView(ProfileKey key, String deploymentName, String version)
       throws NoSuchProfileException, NoSuchDeploymentException
    {
-      Profile profile = ps.getProfile(key);
+      Profile profile = ps.getProfile(key, version);
       DeploymentContext d = profile.getDeployment(deploymentName);
       /** TODO ManagedObject mo = d.getManagedObject();
       return mo; */

Modified: trunk/system/src/tests/org/jboss/test/profileservice/simple1/ProfileServiceImpl.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/profileservice/simple1/ProfileServiceImpl.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/tests/org/jboss/test/profileservice/simple1/ProfileServiceImpl.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -62,7 +62,7 @@
    /**
     * Always returns the default profile.
     */
-   public Profile getProfile(ProfileKey key)
+   public Profile getProfile(ProfileKey key, String version)
       throws NoSuchProfileException
    {
       return defatulImpl;
@@ -81,12 +81,12 @@
    }
 
    // Admin of profiles @todo could be an option plugin
-   public Profile newProfile(ProfileKey key)
+   public Profile newProfile(ProfileKey key, String version)
    {
       return null;
    }
 
-   public void removeProfile(ProfileKey key)
+   public void removeProfile(ProfileKey key, String version)
       throws NoSuchProfileException
    {
    }

Modified: trunk/system/src/tests/org/jboss/test/profileservice/support/Simple1PSBootstrap.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/profileservice/support/Simple1PSBootstrap.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/tests/org/jboss/test/profileservice/support/Simple1PSBootstrap.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -61,7 +61,7 @@
 
       // Load the named profile
       ProfileKey key = new ProfileKey(name);
-      Profile profile = profileService.getProfile(key);
+      Profile profile = profileService.getProfile(key, null);
       /* TODO 
       Deployment[] profileDeployments = profile.getDeployments();
       for(Deployment d : profileDeployments)

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/MainTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/MainTestCase.java	2006-12-17 11:39:17 UTC (rev 59068)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/MainTestCase.java	2006-12-18 08:06:42 UTC (rev 59069)
@@ -71,12 +71,12 @@
       psb.bootstrap();
       ProfileService ps = psb.getProfileService();
       ProfileKey defaultKey = new ProfileKey("default");
-      Profile profile = ps.getProfile(defaultKey);
+      Profile profile = ps.getProfile(defaultKey, null);
       DeploymentContext testBeans = profile.getDeployment("test-beans.xml");
       if( testBeans == null )
       {
          if( profile == null )
-            profile = ps.newProfile(defaultKey);
+            profile = ps.newProfile(defaultKey, null);
          MainDeployer deployer = psb.getMainDeployer();
          VFS vfs = VFS.getVFS(resourcesDir);
          VirtualFile file = vfs.findChildFromRoot("deploy/beans/test-beans.xml");




More information about the jboss-cvs-commits mailing list