// the runtime information. This way, we'll still
// remember it after the servlet-class element has been
// replaced with the name of the container's servlet class.
endpoint.saveServletImplClass();
WebComponentDescriptor webComp =
(WebComponentDescriptor) endpoint.getWebComponentImpl();
WebBundleDescriptor bundle = webComp.getWebBundleDescriptor();
WebServicesDescriptor webServices = bundle.getWebServices();
Collection endpoints =
webServices.getEndpointsImplementedBy(webComp);
if( endpoints.size() > 1 ) {
String msg = "Servlet " + endpoint.getWebComponentLink() +
" implements " + endpoints.size() + " web service endpoints " +
" but must only implement 1";
throw new IllegalStateException(msg);
}
if( endpoint.getEndpointAddressUri() == null ) {
Set urlPatterns = webComp.getUrlPatternsSet();
if( urlPatterns.size() == 1 ) {
// Set endpoint-address-uri runtime info to uri.
// Final endpoint address will still be relative to context root
String uri = (String) urlPatterns.iterator().next();
endpoint.setEndpointAddressUri(uri);
// Set transport guarantee in runtime info if transport
// guarantee is INTEGRAL or CONDIFIDENTIAL for any
// security constraint with this url-pattern.
Collection constraints =
bundle.getSecurityConstraintsForUrlPattern(uri);
for(Iterator i = constraints.iterator(); i.hasNext();) {
SecurityConstraint next = (SecurityConstraint) i.next();
UserDataConstraint dataConstraint =
next.getUserDataConstraint();
String guarantee = (dataConstraint != null) ?
dataConstraint.getTransportGuarantee() : null;
if( (guarantee != null) &&
( guarantee.equals
(UserDataConstraint.INTEGRAL_TRANSPORT) ||
guarantee.equals
(UserDataConstraint.CONFIDENTIAL_TRANSPORT) ) ) {
endpoint.setTransportGuarantee(guarantee);
break;
}
}
} else {
String msg = "Endpoint " + endpoint.getEndpointName() +
" has not been assigned an endpoint address " +
" and is associated with servlet " +
webComp.getCanonicalName() + " , which has " +
urlPatterns.size() + " url patterns";
throw new IllegalStateException(msg);
}
}
}