當前位置: 首頁>>代碼示例>>Java>>正文


Java Handler類代碼示例

本文整理匯總了Java中org.vertx.java.core.Handler的典型用法代碼示例。如果您正苦於以下問題:Java Handler類的具體用法?Java Handler怎麽用?Java Handler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Handler類屬於org.vertx.java.core包,在下文中一共展示了Handler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateDownloadLogs

import org.vertx.java.core.Handler; //導入依賴的package包/類
@Override
public void updateDownloadLogs(final String id, final UserInfos user, final Handler<JsonObject> handler) {
	final QueryBuilder query = QueryBuilder.start("_id").is(id);

	final JsonObject logElem = new JsonObject().putString("userDisplayName", user.getUsername()).putObject("downloadDate", MongoDb.now());
	final MongoUpdateBuilder modifier = new MongoUpdateBuilder();
	modifier.addToSet("downloadLogs", logElem);
	mongo.update(ShareBigFiles.SHARE_BIG_FILE_COLLECTION, MongoQueryBuilder.build(query),
			modifier.build(), new Handler<Message<JsonObject>>() {
				@Override
				public void handle(Message<JsonObject> event) {
					if ("ok".equals(event.body().getString("status"))) {
						handler.handle(new JsonObject().putString("status", "ok"));
					} else {
						handler.handle(new JsonObject().putString("status", "error")
								.putString("message", event.body().getString("message")));
					}
				}
			});
}
 
開發者ID:OPEN-ENT-NG,項目名稱:share-big-files,代碼行數:21,代碼來源:ShareBigFilesServiceImpl.java

示例2: start

import org.vertx.java.core.Handler; //導入依賴的package包/類
@Override
public void start(String host, int port) {
	Handler<HttpServerRequest> handler = new Handler<HttpServerRequest>() {
           public void handle(HttpServerRequest request) {
               if (request.absoluteURI().getPath().equals("/kill")) {
                   request.response().end("Exiting after 5s ...");
                   killWorker();
                   return;
               } else if (request.absoluteURI().getPath().equals("/ping")) {
                   request.response().end("PONG");
                   return;
               } 
               request.response().end("ScheduledJobNode is running");
           }
       };
       registerWorkerHttpHandler(host, port, handler);
}
 
開發者ID:rfxlab,項目名稱:analytics-with-rfx,代碼行數:18,代碼來源:ScheduledJobWorker.java

示例3: main

import org.vertx.java.core.Handler; //導入依賴的package包/類
public static void main(String[] args) {
	// Configure the client.
	String adCode3rd = "/?advideo/3.0/78.109/5798044/0//cc=2;vidAS=pre_roll;vidRT=VAST;vidRTV=2.0.1";
	HttpClient httpClient = VertxFactory.newVertx().createHttpClient();
	httpClient.setHost("adserver.adtech.de");
	httpClient.get(adCode3rd, new Handler<HttpClientResponse>() {

	    @Override
	    public void handle(HttpClientResponse httpClientResponse) {
	    	httpClientResponse.bodyHandler(new Handler<Buffer>() {
	            @Override
	            public void handle(Buffer buffer) {
	                System.out.println("Response (" + buffer.length() + "): ");
	                System.out.println(buffer.getString(0, buffer.length()));
	            }
	        });
	    }
	});
	Utils.sleep(10000);
}
 
開發者ID:rfxlab,項目名稱:analytics-with-rfx,代碼行數:21,代碼來源:NettyHttpClient.java

示例4: init

import org.vertx.java.core.Handler; //導入依賴的package包/類
private void init() {
    this.next.readStream().dataHandler(new Handler<Buffer>() {
        @Override
        public void handle(Buffer buffer) {
            if( encryptedReadBuffer == null ) {
                encryptedReadBuffer = buffer;
            } else {
                encryptedReadBuffer.appendBuffer(buffer);
            }
            encryptedReadBufferUnderflow = false;
            pumpReads();
        }
    });
    this.next.readStream().endHandler(new Handler<Void>() {
        @Override
        public void handle(Void x) {
            encryptedReadEOF = true;
        }
    });
    this.next.readStream().exceptionHandler(new Handler<Throwable>() {
        @Override
        public void handle(Throwable error) {
            onFailure(error);
        }
    });
}
 
