Skip to content

Commit 0093886

Browse files
committed
new file: .gitignore
new file: nbactions.xml new file: pom.xml new file: src/main/java/com/appdynamics/extension/webdispatcher/webdispatcherExtension/ConfigReader.java new file: src/main/java/com/appdynamics/extension/webdispatcher/webdispatcherExtension/ExtensionController.java new file: src/main/java/com/appdynamics/extension/webdispatcher/webdispatcherExtension/ExtensionLogger.java new file: src/main/java/com/appdynamics/extension/webdispatcher/webdispatcherExtension/WebDispatcherLogRead.java new file: src/main/java/com/appdynamics/extension/webdispatcher/webdispatcherExtension/balancingData.java new file: src/main/resources/config.properties new file: src/main/resources/generate_logs.sh new file: src/main/resources/generate_logs_v2.sh new file: src/main/resources/monitor.xml new file: src/main/resources/read.properties new file: src/main/resources/webDispatcherAIX.sh new file: src/main/resources/webDispatcherLinux.sh new file: src/site/site.xml new file: src/test/java/com/appdynamics/extension/webdispatcher/webdispatcherExtension/AppTest.java modified: .gitignore
0 parents  commit 0093886

22 files changed

+1304
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.classpath

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
4+
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
5+
<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
6+
<classpathentry kind="output" path="target/classes"/>
7+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
8+
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
9+
</classpath>

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target/
2+

.project

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>webdispatcherExtension</name>
4+
<comment>A simple webdispatcherExtension. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
5+
<projects/>
6+
<buildSpec>
7+
<buildCommand>
8+
<name>org.eclipse.jdt.core.javabuilder</name>
9+
</buildCommand>
10+
<buildCommand>
11+
<name>org.eclipse.m2e.core.maven2Builder</name>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
17+
</natures>
18+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
eclipse.preferences.version=1
2+
encoding//src/main/java=UTF-8
3+
encoding//src/test/java=UTF-8
4+
encoding/<project>=UTF-8

.settings/org.eclipse.jdt.core.prefs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
3+
org.eclipse.jdt.core.compiler.compliance=1.7
4+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5+
org.eclipse.jdt.core.compiler.release=disabled
6+
org.eclipse.jdt.core.compiler.source=1.7

.settings/org.eclipse.m2e.core.prefs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1

nbactions.xml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<actions>
3+
<action>
4+
<actionName>CUSTOM-PackagingExtension</actionName>
5+
<displayName>PackagingExtension</displayName>
6+
<goals>
7+
<goal>clean</goal>
8+
<goal>package</goal>
9+
</goals>
10+
</action>
11+
<action>
12+
<actionName>CUSTOM-Final Packaging</actionName>
13+
<displayName>Final Packaging</displayName>
14+
<goals>
15+
<goal>clean</goal>
16+
<goal>install</goal>
17+
</goals>
18+
</action>
19+
</actions>

pom.xml

