当前位置: 首页>>代码示例>>Java>>正文


Java Container类代码示例

本文整理汇总了Java中org.vertx.java.platform.Container的典型用法代码示例。如果您正苦于以下问题:Java Container类的具体用法?Java Container怎么用?Java Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Container类属于org.vertx.java.platform包,在下文中一共展示了Container类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testForwardSendNoReply

import org.vertx.java.platform.Container; //导入依赖的package包/类
@Test
public void testForwardSendNoReply() throws MalformedURLException {
	String address = "testaddress";
	String message = "HelloWorld";
	String responseMediaType = "application/xml";
	long timeout = 60000;
	JsonObject config = createConfig(address, timeout);
	HttpEventBusBridgeService service = new HttpEventBusBridgeService();
	EventBusBridgeRequest request = createRequest(address, message, null, responseMediaType);
	
	Vertx vertx = Mockito.mock(Vertx.class);
	EventBus eventBus = Mockito.mock(EventBus.class);
	when(vertx.eventBus()).thenReturn(eventBus);
	when(eventBus.send(address, message)).thenReturn(eventBus);
	
	Container container = Mockito.mock(Container.class); 
	when(container.config()).thenReturn(config);

	service.forward(request, EventBusInstruction.send, vertx, container);
	verify(eventBus, times(1)).sendWithTimeout(eq(address), eq((Object) message), eq(timeout), any(NoOpResponseHandler.class));
}
 
开发者ID:j2ro,项目名称:mod-http-event-bus-bridge,代码行数:22,代码来源:HttpEventBusBridgeServiceTest.java

示例2: testForwardSendReply

import org.vertx.java.platform.Container; //导入依赖的package包/类
@Test
public void testForwardSendReply() throws MalformedURLException {
	String address = "testaddress";
	String message = "HelloWorld";
	URL responseUrl = new URL("http://localhost:8080/ebbresponse");
	String responseMediaType = "application/xml";
	HttpClient httpClient = Mockito.mock(HttpClient.class);
	long timeout = 60000;
	JsonObject config = createConfig(address, timeout);
	
	HttpEventBusBridgeService service = new HttpEventBusBridgeService();
	EventBusBridgeRequest request = createRequest(address, message, responseUrl, responseMediaType);
	
	Vertx vertx = Mockito.mock(Vertx.class);
	EventBus eventBus = Mockito.mock(EventBus.class);
	when(vertx.eventBus()).thenReturn(eventBus);
	when(eventBus.send(address, message)).thenReturn(eventBus);
	when(vertx.createHttpClient()).thenReturn(httpClient);
	
	Container container = Mockito.mock(Container.class); 
	when(container.config()).thenReturn(config);

	service.forward(request, EventBusInstruction.send, vertx, container);
	verify(eventBus, times(1)).sendWithTimeout(eq(address), eq((Object)message), eq(timeout), any(HttpResponseHandler.class));
}
 
开发者ID:j2ro,项目名称:mod-http-event-bus-bridge,代码行数:26,代码来源:HttpEventBusBridgeServiceTest.java

示例3: testForwardSendInvalidAddress

import org.vertx.java.platform.Container; //导入依赖的package包/类
@Test(expected = WebApplicationException.class)
public void testForwardSendInvalidAddress() throws MalformedURLException {
	String invalidAddress = "illegaladdress";
	String allowedAddress = "validaddress";
	String message = "HelloWorld";
	String responseMediaType = "application/xml";
	long timeout = 60000;
	JsonObject config = createConfig(allowedAddress, timeout);
	HttpEventBusBridgeService service = new HttpEventBusBridgeService();
	EventBusBridgeRequest request = createRequest(invalidAddress, message, null, responseMediaType);
	
	Vertx vertx = Mockito.mock(Vertx.class);
	
	Container container = Mockito.mock(Container.class); 
	when(container.config()).thenReturn(config);

	service.forward(request, EventBusInstruction.send, vertx, container);
}
 
开发者ID:j2ro,项目名称:mod-http-event-bus-bridge,代码行数:19,代码来源:HttpEventBusBridgeServiceTest.java

示例4: testForwardPublish

