tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tveron...@apache.org
Subject svn commit: r1541905 - in /tomee/tomee/trunk/tomee/tomee-webaccess: ./ src/main/groovy/org/apache/tomee/webaccess/data/dto/ src/main/groovy/org/apache/tomee/webaccess/rest/ src/main/groovy/org/apache/tomee/webaccess/service/ src/main/webapp/app/ src/ma...
Date Thu, 14 Nov 2013 13:39:56 GMT
Author: tveronezi
Date: Thu Nov 14 13:39:55 2013
New Revision: 1541905

URL: http://svn.apache.org/r1541905
Log:
TOMEE-1074
Done

Added:
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/data/dto/SessionResultDto.groovy
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/Session.groovy
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/service/SessionServiceImpl.groovy
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/handlebarsHelpers.js
      - copied, changed from r1541661, tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/i18n.js
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/templates/sessions.handlebars
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/view/sessions.js
Modified:
    tomee/tomee/trunk/tomee/tomee-webaccess/Makefile
    tomee/tomee/trunk/tomee/tomee-webaccess/pom.xml
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/ApplicationConfig.groovy
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/KeepAlive.groovy
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/Log.groovy
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/Scripting.groovy
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/WebServices.groovy
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/service/WsServiceImpl.groovy
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/app.less
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/application.js
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/i18n.js
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/templates.js
    tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/templates/container.handlebars

Modified: tomee/tomee/trunk/tomee/tomee-webaccess/Makefile
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/Makefile?rev=1541905&r1=1541904&r2=1541905&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/Makefile (original)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/Makefile Thu Nov 14 13:39:55 2013
@@ -13,8 +13,8 @@
 #
 
 up-static:
-	rm -rf target/apache-tomee/webapps/ROOT/app
-	cp -r src/main/webapp/app target/apache-tomee/webapps/ROOT/
+	rm -rf target/apache-tomee/webapps/webaccess/app
+	cp -r src/main/webapp/app target/apache-tomee/webapps/webaccess/
 
 run:
 	mvn clean install -DskipTests=true

Modified: tomee/tomee/trunk/tomee/tomee-webaccess/pom.xml
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/pom.xml?rev=1541905&r1=1541904&r2=1541905&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/pom.xml (original)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/pom.xml Thu Nov 14 13:39:55 2013
@@ -172,7 +172,7 @@
         <version>${project.version}</version>
         <configuration>
           <simpleLog>true</simpleLog>
-          <context>ROOT</context>
+          <context>webaccess</context>
           <tomeeClassifier>jaxrs</tomeeClassifier>
         </configuration>
       </plugin>

Added: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/data/dto/SessionResultDto.groovy
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/data/dto/SessionResultDto.groovy?rev=1541905&view=auto
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/data/dto/SessionResultDto.groovy
(added)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/data/dto/SessionResultDto.groovy
Thu Nov 14 13:39:55 2013
@@ -0,0 +1,45 @@
+/**
+ *
+ * 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.
+ */
+
+package org.apache.tomee.webaccess.data.dto
+
+import javax.xml.bind.annotation.XmlAccessType
+import javax.xml.bind.annotation.XmlAccessorType
+import javax.xml.bind.annotation.XmlElement
+import javax.xml.bind.annotation.XmlRootElement
+
+@XmlAccessorType(XmlAccessType.NONE)
+@XmlRootElement
+class SessionResultDto {
+
+    @XmlElement
+    String context
+
+    @XmlElement
+    String sessionId
+
+    @XmlElement
+    Long lastAccessTs
+
+    @XmlElement
+    Long creationTs
+
+    @XmlElement
+    Long expirationTs
+
+}

Modified: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/ApplicationConfig.groovy
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/ApplicationConfig.groovy?rev=1541905&r1=1541904&r2=1541905&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/ApplicationConfig.groovy
(original)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/ApplicationConfig.groovy
Thu Nov 14 13:39:55 2013
@@ -23,7 +23,9 @@ import javax.ws.rs.core.Application
 
 @ApplicationPath("/rest")
 class ApplicationConfig extends Application {
+
     Set<Class<?>> getClasses() {
-        [KeepAlive, Log, Scripting, WebServices]
+        [KeepAlive, Log, Scripting, WebServices, Session]
     }
+
 }