+231
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.appdynamics.extension.webdispatcher</groupId>
8+
<artifactId>webdispatcherExtension</artifactId>
9+
<version>0.0.1</version>
10+
11+
<name>webdispatcherExtension</name>
12+
<description>A simple webdispatcherExtension.</description>
13+
<!-- FIXME change it to the project's website -->
14+
<url>http://www.example.com</url>
15+
16+
<properties>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
<maven.compiler.source>1.8</maven.compiler.source>
19+
<maven.compiler.target>1.8</maven.compiler.target>
20+
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
21+
<target.dir>${project.build.directory}/WebDispatcher</target.dir>
22+
</properties>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>junit</groupId>
27+
<artifactId>junit</artifactId>
28+
<version>3.8.1</version>
29+
</dependency>
30+
<dependency>
31+
<groupId>com.h2database</groupId>
32+
<artifactId>h2</artifactId>
33+
<version>1.4.190</version>
34+
</dependency>
35+
</dependencies>
36+
37+
<build>
38+
<finalName>${project.artifactId}</finalName>
39+
<plugins>
40+
<plugin>
41+
<groupId>org.apache.maven.plugins</groupId>
42+
<artifactId>maven-dependency-plugin</artifactId>
43+
<version>3.1.1</version>
44+
<executions>
45+
<execution>
46+
<id>copy-dependencies</id>
47+
<phase>package</phase>
48+
<goals>
49+
<goal>copy-dependencies</goal>
50+
</goals>
51+
<configuration>
52+
<excludeArtifactIds>junit</excludeArtifactIds>
53+
<outputDirectory>${project.build.directory}/WebDispatcherMonitor</outputDirectory>
54+
<overWriteReleases>false</overWriteReleases>
55+
<overWriteSnapshots>false</overWriteSnapshots>
56+
<overWriteIfNewer>true</overWriteIfNewer>
57+
</configuration>
58+
</execution>
59+
</executions>
60+
</plugin>
61+
62+
<plugin>
63+
<groupId>org.codehaus.mojo</groupId>
64+
<artifactId>versions-maven-plugin</artifactId>
65+
<version>2.1</version>
66+
</plugin>
67+
<plugin>
68+
<groupId>org.apache.maven.plugins</groupId>
69+
<artifactId>maven-shade-plugin</artifactId>
70+
<version>3.2.1</version>
71+
<configuration>
72+
<createDependencyReducedPom>false</createDependencyReducedPom>
73+
<minimizeJar>true</minimizeJar>
74+
<filters>
75+
<filter>
76+
<artifact>*:*</artifact>
77+
<excludes>
78+
<exclude>META-INF/*.SF</exclude>
79+
<exclude>META-INF/*.DSA</exclude>
80+
<exclude>META-INF/*.RSA</exclude>
81+
</excludes>
82+
</filter>
83+
<!--<filter>
84+
<artifact>com.h2database:h2</artifact>
85+
<includes>
86+
<include>**</include>
87+
</includes>
88+
</filter>-->
89+
<filter>
90+
<artifact>junit:junit</artifact>
91+
<excludes>
92+
<exclude>**</exclude>
93+
</excludes>
94+
</filter>
95+
</filters>
96+
</configuration>
97+
<executions>
98+
<execution>
99+
<phase>package</phase>
100+
<goals>
101+
<goal>shade</goal>
102+
</goals>
103+
<configuration>
104+
<transformers>
105+
<transformer
106+
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
107+
<transformer
108+
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
109+
<manifestEntries>
110+
<Implementation-Title>WebDispatcher monitor v${project.version} Build Date ${maven.build.timestamp}</Implementation-Title>
111+
<Main-Class>com.appdynamics.extension.webdispatcher.webdispatcherExtension.ExtensionController</Main-Class>
112+
<Class-Path>h2-1.4.190.jar</Class-Path>
113+
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
114+
<X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
115+
</manifestEntries>
116+
</transformer>
117+
</transformers>
118+
</configuration>
119+
</execution>
120+
</executions>
121+
</plugin>
122+
<plugin>
123+
<groupId>org.apache.maven.plugins</groupId>
124+
<artifactId>maven-antrun-plugin</artifactId>
125+
<version>1.6</version>
126+
<executions>
127+
<execution>
128+
<!--<id>install</id>-->
129+
<phase>package</phase>
130+
<!--<goals>
131+
<goal>install</goal>
132+
</goals>-->
133+
<configuration>
134+
<target>
135+
<mkdir dir="${project.build.directory}/WebDispatcherMonitor" />
136+
<copy todir="${project.build.directory}/WebDispatcherMonitor">
137+
<fileset dir="src/main/resources" includes="config.properties" />
138+
<fileset dir="src/main/resources" includes="read.properties" />
139+
<fileset dir="src/main/resources" includes="monitor.xml" />
140+
<fileset dir="src/main/resources" includes="webDispatcherAIX.sh" />
141+
<fileset dir="src/main/resources" includes="webDispatcherLinux.sh" />
142+
143+
</copy>
144+
<copy todir="${project.build.directory}/WebDispatcherMonitor">
145+
<fileset dir="${project.build.directory}"
146+
includes="${project.artifactId}.${project.packaging}" />
147+
</copy>
148+
<zip destfile="${project.build.directory}/WebDispatcherMonitor-${project.version}.zip">
149+
<zipfileset dir="${project.build.directory}/WebDispatcherMonitor" filemode="755"
150+
prefix="WebDispatcherMonitor/" />
151+
</zip>
152+
<!--<delete dir="${project.build.directory}/WebDispatcherMonitor" />-->
153+
</target>
154+
</configuration>
155+
<goals>
156+
<goal>run</goal>
157+
</goals>
158+
</execution>
159+
</executions>
160+
</plugin>
161+
</plugins>
162+
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
163+
<plugins>
164+
<plugin>
165+
<artifactId>maven-resources-plugin</artifactId>
166+
<version>3.1.0</version>
167+
<executions>
168+
<execution>
169+
<id>copy-resources</id>
170+
<!-- here the phase you need -->
171+
<phase>package</phase>
172+
<goals>
173+
<goal>copy-resources</goal>
174+
</goals>
175+
<configuration>
176+
<outputDirectory>${basedir}/target/</outputDirectory>
177+
<resources>
178+
<resource>
179+
<directory>src/main/resources/</directory>
180+
<filtering>true</filtering>
181+
</resource>
182+
</resources>
183+
</configuration>
184+
</execution>
185+
</executions>
186+
</plugin>
187+
<plugin>
188+
<artifactId>maven-clean-plugin</artifactId>
189+
<version>3.1.0</version>
190+
</plugin>
191+
<plugin>
192+
<artifactId>maven-site-plugin</artifactId>
193+
<version>3.7.1</version>
194+
</plugin>
195+
<plugin>
196+
<artifactId>maven-project-info-reports-plugin</artifactId>
197+
<version>3.0.0</version>
198+
</plugin>
199+
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
200+
<plugin>
201+
<artifactId>maven-compiler-plugin</artifactId>
202+
<version>3.8.0</version>
203+
</plugin>
204+
<plugin>
205+
<artifactId>maven-surefire-plugin</artifactId>
206+
<version>2.22.1</version>
207+
</plugin>
208+
<plugin>
209+
<artifactId>maven-jar-plugin</artifactId>
210+
<version>3.0.2</version>
211+
</plugin>
212+
<plugin>
213+
<artifactId>maven-install-plugin</artifactId>
214+
<version>2.5.2</version>
215+
</plugin>
216+
<plugin>
217+
<artifactId>maven-deploy-plugin</artifactId>
218+
<version>2.8.2</version>
219+
</plugin>
220+
</plugins>
221+
</pluginManagement>
222+
</build>
223+
224+
<reporting>
225+
<plugins>
226+
<plugin>
227+
<artifactId>maven-project-info-reports-plugin</artifactId>
228+
</plugin>
229+
</plugins>
230+
</reporting>
231+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.appdynamics.extension.webdispatcher.webdispatcherExtension;
2+
3+
import java.io.FileNotFoundException;
4+
import java.io.File;
5+
import java.io.FileInputStream;
6+
import java.io.FileOutputStream;
7+
import java.io.IOException;
8+
import java.io.InputStream;
9+
import java.io.OutputStream;
10+
import java.util.Properties;
11+
import java.util.logging.Level;
12+
import java.util.logging.Logger;
13+
14+
public class ConfigReader {
15+
String result = "";
16+
InputStream inputStream;
17+
Logger LOGGER;
18+
19+
public ConfigReader(){
20+
LOGGER = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
21+
}
22+
public Properties getPropValues(String propFileName) throws IOException {
23+
24+
Properties prop = new Properties();
25+
26+
try {
27+
File configFile = new File(propFileName);
28+
LOGGER.log(Level.WARNING, "Config file path: {0}", configFile.getCanonicalPath());
29+
inputStream = new FileInputStream(configFile);
30+
//inputStream = getClass().getClassLoader().getResourceAsStream(propFileName);
31+
//getClass().getClassLoader().getResourceAsStream(propFileName).
32+
if (inputStream != null) {
33+
prop.load(inputStream);
34+
} else {
35+
throw new FileNotFoundException("Property file '" + propFileName + "' not found in the classpath");
36+
}
37+
} catch (Exception e) {
38+
LOGGER.log(Level.WARNING, "Exception reading configuration file: {0}", e);
39+
} finally {
40+
inputStream.close();
41+
}
42+
return prop;
43+
}
44+
45+
public boolean setPropValues(String propFileName, Properties properties) throws IOException{
46+
boolean result=false;
47+
OutputStream outputStream;
48+
try {
49+
File configFile = new File(propFileName);
50+
LOGGER.log(Level.WARNING, "Config file path: {0}", configFile.getCanonicalPath());
51+
outputStream = new FileOutputStream(configFile);
52+
outputStream.write(properties.toString().replace("{", "").replace("}", "").replace(", ",System.getProperty("line.separator")).getBytes());
53+
outputStream.flush();
54+
outputStream.close();
55+
result=true;
56+
} catch (Exception e) {
57+
System.out.println("Exception writing configuration file: " + e);
58+
LOGGER.log(Level.WARNING, "Exception writing configuration file: {0}", e);
59+
}
60+
61+
return result;
62+
}
63+
}

0 commit comments

Comments
 (0)