/** * Returns WebServiceContext associated with this invocation. * * @param invocation current invocation * @return web service context or null if not available */ private WebServiceContext getWebServiceContext(final Invocation invocation) { final InvocationContext invocationContext = invocation.getInvocationContext(); return invocationContext.getAttachment(WebServiceContext.class); }
protected Object getTargetBean(Endpoint ep, Invocation epInv) { 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); } } return targetBean; }
private boolean validInvocationContext(InvocationContext context) { if (context == null) return false; final boolean servletInvocationContext = context instanceof ServletRequestContext; final boolean nettyInvocationContext = context.getProperty(Constants.NETTY_MESSAGE) != null; return servletInvocationContext || nettyInvocationContext; }
/** * Calls {@link javax.xml.rpc.server.ServiceLifecycle#init(Object)} * method on target bean if this bean implements * {@link javax.xml.rpc.server.ServiceLifecycle} interface. * * @param invocation current invocation * @throws Exception if any error occurs */ @Override public void onBeforeInvocation(final Invocation invocation) throws Exception { final InvocationContext invocationContext = invocation.getInvocationContext(); final Object targetBean = invocationContext.getTargetBean(); final boolean isJaxrpcLifecycleBean = targetBean instanceof ServiceLifecycle; if (isJaxrpcLifecycleBean) { final ServletEndpointContext sepContext = invocationContext.getAttachment(ServletEndpointContext.class); ((ServiceLifecycle) targetBean).init(sepContext); } }
private Invocation createInvocation(InvocationHandler invHandler, Object serviceObject, Endpoint ep, Method m, Object[] paramArray) { Invocation inv = invHandler.createInvocation(); InvocationContext invContext = inv.getInvocationContext(); WebServiceContext wsCtx = new WebServiceContextImpl(null); invContext.addAttachment(WebServiceContext.class, wsCtx); invContext.setTargetBean(serviceObject); inv.setJavaMethod(m); inv.setArgs(paramArray); return inv; }
/** * Returns endpoint instance associated with current invocation. * * @param invocation current invocation * @return target bean in invocation */ private Object getTargetBean(final Invocation invocation) { final InvocationContext invocationContext = invocation.getInvocationContext(); return invocationContext.getTargetBean(); }
public Invocation() { this.invocationContext = new InvocationContext(); }
public Object getInstance() { return wsInvocation.getInvocationContext().getTargetBean(); } };
protected Invocation setupInvocation(Endpoint ep, EndpointInvocation epInv, InvocationContext invContext) throws Exception { CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext(); if (msgContext instanceof SOAPMessageContextJAXRPC) { invContext.addAttachment(javax.xml.rpc.handler.MessageContext.class, msgContext); } if (ServiceLifecycle.class.isAssignableFrom(ep.getTargetBeanClass()) && invContext instanceof ServletRequestContext) { ServletEndpointContext servletEndpointContext = new ServletEndpointContextImpl((ServletRequestContext)invContext); invContext.addAttachment(ServletEndpointContext.class, servletEndpointContext); } invContext.addAttachment(EndpointInvocation.class, epInv); Invocation wsInv = new DelegatingInvocation(); wsInv.setInvocationContext(invContext); wsInv.setJavaMethod(getImplMethod(endpoint, epInv)); wsInv.getInvocationContext().setTargetBean(getEndpointInstance()); return wsInv; }
public Invocation() { this.invocationContext = new InvocationContext(); }
public CallbackImpl(Invocation epInv) { jaxrpcMessageContext = epInv.getInvocationContext().getAttachment(javax.xml.rpc.handler.MessageContext.class); jaxwsMessageContext = epInv.getInvocationContext().getAttachment(javax.xml.ws.handler.MessageContext.class); }
protected Object getTargetBean(Endpoint ep, Invocation epInv) { 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); } } return targetBean; }
public Object getInstance() { return wsInvocation.getInvocationContext().getTargetBean(); } };
private String getResourcePath(final InvocationContext context) { String resourcePath = null; if (context instanceof ServletRequestContext) { ServletRequestContext reqContext = (ServletRequestContext)context; HttpServletRequest req = reqContext.getHttpServletRequest(); resourcePath = (String)req.getParameter("resource"); } else if (context.getProperty(Constants.NETTY_MESSAGE) != null) { return null; // TODO: implement resourcePath = getResourcePath(nettyMessage.getUri()); // i.e. parse it from query string } return resourcePath; }
public <T> T get(Class<T> propertyType) { return wsInv.getInvocationContext().getAttachment(propertyType); } }
protected Object getTargetBean(Endpoint ep, Invocation epInv) { 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("Canot get target bean instance", ex); } } return targetBean; }
/** * Calls {@link javax.xml.rpc.server.ServiceLifecycle#destroy()} * method on target bean if this bean implements * {@link javax.xml.rpc.server.ServiceLifecycle} interface. * * @param invocation current invocation * @throws Exception if any error occurs */ @Override public void onAfterInvocation(final Invocation invocation) throws Exception { final InvocationContext invocationContext = invocation.getInvocationContext(); final Object targetBean = invocationContext.getTargetBean(); final boolean isJaxrpcLifecycleBean = targetBean instanceof ServiceLifecycle; if (isJaxrpcLifecycleBean) { ((ServiceLifecycle) targetBean).destroy(); } }
private URL getRequestURL(Endpoint endpoint, InvocationContext context) throws MalformedURLException { URL requestURL = null; if (context instanceof ServletRequestContext) { ServletRequestContext reqContext = (ServletRequestContext)context; HttpServletRequest req = reqContext.getHttpServletRequest(); requestURL = new URL(req.getRequestURL().toString()); } else if (context.getProperty(Constants.NETTY_MESSAGE) != null) { requestURL = new URL(endpoint.getAddress()); } return requestURL; }
public CallbackImpl(Invocation epInv) { jaxrpcMessageContext = epInv.getInvocationContext().getAttachment(javax.xml.rpc.handler.MessageContext.class); jaxwsMessageContext = epInv.getInvocationContext().getAttachment(javax.xml.ws.handler.MessageContext.class); }
protected Object getTargetBean(Endpoint ep, Invocation epInv) { 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); } } return targetBean; }