import org.vertx.java.platform.Container; //导入依赖的package包/类
@Test
public void testForwardPublish() throws MalformedURLException {
	String address = "testaddress";
	String message = "HelloWorld";
	String responseMediaType = "application/xml";
	long timeout = 60000;
	JsonObject config = createConfig(address, timeout);
	HttpEventBusBridgeService service = new HttpEventBusBridgeService();
	EventBusBridgeRequest request = createRequest(address, message, null, responseMediaType);
	
	Vertx vertx = Mockito.mock(Vertx.class);
	EventBus eventBus = Mockito.mock(EventBus.class);
	when(vertx.eventBus()).thenReturn(eventBus);
	when(eventBus.send(address, message)).thenReturn(eventBus);
	
	Container container = Mockito.mock(Container.class); 
	when(container.config()).thenReturn(config);

	service.forward(request, EventBusInstruction.publish, vertx, container);
	verify(eventBus, times(1)).publish(address, (Object) message);
}
 
开发者ID:j2ro,项目名称:mod-http-event-bus-bridge,代码行数:22,代码来源:HttpEventBusBridgeServiceTest.java

示例5: testForwardPublishInvalidAddress

import org.vertx.java.platform.Container; //导入依赖的package包/类
@Test(expected = WebApplicationException.class)
public void testForwardPublishInvalidAddress() throws MalformedURLException {
	String invalidAddress = "illegaladdress";
	String allowedAddress = "validaddress";
	String message = "HelloWorld";
	String responseMediaType = "application/xml";
	long timeout = 60000;
	JsonObject config = createConfig(allowedAddress, timeout);
	HttpEventBusBridgeService service = new HttpEventBusBridgeService();
	EventBusBridgeRequest request = createRequest(invalidAddress, message, null, responseMediaType);
	
	Vertx vertx = Mockito.mock(Vertx.class);

	Container container = Mockito.mock(Container.class); 
	when(container.config()).thenReturn(config);

	service.forward(request, EventBusInstruction.publish, vertx, container);
}
 
开发者ID:j2ro,项目名称:mod-http-event-bus-bridge,代码行数:19,代码来源:HttpEventBusBridgeServiceTest.java

示例6: SendInBlueSender

