本文整理汇总了Java中javax.xml.bind.Binder类的典型用法代码示例。如果您正苦于以下问题:Java Binder类的具体用法?Java Binder怎么用?Java Binder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Binder类属于javax.xml.bind包,在下文中一共展示了Binder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doParse
import javax.xml.bind.Binder; //导入依赖的package包/类
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
doBeforeParse(element);
super.doParse(element, parserContext, builder);
// now lets parse the routes with JAXB
Binder<Node> binder;
try {
binder = getJaxbContext().createBinder();
} catch (JAXBException e) {
throw new BeanDefinitionStoreException("Failed to create the JAXB binder", e);
}
Object value = parseUsingJaxb(element, parserContext, binder);
if (value instanceof CamelRouteContextFactoryBean) {
CamelRouteContextFactoryBean factoryBean = (CamelRouteContextFactoryBean) value;
builder.addPropertyValue("routes", factoryBean.getRoutes());
}
// lets inject the namespaces into any namespace aware POJOs
injectNamespaces(element, binder);
}
示例2: registerEndpointsWithIdsDefinedInFromOrToTypes
import javax.xml.bind.Binder; //导入依赖的package包/类
/**
* Used for auto registering endpoints from the <tt>from</tt> or <tt>to</tt> DSL if they have an id attribute set
*/
protected void registerEndpointsWithIdsDefinedInFromOrToTypes(Element element, ParserContext parserContext, String contextId, Binder<Node> binder) {
NodeList list = element.getChildNodes();
int size = list.getLength();
for (int i = 0; i < size; i++) {
Node child = list.item(i);
if (child instanceof Element) {
Element childElement = (Element) child;
Object object = binder.getJAXBNode(child);
// we only want from/to types to be registered as endpoints
if (object instanceof FromDefinition || object instanceof SendDefinition) {
registerEndpoint(childElement, parserContext, contextId);
}
// recursive
registerEndpointsWithIdsDefinedInFromOrToTypes(childElement, parserContext, contextId, binder);
}
}
}
示例3: createCamelModelObjectFromXML
import javax.xml.bind.Binder; //导入依赖的package包/类
/**
* Creates camel model object like CamelContextFactoryBean, RouteDefinition or RoutesDefinition
* from XML file.
*
* @param xmlPath path to the file
* @return created camel model object
* @throws Exception failed to unmarshall camel model object from XML file
*/
public static Object createCamelModelObjectFromXML(String xmlPath) throws Exception {
InputStream input = Classes.getResourceAsStream(xmlPath);
if (input == null) {
throw CommonCamelMessages.MESSAGES.specifiedCamelContextFileIsNotFound(xmlPath);
}
InputSource source = new InputSource(input);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(source);
Element element = document.getDocumentElement();
Element camelModelElement = findCamelModelElement(element, xmlPath);
if (camelModelElement == null) {
throw CommonCamelMessages.MESSAGES.noCamelContextElementFound(xmlPath);
}
Binder<Node> binder = JAXB_CONTEXT.createBinder();
Object obj = binder.unmarshal(camelModelElement);
injectNamespaces(camelModelElement, binder);
return obj;
}
示例4: extractFromSearch
import javax.xml.bind.Binder; //导入依赖的package包/类
Identifier extractFromSearch(SearchType search, Binder<Node> binder)
throws InvalidIdentifierException, UnmarshalException {
NullCheck.check(search, "search null");
Object o = null;
if (search.getAccessRequest() != null) {
o = search.getAccessRequest();
} else if (search.getDevice() != null) {
o = search.getDevice();
} else if (search.getIdentity() != null) {
o = search.getIdentity();
} else if (search.getIpAddress() != null) {
o = search.getIpAddress();
} else if (search.getMacAddress() != null) {
o = search.getMacAddress();
} else {
throw new UnmarshalException("identifier not set in search");
}
return transformJaxbObjectToIdentifier(o, binder);
}
示例5: extractIdentifierArray
import javax.xml.bind.Binder; //导入依赖的package包/类
/**
* Helper for the last 3 methods
*
* @param olist
* @param max
* @return
* @throws UnmarshalException
* @throws InvalidIdentifierException
*/
private Identifier[] extractIdentifierArray(List<Object> olist, int max,
Binder<Node> binder) throws UnmarshalException, InvalidIdentifierException {
Identifier ret[];
if (olist == null) {
throw new UnmarshalException("no identifiers in publish");
}
if (olist.size() == 0 || olist.size() > max) {
throw new UnmarshalException("bad number of identifiers in update");
}
ret = new Identifier[max];
for (int i = 0; i < olist.size(); i++) {
Object o = olist.get(i);
if (o == null) {
throw new UnmarshalException("invalid identifier");
}
ret[i] = transformJaxbObjectToIdentifier(o, binder);
}
return ret;
}
示例6: createBinder
import javax.xml.bind.Binder; //导入依赖的package包/类
@Override
public <T> Binder<T> createBinder(Class<T> domType) {
if(domType==Node.class)
return (Binder<T>)createBinder();
else
return super.createBinder(domType);
}
示例7: parseRestContextNode
import javax.xml.bind.Binder; //导入依赖的package包/类
private Metadata parseRestContextNode(Element element, ParserContext context) {
LOG.trace("Parsing RestContext {}", element);
// now parse the rests with JAXB
Binder<Node> binder;
try {
binder = getJaxbContext().createBinder();
} catch (JAXBException e) {
throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
}
Object value = parseUsingJaxb(element, context, binder);
if (!(value instanceof CamelRestContextFactoryBean)) {
throw new ComponentDefinitionException("Expected an instance of " + CamelRestContextFactoryBean.class);
}
CamelRestContextFactoryBean rcfb = (CamelRestContextFactoryBean) value;
String id = rcfb.getId();
MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
factory.setId(".camelBlueprint.passThrough." + id);
factory.setObject(new PassThroughCallable<Object>(rcfb));
MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
factory2.setId(".camelBlueprint.factory." + id);
factory2.setFactoryComponent(factory);
factory2.setFactoryMethod("call");
MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
ctx.setId(id);
ctx.setRuntimeClass(List.class);
ctx.setFactoryComponent(factory2);
ctx.setFactoryMethod("getRests");
// must be lazy as we want CamelContext to be activated first
ctx.setActivation(ACTIVATION_LAZY);
// lets inject the namespaces into any namespace aware POJOs
injectNamespaces(element, binder);
LOG.trace("Parsing RestContext done, returning {}", element, ctx);
return ctx;
}
示例8: parseEndpointNode
import javax.xml.bind.Binder; //导入依赖的package包/类
private Metadata parseEndpointNode(Element element, ParserContext context) {
LOG.trace("Parsing Endpoint {}", element);
// now parse the rests with JAXB
Binder<Node> binder;
try {
binder = getJaxbContext().createBinder();
} catch (JAXBException e) {
throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
}
Object value = parseUsingJaxb(element, context, binder);
if (!(value instanceof CamelEndpointFactoryBean)) {
throw new ComponentDefinitionException("Expected an instance of " + CamelEndpointFactoryBean.class);
}
CamelEndpointFactoryBean rcfb = (CamelEndpointFactoryBean) value;
String id = rcfb.getId();
MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
factory.setId(".camelBlueprint.passThrough." + id);
factory.setObject(new PassThroughCallable<Object>(rcfb));
MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
factory2.setId(".camelBlueprint.factory." + id);
factory2.setFactoryComponent(factory);
factory2.setFactoryMethod("call");
factory2.setInitMethod("afterPropertiesSet");
factory2.setDestroyMethod("destroy");
factory2.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
ctx.setId(id);
ctx.setRuntimeClass(Endpoint.class);
ctx.setFactoryComponent(factory2);
ctx.setFactoryMethod("getObject");
// must be lazy as we want CamelContext to be activated first
ctx.setActivation(ACTIVATION_LAZY);
LOG.trace("Parsing endpoint done, returning {}", element, ctx);
return ctx;
}
示例9: parseKeyStoreParametersNode
import javax.xml.bind.Binder; //导入依赖的package包/类
private Metadata parseKeyStoreParametersNode(Element element, ParserContext context) {
LOG.trace("Parsing KeyStoreParameters {}", element);
// now parse the key store parameters with JAXB
Binder<Node> binder;
try {
binder = getJaxbContext().createBinder();
} catch (JAXBException e) {
throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
}
Object value = parseUsingJaxb(element, context, binder);
if (!(value instanceof KeyStoreParametersFactoryBean)) {
throw new ComponentDefinitionException("Expected an instance of " + KeyStoreParametersFactoryBean.class);
}
KeyStoreParametersFactoryBean kspfb = (KeyStoreParametersFactoryBean) value;
String id = kspfb.getId();
MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
factory.setId(".camelBlueprint.passThrough." + id);
factory.setObject(new PassThroughCallable<Object>(kspfb));
MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
factory2.setId(".camelBlueprint.factory." + id);
factory2.setFactoryComponent(factory);
factory2.setFactoryMethod("call");
factory2.setInitMethod("afterPropertiesSet");
factory2.setDestroyMethod("destroy");
factory2.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
ctx.setId(id);
ctx.setRuntimeClass(KeyStoreParameters.class);
ctx.setFactoryComponent(factory2);
ctx.setFactoryMethod("getObject");
// must be lazy as we want CamelContext to be activated first
ctx.setActivation(ACTIVATION_LAZY);
LOG.trace("Parsing KeyStoreParameters done, returning {}", ctx);
return ctx;
}
示例10: parseSecureRandomParametersNode
import javax.xml.bind.Binder; //导入依赖的package包/类
private Metadata parseSecureRandomParametersNode(Element element, ParserContext context) {
LOG.trace("Parsing SecureRandomParameters {}", element);
// now parse the key store parameters with JAXB
Binder<Node> binder;
try {
binder = getJaxbContext().createBinder();
} catch (JAXBException e) {
throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
}
Object value = parseUsingJaxb(element, context, binder);
if (!(value instanceof SecureRandomParametersFactoryBean)) {
throw new ComponentDefinitionException("Expected an instance of " + SecureRandomParametersFactoryBean.class);
}
SecureRandomParametersFactoryBean srfb = (SecureRandomParametersFactoryBean) value;
String id = srfb.getId();
MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
factory.setId(".camelBlueprint.passThrough." + id);
factory.setObject(new PassThroughCallable<Object>(srfb));
MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
factory2.setId(".camelBlueprint.factory." + id);
factory2.setFactoryComponent(factory);
factory2.setFactoryMethod("call");
factory2.setInitMethod("afterPropertiesSet");
factory2.setDestroyMethod("destroy");
factory2.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
ctx.setId(id);
ctx.setRuntimeClass(SecureRandomParameters.class);
ctx.setFactoryComponent(factory2);
ctx.setFactoryMethod("getObject");
// must be lazy as we want CamelContext to be activated first
ctx.setActivation(ACTIVATION_LAZY);
LOG.trace("Parsing SecureRandomParameters done, returning {}", ctx);
return ctx;
}
示例11: parseSSLContextParametersNode
import javax.xml.bind.Binder; //导入依赖的package包/类
private Metadata parseSSLContextParametersNode(Element element, ParserContext context) {
LOG.trace("Parsing SSLContextParameters {}", element);
// now parse the key store parameters with JAXB
Binder<Node> binder;
try {
binder = getJaxbContext().createBinder();
} catch (JAXBException e) {
throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
}
Object value = parseUsingJaxb(element, context, binder);
if (!(value instanceof SSLContextParametersFactoryBean)) {
throw new ComponentDefinitionException("Expected an instance of " + SSLContextParametersFactoryBean.class);
}
SSLContextParametersFactoryBean scpfb = (SSLContextParametersFactoryBean) value;
String id = scpfb.getId();
MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
factory.setId(".camelBlueprint.passThrough." + id);
factory.setObject(new PassThroughCallable<Object>(scpfb));
MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
factory2.setId(".camelBlueprint.factory." + id);
factory2.setFactoryComponent(factory);
factory2.setFactoryMethod("call");
factory2.setInitMethod("afterPropertiesSet");
factory2.setDestroyMethod("destroy");
factory2.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
ctx.setId(id);
ctx.setRuntimeClass(SSLContextParameters.class);
ctx.setFactoryComponent(factory2);
ctx.setFactoryMethod("getObject");
// must be lazy as we want CamelContext to be activated first
ctx.setActivation(ACTIVATION_LAZY);
LOG.trace("Parsing SSLContextParameters done, returning {}", ctx);
return ctx;
}
示例12: parseUsingJaxb
import javax.xml.bind.Binder; //导入依赖的package包/类
protected Object parseUsingJaxb(Element element, ParserContext parserContext, Binder<Node> binder) {
try {
return binder.unmarshal(element);
} catch (JAXBException e) {
throw new ComponentDefinitionException("Failed to parse JAXB element: " + e, e);
}
}
示例13: parseUsingJaxb
import javax.xml.bind.Binder; //导入依赖的package包/类
protected Object parseUsingJaxb(Element element, ParserContext parserContext, Binder<Node> binder) {
try {
return binder.unmarshal(element);
} catch (JAXBException e) {
throw new BeanDefinitionStoreException("Failed to parse JAXB element", e);
}
}
示例14: fromXMLString
import javax.xml.bind.Binder; //导入依赖的package包/类
public static WindowState fromXMLString(String s){
try {
JAXBContext context = JAXBContext.newInstance(WindowState.class);
Binder<Node> binder = context.createBinder();
Document doc = XMLUtils.parse(s);
return (WindowState)binder.unmarshal(doc);
} catch (Throwable e) {
return null;
}
}
示例15: deepCopy
import javax.xml.bind.Binder; //导入依赖的package包/类
/**
* Deep copy the script by serialising to xml and then deserialising.
* UUID is preserved.
*
* @param script
* @return
*/
public Script deepCopy(Script script) {
Binder<Node> binder = context.createBinder();
Document xml = toXML(script,binder);
Script ret = fromXML(xml,binder);
ret.setUuid(script.getUuid());
return ret;
}