Skip to content

Commit

Permalink
OPEN - #1: Update to tapestry 5.4
Browse files Browse the repository at this point in the history
- rewrite the ConversationModerator.js as a javascript module
- remove RequestHandlerDecorator and refactor to an inline aspect
- update dependencies and change metadata to point to github in pom.xml
- fix tests and clean up
  • Loading branch information
kaosko committed Jan 21, 2016
1 parent 32d1e7f commit cbb14f3
Show file tree
Hide file tree
Showing 14 changed files with 303 additions and 417 deletions.
94 changes: 28 additions & 66 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@
<artifactId>tapestry-conversations</artifactId>
<name>Tynamo Conversations</name>
<packaging>jar</packaging>
<version>0.1.3-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<description>
An implementation of conversation-within-page concept for Tapestry 5
</description>

<parent>
<groupId>org.tynamo</groupId>
<artifactId>tynamo-parent</artifactId>
<version>0.0.6</version>
<version>0.2.2</version>
</parent>
<properties>
<tapestry-release-version>5.2.2</tapestry-release-version>
<tapestry-release-version>5.4.0</tapestry-release-version>
</properties>

<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-core</artifactId>
Expand All @@ -27,8 +33,8 @@
</dependency>
<dependency>
<groupId>org.tynamo</groupId>
<artifactId>tapestry-model-test</artifactId>
<version>0.1.0</version>
<artifactId>tynamo-test</artifactId>
<version>0.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -40,15 +46,6 @@
</dependency>
</dependencies>


<distributionManagement>
<site>
<id>tynamo-site</id>
<!-- Note the url. Only static files deployed in /constant/ can be decorated by Unity -->
<url>dav:https://dav.codehaus.org/tynamo/constant/sites/tapestry-conversations</url>
</site>
</distributionManagement>

<build>
<resources>
<resource>
Expand All @@ -59,7 +56,7 @@
<filtering>true</filtering>
</resource>
</resources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -72,69 +69,33 @@
</archive>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
<configuration>
<!-- I couldn't get either this or filter tag to work properly -->
<component>13675</component>
<onlyCurrentVersion>true</onlyCurrentVersion>
<statusIds>Resolved, Closed</statusIds>

<template>release-announcement.vm</template>
<!-- Unbelievable, but changes plugin requires to keep the announcement in src/main/resources directory.. It doesn't accept e.g. ../ -->
<templateDirectory>announcements</templateDirectory>
<smtpHost>localhost</smtpHost>
<fromDeveloperId>kaosko</fromDeveloperId>
<mailSender>
<name>Tynamo Dev Team</name>
<email>[email protected]</email>
</mailSender>
<toAddresses>
<!-- Codehaus just doesn't accept me sending email with this mailSender from local sendmail
to the list, so just send to my own email for now
<toAddress>[email protected]</toAddress>
<toAddress>[email protected]</toAddress>
<toAddress>[email protected]</toAddress>
-->
<toAddress>[email protected]</toAddress>
</toAddresses>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<!-- send announcement email automatically -->
<!-- Disable changes plugin for now since need to figure out how to integrate with Jira version numbers
(conversations-0.1.0 rather than just 0.1.0)
<goals>deploy site-deploy changes:announcement-mail -DgenerateJiraAnnouncement=true</goals>
-->
<goals>deploy site-deploy</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Reloading needs to be disabled because the constructor of Conversation is package-private
<!-- Reloading needs to be disabled because the constructor of Conversation is package-private
but I don't want to use .preventReloading() since that would make the module T5.2 specific
-->
<argLine>-Dtapestry.service-reloading-enabled=false</argLine>
<redirectTestOutputToFile>false</redirectTestOutputToFile>
</configuration>
</plugin>
<!-- needed only for testing -->
<!-- run the test app in the port 8180 with "mvn jetty:run" -->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.4.v20141103</version>
<configuration>
<contextPath>/</contextPath>
<useTestClasspath>true</useTestClasspath>
<webAppSourceDirectory>${basedir}/src/test/webapp</webAppSourceDirectory>
<systemProperties>
<systemProperty>
<name>jetty.port</name>
<value>8180</value>
</systemProperty>
<systemProperty>
<name>tapestry.compress-whitespace</name>
<value>false</value>
Expand All @@ -146,12 +107,13 @@
</systemProperties>
</configuration>
</plugin>
</plugins>
</plugins>
</build>

<scm>
<connection>scm:svn:http://svn.codehaus.org/tynamo/trunk/tapestry-conversations</connection>
<developerConnection>scm:svn:https://svn.codehaus.org/tynamo/trunk/tapestry-conversations</developerConnection>
<url>http://svn.tynamo.codehaus.org/tynamo/trunk/tapestry-conversations</url>
<scm>
<connection>scm:git:[email protected]:tynamo/tapestry-conversations.git</connection>
<developerConnection>scm:git:[email protected]:tynamo/tapestry-conversations.git</developerConnection>
<url>https://github.com/tynamo/tapestry-conversations</url>
<tag>HEAD</tag>
</scm>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.Link;
import org.apache.tapestry5.RenderSupport;
import org.apache.tapestry5.annotations.AfterRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
import org.tynamo.conversations.ConversationModeratorAware;
import org.tynamo.conversations.services.ConversationManager;

