GVKun编程网logo

Vert.x Blueprint 系列教程(二) | Vert.x Kue 教程(Web部分)(vertx教程视频)

16

本文将带您了解关于Vert.xBlueprint系列教程(二)|Vert.xKue教程的新内容,同时我们还将为您解释Web部分的相关知识,另外,我们还将为您提供关于asp.netdevelopment

本文将带您了解关于Vert.x Blueprint 系列教程(二) | Vert.x Kue 教程的新内容,同时我们还将为您解释Web部分的相关知识,另外,我们还将为您提供关于asp.net development web server dynamic port numbering problem、blueprint-css – 如何使用BlueprintCSS将div居中?、BlueprintNativeEvent 需要注意的地方、com.intellij.util.xml.converters.values.ClassValueConverter的实例源码的实用信息。

本文目录一览:

Vert.x Blueprint 系列教程(二) | Vert.x Kue 教程(Web部分)(vertx教程视频)

Vert.x Blueprint 系列教程(二) | Vert.x Kue 教程(Web部分)(vertx教程视频)

上部分蓝图教程中我们一起探索了如何用Vert.x开发一个基于消息的应用。在这部分教程中,我们将粗略地探索一下kue-http模块的实现。

Vert.x Kue REST API

kue-http模块中只有一个类KueHttpVerticle,作为整个REST API以及UI服务的实现。对REST API部分来说,如果看过我们之前的 Vert.x 蓝图 | 待办事项服务开发教程 的话,你应该对这一部分非常熟悉了,因此这里我们就不详细解释了。有关使用Vert.x Web实现REST API的教程可参考 Vert.x 蓝图 | 待办事项服务开发教程。

将Kue UI与Vert.x Web进行适配

除了REST API之外,我们还给Vert.x Kue提供了一个用户界面。我们复用了Automattic/Kue的用户界面所以我们就不用写前端代码了(部分API有变动的地方我已进行了修改)。我们只需要将前端代码与Vert.x Web适配即可。

首先,前端的代码都属于静态资源,因此我们需要配置路由来允许访问静态资源:

router.route().handler(StaticHandler.create(root));

这样我们就可以直接访问静态资源咯~

注意到Kue UI使用了Jade(最近貌似改名叫Pug了)作为模板引擎,因此我们需要一个Jade模板解析器。好在Vert.x Web提供了一个Jade模板解析的实现: io.vertx:vertx-web-templ-jade,所以我们可以利用这个实现来渲染UI。首先在类中定义一个JadeTemplateEngine并在start方法中初始化:

engine = JadeTemplateEngine.create();

然后我们就可以写一个处理器方法来根据不同的任务状态来渲染UI:

private void render(RoutingContext context, String state) {
  final String uiPath = "webroot/views/job/list.jade"; // (1)
  String title = config().getString("kue.ui.title", "Vert.x Kue");
  kue.getAllTypes()
    .setHandler(resultHandler(context, r -> {
      context.put("state", state) // (2)
        .put("types", r)
        .put("title", title);
      engine.render(context, uiPath, res -> { // (3)
        if (res.succeeded()) {
          context.response()
            .putHeader("content-type", "text/html") // (4)
            .end(res.result());
        } else {
          context.fail(res.cause());
        }
      });
    }));
}

首先我们需要给渲染引擎指定我们前端代码的地址 (1)。然后我们从Redis中获取其中所有的任务类型,然后向解析器context中添加任务状态、网页标题、任务类型等信息供渲染器渲染使用 (2)。接着我们就可以调用engine.render(context, path, handler)方法进行渲染 (3)。如果渲染成功,我们将页面写入HTTP Response (4)。

现在我们可以利用render方法去实现其它的路由函数了:

private void handleUIActive(RoutingContext context) {
  render(context, "active");
}

然后我们给它绑个路由就可以了:

router.route(KUE_UI_ACTIVE).handler(this::handleUIActive);

是不是非常方便呢?不仅如此,Vert.x Web还提供了其它各种模板引擎的支持,比如 FreeMaker, Pebble 以及 Thymeleaf 3。如果感兴趣的话,你可以查阅官方文档来获取详细的使用指南。

