[jboss-cvs] JBossAS SVN: r100406 - trunk/cluster/src/main/java/org/jboss/ha/singleton.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 4 05:40:54 EST 2010


Author: emuckenhuber
Date: 2010-02-04 05:40:54 -0500 (Thu, 04 Feb 2010)
New Revision: 100406

Added:
   trunk/cluster/src/main/java/org/jboss/ha/singleton/ProfileKeyMetaMapper.java
Modified:
   trunk/cluster/src/main/java/org/jboss/ha/singleton/HASingletonProfileActivator.java
   trunk/cluster/src/main/java/org/jboss/ha/singleton/HASingletonProfileManager.java
Log:
[JBAS-7642] add ProfileKey mapper

Modified: trunk/cluster/src/main/java/org/jboss/ha/singleton/HASingletonProfileActivator.java
===================================================================
--- trunk/cluster/src/main/java/org/jboss/ha/singleton/HASingletonProfileActivator.java	2010-02-04 10:30:31 UTC (rev 100405)
+++ trunk/cluster/src/main/java/org/jboss/ha/singleton/HASingletonProfileActivator.java	2010-02-04 10:40:54 UTC (rev 100406)
@@ -28,6 +28,7 @@
 import org.jboss.managed.api.annotation.ManagementProperties;
 import org.jboss.managed.api.annotation.ManagementProperty;
 import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.metatype.api.annotations.MetaMapping;
 import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
@@ -241,6 +242,7 @@
     */
    @ManagementProperty(use={ViewUse.STATISTIC}, description="ProfileKey for the Profile we activate")
    @ManagementObjectID(type="HASingletonProfileActivator")
+   @MetaMapping(ProfileKeyMetaMapper.class)
    public ProfileKey getProfileKey()
    {
       if (this.profileKey == null)

Modified: trunk/cluster/src/main/java/org/jboss/ha/singleton/HASingletonProfileManager.java
===================================================================
--- trunk/cluster/src/main/java/org/jboss/ha/singleton/HASingletonProfileManager.java	2010-02-04 10:30:31 UTC (rev 100405)
+++ trunk/cluster/src/main/java/org/jboss/ha/singleton/HASingletonProfileManager.java	2010-02-04 10:40:54 UTC (rev 100406)
@@ -33,6 +33,7 @@
 import org.jboss.managed.api.annotation.ManagementProperties;
 import org.jboss.managed.api.annotation.ManagementProperty;
 import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.metatype.api.annotations.MetaMapping;
 import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
@@ -131,6 +132,7 @@
 
    @ManagementProperty(use={ViewUse.STATISTIC}, description="ProfileKey for the Profile we activate")
    @ManagementObjectID(type="HASingletonProfileManager")
+   @MetaMapping(ProfileKeyMetaMapper.class)
    @Override
    public ProfileKey getProfileKey()
    {

Added: trunk/cluster/src/main/java/org/jboss/ha/singleton/ProfileKeyMetaMapper.java
===================================================================
--- trunk/cluster/src/main/java/org/jboss/ha/singleton/ProfileKeyMetaMapper.java	                        (rev 0)
+++ trunk/cluster/src/main/java/org/jboss/ha/singleton/ProfileKeyMetaMapper.java	2010-02-04 10:40:54 UTC (rev 100406)
@@ -0,0 +1,79 @@
+/*
+* 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.ha.singleton;
+
+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;
+import org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * 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