虽然不耐烦地等待Java 8发布,在阅读Brian Goetz的精彩"Lambda状态"文章之后,我注意到功能组合根本没有被覆盖.
根据上面的文章,在Java 8中应该可以:
// having classes Address and Person
public class Address {
private String country;
public String getCountry() {
return country;
}
}
public class Person {
private Address address;
public Address getAddress() {
return address;
}
}
// we should be able to reference their methods like
Function<Person, Address> personToAddress = Person::getAddress;
Function<Address, String> addressToCountry = Address::getCountry;
Run Code Online (Sandbox Code Playgroud)
现在,如果我想将这两个函数组合成一个函数映射Person到country,我怎样才能在Java 8中实现这一点?
我正在尝试使用JAX WS为PayPal Express Checkout API实现简单的Web服务客户端.PayPal Express Checkout API提供了WSDL文件,我可以使用CXF的wsdl2java实用程序从中生成Java类.
出于身份验证原因,它需要为每个请求添加SOAP Header.这个标题非常简单,应该如下所示:https: //cms.paypal.com/us/cgi-bin/?cmd = __render-content&content_ID = developer/e_howto_api_ECSOAPAPasics #id09C3I0CF0O6
从WSDL类生成的包括ebay.apis.eblbasecomponents.CustomSecurityHeaderType类,它表示我需要添加到每个请求的标头.
所以问题是:如何考虑以下条件,将手动创建的CustomSecurityHeaderType类实例添加到SOAP请求的标题中:
我的问题是在通过子域访问页面时使用GWT 2.6.1时发生臭名昭着的"StatusCodeException:0"问题.https://sub.site.com/
现在,这种情况相当零星的一个客户使用IE11和我不能重现使用IE11,IE10,IE9还是IE8(不谈论Chrome或Firefox)几个不同的计算机上这一点.
从中访问完全相同的webapp https://site.com/似乎对该客户起作用.
这显然让我得出结论,我在同源策略方面遇到了问题.
但奇怪的是,我的webapp的设计方式是没有跨域或跨子域请求.这同样适用于无交叉协议以及无交叉端口的请求.换句话说,在这种情况下不违反同源政策.作为对此的确认,我可以提供以下证据:
在客户现场我已经看到了如何重现:客户开始使用应用程序,一切正常 - 所有请求都正常返回响应.然后,经过几分钟的工作,同一页面上的完全相同的请求(没有重新加载)开始失败,并显示StatusCodeException:0.
基本上,无论是https://sub.site.com和https://site.com指向同一个IP,并有只有一个Tomcat的web应用程序正是服务于相同的资源两个https://sub.site.com和https://site.com.
另一个证明是单个GWT模块本身的代码库:在那里我只使用一个服务的一个实例DashboardService:
public class DashboardModule extends EntryPoint implements IDashboardModule {
private final DashboardServiceAsync dashboardService = createDashboardService();
@Override …Run Code Online (Sandbox Code Playgroud) 假设我在MySQL中有2个表:
create table `persons` (
`id` bigint unsigned not null auto_increment,
`first_name` varchar(64),
`surname` varchar(64),
primary key(`id`)
);
create table `companies` (
`id` bigint unsigned not null auto_increment,
`name` varchar(128),
primary key(`id`)
);
Run Code Online (Sandbox Code Playgroud)
现在,我经常需要对它们进行相同的处理,这就是以下查询的原因:
select person.id as `id`, concat(person.first_name, ' ', person.surname) as `name`, 'person' as `person_type`
from persons
union all
select company.id as `id`, company.name as `name`, 'company' as `person_type`
from companies
Run Code Online (Sandbox Code Playgroud)
开始频繁出现在其他查询中:作为联接或子选择的一部分。现在,我只是将查询插入到联接或子选择中,例如:
select *
from some_table row
left …Run Code Online (Sandbox Code Playgroud) 不久前在 AskUbuntu 上问过这个问题:https ://askubuntu.com/questions/630897/apache-httpd-backed-by-both-tomcat-and-php 但那里没有答案所以我决定在这里问。
再一次 - 假设我可以通过某个域名访问服务器,例如http://mywebapp.com/
我想在该服务器上设置以下内容:
http://mywebapp.com/blog*都由PHP服务器处理(具体是 Wordpress 博客引擎)http://mywebapp.com/*由Apache Tomcat我想,这可能是通过把实现Apache HTTPD服务器在两个前Tomcat和PHP服务器,但无法找到的配置来实现这一目标。
有人可以提供有关如何实现这一目标的任何提示吗?
我创建了工厂类,我想知道哪种方法更好.选项1
public class Factory {
private IProperty prop;
public IDoc doc;
public Factory(int version) {
switch (version) {
case '1':
prop = new Prop();
doc = new Docu();
...
case '2':
prop = new Prop1();
doc = new Docu1();
...
}
}
public IProperty getProperty() {
return this.prop;
}
public IDoc getDoc() {
return this.doc;
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,如果这样做,即定义成员与接口类型,并打开构造函数或每个get方法,而不是在构造函数上使用switch语句,所以在构造函数中,我将获取版本并保存它在类成员上,比如使用像
public IProperty getProperty() {
switch (version) {
case '1':
prop = new Prop();
case '2':
prop = new Prop1();
...
Run Code Online (Sandbox Code Playgroud)
那么更好的方式或任何其他想法是什么?