開發者ID:nkasvosve,項目名稱:beyondj,代碼行數:27,代碼來源:SslSocketWrapper.java

示例5: getInfo

import org.vertx.java.core.Handler; //導入依賴的package包/類
@Override
public void getInfo(final String fileId, final AsyncResultHandler<FileInfos> handler) {
	final JsonObject query = new JsonObject().putString(mapping.getString("file", "file"), fileId);
	mongo.findOne(collection, query, keys, new Handler<Message<JsonObject>>() {
		@Override
		public void handle(Message<JsonObject> event) {
			if ("ok".equals(event.body().getString("status"))) {
				JsonObject res = event.body().getObject("result");
				if (res != null) {
					final FileInfos fi = new FileInfos();
					fi.setApplication(application);
					fi.setId(fileId);
					fi.setName(res.getString(mapping.getString("title", "title")));
					fi.setOwner(res.getObject("owner", new JsonObject()).getString("userId"));
					handler.handle(new DefaultAsyncResult<>(fi));
				} else {
					handler.handle(new DefaultAsyncResult<>((FileInfos) null));
				}
			} else {
				handler.handle(new DefaultAsyncResult<FileInfos>(
						new StorageException(event.body().getString("message"))));
			}
		}
	});
}
 
開發者ID:OPEN-ENT-NG,項目名稱:share-big-files,代碼行數:26,代碼來源:ShareBigFileStorage.java

示例6: getResidualRepositorySize

import org.vertx.java.core.Handler; //導入依賴的package包/類
private void getResidualRepositorySize(final Handler<Long> handler) {
	storage.stats(new AsyncResultHandler<BucketStats>() {
		@Override
		public void handle(AsyncResult<BucketStats> event) {
			Long residualRepositorySize = 0L;
			if (event.succeeded()) {
				final Long sizeUsed = event.result().getStorageSize();
				final Long residualRepository = ShareBigFilesController.this.maxRepositoryQuota - sizeUsed;
				residualRepositorySize = (residualRepository < 0) ? 0L : residualRepository;
			} else {
				log.error("Can't get the repository stats : ", event.cause());
			}
			handler.handle(residualRepositorySize);
		}
	});
}
 
開發者ID:OPEN-ENT-NG,項目名稱:share-big-files,代碼行數:17,代碼來源:ShareBigFilesController.java

示例7: authorize

import org.vertx.java.core.Handler; //導入依賴的package包/類
@Override
public void authorize(final HttpServerRequest request, final Binding binding, final UserInfos user, final Handler<Boolean> handler) {
	RequestUtils.bodyToJson(request, Server.getPathPrefix(Config.getInstance().getConfig()) + "deletes", new Handler<JsonObject>() {
		public void handle(JsonObject data) {
			final List<String> ids = data.getArray("ids").toList();
			if (ids != null && !ids.isEmpty()) {
				List<DBObject> groups = new ArrayList<>();
				String sharedMethod = binding.getServiceMethod().replaceAll("\\.", "-");
				groups.add(QueryBuilder.start("userId").is(user.getUserId())
						.put(sharedMethod).is(true).get());
				for (String gpId: user.getGroupsIds()) {
					groups.add(QueryBuilder.start("groupId").is(gpId)
							.put(sharedMethod).is(true).get());
				}
				QueryBuilder query = QueryBuilder.start("_id").in(new HashSet<String>(ids)).or(
						QueryBuilder.start("owner.userId").is(user.getUserId()).get(),
						QueryBuilder.start("shared").elemMatch(
								new QueryBuilder().or(groups.toArray(new DBObject[groups.size()])).get()).get()
				);
				MongoAppFilter.executeCountQuery(request, conf.getCollection(), MongoQueryBuilder.build(query), ids.size(), handler);
			} else {
				handler.handle(false);
			}
		}
	});
}
 
開發者ID:OPEN-ENT-NG,項目名稱:share-big-files,代碼行數:27,代碼來源:MassJsonShareAndOwner.java

