Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</parent>
<groupId>net.ftlines.wicket-source</groupId>
<artifactId>wicket-source-parent</artifactId>
<version>1.5.0.7-SNAPSHOT</version>
<version>1.3.7.0-SNAPSHOT</version>
<packaging>pom</packaging>
<description>Wicket-source displays component instantiation location in an html attribute, speeding the modification of existing wicket pages. The only module required for maven dependency in your app is wicket-source itself, although a demo app is included.</description>
<name>Wicket Source With Plugins</name>
Expand Down
38 changes: 25 additions & 13 deletions wicket-source-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
<parent>
<groupId>net.ftlines.wicket-source</groupId>
<artifactId>wicket-source-parent</artifactId>
<version>1.5.0.7-SNAPSHOT</version>
<version>1.3.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.ftlines.wicket-source</groupId>
<artifactId>wicket-source-demo</artifactId>
<packaging>war</packaging>
<name>Wicket Source Demo</name>
<description>Wicket Quick-Start project demonstrating use of Wicket-Source</description>
<properties>
<wicket.version>1.5.0</wicket.version>
<jetty.version>7.5.0.v20110901</jetty.version>
<wicket.version>1.3.7</wicket.version>
<jetty.version>6.1.25</jetty.version>
</properties>
<dependencies>
<!-- Project we're demonstrating -->
Expand All @@ -26,7 +25,7 @@
<!-- WICKET DEPENDENCIES -->
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<artifactId>wicket</artifactId>
<version>${wicket.version}</version>
</dependency>
<dependency>
Expand All @@ -39,12 +38,12 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.2</version>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<version>1.2.14</version>
</dependency>

<!-- JUNIT DEPENDENCY FOR TESTING -->
Expand All @@ -56,12 +55,25 @@
</dependency>

<!-- JETTY DEPENDENCIES FOR TESTING -->
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all-server</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-management</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>


</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.ftlines.wicketsource.demo.BookDataTable.BookDataProvider;

import org.apache.wicket.Component;
import org.apache.wicket.PageParameters;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
Expand All @@ -20,7 +21,6 @@
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;

