[jboss-cvs] JBossAS SVN: r100396 - projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 4 04:41:02 EST 2010


Author: emuckenhuber
Date: 2010-02-04 04:41:01 -0500 (Thu, 04 Feb 2010)
New Revision: 100396

Added:
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileKeyMetaMapper.java
Modified:
   projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/Profile.java
Log:
add profile key meta mapper.

Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/Profile.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/Profile.java	2010-02-04 09:35:35 UTC (rev 100395)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/Profile.java	2010-02-04 09:41:01 UTC (rev 100396)
@@ -24,6 +24,11 @@
 import java.util.Collection;
 import java.util.Set;
 
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementObjectID;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+
 /**
  * A profile represents a named collection of deployments on a server.
  * 
@@ -32,24 +37,30 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
+ at ManagementObject(properties = ManagementProperties.EXPLICIT)
 public interface Profile
 {
    
    /**
-    * Get the key used to create the Profile
+    * Get the key used to create the Profile.
+    * 
     * @return key used to create the Profile
     */
+   @ManagementObjectID
    ProfileKey getKey();
 
    /**
     * Get the names of the deployments in the profile.
+    * 
     * @return names of deployments
     */
+   @ManagementProperty(name = "deployment-names", description = "The deployment names.", readOnly = true)
    Set<String> getDeploymentNames();
 
    /**
-    * Get all deployments defined in this profile
-    * @return the deployment instances in this profile.
+    * Get all deployments defined in this profile.
+    * 
+    * @return the deployment instances in this profile
     */
    Collection<ProfileDeployment> getDeployments();
    
@@ -71,9 +82,11 @@
    boolean hasDeployment(String name);
    
    /**
-    * Get the system time in milliseconds the profile was last modified. 
+    * Get the system time in milliseconds the profile was last modified.
+    *  
     * @return System.currentTimeMillis of last modification
     */
+   @ManagementProperty(name = "last-modified", description = "The time this profile was last modified.", readOnly = true)
    long getLastModified();
    
    /**

Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileKeyMetaMapper.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileKeyMetaMapper.java	                        (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileKeyMetaMapper.java	2010-02-04 09:41:01 UTC (rev 100396)
@@ -0,0 +1,78 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Inc., and individual contributors as indicated
+* 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.lang.reflect.Type;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.MetaMapper;
+
+/**
+ * A ProfileKey -> SimpleValue.STRING meta mapper. We only need the
+ * profile name, since the domain and server information are shared
+ * between all ProfileKeys in a server.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProfileKeyMetaMapper extends MetaMapper<ProfileKey>
+{
+
+   @Override
+   public MetaType getMetaType()
+   {
+      return SimpleMetaType.STRING;
+   }
+   
+   @Override
+   public Type mapToType()
+   {
+      return ProfileKey.class;
+   }
+   
+   @Override
+   public MetaValue createMetaValue(MetaType metaType, ProfileKey key)
+   {
+      if(key == null)
+      {
+         throw new IllegalArgumentException("null profile key");
+      }
+      return SimpleValueSupport.wrap(key.getName());
+   }
+
+   @Override
+   public ProfileKey unwrapMetaValue(MetaValue metaValue)
+   {
+      if(metaValue != null && SimpleMetaType.STRING.equals(metaValue.getMetaType()))
+      {
+         String profileName = String.class.cast(((SimpleValue) metaValue).getValue());
+         return new ProfileKey(profileName);
+      }
+      throw new IllegalStateException("cannot recreate profile key");
+   }
+
+}
+




More information about the jboss-cvs-commits mailing list