import org.vertx.java.platform.Container; //导入依赖的package包/类
public SendInBlueSender(Vertx vertx, Container container, JsonObject config)
		throws InvalidConfigurationException, URISyntaxException {
	super(vertx, container);
	if (config != null && isNotEmpty(config.getString("uri")) && isNotEmpty(config.getString("api-key"))) {
		URI uri = new URI(config.getString("uri"));
		httpClient = vertx.createHttpClient()
				.setHost(uri.getHost())
				.setPort(uri.getPort())
				.setMaxPoolSize(16)
				.setSSL("https".equals(uri.getScheme()))
				.setKeepAlive(false);
		apiKey = config.getString("api-key");
		dedicatedIp = config.getString("ip");
		splitRecipients = config.getBoolean("split-recipients", false);
		mapper = new ObjectMapper();
		mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
	} else {
		throw new InvalidConfigurationException("missing.parameters");
	}
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:21,代码来源:SendInBlueSender.java

示例7: NotificationHelper

import org.vertx.java.platform.Container; //导入依赖的package包/类
public NotificationHelper(Vertx vertx, Container container) {
	this.log = container.logger();
	this.render = new Renders(vertx, container);
	final Object encodedEmailConfig = vertx.sharedData().getMap("server").get("emailConfig");

	String defaultMail = "[email protected]";
	String defaultHost = "http://localhost:8009";

	if(encodedEmailConfig != null){
		JsonObject emailConfig = new JsonObject(encodedEmailConfig.toString());
		defaultMail = emailConfig.getString("email", defaultMail);
		defaultHost = emailConfig.getString("host", defaultHost);
	}

	this.senderEmail = container.config().getString("email", defaultMail);
	this.host = container.config().getString("host", defaultHost);
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:18,代码来源:NotificationHelper.java

示例8: init

import org.vertx.java.platform.Container; //导入依赖的package包/类
public void init(Vertx vertx, Container container, RouteMatcher rm,
				 Map<String, SecuredAction> securedActions) {
	super.vertx = vertx;
	super.container = container;
	super.rm = rm;
	super.securedActions = securedActions;
	super.eb = Server.getEventBus(vertx);
	if (pathPrefix == null) {
		super.pathPrefix = Server.getPathPrefix(container.config());
	}
	if (rm != null) {
		loadRoutes();
	} else {
		log.error("RouteMatcher is null.");
	}
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:17,代码来源:BaseController.java

示例9: init

import org.vertx.java.platform.Container; //导入依赖的package包/类
public void init(Container container, Vertx vertx) {
	try {
		if (vertx.fileSystem().existsSync(messagesDir)) {
			Map<Locale, JsonObject> messages = messagesByDomains.get(DEFAULT_DOMAIN);
			if (messages == null) {
				messages = new HashMap<>();
				messagesByDomains.put(DEFAULT_DOMAIN, messages);
			}
			for(String path : vertx.fileSystem().readDirSync(messagesDir)) {
				if (vertx.fileSystem().propsSync(path).isRegularFile()) {
					Locale l = Locale.forLanguageTag(new File(path).getName().split("\\.")[0]);
					JsonObject jo = new JsonObject(vertx.fileSystem().readFileSync(path).toString());
					messages.put(l,jo);
				}
			}
		} else {
			log.warn("I18n directory " + messagesDir + " doesn't exist.");
		}
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:23,代码来源:I18n.java

示例10: VertxApplicationContext

import org.vertx.java.platform.Container; //导入依赖的package包/类
/**
 * @param loader
 * @param vertx
 * @param container 
 */
public VertxApplicationContext(final ClassLoader loader, final Vertx vertx, final Container container) {
  this.vertx = vertx;
  this.container = container;

  this.parent = new GenericApplicationContext();
  parent.setClassLoader(loader);

  ConfigurableListableBeanFactory factory = parent.getBeanFactory();

  factory.registerSingleton(VERTX_BEAN_NAME, this.vertx);
  factory.registerAlias(VERTX_BEAN_NAME, "vertx");

  factory.registerSingleton(EVENTBUS_BEAN_NAME, vertx.eventBus());
  factory.registerAlias(EVENTBUS_BEAN_NAME, "eventBus");

  factory.registerSingleton(VERTICLE_CONTAINER_BEAN_NAME, this.container);
  factory.registerAlias(VERTICLE_CONTAINER_BEAN_NAME, "verticle-container");

  parent.refresh();
  parent.start();
  parent.registerShutdownHook();
}
 
开发者ID:chipat,项目名称:mod-lang-spring-updated,代码行数:28,代码来源:VertxApplicationContext.java

示例11: init

import org.vertx.java.platform.Container; //导入依赖的package包/类
@Override
public void init(Vertx vertx, final Container container, RouteMatcher rm,
		Map<String, fr.wseduc.webutils.security.SecuredAction> securedActions) {
	super.init(vertx, container, rm, securedActions);

	ConcurrentSharedMap<Object, Object> server = vertx.sharedData().getMap("server");
	Boolean cluster = (Boolean) server.get("cluster");
	if (Boolean.TRUE.equals(cluster)) {
		ClusterManager cm = ((VertxInternal) vertx).clusterManager();
		cursusMap = cm.getSyncMap("cursusMap");
	} else {
		cursusMap = new HashMap<>();
	}

	/*
	service.refreshToken(new Handler<Boolean>() {
		public void handle(Boolean res) {
			if(!res)
				log.error("[Cursus][refreshToken] Error while retrieving the Token.");
			else
				log.info("[Cursus][refreshToken] Token refreshed.");
		}
	});
	*/
	if(cursusMap.containsKey("wallets"))
		return;
	service.refreshWallets(new Handler<Boolean>() {
		public void handle(Boolean res) {
			if(!res)
				log.error("[Cursus][refreshWallets] Error while retrieving the wallets list.");
			else
				log.info("[Cursus][refreshWallets] Wallets list refreshed.");
		}
	});

}
 
开发者ID:OPEN-ENT-NG,项目名称:cursus,代码行数:37,代码来源:CursusController.java

示例12: CollaborativeEditorController

import org.vertx.java.platform.Container; //导入依赖的package包/类
/**
 * Default constructor
 * @param vertx vertx
 * @param collection MongoDB collection to request.
 */
public CollaborativeEditorController(Vertx vertx, String collection, Container container) {
    super(collection);
    JsonObject config = container.config();
    this.etherpadHelper = new EtherpadHelper(vertx, collection, config.getString("etherpad-url", null),
            config.getString("etherpad-api-key", null), config.getString("etherpad-public-url", null),
            config.getBoolean("trust-all-certificate", true), config.getString("etherpad-domain", null));
}
 
开发者ID:OPEN-ENT-NG,项目名称:collaborative-editor,代码行数:13,代码来源:CollaborativeEditorController.java

示例13: forward

import org.vertx.java.platform.Container; //导入依赖的package包/类
/**
 * Service to forward HTTP request onto the vertx event bus.
 * @param request EventBusBridgeRequest object
 * @param instruction Instruction (i.e. send or publish)
 * @param vertx Vertx instance
 * @param container Container instance
 * @return Message
 * @throws MalformedURLException If the response url contained in the request is invalid
 */
@POST
@Path("/{instruction}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response forward(final EventBusBridgeRequest request, @PathParam("instruction") final EventBusInstruction instruction,
		                @Context final Vertx vertx, @Context final Container container) throws MalformedURLException {
	String address = request.getAddress();
	JsonObject config = container.config();

	validateRequest(request, config);

	Object messageObject = EventBusMessageTypeConverter.convertIncomingMessage(request.getMessage(), request.getEventBusMessageType());
	switch (instruction) {
		case send:
			Long timeout = config.getLong("timeout", DEFAULT_TIMEOUT);
			String mediaType = request.getResponseMediaType() != null ? request.getResponseMediaType() : DEFAULT_RESPONSE_MEDIA_TYPE;
			URL responseUrl = request.getResponseUrl() != null ? new URL(request.getResponseUrl()) : null;
			send(address, messageObject, responseUrl, mediaType, vertx, timeout);
			break;
		case publish:
			publish(address, messageObject, vertx);
			break;
		default:
			throw new IllegalArgumentException("Illegal event bus instruction provided: " + instruction);
	}
	return Response.accepted().build();
}
 
开发者ID:j2ro,项目名称:mod-http-event-bus-bridge,代码行数:36,代码来源:HttpEventBusBridgeService.java

示例14: GoMailSender

import org.vertx.java.platform.Container; //导入依赖的package包/类
public GoMailSender(Vertx vertx, Container container, JsonObject config)
		throws InvalidConfigurationException, URISyntaxException {
	super(vertx, container);

	if (config != null && isNotEmpty(config.getString("uri")) && isNotEmpty(config.getString("user"))
			&& isNotEmpty(config.getString("password")) && isNotEmpty(config.getString("platform"))) {
		ByteArrayOutputStream userAndPassword = new ByteArrayOutputStream();
		try {
			userAndPassword.write(config.getString("user").getBytes());
			userAndPassword.write(':');
			userAndPassword.write(config.getString("password").getBytes());
		} catch (IOException e) {
			log.error(e);
		}
		basicAuthHeader = "Basic " + Base64.encodeBytes(userAndPassword.toByteArray());
		URI uri = new URI(config.getString("uri"));
		httpClient = vertx.createHttpClient().setHost(uri.getHost()).setPort(uri.getPort()).setMaxPoolSize(16)
				.setSSL("https".equals(uri.getScheme())).setKeepAlive(false);
		platform = config.getString("platform");
		mapper = new ObjectMapper();
		mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"));
		mapper.addMixInAnnotations(Bounce.class, GoMailBounceMixIn.class);

	} else {
		throw new InvalidConfigurationException("missing.parameters");
	}
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:28,代码来源:GoMailSender.java

示例15: Controller

import org.vertx.java.platform.Container; //导入依赖的package包/类
public Controller(Vertx vertx, Container container, RouteMatcher rm,
		Map<String, SecuredAction> securedActions) {
	super(vertx, container);
	this.rm = rm;
	this.uriBinding = new HashMap<>();
	this.securedActions = securedActions;
	if (vertx != null) {
		this.eb = Server.getEventBus(vertx);
	}
	if (rm != null) {
		loadRoutes();
	}
	this.accessLogger = new AccessLogger();
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:15,代码来源:Controller.java


注:本文中的org.vertx.java.platform.Container类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。