use of org.apache.camel.RuntimeCamelException in project camel by apache.
the class ZipFileDataFormatAutoConfiguration method configureZipFileDataFormatFactory.
@Bean(name = "zipfile-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(ZipFileDataFormat.class)
public DataFormatFactory configureZipFileDataFormatFactory(final CamelContext camelContext, final ZipFileDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
ZipFileDataFormat dataformat = new ZipFileDataFormat();
if (CamelContextAware.class.isAssignableFrom(ZipFileDataFormat.class)) {
CamelContextAware contextAware = CamelContextAware.class.cast(dataformat);
if (contextAware != null) {
contextAware.setCamelContext(camelContext);
}
}
try {
Map<String, Object> parameters = new HashMap<>();
IntrospectionSupport.getProperties(configuration, parameters, null, false);
IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), dataformat, parameters);
} catch (Exception e) {
throw new RuntimeCamelException(e);
}
return dataformat;
}
};
}
use of org.apache.camel.RuntimeCamelException in project camel by apache.
the class ServiceInterfaceStrategy method findQNameForSoapActionOrType.
/**
* Determine the QName of the method parameter of the method that matches
* either soapAction and type or if not possible only the type
*
* @param soapAction
* @param type
* @return matching QName throws RuntimeException if no matching QName was
* found
*/
public QName findQNameForSoapActionOrType(String soapAction, Class<?> type) {
MethodInfo info = soapActionToMethodInfo.get(soapAction);
if (info != null) {
if (isClient) {
if (type != null) {
return info.getIn(type.getName()).getElName();
} else {
return null;
}
} else {
return info.getOut().getElName();
}
}
QName qName = null;
if (type != null) {
if (isClient) {
qName = inTypeNameToQName.get(type.getName());
} else {
qName = outTypeNameToQName.get(type.getName());
}
}
if (qName == null) {
try {
qName = fallBackStrategy.findQNameForSoapActionOrType(soapAction, type);
} catch (Exception e) {
String msg = "No method found that matches the given SoapAction " + soapAction + " or that has an " + (isClient ? "input" : "output") + " of type " + type.getName();
throw new RuntimeCamelException(msg, e);
}
}
return qName;
}
use of org.apache.camel.RuntimeCamelException in project camel by apache.
the class ServiceInterfaceStrategyTest method testServiceInterfaceStrategyWithClient.
@Test
public void testServiceInterfaceStrategyWithClient() {
ServiceInterfaceStrategy strategy = new ServiceInterfaceStrategy(CustomerService.class, true);
QName elName = strategy.findQNameForSoapActionOrType("", GetCustomersByName.class);
assertEquals("http://customerservice.example.com/", elName.getNamespaceURI());
assertEquals("getCustomersByName", elName.getLocalPart());
QName elName2 = strategy.findQNameForSoapActionOrType("getCustomersByName", GetCustomersByName.class);
assertEquals("http://customerservice.example.com/", elName2.getNamespaceURI());
assertEquals("getCustomersByName", elName2.getLocalPart());
// Tests the case where the soap action is found but the in type is null
QName elName3 = strategy.findQNameForSoapActionOrType("http://customerservice.example.com/getAllCustomers", null);
assertNull(elName3);
QName elName4 = strategy.findQNameForSoapActionOrType("http://customerservice.example.com/getAllAmericanCustomers", null);
assertNull(elName4);
try {
elName = strategy.findQNameForSoapActionOrType("test", Class.class);
fail();
} catch (RuntimeCamelException e) {
LOG.debug("Caught expected message: " + e.getMessage());
}
}
use of org.apache.camel.RuntimeCamelException in project camel by apache.
the class ServiceInterfaceStrategyTest method testServiceInterfaceStrategyWithServer.
@Test
public void testServiceInterfaceStrategyWithServer() {
ServiceInterfaceStrategy strategy = new ServiceInterfaceStrategy(CustomerService.class, false);
// Tests the case where the action is not found but the type is
QName elName = strategy.findQNameForSoapActionOrType("", GetCustomersByNameResponse.class);
assertEquals("http://customerservice.example.com/", elName.getNamespaceURI());
assertEquals("getCustomersByNameResponse", elName.getLocalPart());
// Tests the case where the soap action is found
QName elName2 = strategy.findQNameForSoapActionOrType("http://customerservice.example.com/getCustomersByName", GetCustomersByName.class);
assertEquals("http://customerservice.example.com/", elName2.getNamespaceURI());
assertEquals("getCustomersByNameResponse", elName2.getLocalPart());
// found
try {
elName = strategy.findQNameForSoapActionOrType("test", Class.class);
fail();
} catch (RuntimeCamelException e) {
LOG.debug("Caught expected message: " + e.getMessage());
}
}
use of org.apache.camel.RuntimeCamelException in project camel by apache.
the class ServiceInterfaceStrategyTest method testServiceInterfaceStrategyWithRequestWrapperAndClient.
@Test
public void testServiceInterfaceStrategyWithRequestWrapperAndClient() {
ServiceInterfaceStrategy strategy = new ServiceInterfaceStrategy(com.example.customerservice2.CustomerService.class, true);
QName elName = strategy.findQNameForSoapActionOrType("", com.example.customerservice2.GetCustomersByName.class);
assertEquals("http://customerservice2.example.com/", elName.getNamespaceURI());
assertEquals("getCustomersByName", elName.getLocalPart());
try {
elName = strategy.findQNameForSoapActionOrType("test", Class.class);
fail();
} catch (RuntimeCamelException e) {
LOG.debug("Caught expected message: " + e.getMessage());
}
}
Aggregations