Skip to content

Commit

Permalink
CacheReturn on RoutingContex#vertx
Browse files Browse the repository at this point in the history
  • Loading branch information
tsegismont committed Jan 24, 2017
1 parent 2fb9b96 commit 1f39d81
Show file tree
Hide file tree
Showing 19 changed files with 316 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.vertx.groovy.serviceproxy.testmodel;
public class TestConnection_GroovyExtension {
public static io.vertx.serviceproxy.testmodel.TestConnection insert(io.vertx.serviceproxy.testmodel.TestConnection j_receiver, java.lang.String name, java.util.Map<String, Object> data, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>> resultHandler) {
io.vertx.lang.groovy.ConversionHelper.wrap(j_receiver.insert(name,
data != null ? io.vertx.lang.groovy.ConversionHelper.toJsonObject(data) : null,
resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>() {
public void handle(io.vertx.core.AsyncResult<java.lang.String> ar) {
resultHandler.handle(ar.map(event -> event));
}
} : null));
return j_receiver;
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@ package io.vertx.kotlin.serviceproxy.testmodel

import io.vertx.serviceproxy.testmodel.TestDataObject

/**
* A function providing a DSL for building [io.vertx.serviceproxy.testmodel.TestDataObject] objects.
*
*
* @param bool
* @param number
* @param string
*
* <p/>
* NOTE: This function has been automatically generated from the [io.vertx.serviceproxy.testmodel.TestDataObject original] using Vert.x codegen.
*/
fun TestDataObject(
bool: Boolean? = null,
bool: Boolean? = null,
number: Int? = null,
string: String? = null): TestDataObject = io.vertx.serviceproxy.testmodel.TestDataObject().apply {

if (bool != null) {
this.isBool = bool
this.setBool(bool)
}

if (number != null) {
this.number = number
this.setNumber(number)
}

if (string != null) {
this.string = string
this.setString(string)
}

}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
moduleName = test-module
moduleName = io.vertx.serviceproxy.testmodel.TestService-module
moduleVersion = 1.0
extensionClasses = io.vertx.groovy.serviceproxy.testmodel.GroovyExtension
staticExtensionClasses = io.vertx.groovy.serviceproxy.testmodel.GroovyStaticExtension
extensionClasses = io.vertx.groovy.serviceproxy.testmodel.TestConnection_GroovyExtension, io.vertx.groovy.serviceproxy.testmodel.TestService_GroovyExtension
staticExtensionClasses =
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
moduleName = io.vertx.ext.web.templ.FreeMarkerTemplateEngine-module
moduleVersion = 1.0
extensionClasses =
staticExtensionClasses =
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
moduleName = io.vertx.ext.web.templ.HandlebarsTemplateEngine-module
moduleVersion = 1.0
extensionClasses =
staticExtensionClasses =
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
moduleName = io.vertx.ext.web.templ.JadeTemplateEngine-module
moduleVersion = 1.0
extensionClasses =
staticExtensionClasses =
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
moduleName = io.vertx.ext.web.templ.MVELTemplateEngine-module
moduleVersion = 1.0
extensionClasses =
staticExtensionClasses =
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
moduleName = io.vertx.ext.web.templ.PebbleTemplateEngine-module
moduleVersion = 1.0
extensionClasses =
staticExtensionClasses =
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
moduleName = io.vertx.ext.web.templ.ThymeleafTemplateEngine-module
moduleVersion = 1.0
extensionClasses =
staticExtensionClasses =
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
moduleName = vertx-web-client-module
moduleName = io.vertx.ext.web.client.WebClient-module
moduleVersion = 1.0
extensionClasses = io.vertx.groovy.ext.web.client.GroovyExtension
staticExtensionClasses = io.vertx.groovy.ext.web.client.GroovyStaticExtension
extensionClasses = io.vertx.groovy.ext.web.client.HttpRequest_GroovyExtension, io.vertx.groovy.ext.web.client.HttpResponse_GroovyExtension
staticExtensionClasses =
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
moduleName = vertx-web-common-module
moduleName = io.vertx.ext.web.codec.BodyCodec-module
moduleVersion = 1.0
extensionClasses = io.vertx.groovy.ext.web.GroovyExtension
staticExtensionClasses = io.vertx.groovy.ext.web.GroovyStaticExtension
extensionClasses =
staticExtensionClasses = io.vertx.groovy.ext.web.codec.BodyCodec_GroovyStaticExtension
11 changes: 5 additions & 6 deletions vertx-web/src/main/java/io/vertx/ext/web/RoutingContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.vertx.codegen.annotations.GenIgnore;
import io.vertx.codegen.annotations.Nullable;
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
Expand All @@ -31,7 +30,6 @@
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.auth.User;
import io.vertx.ext.web.impl.ParsableLanguageValue;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -139,6 +137,7 @@ public interface RoutingContext {
/**
* @return the Vert.x instance associated to the initiating {@link Router} for this context
*/
@CacheReturn
Vertx vertx();

/**
Expand Down Expand Up @@ -292,7 +291,7 @@ public interface RoutingContext {
* @return the most acceptable content type.
*/
@Nullable String getAcceptableContentType();

/**
* The headers:
* <ol>
Expand Down Expand Up @@ -415,7 +414,7 @@ default void reroute(String path) {
@Deprecated
@CacheReturn
List<Locale> acceptableLocales();

/**
* Returns the languages for the current request. The languages are determined from the <code>Accept-Language</code>
* header and sorted on quality.
Expand All @@ -434,7 +433,7 @@ default List<LanguageHeader> acceptableLanguages(){
/**
* Helper to return the user preferred locale. It is the same action as returning the first element of the acceptable
* locales.
*
*
* @deprecated Use {@link #preferredLanguage()} instead
* @return the users preferred locale.
*/
Expand All @@ -443,7 +442,7 @@ default List<LanguageHeader> acceptableLanguages(){
default Locale preferredLocale() {
return preferredLanguage();
}

/**
* Helper to return the user preferred language.
* It is the same action as returning the first element of the acceptable languages.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,62 @@
package io.vertx.kotlin.ext.web.handler.sockjs

import io.vertx.ext.web.handler.sockjs.BridgeOptions

import io.vertx.ext.web.handler.sockjs.PermittedOptions

/**
* A function providing a DSL for building [io.vertx.ext.web.handler.sockjs.BridgeOptions] objects.
*
* Options for configuring the event bus bridge.
*
* @param inboundPermitted
* @param inboundPermitteds
* @param maxAddressLength
* @param maxHandlersPerSocket
* @param outboundPermitted
* @param outboundPermitteds
* @param pingTimeout
* @param replyTimeout
*
* <p/>
* NOTE: This function has been automatically generated from the [io.vertx.ext.web.handler.sockjs.BridgeOptions original] using Vert.x codegen.
*/
fun BridgeOptions(
maxAddressLength: Int? = null,
inboundPermitted: List<io.vertx.ext.web.handler.sockjs.PermittedOptions>? = null,
inboundPermitteds: List<io.vertx.ext.web.handler.sockjs.PermittedOptions>? = null,
maxAddressLength: Int? = null,
maxHandlersPerSocket: Int? = null,
outboundPermitted: List<io.vertx.ext.web.handler.sockjs.PermittedOptions>? = null,
outboundPermitteds: List<io.vertx.ext.web.handler.sockjs.PermittedOptions>? = null,
pingTimeout: Long? = null,
replyTimeout: Long? = null): BridgeOptions = io.vertx.ext.web.handler.sockjs.BridgeOptions().apply {

if (inboundPermitted != null) {
this.setInboundPermitted(inboundPermitted)
}
if (inboundPermitteds != null) {
for (item in inboundPermitteds) {
this.addInboundPermitted(item)
}
}
if (maxAddressLength != null) {
this.maxAddressLength = maxAddressLength
this.setMaxAddressLength(maxAddressLength)
}

if (maxHandlersPerSocket != null) {
this.maxHandlersPerSocket = maxHandlersPerSocket
this.setMaxHandlersPerSocket(maxHandlersPerSocket)
}
if (outboundPermitted != null) {
this.setOutboundPermitted(outboundPermitted)
}
if (outboundPermitteds != null) {
for (item in outboundPermitteds) {
this.addOutboundPermitted(item)
}
}

if (pingTimeout != null) {
this.pingTimeout = pingTimeout
this.setPingTimeout(pingTimeout)
}

if (replyTimeout != null) {
this.replyTimeout = replyTimeout
this.setReplyTimeout(replyTimeout)
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,37 @@ package io.vertx.kotlin.ext.web.handler.sockjs

import io.vertx.ext.web.handler.sockjs.PermittedOptions

/**
* A function providing a DSL for building [io.vertx.ext.web.handler.sockjs.PermittedOptions] objects.
*
* Specify a match to allow for inbound and outbound traffic using the
* [io.vertx.ext.web.handler.sockjs.BridgeOptions].
*
* @param address The exact address the message is being sent to. If you want to allow messages based on an exact address you use this field.
* @param addressRegex A regular expression that will be matched against the address. If you want to allow messages based on a regular expression you use this field. If the [io.vertx.ext.web.handler.sockjs.PermittedOptions] value is specified this will be ignored.
* @param match This allows you to allow messages based on their structure. Any fields in the match must exist in the message with the same values for them to be allowed. This currently only works with JSON messages.
* @param requiredAuthority Declare a specific authority that user must have in order to allow messages
*
* <p/>
* NOTE: This function has been automatically generated from the [io.vertx.ext.web.handler.sockjs.PermittedOptions original] using Vert.x codegen.
*/
fun PermittedOptions(
address: String? = null,
address: String? = null,
addressRegex: String? = null,
match: io.vertx.core.json.JsonObject? = null,
requiredAuthority: String? = null): PermittedOptions = io.vertx.ext.web.handler.sockjs.PermittedOptions().apply {

if (address != null) {
this.address = address
this.setAddress(address)
}

if (addressRegex != null) {
this.addressRegex = addressRegex
this.setAddressRegex(addressRegex)
}

if (match != null) {
this.match = match
this.setMatch(match)
}

if (requiredAuthority != null) {
this.requiredAuthority = requiredAuthority
this.setRequiredAuthority(requiredAuthority)
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,48 @@ package io.vertx.kotlin.ext.web.handler.sockjs

import io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions

/**
* A function providing a DSL for building [io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions] objects.
*
* Options for configuring a SockJS handler
*
* @param disabledTransports
* @param heartbeatInterval
* @param insertJSESSIONID
* @param libraryURL
* @param maxBytesStreaming
* @param sessionTimeout
*
* <p/>
* NOTE: This function has been automatically generated from the [io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions original] using Vert.x codegen.
*/
fun SockJSHandlerOptions(
heartbeatInterval: Long? = null,
disabledTransports: Set<String>? = null,
heartbeatInterval: Long? = null,
insertJSESSIONID: Boolean? = null,
libraryURL: String? = null,
maxBytesStreaming: Int? = null,
sessionTimeout: Long? = null): SockJSHandlerOptions = io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions().apply {

if (disabledTransports != null) {
for (item in disabledTransports) {
this.addDisabledTransport(item)
}
}
if (heartbeatInterval != null) {
this.heartbeatInterval = heartbeatInterval
this.setHeartbeatInterval(heartbeatInterval)
}

if (insertJSESSIONID != null) {
this.isInsertJSESSIONID = insertJSESSIONID
this.setInsertJSESSIONID(insertJSESSIONID)
}

if (libraryURL != null) {
this.libraryURL = libraryURL
this.setLibraryURL(libraryURL)
}

if (maxBytesStreaming != null) {
this.maxBytesStreaming = maxBytesStreaming
this.setMaxBytesStreaming(maxBytesStreaming)
}

if (sessionTimeout != null) {
this.sessionTimeout = sessionTimeout
this.setSessionTimeout(sessionTimeout)
}

}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
moduleName = vertx-web-module
moduleName = io.vertx.ext.web.handler.VirtualHostHandler-module
moduleVersion = 1.0
extensionClasses = io.vertx.groovy.ext.web.GroovyExtension
staticExtensionClasses = io.vertx.groovy.ext.web.GroovyStaticExtension
extensionClasses = io.vertx.groovy.ext.web.handler.sockjs.BridgeEvent_GroovyExtension, io.vertx.groovy.ext.web.handler.OAuth2AuthHandler_GroovyExtension, io.vertx.groovy.ext.web.RoutingContext_GroovyExtension, io.vertx.groovy.ext.web.Session_GroovyExtension, io.vertx.groovy.ext.web.handler.sockjs.SockJSHandler_GroovyExtension
staticExtensionClasses = io.vertx.groovy.ext.web.handler.sockjs.SockJSHandler_GroovyStaticExtension
5 changes: 4 additions & 1 deletion vertx-web/src/main/resources/vertx-web-js/routing_context.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ var RoutingContext = function(j_val) {
this.vertx = function() {
var __args = arguments;
if (__args.length === 0) {
return utils.convReturnVertxGen(Vertx, j_routingContext["vertx()"]());
if (that.cachedvertx == null) {
that.cachedvertx = utils.convReturnVertxGen(Vertx, j_routingContext["vertx()"]());
}
return that.cachedvertx;
} else throw new TypeError('function invoked with invalid arguments');
};

Expand Down
5 changes: 4 additions & 1 deletion vertx-web/src/main/resources/vertx-web/routing_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ def remove(key=nil)
# @return [::Vertx::Vertx] the Vert.x instance associated to the initiating {::VertxWeb::Router} for this context
def vertx
if !block_given?
return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:vertx, []).call(),::Vertx::Vertx)
if @cached_vertx != nil
return @cached_vertx
end
return @cached_vertx = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:vertx, []).call(),::Vertx::Vertx)
end
raise ArgumentError, "Invalid arguments when calling vertx()"
end
Expand Down

0 comments on commit 1f39d81

Please sign in to comment.