示例8: createBooking

import org.vertx.java.core.Handler; //導入依賴的package包/類
@Post("/resource/:id/booking")
@ApiDoc("Create booking of a given resource")
@SecuredAction(value = "rbs.contrib", type= ActionType.RESOURCE)
@ResourceFilter(TypeAndResourceAppendPolicy.class)
public void createBooking(final HttpServerRequest request) {

    UserUtils.getUserInfos(eb, request, new Handler<UserInfos>() {
        @Override
        public void handle(final UserInfos user) {
            if (user != null) {
                RequestUtils.bodyToJson(request, pathPrefix + "createBooking",
                        getBookingHandler(user, request, true));
            } else {
                log.debug("User not found in session.");
                unauthorized(request);
            }
        }
    });
}
 
開發者ID:OPEN-ENT-NG,項目名稱:rbs,代碼行數:20,代碼來源:BookingController.java

示例9: initVerticle

import org.vertx.java.core.Handler; //導入依賴的package包/類
@Override
protected void initVerticle() {
    Commands.call(
            eventBus(),
            LOCAL_ADDRESS,
            Commands.cmdDeployVerticle(
                    TestVerticle1.class.getName(),
                    new JsonObject(),
                    1,
                    false,
                    false),
            new Handler<Message<JsonObject>>() {

                @Override
                public void handle(Message<JsonObject> message) {
                    Result result = new Result(message.body());
                    if (result.getReturnCode() != RET_DEPLOYMENT_ID) {
                        throw new IllegalStateException(result.getReason());
                    } else {
                        undeployVerticle(result.getReason()); // Deployment ID is in reason
                    }
                }
            });
}
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:25,代碼來源:ActivatorTest.java

示例10: getDelaysAndTypeProperties

import org.vertx.java.core.Handler; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void getDelaysAndTypeProperties(long resourceId, Handler<Either<String, JsonObject>> handler) {
	StringBuilder query = new StringBuilder("SELECT r.min_delay, r.max_delay, t.owner, t.school_id,");

	// Subquery to return managers
	query.append(" (SELECT json_agg(DISTINCT ts.member_id) FROM rbs.resource_type_shares AS ts")
		.append(" WHERE ts.resource_id = t.id")
		.append(" AND ts.action = 'net-atos-entng-rbs-controllers-ResourceTypeController|shareJsonSubmit') AS managers");

	query.append(" FROM rbs.resource AS r")
		.append(" INNER JOIN rbs.resource_type AS t ON r.type_id = t.id")
		.append(" WHERE r.id = ?");

	JsonArray values = new JsonArray().add(resourceId);

	Sql.getInstance().prepared(query.toString(), values, validUniqueResultHandler(handler));
}
 
開發者ID:OPEN-ENT-NG,項目名稱:rbs,代碼行數:21,代碼來源:ResourceServiceSqlImpl.java

示例11: updateBooking

import org.vertx.java.core.Handler; //導入依賴的package包/類
@Put("/resource/:id/booking/:bookingId")
@ApiDoc("Update booking")
@SecuredAction(value = "rbs.contrib", type= ActionType.RESOURCE)
@ResourceFilter(TypeAndResourceAppendPolicy.class)
public void updateBooking(final HttpServerRequest request){
    UserUtils.getUserInfos(eb, request, new Handler<UserInfos>() {
        @Override
        public void handle(final UserInfos user) {
            if (user != null) {
                RequestUtils.bodyToJson(request, pathPrefix + "updateBooking",
                        getBookingHandler(user, request, false));
            } else {
                log.debug("User not found in session.");
                unauthorized(request);
            }
        }
    });
}
 
開發者ID:OPEN-ENT-NG,項目名稱:rbs,代碼行數:19,代碼來源:BookingController.java

示例12: startLocalHttpServer

