1 package org.apache.maven.archiva.web.action.admin;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.maven.archiva.repository.scanner.RepositoryScanner;
23 import org.apache.maven.archiva.security.ArchivaRoleConstants;
24 import org.apache.maven.archiva.web.action.PlexusActionSupport;
25 import org.codehaus.plexus.cache.Cache;
26 import org.codehaus.plexus.redback.rbac.Resource;
27 import org.codehaus.plexus.taskqueue.TaskQueue;
28 import org.codehaus.redback.integration.interceptor.SecureAction;
29 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
30 import org.codehaus.redback.integration.interceptor.SecureActionException;
35 * Shows system status information for the administrator.
38 * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="systemStatus" instantiation-strategy="per-lookup"
40 public class SystemStatusAction
41 extends PlexusActionSupport
42 implements SecureAction
45 * @plexus.requirement role="org.codehaus.plexus.taskqueue.TaskQueue"
47 private Map<String,TaskQueue> queues;
50 * @plexus.requirement role="org.codehaus.plexus.cache.Cache"
52 private Map<String,Cache> caches;
57 private RepositoryScanner scanner;
59 private String memoryStatus;
61 public SecureActionBundle getSecureActionBundle()
62 throws SecureActionException
64 SecureActionBundle bundle = new SecureActionBundle();
66 bundle.setRequiresAuthentication( true );
67 bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
72 public String execute()
74 Runtime runtime = Runtime.getRuntime();
76 long total = runtime.totalMemory();
77 long used = total - runtime.freeMemory();
78 long max = runtime.maxMemory();
79 memoryStatus = formatMemory(used) + "/" + formatMemory(total) + " (Max: " + formatMemory(max) + ")";
84 private static String formatMemory( long l )
86 return l / ( 1024 * 1024 ) + "M";
89 public String getMemoryStatus()
94 public RepositoryScanner getScanner()
99 public Map<String, Cache> getCaches()
104 public Map<String, TaskQueue> getQueues()