List of usage examples for javax.servlet ServletConfig getServletContext
public ServletContext getServletContext();
From source file:org.wso2.carbon.registry.resource.ui.clients.RegistryAdminServiceClient.java
public RegistryAdminServiceClient(ServletConfig config, HttpSession session) throws RegistryException { String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); ConfigurationContext configContext = (ConfigurationContext) config.getServletContext() .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); epr = backendServerURL + "RegistryAdminService"; try {//w w w . j a va 2 s . c o m stub = new RegistryAdminServiceStub(configContext, epr); ServiceClient client = stub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); } catch (AxisFault axisFault) { String msg = "Failed to initiate resource service client. " + axisFault.getMessage(); log.error(msg, axisFault); throw new RegistryException(msg, axisFault); } }
From source file:org.pentaho.test.platform.web.GetImageIT.java
@Before public void setUp() throws PlatformInitializationException, ServletException { request = mock(HttpServletRequest.class); when(request.getMethod()).thenReturn("GET"); response = mock(HttpServletResponse.class); servlet = spy(new GetImage()); final ServletConfig servletConfig = mock(ServletConfig.class); final ServletContext servletContext = mock(ServletContext.class); when(servletContext.getMimeType(anyString())).thenReturn(TEST_MIME_TYPE); when(servletConfig.getServletContext()).thenReturn(servletContext); servlet.init(servletConfig);/* w w w. j a v a 2 s. co m*/ mp.start(); }
From source file:io.github.benas.todolist.web.servlet.user.LoginServlet.java
@Override public void init(ServletConfig servletConfig) throws ServletException { //initialize Spring user service ApplicationContext applicationContext = WebApplicationContextUtils .getWebApplicationContext(servletConfig.getServletContext()); userService = applicationContext.getBean(UserService.class); //initialize JSR 303 validator ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); validator = factory.getValidator();/*from w w w . j a v a 2s .co m*/ resourceBundle = ResourceBundle.getBundle("todolist"); }
From source file:com.eviware.soapui.impl.wsdl.monitor.jettyproxy.ProxyServlet.java
public void init(ServletConfig config) throws ServletException { this.config = config; this.context = config.getServletContext(); }
From source file:org.apache.stratos.manager.dashboard.ui.clients.CloudManagerServiceClient.java
public CloudManagerServiceClient(ServletRequest request, ServletConfig config, HttpSession session) throws RegistryException { String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); ConfigurationContext configContext = (ConfigurationContext) config.getServletContext() .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); epr = backendServerURL + "CloudManagerService"; try {//from www. jav a 2s. c o m stub = new CloudManagerServiceStub(configContext, epr); ServiceClient client = stub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); } catch (AxisFault axisFault) { String msg = "Failed to initiate Add Services service client. " + axisFault.getMessage(); log.error(msg, axisFault); throw new RegistryException(msg, axisFault); } }
From source file:org.wso2.carbon.governance.custom.lifecycles.history.ui.clients.ResourceServiceClient.java
public ResourceServiceClient(ServletConfig config, HttpSession session) throws RegistryException { String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); ConfigurationContext configContext = (ConfigurationContext) config.getServletContext() .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); epr = backendServerURL + "ResourceAdminService"; try {//from w w w . j a v a 2 s . c o m stub = new ResourceAdminServiceStub(configContext, epr); ServiceClient client = stub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); } catch (AxisFault axisFault) { String msg = "Failed to initiate resource service client. " + axisFault.getMessage(); log.error(msg, axisFault); throw new RegistryException(msg, axisFault); } }
From source file:org.polymap.service.fs.webdav.WebDavServer.java
public void init(ServletConfig _config) throws ServletException { super.init(_config); log.info("WebDAV Server: " + _config.getServletContext().getContextPath()); try {//from w w w . j a va2 s .c o m this.config = _config; // Map<String,String> users = new HashMap(); // users.put( "admin", "admin" ); // users.put( "falko", "." ); securityManager = new SecurityManagerAdapter("POLYMAP3 WebDAV"); resourceFactory = new WebDavResourceFactory(securityManager, "webdav"); AuthenticationService authService = new AuthenticationService(); BalkonCacheControl cacheControl = new BalkonCacheControl(false); BalkonWebDavResponseHandler defaultHandler = new BalkonWebDavResponseHandler(authService); defaultHandler.setCacheControl(cacheControl); CompressingResponseHandler compressHandler = new CompressingResponseHandler(defaultHandler); compressHandler.setMaxMemorySize(1024 * 1024); compressHandler.setCacheControlHelper(cacheControl); httpManager = new HttpManager(resourceFactory, compressHandler, authService); httpManager.addFilter(0, new PreAuthenticationFilter(httpManager.getResponseHandler(), securityManager)); } catch (Throwable ex) { log.error("Exception while starting", ex); throw new RuntimeException(ex); } }
From source file:com.tenduke.example.scribeoauth.JwtLoginServlet.java
/** * Initializes this servlet./*ww w.java2 s .c om*/ * @param config Servlet configuration. * @throws ServletException For errors during init. */ @Override public void init(final ServletConfig config) throws ServletException { // super.init(config); // final JSONObject jwtPublicKey = readConfiguration("idp.jwt.publickey.json", config.getServletContext()); try { // byte[] publicKeyDecoded = Base64.decodeBase64(jwtPublicKey.getString("publicKey")); X509EncodedKeySpec keySpec = new X509EncodedKeySpec(publicKeyDecoded); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); publicKey = keyFactory.generatePublic(keySpec); } catch (InvalidKeySpecException | NoSuchAlgorithmException ex) { // throw new ServletException("No way, basic RSA based key generation failed...", ex); } }
From source file:dk.itst.oiosaml.sp.service.DispatcherServlet.java
@Override public final void init(ServletConfig config) throws ServletException { setHandler(new ConfigurationHandler(config.getServletContext()), "configure"); servletContext = config.getServletContext(); initServlet();/*from ww w . ja v a 2 s. c om*/ engine = new VelocityEngine(); engine.setProperty(VelocityEngine.RESOURCE_LOADER, "classpath"); engine.setProperty("classpath.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); try { engine.init(); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.wso2.carbon.registry.activities.ui.clients.ActivityServiceClient.java
public ActivityServiceClient(String cookie, ServletConfig config, HttpSession session) throws RegistryException { this.session = session; if (proxy == null) { String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); ConfigurationContext configContext = (ConfigurationContext) config.getServletContext() .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); String epr = backendServerURL + "ActivityAdminService"; try {//from w w w.j a v a2s .c o m stub = new ActivityAdminServiceStub(configContext, epr); ServiceClient client = stub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); } catch (AxisFault axisFault) { String msg = "Failed to initiate comment service client. " + axisFault.getMessage(); log.error(msg, axisFault); throw new RegistryException(msg, axisFault); } proxy = this; } }