You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by da...@apache.org on 2014/04/20 22:04:51 UTC
[3/3] git commit: Rename folder to match artifactId
Rename folder to match artifactId
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/34b900af
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/34b900af
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/34b900af
Branch: refs/heads/master
Commit: 34b900af6bb33cf19b17fc927ce174e32e3fa77e
Parents: f3643fa
Author: Martijn Dashorst <da...@apache.org>
Authored: Sun Apr 20 22:04:55 2014 +0200
Committer: Martijn Dashorst <da...@apache.org>
Committed: Sun Apr 20 22:04:55 2014 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
wicket-objectsizeof-agent/pom.xml | 85 ++++++++++++
.../InstrumentationObjectSizeOfStrategy.java | 133 +++++++++++++++++++
.../util/instrument/ObjectSizeOfAgent.java | 69 ++++++++++
.../src/main/resources/META-INF/MANIFEST.MF | 4 +
wicket-objectsizeof-agent/src/site/site.xml | 24 ++++
.../util/license/ApacheLicenceHeaderTest.java | 34 +++++
.../.settings/org.eclipse.core.resources.prefs | 11 --
.../.settings/org.eclipse.m2e.core.prefs | 5 -
.../.settings/org.eclipse.pde.core.prefs | 3 -
.../.settings/org.eclipse.wst.common.component | 6 -
...rg.eclipse.wst.common.project.facet.core.xml | 5 -
wicket-objectssizeof-agent/pom.xml | 85 ------------
.../InstrumentationObjectSizeOfStrategy.java | 133 -------------------
.../util/instrument/ObjectSizeOfAgent.java | 69 ----------
.../src/main/resources/META-INF/MANIFEST.MF | 4 -
wicket-objectssizeof-agent/src/site/site.xml | 24 ----
.../util/license/ApacheLicenceHeaderTest.java | 34 -----
18 files changed, 350 insertions(+), 380 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0ed0efc..008b757 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,7 +56,7 @@
<module>wicket-auth-roles</module>
<module>wicket-guice</module>
<module>wicket-jmx</module>
- <module>wicket-objectssizeof-agent</module>
+ <module>wicket-objectsizeof-agent</module>
<module>wicket-examples</module>
<module>wicket-experimental</module>
<module>archetypes/quickstart</module>
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectsizeof-agent/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-objectsizeof-agent/pom.xml b/wicket-objectsizeof-agent/pom.xml
new file mode 100644
index 0000000..dd7c3fb
--- /dev/null
+++ b/wicket-objectsizeof-agent/pom.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-parent</artifactId>
+ <version>7.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>wicket-objectsizeof-agent</artifactId>
+ <packaging>jar</packaging>
+ <name>Wicket Objects Sizeof Agent</name>
+ <description>Agent for pluggin in object size measurements using instrumentation</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ org.apache.felix
+ </groupId>
+ <artifactId>
+ maven-bundle-plugin
+ </artifactId>
+ <versionRange>
+ [2.3.7,)
+ </versionRange>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectsizeof-agent/src/main/java/org/apache/wicket/util/instrument/InstrumentationObjectSizeOfStrategy.java
----------------------------------------------------------------------
diff --git a/wicket-objectsizeof-agent/src/main/java/org/apache/wicket/util/instrument/InstrumentationObjectSizeOfStrategy.java b/wicket-objectsizeof-agent/src/main/java/org/apache/wicket/util/instrument/InstrumentationObjectSizeOfStrategy.java
new file mode 100644
index 0000000..a7355fa
--- /dev/null
+++ b/wicket-objectsizeof-agent/src/main/java/org/apache/wicket/util/instrument/InstrumentationObjectSizeOfStrategy.java
@@ -0,0 +1,133 @@
+/*
+ * 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.wicket.util.instrument;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.lang.instrument.Instrumentation;
+
+import org.apache.wicket.core.util.lang.WicketObjects.IObjectSizeOfStrategy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Object size of strategy that is based on instrumentation.
+ *
+ * @author eelcohillenius
+ */
+public class InstrumentationObjectSizeOfStrategy implements IObjectSizeOfStrategy
+{
+
+ private static final Logger LOG = LoggerFactory.getLogger(InstrumentationObjectSizeOfStrategy.class);
+
+ /**
+ * Records the size of an object and it's dependents as if they were serialized but using the
+ * instrumentation API to calculate.
+ */
+ private final class SizeRecodingOuputStream extends ObjectOutputStream
+ {
+
+ private long totalSize = 0;
+
+ /**
+ * Construct.
+ *
+ * @throws IOException
+ */
+ public SizeRecodingOuputStream() throws IOException
+ {
+ super(new OutputStream()
+ {
+
+ @Override
+ public void write(int b) throws IOException
+ {
+ }
+ });
+ enableReplaceObject(true);
+ }
+
+ /**
+ * Gets the calculated size.
+ *
+ * @return
+ */
+ public long getTotalSize()
+ {
+ return totalSize;
+ }
+
+ @Override
+ protected Object replaceObject(Object obj) throws IOException
+ {
+
+ if (obj != null)
+ {
+ totalSize += instrumentation.getObjectSize(obj);
+ }
+
+ return obj;
+ }
+ }
+
+ /**
+ * Instrumentation instance.
+ */
+ private final Instrumentation instrumentation;
+
+ /**
+ * Construct.
+ *
+ * @param instrumentation
+ */
+ public InstrumentationObjectSizeOfStrategy(Instrumentation instrumentation)
+ {
+ this.instrumentation = instrumentation;
+ }
+
+ /**
+ * Calculates full size of object iterating over its hierarchy graph.
+ *
+ * @param obj
+ * object to calculate size of
+ * @return object size
+ *
+ * @see org.apache.wicket.core.util.lang.WicketObjects.IObjectSizeOfStrategy#sizeOf(java.io.Serializable)
+ */
+ @Override
+ public long sizeOf(Serializable obj)
+ {
+ if (obj == null)
+ {
+ return 0;
+ }
+ try
+ {
+ SizeRecodingOuputStream recorder = new SizeRecodingOuputStream();
+ recorder.writeObject(obj);
+ return recorder.getTotalSize();
+ }
+ catch (IOException e)
+ {
+ LOG.error("Error calculating size of object", e);
+ return -1;
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectsizeof-agent/src/main/java/org/apache/wicket/util/instrument/ObjectSizeOfAgent.java
----------------------------------------------------------------------
diff --git a/wicket-objectsizeof-agent/src/main/java/org/apache/wicket/util/instrument/ObjectSizeOfAgent.java b/wicket-objectsizeof-agent/src/main/java/org/apache/wicket/util/instrument/ObjectSizeOfAgent.java
new file mode 100644
index 0000000..474556a
--- /dev/null
+++ b/wicket-objectsizeof-agent/src/main/java/org/apache/wicket/util/instrument/ObjectSizeOfAgent.java
@@ -0,0 +1,69 @@
+/*
+ * 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.wicket.util.instrument;
+
+import java.lang.instrument.Instrumentation;
+
+import org.apache.wicket.core.util.lang.WicketObjects;
+import org.apache.wicket.core.util.lang.WicketObjects.IObjectSizeOfStrategy;
+
+/**
+ * Instrumentation agent for calculating object sizes using Java's instrumentation API. To use it,
+ * have the jar somewhere we you can access it (just having this class on the classpath is not
+ * enough) and startup your application with a -javaagent argument like e.g:
+ * '-javaagent:/mydir/wicket-objectsizeof-agent-1.3-SNAPSHOT.jar'. When the application starts up,
+ * this agent will register an {@link IObjectSizeOfStrategy} at
+ * {@link WicketObjects#setObjectSizeOfStrategy(IObjectSizeOfStrategy)}. Note that this is a static
+ * registration.
+ *
+ * @author eelcohillenius
+ */
+public class ObjectSizeOfAgent
+{
+
+ /**
+ * Initializes agent when it is attached to an already running JVM.
+ *
+ * @param agentArgs
+ * Arguments passed in to the agent
+ * @param instrumentation
+ * The instrumentation class
+ */
+ public static void agentmain(String agentArgs, Instrumentation instrumentation)
+ {
+
+ InstrumentationObjectSizeOfStrategy strategy = new InstrumentationObjectSizeOfStrategy(
+ instrumentation);
+ WicketObjects.setObjectSizeOfStrategy(strategy);
+ }
+
+ /**
+ * Initializes agent before the main function of the application is executed.
+ *
+ * @param agentArgs
+ * Arguments passed in to the agent
+ * @param instrumentation
+ * The instrumentation class
+ */
+ public static void premain(String agentArgs, Instrumentation instrumentation)
+ {
+
+ InstrumentationObjectSizeOfStrategy strategy = new InstrumentationObjectSizeOfStrategy(
+ instrumentation);
+ WicketObjects.setObjectSizeOfStrategy(strategy);
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectsizeof-agent/src/main/resources/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/wicket-objectsizeof-agent/src/main/resources/META-INF/MANIFEST.MF b/wicket-objectsizeof-agent/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..5e589d4
--- /dev/null
+++ b/wicket-objectsizeof-agent/src/main/resources/META-INF/MANIFEST.MF
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Premain-Class: org.apache.wicket.util.instrument.ObjectSizeOfAgent
+Agent-Class: org.apache.wicket.util.instrument.ObjectSizeOfAgent
+
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectsizeof-agent/src/site/site.xml
----------------------------------------------------------------------
diff --git a/wicket-objectsizeof-agent/src/site/site.xml b/wicket-objectsizeof-agent/src/site/site.xml
new file mode 100644
index 0000000..07fbc12
--- /dev/null
+++ b/wicket-objectsizeof-agent/src/site/site.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ 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.
+-->
+<project name="Wicket Objectsizeof Agent">
+ <skin>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-site-skin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </skin>
+</project>
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectsizeof-agent/src/test/wicket/util/license/ApacheLicenceHeaderTest.java
----------------------------------------------------------------------
diff --git a/wicket-objectsizeof-agent/src/test/wicket/util/license/ApacheLicenceHeaderTest.java b/wicket-objectsizeof-agent/src/test/wicket/util/license/ApacheLicenceHeaderTest.java
new file mode 100644
index 0000000..948a495
--- /dev/null
+++ b/wicket-objectsizeof-agent/src/test/wicket/util/license/ApacheLicenceHeaderTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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 wicket.util.license;
+
+/**
+ * Test that the license headers are in place in this project. The tests are run
+ * from {@link ApacheLicenseHeaderTestCase}, but you can add project specific
+ * tests here if needed.
+ *
+ * @author Frank Bille Jensen (frankbille)
+ */
+public class ApacheLicenceHeaderTest extends ApacheLicenseHeaderTestCase {
+
+ /**
+ * Construct.
+ */
+ public ApacheLicenceHeaderTest() {
+ xmlIgnore = new String[] { ".settings" };
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectssizeof-agent/.settings/org.eclipse.core.resources.prefs
----------------------------------------------------------------------
diff --git a/wicket-objectssizeof-agent/.settings/org.eclipse.core.resources.prefs b/wicket-objectssizeof-agent/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index eb4e8cf..0000000
--- a/wicket-objectssizeof-agent/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,11 +0,0 @@
-#Mon Oct 10 10:40:56 EEST 2011
-eclipse.preferences.version=1
-encoding//.deprecations/DEPRECATE_wicket.markup.html.form.FormComponent.inputAsStringArray().xml=utf-8
-encoding//.deprecations/DEPRECATE_wicket.markup.html.list.ListView.setOptimizeItemRemoval(boolean).xml=utf-8
-encoding//.deprecations/DEPRECATE_wicket.markup.html.tree.Tree$TreePathsListView.getOptimizeItemRemoval().xml=utf-8
-encoding//src/java/wicket/Application_bg.properties=UTF-8
-encoding//src/main/java=UTF-8
-encoding//src/main/resources=UTF-8
-encoding//src/test/java=UTF-8
-encoding/<project>=UTF-8
-instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectssizeof-agent/.settings/org.eclipse.m2e.core.prefs
----------------------------------------------------------------------
diff --git a/wicket-objectssizeof-agent/.settings/org.eclipse.m2e.core.prefs b/wicket-objectssizeof-agent/.settings/org.eclipse.m2e.core.prefs
deleted file mode 100644
index 17d5ee05..0000000
--- a/wicket-objectssizeof-agent/.settings/org.eclipse.m2e.core.prefs
+++ /dev/null
@@ -1,5 +0,0 @@
-#Mon Sep 19 12:01:07 PDT 2011
-activeProfiles=
-eclipse.preferences.version=1
-resolveWorkspaceProjects=true
-version=1
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectssizeof-agent/.settings/org.eclipse.pde.core.prefs
----------------------------------------------------------------------
diff --git a/wicket-objectssizeof-agent/.settings/org.eclipse.pde.core.prefs b/wicket-objectssizeof-agent/.settings/org.eclipse.pde.core.prefs
deleted file mode 100644
index 1eb6077..0000000
--- a/wicket-objectssizeof-agent/.settings/org.eclipse.pde.core.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Mon Sep 19 12:02:51 PDT 2011
-BUNDLE_ROOT_PATH=target/classes
-eclipse.preferences.version=1
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectssizeof-agent/.settings/org.eclipse.wst.common.component
----------------------------------------------------------------------
diff --git a/wicket-objectssizeof-agent/.settings/org.eclipse.wst.common.component b/wicket-objectssizeof-agent/.settings/org.eclipse.wst.common.component
deleted file mode 100644
index a299cd5..0000000
--- a/wicket-objectssizeof-agent/.settings/org.eclipse.wst.common.component
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
- <wb-module deploy-name="wicket-core">
- <wb-resource deploy-path="/" source-path="/src/main/java"/>
- <wb-resource deploy-path="/" source-path="/src/main/resources"/>
- </wb-module>
-</project-modules>
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectssizeof-agent/.settings/org.eclipse.wst.common.project.facet.core.xml
----------------------------------------------------------------------
diff --git a/wicket-objectssizeof-agent/.settings/org.eclipse.wst.common.project.facet.core.xml b/wicket-objectssizeof-agent/.settings/org.eclipse.wst.common.project.facet.core.xml
deleted file mode 100644
index c78d932..0000000
--- a/wicket-objectssizeof-agent/.settings/org.eclipse.wst.common.project.facet.core.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<faceted-project>
- <installed facet="java" version="1.6"/>
- <installed facet="jst.utility" version="1.0"/>
-</faceted-project>
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectssizeof-agent/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-objectssizeof-agent/pom.xml b/wicket-objectssizeof-agent/pom.xml
deleted file mode 100644
index dd7c3fb..0000000
--- a/wicket-objectssizeof-agent/pom.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-parent</artifactId>
- <version>7.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <artifactId>wicket-objectsizeof-agent</artifactId>
- <packaging>jar</packaging>
- <name>Wicket Objects Sizeof Agent</name>
- <description>Agent for pluggin in object size measurements using instrumentation</description>
- <dependencies>
- <dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- <pluginManagement>
- <plugins>
- <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>
- org.apache.felix
- </groupId>
- <artifactId>
- maven-bundle-plugin
- </artifactId>
- <versionRange>
- [2.3.7,)
- </versionRange>
- <goals>
- <goal>manifest</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore />
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectssizeof-agent/src/main/java/org/apache/wicket/util/instrument/InstrumentationObjectSizeOfStrategy.java
----------------------------------------------------------------------
diff --git a/wicket-objectssizeof-agent/src/main/java/org/apache/wicket/util/instrument/InstrumentationObjectSizeOfStrategy.java b/wicket-objectssizeof-agent/src/main/java/org/apache/wicket/util/instrument/InstrumentationObjectSizeOfStrategy.java
deleted file mode 100644
index a7355fa..0000000
--- a/wicket-objectssizeof-agent/src/main/java/org/apache/wicket/util/instrument/InstrumentationObjectSizeOfStrategy.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.wicket.util.instrument;
-
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.lang.instrument.Instrumentation;
-
-import org.apache.wicket.core.util.lang.WicketObjects.IObjectSizeOfStrategy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Object size of strategy that is based on instrumentation.
- *
- * @author eelcohillenius
- */
-public class InstrumentationObjectSizeOfStrategy implements IObjectSizeOfStrategy
-{
-
- private static final Logger LOG = LoggerFactory.getLogger(InstrumentationObjectSizeOfStrategy.class);
-
- /**
- * Records the size of an object and it's dependents as if they were serialized but using the
- * instrumentation API to calculate.
- */
- private final class SizeRecodingOuputStream extends ObjectOutputStream
- {
-
- private long totalSize = 0;
-
- /**
- * Construct.
- *
- * @throws IOException
- */
- public SizeRecodingOuputStream() throws IOException
- {
- super(new OutputStream()
- {
-
- @Override
- public void write(int b) throws IOException
- {
- }
- });
- enableReplaceObject(true);
- }
-
- /**
- * Gets the calculated size.
- *
- * @return
- */
- public long getTotalSize()
- {
- return totalSize;
- }
-
- @Override
- protected Object replaceObject(Object obj) throws IOException
- {
-
- if (obj != null)
- {
- totalSize += instrumentation.getObjectSize(obj);
- }
-
- return obj;
- }
- }
-
- /**
- * Instrumentation instance.
- */
- private final Instrumentation instrumentation;
-
- /**
- * Construct.
- *
- * @param instrumentation
- */
- public InstrumentationObjectSizeOfStrategy(Instrumentation instrumentation)
- {
- this.instrumentation = instrumentation;
- }
-
- /**
- * Calculates full size of object iterating over its hierarchy graph.
- *
- * @param obj
- * object to calculate size of
- * @return object size
- *
- * @see org.apache.wicket.core.util.lang.WicketObjects.IObjectSizeOfStrategy#sizeOf(java.io.Serializable)
- */
- @Override
- public long sizeOf(Serializable obj)
- {
- if (obj == null)
- {
- return 0;
- }
- try
- {
- SizeRecodingOuputStream recorder = new SizeRecodingOuputStream();
- recorder.writeObject(obj);
- return recorder.getTotalSize();
- }
- catch (IOException e)
- {
- LOG.error("Error calculating size of object", e);
- return -1;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectssizeof-agent/src/main/java/org/apache/wicket/util/instrument/ObjectSizeOfAgent.java
----------------------------------------------------------------------
diff --git a/wicket-objectssizeof-agent/src/main/java/org/apache/wicket/util/instrument/ObjectSizeOfAgent.java b/wicket-objectssizeof-agent/src/main/java/org/apache/wicket/util/instrument/ObjectSizeOfAgent.java
deleted file mode 100644
index 474556a..0000000
--- a/wicket-objectssizeof-agent/src/main/java/org/apache/wicket/util/instrument/ObjectSizeOfAgent.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.wicket.util.instrument;
-
-import java.lang.instrument.Instrumentation;
-
-import org.apache.wicket.core.util.lang.WicketObjects;
-import org.apache.wicket.core.util.lang.WicketObjects.IObjectSizeOfStrategy;
-
-/**
- * Instrumentation agent for calculating object sizes using Java's instrumentation API. To use it,
- * have the jar somewhere we you can access it (just having this class on the classpath is not
- * enough) and startup your application with a -javaagent argument like e.g:
- * '-javaagent:/mydir/wicket-objectsizeof-agent-1.3-SNAPSHOT.jar'. When the application starts up,
- * this agent will register an {@link IObjectSizeOfStrategy} at
- * {@link WicketObjects#setObjectSizeOfStrategy(IObjectSizeOfStrategy)}. Note that this is a static
- * registration.
- *
- * @author eelcohillenius
- */
-public class ObjectSizeOfAgent
-{
-
- /**
- * Initializes agent when it is attached to an already running JVM.
- *
- * @param agentArgs
- * Arguments passed in to the agent
- * @param instrumentation
- * The instrumentation class
- */
- public static void agentmain(String agentArgs, Instrumentation instrumentation)
- {
-
- InstrumentationObjectSizeOfStrategy strategy = new InstrumentationObjectSizeOfStrategy(
- instrumentation);
- WicketObjects.setObjectSizeOfStrategy(strategy);
- }
-
- /**
- * Initializes agent before the main function of the application is executed.
- *
- * @param agentArgs
- * Arguments passed in to the agent
- * @param instrumentation
- * The instrumentation class
- */
- public static void premain(String agentArgs, Instrumentation instrumentation)
- {
-
- InstrumentationObjectSizeOfStrategy strategy = new InstrumentationObjectSizeOfStrategy(
- instrumentation);
- WicketObjects.setObjectSizeOfStrategy(strategy);
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectssizeof-agent/src/main/resources/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/wicket-objectssizeof-agent/src/main/resources/META-INF/MANIFEST.MF b/wicket-objectssizeof-agent/src/main/resources/META-INF/MANIFEST.MF
deleted file mode 100644
index 5e589d4..0000000
--- a/wicket-objectssizeof-agent/src/main/resources/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,4 +0,0 @@
-Manifest-Version: 1.0
-Premain-Class: org.apache.wicket.util.instrument.ObjectSizeOfAgent
-Agent-Class: org.apache.wicket.util.instrument.ObjectSizeOfAgent
-
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectssizeof-agent/src/site/site.xml
----------------------------------------------------------------------
diff --git a/wicket-objectssizeof-agent/src/site/site.xml b/wicket-objectssizeof-agent/src/site/site.xml
deleted file mode 100644
index 07fbc12..0000000
--- a/wicket-objectssizeof-agent/src/site/site.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- 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.
--->
-<project name="Wicket Objectsizeof Agent">
- <skin>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-site-skin</artifactId>
- <version>1.0-SNAPSHOT</version>
- </skin>
-</project>
http://git-wip-us.apache.org/repos/asf/wicket/blob/34b900af/wicket-objectssizeof-agent/src/test/wicket/util/license/ApacheLicenceHeaderTest.java
----------------------------------------------------------------------
diff --git a/wicket-objectssizeof-agent/src/test/wicket/util/license/ApacheLicenceHeaderTest.java b/wicket-objectssizeof-agent/src/test/wicket/util/license/ApacheLicenceHeaderTest.java
deleted file mode 100644
index 948a495..0000000
--- a/wicket-objectssizeof-agent/src/test/wicket/util/license/ApacheLicenceHeaderTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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 wicket.util.license;
-
-/**
- * Test that the license headers are in place in this project. The tests are run
- * from {@link ApacheLicenseHeaderTestCase}, but you can add project specific
- * tests here if needed.
- *
- * @author Frank Bille Jensen (frankbille)
- */
-public class ApacheLicenceHeaderTest extends ApacheLicenseHeaderTestCase {
-
- /**
- * Construct.
- */
- public ApacheLicenceHeaderTest() {
- xmlIgnore = new String[] { ".settings" };
- }
-}