use of org.apache.camel.RuntimeCamelException in project camel by apache.
the class BindyKeyValuePairDataFormatAutoConfiguration method configureBindyKeyValuePairDataFormatFactory.
@Bean(name = "bindy-kvp-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BindyKeyValuePairDataFormat.class)
public DataFormatFactory configureBindyKeyValuePairDataFormatFactory(final CamelContext camelContext, final BindyKeyValuePairDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
BindyKeyValuePairDataFormat dataformat = new BindyKeyValuePairDataFormat();
if (CamelContextAware.class.isAssignableFrom(BindyKeyValuePairDataFormat.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 BoonDataFormatAutoConfiguration method configureBoonDataFormatFactory.
@Bean(name = "boon-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BoonDataFormat.class)
public DataFormatFactory configureBoonDataFormatFactory(final CamelContext camelContext, final BoonDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
BoonDataFormat dataformat = new BoonDataFormat();
if (CamelContextAware.class.isAssignableFrom(BoonDataFormat.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 CastorDataFormatAutoConfiguration method configureCastorDataFormatFactory.
@Bean(name = "castor-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(CastorDataFormat.class)
public DataFormatFactory configureCastorDataFormatFactory(final CamelContext camelContext, final CastorDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
CastorDataFormat dataformat = new CastorDataFormat();
if (CamelContextAware.class.isAssignableFrom(CastorDataFormat.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 BarcodeDataFormatAutoConfiguration method configureBarcodeDataFormatFactory.
@Bean(name = "barcode-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BarcodeDataFormat.class)
public DataFormatFactory configureBarcodeDataFormatFactory(final CamelContext camelContext, final BarcodeDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
BarcodeDataFormat dataformat = new BarcodeDataFormat();
if (CamelContextAware.class.isAssignableFrom(BarcodeDataFormat.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 Olingo2AppWrapper method getEdm.
// double checked locking based singleton Edm reader
public Edm getEdm() throws RuntimeCamelException {
Edm localEdm = edm;
if (localEdm == null) {
synchronized (this) {
localEdm = edm;
if (localEdm == null) {
final CountDownLatch latch = new CountDownLatch(1);
final Exception[] error = new Exception[1];
olingo2App.read(null, "$metadata", null, new Olingo2ResponseHandler<Edm>() {
@Override
public void onResponse(Edm response) {
edm = response;
latch.countDown();
}
@Override
public void onException(Exception ex) {
error[0] = ex;
latch.countDown();
}
@Override
public void onCanceled() {
error[0] = new RuntimeCamelException("OData HTTP request cancelled!");
latch.countDown();
}
});
try {
// wait until response or timeout
latch.await();
final Exception ex = error[0];
if (ex != null) {
if (ex instanceof RuntimeCamelException) {
throw (RuntimeCamelException) ex;
} else {
final String message = ex.getMessage() != null ? ex.getMessage() : ex.getClass().getName();
throw new RuntimeCamelException("Error reading EDM: " + message, ex);
}
}
} catch (InterruptedException e) {
throw new RuntimeCamelException(e.getMessage(), e);
}
localEdm = edm;
}
}
}
return localEdm;
}
Aggregations