use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class ServiceImpl method getPortTypeName.
private QName getPortTypeName(Class<?> serviceEndpointInterface) {
Class<?> seiClass = serviceEndpointInterface;
if (!serviceEndpointInterface.isAnnotationPresent(WebService.class)) {
Message msg = new Message("SEI_NO_WEBSERVICE_ANNOTATION", BUNDLE, serviceEndpointInterface.getCanonicalName());
throw new WebServiceException(msg.toString());
}
if (!serviceEndpointInterface.isInterface()) {
WebService webService = serviceEndpointInterface.getAnnotation(WebService.class);
String epi = webService.endpointInterface();
if (epi.length() > 0) {
try {
seiClass = Thread.currentThread().getContextClassLoader().loadClass(epi);
} catch (ClassNotFoundException e) {
Message msg = new Message("COULD_NOT_LOAD_CLASS", BUNDLE, epi);
throw new WebServiceException(msg.toString());
}
if (!seiClass.isAnnotationPresent(javax.jws.WebService.class)) {
Message msg = new Message("SEI_NO_WEBSERVICE_ANNOTATION", BUNDLE, seiClass.getCanonicalName());
throw new WebServiceException(msg.toString());
}
}
}
WebService webService = seiClass.getAnnotation(WebService.class);
String name = webService.name();
if (name.length() == 0) {
name = seiClass.getSimpleName();
}
String tns = webService.targetNamespace();
if (tns.isEmpty()) {
tns = PackageUtils.getNamespace(PackageUtils.getPackageName(seiClass));
}
return new QName(tns, name);
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class AnnotationHandlerChainBuilder method buildHandlerChainFromClass.
/**
* @param clz
* @param existingHandlers
* @return
*/
public List<Handler> buildHandlerChainFromClass(Class<?> clz, List<Handler> existingHandlers, QName portQName, QName serviceQName, String bindingID) {
LOG.fine("building handler chain");
HandlerChainAnnotation hcAnn = findHandlerChainAnnotation(clz, true);
final List<Handler> chain;
if (hcAnn == null) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("no HandlerChain annotation on " + clz);
}
chain = new ArrayList<>();
} else {
hcAnn.validate();
try {
URL handlerFileURL = resolveHandlerChainFile(clz, hcAnn.getFileName());
if (handlerFileURL == null) {
throw new WebServiceException(new Message("HANDLER_CFG_FILE_NOT_FOUND_EXC", BUNDLE, hcAnn.getFileName()).toString());
}
Document doc = StaxUtils.read(handlerFileURL.openStream());
Element el = doc.getDocumentElement();
boolean isJavaEENamespace = JavaeeHandlerChainBuilder.JAVAEE_NS.equals(el.getNamespaceURI());
boolean isJakartaEENamespace = JakartaeeHandlerChainBuilder.JAKARTAEE_NS.equals(el.getNamespaceURI());
if (!isJavaEENamespace && !isJakartaEENamespace) {
throw new WebServiceException(BundleUtils.getFormattedString(BUNDLE, "NOT_VALID_NAMESPACE", el.getNamespaceURI()));
}
final ClassLoader classLoader = getClassLoader(clz);
final DelegatingHandlerChainBuilder delegate = ht -> buildHandlerChain(ht, classLoader);
if (isJavaEENamespace) {
chain = new JavaeeHandlerChainBuilder(BUNDLE, handlerFileURL, delegate).build(el, portQName, serviceQName, bindingID);
} else {
chain = new JakartaeeHandlerChainBuilder(BUNDLE, handlerFileURL, delegate).build(el, portQName, serviceQName, bindingID);
}
} catch (WebServiceException e) {
throw e;
} catch (Exception e) {
throw new WebServiceException(BUNDLE.getString("CHAIN_NOT_SPECIFIED_EXC"), e);
}
}
assert chain != null;
if (existingHandlers != null) {
chain.addAll(existingHandlers);
}
return sortHandlers(chain);
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class JAXWSMethodDispatcher method bind.
public void bind(OperationInfo o, Method... methods) {
Method[] newMethods = new Method[methods.length];
int i = 0;
for (Method m : methods) {
try {
newMethods[i] = getImplementationMethod(m);
i++;
} catch (NoSuchMethodException e) {
if (m.getName().endsWith("Async") && (Future.class.equals(m.getReturnType()) || Response.class.equals(m.getReturnType()))) {
newMethods[i] = m;
i++;
continue;
}
Class<?> endpointClass = implInfo.getImplementorClass();
Message msg = new Message("SEI_METHOD_NOT_FOUND", LOG, m.getName(), endpointClass.getName());
throw new ServiceConstructionException(msg, e);
}
}
super.bind(o, newMethods);
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class AbstractInvoker method createFault.
protected Fault createFault(Throwable ex, Method m, List<Object> params, boolean checked) {
if (checked) {
return new Fault(ex);
}
String message = (ex == null) ? "" : ex.getMessage();
String method = (m == null) ? "<null>" : m.toString();
return new Fault(new Message("EXCEPTION_INVOKING_OBJECT", LOG, message, method, params), ex);
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class AbstractInvoker method invoke.
public Object invoke(Exchange exchange, Object o) {
final Object serviceObject = getServiceObject(exchange);
try {
BindingOperationInfo bop = exchange.getBindingOperationInfo();
MethodDispatcher md = (MethodDispatcher) exchange.getService().get(MethodDispatcher.class.getName());
Method m = bop == null ? null : md.getMethod(bop);
if (m == null && bop == null) {
LOG.severe(new Message("MISSING_BINDING_OPERATION", LOG).toString());
throw new Fault(new Message("EXCEPTION_INVOKING_OBJECT", LOG, "No binding operation info", "unknown method", "unknown"));
}
List<Object> params = null;
if (o instanceof List) {
params = CastUtils.cast((List<?>) o);
} else if (o != null) {
params = new MessageContentsList(o);
}
m = adjustMethodAndParams(m, exchange, params, serviceObject.getClass());
// Method m = (Method)bop.getOperationInfo().getProperty(Method.class.getName());
m = matchMethod(m, serviceObject);
return invoke(exchange, serviceObject, m, params);
} finally {
releaseServiceObject(exchange, serviceObject);
}
}
Aggregations