Java Code Examples for javax.servlet.ServletConfig

The following are top voted examples for showing how to use javax.servlet.ServletConfig. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: alfresco-remote-api   File: CMISServletDispatcher.java   Source Code and License 6 votes vote down vote up
public void init()
{
	Endpoint endpoint = new Endpoint(getBinding(), version);
	registry.registerDispatcher(endpoint, this);

	try
	{
		// fake the CMIS servlet
		ServletConfig config = getServletConfig();
    	this.servlet = getServlet();
    	servlet.init(config);
	}
	catch(ServletException e)
	{
		throw new AlfrescoRuntimeException("Failed to initialise CMIS servlet dispatcher", e);
	}
}
 
Example 2
Project: agilion   File: Bootstrap.java   Source Code and License 6 votes vote down vote up
@Override
public void init(ServletConfig config) throws ServletException {
  Info info = new Info()
    .title("Swagger Server")
    .description("orchestrates backend jobs")
    .termsOfService("")
    .contact(new Contact()
      .email("[email protected]"))
    .license(new License()
      .name("LGPL 3.0")
      .url("http://www.gnu.org/licenses/lgpl-3.0.txt"));

  ServletContext context = config.getServletContext();
  Swagger swagger = new Swagger().info(info);

  new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
}
 
Example 3
Project: e-identification-tupas-idp-public   File: ShibbolethExtAuthnHandler.java   Source Code and License 6 votes vote down vote up
public void init(ServletConfig config) throws ServletException {
    try {
        WebApplicationContext springContext = WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext());
        final AutowireCapableBeanFactory beanFactory = springContext.getAutowireCapableBeanFactory();
        beanFactory.autowireBean(this);
    }
    catch (Exception e) {
        logger.error("Error initializing ShibbolethExtAuthnHandler", e);
    }
}
 
Example 4
Project: swaggy-jenkins   File: ViewApi.java   Source Code and License 6 votes vote down vote up
public ViewApi(@Context ServletConfig servletContext) {
   ViewApiService delegate = null;

   if (servletContext != null) {
      String implClass = servletContext.getInitParameter("ViewApi.implementation");
      if (implClass != null && !"".equals(implClass.trim())) {
         try {
            delegate = (ViewApiService) Class.forName(implClass).newInstance();
         } catch (Exception e) {
            throw new RuntimeException(e);
         }
      } 
   }

   if (delegate == null) {
      delegate = ViewApiServiceFactory.getViewApi();
   }

   this.delegate = delegate;
}
 
Example 5
Project: elastest-instrumentation-manager   File: AgentApi.java   Source Code and License 6 votes vote down vote up
public AgentApi(@Context ServletConfig servletContext) {
   AgentApiService delegate = null;

   if (servletContext != null) {
      String implClass = servletContext.getInitParameter("AgentApi.implementation");
      if (implClass != null && !"".equals(implClass.trim())) {
         try {
            delegate = (AgentApiService) Class.forName(implClass).newInstance();
         } catch (Exception e) {
            throw new RuntimeException(e);
         }
      } 
   }

   if (delegate == null) {
      delegate = AgentApiServiceFactory.getAgentApi();
   }

   this.delegate = delegate;
}
 
Example 6
Project: elastest-instrumentation-manager   File: AgentconfigurationApi.java   Source Code and License 6 votes vote down vote up
public AgentconfigurationApi(@Context ServletConfig servletContext) {
   AgentconfigurationApiService delegate = null;

   if (servletContext != null) {
      String implClass = servletContext.getInitParameter("AgentconfigurationApi.implementation");
      if (implClass != null && !"".equals(implClass.trim())) {
         try {
            delegate = (AgentconfigurationApiService) Class.forName(implClass).newInstance();
         } catch (Exception e) {
            throw new RuntimeException(e);
         }
      } 
   }

   if (delegate == null) {
      delegate = AgentconfigurationApiServiceFactory.getAgentconfigurationApi();
   }

   this.delegate = delegate;
}
 