@IncludeJavaScriptLibrary("ConversationModerator.js")
public class ConversationModerator {
private static final String eventName = "checkidle";

@Inject
private ComponentResources componentResources;

@Environmental
private RenderSupport renderSupport;
@Inject
private JavaScriptSupport javaScriptSupport;

@Parameter("15")
private int idleCheck;
Expand Down Expand Up @@ -98,8 +95,12 @@ public void afterRender() {
baseURI = baseURI.substring(0, index + 1);

// System.out.println("Active conversation is " + conversationManager.getActiveConversation());
renderSupport.addScript(String.format("%s = new ConversationModerator('%s', '%s', %s, true, %s, %s, '%s', '%s');", componentResources.getId(), baseURI,
defaultURIparameters, keepAlive, idleCheck, warnBefore, warnBeforeHandler, endedHandler));
javaScriptSupport.require("conversation/ConversationModerator").with(componentResources.getId(), baseURI,
defaultURIparameters, keepAlive, idleCheck, warnBefore, warnBeforeHandler, endedHandler);

// renderSupport.addScript(String.format("%s = new ConversationModerator('%s', '%s', %s, true, %s, %s, '%s', '%s');",
// componentResources.getId(), baseURI,
// defaultURIparameters, keepAlive, idleCheck, warnBefore, warnBeforeHandler, endedHandler));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public boolean isUsingCookie() {
return usingCookie;
}

Conversation(String sessionId, String id, String pageName, Integer maxIdleSeconds, Integer maxConversationLengthSeconds, boolean usingCookie) {
public Conversation(String sessionId, String id, String pageName, Integer maxIdleSeconds,
Integer maxConversationLengthSeconds, boolean usingCookie) {
if (maxIdleSeconds == null) maxIdleSeconds = 0;
if (maxConversationLengthSeconds == null) maxConversationLengthSeconds = 0;
this.sessionId = sessionId;
Expand All @@ -42,7 +43,7 @@ public String getId() {
public String getSessionId() {
return sessionId;
}

public String getPageName() {
return pageName;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,62 @@
package org.tynamo.conversations.services;

import java.io.IOException;
import java.util.Properties;
import java.lang.reflect.Method;

import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.ioc.Configuration;
import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.MethodAdviceReceiver;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.Contribute;
import org.apache.tapestry5.ioc.annotations.Match;
import org.apache.tapestry5.ioc.annotations.Order;
import org.apache.tapestry5.ioc.services.ApplicationDefaults;
import org.apache.tapestry5.ioc.services.SymbolProvider;
import org.apache.tapestry5.plastic.MethodAdvice;
import org.apache.tapestry5.plastic.MethodInvocation;
import org.apache.tapestry5.services.LibraryMapping;
import org.apache.tapestry5.services.PersistentFieldStrategy;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.RequestGlobals;

public class ConversationModule {
private static final String version;
static {
Properties moduleProperties = new Properties();
String aVersion = "unversioned";
try {
moduleProperties.load(ConversationModule.class.getResourceAsStream("module.properties"));
aVersion = moduleProperties.getProperty("module.version");
} catch (IOException e) {
// ignore
}
version = aVersion;
public static void bind(ServiceBinder binder) {
binder.bind(ConversationManager.class);
}

public static void bind(ServiceBinder binder) {
binder.bind(RequestHandlerDecorator.class, RequestHandlerDecoratorImpl.class);
binder.bind(ConversationManager.class, ConversationManagerImpl.class);
@Contribute(SymbolProvider.class)
@ApplicationDefaults
public static void setApplicationDefaults(MappedConfiguration<String, Object> configuration) {
configuration.add(SymbolConstants.JAVASCRIPT_INFRASTRUCTURE_PROVIDER, "jquery");
}

public static void contributeComponentClassResolver(Configuration<LibraryMapping> configuration) {
configuration.add(new LibraryMapping("conversation", "org.tynamo.conversations"));
}

public static void contributeClasspathAssetAliasManager(MappedConfiguration<String, String> configuration) {
configuration.add("tynamo-conversations-" + version, "org/tynamo/conversations");
}

public static void contributePersistentFieldManager(MappedConfiguration<String, PersistentFieldStrategy> configuration, RequestGlobals requestGlobals,
Request request, ConversationManager conversationManager) {
configuration.add("conversation", new ConversationalPersistentFieldStrategy(request, conversationManager));
}

public static <T> T decorateComponentRequestHandler(Class<T> serviceInterface, T delegate, RequestHandlerDecorator decorator) {
return decorator.build(serviceInterface, delegate);
// public static <T> T decorateComponentRequestHandler(Class<T> serviceInterface, T delegate, RequestHandlerDecorator decorator) {
// return decorator.build(serviceInterface, delegate);
// }

@Match("ComponentRequestHandler")
@Order("before:*")
public static void adviseComponentRequestHandler(final MethodAdviceReceiver receiver,
final ConversationManager conversationManager) {
MethodAdvice advice = new MethodAdvice() {
public void advise(MethodInvocation invocation) {
conversationManager.activateConversation(invocation.getParameter(0));
invocation.proceed();
}
};

for (Method method : receiver.getInterface().getMethods())
receiver.adviseMethod(method, advice);

}

}

This file was deleted.

This file was deleted.

Loading

0 comments on commit cbb14f3

Please sign in to comment.