[jboss-cvs] JBossAS SVN: r95967 - in projects/jboss-jca/trunk: sjc and 15 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 3 11:37:44 EST 2009
Author: jesper.pedersen
Date: 2009-11-03 11:37:44 -0500 (Tue, 03 Nov 2009)
New Revision: 95967
Added:
projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/web.xml
projects/jboss-jca/trunk/web/
projects/jboss-jca/trunk/web/build.xml
projects/jboss-jca/trunk/web/src/
projects/jboss-jca/trunk/web/src/main/
projects/jboss-jca/trunk/web/src/main/java/
projects/jboss-jca/trunk/web/src/main/java/org/
projects/jboss-jca/trunk/web/src/main/java/org/jboss/
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/SecurityActions.java
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/WARDeployer.java
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/WARDeployment.java
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/WebServer.java
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/AttrResultInfo.java
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/DomainData.java
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/HtmlAdaptorServlet.java
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/MBeanData.java
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/OpResultInfo.java
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/SecurityActions.java
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/Server.java
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/package.html
projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/package.html
projects/jboss-jca/trunk/web/src/main/resources/
projects/jboss-jca/trunk/web/src/main/resources/console-manifest.mf
projects/jboss-jca/trunk/web/src/main/resources/console/
projects/jboss-jca/trunk/web/src/main/resources/console/WEB-INF/
projects/jboss-jca/trunk/web/src/main/resources/console/WEB-INF/web.xml
projects/jboss-jca/trunk/web/src/main/resources/console/displaymbeans.jsp
projects/jboss-jca/trunk/web/src/main/resources/console/displayopresult.jsp
projects/jboss-jca/trunk/web/src/main/resources/console/error.jsp
projects/jboss-jca/trunk/web/src/main/resources/console/index.jsp
projects/jboss-jca/trunk/web/src/main/resources/console/inspectmbean.jsp
projects/jboss-jca/trunk/web/src/main/resources/console/jboss.css
projects/jboss-jca/trunk/web/src/main/resources/web-manifest.mf
projects/jboss-jca/trunk/web/src/main/resources/web.xml
Modified:
projects/jboss-jca/trunk/build.xml
projects/jboss-jca/trunk/ivy.xml
projects/jboss-jca/trunk/sjc/build.xml
projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap.xml
projects/jboss-jca/trunk/sjc/src/main/resources/logging.properties
projects/jboss-jca/trunk/tools/findbugs/filter.xml
Log:
[JBJCA-207] [JBJCA-208] [JBJCA-209] [JBJCA-210] [JBJCA-211] [JBJCA-212] Web server / WAR deployer / management console
Modified: projects/jboss-jca/trunk/build.xml
===================================================================
--- projects/jboss-jca/trunk/build.xml 2009-11-03 16:36:46 UTC (rev 95966)
+++ projects/jboss-jca/trunk/build.xml 2009-11-03 16:37:44 UTC (rev 95967)
@@ -75,7 +75,9 @@
<property name="version.apache-log4j" value="1.2.14"/>
<property name="version.apache-logging" value="1.1.0.jboss"/>
<property name="version.apache-xerces" value="2.9.1"/>
+ <property name="version.dom4j" value="1.6.1"/>
<property name="version.easymock" value="2.4"/>
+ <property name="version.eclipse-jdt" value="3.1.1"/>
<property name="version.hibernate-validator" value="4.0.1.GA"/>
<property name="version.javassist" value="3.11.0.GA"/>
<property name="version.jaxb.api" value="2.1"/>
@@ -104,6 +106,8 @@
<property name="version.jboss.vfs" value="2.1.3.SP1"/>
<property name="version.jboss.xb" value="2.0.1.GA"/>
<property name="version.jboss.security" value="2.1.0.20090318"/>
+ <property name="version.jetty" value="6.1.21"/>
+ <property name="version.jetty.servlet" value="6.1.14"/>
<property name="version.junit" value="4.7"/>
<property name="version.slf4j" value="1.5.6"/>
<property name="version.stax" value="1.0.1"/>
@@ -204,6 +208,7 @@
<ant dir="core" inheritRefs="true" target="jars"/>
<ant dir="deployers" inheritRefs="true" target="jars"/>
<ant dir="embedded" inheritRefs="true" target="jars"/>
+ <ant dir="web" inheritRefs="true" target="jars"/>
<ant dir="sjc" inheritRefs="true" target="jars"/>
<ant dir="standalone" inheritRefs="true" target="jars"/>
</target>
@@ -218,6 +223,7 @@
<ant dir="core" inheritRefs="true" target="docs"/>
<ant dir="deployers" inheritRefs="true" target="docs"/>
<ant dir="embedded" inheritRefs="true" target="docs"/>
+ <ant dir="web" inheritRefs="true" target="docs"/>
<ant dir="sjc" inheritRefs="true" target="docs"/>
<ant dir="standalone" inheritRefs="true" target="docs"/>
</target>
@@ -365,6 +371,8 @@
<class location="${target.dir}/jboss-jca-sjc.jar" />
<class location="${target.dir}/jboss-jca-spec-api.jar" />
<class location="${target.dir}/jboss-jca-standalone.jar" />
+ <class location="${target.dir}/jboss-jca-web.jar" />
+ <class location="${target.dir}/jboss-jca-web-console.jar" />
</findbugs>
<findbugs home="${basedir}/tools/findbugs/lib/"
@@ -391,6 +399,8 @@
<class location="${target.dir}/jboss-jca-sjc.jar" />
<class location="${target.dir}/jboss-jca-spec-api.jar" />
<class location="${target.dir}/jboss-jca-standalone.jar" />
+ <class location="${target.dir}/jboss-jca-web.jar" />
+ <class location="${target.dir}/jboss-jca-web-console.jar" />
</findbugs>
</target>
@@ -498,6 +508,9 @@
<fileset dir="fungal/src/main/java">
<include name="**/*.java" />
</fileset>
+ <fileset dir="web/src/main/java">
+ <include name="**/*.java" />
+ </fileset>
</cobertura-report>
<cobertura-report format="xml"
@@ -521,6 +534,9 @@
<fileset dir="fungal/src/main/java">
<include name="**/*.java" />
</fileset>
+ <fileset dir="web/src/main/java">
+ <include name="**/*.java" />
+ </fileset>
</cobertura-report>
</target>
Modified: projects/jboss-jca/trunk/ivy.xml
===================================================================
--- projects/jboss-jca/trunk/ivy.xml 2009-11-03 16:36:46 UTC (rev 95966)
+++ projects/jboss-jca/trunk/ivy.xml 2009-11-03 16:37:44 UTC (rev 95967)
@@ -39,6 +39,7 @@
<dependency org="apache-log4j" name="log4j" rev="${version.apache-log4j}" conf="standalone->default;sjc->*"/>
<dependency org="apache-logging" name="commons-logging" rev="${version.apache-logging}" conf="*"/>
<dependency org="com.sun.xml.bind" name="jaxb-impl" rev="${version.jaxb.impl}" conf="standalone->default;sjc->*"/>
+ <dependency org="dom4j" name="dom4j" rev="${version.dom4j}" conf="standalone->default;sjc->*"/>
<dependency org="javassist" name="javassist" rev="${version.javassist}" conf="standalone->default;sjc->*"/>
<dependency org="javax.activation" name="activation" rev="${version.activation}" conf="standalone->default;sjc->*"/>
<dependency org="javax.validation" name="validation-api" rev="${version.validation-api}" conf="standalone->default;sjc->*"/>
@@ -49,6 +50,7 @@
<dependency org="junit" name="junit" rev="${version.junit}" conf="test->default"/>
<dependency org="org.easymock" name="easymock" rev="${version.easymock}" conf="test->default"/>
<dependency org="org.easymock" name="easymockclassextension" rev="${version.easymock}" conf="test->default"/>
+ <dependency org="org.eclipse.jdt" name="core" rev="${version.eclipse-jdt}" conf="standalone->default;sjc->*"/>
<dependency org="org.hibernate" name="hibernate-validator" rev="${version.hibernate-validator}" conf="standalone->default;sjc->*"/>
<dependency org="org.jboss" name="jboss-common-core" rev="${version.jboss.common}" conf="standalone->default;sjc->*"/>
<dependency org="org.jboss" name="jboss-mdr" rev="${version.jboss.mdr}" conf="standalone->default;sjc->*"/>
@@ -88,6 +90,11 @@
<dependency org="org.jboss.slf4j" name="slf4j-jboss-logging" rev="${version.jboss.slf4j}" conf="standalone->default;sjc->*"/>
<dependency org="org.jboss.security" name="jboss-security-spi-bare" rev="${version.jboss.security}" conf="standalone->default;sjc->*"/>
<dependency org="org.jboss.slf4j" name="slf4j-jboss-logmanager" rev="${version.jboss.slf4j.logmanager}" conf="standalone->default;sjc->*"/>
+ <dependency org="org.mortbay.jetty" name="jetty" rev="${version.jetty}" conf="standalone->default;sjc->*"/>
+ <dependency org="org.mortbay.jetty" name="jetty-util" rev="${version.jetty}" conf="standalone->default;sjc->*"/>
+ <dependency org="org.mortbay.jetty" name="servlet-api-2.5" rev="${version.jetty.servlet}" conf="standalone->default;sjc->*"/>
+ <dependency org="org.mortbay.jetty" name="jsp-2.1" rev="${version.jetty.servlet}" conf="standalone->default;sjc->*"/>
+ <dependency org="org.mortbay.jetty" name="jsp-api-2.1" rev="${version.jetty.servlet}" conf="standalone->default;sjc->*"/>
<dependency org="org.slf4j" name="jcl-over-slf4j" rev="${version.slf4j}" conf="standalone->default;sjc->*"/>
<dependency org="org.slf4j" name="slf4j-api" rev="${version.slf4j}" conf="standalone->default;sjc->*"/>
<dependency org="stax" name="stax-api" rev="${version.stax}" conf="standalone->default;sjc->*"/>
Modified: projects/jboss-jca/trunk/sjc/build.xml
===================================================================
--- projects/jboss-jca/trunk/sjc/build.xml 2009-11-03 16:36:46 UTC (rev 95966)
+++ projects/jboss-jca/trunk/sjc/build.xml 2009-11-03 16:37:44 UTC (rev 95967)
@@ -134,12 +134,14 @@
<exclude name="jboss-jca-deployers-main.jar"/>
<exclude name="jboss-jca-deployers-rar.jar"/>
<exclude name="jboss-jca-standalone.jar"/>
+ <exclude name="jboss-jca-web-console.jar"/>
</fileset>
</copy>
<copy todir="${target.dir}/sjc/lib">
<fileset dir="${lib.dir}/sjc">
<include name="*.jar"/>
+ <exclude name="dom4j.jar"/>
<exclude name="jaxb-api.jar"/>
<exclude name="xercesImpl.jar"/>
<exclude name="stax-api.jar"/>
@@ -154,6 +156,12 @@
</fileset>
</copy>
+ <copy todir="${target.dir}/sjc/deploy">
+ <fileset dir="${target.dir}">
+ <include name="*.war"/>
+ </fileset>
+ </copy>
+
<chmod dir="${target.dir}/sjc/bin" perm="ugo+rx" includes="**/*.sh"/>
</target>
Added: projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/web.xml
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/web.xml (rev 0)
+++ projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/web.xml 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,16 @@
+<deployment>
+
+ <!-- Web Server -->
+ <bean name="WebServer" class="org.jboss.jca.web.WebServer">
+ <property name="host">${jboss.jca.bindaddress:localhost}</property>
+ <property name="port">8080</property>
+ <depends>NamingServer</depends>
+ </bean>
+
+ <!-- WAR deployer -->
+ <bean name="WARDeployer" class="org.jboss.jca.web.WARDeployer">
+ <property name="server"><inject bean="WebServer" property="Server"/></property>
+ <depends>WebServer</depends>
+ </bean>
+
+</deployment>
Modified: projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap.xml
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap.xml 2009-11-03 16:36:46 UTC (rev 95966)
+++ projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap.xml 2009-11-03 16:37:44 UTC (rev 95967)
@@ -3,5 +3,6 @@
<url>bootstrap/naming.xml</url>
<url>bootstrap/transaction.xml</url>
<url>bootstrap/jca.xml</url>
+ <url>bootstrap/web.xml</url>
</bootstrap>
Modified: projects/jboss-jca/trunk/sjc/src/main/resources/logging.properties
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/resources/logging.properties 2009-11-03 16:36:46 UTC (rev 95966)
+++ projects/jboss-jca/trunk/sjc/src/main/resources/logging.properties 2009-11-03 16:37:44 UTC (rev 95967)
@@ -23,7 +23,7 @@
### $Id: $ ###
# Additional logger names to configure (root logger is always configured)
-loggers=org.jboss.jca,org.jboss,org.jnp,com.arjuna
+loggers=org.jboss.jca,org.jboss,org.jnp,com.arjuna,org.mortbay
# Root logger level
logger.level=${jboss.jca.log.level:INFO}
@@ -41,6 +41,9 @@
# com.arjuna
logger.com.arjuna.level=INFO
+# org.mortbay
+logger.org.mortbay.level=WARN
+
# Console handler configuration
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.properties=autoFlush
Modified: projects/jboss-jca/trunk/tools/findbugs/filter.xml
===================================================================
--- projects/jboss-jca/trunk/tools/findbugs/filter.xml 2009-11-03 16:36:46 UTC (rev 95966)
+++ projects/jboss-jca/trunk/tools/findbugs/filter.xml 2009-11-03 16:37:44 UTC (rev 95967)
@@ -78,4 +78,42 @@
<Bug code="UPM"/>
</Match>
+ <!-- org.jboss.jca.web filter -->
+ <Match>
+ <Class name="org.jboss.jca.web.WARDeployment"/>
+ <Bug code="UrF"/>
+ </Match>
+ <Match>
+ <Class name="org.jboss.jca.web.console.HtmlAdaptorServlet"/>
+ <Bug code="DLS"/>
+ </Match>
+ <Match>
+ <Class name="org.jboss.jca.web.console.HtmlAdaptorServlet$1"/>
+ <Bug code="SIC"/>
+ </Match>
+ <Match>
+ <Class name="org.jboss.jca.web.console.HtmlAdaptorServlet$2"/>
+ <Bug code="SIC"/>
+ </Match>
+ <Match>
+ <Class name="org.jboss.jca.web.console.HtmlAdaptorServlet$3"/>
+ <Bug code="SIC"/>
+ </Match>
+ <Match>
+ <Class name="org.jboss.jca.web.console.HtmlAdaptorServlet$4"/>
+ <Bug code="SIC"/>
+ </Match>
+ <Match>
+ <Class name="org.jboss.jca.web.console.HtmlAdaptorServlet$5"/>
+ <Bug code="SIC"/>
+ </Match>
+ <Match>
+ <Class name="org.jboss.jca.web.console.OpResultInfo"/>
+ <Bug code="EI,EI2"/>
+ </Match>
+ <Match>
+ <Class name="org.jboss.jca.web.console.Server"/>
+ <Bug code="RCN"/>
+ </Match>
+
</FindBugsFilter>
Added: projects/jboss-jca/trunk/web/build.xml
===================================================================
--- projects/jboss-jca/trunk/web/build.xml (rev 0)
+++ projects/jboss-jca/trunk/web/build.xml 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,104 @@
+<!--
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.
+-->
+<project name="jboss-jca-web"
+ default="compile"
+ xmlns:ivy="antlib:org.apache.ivy.ant">
+
+ <!-- =================================
+ Properties
+ ================================= -->
+ <property name="build.web.dir" value="${build.dir}/web" />
+
+ <!-- =================================
+ Target: init
+ ================================= -->
+ <target name="init">
+ <mkdir dir="${build.web.dir}" />
+ <mkdir dir="${build.web.dir}/impl" />
+ </target>
+
+ <!-- =================================
+ Target: compile
+ ================================= -->
+ <target name="compile" depends="init">
+ <javac srcdir="src/main"
+ destdir="${build.web.dir}/impl"
+ classpathref="sjc.lib.path.id"
+ debug="${javac.debug}"
+ deprecation="${javac.deprecation}"
+ optimize="${javac.optimize}">
+ <compilerarg value="-Xlint"/>
+ </javac>
+ </target>
+
+ <!-- =================================
+ Target: jars
+ ================================= -->
+ <target name="jars" depends="compile">
+ <copy todir="${build.web.dir}/impl">
+ <fileset dir="src/main/resources"
+ includes="*.xml"/>
+ </copy>
+ <jar destfile="${target.dir}/jboss-jca-web.jar"
+ manifest="src/main/resources/web-manifest.mf"
+ basedir="${build.web.dir}/impl"
+ excludes="**/console/**,**/*.java"/>
+
+ <jar destfile="${target.dir}/jboss-jca-web-console.jar"
+ manifest="src/main/resources/console-manifest.mf"
+ basedir="${build.web.dir}/impl"
+ includes="**/console/**"
+ excludes="**/*.java"/>
+
+ <war destfile="${target.dir}/console.war"
+ webxml="src/main/resources/console/WEB-INF/web.xml">
+ <fileset dir="src/main/resources/console"/>
+ <lib dir="${target.dir}">
+ <include name="jboss-jca-web-console.jar"/>
+ </lib>
+ <lib dir="${lib.dir}/sjc">
+ <include name="dom4j.jar"/>
+ </lib>
+ </war>
+
+ </target>
+
+ <!-- =================================
+ Target: docs
+ ================================= -->
+ <target name="docs">
+ <mkdir dir="${target.dir}/docs/web"/>
+ <javadoc packagenames="org.*"
+ sourcepath="src/main/java"
+ destdir="${target.dir}/docs/web"
+ author="true"
+ version="true"
+ windowtitle="JBoss JCA Web"
+ doctitle="JBoss JCA Web"
+ use="true"
+ classpathref="sjc.lib.path.id"
+ bottom="Copyright © 2009 Red Hat Middleware LLC (http://www.jboss.com/)">
+ <link offline="true" href="http://java.sun.com/j2se/5/docs/api/" packagelistLoc="${java.home}/../docs/api"/>
+ </javadoc>
+ </target>
+
+</project>
Added: projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/SecurityActions.java
===================================================================
--- projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/SecurityActions.java (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/SecurityActions.java 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.web;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Privileged Blocks
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+class SecurityActions
+{
+ /**
+ * Constructor
+ */
+ private SecurityActions()
+ {
+ }
+
+ /**
+ * Get the thread context class loader
+ * @return The class loader
+ */
+ static ClassLoader getThreadContextClassLoader()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+
+ /**
+ * Set the thread context class loader
+ * @param cl The class loader
+ */
+ static void setThreadContextClassLoader(final ClassLoader cl)
+ {
+ AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ return null;
+ }
+ });
+ }
+
+ /**
+ * Get a system property
+ * @param name The property name
+ * @return The property value
+ */
+ static String getSystemProperty(final String name)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<String>()
+ {
+ public String run()
+ {
+ return System.getProperty(name);
+ }
+ });
+ }
+
+ /**
+ * Create an URLClassLoader
+ * @param urls The urls
+ * @param parent The parent class loader
+ * @return The class loader
+ */
+ static URLClassLoader createURLCLassLoader(final URL[] urls, final ClassLoader parent)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<URLClassLoader>()
+ {
+ public URLClassLoader run()
+ {
+ return new URLClassLoader(urls, parent);
+ }
+ });
+ }
+}
Added: projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/WARDeployer.java
===================================================================
--- projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/WARDeployer.java (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/WARDeployer.java 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,164 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.web;
+
+import org.jboss.jca.fungal.deployers.DeployException;
+import org.jboss.jca.fungal.deployers.Deployer;
+import org.jboss.jca.fungal.deployers.Deployment;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.webapp.WebAppContext;
+
+
+/**
+ * The WAR deployer for JCA/SJC
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class WARDeployer implements Deployer
+{
+ private static Logger log = Logger.getLogger(WARDeployer.class);
+ private static boolean trace = log.isTraceEnabled();
+
+ private Server server;
+
+ /**
+ * Constructor
+ */
+ public WARDeployer()
+ {
+ this.server = null;
+ }
+
+ /**
+ * Get the server
+ * @return The server
+ */
+ public Server getServer()
+ {
+ return server;
+ }
+
+ /**
+ * Set the server
+ * @param server The server
+ */
+ public void setServer(Server server)
+ {
+ this.server = server;
+ }
+
+ /**
+ * Deploy
+ * @param url The url
+ * @param parent The parent classloader
+ * @return The deployment
+ * @exception DeployException Thrown if an error occurs during deployment
+ */
+ public Deployment deploy(URL url, ClassLoader parent) throws DeployException
+ {
+ if (url == null || !(url.toExternalForm().endsWith(".war") || url.toExternalForm().endsWith(".war/")))
+ return null;
+
+ log.debug("Deploying: " + url.toExternalForm());
+
+ try
+ {
+ String path = url.toExternalForm();
+
+ // Extract context path based on .war name
+ String contextPath = "/";
+ if (!path.endsWith("/"))
+ {
+ contextPath += path.substring(path.lastIndexOf('/') + 1, path.lastIndexOf('.'));
+ }
+ else
+ {
+ int lastIndex = path.lastIndexOf('/');
+
+ int index = path.indexOf('/');
+ boolean done = false;
+
+ while (!done)
+ {
+ if (index + 1 <= path.length())
+ {
+ int nextIndex = path.indexOf('/', index + 1);
+ if (nextIndex == lastIndex)
+ {
+ done = true;
+ }
+ else
+ {
+ index = nextIndex;
+ }
+ }
+ else
+ {
+ done = true;
+ }
+ }
+
+ contextPath += path.substring(index + 1, path.lastIndexOf("."));
+ }
+
+ // Setup temporary work directory
+ File tmp = new File(SecurityActions.getSystemProperty("jboss.jca.home"), "/tmp/");
+ File tmpDeployment = new File(tmp, "/web" + contextPath);
+
+ if (!tmpDeployment.exists())
+ {
+ if (!tmpDeployment.mkdirs())
+ throw new IOException("Unable to create " + tmpDeployment);
+ }
+
+ // Map ROOT.war to /
+ if ("/ROOT".equalsIgnoreCase(contextPath))
+ contextPath = "/";
+
+ log.debug("ContextPath=" + contextPath);
+
+ WebAppContext webapp = new WebAppContext();
+ webapp.setContextPath(contextPath);
+ webapp.setWar(url.toString());
+ webapp.setTempDirectory(tmpDeployment);
+
+ server.stop();
+ server.addHandler(webapp);
+ server.start();
+
+ log.info("Deployed: " + url.toExternalForm());
+
+ return new WARDeployment(url, webapp, parent);
+ }
+ catch (Exception e)
+ {
+ throw new DeployException(e.getMessage(), e);
+ }
+ }
+}
Added: projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/WARDeployment.java
===================================================================
--- projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/WARDeployment.java (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/WARDeployment.java 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.web;
+
+import org.jboss.jca.fungal.deployers.Deployment;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+
+import org.mortbay.jetty.Handler;
+
+/**
+ * A web archive deployment for JCA/SJC
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class WARDeployment implements Deployment
+{
+ private static Logger log = Logger.getLogger(WARDeployer.class);
+
+ /** The web archiive */
+ private URL archive;
+
+ /** The handler */
+ private Handler handler;
+
+ /** The classloader */
+ private ClassLoader cl;
+
+ /**
+ * Constructor
+ * @param archive The archive
+ * @param handler The handler
+ * @param cl The classloader for the deployment
+ */
+ public WARDeployment(URL archive, Handler handler, ClassLoader cl)
+ {
+ this.archive = archive;
+ this.handler = handler;
+ this.cl = cl;
+ }
+
+ /**
+ * Get the unique URL for the deployment
+ * @return The URL
+ */
+ public URL getURL()
+ {
+ return archive;
+ }
+
+ /**
+ * Get the classloader
+ * @return The classloader
+ */
+ public ClassLoader getClassLoader()
+ {
+ return cl;
+ }
+
+ /**
+ * Destroy
+ */
+ public void destroy()
+ {
+ log.debug("Undeploying: " + archive.toExternalForm());
+
+ if (cl != null && cl instanceof Closeable)
+ {
+ try
+ {
+ ((Closeable)cl).close();
+ }
+ catch (IOException ioe)
+ {
+ // Swallow
+ }
+ }
+
+ log.info("Undeployed: " + archive.toExternalForm());
+ }
+}
Added: projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/WebServer.java
===================================================================
--- projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/WebServer.java (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/WebServer.java 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,153 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.jca.web;
+
+import java.util.concurrent.ExecutorService;
+
+import org.jboss.logging.Logger;
+
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.bio.SocketConnector;
+
+/**
+ * The web server
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class WebServer
+{
+ private static Logger log = Logger.getLogger(WebServer.class);
+ private static boolean trace = log.isTraceEnabled();
+
+ /** The server */
+ private Server server;
+
+ /** The host */
+ private String host;
+
+ /** The port */
+ private int port;
+
+ /** Executor service */
+ private ExecutorService executorService;
+
+ /**
+ * Constructs the web server
+ */
+ public WebServer()
+ {
+ this.server = null;
+ this.host = "localhost";
+ this.port = 8080;
+ this.executorService = null;
+ }
+
+ /**
+ * Get the web server
+ * @return The server
+ */
+ public Server getServer()
+ {
+ return server;
+ }
+
+ /**
+ * Get the host
+ * @return The host
+ */
+ public String getHost()
+ {
+ return host;
+ }
+
+ /**
+ * Set the host
+ * @param host The host
+ */
+ public void setHost(String host)
+ {
+ this.host = host;
+ }
+
+ /**
+ * Get the web server port
+ * @return The port
+ */
+ public int getPort()
+ {
+ return port;
+ }
+
+ /**
+ * Set the web server port
+ * @param port The port
+ */
+ public void setPort(int port)
+ {
+ this.port = port;
+ }
+
+ /**
+ * Set the executor service
+ * @param service The service
+ */
+ public void setExecutorService(ExecutorService service)
+ {
+ this.executorService = service;
+ }
+
+ /**
+ * Start
+ * @exception Throwable If an error occurs
+ */
+ public void start() throws Throwable
+ {
+ stop();
+
+ server = new Server();
+
+ Connector connector = new SocketConnector();
+ connector.setHost(host);
+ connector.setPort(port);
+
+ server.setConnectors(new Connector[]{connector});
+
+ server.start();
+
+ log.info("Jetty " + Server.getVersion() + " started");
+ }
+
+ /**
+ * Stop
+ * @exception Throwable If an error occurs
+ */
+ public void stop() throws Throwable
+ {
+ if (server != null && server.isRunning())
+ {
+ server.stop();
+
+ log.info("Jetty " + Server.getVersion() + " stopped");
+ }
+ }
+}
Added: projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/AttrResultInfo.java
===================================================================
--- projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/AttrResultInfo.java (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/AttrResultInfo.java 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.jca.web.console;
+
+import java.beans.PropertyEditor;
+
+/**
+ * A simple tuple of an mbean operation name, sigature and result.
+ * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class AttrResultInfo
+{
+ /** The name */
+ private String name;
+
+ /** The editor */
+ private PropertyEditor editor;
+
+ /** The result */
+ private Object result;
+
+ /** The error */
+ private Throwable throwable;
+
+ /**
+ * Constructor
+ * @param name The name
+ * @param editor The editor
+ * @param result The result
+ * @param throwable The error
+ */
+ public AttrResultInfo(String name, PropertyEditor editor, Object result, Throwable throwable)
+ {
+ this.name = name;
+ this.editor = editor;
+ this.result = result;
+ this.throwable = throwable;
+ }
+
+ /**
+ * Get the name
+ * @return The value
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Get the editor
+ * @return The value
+ */
+ public PropertyEditor getEditor()
+ {
+ return editor;
+ }
+
+ /**
+ * Get the result
+ * @return The value
+ */
+ public Object getResult()
+ {
+ return result;
+ }
+
+ /**
+ * Get the error
+ * @return The value
+ */
+ public Throwable getError()
+ {
+ return throwable;
+ }
+
+ /**
+ * Get the text representation
+ * @return The string
+ */
+ public String getAsText()
+ {
+ if (throwable != null)
+ return throwable.toString();
+
+ if (result != null)
+ {
+ try
+ {
+ if (editor != null)
+ {
+ editor.setValue(result);
+ return editor.getAsText();
+ }
+ else
+ {
+ return result.toString();
+ }
+ }
+ catch (Exception e)
+ {
+ return "String representation of " + name + "unavailable";
+ }
+ }
+
+ return null;
+ }
+}
Added: projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/DomainData.java
===================================================================
--- projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/DomainData.java (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/DomainData.java 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.jca.web.console;
+
+import java.util.Arrays;
+import java.util.TreeSet;
+
+/**
+ * The MBeanData for a given JMX domain name
+ *
+ * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class DomainData
+{
+ private String domainName;
+ private TreeSet<MBeanData> domainData;
+
+ /**
+ * Constructor
+ * @param domainName The domain name
+ */
+ public DomainData(String domainName)
+ {
+ this.domainName = domainName;
+ this.domainData = new TreeSet<MBeanData>();
+ }
+
+ /**
+ * Constructor
+ * @param domainName The domain name
+ * @param data The MBean data
+ */
+ public DomainData(String domainName, MBeanData[] data)
+ {
+ this(domainName);
+
+ domainData.addAll(Arrays.asList(data));
+ }
+
+ /**
+ * Get the domain name
+ * @return The name
+ */
+ public String getDomainName()
+ {
+ return domainName;
+ }
+
+ /**
+ * Get the data
+ * @return The data
+ */
+ public MBeanData[] getData()
+ {
+ MBeanData[] data = new MBeanData[domainData.size()];
+ domainData.toArray(data);
+ return data;
+ }
+
+ /**
+ * Add data
+ * @param data The MBean data entry
+ */
+ public void addData(MBeanData data)
+ {
+ domainData.add(data);
+ }
+
+ /**
+ * Hash code
+ * @return The hash
+ */
+ public int hashCode()
+ {
+ return domainName.hashCode();
+ }
+
+ /**
+ * Equals
+ * @param obj The other object
+ * @return True if the two object are equal; otherwise false
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj == null || (!(obj instanceof DomainData)))
+ return false;
+
+ if (this == obj)
+ return true;
+
+ DomainData data = (DomainData)obj;
+ return domainName.equals(data.domainName);
+ }
+}
Added: projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/HtmlAdaptorServlet.java
===================================================================
--- projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/HtmlAdaptorServlet.java (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/HtmlAdaptorServlet.java 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,447 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.jca.web.console;
+
+import java.io.IOException;
+import java.net.URLDecoder;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.management.AttributeList;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.logging.Logger;
+
+/**
+ * The HTML adaptor controller servlet.
+ *
+ * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class HtmlAdaptorServlet extends HttpServlet
+{
+ private static final long serialVersionUID = 1L;
+
+ private static Logger log = Logger.getLogger(HtmlAdaptorServlet.class);
+ private static boolean trace = log.isTraceEnabled();
+
+ private static final String ACTION_PARAM = "action";
+ private static final String DISPLAY_MBEANS_ACTION = "displayMBeans";
+ private static final String INSPECT_MBEAN_ACTION = "inspectMBean";
+ private static final String UPDATE_ATTRIBUTES_ACTION = "updateAttributes";
+ private static final String INVOKE_OP_ACTION = "invokeOp";
+ private static final String INVOKE_OP_BY_NAME_ACTION = "invokeOpByName";
+
+ /**
+ * Constructor
+ */
+ public HtmlAdaptorServlet()
+ {
+ }
+
+ /**
+ * Init
+ * @param config The servlet configuration
+ * @exception ServletException Thrown if an error occurs
+ */
+ public void init(ServletConfig config) throws ServletException
+ {
+ super.init(config);
+ }
+
+ /**
+ * Destroy
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * GET
+ * @param request The HTTP request
+ * @param response The HTTP response
+ * @exception ServletException Thrown if an error occurs
+ * @exception IOException Thrown if an I/O error occurs
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ processRequest(request, response);
+ }
+
+ /**
+ * POST
+ * @param request The HTTP request
+ * @param response The HTTP response
+ * @exception ServletException Thrown if an error occurs
+ * @exception IOException Thrown if an I/O error occurs
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ processRequest(request, response);
+ }
+
+ /**
+ * Process the request
+ * @param request The HTTP request
+ * @param response The HTTP response
+ * @exception ServletException Thrown if an error occurs
+ * @exception IOException Thrown if an I/O error occurs
+ */
+ protected void processRequest(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ String action = request.getParameter(ACTION_PARAM);
+
+ if (action == null)
+ action = DISPLAY_MBEANS_ACTION;
+
+ if (action.equals(DISPLAY_MBEANS_ACTION))
+ displayMBeans(request, response);
+ else if (action.equals(INSPECT_MBEAN_ACTION))
+ inspectMBean(request, response);
+ else if (action.equals(UPDATE_ATTRIBUTES_ACTION))
+ updateAttributes(request, response);
+ else if (action.equals(INVOKE_OP_ACTION))
+ invokeOp(request, response);
+ else if (action.equals(INVOKE_OP_BY_NAME_ACTION))
+ invokeOpByName(request, response);
+ }
+
+ /**
+ * Display all MBeans
+ * @param request The HTTP request
+ * @param response The HTTP response
+ * @exception ServletException Thrown if an error occurs
+ * @exception IOException Thrown if an I/O error occurs
+ */
+ private void displayMBeans(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ Iterator mbeans;
+
+ try
+ {
+ mbeans = getDomainData();
+ }
+ catch (Exception e)
+ {
+ throw new ServletException("Failed to get MBeans", e);
+ }
+
+ request.setAttribute("mbeans", mbeans);
+ RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/displaymbeans.jsp");
+ rd.forward(request, response);
+ }
+
+ /**
+ * Display a MBeans attributes and operations
+ * @param request The HTTP request
+ * @param response The HTTP response
+ * @exception ServletException Thrown if an error occurs
+ * @exception IOException Thrown if an I/O error occurs
+ */
+ private void inspectMBean(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ String name = request.getParameter("name");
+
+ if (trace)
+ log.trace("inspectMBean, name=" + name);
+
+ try
+ {
+ MBeanData data = getMBeanData(name);
+ request.setAttribute("mbeanData", data);
+
+ RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/inspectmbean.jsp");
+ rd.forward(request, response);
+ }
+ catch (Exception e)
+ {
+ throw new ServletException("Failed to get MBean data", e);
+ }
+ }
+
+ /**
+ * Update the writable attributes of a MBean
+ * @param request The HTTP request
+ * @param response The HTTP response
+ * @exception ServletException Thrown if an error occurs
+ * @exception IOException Thrown if an I/O error occurs
+ */
+ private void updateAttributes(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ String name = request.getParameter("name");
+
+ if (trace)
+ log.trace("updateAttributes, name=" + name);
+
+ Enumeration paramNames = request.getParameterNames();
+ HashMap<String, String> attributes = new HashMap<String, String>();
+
+ while (paramNames.hasMoreElements())
+ {
+ String param = (String)paramNames.nextElement();
+
+ if (param.equals("name") || param.equals("action"))
+ continue;
+
+ String value = request.getParameter(param);
+
+ if (trace)
+ log.trace("name=" + param + ", value='" + value + "'");
+
+ // Ignore null values, these are empty write-only fields
+ if (value == null || value.length() == 0)
+ continue;
+
+ attributes.put(param, value);
+ }
+
+ try
+ {
+ AttributeList newAttributes = setAttributes(name, attributes);
+ MBeanData data = getMBeanData(name);
+ request.setAttribute("mbeanData", data);
+
+ RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/inspectmbean.jsp");
+ rd.forward(request, response);
+ }
+ catch (Exception e)
+ {
+ throw new ServletException("Failed to update attributes", e);
+ }
+ }
+
+ /**
+ * Invoke a MBean operation given the index into the MBeanOperationInfo{}
+ * array of the mbean.
+ * @param request The HTTP request
+ * @param response The HTTP response
+ * @exception ServletException Thrown if an error occurs
+ * @exception IOException Thrown if an I/O error occurs
+ */
+ private void invokeOp(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ String reqname = request.getParameter("name");
+
+ String name = URLDecoder.decode(reqname, "UTF-8");
+
+ if (trace)
+ log.trace("invokeOp, name=" + name);
+
+ String[] args = getArgs(request);
+ String methodIndex = request.getParameter("methodIndex");
+
+ if (methodIndex == null || methodIndex.length() == 0)
+ throw new ServletException("No methodIndex given in invokeOp form");
+
+ int index = Integer.parseInt(methodIndex);
+ try
+ {
+ OpResultInfo opResult = invokeOp(name, index, args);
+ request.setAttribute("opResultInfo", opResult);
+
+ RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/displayopresult.jsp");
+ rd.forward(request, response);
+ }
+ catch (Exception e)
+ {
+ throw new ServletException("Failed to invoke operation", e);
+ }
+ }
+
+ /**
+ * Invoke a MBean operation given the method name and its signature.
+ * @param request The HTTP request
+ * @param response The HTTP response
+ * @exception ServletException Thrown if an error occurs
+ * @exception IOException Thrown if an I/O error occurs
+ */
+ private void invokeOpByName(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ String name = request.getParameter("name");
+
+ if (trace)
+ log.trace("invokeOpByName, name=" + name);
+
+ String[] argTypes = request.getParameterValues("argType");
+ String[] args = getArgs(request);
+ String methodName = request.getParameter("methodName");
+
+ if (methodName == null)
+ throw new ServletException("No methodName given in invokeOpByName form");
+
+ try
+ {
+ OpResultInfo opResult = invokeOpByName(name, methodName, argTypes, args);
+ request.setAttribute("opResultInfo", opResult);
+
+ RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/displayopresult.jsp");
+ rd.forward(request, response);
+ }
+ catch (Exception e)
+ {
+ throw new ServletException("Failed to invoke operation", e);
+ }
+ }
+
+ /**
+ * Extract the argN values from the request into a String[]
+ * @param request The HTTP request
+ * @return The argument values
+ */
+ private String[] getArgs(HttpServletRequest request)
+ {
+ ArrayList<String> argList = new ArrayList<String>();
+
+ for (int i = 0; true; i++)
+ {
+ String name = "arg" + i;
+ String value = request.getParameter(name);
+
+ if (value == null)
+ break;
+
+ argList.add(value);
+
+ if (trace)
+ log.trace(name + "=" + value);
+ }
+
+ String[] args = new String[argList.size()];
+ argList.toArray(args);
+ return args;
+ }
+
+ /**
+ * Get the MBean data for a bean
+ * @param name The name of the bean
+ * @return The data
+ * @exception PrivilegedExceptionAction Thrown if the operation cannot be performed
+ */
+ private MBeanData getMBeanData(final String name) throws PrivilegedActionException
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<MBeanData>()
+ {
+ public MBeanData run() throws Exception
+ {
+ return Server.getMBeanData(name);
+ }
+ });
+ }
+
+ /**
+ * Get the domain data
+ * @return A data iterator
+ * @exception PrivilegedExceptionAction Thrown if the operation cannot be performed
+ */
+ @SuppressWarnings("unchecked")
+ private Iterator getDomainData() throws PrivilegedActionException
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Iterator>()
+ {
+ public Iterator run() throws Exception
+ {
+ return Server.getDomainData();
+ }
+ });
+ }
+
+ /**
+ * Invoke an operation on a MBean
+ * @param name The name of the bean
+ * @param index The operation index
+ * @param args The operation arguments
+ * @return The operation result
+ * @exception PrivilegedExceptionAction Thrown if the operation cannot be performed
+ */
+ private OpResultInfo invokeOp(final String name, final int index, final String[] args)
+ throws PrivilegedActionException
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<OpResultInfo>()
+ {
+ public OpResultInfo run() throws Exception
+ {
+ return Server.invokeOp(name, index, args);
+ }
+ });
+ }
+
+ /**
+ * Invoke an operation on a MBean
+ * @param name The name of the bean
+ * @param methodName The operation name
+ * @param argTypes The argument types
+ * @param args The operation arguments
+ * @return The operation result
+ * @exception PrivilegedExceptionAction Thrown if the operation cannot be performed
+ */
+ private OpResultInfo invokeOpByName(final String name,
+ final String methodName,
+ final String[] argTypes,
+ final String[] args)
+ throws PrivilegedActionException
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<OpResultInfo>()
+ {
+ public OpResultInfo run() throws Exception
+ {
+ return Server.invokeOpByName(name, methodName, argTypes, args);
+ }
+ });
+ }
+
+ /**
+ * Set attributes on a MBean
+ * @param name The name of the bean
+ * @param attributes The attributes
+ * @return The updated attributes list
+ * @exception PrivilegedExceptionAction Thrown if the operation cannot be performed
+ */
+ @SuppressWarnings({ "unchecked" })
+ private AttributeList setAttributes(final String name, final HashMap attributes) throws PrivilegedActionException
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<AttributeList>()
+ {
+ public AttributeList run() throws Exception
+ {
+ return Server.setAttributes(name, attributes);
+ }
+ });
+ }
+}
Added: projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/MBeanData.java
===================================================================
--- projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/MBeanData.java (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/MBeanData.java 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,166 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.jca.web.console;
+
+import javax.management.MBeanInfo;
+import javax.management.ObjectName;
+
+/**
+ * A MBean ObjectName and MBeanInfo pair that is orderable by ObjectName.
+ *
+ * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class MBeanData implements Comparable
+{
+ private ObjectName objectName;
+ private MBeanInfo metaData;
+
+ /**
+ * Constructor
+ */
+ public MBeanData()
+ {
+ }
+
+ /**
+ * Constructor
+ * @param objectName The object name
+ * @param metaData The metadata about the bean
+ */
+ public MBeanData(ObjectName objectName, MBeanInfo metaData)
+ {
+ this.objectName = objectName;
+ this.metaData = metaData;
+ }
+
+ /**
+ * Get the object name
+ * @return The name
+ */
+ public ObjectName getObjectName()
+ {
+ return objectName;
+ }
+
+ /**
+ * Set the object name
+ * @param objectName The new value
+ */
+ public void setObjectName(ObjectName objectName)
+ {
+ this.objectName = objectName;
+ }
+
+ /**
+ * Get the metadata
+ * @return The data
+ */
+ public MBeanInfo getMetaData()
+ {
+ return metaData;
+ }
+
+ /**
+ * Set the metadata
+ * @param metaData The new value
+ */
+ public void setMetaData(MBeanInfo metaData)
+ {
+ this.metaData = metaData;
+ }
+
+ /**
+ * Get the string repsentation of the object name
+ * @return The string
+ */
+ public String getName()
+ {
+ return objectName.toString();
+ }
+
+ /**
+ * Get the key propertues listing
+ * @return The keys
+ */
+ public String getNameProperties()
+ {
+ return objectName.getCanonicalKeyPropertyListString();
+ }
+
+ /**
+ * Get the class name
+ * @return The class name
+ */
+ public String getClassName()
+ {
+ return metaData.getClassName();
+ }
+
+ /**
+ * Compares MBeanData based on the ObjectName domain name and canonical
+ * key properties
+ *
+ * @param o the MBeanData to compare against
+ * @return < 0 if this is less than o, > 0 if this is greater than o,
+ * 0 if equal.
+ */
+ public int compareTo(Object o)
+ {
+ MBeanData md = (MBeanData) o;
+ String d1 = objectName.getDomain();
+ String d2 = md.objectName.getDomain();
+ int compare = d1.compareTo(d2);
+ if (compare == 0)
+ {
+ String p1 = objectName.getCanonicalKeyPropertyListString();
+ String p2 = md.objectName.getCanonicalKeyPropertyListString();
+ compare = p1.compareTo(p2);
+ }
+ return compare;
+ }
+
+ /**
+ * Hash code
+ * @return The hash
+ */
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ /**
+ * Equals
+ * @param o The other object
+ * @return True if the two object are equal; otherwise false
+ */
+ public boolean equals(Object o)
+ {
+ if (o == null || (!(o instanceof MBeanData)))
+ return false;
+
+ if (this == o)
+ return true;
+
+ return (this.compareTo(o) == 0);
+ }
+}
Added: projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/OpResultInfo.java
===================================================================
--- projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/OpResultInfo.java (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/OpResultInfo.java 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.jca.web.console;
+
+/**
+ * A simple tuple of a MBean operation name,
+ * index, signature, args and operation result.
+ *
+ * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class OpResultInfo
+{
+ /** Operation name */
+ private String name;
+
+ /** Operation signature */
+ private String[] signature;
+
+ /** Arguments */
+ private String[] args;
+
+ /** The result */
+ private Object result;
+
+ /**
+ * Constructor
+ */
+ public OpResultInfo()
+ {
+ }
+
+ /**
+ * Constructor
+ * @param name The name
+ * @param signature The signature
+ * @param args The arguments
+ * @param result The result
+ */
+ public OpResultInfo(String name, String[] signature, String[] args, Object result)
+ {
+ this.name = name;
+ this.signature = signature;
+ this.args = args;
+ this.result = result;
+ }
+
+ /**
+ * Get the name
+ * @return The value
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Get the signature
+ * @return The value
+ */
+ public String[] getSignature()
+ {
+ return signature;
+ }
+
+ /**
+ * Get the arguments
+ * @return The value
+ */
+ public String[] getArguments()
+ {
+ return args;
+ }
+
+ /**
+ * Get the result
+ * @return The value
+ */
+ public Object getResult()
+ {
+ return result;
+ }
+}
Added: projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/SecurityActions.java
===================================================================
--- projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/SecurityActions.java (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/SecurityActions.java 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.web.console;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Privileged Blocks
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+class SecurityActions
+{
+ /**
+ * Constructor
+ */
+ private SecurityActions()
+ {
+ }
+
+ /**
+ * Get the thread context class loader
+ * @return The class loader
+ */
+ static ClassLoader getThreadContextClassLoader()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+}
Added: projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/Server.java
===================================================================
--- projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/Server.java (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/Server.java 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,376 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.jca.web.console;
+
+import java.beans.IntrospectionException;
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeMap;
+
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.JMException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.Classes;
+import org.jboss.util.propertyeditor.PropertyEditors;
+
+/**
+ * Utility methods related to the MBeanServer interface
+ * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class Server
+{
+ private static Logger log = Logger.getLogger(Server.class);
+ private static boolean trace = log.isTraceEnabled();
+
+ private static final String DOMAIN = "jboss.jca";
+
+ private static MBeanServer mbeanServer = null;
+
+ /**
+ * Get the MBeanServer instance
+ * @return The instance
+ */
+ public static MBeanServer getMBeanServer()
+ {
+ if (mbeanServer != null)
+ return mbeanServer;
+
+ try
+ {
+ ArrayList<MBeanServer> l = MBeanServerFactory.findMBeanServer(null);
+
+ if (l != null)
+ {
+ for (MBeanServer ms : l)
+ {
+ String[] domains = ms.getDomains();
+
+ if (domains != null)
+ {
+ for (String d : domains)
+ {
+ if (DOMAIN.equals(d))
+ {
+ mbeanServer = ms;
+ return ms;
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (SecurityException se)
+ {
+ // Ignore
+ }
+
+ return null;
+ }
+
+ /**
+ * Get the domain data
+ * @return The data iterator
+ * @exception JMException Thrown if an error occurs
+ */
+ public static Iterator getDomainData() throws JMException
+ {
+ MBeanServer server = getMBeanServer();
+ TreeMap<String, DomainData> domainData = new TreeMap<String, DomainData>();
+
+ if (server != null)
+ {
+ Set objectNames = server.queryNames(null, null);
+ Iterator objectNamesIter = objectNames.iterator();
+
+ while (objectNamesIter.hasNext())
+ {
+ ObjectName name = (ObjectName)objectNamesIter.next();
+ MBeanInfo info = server.getMBeanInfo(name);
+ String domainName = name.getDomain();
+ MBeanData mbeanData = new MBeanData(name, info);
+ DomainData data = domainData.get(domainName);
+
+ if (data == null)
+ {
+ data = new DomainData(domainName);
+ domainData.put(domainName, data);
+ }
+
+ data.addData(mbeanData);
+ }
+ }
+
+ return domainData.values().iterator();
+ }
+
+ /**
+ * Get MBean data
+ * @param name The bean name
+ * @return The data
+ * @exception JMException Thrown if an error occurs
+ */
+ public static MBeanData getMBeanData(String name) throws JMException
+ {
+ MBeanServer server = getMBeanServer();
+ ObjectName objName = new ObjectName(name);
+ MBeanInfo info = server.getMBeanInfo(objName);
+
+ return new MBeanData(objName, info);
+ }
+
+ /**
+ * Get MBean attribute object
+ * @param name The bean name
+ * @param attrName The attribute name
+ * @return The data
+ * @exception JMException Thrown if an error occurs
+ */
+ public static Object getMBeanAttributeObject(String name, String attrName) throws JMException
+ {
+ MBeanServer server = getMBeanServer();
+ ObjectName objName = new ObjectName(name);
+
+ return server.getAttribute(objName, attrName);
+ }
+
+ /**
+ * Get MBean attribute
+ * @param name The bean name
+ * @param attrName The attribute name
+ * @return The data
+ * @exception JMException Thrown if an error occurs
+ */
+ public static String getMBeanAttribute(String name, String attrName) throws JMException
+ {
+ MBeanServer server = getMBeanServer();
+ ObjectName objName = new ObjectName(name);
+
+ String value = null;
+ try
+ {
+ Object attr = server.getAttribute(objName, attrName);
+ if (attr != null)
+ value = attr.toString();
+ }
+ catch (JMException e)
+ {
+ value = e.getMessage();
+ }
+ return value;
+ }
+
+ /**
+ * Get MBean attribute result info
+ * @param name The bean name
+ * @param attrInfo The attribute information
+ * @return The data
+ * @exception JMException Thrown if an error occurs
+ */
+ public static AttrResultInfo getMBeanAttributeResultInfo(String name, MBeanAttributeInfo attrInfo)
+ throws JMException
+ {
+ ClassLoader loader = SecurityActions.getThreadContextClassLoader();
+ MBeanServer server = getMBeanServer();
+ ObjectName objName = new ObjectName(name);
+ String attrName = attrInfo.getName();
+ String attrType = attrInfo.getType();
+ Object value = null;
+ Throwable throwable = null;
+
+ if (attrInfo.isReadable())
+ {
+ try
+ {
+ value = server.getAttribute(objName, attrName);
+ }
+ catch (Throwable t)
+ {
+ throwable = t;
+ }
+ }
+
+ Class typeClass = null;
+ try
+ {
+ typeClass = Classes.getPrimitiveTypeForName(attrType);
+ if (typeClass == null)
+ typeClass = loader.loadClass(attrType);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ // Ignore
+ }
+
+ PropertyEditor editor = null;
+ if (typeClass != null)
+ editor = PropertyEditorManager.findEditor(typeClass);
+
+ return new AttrResultInfo(attrName, editor, value, throwable);
+ }
+
+ /**
+ * Set MBean attributes
+ * @param name The bean name
+ * @param attributes The attributes
+ * @return The updated attribute list
+ * @exception JMException Thrown if an error occurs
+ */
+ public static AttributeList setAttributes(String name, HashMap attributes) throws JMException
+ {
+ MBeanServer server = getMBeanServer();
+ ObjectName objName = new ObjectName(name);
+ MBeanInfo info = server.getMBeanInfo(objName);
+ MBeanAttributeInfo[] attributesInfo = info.getAttributes();
+ AttributeList newAttributes = new AttributeList();
+
+ for (int a = 0; a < attributesInfo.length; a++)
+ {
+ MBeanAttributeInfo attrInfo = attributesInfo[a];
+ String attrName = attrInfo.getName();
+
+ if (!attributes.containsKey(attrName))
+ continue;
+
+ String value = (String) attributes.get(attrName);
+ if (value.equals("null") && server.getAttribute(objName, attrName) == null)
+ {
+ if (trace)
+ log.trace("ignoring 'null' for " + attrName);
+ continue;
+ }
+
+ String attrType = attrInfo.getType();
+ Attribute attr = null;
+ try
+ {
+ Object realValue = PropertyEditors.convertValue(value, attrType);
+ attr = new Attribute(attrName, realValue);
+ }
+ catch (ClassNotFoundException e)
+ {
+ String s = (attr != null) ? attr.getName() : attrType;
+ if (trace)
+ log.trace("Failed to load class for attribute: " + s, e);
+ throw new ReflectionException(e, "Failed to load class for attribute: " + s);
+ }
+ catch (IntrospectionException e)
+ {
+ if (trace)
+ log.trace("Skipped setting attribute: " + attrName +
+ ", cannot find PropertyEditor for type: " + attrType);
+ continue;
+ }
+
+ server.setAttribute(objName, attr);
+ newAttributes.add(attr);
+ }
+
+ return newAttributes;
+ }
+
+ /**
+ * Invoke an operation
+ * @param name The bean name
+ * @param index The method index
+ * @param args The arguments
+ * @return The result
+ * @exception JMException Thrown if an error occurs
+ */
+ public static OpResultInfo invokeOp(String name, int index, String[] args) throws JMException
+ {
+ MBeanServer server = getMBeanServer();
+ ObjectName objName = new ObjectName(name);
+ MBeanInfo info = server.getMBeanInfo(objName);
+ MBeanOperationInfo[] opInfo = info.getOperations();
+ MBeanOperationInfo op = opInfo[index];
+ MBeanParameterInfo[] paramInfo = op.getSignature();
+ String[] argTypes = new String[paramInfo.length];
+
+ for (int p = 0; p < paramInfo.length; p++)
+ argTypes[p] = paramInfo[p].getType();
+
+ return invokeOpByName(name, op.getName(), argTypes, args);
+ }
+
+ /**
+ * Invoke an operation by name
+ * @param name The bean name
+ * @param opName The operation name
+ * @param argTypes The argument types
+ * @param args The arguments
+ * @return The result
+ * @exception JMException Thrown if an error occurs
+ */
+ public static OpResultInfo invokeOpByName(String name, String opName, String[] argTypes, String[] args)
+ throws JMException
+ {
+ MBeanServer server = getMBeanServer();
+ ObjectName objName = new ObjectName(name);
+ int length = argTypes != null ? argTypes.length : 0;
+ Object[] typedArgs = new Object[length];
+
+ for (int p = 0; p < typedArgs.length; p++)
+ {
+ String arg = args[p];
+ try
+ {
+ Object argValue = PropertyEditors.convertValue(arg, argTypes[p]);
+ typedArgs[p] = argValue;
+ }
+ catch (ClassNotFoundException e)
+ {
+ if (trace)
+ log.trace("Failed to load class for arg" + p, e);
+ throw new ReflectionException(e, "Failed to load class for arg" + p);
+ }
+ catch (java.beans.IntrospectionException e)
+ {
+ // If the type is not java.lang.Object throw an exception
+ if (!argTypes[p].equals("java.lang.Object"))
+ throw new javax.management.IntrospectionException("Failed to find PropertyEditor for type: " +
+ argTypes[p]);
+ // Just use the String arg
+ typedArgs[p] = arg;
+ continue;
+ }
+ }
+
+ Object opReturn = server.invoke(objName, opName, typedArgs, argTypes);
+ return new OpResultInfo(opName, argTypes, args, opReturn);
+ }
+}
Added: projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/package.html
===================================================================
--- projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/package.html (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/console/package.html 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,3 @@
+<body>
+This package contains the classes needed for the management web console for JBoss JCA
+</body>
Added: projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/package.html
===================================================================
--- projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/package.html (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/java/org/jboss/jca/web/package.html 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,3 @@
+<body>
+This package contains a web server integration layer.
+</body>
Added: projects/jboss-jca/trunk/web/src/main/resources/console/WEB-INF/web.xml
===================================================================
--- projects/jboss-jca/trunk/web/src/main/resources/console/WEB-INF/web.xml (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/resources/console/WEB-INF/web.xml 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<web-app version="2.5"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <description>The JBoss JCA Management Console</description>
+
+ <servlet>
+ <servlet-name>HtmlAdaptor</servlet-name>
+ <servlet-class>org.jboss.jca.web.console.HtmlAdaptorServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>HtmlAdaptor</servlet-name>
+ <url-pattern>/HtmlAdaptor</url-pattern>
+ </servlet-mapping>
+
+ <error-page>
+ <error-code>500</error-code>
+ <location>/error.jsp</location>
+ </error-page>
+
+</web-app>
Added: projects/jboss-jca/trunk/web/src/main/resources/console/displaymbeans.jsp
===================================================================
--- projects/jboss-jca/trunk/web/src/main/resources/console/displaymbeans.jsp (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/resources/console/displaymbeans.jsp 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,80 @@
+<?xml version="1.0"?>
+<%@page contentType="text/html" import="java.io.*,java.net.*,java.util.*,org.jboss.jca.web.console.*"%>
+
+<%!
+
+ /**
+ * Translate HTML tags and single and double quotes.
+ */
+ public String translateMetaCharacters(Object value)
+ {
+ if(value == null)
+ return null;
+
+ String s = String.valueOf(value);
+ String sanitizedName = s.replace("<", "<");
+ sanitizedName = sanitizedName.replace(">", ">");
+ sanitizedName = sanitizedName.replace("\"", """);
+ sanitizedName = sanitizedName.replace("\'", "'");
+ return sanitizedName;
+ }
+%>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+ <title>JBoss JCA Management Console</title>
+ <link rel="stylesheet" href="jboss.css" type="text/css" />
+ <meta http-equiv="cache-control" content="no-cache"/>
+</head>
+
+<body>
+
+ <table>
+ <tr>
+ <td height="105" align="left"><h1>JBoss JCA Management Console</h1></td>
+ </tr>
+ </table>
+
+
+
+<%
+ out.println("<table>");
+ Iterator mbeans = (Iterator) request.getAttribute("mbeans");
+ int i = 0;
+ while( mbeans.hasNext() )
+ {
+ DomainData domainData = (DomainData) mbeans.next();
+ out.println(" <tr>");
+ out.println(" <th>");
+ out.println(" <h2>" + domainData.getDomainName() + "</h2>");
+ out.println(" </th>");
+ out.println(" </tr>");
+ out.println(" <tr>");
+ out.println(" <td>");
+ out.println(" <ul>");
+ MBeanData[] data = domainData.getData();
+ for (int d = 0; d < data.length; d++)
+ {
+ String name = data[d].getObjectName().toString();
+ String properties = translateMetaCharacters(data[d].getNameProperties());
+ out.println(" <li><a href=\"HtmlAdaptor?action=inspectMBean&name=" + URLEncoder.encode(name, "UTF-8") + "\">"+URLDecoder.decode(properties, "UTF-8")+"</a></li>");
+ }
+ out.println(" </ul>");
+ out.println(" </td>");
+ out.println(" </tr>");
+ }
+ out.println("</table>");
+%>
+
+ <table width="100%" class="copyright">
+ <tr>
+ <td class="copyright">
+ Copyright © 2009 <a href="http://www.jboss.org/jca" target="_blank">JBoss, by Red Hat</a>
+ </td>
+ </tr>
+ </table>
+
+
+</body>
+</html>
Added: projects/jboss-jca/trunk/web/src/main/resources/console/displayopresult.jsp
===================================================================
--- projects/jboss-jca/trunk/web/src/main/resources/console/displayopresult.jsp (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/resources/console/displayopresult.jsp 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,103 @@
+<?xml version="1.0"?>
+<%@page contentType="text/html"
+ import="java.net.*,
+ java.io.*,
+ java.beans.PropertyEditor,
+ org.jboss.util.propertyeditor.PropertyEditors"
+%>
+
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+<head>
+ <title>JBoss JCA Management Console</title>
+ <link rel="stylesheet" href="jboss.css" type="text/css" />
+ <meta http-equiv="cache-control" content="no-cache" />
+</head>
+
+<jsp:useBean id='opResultInfo' class='org.jboss.jca.web.console.OpResultInfo' type='org.jboss.jca.web.console.OpResultInfo' scope='request'/>
+<%
+ if (opResultInfo.getName() == null)
+ {
+%>
+ <jsp:forward page="/" />
+
+<%
+ }
+%>
+<body leftmargin="10" rightmargin="10" topmargin="10">
+
+<table>
+ <tr>
+ <td height="105" align="left"><h1>JBoss JCA Management Console</h1></td>
+ <td height="105" align="right" width="300">
+ <p>
+ <input type="button" value="Back to Agent" onClick="javascript:location='HtmlAdaptor?action=displayMBeans'"/>
+ </p>
+ <p>
+ <input type="button" value="Back to MBean" onClick="javascript:location='HtmlAdaptor?action=inspectMBean&name=<%= request.getParameter("name") %>'"/>
+ </p>
+ <p>
+ <%
+ out.print("<input type='button' onClick=\"location='HtmlAdaptor?action=invokeOpByName");
+ out.print("&name=" + request.getParameter("name"));
+ out.print("&methodName=" + opResultInfo.getName());
+
+ for (int i = 0; i < opResultInfo.getArguments().length; i++)
+ {
+ out.print("&argType=" + opResultInfo.getSignature()[i]);
+ out.print("&arg" + i + "=" + opResultInfo.getArguments()[i]);
+ }
+
+ out.println("'\" value='Reinvoke MBean Operation'/>");
+ %>
+ </p>
+ </td>
+ </tr>
+</table>
+
+<p>
+<%
+ if (opResultInfo.getResult() == null)
+ {
+ out.println("Operation completed successfully without a return value!");
+ }
+ else
+ {
+ String opResultString = null;
+
+ PropertyEditor propertyEditor = PropertyEditors.findEditor(opResultInfo.getResult().getClass());
+ if (propertyEditor != null)
+ {
+ propertyEditor.setValue(opResultInfo.getResult());
+ opResultString = propertyEditor.getAsText();
+ }
+ else
+ {
+ opResultString = opResultInfo.getResult().toString();
+ }
+
+ boolean hasPreTag = opResultString.startsWith("<pre>");
+ if (!hasPreTag)
+ out.println("<pre>");
+
+ out.println(opResultString);
+
+ if (!hasPreTag)
+ out.println("</pre>");
+ }
+%>
+</p>
+
+ <table width="100%" class="copyright">
+ <tr>
+ <td class="copyright">
+ Copyright © 2009 <a href="http://www.jboss.org/jca" target="_blank">JBoss, by Red Hat</a>
+ </td>
+ </tr>
+ </table>
+
+</body>
+</html>
Added: projects/jboss-jca/trunk/web/src/main/resources/console/error.jsp
===================================================================
--- projects/jboss-jca/trunk/web/src/main/resources/console/error.jsp (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/resources/console/error.jsp 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,31 @@
+<%-- A simple error page. --%>
+
+<%@ page isErrorPage="true" %>
+
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+ <head>
+ <title>JBoss JCA Management Console</title>
+ <link rel="stylesheet" href="jboss.css" type="text/css" />
+ <meta http-equiv="cache-control" content="no-cache" />
+ </head>
+ <body>
+ <h1>Error</h1>
+ <hr size=\"1\" noshade=\"noshade\">
+ <span class="errorText">An error has occurred.</span>
+ <hr size=\"1\" noshade=\"noshade\">
+
+ <table width="100%" class="copyright">
+ <tr>
+ <td class="copyright">
+ Copyright © 2009 <a href="http://www.jboss.org/jca" target="_blank">JBoss, by Red Hat</a>
+ </td>
+ </tr>
+ </table>
+
+ </body>
+</html>
+
Added: projects/jboss-jca/trunk/web/src/main/resources/console/index.jsp
===================================================================
--- projects/jboss-jca/trunk/web/src/main/resources/console/index.jsp (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/resources/console/index.jsp 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<%@page contentType="text/html"%>
+
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <head>
+ <title>JBoss JCA Management Console</title>
+ </head>
+ <frameset>
+ <frame name="ObjectNodeView" src="HtmlAdaptor?action=displayMBeans" scrolling="auto" frameborder="0"/>
+ <noframes>A frames enabled browser is required for the main view</noframes>
+ </frameset>
+</html>
Added: projects/jboss-jca/trunk/web/src/main/resources/console/inspectmbean.jsp
===================================================================
--- projects/jboss-jca/trunk/web/src/main/resources/console/inspectmbean.jsp (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/resources/console/inspectmbean.jsp 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,411 @@
+<?xml version="1.0"?>
+<%@page contentType="text/html"
+ import="java.net.*,java.io.*,java.util.*,javax.management.*,javax.management.modelmbean.*,
+ org.jboss.jca.web.console.*,
+ org.dom4j.io.HTMLWriter,
+ org.dom4j.tree.FlyweightCDATA,
+ java.lang.reflect.Array,
+ java.beans.PropertyEditor,
+ org.jboss.util.propertyeditor.PropertyEditors"
+%>
+
+<%!
+ private static final Comparator MBEAN_FEATURE_INFO_COMPARATOR = new Comparator()
+ {
+ public int compare(Object value1, Object value2)
+ {
+ MBeanFeatureInfo featureInfo1 = (MBeanFeatureInfo) value1;
+ MBeanFeatureInfo featureInfo2 = (MBeanFeatureInfo) value2;
+
+ String name1 = featureInfo1.getName();
+ String name2 = featureInfo2.getName();
+
+ return name1.compareTo(name2);
+ }
+
+ public boolean equals(Object other)
+ {
+ return this == other;
+ }
+ };
+
+ String sep = System.getProperty("line.separator","\n");
+
+ public String fixDescription(String desc)
+ {
+ if (desc == null || desc.equals(""))
+ {
+ return "(no description)";
+ }
+ return desc;
+ }
+
+ public String fixValue(Object value)
+ {
+ if (value == null)
+ return null;
+ String s = String.valueOf(value);
+ StringWriter sw = new StringWriter();
+ HTMLWriter hw = new HTMLWriter(sw);
+ try
+ {
+ // hw.write(s); // strips whitespace
+ hw.write(new FlyweightCDATA(s));
+ s = sw.toString();
+ }
+ catch(Exception e)
+ {
+ }
+ return s;
+ }
+
+ public String fixValueForAttribute(Object value)
+ {
+ if (value == null)
+ return null;
+ String s = String.valueOf(value);
+ StringWriter sw = new StringWriter();
+ HTMLWriter hw = new HTMLWriter(sw);
+ try
+ {
+ hw.write(s);
+ s = sw.toString();
+ }
+ catch(Exception e)
+ {
+ }
+ return s;
+ }
+
+ /**
+ * Translate HTML tags and single and double quotes.
+ */
+ public String translateMetaCharacters(Object value)
+ {
+ if(value == null)
+ return null;
+
+ String s = String.valueOf(value);
+ String sanitizedName = s.replace("<", "<");
+ sanitizedName = sanitizedName.replace(">", ">");
+ sanitizedName = sanitizedName.replace("\"", """);
+ sanitizedName = sanitizedName.replace("\'", "'");
+ return sanitizedName;
+ }
+
+%>
+
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+
+<head>
+ <title>JBoss JCA Management Console</title>
+ <link rel="stylesheet" href="jboss.css" type="text/css" />
+ <meta http-equiv="cache-control" content="no-cache" />
+</head>
+
+<jsp:useBean id='mbeanData' class='org.jboss.jca.web.console.MBeanData' scope='request'/>
+<%
+ if (mbeanData.getObjectName() == null)
+ {
+%>
+<jsp:forward page="/" />
+<%
+ }
+ ObjectName objectName = mbeanData.getObjectName();
+ String objectNameString = mbeanData.getName();
+ String quotedObjectNameString = URLEncoder.encode(mbeanData.getName(), "UTF-8");
+ MBeanInfo mbeanInfo = mbeanData.getMetaData();
+ MBeanAttributeInfo[] attributeInfo = mbeanInfo.getAttributes();
+ MBeanOperationInfo[] operationInfo = mbeanInfo.getOperations();
+
+ //FIXME: Seems to create ArrayIndexOutofBoundsException when uncommented
+ /*Arrays.sort(attributeInfo, MBEAN_FEATURE_INFO_COMPARATOR);
+
+ HashMap operationInfoIndexMap = new HashMap();
+ for (int a = 0; a < operationInfo.length; a++)
+ {
+ MBeanOperationInfo opInfo = operationInfo[a];
+ operationInfoIndexMap.put(opInfo, String.valueOf(a));
+ }
+
+ Arrays.sort(operationInfo, MBEAN_FEATURE_INFO_COMPARATOR);
+ */
+%>
+
+<body leftmargin="10" rightmargin="10" topmargin="10">
+
+<table>
+ <tr>
+ <td height="105" align="left"><h1>JBoss JCA Management Console</h1></td>
+ <td height="105" align="right" width="300" nowrap>
+ <p>
+ <input type="button" value="Back to Agent" onClick="javascript:location='HtmlAdaptor?action=displayMBeans'"/>
+ </p>
+ <p>
+ <input type="button" value="Refresh MBean View" onClick="javascript:location='HtmlAdaptor?action=inspectMBean&name=<%= URLEncoder.encode(request.getParameter("name"),"UTF-8") %>'"/>
+ </p>
+ </td>
+ </tr>
+</table>
+
+
+
+<%
+ boolean odd = true;
+%>
+
+<!-- 1 -->
+
+<table>
+ <tr class='rowodd'><th>ObjectName</th><td colspan="2"><%= objectName %></td></tr>
+ <tr class='roweven'><th>Java Class</th><td colspan="2"><jsp:getProperty name='mbeanData' property='className'/></td></tr>
+ <tr class='rowodd'><th>Description</th><td colspan="2"><%= fixDescription(mbeanInfo.getDescription())%></td></tr>
+</table>
+
+<!-- 2 -->
+<br/>
+<%
+ if (attributeInfo.length > 0) {
+%>
+<form method="post" action="HtmlAdaptor">
+ <input type="hidden" name="action" value="updateAttributes" />
+ <input type="hidden" name="name" value="<%= objectNameString %>" />
+ <table>
+ <tr>
+ <th bgcolor='#d9e0e3'>Attribute Name</th>
+ <th bgcolor='#d9e0e3'>Access</th>
+ <th bgcolor='#d9e0e3'>Type</th>
+ <th bgcolor='#d9e0e3'>Description</th>
+ <th bgcolor='#d9e0e3'>Attribute Value</th>
+ </tr>
+<%
+ odd = true;
+ boolean hasWriteableAttribute=false;
+ for(int a = 0; a < attributeInfo.length; a ++)
+ {
+ MBeanAttributeInfo attrInfo = attributeInfo[a];
+ String attrName = attrInfo.getName();
+ String attrType = attrInfo.getType();
+ AttrResultInfo attrResult = Server.getMBeanAttributeResultInfo(objectNameString, attrInfo);
+ String attrValue = attrResult.getAsText();
+ String access = "";
+ if (attrInfo.isReadable())
+ access += "R";
+ if (attrInfo.isWritable())
+ {
+ access += "W";
+ hasWriteableAttribute = true;
+ }
+ String attrDescription = fixDescription(attrInfo.getDescription());
+ if (odd)
+ {
+ out.println(" <tr class='rowodd'>");
+ }
+ else
+ {
+ out.println(" <tr class='roweven'>");
+ }
+ out.println(" <td>"+attrName+"</td>");
+ out.println(" <td align='center'>"+access+"</td>");
+ out.println(" <td>"+attrType+"</td>");
+ out.println(" <td>"+attrDescription+"</td>");
+ out.println(" <td>");
+ out.println(" <pre>");
+
+ if (attrInfo.isWritable())
+ {
+ String readonly = attrResult.getEditor() == null ? "class='readonly' readonly" : "class='writable'";
+ if (attrType.equals("boolean") || attrType.equals("java.lang.Boolean"))
+ {
+ Boolean value = attrValue == null || "".equals( attrValue ) ? null : Boolean.valueOf(attrValue);
+ String trueChecked = (value == Boolean.TRUE ? "checked" : "");
+ String falseChecked = (value == Boolean.FALSE ? "checked" : "");
+ String naChecked = value == null ? "checked" : "";
+ out.print("<input type='radio' name='"+attrName+"' value='True' "+trueChecked+"/>True");
+ out.print("<input type='radio' name='"+attrName+"' value='False' "+falseChecked+"/>False");
+ // For wrappers, enable a 'null' selection
+ if (attrType.equals("java.lang.Boolean") && PropertyEditors.isNullHandlingEnabled())
+ {
+ out.print("<input type='radio' name='"+attrName+"' value='' "+naChecked+"/>True");
+ }
+ }
+ else if (attrInfo.isReadable())
+ {
+ attrValue = fixValueForAttribute(attrValue);
+ if (String.valueOf(attrValue).indexOf(sep) == -1)
+ {
+ out.print("<input type='text' size='80' name='" + attrName + "' value='" + translateMetaCharacters(attrValue) + "' " + readonly + "/>");
+ }
+ else
+ {
+ out.print("<textarea cols='80' rows='10' type='text' name='" + attrName + "' "+readonly+">" + attrValue + "</textarea>");
+ }
+ }
+ else
+ {
+ out.print("<input type='text' name='" + attrName + "' " + readonly + "/>");
+ }
+ }
+ else
+ {
+ if (attrType.equals("[Ljavax.management.ObjectName;"))
+ {
+ ObjectName[] names = (ObjectName[]) Server.getMBeanAttributeObject(objectNameString, attrName);
+ if (names != null)
+ {
+ for (int i = 0; i < names.length; i++)
+ {
+ out.print("<p align='center'><a href='HtmlAdaptor?action=inspectMBean&name=" + URLEncoder.encode(names[i] + "", "UTF-8") + ">" + names[i] + "</a></p>");
+ }
+ }
+ }
+ else if (attrType.startsWith("["))
+ {
+ Object arrayObject = Server.getMBeanAttributeObject(objectNameString, attrName);
+ if (arrayObject != null)
+ {
+ for (int i = 0; i < Array.getLength(arrayObject); ++i)
+ {
+ out.println(fixValue(Array.get(arrayObject,i)));
+ }
+ }
+ }
+ else
+ {
+ out.print(fixValue(attrValue));
+ }
+ }
+
+ if (attrType.equals("javax.management.ObjectName"))
+ {
+ if (attrValue != null)
+ {
+ out.print("<p align='center'><a href='HtmlAdaptor?action=inspectMBean&name="+URLEncoder.encode(attrValue,"UTF-8")+"'>View MBean</a></p>");
+ }
+ }
+ out.println(" </pre>");
+ out.println(" </td>");
+ out.println(" </tr>");
+ odd = !odd;
+ }
+
+ if (hasWriteableAttribute)
+ {
+ out.println(" <tr><td colspan='4'></td><td><p align='center'><input type='submit' value='Apply Changes'/></p></td></tr>");
+ }
+%>
+ </table>
+</form>
+
+<%
+ }
+%>
+
+<!-- 3 -->
+<br/>
+<%
+if (operationInfo.length > 0)
+{
+ out.println(" <table>");
+ out.println(" <tr>");
+ out.println(" <th bgcolor='#d9e0e3'>Operation</th>");
+ out.println(" <th bgcolor='#d9e0e3'>Return Type</th>");
+ out.println(" <th bgcolor='#d9e0e3'>Description</th>");
+ out.println(" <th bgcolor='#d9e0e3'>Parameters</th>");
+ out.println(" </tr>");
+
+ odd = true;
+ for (int a = 0; a < operationInfo.length; a++)
+ {
+ MBeanOperationInfo opInfo = operationInfo[a];
+ boolean accept = true;
+ if (opInfo instanceof ModelMBeanOperationInfo)
+ {
+ Descriptor desc = ((ModelMBeanOperationInfo)opInfo).getDescriptor();
+ String role = (String)desc.getFieldValue("role");
+ if ("getter".equals(role) || "setter".equals(role))
+ {
+ accept = false;
+ }
+ }
+ if (accept)
+ {
+ MBeanParameterInfo[] sig = opInfo.getSignature();
+ if (odd)
+ {
+ out.println(" <tr class='rowodd'>");
+ }
+ else
+ {
+ out.println(" <tr class='roweven'>");
+ }
+ out.println(" <td>" + opInfo.getName() + "</td>");
+ out.println(" <td>" + opInfo.getReturnType() + "</td>");
+ out.println(" <td>" + fixDescription(opInfo.getDescription()) + "</td>");
+ out.println(" <td align='center'>");
+ out.println(" <form method='post' action='HtmlAdaptor'>");
+ out.println(" <input type='hidden' name='action' value='invokeOp'/>");
+ out.println(" <input type='hidden' name='name' value='" + quotedObjectNameString + "'/>");
+ out.println(" <input type='hidden' name='methodIndex' value='" + a + "'/>");
+
+ if (sig.length > 0)
+ {
+ out.println(" <table>");
+ for (int p = 0; p < sig.length; p++)
+ {
+ MBeanParameterInfo paramInfo = sig[p];
+ String pname = paramInfo.getName();
+ String ptype = paramInfo.getType();
+ if (pname == null || pname.length() == 0 || pname.equals(ptype))
+ {
+ pname = "arg" + p;
+ }
+ String pdesc = fixDescription(paramInfo.getDescription());
+ out.println(" <tr>");
+ out.println(" <td>" + pname + "</td>");
+ out.println(" <td>" + ptype + "</td>");
+ out.println(" <td>" + pdesc + "</td>");
+ out.print(" <td width='50'>");
+ if (ptype.equals("boolean")||ptype.equals("java.lang.Boolean"))
+ {
+ out.print("<input type='radio' name='arg" + p + "' value='True' checked/>True");
+ out.print("<input type='radio' name='arg" + p + "' value='False'/>False");
+ }
+ else
+ {
+ out.print("<input type='text' class='writable' name='arg" + p + "'/>");
+ }
+ out.println("</td>");
+ out.println(" </tr>");
+ }
+ out.println(" </table>");
+ }
+ else
+ {
+ out.println(" [no parameters]<BR>");
+ }
+ out.println(" <input type='submit' value='Invoke'/>");
+ out.println(" </form>");
+ out.println(" </td>");
+ out.println(" </tr>");
+ odd = !odd;
+ }
+ }
+ out.println(" </table>");
+}
+%>
+
+ <table width="100%" class="copyright">
+ <tr>
+ <td class="copyright">
+ Copyright © 2009 <a href="http://www.jboss.org/jca" target="_blank">JBoss, by Red Hat</a>
+ </td>
+ </tr>
+ </table>
+
+</body>
+</html>
Added: projects/jboss-jca/trunk/web/src/main/resources/console/jboss.css
===================================================================
--- projects/jboss-jca/trunk/web/src/main/resources/console/jboss.css (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/resources/console/jboss.css 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,187 @@
+html {
+ height: 100%;
+ min-height: 100%;
+ background-color : #ffffff;
+ color : #454545;
+ border-collapse : collapse;
+ border-style: none;
+ margin : 0px auto;
+ padding: 0px;
+}
+
+body {
+ background-color : #ffffff;
+ color : #454545;
+ margin : 0px auto;
+ text-align : left;
+ font-family : "Lucida Grand", Verdana, Arial, Helvetica, sans-serif;
+ font-size: 10pt;
+ border-collapse : collapse;
+ border-style: none;
+ padding: 5px;
+}
+
+a {
+ color: #527fa8;
+ text-decoration: underline;
+}
+
+hr {
+ border-top: 1px solid #a4b2b9;
+ border-right: 0px solid #a4b2b9;
+ border-left: 0px solid #a4b2b9;
+ border-bottom: 0px solid #a4b2b9;
+ margin-bottom: 3px;
+}
+
+img {
+ border: 0px;
+}
+
+h1 {
+ font-family : "Lucida Grand", Verdana, Arial, Helvetica, sans-serif;
+ font-size : 14pt;
+ font-weight : bold;
+ background-color: white;
+ color: #50667c;
+ padding: 1px;
+}
+
+h2 {
+ font-family : "Lucida Grand", Verdana, Arial, Helvetica, sans-serif;
+ font-size : 12pt;
+ font-weight : bold;
+ background-color: #50667c;
+ color: white;
+ padding: 1px;
+}
+
+h3 {
+ font-family : "Lucida Grand", Verdana, Arial, Helvetica, sans-serif;
+ font-size : 11pt;
+ font-weight : bold;
+ background-color: white;
+ color: #50667c;
+ padding: 1px;
+}
+
+h4 {
+ font-family : "Lucida Grand", Verdana, Arial, Helvetica, sans-serif;
+ font-size : 10pt;
+ font-weight : bold;
+ background-color: white;
+ color: #50667c;
+ padding: 1px;
+}
+
+h5 {
+ font-family : "Lucida Grand", Verdana, Arial, Helvetica, sans-serif;
+ font-size : 10pt;
+ font-weight : bold;
+ background-color: white;
+ color: #50667c;
+ padding: 1px;
+}
+
+h6 {
+ font-family : "Lucida Grand", Verdana, Arial, Helvetica, sans-serif;
+ font-size : 10pt;
+ font-weight : bold;
+ background-color: white;
+ color: #50667c;
+ padding: 1px;
+}
+
+table {
+ width: 100%;
+ border-color: #50667c;
+ border-style: solid;
+ border-collapse : collapse;
+}
+
+tr th {
+ font-size: 10pt;
+ font-weight: bold;
+ color: #5f6a6f;
+ text-align: left;
+ padding: 1px;
+}
+
+tr td {
+ font-size: 10pt;
+ vertical-align: top;
+ text-align: left;
+ padding: 1px;
+}
+
+input {
+ font-family: Tahoma,Verdana,sans-serif;
+ font-size: 8pt;
+}
+
+input.readonly {
+ border: 1px solid #999999;
+ background-color: #C0C0C0;
+}
+
+input.writable {
+ border: 1px solid #999999;
+ background-color: #FFFFFF;
+}
+
+pre {
+ white-space: pre-wrap; /* css-3 */
+ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
+ white-space: -pre-wrap; /* Opera 4-6 */
+ white-space: -o-pre-wrap; /* Opera 7 */
+ word-wrap: break-word; /* Internet Explorer 5.5+ */
+}
+
+* .roweven {
+ background-color: white;
+}
+
+* .rowodd {
+ background-color: #eff4f7;
+}
+
+* .error {
+ font-size: 8pt;
+ color: red;
+}
+
+* .copyright {
+ font-family : "Lucida Grand", Verdana, Arial, Helvetica, sans-serif;
+ font-size: 8pt;
+ text-align : center;
+ color: white;
+ background-color: #50667c;
+ padding : 3px 0px 0px 0px;
+ margin : 0px;
+ vertical-align : bottom;
+}
+
+.copyright a {
+ font-family : "Lucida Grand", Verdana, Arial, Helvetica, sans-serif;
+ font-size: 8pt;
+ text-align : center;
+ color : white;
+ background-color : #50667c;
+ text-decoration : none;
+}
+
+.copyright a:link {
+ color : white;
+ background-color : #50667c;
+}
+
+.copyright a:visited {
+ color : white;
+ background-color : #50667c;
+}
+
+.copyright a:hover {
+ color : white;
+ background-color: #50667c;
+ text-decoration : underline;
+}
Added: projects/jboss-jca/trunk/web/src/main/resources/console-manifest.mf
===================================================================
--- projects/jboss-jca/trunk/web/src/main/resources/console-manifest.mf (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/resources/console-manifest.mf 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,4 @@
+Implementation-Title: JBoss JCA Console
+Implementation-Vendor: Red Hat Middleware LLC
+Implementation-Vendor-Id: org.jboss
+Implementation-Version: 0.1
Added: projects/jboss-jca/trunk/web/src/main/resources/web-manifest.mf
===================================================================
--- projects/jboss-jca/trunk/web/src/main/resources/web-manifest.mf (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/resources/web-manifest.mf 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,4 @@
+Implementation-Title: JBoss JCA Web
+Implementation-Vendor: Red Hat Middleware LLC
+Implementation-Vendor-Id: org.jboss
+Implementation-Version: 0.1
Added: projects/jboss-jca/trunk/web/src/main/resources/web.xml
===================================================================
--- projects/jboss-jca/trunk/web/src/main/resources/web.xml (rev 0)
+++ projects/jboss-jca/trunk/web/src/main/resources/web.xml 2009-11-03 16:37:44 UTC (rev 95967)
@@ -0,0 +1,16 @@
+<deployment>
+
+ <!-- Web Server -->
+ <bean name="WebServer" class="org.jboss.jca.web.WebServer">
+ <property name="host">${jboss.jca.bindaddress:localhost}</property>
+ <property name="port">8080</property>
+ <depends>NamingServer</depends>
+ </bean>
+
+ <!-- WAR deployer -->
+ <bean name="WARDeployer" class="org.jboss.jca.web.WARDeployer">
+ <property name="server"><inject bean="WebServer" property="Server"/></property>
+ <depends>WebServer</depends>
+ </bean>
+
+</deployment>
More information about the jboss-cvs-commits
mailing list