[jboss-cvs] JBossAS SVN: r65000 - in trunk/system-jmx/src/main/org/jboss/system/deployers: managed and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 31 18:43:07 EDT 2007
Author: scott.stark at jboss.org
Date: 2007-08-31 18:43:07 -0400 (Fri, 31 Aug 2007)
New Revision: 65000
Added:
trunk/system-jmx/src/main/org/jboss/system/deployers/managed/
trunk/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceMetaDataICF.java
Log:
InstanceClassFactory implementation for ServiceMetaData
Added: trunk/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceMetaDataICF.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceMetaDataICF.java (rev 0)
+++ trunk/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceMetaDataICF.java 2007-08-31 22:43:07 UTC (rev 65000)
@@ -0,0 +1,84 @@
+/*
+ * 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.deployers.managed;
+
+import java.io.Serializable;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.spi.factory.InstanceClassFactory;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+
+/**
+ * The InstanceClassFactory implementation for ServiceMetaData.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class ServiceMetaDataICF
+ implements InstanceClassFactory
+{
+ /** The meta value factory */
+ private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
+
+ public Class<? extends Serializable> getManagedObjectClass(Serializable instance)
+ throws ClassNotFoundException
+ {
+ ServiceMetaData md = (ServiceMetaData) instance;
+ ClassLoader loader = instance.getClass().getClassLoader();
+ Class moClass = loader.loadClass(md.getCode());
+ return moClass;
+ }
+ public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property, Serializable instance)
+ {
+ ServiceMetaData md = (ServiceMetaData) instance;
+ // First look to the mapped name
+ String name = property.getMappedName();
+ if (name == null)
+ property.getName();
+
+ // Get the attribute value
+ Object value = null;
+ for (ServiceAttributeMetaData amd : md.getAttributes())
+ {
+ if (amd.getName().equals(name))
+ {
+ value = amd.getValue();
+ }
+ }
+
+ PropertyInfo propertyInfo = beanInfo.getProperty(name);
+ if (propertyInfo == null)
+ {
+ throw new IllegalStateException("Unable to find property: " + name
+ + " for " + instance.getClass().getName());
+ }
+
+ return metaValueFactory.create(value, propertyInfo.getType());
+ }
+
+
+}
Property changes on: trunk/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceMetaDataICF.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list