本文整理汇总了Java中javax.jws.HandlerChain类的典型用法代码示例。如果您正苦于以下问题:Java HandlerChain类的具体用法?Java HandlerChain怎么用?Java HandlerChain使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HandlerChain类属于javax.jws包,在下文中一共展示了HandlerChain类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFileAsStream
import javax.jws.HandlerChain; //导入依赖的package包/类
static InputStream getFileAsStream(Class clazz, HandlerChain chain) {
URL url = clazz.getResource(chain.file());
if (url == null) {
url = Thread.currentThread().getContextClassLoader().
getResource(chain.file());
}
if (url == null) {
String tmp = clazz.getPackage().getName();
tmp = tmp.replace('.', '/');
tmp += "/" + chain.file();
url =
Thread.currentThread().getContextClassLoader().getResource(tmp);
}
if (url == null) {
throw new UtilException("util.failed.to.find.handlerchain.file",
clazz.getName(), chain.file());
}
try {
return url.openStream();
} catch (IOException e) {
throw new UtilException("util.failed.to.parse.handlerchain.file",
clazz.getName(), chain.file());
}
}
示例2: getFileAsStream
import javax.jws.HandlerChain; //导入依赖的package包/类
static InputStream getFileAsStream(Class clazz, HandlerChain chain) {
Package pkg = clazz.getPackage();
String filename = chain.file();
String fullpath = addPackagePath(filename, pkg);
InputStream is;
is = moduleResource(clazz, filename);
if (is != null) return is;
is = moduleResource(clazz, fullpath);
if (is != null) return is;
URL url = cpResource(clazz, filename);
if (url == null) url = cpResource(clazz, fullpath);
if (url == null) {
throw new UtilException("util.failed.to.find.handlerchain.file",
clazz.getName(), filename);
}
try {
return url.openStream();
} catch (IOException e) {
throw new UtilException("util.failed.to.parse.handlerchain.file",
clazz.getName(), filename);
}
}
示例3: getHandlerChains
import javax.jws.HandlerChain; //导入依赖的package包/类
public static HandlerChains getHandlerChains(Class<?> declaringClass, final String serviceEndpoint, final ClassLoader classLoader) throws OpenEJBException {
HandlerChain handlerChain = declaringClass.getAnnotation(HandlerChain.class);
if (handlerChain == null && serviceEndpoint != null) {
try {
declaringClass = classLoader.loadClass(serviceEndpoint);
handlerChain = declaringClass.getAnnotation(HandlerChain.class);
} catch (final ClassNotFoundException ignored) {
// no-op
}
}
HandlerChains handlerChains = null;
if (handlerChain != null) {
try {
final URL handlerFileURL = declaringClass.getResource(handlerChain.file());
handlerChains = ReadDescriptors.readHandlerChains(handlerFileURL);
} catch (final Throwable e) {
throw new OpenEJBException("Unable to load handler chain file: " + handlerChain.file(), e);
}
}
return handlerChains;
}
示例4: writeHandlerConfig
import javax.jws.HandlerChain; //导入依赖的package包/类
protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) {
Element e = options.getHandlerChainConfiguration();
if (e == null) {
return;
}
JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class));
NodeList nl = e.getElementsByTagNameNS(
"http://java.sun.com/xml/ns/javaee", "handler-chain");
if(nl.getLength() > 0){
String fName = getHandlerConfigFileName(className);
handlerChainAnn.param("file", fName);
generateHandlerChainFile(e, className);
}
}
示例5: attachHandlerChainAnnotation
import javax.jws.HandlerChain; //导入依赖的package包/类
/**
* This method is use to attach @HandlerChain annotation data to a composite object.
*
* @param composite - <code>TMFAnnotationComposite</code>
* @param annotatedElement - <code>AnnotatedElement</code>
*/
public static void attachHandlerChainAnnotation(TMFAnnotationComposite composite,
AnnotatedElement annotatedElement) {
HandlerChain handlerChain = (HandlerChain)ConverterUtils.getAnnotation(
HandlerChain.class, annotatedElement);
if (handlerChain != null) {
HandlerChainAnnot hcAnnot = ConverterUtils.createHandlerChainAnnot(
handlerChain);
composite.setHandlerChainAnnot(hcAnnot);
}
}
示例6: writeHandlerConfig
import javax.jws.HandlerChain; //导入依赖的package包/类
protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) {
Element e = options.getHandlerChainConfiguration();
if(e == null)
return;
JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class));
NodeList nl = e.getElementsByTagNameNS(
"http://java.sun.com/xml/ns/javaee", "handler-chain");
if(nl.getLength() > 0){
String fName = getHandlerConfigFileName(className);
handlerChainAnn.param("file", fName);
generateHandlerChainFile(e, className);
}
}
示例7: processWebServiceHandlers
import javax.jws.HandlerChain; //导入依赖的package包/类
/**
* Scan for @EJB, @Resource, @WebServiceRef, @PersistenceUnit, and @PersistenceContext on WebService HandlerChain classes
*/
private void processWebServiceHandlers(final EjbModule ejbModule, final EnterpriseBean bean, final AnnotationFinder finder) throws OpenEJBException {
// add webservice handler classes to the class finder used in annotation processing
final Set<String> classes = new HashSet<>();
if (ejbModule.getWebservices() != null) {
for (final WebserviceDescription webservice : ejbModule.getWebservices().getWebserviceDescription()) {
for (final PortComponent port : webservice.getPortComponent()) {
// only process port definitions for this ejb
if (!bean.getEjbName().equals(port.getServiceImplBean().getEjbLink())) {
continue;
}
if (port.getHandlerChains() == null) {
continue;
}
for (final org.apache.openejb.jee.HandlerChain handlerChain : port.getHandlerChains().getHandlerChain()) {
for (final Handler handler : handlerChain.getHandler()) {
final String handlerClass = realClassName(handler.getHandlerClass());
if (handlerClass != null) {
classes.add(handlerClass);
}
}
}
}
}
}
// classes.add(bean.getEjbClass());
final AnnotationFinder handlersFinder = finder.select(classes);
buildAnnotatedRefs(bean, handlersFinder, ejbModule.getClassLoader());
}
示例8: getAnnoHandlerChainAnnotation
import javax.jws.HandlerChain; //导入依赖的package包/类
public HandlerChain getAnnoHandlerChainAnnotation(Object sparseCompositeKey) {
if (this.handlerChainAnnotation == null) {
if (composite.isServiceProvider()) {
/*
* Per JSR-181 The @HandlerChain annotation MAY be present on
* the endpoint interface and service implementation bean. The
* service implementations bean's @HandlerChain is used if
* @HandlerChain is present on both. So, if we do find the
* annotation on this impl, then don't worry about else
* Otherwise, check to see if the SEI might be annotated with
* @HandlerChain
*/
handlerChainAnnotation = composite.getHandlerChainAnnot();
if (handlerChainAnnotation == null) {
// If this is NOT an implicit SEI, then check for the
// annotation on the SEI
if (!DescriptionUtils.isEmpty(getAnnoWebServiceEndpointInterface())) {
DescriptionBuilderComposite seic = getServiceDescriptionImpl().getDBCMap()
.get(composite.getWebServiceAnnot().endpointInterface());
if (seic != null) {
handlerChainAnnotation = seic.getHandlerChainAnnot();
}
}
}
} else {
handlerChainAnnotation = composite.getHandlerChainAnnot();
}
}
if (handlerChainAnnotation == null) {
if (sparseCompositeKey != null) {
DescriptionBuilderComposite sparseComposite = composite.getSparseComposite(sparseCompositeKey);
if (sparseComposite != null && sparseComposite.getHandlerChainAnnot() != null) {
handlerChainAnnotation = sparseComposite.getHandlerChainAnnot();
}
}
}
return handlerChainAnnotation;
}
示例9: WSServiceDelegate
import javax.jws.HandlerChain; //导入依赖的package包/类
/**
* @param serviceClass
* Either {@link Service}.class or other generated service-derived classes.
*/
public WSServiceDelegate(@Nullable Source wsdl, @NotNull QName serviceName, @NotNull final Class<? extends Service> serviceClass) {
//we cant create a Service without serviceName
if (serviceName == null)
throw new WebServiceException(ClientMessages.INVALID_SERVICE_NAME_NULL(serviceName));
InitParams initParams = INIT_PARAMS.get();
INIT_PARAMS.set(null); // mark it as consumed
if(initParams==null) initParams = EMPTY_PARAMS;
this.serviceName = serviceName;
this.serviceClass = serviceClass;
Container tContainer = initParams.getContainer()!=null ? initParams.getContainer() : ContainerResolver.getInstance().getContainer();
if (tContainer == Container.NONE) {
tContainer = new ClientContainer();
}
this.container = tContainer;
// load interceptor
ServiceInterceptor interceptor = ServiceInterceptorFactory.load(this, Thread.currentThread().getContextClassLoader());
ServiceInterceptor si = container.getSPI(ServiceInterceptor.class);
if (si != null) {
interceptor = ServiceInterceptor.aggregate(interceptor, si);
}
this.serviceInterceptor = interceptor;
//if wsdl is null, try and get it from the WebServiceClient.wsdlLocation
if(wsdl == null){
if(serviceClass != Service.class){
WebServiceClient wsClient = AccessController.doPrivileged(new PrivilegedAction<WebServiceClient>() {
public WebServiceClient run() {
return serviceClass.getAnnotation(WebServiceClient.class);
}
});
String wsdlLocation = wsClient.wsdlLocation();
wsdlLocation = JAXWSUtils.absolutize(JAXWSUtils.getFileOrURLName(wsdlLocation));
wsdl = new StreamSource(wsdlLocation);
}
}
WSDLServiceImpl service=null;
if (wsdl != null) {
try {
URL url = wsdl.getSystemId()==null ? null : new URL(wsdl.getSystemId());
WSDLModelImpl model = parseWSDL(url, wsdl);
service = model.getService(this.serviceName);
if (service == null)
throw new WebServiceException(
ClientMessages.INVALID_SERVICE_NAME(this.serviceName,
buildNameList(model.getServices().keySet())));
// fill in statically known ports
for (WSDLPortImpl port : service.getPorts())
ports.put(port.getName(), new PortInfo(this, port));
} catch (MalformedURLException e) {
throw new WebServiceException(ClientMessages.INVALID_WSDL_URL(wsdl.getSystemId()));
}
}
this.wsdlService = service;
if (serviceClass != Service.class) {
//if @HandlerChain present, set HandlerResolver on service context
HandlerChain handlerChain =
AccessController.doPrivileged(new PrivilegedAction<HandlerChain>() {
public HandlerChain run() {
return serviceClass.getAnnotation(HandlerChain.class);
}
});
if (handlerChain != null)
handlerConfigurator = new AnnotationConfigurator(this);
}
}
示例10: processWebServiceClientHandlers
import javax.jws.HandlerChain; //导入依赖的package包/类
/**
* Scan for @EJB, @Resource, @WebServiceRef, @PersistenceUnit, and @PersistenceContext on WebService HandlerChain classes
*
* @param consumer
* @param classLoader
* @throws OpenEJBException
*/
private void processWebServiceClientHandlers(final JndiConsumer consumer, final AnnotationFinder finder, final ClassLoader classLoader) throws OpenEJBException {
if (SystemInstance.get().hasProperty("openejb.geronimo")) {
return;
}
final Set<String> processedClasses = new HashSet<>();
final Set<String> handlerClasses = new HashSet<>();
do {
// get unprocessed handler classes
handlerClasses.clear();
for (final ServiceRef serviceRef : consumer.getServiceRef()) {
final HandlerChains chains = serviceRef.getAllHandlers();
if (chains == null) {
continue;
}
for (final org.apache.openejb.jee.HandlerChain handlerChain : chains.getHandlerChain()) {
for (final Handler handler : handlerChain.getHandler()) {
if (handler.getHandlerClass() != null) {
handlerClasses.add(realClassName(handler.getHandlerClass()));
}
}
}
}
handlerClasses.removeAll(processedClasses);
if (handlerClasses.isEmpty()) {
continue;
}
// process handler classes
final AnnotationFinder handlerAnnotationFinder = finder != null ? finder.select(handlerClasses) :
new FinderFactory.OpenEJBAnnotationFinder(new FinderFactory.DoLoadClassesArchive(classLoader, handlerClasses));
/*
* @EJB
* @Resource
* @WebServiceRef
* @PersistenceUnit
* @PersistenceContext
*/
buildAnnotatedRefs(consumer, handlerAnnotationFinder, classLoader);
processedClasses.addAll(handlerClasses);
} while (!handlerClasses.isEmpty());
}
示例11: createHandlerChainAnnot
import javax.jws.HandlerChain; //导入依赖的package包/类
/**
* This is a helper method to create a <code>HandlerChainAnnot</code> since the
*
* @param handlerChain - <code>HandlerChain</code>
* @return - <code>HandlerChainAnnot</code>
* @HandlerChain annotation may be present on a Type, Method, or Field.
*/
public static HandlerChainAnnot createHandlerChainAnnot(HandlerChain handlerChain) {
HandlerChainAnnot hcAnnot = HandlerChainAnnot.createHandlerChainAnnotImpl();
hcAnnot.setFile(handlerChain.file());
hcAnnot.setName(handlerChain.name());
return hcAnnot;
}