我是elasticsearch的新手,并且正在寻找使用Java API的一些帮助.我有一些域对象例如
@XmlRootElement
public class BasicActivity {
private String activityName;
private FullActivity activity;
// Getters and setters
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个连接到节点的传输客户端
Client client = new TransportClient()
.addTransportAddress(new InetSocketTransportAddress("192.168.0.198",9300));
Run Code Online (Sandbox Code Playgroud)
有没有简单的方法将我的对象直接插入elasticsearch?
我见过这个
IndexResponse response = client.prepareIndex("twitter", "tweet", "1")
.setSource(jsonBuilder()
.startObject()
.field("user", "kimchy")
.field("postDate", new Date())
.field("message", "trying out Elastic Search")
.endObject()
)
.execute()
.actionGet();
Run Code Online (Sandbox Code Playgroud)
但要做到这一点,我必须将每个对象转换为json,尽管这可能不是我理想的情况.
如果我对它的工作方式(架构上)有误解,请告诉我,我在这里学习!
欢呼,罗布
我有一个gwt建议框,它执行RPC调用以从服务器获取一些数据并显示它.在某些情况下,最多有2000个结果.虽然在Firefox中运行javascript时这在chrome中工作正常,但它会冻结窗口5秒钟,有时会导致脚本没有响应警告.
我想要做的是像显示20个结果,并有更多的按钮,它可以只是追加接下来的20,而不必每次被点击一次打电话回服务器.我是相当新的,我已经尝试扩展suggestBox和重写showSuggestions()但它受到保护所以我不能.
任何建议/想法都会很棒.
干杯,罗布
我已经完成了几个教程的混搭,也没有太成功!
我试图让Apache CXF和WS-Security回调我的Spring Security身份验证器.一切都接近工作但是在某个时刻,我在获取密码以使Spring安全性退出WS-call时遇到问题.
下面的处理程序变得很难,但pc.getPassword()为空.我希望这是在Soap中发送的密码,所以我可以把它传递给spring
public class ServerPasswordCallback implements CallbackHandler {
public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
pc.setPassword( pc.getPassword() );
}
Run Code Online (Sandbox Code Playgroud)
我的拦截器设置如此
<bean id="wsAuthenticationInterceptor" class="com.olympus.viewtheworld.server.security.auth.WSAuthenticationInInterceptor">
<constructor-arg index="0">
<map key-type="java.lang.String" value-type="java.lang.Object">
<entry key="action" value="UsernameToken" />
<entry key="passwordType" value="PasswordText" />
<entry key="passwordCallbackClass" value="com.olympus.viewtheworld.server.security.auth.ServerPasswordCallback" />
</map>
</constructor-arg>
<property name="authenticationManager" ref="authenticationManager"/>
</bean>
<jaxws:endpoint id="secureHelloService"
implementor="#secureHelloServiceImpl"
implementorClass="com.olympus.viewtheworld.server.service.Impl.SecureHelloServiceImpl"
address="/SoapService/secure/hello">
<jaxws:serviceFactory>
<ref bean="jaxws-and-aegis-service-factory" />
</jaxws:serviceFactory>
<jaxws:inInterceptors>
<bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>
<ref bean="wsAuthenticationInterceptor" />
</jaxws:inInterceptors>
</jaxws:endpoint>
Run Code Online (Sandbox Code Playgroud)
我从SoapUI发出的soap请求是
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://test/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> …
Run Code Online (Sandbox Code Playgroud) 是否可以使用Spring Validators来验证来自Web Services Soap请求的数据?或者更多,那么我应该如何改变以下方法以使其成为可能?
我的确切背景如下:
我有一个使用Freemarker和Controllers的Web前端,可以正常使用验证,例如使用
<bean id="stockValidator" class="com.client.validator.StockValidator" />
Run Code Online (Sandbox Code Playgroud)
在dispatcher-servlet.xml中
然后在StockController中,对Post请求进行验证.
@RequestMapping(value = "/addStock", method = RequestMethod.POST)
public String addStudent(@ModelAttribute Stock stock,BindingResult result,
ModelMap model ) {
StockValidator.validate(stock, result );
if (result.hasErrors()) {
//model.addAttribute("stock", stock);
return "stock";
} else {
StockService.save(stock);
model.addAttribute("stockId", stock.getStockId());
model.addAttribute("stockCode", stock.getStockCode());
model.addAttribute("stockName", stock.getStockName());
return "result";
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我的SOAP Web服务是基于Annotation连接到服务中的
import javax.jws.WebService;
import org.springframework.beans.factory.annotation.Autowired;
import com.olympus.viewtheworld.server.dao.StockDao;
import com.olympus.viewtheworld.server.service.StockService;
import com.olympus.viewtheworld.shared.domain.Stock;
@WebService(endpointInterface = "com.server.service.StockService")
public class StockServiceImpl implements StockService{
@Autowired
StockDao stockDao;
Run Code Online (Sandbox Code Playgroud)
这在调度程序servlet中映射如下:
<jaxws:endpoint id="stockService"
implementorClass="com.server.service.Impl.StockServiceImpl"
implementor="#stockServiceImpl" …
Run Code Online (Sandbox Code Playgroud) 我一直在阅读rabbitMQ教程,我正在寻找一些关于我应该使用的设置的帮助.
我有一个任务列表1-50,我希望在一组4台计算机上运行一次(并且只运行一次),每台计算机都运行一个工作程序.我在https://www.rabbitmq.com/tutorials/tutorial-two-python.html上设置了类似于教程2的模板
并非所有计算机都可以运行所有任务(他们并未安装所有软件)
我想要实现的是允许过滤发送给工作人员的任务的设置.
我阅读了有关如何在广播情况下使用路由实现此目的的教程,但是我并不完全掌握将映射回到类似于教程2的简单推送模型需要做的事情(因为我不想广播工作).
在某些方面,我希望能够根据负载动态扩展每个盒子上的工人数量.
什么是我应该使用的最佳模型,是否有任何好的教程或写作,你可以建议了解这种方法?
干杯,罗布
java ×4
cxf ×1
gwt ×1
python ×1
rabbitmq ×1
spring ×1
spring-mvc ×1
validation ×1
ws-security ×1