On 10/31/11 4:04 AM, Chad Beaulac wrote:
Maybe I don't have all of the auto discovery setup correctly.
The *META-INF/services/org/apache/camel/component/mina2 file looks like
this:
class=org.apache.camel.component.mina2.Mina2Component
It looks good. I'm not sure if this file is a part of your camel-mina2
bundle?
My Mina2Component is very straight-forard and looks like this:
public class Mina2Component extends DefaultComponent {
private static final transient Logger LOG =
LoggerFactory.getLogger(Mina2Component.class);
private Mina2Configuration configuration;
public Mina2Component() {
}
public Mina2Component(CamelContext context) {
super(context);
}
@Override
protected Endpoint createEndpoint(String uri, String remaining,
Map<String, Object> parameters) throws Exception {
// Using the configuration which set by the component as a default one
// Since the configuration's properties will be set by the URI
// we need to copy or create a new MinaConfiguration here
Mina2Configuration config;
if (configuration != null) {
config = configuration.copy();
}
else {
config = new Mina2Configuration();
}
URI u = new URI(remaining);
config.setHost(u.getHost());
config.setPort(u.getPort());
config.setProtocol(u.getScheme());
config.setFilters(resolveAndRemoveReferenceListParameter(parameters,
"filters", IoFilter.class));
setProperties(config, parameters);
return createEndpoint(uri, config);
}
public Endpoint createEndpoint(Mina2Configuration config) throws
Exception {
return createEndpoint(null, config);
}
private Endpoint createEndpoint(String uri, Mina2Configuration config)
throws Exception {
ObjectHelper.notNull(getCamelContext(), "camelContext");
configuration = config;
Endpoint epoint = null;
String protocol = config.getProtocol();
// if mistyped uri then protocol can be null
if (protocol != null) {
if (protocol.equals("tcp")
|| config.isDatagramProtocol()
|| protocol.equals("vm")) {
epoint = new Mina2Endpoint(uri, this);
}
else {
// protocol not resolved so error
throw new IllegalArgumentException("Unrecognised MINA protocol: " +
protocol + " for uri: " + uri);
}
}
return epoint;
}
// Properties
//-------------------------------------------------------------------------
public Mina2Configuration getConfiguration() {
return configuration;
}
public void setConfiguration(Mina2Configuration configuration) {
this.configuration = configuration;
}
}
Now what?
-Chad
*On Sun, Oct 30, 2011 at 3:40 PM, Johan Edstrom<seij...@gmail.com> wrote:
Do you have all of the auto discovery files there correctly?
http://camel.apache.org/writing-components.html
/je
On Oct 30, 2011, at 1:10 PM, Chad Beaulac wrote:
I'm working on a mina2 component. Unit tests that use the Java DSL pass.
Unit tests that use the TemplateProducer fail with an error like:
(From the Mina2ComponentTest.testMistypedProtocol)
org.apache.camel.ResolveEndpointFailedException: Failed to resolve
endpoint: mina2://tcp//localhost:8080 due to: No component found with
scheme:
mina2
Java DSL with something like the route below work fine:
from("mina2:udp://127.0.0.1:10111?sync=false&minaLogger=true
").to("mock:result");
Maybe I'm suppose to add something to features.xml but I'm not sure what
and I'm not sure if that's the issue.
Any insight/help is very appreciated.
Thanks,
Chad
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang