Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d7a089

Browse files
committed
Initial commit. Bare bones.
0 parents  commit 4d7a089

File tree

130 files changed

+14256
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+14256
-0
lines changed

agent/core/pom.xml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.jolokia</groupId>
8+
<artifactId>jolokia-core</artifactId>
9+
<version>0.80-SNAPSHOT</version>
10+
<packaging>jar</packaging>
11+
<name>jolokia-core</name>
12+
<description>jar file containing servlet and helper classes</description>
13+
14+
<parent>
15+
<groupId>org.jolokia</groupId>
16+
<artifactId>jolokia-agent-parent</artifactId>
17+
<version>0.80-SNAPSHOT</version>
18+
<relativePath>../pom.xml</relativePath>
19+
</parent>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>com.googlecode.json-simple</groupId>
24+
<artifactId>json-simple</artifactId>
25+
</dependency>
26+
27+
<dependency>
28+
<groupId>javax.servlet</groupId>
29+
<artifactId>servlet-api</artifactId>
30+
<scope>provided</scope>
31+
</dependency>
32+
33+
<dependency>
34+
<groupId>org.testng</groupId>
35+
<artifactId>testng</artifactId>
36+
<scope>test</scope>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>org.easymock</groupId>
41+
<artifactId>easymock</artifactId>
42+
<scope>test</scope>
43+
</dependency>
44+
45+
<dependency>
46+
<groupId>org.easymock</groupId>
47+
<artifactId>easymockclassextension</artifactId>
48+
<scope>test</scope>
49+
</dependency>
50+
51+
</dependencies>
52+
53+
</project>
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
package org.jolokia;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
/*
7+
* jmx4perl - WAR Agent for exporting JMX via JSON
8+
*
9+
* Copyright (C) 2009 Roland Huß, [email protected]
10+
*
11+
* This program is free software; you can redistribute it and/or
12+
* modify it under the terms of the GNU General Public License
13+
* as published by the Free Software Foundation; either version 2
14+
* of the License, or (at your option) any later version.
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU General Public License
22+
* along with this program; if not, write to the Free Software
23+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24+
*
25+
* A commercial license is available as well. Please contact [email protected] for
26+
* further details.
27+
*/
28+
29+
/**
30+
* @author roland
31+
* @since Jan 1, 2010
32+
*/
33+
public enum ConfigKey {
34+
35+
// Maximum number of history entries to keep
36+
HISTORY_MAX_ENTRIES("historyMaxEntries","10"),
37+
38+
// Whether debug is switched on or not
39+
DEBUG("debug","false"),
40+
41+
// Maximum number of debug entries to hold
42+
DEBUG_MAX_ENTRIES("debugMaxEntries","100"),
43+
44+
// Dispatcher to use
45+
DISPATCHER_CLASSES("dispatcherClasses"),
46+
47+
// Maximum traversal depth for serialization of complex objects.
48+
MAX_DEPTH("maxDepth",null),
49+
50+
// Maximum size of collections returned during serialization.
51+
// If larger, the collection is truncated
52+
MAX_COLLECTION_SIZE("maxCollectionSize",null),
53+
54+
// Maximum number of objects returned by serialization
55+
MAX_OBJECTS("maxObjects",null),
56+
57+
// Context used for agent, used e.g. in the OSGi activator
58+
// (but not for the servlet, this is done in web.xml)
59+
AGENT_CONTEXT("agentContext","/jolokia"),
60+
61+
// User and password for authentication purposes.
62+
USER("user"),
63+
PASSWORD("password"),
64+
65+
// Runtime configuration (i.e. must come in with a request)
66+
// for ignoring errors during JMX operations and JSON serialization.
67+
// This works only for certain operations like pattern reads.
68+
IGNORE_ERRORS("ignoreErrors"),
69+
70+
// Optional domain name for registering own MBeans
71+
MBEAN_QUALIFIER("mbeanQualifier");
72+
73+
private String key;
74+
private String defaultValue;
75+
private static Map<String, ConfigKey> keyByName;
76+
77+
// Build up internal reverse map
78+
static {
79+
keyByName = new HashMap<String, ConfigKey>();
80+
for (ConfigKey ck : ConfigKey.values()) {
81+
keyByName.put(ck.getKeyValue(),ck);
82+
}
83+
}
84+
85+
ConfigKey(String pValue) {
86+
this(pValue,null);
87+
}
88+
89+
ConfigKey(String pValue, String pDefault) {
90+
key = pValue;
91+
defaultValue = pDefault;
92+
}
93+
94+
@Override
95+
public String toString() {
96+
return key;
97+
}
98+
99+
public static ConfigKey getByKey(String pKeyS) {
100+
return keyByName.get(pKeyS);
101+
}
102+
103+
public String getKeyValue() {
104+
return key;
105+
}
106+
107+
public String getDefaultValue() {
108+
return defaultValue;
109+
}
110+
111+
// Extract value from map, including a default value if
112+
// value is not set
113+
public String getValue(Map<ConfigKey, String> pConfig) {
114+
String value = pConfig.get(this);
115+
if (value == null) {
116+
value = this.getDefaultValue();
117+
}
118+
return value;
119+
}
120+
121+
// Extract config options from a given map
122+
public static Map<ConfigKey,String> extractConfig(Map<String,String> pMap) {
123+
Map<ConfigKey,String> ret = new HashMap<ConfigKey, String>();
124+
for (ConfigKey c : ConfigKey.values()) {
125+
String value = pMap.get(c.getKeyValue());
126+
if (value != null) {
127+
ret.put(c,value);
128+
}
129+
}
130+
return ret;
131+
}
132+
}

0 commit comments

Comments
 (0)