Example 7
Project: apache-tomcat-7.0.73-with-comment   File: TagHandlerPool.java   Source Code and License 6 votes vote down vote up
protected void init(ServletConfig config) {
    int maxSize = -1;
    String maxSizeS = getOption(config, OPTION_MAXSIZE, null);
    if (maxSizeS != null) {
        try {
            maxSize = Integer.parseInt(maxSizeS);
        } catch (Exception ex) {
            maxSize = -1;
        }
    }
    if (maxSize < 0) {
        maxSize = Constants.MAX_POOL_SIZE;
    }
    this.handlers = new Tag[maxSize];
    this.current = -1;
    instanceManager = InstanceManagerFactory.getInstanceManager(config);
}
 
Example 8
Project: parabuild-ci   File: ContainerUtil.java   Source Code and License 6 votes vote down vote up
/**
 * Create a {@link DefaultContainer}, allowing users to upgrade to a child
 * of DefaultContainer using an {@link ServletConfig} init parameter of
 * <code>org.directwebremoting.Container</code>. Note that while the
 * parameter name is the classname of {@link Container}, currently the only
 * this can only be used to create children that inherit from
 * {@link DefaultContainer}. This restriction may be relaxed in the future.
 * Unlike {@link #setupDefaultContainer(DefaultContainer, ServletConfig)},
 * this method does not call any setup methods.
 * @param servletConfig The source of init parameters
 * @return An unsetup implementaion of DefaultContainer
 * @throws ServletException If the specified class could not be found
 * @see ServletConfig#getInitParameter(String)
 */
public static DefaultContainer createDefaultContainer(ServletConfig servletConfig) throws ServletException
{
    try
    {
        String typeName = servletConfig.getInitParameter(Container.class.getName());
        if (typeName == null)
        {
            return new DefaultContainer();
        }

        log.debug("Using alternate Container implementation: " + typeName);
        Class type = LocalUtil.classForName(typeName);
        return (DefaultContainer) type.newInstance();
    }
    catch (Exception ex)
    {
        throw new ServletException(ex);
    }
}
 
Example 9
Project: dropwizard-prometheus   File: PrometheusServlet.java   Source Code and License 6 votes vote down vote up
@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    final ServletContext context = config.getServletContext();
    if (null == registry) {
        final Object registryAttr = context.getAttribute(METRICS_REGISTRY);
        if (registryAttr instanceof MetricRegistry) {
            this.registry = (MetricRegistry) registryAttr;
        } else {
            throw new ServletException("Couldn't find a MetricRegistry instance.");
        }
    }

    filter = (MetricFilter) context.getAttribute(METRIC_FILTER);
    if (filter == null) {
        filter = MetricFilter.ALL;
    }

    this.allowedOrigin = context.getInitParameter(ALLOWED_ORIGIN);
}
 
Example 10
Project: dremio-oss   File: IndexServlet.java   Source Code and License 6 votes vote down vote up
@Override
public void init(ServletConfig servletConfig) throws ServletException {
  this.servletConfig = servletConfig;

  //templateCfg.setClassForTemplateLoading(getClass(), "/");
  Resource baseResource;
  try {
    baseResource = Resource.newResource(servletConfig.getInitParameter("resourceBase"));
  } catch (MalformedURLException e) {
    throw new ServletException(e);
  }
  templateCfg.setTemplateLoader(new ResourceTemplateLoader(baseResource));
  templateCfg.setDefaultEncoding("UTF-8");

  // Sets how errors will appear.
  // During web page *development* TemplateExceptionHandler.HTML_DEBUG_HANDLER
  // is better.
  // cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  templateCfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
}
 
Example 11
Project: swaggy-jenkins   File: BlueApi.java   Source Code and License 6 votes vote down vote up
public BlueApi(@Context ServletConfig servletContext) {
   BlueApiService delegate = null;

   if (servletContext != null) {
      String implClass = servletContext.getInitParameter("BlueApi.implementation");
      if (implClass != null && !"".equals(implClass.trim())) {
         try {
            delegate = (BlueApiService) Class.forName(implClass).newInstance();
         } catch (Exception e) {
            throw new RuntimeException(e);
         }
      } 
   }

   if (delegate == null) {
      delegate = BlueApiServiceFactory.getBlueApi();
   }

   this.delegate = delegate;
}
 