展示时间!

是不是等不及要看UI长啥样了?现在我们就来展示一下!首先构建项目:

gradle build

kue-http需要kue-core运行着(因为kue-core里注册了Event Bus服务),因此我们先运行kue-core,再运行kue-http。不要忘记运行Redis:

redis-server
java -jar kue-core/build/libs/vertx-blueprint-kue-core.jar -cluster -ha -conf config/config.json
java -jar kue-http/build/libs/vertx-blueprint-kue-http.jar -cluster -ha -conf config/config.json

为了更好地观察任务处理的流程,我们再运行一个示例:

java -jar kue-example/build/libs/vertx-blueprint-kue-example.jar -cluster -ha -conf config/config.json

好啦!现在在浏览器中访问http://localhost:8080,我们的Kue UI就呈现在我们眼前啦!

Vert.x Kue UI


My Blog: 「千载弦歌,芳华如梦」 - sczyh30''s blog

asp.net development web server dynamic port numbering problem

asp.net development web server dynamic port numbering problem

The problem 

I had this problem in Visual Studio 2005 and Now I have it in Visual Web Developer 2008 express edition where when debugging a web application using the development web server the dynamic port number used by the server didn't match what Visual Studio had used for the web browser. It was always wrong and normally out by two or three port numbers.

For example the cassini web development server starts and I can see in the notification area what port number it uses

visual studio web server port

However the web browser started by Visual studio looks like this


Clearly that isn't going to work.

The Solution

I managed to track down the problem to my firewall software part of the ESET Smart Security Suite. Now, I am pretty sure that when I was using Visual Studio 2005 and had the problem that I was using either McAfee, norton/Symantec or possibly even the Outpost firewall software. My solution won't work if you aren't using Eset but hopefully it will help you to look in the right area.

  1. If you are using ESET Smary Security Suite then I bet you are using the Protocol Filtering (you can tell by looking in the Advanced Firewall Setup).
    You Could just turn it off and ignore the rest of my blurb but you probably want to keep Protocol Filtering enabled so goto step 2.
  2. In the Advanced setup you need to locate the section shown in the image below and uncheck the web development server.

  3. Make sure you stop the web development server if it's still running and then try debugging from Visual Studio again.

 

from:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2788405&SiteID=1

http://www.wahooga.com/archive/2008/02/20/visual-studio-development-web-server-automatic-port-numbering-problem.aspx

 

blueprint-css – 如何使用BlueprintCSS将div居中?

blueprint-css – 如何使用BlueprintCSS将div居中?

所以我在容器类中有div.如何使div居中,以便根据div的宽度正确地向两侧添加空白空间?

<body>
  <div>
    ... other stuff ...
    <div>center me</div>
  </div>
</body>

解决方法

你可以这样做:

<div>contents</div>

BlueprintNativeEvent 需要注意的地方

BlueprintNativeEvent 需要注意的地方

BlueprintNativeEvent

注释

    This function is designed to be overridden by a Blueprint, but also has a default native implementation. Declares an additional function named the same as the main function, but with _implementation added to the end, which is where code should be written. The autogenerated code will call the "_Implementation" method if no Blueprint override is found.(原文)

    此函数将由蓝图进行重载,但同时也包含 native 类的执行。提供一个名称为 [FunctionName]_Implementation 的函数本体而非 [FunctionName]; 自动生成的代码将包含转换程序,此程序在需要时会调用实施方式。

代码示例

父.h----PickUp.h

//当PickUp被收集调用的方法
	UFUNCTION(BlueprintNativeEvent,Category="PickUp")
	void WasCollected();
	virtual void WasCollected_Implementation();

父.cpp----PickUp.cpp

void APickUp::WasCollected_Implementation()
{
	//获取该对象的名称
	FString PickUpDebugString = GetName();

	//打印
	UE_LOG(LogClass, Log, TEXT("You have collected %s"), *PickUpDebugString);
}

子.h----BatteryPickUp.h

//重写父代码
void WasCollected_Implementation() override;

子.cpp----BatteryPickUp.cpp

