第1题:
我不能真正理解之间的差异enrich()和pollEnrich().也许Camel使用的术语并不是那么好.
我在这里阅读:http://camel.apache.org/content-enricher.html
使用丰富的DSL元素进行内容丰富
Camel带有两种丰富的DSL内容
- 丰富
- pollEnrich
enrich使用Producer来获取附加数据.它通常用于请求回复消息传递,例如用于调用外部Web服务.另一方面,pollEnrich使用轮询消费者来获取附加数据.它通常用于事件消息消息传递,例如读取文件或下载FTP文件.
我不明白有什么区别.他们似乎都通过消费来获得额外的数据(Web服务响应,FTP文件).那么为什么他们说Web服务响应是由"生产者"完成的呢?
第2个问题:
在"骆驼在行动"一书中.72他们说:
Enrich和pollEnrich无法访问当前交易所的信息
rich和pollEnrich都不能利用当前交易所的任何信息.这意味着,例如,您无法在交换机上存储文件头,以供pollEnrich用于选择特定文件.如果Camel团队能够找到解决方案,将来可能会发生变化.
但是,他们提供了类似于以下的代码示例,用于实现聚合策略:
public class ExampleAggregationStrategy implements AggregationStrategy {
public Exchange aggregate(Exchange original, Exchange resource) {
Object originalBody = original.getIn().getBody();
Object resourceResponse = resource.getIn().getBody();
Object mergeResult = ... // combine original body and resource response
if (original.getPattern().isOutCapable()) {
original.getOut().setBody(mergeResult);
} else {
original.getIn().setBody(mergeResult);
}
return original;
}
}
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我看到他们可以访问Exchange original,是不是"当前的交换"?如果没有,那么"原始交换"代表什么交换呢?他们的"当前交换"是什么意思?
我尝试用新的子字符串替换stdin中的某个子字符串.在读完几个文件后,我必须从管道中获取stdin cat.然后我想将更改的字符串向前推到管道.
这是我尝试做的事情:
cat file1 file2 | echo ${#(cat)/@path_to_file/'path//to//file'} | ... | ... | ... | ...
我尝试用替换子字符串@path_to_file替换子字符串'path/to/file'(周围的引号是替换子字符串的一部分).
但是bash给了我一个错误信息: bad substitution
任何想法我怎么能做到这一点?
我尝试从现有的CXF休息服务创建一个wadl.这是行不通的.我得到HTTP 404.其余服务本身确实有用.我使用Tomcat 7.
我究竟做错了什么?
Server Information
Tomcat Version JVM Version JVM Vendor OS Name OS Version OS Architecture Hostname IP Address
Apache Tomcat/7.0.52 (Ubuntu) 1.7.0_72-b14 Oracle Corporation Linux 3.13.0-43-generic amd64 myself 127.0.1.1
Run Code Online (Sandbox Code Playgroud)
/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-cxf-rest-example.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)
/WEB-INF/spring-cxf-rest-example.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd …Run Code Online (Sandbox Code Playgroud) 我正在使用Apache-Camel 2.15.2.
我正在尝试CamelContext动态添加路由,但我遇到了一个令我感到困惑的问题.
据我所知,我确实将路由添加到正确的路径CamelContext,看起来它们configure()被调用而没有抛出异常.但是当我尝试执行主路由时,我得到一个运行时异常告诉我,我动态添加的路由不存在.
这是我的代码的简化版本:
public class MainRouteBuilder extends RouteBuilder
{
public static CamelContext camelContext;
public static boolean returnLabel = true;
public static RouteBuilder nestedRouteBuilder;
@Override
public void configure() throws Exception
{
System.out.println("Building main route!");
System.out.println("Context: " + getContext());
camelContext = getContext();
from("direct:mainRoute")
//3. I do not actually want to instantiate RouteContainer like this each time I call this route.
//I would simply want to reuse a reference to an instance I created outside …Run Code Online (Sandbox Code Playgroud) 我有一个Spring-MVC应用程序(即我使用的是Spring的调度程序servlet).我也使用Spring Security来验证用户身份.因为我使用Spring的调度程序servlet,所以我不必声明
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
Run Code Online (Sandbox Code Playgroud)
在我的web.xml中,以便能够使用RequestContextHolder(如果我正确理解文档).
我的问题涉及我的界面实现org.springframework.security.web.authentication.AuthenticationSuccessHandler:
public class AuthenticationSuccessHandlerImpl implements AuthenticationSuccessHandler {
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
int timeout = 60*60;
//does work
request.getSession().setMaxInactiveInterval(timeout); //60 minutes
System.out.println("Session timeout of user: " + authentication.getName() + " has been set to: " + timeout + " seconds.");
/*
//does not work
session().setMaxInactiveInterval(timeout); //60 minutes
System.out.println("Session timeout of user: " + request.getUserPrincipal().getName() + " has been set to: " + …Run Code Online (Sandbox Code Playgroud) 从像这样的网页,
http://www.jsftutorials.net/components/step5.html
我知道JSF标记/视图组件中的绑定属性是将视图组件绑定到辅助bean中的UI组件的Java实例.
例如,这是在以下代码中完成的操作:
<h:inputText value="#{ myBean.someProperty}" binding="#{ myBean.somePropertyInputText}"/>
Run Code Online (Sandbox Code Playgroud)
但有时我看到这样的代码:
<h:commandButton id="t1" binding="#{foo}" value="Hello, World!" onclick="alert('I am #{id:cid(foo)}'); return false;" />
Run Code Online (Sandbox Code Playgroud)
id:cidtaglib函数在哪里定义如下:
public static String cid(UIComponent component) {
FacesContext context = FacesContext.getCurrentInstance();
return component.getClientId(context);
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,binding="#{foo}"不绑定到"支持bean中的UI组件的Java实例".
那么表达式的含义是binding="#{foo}"什么?
我正在尝试将名为datasource的xml文件添加oracle-ds.xml到我的JBoss 7.1文件夹中,以便我在该服务器上部署的项目可以使用该数据源.
正如在jboss.org上解释的那样,我需要将该文件放在deployments文件夹中.
这就是我做的.但与他们在上面的链接中所说的不同,我在我的本地maven存储库中有我的Orcale驱动程序jar.无论如何,maven能够建立这个项目.
现在,当我重新启动Jboss时,它似乎被oracle-ds.xml视为需要部署的项目(jar),而不是作为xml设置文件......
以下是Jboss重启过程中的一些控制台输出:
15:58:16,666 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "oracle-ds.xml"
15:58:16,728 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.deployment.unit."oracle-ds.xml".PARSE: org.jboss.msc.se
rvice.StartException in service jboss.deployment.unit."oracle-ds.xml".PARSE: Failed to process phase PARSE of deployment "oracle-ds.xml"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_29]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_29]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_29]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: IJ010061: Unexpected element: local-tx-datasource
at org.jboss.as.connector.deployers.processors.DsXmlDeploymentParsingProcessor.deploy(DsXmlDeploymentParsingProcessor.java:85)
at …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用jTDS连接器jtds-1.3.1.jar从Sql Develper 4.0.3.16连接到Sql Server 2012.
操作系统:Ubuntu 14.04
Java的:
~$ java -version
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)
Run Code Online (Sandbox Code Playgroud)
在创建连接窗口中,当我测试连接时,它是成功的.
当我打开连接时,我可以看到所有数据库.当我尝试打开一个我应该有权打开的数据库时,我收到以下错误窗口:

有任何想法吗?
PS如果微软有一个JDBC驱动程序 sqljdbc4-4.0.jar(当我从Java代码连接到Sql Server 2012时它适用于我),为什么我必须使用jTDS才能将Sql开发人员连接到Sql Server?当我尝试将它用作连接器时,似乎Sql Developer不接受Microsoft jdbc驱动程序.
点击之前 +

点击后 +

我的项目包括较旧的未注释控制器以及较新的基于注释的控制器.
我正在使用最新的Spring jar(3.0.5)和我的dispatcher-servlet.xml <mvc:annotation-driven />.
问题是<mvc:annotation-driven />导致请求映射(通过dispatcher-servlet.xml中的控制器bean的name属性)到我的未注释的控制器不工作...每次我将请求定向到未注释的控制器我我收到一条错误消息,例如:
org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/some_path/some_page.htm] in DispatcherServlet with name 'dispatcher'
Run Code Online (Sandbox Code Playgroud)
如何保持未注释的控制器,但告诉spring识别他们的(旧式)映射?
我正在寻找解决方案,对我已有的控制器的Java代码进行最小的更改.
谢谢!
我使用以下代码来缩进作为字符串提供给我的 xml 文档。
我正在使用 的 JDK 实现org.w3c.dom.ls,如果这很重要的话。
http://docs.oracle.com/javase/7/docs/api/org/w3c/dom/ls/package-summary.html
public String format(String xml) {
try {
final InputSource src = new InputSource(new StringReader(xml));
final Node document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(src).getDocumentElement();
final Boolean keepDeclaration = Boolean.valueOf(xml.startsWith("<?xml"));
//May need this: System.setProperty(DOMImplementationRegistry.PROPERTY,"com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
final DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
final DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
final LSSerializer writer = impl.createLSSerializer();
writer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE); // Set this to true if the output needs to be beautified.
writer.getDomConfig().setParameter("xml-declaration", keepDeclaration); // Set this to true if the declaration is needed …Run Code Online (Sandbox Code Playgroud) java ×4
apache-camel ×2
spring-mvc ×2
tomcat7 ×2
annotations ×1
bash ×1
binding ×1
components ×1
cxf ×1
cxfrs ×1
datasource ×1
deployment ×1
el ×1
java-7 ×1
jboss ×1
jboss7.x ×1
jsf ×1
jsf-2 ×1
jtds ×1
pipe ×1
rest ×1
shell ×1
spring ×1
sql-server ×1
stdin ×1
wadl ×1
xerces ×1
xml ×1
xml-parsing ×1