Example 12
Project: joai-project   File: SchemaViewerServlet.java   Source Code and License 6 votes vote down vote up
public void init(ServletConfig conf) 
  		 throws ServletException {
System.out.println(getDateStamp() + " SchemaViewerServlet starting");
String initErrorMsg = "";
try {
	super.init(conf);
} catch (Throwable exc) {
	initErrorMsg = "SchemaViewerServlet Initialization Error:\n  " + exc;
	prtlnErr (initErrorMsg);
}

ServletContext servletContext = getServletContext();

MetadataVocab vocab = (MetadataVocab)servletContext.getAttribute( "MetadataVocab" );
if (vocab == null) {
	throw new ServletException ("MetadataVocab not found in servlet context");
}

// set up remote searcher
/* RemoteSearcher rs = (RemoteSearcher) servletContext.getAttribute ("RemoteSearcher");
if (rs == null) {
	throw new ServletException ("RemoteSearcher not found in servlet context");
} */

System.out.println(getDateStamp() + " SchemaViewerServlet initialized.");
  }
 
Example 13
Project: lams   File: TagHandlerPool.java   Source Code and License 6 votes vote down vote up
protected void init( ServletConfig config ) {
    int maxSize=-1;
    String maxSizeS=getOption(config, OPTION_MAXSIZE, null);
    if( maxSizeS != null ) {
        try {
            maxSize=Integer.parseInt(maxSizeS);
        } catch( Exception ex) {
            maxSize=-1;
        }
    }
    if( maxSize <0  ) {
        maxSize=Constants.MAX_POOL_SIZE;
    }
    this.handlers = new Tag[maxSize];
    this.current = -1;
    instanceManager = InstanceManagerFactory.getInstanceManager(config);
}
 
Example 14
Project: validator-web   File: StartupUtil.java   Source Code and License 6 votes vote down vote up
private static void scanValidationComponents(DefaultContainer container, ServletConfig servletConfig) {
    String scanPackage = servletConfig.getInitParameter(SCAN_PACKAGE_INIT_PARAMETER);
    if (scanPackage == null) {
        return;
    }
    
    ClassPathScanner scanner = new ClassPathScanner();
    scanner.addIncludeFilter(new ValidationScriptMappingTypeFilter());
    Set<Class<?>> classes = scanner.scan(scanPackage);
    
    for (Class<?> beanClass : classes) {
        try {
            Object bean = ClassUtils.newInstance(beanClass);
            String beanName = generateBeanName(beanClass, container);
            container.addBean(beanName, bean);
        } catch (Exception e) {
            log.error("Unable to instantiate class [" + beanClass.getName() + "].", e);
        }
    }
}
 
Example 15
Project: rockscript   File: Servlet.java   Source Code and License 6 votes vote down vote up
@Override
public void init(ServletConfig servletConfig) throws ServletException {
  super.init(servletConfig);

  if (engine==null) {
    Map<String,String> configurationProperties = readConfigurationProperties(servletConfig);
    engine = createEngine(configurationProperties);
  }

  engine.start();

  log.debug(" ____            _     ____            _       _    ");
  log.debug("|  _ \\ ___   ___| | __/ ___|  ___ _ __(_)_ __ | |_  ");
  log.debug("| |_) / _ \\ / __| |/ /\\___ \\ / __| '__| | '_ \\| __| ");
  log.debug("|  _ < (_) | (__|   <  ___) | (__| |  | | |_) | |_  ");
  log.debug("|_| \\_\\___/ \\___|_|\\_\\|____/ \\___|_|  |_| .__/ \\__| ");
  log.debug("                                        |_|         ");

  setGson(engine.getGson());

  engine
    .getRequestHandlers()
    .forEach(requestHandler->requestHandler(requestHandler));

  defaultResponseHeader("Access-Control-Allow-Origin", "*");
}
 