void ABatteryPickUp::WasCollected_Implementation()
{
	//先执行父类行为
	Super::WasCollected_Implementation();

	//销毁
	Destroy();
}

在某个类调用

void AGame04_BatteryCharacter::CollectPickUps()
{
    //APickUp即为父类
	APickUp* const TestPickUp;
	TestPickUp->WasCollected();
}

总结    

    总体来说,UFUNCTION (BlueprintNativeEvent) 下的函数,只声明,不定义,但是需要在说明一个同名函数,后面加上_implementation 并且需要定义。至于为什么,现在还不知道,日后再补。(12/09

补充

功能

    使用 UFUNCTION(BlueprintNativeEvent) 可以很方便的实现一个按键绑定多个不同事件

原因

    因为它会优先调用继承这个类的蓝图里面的事件(中文:事件 WasCollected 英文:Event WasCollected)(前提是重写该蓝图事件)

    如果蓝图没有重写该事件,那么就默认调用 C++ 实现的_implementation

实例

为了方便我们将事件 WasCollected 叫节点 1,父类:WasCollected 叫节点 2

节点 1:

    不做说明,因为好像没有什么好说的

节点 2:

    它是调用 BatteryPickUp 里的 WasCollected 的,而且我们在 BatteryPickUp 里写了销毁和调用父类 PickUp WasCollected, 所以这个节点 2 的作用就是销毁以及调用 PickUp WasCollected.

可能在这里有人有疑问,在 BatteryPIckUp 并没有写 WasCollected, 为什么可以调用?

emmmmmmmm, 其实他调用的都是对应的 WasCollected_Implementation(个人理解,有误望指出)

未解之谜

当然你把鼠标停留在节点 2 或 1 上它会出现

它们的目标都是 PickUp

可能我上面有理解错,他们应该都是调用基类的 PickUp 里的 WasCollected, 然后通过某种方式???将 WasCollected_Implementation 这个函数转化为 WasCollected 这个函数了吧.

我尝试通过 VS2017 调试,希望可以跟踪上面这个未解之谜,然而无奈 F11 无法进入函数内部,各种调试模式都尝试过,但是都没有办法,希望有人可以帮我解答这个问题吧

com.intellij.util.xml.converters.values.ClassValueConverter的实例源码

com.intellij.util.xml.converters.values.ClassValueConverter的实例源码

项目:intellij-ce-playground    文件:JavaDomApplicationComponent.java   
public JavaDomApplicationComponent(ConverterManager converterManager) {
  converterManager.addConverter(PsiClass.class,new PsiClassConverter());
  converterManager.addConverter(PsiType.class,new CanonicalPsiTypeConverterImpl());
  converterManager.registerConverterImplementation(JvmPsiTypeConverter.class,new JvmPsiTypeConverterImpl());
  converterManager.registerConverterImplementation(CanonicalPsiTypeConverter.class,new CanonicalPsiTypeConverterImpl());

  final ClassValueConverter classValueConverter = ClassValueConverter.getClassValueConverter();
  converterManager.registerConverterImplementation(ClassValueConverter.class,classValueConverter);
  final ClassArrayConverter classArrayConverter = ClassArrayConverter.getClassArrayConverter();
  converterManager.registerConverterImplementation(ClassArrayConverter.class,classArrayConverter);

}
项目:tools-idea    文件:JavaDomApplicationComponent.java   
public JavaDomApplicationComponent(ConverterManager converterManager) {
  converterManager.addConverter(PsiClass.class,classArrayConverter);

}
项目:consulo-java    文件:JavaDomApplicationComponent.java   
public JavaDomApplicationComponent(ConverterManager converterManager) {
  converterManager.addConverter(PsiClass.class,classArrayConverter);

}

今天关于Vert.x Blueprint 系列教程(二) | Vert.x Kue 教程Web部分的分享就到这里,希望大家有所收获,若想了解更多关于asp.net development web server dynamic port numbering problem、blueprint-css – 如何使用BlueprintCSS将div居中?、BlueprintNativeEvent 需要注意的地方、com.intellij.util.xml.converters.values.ClassValueConverter的实例源码等相关知识,可以在本站进行查询。

本文标签: