use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class EndpointReferenceUtils method setMetadata.
/**
* Sets the metadata on the provided endpoint reference.
* @param ref the endpoint reference.
* @param metadata the list of metadata source.
*/
public static void setMetadata(EndpointReferenceType ref, List<Source> metadata) throws EndpointUtilsException {
if (null != ref) {
MetadataType mt = getSetMetadata(ref);
List<Object> anyList = mt.getAny();
try {
for (Source source : metadata) {
Node node = null;
boolean doTransform = true;
if (source instanceof StreamSource) {
StreamSource ss = (StreamSource) source;
if (null == ss.getInputStream() && null == ss.getReader()) {
setWSDLLocation(ref, ss.getSystemId());
doTransform = false;
}
} else if (source instanceof DOMSource) {
node = ((DOMSource) source).getNode();
doTransform = false;
}
if (doTransform) {
DOMResult domResult = new DOMResult();
domResult.setSystemId(source.getSystemId());
node = StaxUtils.read(source);
node = domResult.getNode();
}
if (null != node) {
if (node instanceof Document) {
try {
((Document) node).setDocumentURI(source.getSystemId());
} catch (Exception ex) {
// ignore - not DOM level 3
}
node = node.getFirstChild();
}
while (node.getNodeType() != Node.ELEMENT_NODE) {
node = node.getNextSibling();
}
anyList.add(node);
}
}
} catch (XMLStreamException te) {
throw new EndpointUtilsException(new Message("COULD_NOT_POPULATE_EPR", LOG), te);
}
}
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class ProviderImpl method createEndpoint.
// new in 2.2
public Endpoint createEndpoint(String bindingId, Object implementor, WebServiceFeature... features) {
EndpointImpl ep = null;
if (EndpointUtils.isValidImplementor(implementor)) {
Bus bus = BusFactory.getThreadDefaultBus();
ep = createEndpointImpl(bus, bindingId, implementor, features);
return ep;
}
throw new WebServiceException(new Message("INVALID_IMPLEMENTOR_EXC", LOG).toString());
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class JMSConfigFeature method initialize.
@Override
public void initialize(Client client, Bus bus) {
checkJmsConfig();
Conduit conduit = client.getConduit();
if (!(conduit instanceof JMSConduit)) {
throw new ConfigurationException(new Message("JMSCONFIGFEATURE_ONLY_JMS", LOG));
}
JMSConduit jmsConduit = (JMSConduit) conduit;
jmsConduit.setJmsConfig(jmsConfig);
super.initialize(client, bus);
}
use of org.apache.cxf.common.i18n.Message in project tomee by apache.
the class JAXBSchemaInitializer method createBridgeXsElement.
private void createBridgeXsElement(MessagePartInfo part, QName qn, QName typeName) {
SchemaInfo schemaInfo = serviceInfo.getSchema(qn.getNamespaceURI());
if (schemaInfo != null) {
XmlSchemaElement el = schemaInfo.getElementByQName(qn);
if (el == null) {
createXsElement(schemaInfo.getSchema(), part, typeName, schemaInfo);
} else if (!typeName.equals(el.getSchemaTypeName())) {
throw new Fault(new Message("CANNOT_CREATE_ELEMENT", LOG, qn, typeName, el.getSchemaTypeName()));
}
return;
}
XmlSchema schema = schemas.newXmlSchemaInCollection(qn.getNamespaceURI());
if (qualifiedSchemas) {
schema.setElementFormDefault(XmlSchemaForm.QUALIFIED);
}
schemaInfo = new SchemaInfo(qn.getNamespaceURI(), qualifiedSchemas, false);
schemaInfo.setSchema(schema);
createXsElement(schema, part, typeName, schemaInfo);
NamespaceMap nsMap = new NamespaceMap();
nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX, schema.getTargetNamespace());
nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD);
schema.setNamespaceContext(nsMap);
serviceInfo.addSchema(schemaInfo);
}
use of org.apache.cxf.common.i18n.Message in project tomee by apache.
the class JAXBEncoderDecoder method doUnmarshal.
private static Object doUnmarshal(final Unmarshaller u, final Object source, final QName elName, final Class<?> clazz, final boolean unwrap) throws Exception {
final Object obj;
boolean unmarshalWithClass = true;
if (clazz == null || (!clazz.isPrimitive() && !clazz.isArray() && !clazz.isEnum() && !clazz.equals(Calendar.class) && (Modifier.isAbstract(clazz.getModifiers()) || Modifier.isInterface(clazz.getModifiers())))) {
unmarshalWithClass = false;
}
if (clazz != null && ("javax.xml.datatype.XMLGregorianCalendar".equals(clazz.getName()) || "javax.xml.datatype.Duration".equals(clazz.getName()))) {
// special treat two jaxb defined built-in abstract types
unmarshalWithClass = true;
}
if (source instanceof Node) {
obj = unmarshalWithClass ? u.unmarshal((Node) source, clazz) : u.unmarshal((Node) source);
} else if (source instanceof DepthXMLStreamReader) {
// JAXB optimizes a ton of stuff depending on the StreamReader impl. Thus,
// we REALLY want to pass the original reader in. This is OK with JAXB
// as it doesn't read beyond the end so the DepthXMLStreamReader state
// would be OK when it returns. The main winner is FastInfoset where parsing
// a testcase I have goes from about 300/sec to well over 1000.
DepthXMLStreamReader dr = (DepthXMLStreamReader) source;
XMLStreamReader reader = dr.getReader();
// allows the XML Stream Reader to adjust it's behaviour based on the state of the unmarshaller
if (reader instanceof UnmarshallerAwareXMLReader) {
((UnmarshallerAwareXMLReader) reader).setUnmarshaller(u);
}
if (u.getSchema() != null) {
// validating, but we may need more namespaces
reader = findExtraNamespaces(reader);
}
obj = unmarshalWithClass ? u.unmarshal(reader, clazz) : u.unmarshal(dr.getReader());
} else if (source instanceof XMLStreamReader) {
XMLStreamReader reader = (XMLStreamReader) source;
// allows the XML Stream Reader to adjust it's behaviour based on the state of the unmarshaller
if (reader instanceof UnmarshallerAwareXMLReader) {
((UnmarshallerAwareXMLReader) reader).setUnmarshaller(u);
}
if (u.getSchema() != null) {
// validating, but we may need more namespaces
reader = findExtraNamespaces(reader);
}
obj = unmarshalWithClass ? u.unmarshal(reader, clazz) : u.unmarshal(reader);
} else if (source instanceof XMLEventReader) {
// allows the XML Event Reader to adjust it's behaviour based on the state of the unmarshaller
if (source instanceof UnmarshallerAwareXMLReader) {
((UnmarshallerAwareXMLReader) source).setUnmarshaller(u);
}
obj = unmarshalWithClass ? u.unmarshal((XMLEventReader) source, clazz) : u.unmarshal((XMLEventReader) source);
} else if (source == null) {
throw new Fault(new Message("UNKNOWN_SOURCE", LOG, "null"));
} else {
throw new Fault(new Message("UNKNOWN_SOURCE", LOG, source.getClass().getName()));
}
return unwrap ? getElementValue(obj) : obj;
}
Aggregations