Example 16
Project: Equella   File: SRWServletExt.java   Source Code and License 6 votes vote down vote up
@Override
public void init() throws ServletException
{
	Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
	final ServletConfig config = super.getServletConfig();
	super.init();

	// We do so we don't have specify a 'database' on the URL path
	// eg. http://localhost:8988/dev/first/srw/
	srwInfo = new SRWServletInfo()
	{
		@Override
		public String getDBName(HttpServletRequest request)
		{
			return DB_NAME;
		}
	};
	srwInfo.init(config);
	srwInfo.getProperties().put("defaultSchema", EquellaSRWDatabase.DEFAULT_SCHEMA.getTleId()); //$NON-NLS-1$
	srwInfo.getProperties().put("db." + DB_NAME + ".class", EquellaSRWDatabase.class.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
 
Example 17
Project: parabuild-ci   File: DwrGuiceServlet.java   Source Code and License 5 votes vote down vote up
/**
 * Copies DWR configuration values from the Guice bindings into 
 * {@code servletConfig} to make these values accessible to the 
 * standard DWR servlet configuration machinery.
 */
@Override public void init(ServletConfig servletConfig) throws ServletException
{
    // Save this for later use by destroy.
    this.servletContext = servletConfig.getServletContext();
    
    // Set the current context thread-locally so our internal classes can
    // look up the Injector and use it in turn to look up further objects.
    pushServletContext(this.servletContext);
    try
    {      
        // Since ServletConfig is immutable, we use a modifiable 
        // decoration of the real servlet configuration and pass 
        // that to the init method of the superclass.
        ModifiableServletConfig config = new ModifiableServletConfig(servletConfig);
    
        // Apply settings configured at bind-time.
        setInitParameters(config);

        // Use our internal manager classes to replace and delegate to
        // any user-specified or default implementations, after adding
        // additional creators and converters registered at bind-time.
        configureDelegatedTypes(config);
        
        // Normal DwrServlet initialization happens here using the
        // modified ServletConfig instead of the one we were passed.
        super.init(config);

        // Objects with (non-global) application scope are initialized
        // eagerly.
        initApplicationScoped();            
    }
    finally
    {
        // Clean up the ThreadLocal we just used.
        popServletContext();
    }
}
 
Example 18
Project: java-web-services-training   File: CountriesServlet.java   Source Code and License 5 votes vote down vote up
@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    // Prepare list of Country objects
    countries.add(new Country("IDN", "Indonesia"));
    countries.add(new Country("MYS", "Malaysia"));
}
 
Example 19
Project: pentaho-8-reporting-for-java-developers   File: PentahoServlet.java   Source Code and License 5 votes vote down vote up
@Override
public void init(
  ServletConfig config) 
  throws ServletException 
{

  super.init(config);
  ClassicEngineBoot.getInstance().start();

}
 
Example 20
Project: parabuild-ci   File: ContainerUtil.java   Source Code and License 5 votes vote down vote up
/**
 * Take a DefaultContainer and setup the default beans
 * @param container The container to configure
 * @param servletConfig The servlet configuration (null to ignore)
 * @throws InstantiationException If we can't instantiate a bean
 * @throws IllegalAccessException If we have access problems creating a bean
 */
public static void setupFromServletConfig(DefaultContainer container, ServletConfig servletConfig) throws InstantiationException, IllegalAccessException
{
    Enumeration en = servletConfig.getInitParameterNames();
    while (en.hasMoreElements())
    {
        String name = (String) en.nextElement();
        String value = servletConfig.getInitParameter(name);
        container.addParameter(name, value);
    }
}
 
Example 21
Project: lams   File: CGIServlet.java   Source Code and License 5 votes vote down vote up
/**
 * Sets instance variables.
 * <P>
 * Modified from Craig R. McClanahan's InvokerServlet
 * </P>
 *
 * @param config                    a <code>ServletConfig</code> object
 *                                  containing the servlet's
 *                                  configuration and initialization
 *                                  parameters
 *
 * @exception ServletException      if an exception has occurred that
 *                                  interferes with the servlet's normal
 *                                  operation
 */
public void init(ServletConfig config) throws ServletException {

    super.init(config);

    // Verify that we were not accessed using the invoker servlet
    String servletName = getServletConfig().getServletName();
    if (servletName == null)
        servletName = "";
    if (servletName.startsWith("org.apache.catalina.INVOKER."))
        throw new UnavailableException
            ("Cannot invoke CGIServlet through the invoker");
    
    // Set our properties from the initialization parameters
    if (getServletConfig().getInitParameter("debug") != null)
        debug = Integer.parseInt(getServletConfig().getInitParameter("debug"));
    cgiPathPrefix = getServletConfig().getInitParameter("cgiPathPrefix");
    boolean passShellEnvironment = 
        Boolean.valueOf(getServletConfig().getInitParameter("passShellEnvironment")).booleanValue();

    if (passShellEnvironment) {
        shellEnv.putAll(System.getenv());
    }

    if (getServletConfig().getInitParameter("executable") != null) {
        cgiExecutable = getServletConfig().getInitParameter("executable");
    }

    if (getServletConfig().getInitParameter("parameterEncoding") != null) {
        parameterEncoding = getServletConfig().getInitParameter("parameterEncoding");
    }

}
 
Example 22
Project: pentaho-8-reporting-for-java-developers   File: PentahoServlet.java   Source Code and License 5 votes vote down vote up
@Override
public void init(
  ServletConfig config) 
  throws ServletException 
{

  super.init(config);
  ClassicEngineBoot.getInstance().start();

}
 
Example 23
Project: uflo   File: UfloServlet.java   Source Code and License 5 votes vote down vote up
@Override
public void init(ServletConfig config) throws ServletException {
	super.init(config);
	WebApplicationContext applicationContext=getWebApplicationContext(config);
	Collection<ServletHandler> handlers=applicationContext.getBeansOfType(ServletHandler.class).values();
	for(ServletHandler handler:handlers){
		String url=handler.url();
		if(handlerMap.containsKey(url)){
			throw new RuntimeException("Handler ["+url+"] already exist.");
		}
		handlerMap.put(url, handler);
	}
}
 
Example 24
Project: apache-tomcat-7.0.73-with-comment   File: TagHandlerPool.java   Source Code and License 5 votes vote down vote up
protected static String getOption(ServletConfig config, String name,
        String defaultV) {
    if (config == null)
        return defaultV;

    String value = config.getInitParameter(name);
    if (value != null)
        return value;
    if (config.getServletContext() == null)
        return defaultV;
    value = config.getServletContext().getInitParameter(name);
    if (value != null)
        return value;
    return defaultV;
}
 
Example 25
Project: parabuild-ci   File: StartupUtil.java   Source Code and License 5 votes vote down vote up
/**
 * We have some special logging classes to maintain an optional dependence
 * on commons-logging. This sets the servlet for when this is not available.
 * @param servletConfig The servlet configuration
 * @param servlet The servlet that we are running under
 */
public static void setupLogging(ServletConfig servletConfig, HttpServlet servlet)
{
    ServletLoggingOutput.setExecutionContext(servlet);
    String logLevel = servletConfig.getInitParameter(ContainerUtil.INIT_LOGLEVEL);
    if (logLevel != null)
    {
        ServletLoggingOutput.setLevel(logLevel);
    }
}
 
Example 26
Project: pentaho-8-reporting-for-java-developers   File: PentahoServlet.java   Source Code and License 5 votes vote down vote up
@Override
public void init(
  ServletConfig config) 
  throws ServletException 
{

  super.init(config);
  ClassicEngineBoot.getInstance().start();

}
 
Example 27
Project: parabuild-ci   File: DefaultWebContextBuilder.java   Source Code and License 5 votes vote down vote up
public void set(HttpServletRequest request, HttpServletResponse response, ServletConfig config, ServletContext context, Container container)
{
    try
    {
        WebContext ec = new DefaultWebContext(request, response, config, context, container);
        user.set(ec);
    }
    catch (Exception ex)
    {
        log.fatal("Failed to create an ExecutionContext", ex);
    }
}
 
Example 28
Project: validator-web   File: WebContextThreadStack.java   Source Code and License 5 votes vote down vote up
/**
 * Make the current thread know what the current request is.
 * @param servletConfig The servlet configuration object used by a servlet container
 * @param request The incoming http request
 * @param response The outgoing http reply
 * @see #disengageThread()
 */
public static void engageThread(ServletConfig servletConfig, HttpServletRequest request, HttpServletResponse response) {
    try {
        WebContext ec = new DefaultWebContext(request, response, servletConfig,
                servletConfig.getServletContext());
        engageThread(ec);
    } catch (Exception ex) {
        log.fatal("Failed to create an ExecutionContext", ex);
    }
}
 
Example 29
Project: sgroup   File: ProductServlet.java   Source Code and License 5 votes vote down vote up
/**
     * 带参数的初始化,只执行一次
     * @param config web.xml的配置
     * @throws ServletException
     */
    @Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
//        读取编码格式
//        charset = config.getInitParameter("charset");

    }
 
