You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2010/03/15 07:21:27 UTC
svn commit: r923074 - in
/servicemix/components/engines/servicemix-cxf-se/trunk/src:
main/java/org/apache/servicemix/cxfse/ test/java/org/apache/servicemix/cxfse/
test/resources/org/apache/servicemix/cxfse/
Author: ffang
Date: Mon Mar 15 06:21:27 2010
New Revision: 923074
URL: http://svn.apache.org/viewvc?rev=923074&view=rev
Log:
[SMXCOMP-724]add pojoService/pojoEndpoint to control the service/endpoint name used for the servicemodel which is generated from pojo
Added:
servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CodeFirstTest.java
servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/PersonImpl.java
servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/code_first.xml
Modified:
servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java
Modified: servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java?rev=923074&r1=923073&r2=923074&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java (original)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java Mon Mar 15 06:21:27 2010
@@ -117,7 +117,7 @@ public class CxfSeEndpoint extends Provi
private boolean useXmlBeans;
private QName pojoService;
- private String pojoEndpoint;
+ private QName pojoEndpoint;
private QName pojoInterfaceName;
private Server soapBindingServer;
@@ -269,6 +269,12 @@ public class CxfSeEndpoint extends Provi
if (isUseJBIWrapper()) {
sf.setBindingId(org.apache.cxf.binding.jbi.JBIConstants.NS_JBI_BINDING);
}
+ if (getPojoService() != null) {
+ sf.setServiceName(getPojoService());
+ }
+ if (getPojoEndpoint() != null) {
+ sf.setEndpointName(getPojoEndpoint());
+ }
server = sf.create();
server.getEndpoint().getInInterceptors().addAll(getInInterceptors());
server.getEndpoint().getInFaultInterceptors().addAll(getInFaultInterceptors());
@@ -279,13 +285,17 @@ public class CxfSeEndpoint extends Provi
server.getEndpoint().getOutInterceptors().add(new AttachmentOutInterceptor());
}
if (sf.getServiceFactory().getServiceQName() != null) {
- setPojoService(sf.getServiceFactory().getServiceQName());
+ if (getPojoService() == null) {
+ setPojoService(sf.getServiceFactory().getServiceQName());
+ }
if (getService() == null) {
setService(sf.getServiceFactory().getServiceQName());
}
}
if (sf.getServiceFactory().getEndpointInfo().getName() != null) {
- setPojoEndpoint(sf.getServiceFactory().getEndpointInfo().getName().getLocalPart());
+ if (getPojoEndpoint() == null) {
+ setPojoEndpoint(sf.getServiceFactory().getEndpointInfo().getName());
+ }
if (getEndpoint() == null) {
setEndpoint(sf.getServiceFactory().getEndpointInfo().getName().getLocalPart());
}
@@ -299,6 +309,12 @@ public class CxfSeEndpoint extends Provi
} else {
JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
serviceFactory.setPopulateFromClass(true);
+ if (getPojoService() != null) {
+ serviceFactory.setServiceName(getPojoService());
+ }
+ if (getPojoEndpoint() != null) {
+ serviceFactory.setEndpointName(getPojoEndpoint());
+ }
endpoint = new EndpointImpl(getBus(), getPojo(), new JaxWsServerFactoryBean(serviceFactory));
if (isUseJBIWrapper()) {
endpoint.setBindingUri(org.apache.cxf.binding.jbi.JBIConstants.NS_JBI_BINDING);
@@ -315,9 +331,13 @@ public class CxfSeEndpoint extends Provi
endpoint.getOutInterceptors().add(new AttachmentOutInterceptor());
}
JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(getPojo().getClass());
- setPojoService(implInfo.getServiceName());
+ if (getPojoService() == null) {
+ setPojoService(implInfo.getServiceName());
+ }
setPojoInterfaceName(implInfo.getInterfaceName());
- setPojoEndpoint(implInfo.getEndpointName().getLocalPart());
+ if (getPojoEndpoint() == null ) {
+ setPojoEndpoint(implInfo.getEndpointName());
+ }
if (getService() == null) {
setService(implInfo.getServiceName());
}
@@ -347,7 +367,7 @@ public class CxfSeEndpoint extends Provi
.getName().getLocalPart());
}
setPojoService(server.getEndpoint().getService().getName());
- setPojoEndpoint(server.getEndpoint().getEndpointInfo().getName().getLocalPart());
+ setPojoEndpoint(server.getEndpoint().getEndpointInfo().getName());
if (!isUseJBIWrapper() && !isUseSOAPEnvelope()) {
// cleanup interceptors
removeInterceptor(server.getEndpoint().getBinding().getInInterceptors(), "ReadHeadersInterceptor");
@@ -620,19 +640,33 @@ public class CxfSeEndpoint extends Provi
return useAegis;
}
- protected void setPojoService(QName pojoService) {
+ /**
+ * Specifies the servicemodel service name generated from the pojo
+ *
+ * @org.apache.xbean.Property description="Specifies the servicemodel
+ * service name generated from the pojo.
+ * The default is <code>null</code>.
+ */
+ public void setPojoService(QName pojoService) {
this.pojoService = pojoService;
}
- protected QName getPojoService() {
+ public QName getPojoService() {
return pojoService;
}
- protected void setPojoEndpoint(String pojoEndpoint) {
+ /**
+ * Specifies the servicemodel endpoint name generated from the pojo
+ *
+ * @org.apache.xbean.Property description="Specifies the servicemodel
+ * endpoint name generated from the pojo.
+ * The default is <code>null</code>.
+ */
+ public void setPojoEndpoint(QName pojoEndpoint) {
this.pojoEndpoint = pojoEndpoint;
}
- protected String getPojoEndpoint() {
+ public QName getPojoEndpoint() {
return pojoEndpoint;
}
Added: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CodeFirstTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CodeFirstTest.java?rev=923074&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CodeFirstTest.java (added)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CodeFirstTest.java Mon Mar 15 06:21:27 2010
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.cxfse;
+
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+public class CodeFirstTest extends SpringTestSupport {
+
+ private DefaultServiceMixClient client;
+ private InOut io;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ client = new DefaultServiceMixClient(jbi);
+
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testAegis() throws Exception {
+ io = client.createInOutExchange();
+ io.setService(new QName("http://code_first/test", "PersonImpl"));
+ io.setInterfaceName(new QName("http://code_first/test", "Person"));
+ io.setOperation(new QName("http://code_first/test", "GetPerson"));
+ io.getInMessage().setContent(new StringSource(
+ "<message xmlns=\"http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper\">"
+ + "<part>"
+ + "<GetPerson xmlns=\"http://code_first/test\">"
+ + "<personId>world</personId>"
+ + "</GetPerson>"
+ + "</part>"
+ + "</message>"));
+ client.sendSync(io);
+
+ assertTrue(new SourceTransformer().contentToString(
+ io.getOutMessage()).indexOf("ffang") >= 0);
+ client.done(io);
+ }
+
+ @Override
+ protected AbstractXmlApplicationContext createBeanFactory() {
+ return new ClassPathXmlApplicationContext("org/apache/servicemix/cxfse/code_first.xml");
+ }
+
+}
Added: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/PersonImpl.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/PersonImpl.java?rev=923074&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/PersonImpl.java (added)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/PersonImpl.java Mon Mar 15 06:21:27 2010
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.cxfse;
+
+public class PersonImpl {
+ public String GetPerson(String personId) {
+ if (personId == null || personId.length() == 0) {
+ return "null";
+ }
+ return personId = "ffang";
+ }
+
+}
Added: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/code_first.xml
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/code_first.xml?rev=923074&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/code_first.xml (added)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/code_first.xml Mon Mar 15 06:21:27 2010
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
+ xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0"
+ xmlns:person="http://code_first/test">
+
+ <sm:container id="jbi" embedded="true">
+
+ <sm:endpoints>
+ <cxfse:endpoint useAegis="true" service="person:PersonImpl" pojoService="person:PersonImpl">
+ <cxfse:pojo>
+ <bean class="org.apache.servicemix.cxfse.PersonImpl">
+ </bean>
+
+ </cxfse:pojo>
+ <cxfse:inInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+ </cxfse:inInterceptors>
+ <cxfse:outInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+ </cxfse:outInterceptors>
+ <cxfse:inFaultInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+ </cxfse:inFaultInterceptors>
+ <cxfse:outFaultInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+ </cxfse:outFaultInterceptors>
+ </cxfse:endpoint>
+ </sm:endpoints>
+
+ </sm:container>
+
+</beans>