Author: tveronezi
Date: Wed Apr 11 00:38:31 2012
New Revision: 1312055
URL: http://svn.apache.org/viewvc?rev=1312055&view=rev
Log:
https://issues.apache.org/jira/browse/TOMEE-142
(in progress task)
-console view
Added:
openejb/trunk/openejb/tomee/tomee-loader/src/main/java/org/apache/tomee/loader/servlet/ConsoleServlet.java
- copied, changed from r1309327,
openejb/trunk/openejb/tomee/tomee-loader/src/main/java/org/apache/tomee/loader/servlet/JndiServlet.java
openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/viewconsole.jsp
- copied, changed from r1311017,
openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/viewejb.jsp
Modified:
openejb/trunk/openejb/tomee/tomee-plus-webapp/src/main/webapp/WEB-INF/web.xml
openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/WEB-INF/web.xml
openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/default.css
Copied:
openejb/trunk/openejb/tomee/tomee-loader/src/main/java/org/apache/tomee/loader/servlet/ConsoleServlet.java
(from r1309327,
openejb/trunk/openejb/tomee/tomee-loader/src/main/java/org/apache/tomee/loader/servlet/JndiServlet.java)
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-loader/src/main/java/org/apache/tomee/loader/servlet/ConsoleServlet.java?p2=openejb/trunk/openejb/tomee/tomee-loader/src/main/java/org/apache/tomee/loader/servlet/ConsoleServlet.java&p1=openejb/trunk/openejb/tomee/tomee-loader/src/main/java/org/apache/tomee/loader/servlet/JndiServlet.java&r1=1309327&r2=1312055&rev=1312055&view=diff
==============================================================================
---
openejb/trunk/openejb/tomee/tomee-loader/src/main/java/org/apache/tomee/loader/servlet/JndiServlet.java
(original)
+++
openejb/trunk/openejb/tomee/tomee-loader/src/main/java/org/apache/tomee/loader/servlet/ConsoleServlet.java
Wed Apr 11 00:38:31 2012
@@ -18,36 +18,58 @@
package org.apache.tomee.loader.servlet;
import com.google.gson.Gson;
-import org.apache.tomee.loader.listener.UserSessionListener;
-import javax.naming.NamingException;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-public class JndiServlet extends HttpServlet {
+public class ConsoleServlet extends HttpServlet {
@Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
- final String json;
+ protected void doPost(HttpServletRequest req, final HttpServletResponse
resp) throws ServletException, IOException {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+
+ String engineName = req.getParameter("engineName");
+ if (engineName == null || "".equals(engineName.trim())) {
+ engineName = "JavaScript";
+ }
+ final ScriptEngine engine = manager.getEngineByName(engineName);
+
+ engine.put("req", req);
+ engine.put("resp", resp);
+
+ engine.put("util", new Utility() {
+
+
+ @Override
+ public void write(Object obj) throws Exception {
+ resp.getWriter().write(String.valueOf(obj));
+ }
+
+ @Override
+ public String getJson(Object obj) {
+ return new Gson().toJson(obj);
+ }
+ });
+
+ String scriptCode = req.getParameter("scriptCode");
+ if (scriptCode == null || "".equals(scriptCode.trim())) {
+ scriptCode = "var a = 0;";
+ }
try {
- final Map<String, Object> result = new HashMap<String, Object>();
- result.put("jndi", get(req));
- json = new Gson().toJson(result);
- } catch (NamingException e) {
+ engine.eval(scriptCode);
+ } catch (ScriptException e) {
throw new ServletException(e);
}
- resp.setContentType("application/json");
- resp.setCharacterEncoding("UTF-8");
- resp.getWriter().write(json);
}
- public Map<String, Object> get(HttpServletRequest req) throws
NamingException {
- return
UserSessionListener.getServiceContext(req.getSession()).getJndiHelper().getJndi();
+ private interface Utility {
+ void write(Object obj) throws Exception;
+ String getJson(Object obj);
}
-
}
Modified:
openejb/trunk/openejb/tomee/tomee-plus-webapp/src/main/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-plus-webapp/src/main/webapp/WEB-INF/web.xml?rev=1312055&r1=1312054&r2=1312055&view=diff
==============================================================================
---
openejb/trunk/openejb/tomee/tomee-plus-webapp/src/main/webapp/WEB-INF/web.xml
(original)
+++
openejb/trunk/openejb/tomee/tomee-plus-webapp/src/main/webapp/WEB-INF/web.xml
Wed Apr 11 00:38:31 2012
@@ -19,7 +19,7 @@
<web-app 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_3_0.xsd"
- version="3.0" metadata-complete="true">
+ version="3.0" metadata-complete="true">
<display-name>OpenEJB Loader Application</display-name>
@@ -45,6 +45,11 @@
</servlet>
<servlet>
+ <servlet-name>WsConsole</servlet-name>
+
<servlet-class>org.apache.tomee.loader.servlet.ConsoleServlet</servlet-class>
+ </servlet>
+
+ <servlet>
<servlet-name>WsJndi</servlet-name>
<servlet-class>org.apache.tomee.loader.servlet.JndiServlet</servlet-class>
</servlet>
@@ -65,6 +70,11 @@
</servlet-mapping>
<servlet-mapping>
+ <servlet-name>WsConsole</servlet-name>
+ <url-pattern>/ws/console/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
<servlet-name>WsJndi</servlet-name>
<url-pattern>/ws/jndi/*</url-pattern>
</servlet-mapping>
Modified:
openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/WEB-INF/web.xml?rev=1312055&r1=1312054&r2=1312055&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/WEB-INF/web.xml
(original)
+++ openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/WEB-INF/web.xml
Wed Apr 11 00:38:31 2012
@@ -45,6 +45,11 @@
</servlet>
<servlet>
+ <servlet-name>WsConsole</servlet-name>
+
<servlet-class>org.apache.tomee.loader.servlet.ConsoleServlet</servlet-class>
+ </servlet>
+
+ <servlet>
<servlet-name>WsJndi</servlet-name>
<servlet-class>org.apache.tomee.loader.servlet.JndiServlet</servlet-class>
</servlet>
@@ -65,6 +70,11 @@
</servlet-mapping>
<servlet-mapping>
+ <servlet-name>WsConsole</servlet-name>
+ <url-pattern>/ws/console/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
<servlet-name>WsJndi</servlet-name>
<url-pattern>/ws/jndi/*</url-pattern>
</servlet-mapping>
Modified: openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/default.css
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/default.css?rev=1312055&r1=1312054&r2=1312055&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/default.css
(original)
+++ openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/default.css Wed
Apr 11 00:38:31 2012
@@ -1,284 +1,27 @@
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-
-<!-- $Rev: 597221 $ $Date: 2007-11-21 22:51:05 +0100 (Wed, 21 Nov 2007) $ -->
-
-BODY {
- background: #ffffff;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- font-size: 8px;
-}
-
-A:link,
-A:visited,
-A:active {
- text-decoration: none
-}
-
-.userdata {
- behavior: url('#default#userdata');
-}
-
-.bg {
- background-repeat: no-repeat
-}
-
-.pageTitle {
- font-size: 18px;
- font-family: arial, "Helvetica", "Arial", "sans-serif";
- line-height: 28px;
- font-weight: bold;
- color: #666666;
-}
-
-.pageSubTitle {
- font-size: 15px;
- font-family: arial, "Helvetica", "Arial", "sans-serif";
- line-height: 40px;
- font-weight: bold;
- color: #444444;
-}
-
-.bodyGrey {
- font-size: 11px;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 14px; color: #666666;
-}
-
-.bodyBlack {
- font-size: 12px;
- font-family: arial, helvetica, sans-serif;
- line-height: 16px; color: #222222;
-}
-
-.newsSummary {
- font-size: 12px;
- font-family: arial, helvetica, sans-serif;
- line-height: 16px; color: #222222;
-}
-
-.newsTitle {
- font-size: 12px;
- font-family: arial, helvetica, sans-serif;
- line-height: 16px; color: #222222;
- font-weight: bold;
-}
-
-.option {
- font-size: 12px;
- font-family: arial, helvetica, sans-serif;
- line-height: 16px; color: #222222;
-}
-
-.option-flag {
- font-size: 12px;
- font-family: courier new, arial, helvetica, sans-serif;
- line-height: 16px; color: #7270c2;
- font-weight: bold;
-}
-
-.option-param {
- font-size: 12px;
- font-family: arial, helvetica, sans-serif;
- line-height: 16px; color: #7270c2;
-}
-
-.note {
- font-size: 11px;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 14px; color: #666666;
-}
-
-.note-caption {
- font-size: 12px;
- font-family: arial, helvetica, sans-serif;
- line-height: 16px; color: #FFFFFF;
- font-weight: bold;
-}
-
-.toc {
- font-size: 12px;
- font-family: arial, helvetica, sans-serif;
- line-height: 16px; color: #222222;
-}
-
-.bodyBlackOLD {
- font-size: 11px;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 14px; color: #222222;
-}
-
-
-h1 {
- font-size: 19px;
- font-family: arial, helvetica, sans-serif;
- line-height: 20px; color: #000000;
-}
-
-h2 {
- font-size: 17px;
- font-family: arial, helvetica, sans-serif;
- line-height: 20px; color: #000000;
-}
-
-h3 {
- font-size: 15px;
- font-family: arial, helvetica, sans-serif;
- line-height: 17px; color: #000000;
- font-weight: bold;
-}
-
-h4 {
- font-size: 13px;
- font-family: arial, helvetica, sans-serif;
- line-height: 15px; color: #000000;
- font-weight: bold;
-}
-
-h5 {
- font-size: 12px;
- font-family: arial, helvetica, sans-serif;
- line-height: 15px; color: #444444;
-}
-
-.bodyCode {
- font-size: 11px;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 14px; color: #757585;
-}
-
-.command {
- font-size: 12px;
- font-family: courier new, "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 14px; color: #757585;
-}
-
-.code-title {
- font-size: 12px;
- font-family: arial, "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 12px; color: #666666;
-}
-
-.code-block {
- font-size: 12px;
- font-family: courier new, "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 16px; color: #757585;
-}
-
-.code-comment {
- font-size: 12px;
- font-family: courier new, "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 16px; color: #8888CC;
-}
-
-.legalBlack {
- font-size: 10px;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 14px; color: #000000;
-}
-
-.legalGrey {
- font-size: 9px;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 14px; color: #999999;
-}
-
-.bigGrey {
- font-size: 11px;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 14px; color: #666666;
-}
-
-.projectBlack {
- font-size: 11px;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 11px; color: #000000;
-}
-
-.header {
- font-size: 11px;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 14px;
- font-weight: bold;
- color: #181818;
-}
-
-.teamMember {
- font-size: 11px;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 14px;
- font-weight: bold;
- color: #181818;
-}
-
-.teamMemberRole {
- font-size: 11px;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 14px;
- font-weight: bold;
- color: #A8A8A8;
-}
-
-.menuTopOn {
- font-size: 11px;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 0px;
- color: #6763a9;
-}
-
-.menuTopOff {
- font-size: 11px;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 0px;
- color: #999999;
-}
-
-.menuProjectOn {
- font-size: 12px;
- font-family: "Helvetica", "Arial", "sans-serif";
- line-height: 20px;
- font-weight: bold;
- color: #cbcbeb;
-}
-
-.menuProjectOff {
- font-size: 12px;
- font-family: "Helvetica", "Arial", "sans-serif";
- line-height: 20px;
- font-weight: bold;
- color: #ffffff;
-}
-
-.subMenuOn {
- font-size: 11px;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 30px;
- font-weight: bold;
- color: #4d4b7e;
-}
-
-.subMenuOff {
- font-size: 10px;
- font-family: "Tahoma", "Helvetica", "Arial", "sans-serif";
- line-height: 17px;
- font-weight: bold;
- color: #cbcbeb;
-}
-
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+<!-- $Rev: 597221 $ $Date: 2007-11-21 22:51:05 +0100 (Wed, 21 Nov 2007) $ -->
+
+.boxsizingBorder {
+ box-sizing: border-box;
+ -webkit-box-sizing:border-box;
+ -moz-box-sizing: border-box;
+ -ms-box-sizing: border-box;
+}
\ No newline at end of file
Copied:
openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/viewconsole.jsp (from
r1311017, openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/viewejb.jsp)
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/viewconsole.jsp?p2=openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/viewconsole.jsp&p1=openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/viewejb.jsp&r1=1311017&r2=1312055&rev=1312055&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/viewejb.jsp
(original)
+++ openejb/trunk/openejb/tomee/tomee-webapp/src/main/webapp/viewconsole.jsp
Wed Apr 11 00:38:31 2012
@@ -1,41 +1,24 @@
<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
-->
<!-- $Rev: 597221 $ $Date: 2007-11-21 22:51:05 +0100 (Wed, 21 Nov 2007) $ -->
-<%@ page import="
-org.apache.openejb.BeanType,
-org.apache.openejb.BeanContext,
-org.apache.openejb.loader.SystemInstance,
-org.apache.openejb.spi.ContainerSystem,
-javax.naming.Context,
-javax.naming.InitialContext
-"%>
-<%@ page import="javax.servlet.http.HttpServletRequest" %>
-<%@ page import="javax.servlet.http.HttpSession" %>
-<%@ page import="java.io.IOException" %>
-<%@ page import="java.util.HashMap" %>
-<%@ page import="java.util.Map" %>
-<%@ page import="java.util.List" %>
-<%@ page import="java.util.Properties" %>
-<%@ page import="java.lang.reflect.Field" %>
-<%@ page import="java.lang.reflect.Method" %>
<html>
@@ -47,12 +30,14 @@ javax.naming.InitialContext
<meta name="author" content="">
<!-- Le styles -->
+ <link href="default.css" rel="stylesheet">
<link href="css/bootstrap.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
+
.sidebar-nav {
padding: 9px 0;
}
@@ -76,51 +61,65 @@ javax.naming.InitialContext
<span class="icon-bar"></span>
</a>
<a class="brand" href="http://openejb.apache.org">TomEE</a>
+
<div class="nav-collapse">
<ul class="nav">
<li><a href="index.jsp">Index</a></li>
<li><a href="viewjndi.jsp">JNDI</a></li>
- <li class="active"><a href="viewejb.jsp">EJB</a></li>
+ <li><a href="viewejb.jsp">EJB</a></li>
<li><a href="viewclass.jsp">Class</a></li>
<li><a href="invokeobj.jsp">Invoke</a></li>
+ <li class="active"><a
href="viewconsole.jsp.jsp">Console</a></li>
</ul>
- </div><!--/.nav-collapse -->
+ </div>
+ <!--/.nav-collapse -->
</div>
</div>
</div>
- <div class="container-fluid">
- <div class="row-fluid">
- <div class="span12">
- <%
- try{
- String ejb = request.getParameter("ejb");
- String jndiName = request.getParameter("jndiName");
- String contextID = request.getParameter("ctxID");
- if (ejb == null) {
- out.print("<p>No EJB specified</p>");
- } else {
- printEjb(ejb,jndiName,contextID,out, session);
-
- }
- } catch (Exception e){
-
- out.println("<p>FAIL: <br>");
- out.print(e.getMessage() + "</p>");
- throw e;
- //return;
- }
- %>
- </div>
+<div class="container-fluid">
+ <div class="row-fluid">
+ <div class="span12">
+ <p>
+ <textarea id='scriptCodeTXT' class="span8 input-xlarge"
id="textarea" rows="20">
+//See
http://docs.oracle.com/javase/6/docs/technotes/guides/scripting/programmer_guide/index.html
for more information about java scripting
+
+//import what you need
+importClass(javax.naming.Context);
+importClass(java.util.Properties);
+importClass(javax.naming.InitialContext);
+
+//create the initial context
+var p = new Properties();
+p.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.core.LocalInitialContextFactory");
+p.put("openejb.loader", "embed");
+var ctx = new InitialContext(p);
+
+//lookup and execute your ejb
+var ejbHome = ctx.lookup("MEJB");
+var bean = ejbHome.create();
+
+//the "util" object has tow methods: write and getJson
+util.write(bean.getDefaultDomain());
+
+ </textarea><BR>
+ <a class="btn btn-primary" href="#"
onclick="TOMEE.executeScript();">Run</a>
+ </p>
+
</div>
+ </div>
- <hr>
+ <div id="resultsDIV" class="row-fluid"></div>
- <footer>
- <p>Copyright © 2012 The Apache Software Foundation, Licensed
under the Apache License, Version 2.0. Apache and the Apache feather logo are
trademarks of The Apache Software Foundation.</p>
- </footer>
- </div> <!-- /container -->
+ <hr>
+
+ <footer>
+ <p>Copyright © 2012 The Apache Software Foundation, Licensed
under the Apache License, Version 2.0. Apache
+ and the Apache feather logo are trademarks of The Apache Software
Foundation.</p>
+ </footer>
+</div>
+<!-- /container -->
<!-- Le javascript
@@ -129,124 +128,40 @@ javax.naming.InitialContext
<script src="js/jquery/jquery-1.7.1.js"></script>
<script src="js/bootstrap/bootstrap.js"></script>
-</body>
-</html>
+<script type="text/javascript">
+ var TOMEE = (function () {
-<%!
- private BeanContext getDeployment(String deploymentID) {
- try {
- ContainerSystem containerSystem =
SystemInstance.get().getComponent(ContainerSystem.class);
- BeanContext ejb = containerSystem.getBeanContext(deploymentID);
- return ejb;
- } catch (Exception e) {
- return null;
- }
- }
+ var executeScript = function () {
- public void printEjb(String name,String jndiName, String contextID,
javax.servlet.jsp.JspWriter out, HttpSession session) throws Exception {
- String id = (name.startsWith("/")) ? name.substring(1, name.length())
: name;
- BeanContext ejb = getDeployment(id);
-
- if (ejb == null) {
- out.print("<p>No such EJB: " + id + "</p>");
- return;
- }
- String type = null;
+ var request = $.ajax({
+ type: 'POST',
+ dataType: 'text',
+ data: {
+ 'scriptCode': $('#scriptCodeTXT').val()
+ },
+ url: '/tomee/ws/console',
+ success: function (data) {
+ var value = data;
+ if(!value || value === '') {
+ value = 'done'
+ }
+ var el = $('<div class="well"><p>' + data + '</p></div>');
+ $('#resultsDIV').prepend(el);
+ },
+ error: function (data) {
+ var bodyHtml =
/<body.*?>([\s\S]*)<\/body>/.exec(data.responseText)[1];
+ var el = $('<div class="well"><p>' + bodyHtml +
'</p></div>');
+ $('#resultsDIV').prepend(el);
+ }
+ });
+ };
- switch (ejb.getComponentType()) {
- case CMP_ENTITY:
- type = "EntityBean with Container-Managed Persistence";
- break;
- case BMP_ENTITY:
- type = "EntityBean with Bean-Managed Persistence";
- break;
- case STATEFUL:
- type = "Stateful SessionBean";
- break;
- case STATELESS:
- type = "Stateless SessionBean";
- break;
- case SINGLETON:
- type = "Singleton SessionBean";
- break;
- case MANAGED:
- type = "Managed SessionBean";
- break;
- default:
- type = "Unkown Bean Type";
- break;
+ return {
+ executeScript: executeScript
}
- out.print("<h2>" + type + "</h2>");
- out.print("<table class=\"table table-striped
table-bordered\"><tbody>");
- printRow("JNDI Name", jndiName, out);
- if(ejb.getRemoteInterface() != null)
- printRow("Remote Interface",
getClassRef(ejb.getRemoteInterface(),session), out);
- if(ejb.getHomeInterface() != null)
- printRow("Home Interface",
getClassRef(ejb.getHomeInterface(),session), out);
- if(ejb.getBeanClass() != null)
- printRow("Bean Class", getClassRef(ejb.getBeanClass(),session), out);
- if(ejb.getBusinessLocalInterfaces().size() > 0)
- printRow("Business Local Interfaces",
getClassRefs(ejb.getBusinessLocalInterfaces(),session), out);
- if(ejb.getBusinessRemoteInterfaces().size() > 0)
- printRow("Business Remote Interfaces",
getClassRefs(ejb.getBusinessRemoteInterfaces(),session), out);
- if (ejb.getComponentType() == BeanType.BMP_ENTITY ||
ejb.getComponentType() == BeanType.CMP_ENTITY) {
- printRow("Primary Key",
getClassRef(ejb.getPrimaryKeyClass(),session), out);
- }
- out.print("</tbody></table>");
+ })();
+</script>
- // Browse JNDI with this ejb
- //javax.servlet.http.HttpSession session = this.session;
- //noinspection unchecked
- Map<String, Object> objects = (Map<String, Object>)
session.getAttribute("objects");
- if (objects == null) {
- objects = new HashMap<String, Object>();
- session.setAttribute("objects", objects);
- }
-
- Context ctx;
- if(contextID == null){
- Properties p = new Properties();
-
- p.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.core.LocalInitialContextFactory");
- p.put("openejb.loader", "embed");
-
- ctx = new InitialContext(p);
- }else{
- ctx = (Context)session.getAttribute(contextID);
- }
- Object obj = ctx.lookup(jndiName);
- // String objID = ejb.getHomeInterface().getName() + "@" +
obj.hashCode();
- String objID = ""+obj.hashCode(); //TODO: Not the best of the ID's,
more meaningful ID would be better. Right now hashcode would suffice
- objects.put(objID, obj);
- String invokeURL = "<a class='btn' href='invokeobj.jsp?obj=" + objID +
"'>Invoke this EJB</a>";
-
- Context enc = ejb.getJndiEnc();
- String ctxID = "enc" + enc.hashCode();
- session.setAttribute(ctxID, enc);
- String jndiURL = "<a class='btn' href='viewjndi.jsp?ctxID=" + ctxID +
"'>Browse this EJB's private JNDI namespace</a>";
-
- out.print("<div class='btn-group'>" + invokeURL + jndiURL + "</div>");
- }
-
- protected void printRow(String col1, String col2,
javax.servlet.jsp.JspWriter out) throws IOException {
- out.print("<tr>");
- out.print("<td>" + col1 + "</td>");
- out.print("<td>" + col2 + "</td>");
- out.print("</tr>");
- }
-
- public String getClassRef(Class clazz, HttpSession session) throws
Exception {
- String name = clazz.getName();
- session.setAttribute(name,clazz);
- return "<a href='viewclass.jsp?class=" + name + "'>" + name + "</a>";
- }
-
- public String getClassRefs(List<Class> classes, HttpSession session)
throws Exception{
- String refs = "";
- for(Class clazz: classes){
- refs += getClassRef(clazz,session)+"<br/>";
- }
- return refs;
- }
-%>
+</body>
+</html>