Author: taylor
Date: Fri Apr 17 21:11:44 2015
New Revision: 1674405
URL: http://svn.apache.org/r1674405
Log:
JS2-1320: hook in live stats to memory portlet.
Added:
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/StatisticsManagementService.java
Removed:
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/bootstrap-blue/css/.DS_Store
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/bootstrap-green/css/.DS_Store
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/bootstrap-red/.DS_Store
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/bootstrap-red/css/.DS_Store
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/bootstrap/css/.DS_Store
Modified:
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/portal-admin/profiler.psml
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/profiler.psml
portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-restful-services.xml
Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/portal-admin/profiler.psml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/portal-admin/profiler.psml?rev=1674405&r1=1674404&r2=1674405&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/portal-admin/profiler.psml (original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/portal-admin/profiler.psml Fri Apr 17 21:11:44 2015
@@ -28,7 +28,7 @@ limitations under the License.
<metadata name="title" xml:lang="zh">Profiler管ç</metadata>
<metadata name="title" xml:lang="ko">íë¡íì¼ ê´ë¦¬</metadata>
- <fragment id="pa-site" type="layout" name="jetspeed-layouts::VelocityOneColumn">
+ <fragment id="pa-site" type="layout" name="jetspeed-layouts::ResponsiveLayout">
<fragment id="prof-2" type="portlet" name="j2-admin::ProfilerAdmin" />
</fragment>
Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/profiler.psml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/profiler.psml?rev=1674405&r1=1674404&r2=1674405&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/profiler.psml (original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/profiler.psml Fri Apr 17 21:11:44 2015
@@ -29,7 +29,7 @@ limitations under the License.
<metadata name="title" xml:lang="ko">íë¡íì¼ ê´ë¦¬</metadata>
- <fragment id="pa-site" type="layout" name="jetspeed-layouts::VelocityOneColumn">
+ <fragment id="pa-site" type="layout" name="jetspeed-layouts::ResponsiveLayout">
<fragment id="prof-2" type="portlet" name="j2-admin::ProfilerAdmin" >
</fragment>
</fragment>
Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/StatisticsManagementService.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/StatisticsManagementService.java?rev=1674405&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/StatisticsManagementService.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/StatisticsManagementService.java Fri Apr 17 21:11:44 2015
@@ -0,0 +1,83 @@
+/*
+ * 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.jetspeed.services.rest;
+
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.exception.JetspeedException;
+import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.statistics.PortalStatistics;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * UserManagerService. This REST service provides statistics for Jetspeed charting portlets
+ *
+ * @version $Id: $
+ */
+@Path("/statistics/")
+public class StatisticsManagementService {
+
+ private static Logger log = LoggerFactory.getLogger(ProfilerManagementService.class);
+
+ private PortalStatistics statistics;
+ private PortletActionSecurityBehavior securityBehavior;
+
+ public StatisticsManagementService(PortalStatistics statistics,
+ PortletActionSecurityBehavior securityBehavior) {
+ this.statistics = statistics;
+ this.securityBehavior = securityBehavior;
+ }
+
+ /**
+ * Retrieve JVM memory info
+ *
+ * @param servletRequest
+ * @param uriInfo
+ * @return
+ */
+ @GET
+ @Path("/runtime")
+ public Map<String,Map<String,Long>> runtimeInfo(@Context HttpServletRequest servletRequest, @Context UriInfo uriInfo) {
+ checkPrivilege(servletRequest, JetspeedActions.VIEW);
+ Runtime runtime = Runtime.getRuntime();
+ Map<String,Long> memory = new HashMap<>();
+ memory.put("total", runtime.totalMemory());
+ memory.put("free", runtime.freeMemory());
+ //memory.put("max", runtime.maxMemory());
+ Map<String,Map<String,Long>> result = new HashMap<>();
+ result.put("memory", memory);
+ return result;
+ }
+
+ protected void checkPrivilege(HttpServletRequest servletRequest, String action) {
+ RequestContext requestContext = (RequestContext) servletRequest.getAttribute(RequestContext.REQUEST_PORTALENV);
+ if (securityBehavior != null && !securityBehavior.checkAccess(requestContext, action)) {
+ throw new WebApplicationException(new JetspeedException("Insufficient privilege to access this REST service."));
+ }
+ }
+}
+
Modified: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-restful-services.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-restful-services.xml?rev=1674405&r1=1674404&r2=1674405&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-restful-services.xml (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-restful-services.xml Fri Apr 17 21:11:44 2015
@@ -131,6 +131,10 @@
<meta key="j2:cat" value="default" />
<constructor-arg ref="jaxrsProfilerManagementService"/>
</bean>
+ <bean class="org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider">
+ <meta key="j2:cat" value="default" />
+ <constructor-arg ref="jaxrsStatisticsManagementService"/>
+ </bean>
</list>
</property>
</bean>
@@ -175,4 +179,11 @@
<constructor-arg ref="RolesSecurityBehavior" />
</bean>
+ <!-- Statistics JAX-RS Service -->
+ <bean id="jaxrsStatisticsManagementService" class="org.apache.jetspeed.services.rest.StatisticsManagementService">
+ <meta key="j2:cat" value="default" />
+ <constructor-arg ref="PortalStatistics" />
+ <constructor-arg ref="RolesSecurityBehavior" />
+ </bean>
+
</beans>
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.