Example 30
Project: lazycat   File: TagHandlerPool.java   Source Code and License 5 votes vote down vote up
protected static String getOption(ServletConfig config, String name, String defaultV) {
	if (config == null)
		return defaultV;

	String value = config.getInitParameter(name);
	if (value != null)
		return value;
	if (config.getServletContext() == null)
		return defaultV;
	value = config.getServletContext().getInitParameter(name);
	if (value != null)
		return value;
	return defaultV;
}
 
Example 31
Project: joai-project   File: CommCoreServlet.java   Source Code and License 5 votes vote down vote up
/**
 *  Intialize the StandardsSuggestionService and place it in the ServletContext
 *  where it can be found by the Rest Service Clases.
 *
 * @param  config                Description of the Parameter
 * @exception  ServletException  Description of the Exception
 */
public void init(ServletConfig config)
	 throws ServletException {
	log.info (getDateStamp() + " CommCoreServlet starting");
	String initErrorMsg = "";
	try {
		super.init(config);
	} catch (Throwable exc) {
		initErrorMsg = "CommCoreServlet Initialization Error:\n  " + exc;
		log.error (initErrorMsg);
	}

	// initialize the AdnStandardsManager
	String commCoreStandardsPath = getAbsolutePath ((String)getServletContext().getInitParameter("commCoreStandardsPath"));
	if (commCoreStandardsPath == null) {
		throw new ServletException("init parameter \"commCoreStandardsPath\" not found in servlet context");
	}
	CommCoreServiceHelper commCoreServiceHelper = null;
	try {
		commCoreServiceHelper = new CommCoreServiceHelper(commCoreStandardsPath); 
	} catch (Exception e) {
		log.error("Failed to initialize StdDocument.", e);
	}

	if (commCoreServiceHelper != null)
		getServletContext().setAttribute("commCoreServiceHelper", commCoreServiceHelper);
	else
		throw new ServletException ("Failed to initialize StdDocument");

	log.info (getDateStamp() + " CommCoreServlet completed.\n");
}
 
