[jboss-cvs] JBoss Profiler SVN: r475 - in branches/JBossProfiler2/src: main/org/jboss/profiler/plugins and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 10 04:30:04 EDT 2008
Author: jesper.pedersen
Date: 2008-09-10 04:30:03 -0400 (Wed, 10 Sep 2008)
New Revision: 475
Added:
branches/JBossProfiler2/src/main/org/jboss/profiler/plugins/Seam.java
Modified:
branches/JBossProfiler2/src/etc/jboss-profiler.properties
Log:
Add Seam plugin
Modified: branches/JBossProfiler2/src/etc/jboss-profiler.properties
===================================================================
--- branches/JBossProfiler2/src/etc/jboss-profiler.properties 2008-09-10 08:05:17 UTC (rev 474)
+++ branches/JBossProfiler2/src/etc/jboss-profiler.properties 2008-09-10 08:30:03 UTC (rev 475)
@@ -19,3 +19,4 @@
rmi=yes
corba=yes
plugin.1=org.jboss.profiler.plugins.Hibernate
+plugin.2=org.jboss.profiler.plugins.Seam
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/plugins/Seam.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/plugins/Seam.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/plugins/Seam.java 2008-09-10 08:30:03 UTC (rev 475)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007-2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.profiler.plugins;
+
+import org.jboss.profiler.shared.Plugin;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * The Seam plugin
+ * @author Jesper Pedersen <jesper.pedersen at jboss.org>
+ */
+public class Seam implements Plugin {
+
+ /** The Seam constant */
+ private static final int SEAM = 100;
+
+ /** The vendor */
+ private static final String VENDOR = "JBoss";
+
+ /** The product */
+ private static final String PRODUCT = "Seam Profiler Plugin";
+
+ /** The version */
+ private static final String VERSION = "1.0.CR1";
+
+ /** Full version */
+ private static final String FULL_VERSION = VENDOR + " " + PRODUCT + " " + VERSION;
+
+ /** Known classes */
+ private Set<String> known;
+
+ /**
+ * Constructor
+ */
+ public Seam() {
+ known = new HashSet<String>();
+ }
+
+ /**
+ * Get the name of the plugin
+ * @return The name
+ */
+ public String getName() {
+ return FULL_VERSION;
+ }
+
+ /**
+ * Is the class supported by the plugin
+ * @param c The class
+ * @return True if supported; otherwise false
+ */
+ public boolean isSupported(Class c) {
+
+ if (isAnnotated(c)) {
+ known.add(c.getName());
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Get the type of the class
+ * @param c The class
+ * @return The type; negative if unknown
+ */
+ public int getType(Class c) {
+ if (known.contains(c.getName())) {
+ return SEAM;
+ }
+ return -1;
+ }
+
+ /**
+ * Get the description of the type
+ * @param type The type
+ * @return The description; otherwise null
+ */
+ public String getDescription(int type) {
+ if (SEAM == type) {
+ return "SEAM";
+ }
+ return null;
+ }
+
+ /**
+ * Annotated with @Entity
+ * @param clz The class
+ * @return True if found; otherwise false
+ */
+ private boolean isAnnotated(Class clz) {
+ if (clz != null) {
+ Annotation[] annotations = clz.getDeclaredAnnotations();
+ for (Annotation ca : annotations) {
+ if (ca.annotationType().getName().startsWith("org.jboss.seam.annotations.Name")) {
+ return true;
+ }
+ }
+
+ return isAnnotated(clz.getSuperclass());
+ }
+
+ return false;
+ }
+}
More information about the jboss-cvs-commits
mailing list