import org.vertx.java.core.Handler; //導入依賴的package包/類
private void startLocalHttpServer(final URI address) {

        String host = address.getHost();
        int port = address.getPort();
        m_logger.info("Listening on {}:{}", host, port);
        HttpServer server = vertx.createHttpServer();

        server.requestHandler(new Handler<HttpServerRequest>() {
            @Override
            public void handle(final HttpServerRequest request) {
                m_logger.debug("{} received request from {}",
                        request.localAddress(),
                        request.remoteAddress());
                request.bodyHandler(new Handler<Buffer>() {
                    @Override
                    public void handle(final Buffer body) {
                        m_logger.info("{} client data: {}",
                                request.localAddress(),
                                body.toString(StandardCharsets.UTF_8.name()));
                    }
                });
                request.response().setStatusCode(200).end();
            }
        }).listen(port, host);
    }
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:26,代碼來源:ConnectionsTest.java

示例13: createPeriodicBooking

import org.vertx.java.core.Handler; //導入依賴的package包/類
@Post("/resource/:id/booking/periodic")
@ApiDoc("Create periodic booking of a given resource")
@SecuredAction(value = "rbs.contrib", type= ActionType.RESOURCE)
@ResourceFilter(TypeAndResourceAppendPolicy.class)
public void createPeriodicBooking(final HttpServerRequest request) {
    UserUtils.getUserInfos(eb, request, new Handler<UserInfos>() {
        @Override
        public void handle(final UserInfos user) {
            if (user != null) {
                RequestUtils.bodyToJson(request, pathPrefix + "createPeriodicBooking",
                        getPeriodicBookingHandler(user, request, true));
            } else {
                log.debug("User not found in session.");
                unauthorized(request);
            }
        }
    });
}
 
開發者ID:OPEN-ENT-NG,項目名稱:rbs,代碼行數:19,代碼來源:BookingController.java

示例14: deleteSession

import org.vertx.java.core.Handler; //導入依賴的package包/類
/**
 * Delete a user session on a collaborative editor
 * @param request HTTP request
 */
public void deleteSession(final HttpServerRequest request) {
    UserUtils.getUserInfos(eb, request, new Handler<UserInfos>() {
        @Override
        public void handle(final UserInfos user) {
            String sessionID = CookieHelper.get("sessionID", request);
            if (sessionID != null) {
                client.deleteSession(sessionID, new Handler<JsonObject>() {
                    @Override
                    public void handle(JsonObject event) {
                        if ("ok".equals(event.getField("status"))) {
                            request.response().putHeader("Set-Cookie", "sessionID=deleted;max-age=-1;path=/;domain=" + domain).setStatusCode(200).end();
                        } else {
                            //TODO check if render error because there is a redmine ticket about error log on session doesn't exist !!!!!
                            Renders.renderError(request, event);
                        }
                    }
                });
            } else {
                request.response().setStatusCode(200).end();
            }
        }
    });
}
 
開發者ID:OPEN-ENT-NG,項目名稱:collaborative-editor,代碼行數:28,代碼來源:EtherpadHelper.java

示例15: retrieve

import org.vertx.java.core.Handler; //導入依賴的package包/類
@Override
public void retrieve(String id, Handler<Either<String, JsonObject>> handler) {
	String query;
	JsonArray values = new JsonArray();
	if (id != null) {
		query = "SELECT t.id as _id, t.title, t.icon, t.mode, t.created, t.modified, t.owner, u.username" +
			", json_agg(row_to_json(row(ts.member_id, ts.action)::actualites.share_tuple)) as shared" +
			", array_to_json(array_agg(group_id)) as groups" +
			" FROM actualites.thread AS t" +
			" LEFT JOIN actualites.users AS u ON t.owner = u.id" +
			" LEFT JOIN actualites.thread_shares AS ts ON t.id = ts.resource_id" +
			" LEFT JOIN actualites.members AS m ON (ts.member_id = m.id AND m.group_id IS NOT NULL)" +
			" WHERE t.id = ? " +
			" GROUP BY t.id, u.username" +
			" ORDER BY t.modified DESC";
		values.add(Sql.parseId(id));
		Sql.getInstance().prepared(query.toString(), values, SqlResult.parseSharedUnique(handler));
	}
}
 
開發者ID:OPEN-ENT-NG,項目名稱:actualites,代碼行數:20,代碼來源:ThreadServiceSqlImpl.java


注:本文中的org.vertx.java.core.Handler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。