|
45 | 45 |
|
46 | 46 | import java.lang.reflect.AnnotatedElement; |
47 | 47 | import java.lang.annotation.Annotation; |
48 | | -import java.text.MessageFormat; |
49 | 48 |
|
50 | 49 | import org.glassfish.apf.*; |
51 | 50 |
|
|
56 | 55 | import com.sun.enterprise.deployment.annotation.context.EjbContext; |
57 | 56 |
|
58 | 57 | import com.sun.enterprise.deployment.*; |
| 58 | +import com.sun.enterprise.deployment.annotation.context.EjbsContext; |
59 | 59 | import com.sun.enterprise.deployment.util.DOLUtils; |
60 | 60 | import com.sun.enterprise.deployment.annotation.handlers.AbstractHandler; |
61 | 61 | import com.sun.enterprise.util.LocalStringManagerImpl; |
@@ -188,15 +188,27 @@ public HandlerProcessingResult processAnnotation(AnnotationInfo annInfo) |
188 | 188 | ape.setFatal(false); |
189 | 189 | throw ape; |
190 | 190 | }*/ |
191 | | - |
192 | 191 | // let's see the type of web service we are dealing with... |
193 | | - if ((ejbProvider!= null) && ejbProvider.getType("javax.ejb.Stateless")!=null &&(annCtx |
194 | | - instanceof EjbContext)) { |
| 192 | + if (ejbProvider != null && ejbProvider.getType("javax.ejb.Stateless") != null) { |
195 | 193 | // this is an ejb ! |
196 | | - EjbContext ctx = (EjbContext) annCtx; |
197 | | - bundleDesc = ctx.getDescriptor().getEjbBundleDescriptor(); |
198 | | - bundleDesc.setSpecVersion("3.0"); |
199 | | - } else { |
| 194 | + if (annCtx instanceof EjbContext) { |
| 195 | + EjbContext ctx = (EjbContext) annCtx; |
| 196 | + bundleDesc = ctx.getDescriptor().getEjbBundleDescriptor(); |
| 197 | + bundleDesc.setSpecVersion("3.0"); |
| 198 | + } else if (annCtx instanceof EjbsContext) { |
| 199 | + String name = getEjbName(annElem); |
| 200 | + for (EjbContext ejbCtx : ((EjbsContext) annCtx).getEjbContexts()) { |
| 201 | + EjbDescriptor descriptor = ejbCtx.getDescriptor(); |
| 202 | + if (name.equals(descriptor.getName())) { |
| 203 | + bundleDesc = descriptor.getEjbBundleDescriptor(); |
| 204 | + bundleDesc.setSpecVersion("3.0"); |
| 205 | + break; |
| 206 | + } |
| 207 | + } |
| 208 | + } |
| 209 | + } |
| 210 | + |
| 211 | + if (bundleDesc == null) { |
200 | 212 | // this has to be a servlet since there is no @Servlet annotation yet |
201 | 213 | if(annCtx instanceof WebComponentContext) { |
202 | 214 | bundleDesc = ((WebComponentContext)annCtx).getDescriptor().getWebBundleDescriptor(); |
@@ -466,37 +478,7 @@ public HandlerProcessingResult processAnnotation(AnnotationInfo annInfo) |
466 | 478 |
|
467 | 479 |
|
468 | 480 | //TODO BM handle stateless |
469 | | - Stateless stateless = null; |
470 | | - try { |
471 | | - stateless = annElem.getAnnotation(javax.ejb.Stateless.class); |
472 | | - } catch (Exception e) { |
473 | | - if (logger.isLoggable(Level.FINE)) { |
474 | | - //This can happen in the web.zip installation where there is no ejb |
475 | | - //Just logging the error |
476 | | - conLogger.log(Level.FINE, LogUtils.EXCEPTION_THROWN, e); |
477 | | - } |
478 | | - } |
479 | | - Singleton singleton = null; |
480 | | - try { |
481 | | - singleton = annElem.getAnnotation(javax.ejb.Singleton.class); |
482 | | - } catch (Exception e) { |
483 | | - if (logger.isLoggable(Level.FINE)) { |
484 | | - //This can happen in the web.zip installation where there is no ejb |
485 | | - //Just logging the error |
486 | | - conLogger.log(Level.FINE, LogUtils.EXCEPTION_THROWN, e); |
487 | | - } |
488 | | - } |
489 | | - String name; |
490 | | - |
491 | | - |
492 | | - if ((stateless != null) &&((stateless).name()==null || stateless.name().length()>0)) { |
493 | | - name = stateless.name(); |
494 | | - } else if ((singleton != null) &&((singleton).name()==null || singleton.name().length()>0)) { |
495 | | - name = singleton.name(); |
496 | | - |
497 | | - }else { |
498 | | - name = ((Class) annElem).getSimpleName(); |
499 | | - } |
| 481 | + String name = getEjbName(annElem); |
500 | 482 | EjbDescriptor ejb = ((EjbBundleDescriptor) bundleDesc).getEjbByName(name); |
501 | 483 | endpoint.setEjbComponentImpl(ejb); |
502 | 484 | ejb.setWebServiceEndpointInterfaceName(endpoint.getServiceEndpointInterface()); |
@@ -605,4 +587,38 @@ private boolean isJaxwsRIDeployment(AnnotationInfo annInfo) { |
605 | 587 | } |
606 | 588 | return riDeployment; |
607 | 589 | } |
| 590 | + |
| 591 | + private String getEjbName(AnnotatedElement annElem) { |
| 592 | + Stateless stateless = null; |
| 593 | + try { |
| 594 | + stateless = annElem.getAnnotation(javax.ejb.Stateless.class); |
| 595 | + } catch (Exception e) { |
| 596 | + if (logger.isLoggable(Level.FINE)) { |
| 597 | + //This can happen in the web.zip installation where there is no ejb |
| 598 | + //Just logging the error |
| 599 | + conLogger.log(Level.FINE, LogUtils.EXCEPTION_THROWN, e); |
| 600 | + } |
| 601 | + } |
| 602 | + Singleton singleton = null; |
| 603 | + try { |
| 604 | + singleton = annElem.getAnnotation(javax.ejb.Singleton.class); |
| 605 | + } catch (Exception e) { |
| 606 | + if (logger.isLoggable(Level.FINE)) { |
| 607 | + //This can happen in the web.zip installation where there is no ejb |
| 608 | + //Just logging the error |
| 609 | + conLogger.log(Level.FINE, LogUtils.EXCEPTION_THROWN, e); |
| 610 | + } |
| 611 | + } |
| 612 | + String name; |
| 613 | + |
| 614 | + if ((stateless != null) && ((stateless).name() == null || stateless.name().length() > 0)) { |
| 615 | + name = stateless.name(); |
| 616 | + } else if ((singleton != null) && ((singleton).name() == null || singleton.name().length() > 0)) { |
| 617 | + name = singleton.name(); |
| 618 | + |
| 619 | + } else { |
| 620 | + name = ((Class) annElem).getSimpleName(); |
| 621 | + } |
| 622 | + return name; |
| 623 | + } |
608 | 624 | } |
0 commit comments