private void setInjectionAwareInstanceProvider(final Endpoint ep) { final InstanceProvider stackInstanceProvider = ep.getInstanceProvider(); final DeploymentUnit unit = ep.getService().getDeployment().getAttachment(DeploymentUnit.class); final InstanceProvider injectionAwareInstanceProvider = new InjectionAwareInstanceProvider(stackInstanceProvider, ep, unit); ep.setInstanceProvider(injectionAwareInstanceProvider); }
private InjectionAwareInstanceProvider(final InstanceProvider delegate, final Endpoint endpoint, final DeploymentUnit unit) { this.delegate = delegate; endpointName = endpoint.getShortName(); endpointClass = endpoint.getTargetBeanName(); componentPrefix = unit.getServiceName().append("component"); }
/** * Gets <b>WebContext</b> if associated with EJB endpoint. * * @param endpoint EJB webservice endpoint * @return web context associated with EJB or null */ @SuppressWarnings( {"unchecked"}) private WebContext getWebContextAnnotation(final Endpoint endpoint) { return (WebContext) endpoint.getTargetBeanClass().getAnnotation(WebContext.class); }
private Object getEndpointInstance() { synchronized(endpoint) { try { final String endpointClassName = endpoint.getTargetBeanName(); return endpoint.getInstanceProvider().getInstance(endpointClassName).getValue(); } catch (Exception ex) { throw new IllegalStateException(ex); } } }
servlet.setServletName(ep.getShortName()); servlet.setServletClass(ep.getTargetBeanName()); servlets.add(servlet); servletMapping.setServletName(ep.getShortName()); servletMapping.setUrlPatterns(Arrays.asList(new String[] { ep.getURLPattern() })); servletMappings.add(servletMapping); String ejbName = ep.getShortName(); String beanAuthMethod = null; WebContext anWebContext = (WebContext)ep.getTargetBeanClass().getAnnotation(WebContext.class); if (anWebContext != null) resourceCollection.setUrlPatterns(Arrays.asList(new String[] { ep.getURLPattern() })); ArrayList<String> httpMethods = new ArrayList<String>(); resourceCollection.setHttpMethods(httpMethods);
/** * Gets EJB security meta data if associated with EJB endpoint. * * @param endpoint EJB webservice endpoint * @return EJB security meta data or null */ private EJBSecurityMetaData getEjbSecurityMetaData(final Endpoint endpoint) { final String ejbName = endpoint.getShortName(); final Deployment dep = endpoint.getService().getDeployment(); final EJBArchiveMetaData ejbArchiveMD = WSHelper.getOptionalAttachment(dep, EJBArchiveMetaData.class); final EJBMetaData ejbMD = ejbArchiveMD != null ? ejbArchiveMD.getBeanByEjbName(ejbName) : null; return ejbMD != null ? ejbMD.getSecurityMetaData() : null; }
public void create(Deployment dep, WSFRuntime rruntime) { RewriteResults results = webXMLRewriter.rewriteWebXml(dep); // The endpoint may not have a target bean when // <servlet-class> originally contained a javax.servlet.Servlet for (Endpoint ep : dep.getService().getEndpoints()) { if (ep.getTargetBeanName() == null) { String servletName = ep.getShortName(); String beanClassName = results.sepTargetMap.get(servletName); if (beanClassName == null) throw new IllegalStateException("Cannot obtain target bean for: " + servletName); ep.setTargetBeanName(beanClassName); } } }
/** * Creates servlet-mapping part of web.xml descriptor. * * <pre> * <servlet-mapping> * <servlet-name>EJBEndpointShortName</servlet-name> * <url-pattern>EJBEndpointURLPattern</url-pattern> * </servlet-mapping> * </pre> * * @param dep webservice deployment * @param jbossWebMD jboss web meta data */ private void createServletMappings(final Deployment dep, final JBossWebMetaData jbossWebMD) { this.log.debug("Creating servlet mappings"); final List<ServletMappingMetaData> servletMappings = WebMetaDataHelper.getServletMappings(jbossWebMD); for (final Endpoint ep : dep.getService().getEndpoints()) { final String endpointName = ep.getShortName(); final List<String> urlPatterns = WebMetaDataHelper.getUrlPatterns(ep.getURLPattern()); this.log.debug("Servlet name: " + endpointName + ", URL patterns: " + urlPatterns); WebMetaDataHelper.newServletMapping(endpointName, urlPatterns, servletMappings); } }
@Override public void start(final StartContext context) { WSLogger.ROOT_LOGGER.starting(name); final String domainName = (String)endpoint.getProperty(SECURITY_DOMAIN_NAME); if (isElytronSecurityDomain(endpoint, domainName)) { if (EndpointType.JAXWS_EJB3.equals(endpoint.getType())) { endpoint.setSecurityDomainContext(new ElytronSecurityDomainContextImpl(this.ejbApplicationSecurityDomain.get().getSecurityDomain())); } else { endpoint.setSecurityDomainContext(new ElytronSecurityDomainContextImpl(this.elytronSecurityDomain.get())); } } else { endpoint.setSecurityDomainContext(new SecurityDomainContextImpl(securityDomainContext.get())); } if (EndpointType.JAXWS_EJB3.equals(endpoint.getType())) { final EJBViewMethodSecurityAttributesService ejbMethodSecurityAttributeService = this.ejbMethodSecurityAttributeService.get(); endpoint.addAttachment(EJBMethodSecurityAttributeProvider.class, new EJBMethodSecurityAttributesAdaptor(ejbMethodSecurityAttributeService)); } final List<RecordProcessor> processors = endpoint.getRecordProcessors(); for (final RecordProcessor processor : processors) { registerRecordProcessor(processor, endpoint); } final EndpointMetricsFactory endpointMetricsFactory = SPIProvider.getInstance().getSPI(EndpointMetricsFactory.class); endpoint.setEndpointMetrics(endpointMetricsFactory.newEndpointMetrics()); registerEndpoint(endpoint); endpoint.getLifecycleHandler().start(endpoint); ServiceContainerEndpointRegistry.register(aliasName, endpoint); endpointConsumer.accept(endpoint); }
protected Object getTargetBean(Endpoint ep, Invocation epInv) throws Exception { InvocationContext invCtx = epInv.getInvocationContext(); Object targetBean = invCtx.getTargetBean(); if (targetBean == null) { try { Class<?> epImpl = ep.getTargetBeanClass(); targetBean = epImpl.newInstance(); invCtx.setTargetBean(targetBean); } catch (Exception ex) { throw new IllegalStateException("Cannot get target bean instance", ex); } JavaxAnnotationHelper.callPostConstructMethod(targetBean, targetBean.getClass().getClassLoader()); ep.addAttachment(PreDestroyHolder.class, new PreDestroyHolder(targetBean)); } return targetBean; }
private boolean hasWebservicesMD(final Endpoint endpoint) { final Deployment dep = endpoint.getService().getDeployment(); return dep.getAttachment(WebservicesMetaData.class) != null; }
@Override public void start(final Deployment dep) { final DeploymentUnit unit = dep.getAttachment(DeploymentUnit.class); if (unit instanceof WSEndpointDeploymentUnit) return; for (final Endpoint endpoint : dep.getService().getEndpoints()) { ModelNode op = null; try { op = unit.createDeploymentSubModel(WSExtension.SUBSYSTEM_NAME, PathElement.pathElement(ENDPOINT, URLEncoder.encode(getId(endpoint), "UTF-8"))); } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); } op.get(ENDPOINT_NAME).set(getName(endpoint)); op.get(ENDPOINT_CONTEXT).set(getContext(endpoint)); op.get(ENDPOINT_CLASS).set(endpoint.getTargetBeanName()); op.get(ENDPOINT_TYPE).set(endpoint.getType().toString()); op.get(ENDPOINT_WSDL).set(endpoint.getAddress() + "?wsdl"); } }
protected String getImplicitPattern(Deployment dep, Endpoint ep) { // #4 Fallback to the ejb-name String urlPattern = ep.getShortName(); return urlPattern; }
/** * Creates new JMS Web Service endpoint. * * @param endpointClass endpoint class name * @param endpointName endpoint name * @param dep deployment * @return WS endpoint */ protected final Endpoint newJMSEndpoint(final String endpointClass, final String endpointName, final String soapAddress, final Deployment dep) { if (endpointName == null) throw MESSAGES.nullEndpointName(); if (endpointClass == null) throw MESSAGES.nullEndpointClass(); final Endpoint endpoint = deploymentModelFactory.newJMSEndpoint(endpointClass); endpoint.setAddress(soapAddress); endpoint.setShortName(endpointName); endpoint.setType(endpointType); dep.getService().addEndpoint(endpoint); return endpoint; }
ep.setShortName(ejbName); ep.setProperty(InvocationHandlerEJB3.CONTAINER_NAME, containName);
/** * Creates new Web Service endpoint. * * @param endpointClass endpoint class name * @param endpointName endpoint name * @param dep deployment * @return WS endpoint */ protected final Endpoint newEndpoint(final String endpointClass, final String endpointName, final Deployment dep) { if (endpointName == null) { throw new NullPointerException("Null endpoint name"); } if (endpointClass == null) { throw new NullPointerException("Null endpoint class"); } final Endpoint endpoint = this.deploymentModelFactory.newEndpoint(endpointClass); endpoint.setShortName(endpointName); dep.getService().addEndpoint(endpoint); return endpoint; }
ServerEndpointMetaData sepMetaData = ep.getAttachment(ServerEndpointMetaData.class); if (sepMetaData == null) sepMetaData.setEndpoint(ep); ep.addAttachment(ServerEndpointMetaData.class, sepMetaData); ep.addAttachment(MessageFactoryImpl.class, messageFactory); String targetBean = ep.getTargetBeanName(); if (targetBean != null) sepMetaData.setServiceEndpointImplName(targetBean);
public void init(Endpoint ep) { containerName = (String)ep.getProperty(InvocationHandlerEJB3.CONTAINER_NAME); assert containerName!=null : "Target container name not set"; }
private void unregisterEndpoint(final Endpoint ep) { MBeanServer mbeanServer = serverConfigServiceValue.getValue().getMbeanServer(); if (mbeanServer != null) { try { mbeanServer.unregisterMBean(endpoint.getName()); } catch (final JMException ex) { WSLogger.ROOT_LOGGER.trace("Cannot unregister endpoint from JMX server", ex); WSLogger.ROOT_LOGGER.cannotUnregisterEndpoint(endpoint.getShortName()); } } else { WSLogger.ROOT_LOGGER.mBeanServerNotAvailable(endpoint.getShortName()); } }
/** * Creates new Http Web Service endpoint. * * @param endpointClass endpoint class name * @param endpointName endpoint name * @param dep deployment * @return WS endpoint */ protected final Endpoint newHttpEndpoint(final String endpointClass, final String endpointName, final Deployment dep) { if (endpointName == null) throw WSLogger.ROOT_LOGGER.nullEndpointName(); if (endpointClass == null) throw WSLogger.ROOT_LOGGER.nullEndpointClass(); final Endpoint endpoint = this.deploymentModelFactory.newHttpEndpoint(endpointClass); endpoint.setShortName(endpointName); endpoint.setType(endpointType); dep.getService().addEndpoint(endpoint); return endpoint; }