Search in sources :

Example 6 with HttpPublisher

use of org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher in project kontraktor by RuedigerMoeller.

the class BldFourK method build.

public BldFourK build() {
    Http4K http4K = Http4K.get();
    // fixme https
    http4K.getServer(getPort(), getHostName(), context);
    getItems().forEach(item -> {
        if (item instanceof HttpPublisher) {
            http4K.publish((HttpPublisher) item);
        } else if (item instanceof WebSocketPublisher) {
            http4K.publish((WebSocketPublisher) item);
        } else if (item instanceof BldDirRoot) {
            BldDirRoot dr = (BldDirRoot) item;
            if (getHttpCacheEnabled()) {
                CachedFileResourceManager resMan = new CachedFileResourceManager(getHttpCacheEnabled(), new File(dr.getDir()), 100);
                http4K.publishFileSystem(getHostName(), dr.getUrlPath(), getPort(), resMan);
            } else {
                http4K.publishFileSystem(getHostName(), dr.getUrlPath(), getPort(), new File(dr.getDir()));
            }
        } else if (item instanceof BldHttpHandler) {
            BldHttpHandler dr = (BldHttpHandler) item;
            http4K.publishHandler(getHostName(), dr.getUrlPath(), getPort(), dr.getHandler());
        } else if (item instanceof BldResPath) {
            BldResPath dr = (BldResPath) item;
            DynamicResourceManager drm = new DynamicResourceManager(!dr.isCacheAggregates(), dr.getUrlPath(), dr.isMinify(), dr.getBaseDir(), dr.getResourcePath());
            drm.cachedIndexDir(dr.getProductionBuildDir());
            HtmlImportShim shim = new HtmlImportShim(dr.getUrlPath());
            drm.setJSPostProcessors(dr.getProdModePostProcessors());
            shim.setJSPostProcessors(dr.getProdModePostProcessors());
            shim.minify(dr.isMinify()).inline(dr.isInline()).stripComments(dr.isStripComments());
            drm.setImportShim(shim);
            drm.setTranspilerMap(dr.getTranspilers());
            http4K.publishResourcePath(getHostName(), dr.getUrlPath(), getPort(), drm, dr.isCompress(), dr.getHandlerInterceptor());
        } else {
            System.out.println("unexpected item " + item);
        }
    });
    return this;
}
Also used : HttpPublisher(org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher) WebSocketPublisher(org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher) Http4K(org.nustaq.kontraktor.remoting.http.undertow.Http4K) File(java.io.File)

Example 7 with HttpPublisher

use of org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher in project kontraktor by RuedigerMoeller.

the class RemotingTest method test.

@Test
public void test() {
    RemotingTA serv = Actors.AsActor(RemotingTA.class);
    // websocket
    WebSocketPublisher pub = new WebSocketPublisher().facade(serv).hostName("0.0.0.0").urlPath("/websocket").port(7777).serType(SerializerType.FSTSer);
    pub.publish().await();
    WebSocketConnectable con = new WebSocketConnectable().actorClass(RemotingTA.class).url("ws://localhost:7777/websocket");
    fromRemote(con);
    // TCP NIO
    new TCPNIOPublisher(serv, 7778).publish().await();
    fromRemote(new TCPConnectable(RemotingTA.class, "localhost", 7778));
    // TCP Sync
    new TCPPublisher(serv, 7780).publish().await();
    fromRemote(new TCPConnectable(RemotingTA.class, "localhost", 7780));
    // Http-Longpoll
    new HttpPublisher(serv, "0.0.0.0", "/httpapi", 7779).publish().await();
    fromRemote(new HttpConnectable(RemotingTA.class, "http://localhost:7779/httpapi"));
}
Also used : HttpConnectable(org.nustaq.kontraktor.remoting.http.HttpConnectable) TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) WebSocketPublisher(org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher) HttpPublisher(org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher) TCPPublisher(org.nustaq.kontraktor.remoting.tcp.TCPPublisher) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher) WebSocketConnectable(org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable) Test(org.junit.Test)

Aggregations

HttpPublisher (org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher)7 HttpConnectable (org.nustaq.kontraktor.remoting.http.HttpConnectable)3 WebSocketPublisher (org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher)3 File (java.io.File)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Test (org.junit.Test)2 ActorServer (org.nustaq.kontraktor.remoting.base.ActorServer)2 TCPNIOPublisher (org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher)2 ExecutorService (java.util.concurrent.ExecutorService)1 Http4K (org.nustaq.kontraktor.remoting.http.undertow.Http4K)1 TCPConnectable (org.nustaq.kontraktor.remoting.tcp.TCPConnectable)1 TCPPublisher (org.nustaq.kontraktor.remoting.tcp.TCPPublisher)1 WebSocketConnectable (org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable)1