Hi Welcome to the community.
We could do this from the existing camel-hl7 component, by including a mllp component. That would be the better place to add this component. Feel free to work on a patch, and attach it to a JIRA ticket. Remember to mark [x] in grant license to Apache. On Thu, May 17, 2012 at 12:07 PM, sekaijin <jean-yves.terr...@sap.aphp.fr> wrote: > Hello, > > > I know it is already possible to define camel endpoint MLLP. But I think a > camel-mllp component would be welcome. > > > I therefore propose to add it. this would avoid having to add each time the > same code to set the codec. > > > I have in my project numerous endpoint mllp and I noticed that the > developpers diverge more or less on how to go about it. > the code: from ("mllp://host:8808") is easy to implement and does not cause > confusion. > > > So I defined a camel-mllp componet which extends camel-mina. > this component does is create a codec mllp and delegates the rest of the > work to Mina. it is simple to implement. > > > I therefore propose to bring this component (or the idea of such a > component) in the incubator. > > > the component being reduced to a single class I think the camel maintenace > code will not be more complicated. > > > http://camel.465427.n5.nabble.com/file/n5711304/camel-mllp.zip > camel-mllp.zip > /** > * 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.camel.component.mllp; > > import java.util.Map; > > import org.apache.camel.CamelContext; > import org.apache.camel.Endpoint; > import org.apache.camel.component.hl7.HL7MLLPCodec; > import org.apache.camel.component.mina.MinaComponent; > import org.apache.camel.component.mina.MinaConfiguration; > > /** > * Component for Apache MLLP. > * Camel MLLP extends Camel Mina. > * It accept all mina options. except the codec option. > * Camel-MLLP always uses the codec HL7MLLPCodec. > * If the codec option is present, an IllegalArgumentException is thrown. > * usage: > * from ("mllp://localhost:8889?encoding=ISO-8859-1") > * > * @version > */ > public class MLLPComponent extends MinaComponent > { > /** > * MLLP_DEFAULT_CHARSET default encodingt: UTF-8 > */ > public static final String MLLP_DEFAULT_CHARSET = "UTF-8"; > /** > * MLLP_CHARSET encoding option name. > */ > public static final String MLLP_CHARSET = "encoding"; > /** > * MINA_CODEC mina codec option name. > */ > public static final String MINA_CODEC = "codec"; > /** > * MLLP_DEFAULT_SYNC default exchange pattern: true > */ > public static final boolean MLLP_DEFAULT_SYNC = true; > /** > * MLLP_SYNC exchange pattern Option name > */ > public static final String MLLP_SYNC = "sync"; > > > public MLLPComponent(){ > super(); > } > > public MLLPComponent(final CamelContext context){ > super(context); > } > > /** > * A factory method allowing derived components to create a new mina > endpoint > * from the given URI, remaining path and optional parameters > * > * @param uri the full URI of the endpoint > * @param remaining the remaining part of the URI without the query > * parameters or component prefix > * @param parameters the optional parameters passed in > * @return a newly created mina endpoint or null if the endpoint cannot > be > * created based on the inputs > */ > @Override > protected Endpoint createEndpoint(String uri, String remaining, > Map<String, Object> parameters) > throws Exception{ > > String charSet = MLLP_DEFAULT_CHARSET; > > //set config properties > if(parameters.containsKey(MLLP_CHARSET)){ > charSet = (String) parameters.get(MLLP_CHARSET); > parameters.remove(MLLP_CHARSET); > } > if(!parameters.containsKey(MLLP_SYNC)){ > parameters.put(MLLP_SYNC, MLLP_DEFAULT_SYNC); > } > > if(parameters.containsKey(MINA_CODEC)){ > throw new IllegalArgumentException("Unrecognised MLLP " + > MINA_CODEC + ": the " + MINA_CODEC > + " option is not supported"); > } > > //define config with codec. > this.setConfiguration(getDefaultConfig(charSet)); > > //call mina ceateEndPoint for TCP socket. > return super.createEndpoint(uri, "tcp://" + remaining, parameters); > } > > /** > * Create new mina configuration > * Create a new mina configuration that contains a new instance of > HL7MLLPCodec set with charSet > * @param charSet encoding for HL7MLLPCodec > * @return a newly created mina configuration > */ > private MinaConfiguration getDefaultConfig(String charSet){ > final MinaConfiguration config = new MinaConfiguration(); > final HL7MLLPCodec mllp = new HL7MLLPCodec(); > mllp.setCharset(charSet); > config.setCodec(mllp); > return config; > } > } > > > A+JYT > > PS: I'm Running camel 2.8.0 sandalone and 2.8.0 in fuse > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Suggest-Add-a-camel-mllp-component-into-the-incubator-tp5711304.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/