/**
* The main home page of this application
Expand Down Expand Up @@ -99,7 +99,7 @@ public LinkedTitlePanel(String id, IModel<?> rowModel) {

ExternalLink link = new ExternalLink("link",
new PropertyModel<String>(rowModel, "url"),
new PropertyModel<Book>(rowModel, "title"));
new PropertyModel<String>(rowModel, "title"));
add(link);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,76 +1,49 @@
package net.ftlines.wicketsource.demo;

import org.apache.wicket.util.time.Duration;
import org.eclipse.jetty.http.ssl.SslContextFactory;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.bio.SocketConnector;
import org.eclipse.jetty.server.ssl.SslSocketConnector;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.WebAppContext;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.webapp.WebAppContext;

public class Start {
public static void main(String[] args) throws Exception {
int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

Server server = new Server();
SocketConnector connector = new SocketConnector();

// Set some timeout options to make debugging easier.
connector.setMaxIdleTime(timeout);
connector.setSoLingerTime(-1);
connector.setPort(8080);
server.addConnector(connector);

// check if a keystore for a SSL certificate is available, and
// if so, start a SSL connector on port 8443. By default, the
// quickstart comes with a Apache Wicket Quickstart Certificate
// that expires about half way september 2021. Do not use this
// certificate anywhere important as the passwords are available
// in the source.

Resource keystore = Resource.newClassPathResource("/keystore");
if (keystore != null && keystore.exists()) {
connector.setConfidentialPort(8443);

SslContextFactory factory = new SslContextFactory();
factory.setKeyStoreResource(keystore);
factory.setKeyStorePassword("wicket");
factory.setTrustStore(keystore);
factory.setKeyManagerPassword("wicket");
SslSocketConnector sslConnector = new SslSocketConnector(factory);
sslConnector.setMaxIdleTime(timeout);
sslConnector.setPort(8443);
sslConnector.setAcceptors(4);
server.addConnector(sslConnector);

System.out.println("SSL access to the quickstart has been enabled on port 8443");
System.out.println("You can access the application using SSL on https://localhost:8443");
System.out.println();
}

WebAppContext bb = new WebAppContext();
bb.setServer(server);
bb.setContextPath("/");
bb.setWar("src/main/webapp");

// START JMX SERVER
// MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
// MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
// server.getContainer().addEventListener(mBeanContainer);
// mBeanContainer.start();

server.setHandler(bb);
public class Start {

try {
System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
server.start();
System.in.read();
System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
server.stop();
server.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
public static void main(String[] args) throws Exception {
Server server = new Server();
SocketConnector connector = new SocketConnector();

// Set some timeout options to make debugging easier.
connector.setMaxIdleTime(1000 * 60 * 60);
connector.setSoLingerTime(-1);
connector.setPort(8080);
server.setConnectors(new Connector[] { connector });

WebAppContext bb = new WebAppContext();
bb.setServer(server);
bb.setContextPath("/");
bb.setWar("src/main/webapp");

// START JMX SERVER
// MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
// MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
// server.getContainer().addEventListener(mBeanContainer);
// mBeanContainer.start();

server.addHandler(bb);

try {
System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
server.start();
System.in.read();
System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
// while (System.in.available() == 0) {
// Thread.sleep(5000);
// }
server.stop();
server.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(100);
}
}
}
}
10 changes: 6 additions & 4 deletions wicket-source/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>net.ftlines.wicket-source</groupId>
<artifactId>wicket-source-parent</artifactId>
<version>1.5.0.7-SNAPSHOT</version>
<version>1.3.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>wicket-source</artifactId>
Expand All @@ -20,7 +20,7 @@
</licenses>

<properties>
<wicket.version>1.5.0</wicket.version>
<wicket.version>1.3.7</wicket.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand All @@ -29,7 +29,7 @@
<groupId>org.apache.wicket</groupId>
<artifactId>wicket</artifactId>
<version>${wicket.version}</version>
<type>pom</type>
<type>jar</type>
</dependency>
</dependencies>

Expand All @@ -38,7 +38,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -48,6 +48,7 @@
</execution>
</executions>
</plugin>
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
Expand All @@ -62,6 +63,7 @@
</execution>
</executions>
</plugin>
-->
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@
import org.apache.wicket.application.IComponentOnBeforeRenderListener;

/**
* Sticks the wicket component name into an html attribute on the tag, which
* Sticks the wicket component name into an html attribute on the tag, which
* makes it easier to find using the Firebug or Chrome Dev Tools
* "Inspect Element" menu item.
*
* This outputs more than just container classes (such as panels); it also
* This outputs more than just container classes (such as panels); it also
* tags images, labels, and links. Some of that is noise but some may be useful
* in locating a component in the source.
*
*
* @author Jenny Brown
*
*/
public class AttributeModifyingComponentVisitor implements Serializable, IComponentOnBeforeRenderListener {
private static final long serialVersionUID = 1L;

private final AttributeModifier wicketSourceAttribute;

/**
* Creates a visitor
*/
public AttributeModifyingComponentVisitor() {
wicketSourceAttribute = new AttributeModifier("wicketSource", new SourceModel());
wicketSourceAttribute = new AttributeModifier("wicketSource", true, new SourceModel());
}

/**
Expand All @@ -35,7 +37,7 @@ public void onBeforeRender(Component component)
{
component.add(wicketSourceAttribute);
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
* Notes the creation location of components and saves that metadata in the component metadata area.
* This is the precursor step to using a {@link AttributeModifyingComponentVisitor} for writing out an
* HTML <code>wicketsource="net.simsa.photo.web.MainMenuPanel:35"</code> style of attribute.
*
* This uses a similar approach to line-precise-reporting-on-new-component and is likely to be
*
* This uses a similar approach to line-precise-reporting-on-new-component and is likely to be
* equally slow, so turn it on only in debug/development mode, not production.
*
*
* @author Jenny Brown
*
*/
Expand All @@ -21,24 +21,24 @@ public class AttributeModifyingInstantiationListener implements IComponentInstan
* This is an alternative to Component.CONSTRUCTED_AT_KEY which is package-private and thus internal to wicket.
* If wicket eventually exposes the markup exception from creation time, we can use that directly instead.
*/
static MetaDataKey<InstantiationLocation> CONSTRUCTED_AT_KEY = new MetaDataKey<InstantiationLocation>() {
static MetaDataKey CONSTRUCTED_AT_KEY = new MetaDataKey(InstantiationLocation.class) {
private static final long serialVersionUID = 1L;
};

/**
* Indicates that the component's source location could not be determined,
* probably because this is an internal wicket enclosure or similar
* automatically generated component.
*
*
* @author Jenny Brown
*
*
*/
static class UnsupportedComponentException extends Exception {
public UnsupportedComponentException(String message) {
super(message);
}
}
}

/**
* When a component is instantiated, record the source location as part of its metadata.
*/
Expand All @@ -47,7 +47,7 @@ public void onInstantiation(Component component)
if (component instanceof org.apache.wicket.markup.html.internal.Enclosure) {
return; // nothing to see here; bail out early to save time.
}

try {
component.setMetaData(CONSTRUCTED_AT_KEY, new InstantiationLocation(component));
} catch (UnsupportedComponentException ie) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
* @author Jenny Brown
*
*/
public class SourceModel extends ComponentModel<String>
public class SourceModel extends ComponentModel
{
private static final long serialVersionUID = 1L;

/**
* @return package:file.java:lineNumber from InstantiationLocation.generateSourceLocationAttribute as a String
*/
@Override
protected String getObject(Component component)
{
InstantiationLocation loc = component.getMetaData(AttributeModifyingInstantiationListener.CONSTRUCTED_AT_KEY);
InstantiationLocation loc = (InstantiationLocation) component.getMetaData(AttributeModifyingInstantiationListener.CONSTRUCTED_AT_KEY);
return loc == null ? null : loc.generateSourceLocationAttribute();
}
}
Loading