Modified: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/KeepAlive.groovy
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/KeepAlive.groovy?rev=1541905&r1=1541904&r2=1541905&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/KeepAlive.groovy
(original)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/KeepAlive.groovy
Thu Nov 14 13:39:55 2013
@@ -23,8 +23,10 @@ import javax.ws.rs.Path
 
 @Path("/keep-alive")
 class KeepAlive {
+
     @GET
     void ping() {
         // no-op
     }
+
 }

Modified: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/Log.groovy
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/Log.groovy?rev=1541905&r1=1541904&r2=1541905&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/Log.groovy
(original)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/Log.groovy
Thu Nov 14 13:39:55 2013
@@ -27,6 +27,7 @@ import javax.ws.rs.*
 
 @Path("/log")
 class Log {
+
     @EJB
     private LogServiceImpl service
 
@@ -43,4 +44,5 @@ class Log {
     LogFileResultDto load(@PathParam('fileName') String fileName) {
         service.load(fileName)
     }
+
 }

Modified: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/Scripting.groovy
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/Scripting.groovy?rev=1541905&r1=1541904&r2=1541905&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/Scripting.groovy
(original)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/Scripting.groovy
Thu Nov 14 13:39:55 2013
@@ -29,6 +29,7 @@ import javax.ws.rs.Produces
 
 @Path("/scripting")
 class Scripting {
+
     @EJB
     private ScriptingServiceImpl service
 
@@ -37,4 +38,5 @@ class Scripting {
     ScriptingResultDto execute(@FormParam('engine') String engine, @FormParam('script') String
script) {
         service.execute(engine, script)
     }
+
 }

Added: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/Session.groovy
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/Session.groovy?rev=1541905&view=auto
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/Session.groovy
(added)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/Session.groovy
Thu Nov 14 13:39:55 2013
@@ -0,0 +1,44 @@
+/**
+ *
+ * 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.
+ */
+
+package org.apache.tomee.webaccess.rest
+
+import org.apache.tomee.webaccess.data.dto.SessionResultDto
+import org.apache.tomee.webaccess.service.SessionServiceImpl
+
+import javax.ejb.EJB
+import javax.ws.rs.*
+
+@Path("/session")
+class Session {
+
+    @EJB
+    private SessionServiceImpl service
+
+    @DELETE
+    @Path("/expire/{context}/{sessionId}")
+    void expireSession(@PathParam("context") String context, @PathParam("sessionId") String
sessionId) {
+        service.expireSession(context, sessionId)
+    }
+
+    @GET
+    @Produces("application/json")
+    List<SessionResultDto> list() {
+        service.listSessions()
+    }
+}

Modified: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/WebServices.groovy
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/WebServices.groovy?rev=1541905&r1=1541904&r2=1541905&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/WebServices.groovy
(original)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/rest/WebServices.groovy
Thu Nov 14 13:39:55 2013
@@ -28,6 +28,7 @@ import javax.ws.rs.Produces
 
 @Path("/ws")
 class WebServices {
+
     @EJB
     private WsServiceImpl service
 
@@ -36,4 +37,5 @@ class WebServices {
     WsListResultDto list() {
         service.list()
     }
+
 }

Added: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/service/SessionServiceImpl.groovy
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/service/SessionServiceImpl.groovy?rev=1541905&view=auto
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/service/SessionServiceImpl.groovy
(added)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/service/SessionServiceImpl.groovy
Thu Nov 14 13:39:55 2013
@@ -0,0 +1,87 @@
+/**
+ *
+ * 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.
+ */
+
+package org.apache.tomee.webaccess.service
+
+import org.apache.tomee.webaccess.data.dto.SessionResultDto
+
+import javax.annotation.security.RolesAllowed
+import javax.ejb.Stateless
+import javax.ejb.TransactionAttribute
+import javax.ejb.TransactionAttributeType
+import javax.management.InstanceNotFoundException
+import javax.management.ObjectName
+import javax.ws.rs.PathParam
+import java.lang.management.ManagementFactory
+
+@TransactionAttribute(TransactionAttributeType.SUPPORTS)
+@Stateless
+@RolesAllowed('tomee-admin')
+class SessionServiceImpl {
+
+    static void expireSession(@PathParam("context") String context, @PathParam("sessionId")
String sessionId) {
+        def server = ManagementFactory.getPlatformMBeanServer()
+        def name = "Catalina:type=Manager,context=/$context,host=localhost" as String
+        try {
+            def contextBean = server.getObjectInstance(new ObjectName(name))
+            server.invoke(contextBean.objectName, 'expireSession', [sessionId] as Object[],
[String.class.name] as String[])
+        } catch (InstanceNotFoundException ignore) {
+            // no-op
+        }
+    }
+
+    static List<SessionResultDto> listSessions() {
+        def server = ManagementFactory.getPlatformMBeanServer()
+        def localhostBean = server.getObjectInstance(new ObjectName('Catalina:type=Host,host=localhost'))
+        def children = server.getAttribute(localhostBean.objectName, 'children')
+        def baseNames = children.collect { ObjectName objectName ->
+            server.getAttribute(objectName, 'baseName')
+        }
+        def result = []
+        baseNames.each { baseName ->
+            def name = "Catalina:type=Manager,context=/$baseName,host=localhost" as String
+            try {
+                def contextBean = server.getObjectInstance(new ObjectName(name))
+                def maxInactiveInterval = server.getAttribute(contextBean.objectName, 'maxInactiveInterval')
as Long
+
+                def getValue = { String operationName, String sessionId ->
+                    server.invoke(contextBean.objectName, operationName, [sessionId] as Object[],
[String.class.name] as String[])
+                }
+
+                server.invoke(contextBean.objectName, 'listSessionIds', null, null).split('
').each { String sessionId ->
+                    if (sessionId != '') {
+                        def accessedTs = getValue('getLastAccessedTimestamp', sessionId)
as Long
+                        def expirationTs = maxInactiveInterval * 1000 + accessedTs
+                        def creationTs = getValue('getCreationTimestamp', sessionId) as Long
+                        result << new SessionResultDto(
+                                context: baseName,
+                                sessionId: sessionId,
+                                creationTs: creationTs,
+                                expirationTs: expirationTs,
+                                lastAccessTs: accessedTs
+                        )
+                    }
+                }
+            } catch (InstanceNotFoundException ignore) {
+                // no-op
+            }
+        }
+        result
+    }
+
+}

Modified: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/service/WsServiceImpl.groovy
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/service/WsServiceImpl.groovy?rev=1541905&r1=1541904&r2=1541905&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/service/WsServiceImpl.groovy
(original)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/groovy/org/apache/tomee/webaccess/service/WsServiceImpl.groovy
Thu Nov 14 13:39:55 2013
@@ -36,6 +36,7 @@ import javax.ejb.TransactionAttributeTyp
 @Stateless
 @RolesAllowed('tomee-admin')
 class WsServiceImpl {
+
     private static def log = Logger.getInstance(LogCategory.OPENEJB_ADMIN, WsServiceImpl)
 
     private static ApplicationDto getApplicationByName(WsListResultDto queryResult, String
name) {
@@ -117,4 +118,5 @@ class WsServiceImpl {
         soapWebServices(queryResult)
         queryResult
     }
+
 }

Modified: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/app.less
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/app.less?rev=1541905&r1=1541904&r2=1541905&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/app.less (original)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/app.less Thu Nov 14 13:39:55
2013
@@ -37,6 +37,15 @@ body {
     padding: 0;
   }
 
+  .ux-sessions {
+    position: absolute;
+    top: @topOffset;
+    bottom: @offset;
+    left: @offset;
+    right: @offset;
+    margin-bottom: 0;
+  }
+
   .ux-logfile-output {
     position: absolute;
     top: @topOffset;

Modified: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/application.js
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/application.js?rev=1541905&r1=1541904&r2=1541905&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/application.js (original)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/application.js Thu Nov
14 13:39:55 2013
@@ -21,13 +21,14 @@
 
     var deps = [
         'app/js/view/container',
-        'app/js/view/scripting', 'app/js/view/logfiles', 'app/js/view/growl',
+        'app/js/view/scripting', 'app/js/view/logfiles', 'app/js/view/sessions', 'app/js/view/growl',
         'lib/underscore',
         'app/js/i18n',
+        'app/js/handlebarsHelpers',
         'lib/less', 'lib/backbone', 'lib/jquery', 'lib/bootstrap',
         'app/js/keep-alive'
     ];
-    define(deps, function (containerView, scriptingView, logfilesView) {
+    define(deps, function (containerView, scriptingView, logfilesView, sessionsView) {
         containerView.render();
 
         $.ajaxSetup({ cache: false });
@@ -36,7 +37,9 @@
             //Starting the backbone router.
             var Router = Backbone.Router.extend({
                 routes: {
-                    '': 'showScripting',
+                    '': 'showSessions',
+                    '/': 'showSessions',
+                    'sessions': 'showSessions',
                     'scripting': 'showScripting',
                     'scripting/': 'showScripting',
                     'scripting/:scriptType': 'showScripting',
@@ -45,6 +48,21 @@
                     'log-files/:fileName': 'showLogFile'
                 },
 
+                showSessions: function () {
+                    containerView.showView(sessionsView);
+                    $.ajax({
+                        url: window.ux.ROOT_URL + 'rest/session',
+                        method: 'GET',
+                        dataType: 'json',
+                        data: {},
+                        success: function (data) {
+                            sessionsView.render({
+                                sessions: data.sessionResultDto
+                            });
+                        }
+                    });
+                },
+
                 showScripting: function (scriptType) {
                     containerView.showView(scriptingView);
                     if (scriptType) {
@@ -67,6 +85,18 @@
                 });
             });
 
+            sessionsView.on('expire-session', function (data) {
+                $.ajax({
+                    url: window.ux.ROOT_URL + 'rest/session/expire/' + data.context + '/'
+ data.sessionId,
+                    method: 'DELETE',
+                    dataType: 'json',
+                    data: {},
+                    success: function (data) {
+                        router.showSessions();
+                    }
+                });
+            });
+
             scriptingView.on('execute-action', function (data) {
                 $.ajax({
                     url: window.ux.ROOT_URL + 'rest/scripting/',

Copied: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/handlebarsHelpers.js
(from r1541661, tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/i18n.js)
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/handlebarsHelpers.js?p2=tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/handlebarsHelpers.js&p1=tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/i18n.js&r1=1541661&r2=1541905&rev=1541905&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/i18n.js (original)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/handlebarsHelpers.js Thu
Nov 14 13:39:55 2013
@@ -17,47 +17,16 @@
  "use strict";
  */
 
-define(['lib/underscore', 'lib/handlebars', 'app/js/log'], function (underscore) {
+define(['app/js/i18n', 'lib/handlebars'], function (i18n) {
     'use strict';
 
-    var missing = Handlebars.compile('[!{{key}}!]');
-    var messages = {
-        'application.name': 'Apache TomEE',
-        'visitor': 'visitor',
-        'scripting': 'Scripting',
-        'source': 'Source Code',
-        'output': 'Output',
-        'execute': 'Execute',
-        'clean.execute': 'Clean and execute',
-        'groovy': 'Groovy',
-        'javascript': 'JavaScript',
-        'log.files': 'Log Files',
-        'log.file': 'Choose file'
-    };
-
-    underscore.each(underscore.keys(messages), function (key) {
-        var template = Handlebars.compile(messages[key]);
-        messages[key] = template;
+    Handlebars.registerHelper('i18n', function (key) {
+        return i18n.get(key);
     });
 
-    var get = function (key, values) {
-        var template = messages[key];
-        var cfg = values;
-        if (!template) {
-            template = missing;
-            cfg = {
-                key: key
-            };
-            window.console.error('Missing i18n message.', key);
-        }
-        return template(cfg);
-    };
-
-    Handlebars.registerHelper('i18n', function (key) {
-        return get(key);
+    Handlebars.registerHelper('timeStampToDate', function (value) {
+        var date = new Date(value);
+        return date.toUTCString();
     });
 
-    return {
-        get: get
-    };
 });

Modified: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/i18n.js
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/i18n.js?rev=1541905&r1=1541904&r2=1541905&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/i18n.js (original)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/i18n.js Thu Nov 14 13:39:55
2013
@@ -32,7 +32,13 @@ define(['lib/underscore', 'lib/handlebar
         'groovy': 'Groovy',
         'javascript': 'JavaScript',
         'log.files': 'Log Files',
-        'log.file': 'Choose file'
+        'log.file': 'Choose file',
+        'sessions': 'Sessions',
+        'session.id': 'Session Id',
+        'session.context': 'Context',
+        'session.creation.date': 'Created',
+        'session.last.access': 'Accessed',
+        'session.expiration.date': 'Expire'
     };
 
     underscore.each(underscore.keys(messages), function (key) {
@@ -53,10 +59,6 @@ define(['lib/underscore', 'lib/handlebar
         return template(cfg);
     };
 
-    Handlebars.registerHelper('i18n', function (key) {
-        return get(key);
-    });
-
     return {
         get: get
     };

Modified: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/templates.js
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/templates.js?rev=1541905&r1=1541904&r2=1541905&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/templates.js (original)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/templates.js Thu Nov 14
13:39:55 2013
@@ -27,7 +27,8 @@
         'script-sample-javascript',
         'script-sample-groovy',
         'logfiles',
-        'logfile-link'
+        'logfile-link',
+        'sessions'
     ];
 
     function loop(values, callback) {

Modified: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/templates/container.handlebars
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/templates/container.handlebars?rev=1541905&r1=1541904&r2=1541905&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/templates/container.handlebars
(original)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/templates/container.handlebars
Thu Nov 14 13:39:55 2013
@@ -10,6 +10,7 @@
     </div>
     <div class="collapse navbar-collapse navbar-ex8-collapse">
         <ul class="nav navbar-nav">
+            <li class="ux-app-menu-item ux-sessions"><a href="sessions">{{i18n
"sessions"}}</a></li>
             <li class="ux-app-menu-item ux-scripting"><a href="scripting">{{i18n
"scripting"}}</a></li>
             <li class="ux-app-menu-item ux-log-files"><a href="log-files">{{i18n
"log.files"}}</a></li>
         </ul>

Added: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/templates/sessions.handlebars
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/templates/sessions.handlebars?rev=1541905&view=auto
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/templates/sessions.handlebars
(added)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/templates/sessions.handlebars
Thu Nov 14 13:39:55 2013
@@ -0,0 +1,27 @@
+<table class="table table-striped">
+    <thead>
+    <tr>
+        <th>{{i18n "session.id"}}</th>
+        <th>{{i18n "session.context"}}</th>
+        <th>{{i18n "session.creation.date"}}</th>
+        <th>{{i18n "session.last.access"}}</th>
+        <th>{{i18n "session.expiration.date"}}</th>
+    </tr>
+    </thead>
+    <tbody>
+    {{#each sessions}}
+    <tr>
+        <td>{{this.sessionId}}</td>
+        <td>{{this.context}}</td>
+        <td>{{timeStampToDate this.creationTs}}</td>
+        <td>{{timeStampToDate this.lastAccessTs}}</td>
+        <td>{{timeStampToDate this.expirationTs}}
+            <a class="ux-expire-btn" href="expire">
+                <span data-session-id="{{this.sessionId}}" data-context-id="{{this.context}}"
+                      class="glyphicon glyphicon-trash"></span>
+            </a>
+        </td>
+    </tr>
+    {{/each}}
+    </tbody>
+</table>

Added: tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/view/sessions.js
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/view/sessions.js?rev=1541905&view=auto
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/view/sessions.js (added)
+++ tomee/tomee/trunk/tomee/tomee-webaccess/src/main/webapp/app/js/view/sessions.js Thu Nov
14 13:39:55 2013
@@ -0,0 +1,57 @@
+/**
+ *
+ * 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.
+ */
+
+(function () {
+    'use strict';
+
+    var deps = ['app/js/templates', 'lib/underscore', 'lib/backbone'];
+    define(deps, function (templates, underscore) {
+
+        var View = Backbone.View.extend({
+            tagName: 'div',
+            className: 'ux-sessions',
+            events: {
+                'click .ux-refresh-btn': function (evt) {
+                    evt.preventDefault();
+                    var me = this;
+                    me.trigger('refresh-sessions', {});
+                },
+                'click .ux-expire-btn': function (evt) {
+                    // TRICK to avoid full page reload.
+                    evt.preventDefault();
+                    var myLink = $(evt.target);
+                    this.trigger('expire-session', {
+                        sessionId: myLink.attr('data-session-id'),
+                        context: myLink.attr('data-context-id')
+                    });
+                }
+            },
+            render: function (data) {
+                var me = this;
+                me.$el.empty();
+                var tplValues = {};
+                if (data) {
+                    tplValues = data;
+                }
+                me.$el.append(templates.getValue('sessions', tplValues));
+                return me;
+            }
+        });
+        return new View();
+    });
+}());



Mime
View raw message