Example 32
Project: bootstrap   File: BackendProxyServletTest.java   Source Code and License 5 votes vote down vote up
@Test(expected = UnavailableException.class)
public void getRequiredInitParameter() throws ServletException {
	final ServletConfig servletConfig = Mockito.mock(ServletConfig.class);

	Mockito.when(servletConfig.getServletName()).thenReturn("a");
	Mockito.when(servletContext.getContextPath()).thenReturn("context");
	Mockito.when(servletConfig.getServletContext()).thenReturn(servletContext);
	Mockito.when(servletConfig.getInitParameter("prefix")).thenReturn("prefix");
	Mockito.when(servletConfig.getInitParameter("maxThreads")).thenReturn("6");
	servlet.init(servletConfig);
}
 
Example 33
Project: lazycat   File: JspServletWrapper.java   Source Code and License 5 votes vote down vote up
public JspServletWrapper(ServletConfig config, Options options, String jspUri, JspRuntimeContext rctxt) {

		this.isTagFile = false;
		this.config = config;
		this.options = options;
		this.jspUri = jspUri;
		unloadByCount = options.getMaxLoadedJsps() > 0 ? true : false;
		unloadByIdle = options.getJspIdleTimeout() > 0 ? true : false;
		unloadAllowed = unloadByCount || unloadByIdle ? true : false;
		ctxt = new JspCompilationContext(jspUri, options, config.getServletContext(), this, rctxt);
	}
 
Example 34
Project: server   File: PeerServlet.java   Source Code and License 5 votes vote down vote up
@Override
public void init(ServletConfig servletConfig) throws ServletException {
	super.init(servletConfig);

	WebApplicationContext context = getWebApplicationContext();
	service = (JrpcService) context.getBean("Service");
}
 
Example 35
Project: openNaEF   File: DifferenceServlet.java   Source Code and License 5 votes vote down vote up
@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    try {
        ConfigUtil conf = ConfigUtil.getInstance();
        if (!conf.reload())
            throw new ServletException("Config load error.");
        checkAndCreateDirs(conf.getDebugDumpDir());
        checkAndCreateDirs(conf.getDifferenceSetDir());
        RegularExecution.getInstance().reScheduleAll();
        AAAConfiguration.getInstance().reloadConfiguration();
    } catch (Exception e) {
        log.error("got exception.", e);
    }
}
 
