use of org.apache.camel.RuntimeCamelException in project camel by apache.
the class WebsocketComponent method createServer.
protected Server createServer() throws Exception {
Server server = null;
if (minThreads == null && maxThreads == null && getThreadPool() == null) {
minThreads = 1;
// 1+selectors+acceptors
maxThreads = 1 + Runtime.getRuntime().availableProcessors() * 2;
}
// configure thread pool if min/max given
if (minThreads != null || maxThreads != null) {
if (getThreadPool() != null) {
throw new IllegalArgumentException("You cannot configure both minThreads/maxThreads and a custom threadPool on JettyHttpComponent: " + this);
}
QueuedThreadPool qtp = new QueuedThreadPool();
if (minThreads != null) {
qtp.setMinThreads(minThreads.intValue());
}
if (maxThreads != null) {
qtp.setMaxThreads(maxThreads.intValue());
}
// let the thread names indicate they are from the server
qtp.setName("CamelJettyWebSocketServer");
try {
qtp.start();
} catch (Exception e) {
throw new RuntimeCamelException("Error starting JettyWebSocketServer thread pool: " + qtp, e);
}
server = new Server(qtp);
ContextHandlerCollection collection = new ContextHandlerCollection();
server.setHandler(collection);
}
if (getThreadPool() != null) {
server = new Server(getThreadPool());
ContextHandlerCollection collection = new ContextHandlerCollection();
server.setHandler(collection);
}
return server;
}
use of org.apache.camel.RuntimeCamelException in project camel by apache.
the class ZipIterator method getNextElement.
private Message getNextElement() {
if (zipInputStream == null) {
return null;
}
try {
ZipEntry current = getNextEntry();
if (current != null) {
LOGGER.debug("read zipEntry {}", current.getName());
Message answer = new DefaultMessage();
answer.getHeaders().putAll(inputMessage.getHeaders());
answer.setHeader("zipFileName", current.getName());
answer.setHeader(Exchange.FILE_NAME, current.getName());
answer.setBody(new ZipInputStreamWrapper(zipInputStream));
return answer;
} else {
LOGGER.trace("close zipInputStream");
return null;
}
} catch (IOException exception) {
//Just wrap the IOException as CamelRuntimeException
throw new RuntimeCamelException(exception);
}
}
use of org.apache.camel.RuntimeCamelException in project camel by apache.
the class LZFDataFormatAutoConfiguration method configureLZFDataFormatFactory.
@Bean(name = "lzf-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(LZFDataFormat.class)
public DataFormatFactory configureLZFDataFormatFactory(final CamelContext camelContext, final LZFDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
LZFDataFormat dataformat = new LZFDataFormat();
if (CamelContextAware.class.isAssignableFrom(LZFDataFormat.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 ProtobufDataFormatAutoConfiguration method configureProtobufDataFormatFactory.
@Bean(name = "protobuf-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(ProtobufDataFormat.class)
public DataFormatFactory configureProtobufDataFormatFactory(final CamelContext camelContext, final ProtobufDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
ProtobufDataFormat dataformat = new ProtobufDataFormat();
if (CamelContextAware.class.isAssignableFrom(ProtobufDataFormat.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 NettyConfiguration method copy.
/**
* Returns a copy of this configuration
*/
public NettyConfiguration copy() {
try {
NettyConfiguration answer = (NettyConfiguration) clone();
// make sure the lists is copied in its own instance
List<ChannelHandler> encodersCopy = new ArrayList<ChannelHandler>(encoders);
answer.setEncoders(encodersCopy);
List<ChannelHandler> decodersCopy = new ArrayList<ChannelHandler>(decoders);
answer.setDecoders(decodersCopy);
return answer;
} catch (CloneNotSupportedException e) {
throw new RuntimeCamelException(e);
}
}
Aggregations