Example 36
Project: validator-web   File: ScriptSupportServlet.java   Source Code and License 5 votes vote down vote up
@Override
public void init(ServletConfig servletConfig) throws ServletException {
    super.init(servletConfig);
    
    try {
        this.container = StartupUtil.createAndSetupDefaultContainer(servletConfig);
        
        this.servletConfig = servletConfig;
    } catch (Exception ex) {
        log.fatal("init failed", ex);
        throw new ServletException(ex);
    }
    
    this.processor = this.container.getBean(UrlProcessor.class);
}
 
Example 37
Project: parabuild-ci   File: WebXMLTest.java   Source Code and License 5 votes vote down vote up
public void testServletParameters() throws Exception {
    WebXMLString wxs = new WebXMLString();
    Properties params = new Properties();
    params.setProperty( "color", "red" );
    params.setProperty( "age", "12" );
    wxs.addServlet( "simple", "/SimpleServlet", SimpleGetServlet.class, params );

    ServletRunner sr = new ServletRunner( toInputStream( wxs.asText() ) );
    ServletUnitClient client = sr.newClient();
    InvocationContext ic = client.newInvocation( "http://localhost/SimpleServlet" );
    ServletConfig servletConfig = ic.getServlet().getServletConfig();
    assertNull( "init parameter 'gender' should be null", servletConfig.getInitParameter( "gender" ) );
    assertEquals( "init parameter via config", "red", ic.getServlet().getServletConfig().getInitParameter( "color" ) );
    assertEquals( "init parameter directly", "12", ((HttpServlet) ic.getServlet()).getInitParameter( "age" ) );
}
 
Example 38
Project: jaffa-framework   File: JawrServletTest.java   Source Code and License 5 votes vote down vote up
/**
 * tests Jawr Properties load
 * @throws Exception
    */
//@Test
public void testJawrPropertiesLoad() throws Exception {

	//initialize
	Map<String, String> initParameters = new HashMap<String, String>();
	initParameters.put("configLocation", "/jawr.properties");
	initParameters.put("configPropertiesSourceClass", "org.jaffa.ria.util.PropsFilePropertiesSource");
	initParameters.put("mapping", "/jsJawrPath/");

	ServletContext servletContext = mock(ServletContext.class);
	ServletConfig servletConfig = mock(ServletConfig.class);

	when(servletConfig.getServletContext()).thenReturn(servletContext);
	when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(initParameters.keySet()));
	when(servletConfig.getInitParameter("configLocation")).thenReturn("/jawr.properties");
	when(servletConfig.getInitParameter("configPropertiesSourceClass")).thenReturn("org.jaffa.ria.util.PropsFilePropertiesSource");
	when(servletConfig.getInitParameter("mapping")).thenReturn("/jsJawrPath/");

	when(servletContext.getAttribute("javax.servlet.context.tempdir")).thenReturn(new File("abc"));


	//test
	JawrServlet jawrServlet = new JawrServlet();

	jawrServlet.init(servletConfig);


	//verify
	verify(servletContext).setAttribute(eq(JawrConstant.JS_CONTEXT_ATTRIBUTE), any());

}
 
Example 39
Project: myfaces-trinidad   File: ResourceServlet.java   Source Code and License 5 votes vote down vote up
/**
 * Override of Servlet.init();
 */
@Override
public void init(
  ServletConfig config
  ) throws ServletException
{
  super.init(config);

  // Acquire our FacesContextFactory instance
  try
  {
    _facesContextFactory = (FacesContextFactory)
              FactoryFinder.getFactory
              (FactoryFinder.FACES_CONTEXT_FACTORY);
  }
  catch (FacesException e)
  {
    Throwable rootCause = e.getCause();
    if (rootCause == null)
    {
      throw e;
    }
    else
    {
      throw new ServletException(e.getMessage(), rootCause);
    }
  }

  // Acquire our Lifecycle instance
  _lifecycle = new _ResourceLifecycle();
  _initDebug(config);
  _loaders = new ConcurrentHashMap<String, ResourceLoader>();
  _loaderErrors = new ConcurrentHashMap<String, Class<?>>();
}
 
Example 40
Project: pentaho-8-reporting-for-java-developers   File: PentahoServlet.java   Source Code and License 5 votes vote down vote up
@Override
public void init(
  ServletConfig config) 
  throws ServletException 
{

  super.init(config);
  ClassicEngineBoot.getInstance().start();

}