org.apache.catalina.startup.Bootstrap Java Examples

The following examples show how to use org.apache.catalina.startup.Bootstrap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpnegoAuthenticator.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
protected void initInternal() throws LifecycleException {
    super.initInternal();

    // Kerberos configuration file location
    String krb5Conf = System.getProperty(Constants.KRB5_CONF_PROPERTY);
    if (krb5Conf == null) {
        // System property not set, use the Tomcat default
        File krb5ConfFile = new File(Bootstrap.getCatalinaBase(),
                Constants.DEFAULT_KRB5_CONF);
        System.setProperty(Constants.KRB5_CONF_PROPERTY,
                krb5ConfFile.getAbsolutePath());
    }

    // JAAS configuration file location
    String jaasConf = System.getProperty(Constants.JAAS_CONF_PROPERTY);
    if (jaasConf == null) {
        // System property not set, use the Tomcat default
        File jaasConfFile = new File(Bootstrap.getCatalinaBase(),
                Constants.DEFAULT_JAAS_CONF);
        System.setProperty(Constants.JAAS_CONF_PROPERTY,
                jaasConfFile.getAbsolutePath());
    }
}
 
Example #2
Source File: SpnegoAuthenticator.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
protected void initInternal() throws LifecycleException {
    super.initInternal();

    // Kerberos configuration file location
    String krb5Conf = System.getProperty(Constants.KRB5_CONF_PROPERTY);
    if (krb5Conf == null) {
        // System property not set, use the Tomcat default
        File krb5ConfFile = new File(Bootstrap.getCatalinaBase(),
                Constants.DEFAULT_KRB5_CONF);
        System.setProperty(Constants.KRB5_CONF_PROPERTY,
                krb5ConfFile.getAbsolutePath());
    }

    // JAAS configuration file location
    String jaasConf = System.getProperty(Constants.JAAS_CONF_PROPERTY);
    if (jaasConf == null) {
        // System property not set, use the Tomcat default
        File jaasConfFile = new File(Bootstrap.getCatalinaBase(),
                Constants.DEFAULT_JAAS_CONF);
        System.setProperty(Constants.JAAS_CONF_PROPERTY,
                jaasConfFile.getAbsolutePath());
    }
}
 
Example #3
Source File: Control.java    From dacapobench with Apache License 2.0 5 votes vote down vote up
/**
 * This method gets invoked reflectively from the Tomcat harness so as to
 * avoid classloader strangeness. It would be more correct to use an enum for
 * the 'function' parameter, but we have classloader issues, so a string makes
 * life easier.
 * 
 * @param function The function to perform , one of
 * "prepare","startIteration", "stopIteration","cleanup".
 * @throws Exception Passed back from the Tomcat bootstrap
 */
public void exec(String function) throws Exception {
  if (function.equals("prepare")) {
    Bootstrap.main(new String[] { "startd" });
  } else if (function.equals("startIteration")) {
    startServer();
  } else if (function.equals("stopIteration")) {
    stopServer();
  } else if (function.equals("cleanup")) {
    Bootstrap.main(new String[] { "stopd" });
  }
}
 
Example #4
Source File: TomcatToolRunner.java    From sqoop-on-spark with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
   // Using Boostrap class to boot the common.loader and other catalina specific
   // class loaders.
   Bootstrap bootstrap = new Bootstrap();
   bootstrap.init();

   // Now we need to add the sqoop webapp classes into the class loader. Sadly
   // we have to do a lot of things ourselves. The procedure is:
	// 1) Unpack Sqoop war file
	// 2) Build the ClassLoader using Tomcat's ClassLoaderFactory

	// Various paths to war file and locations inside the war file
	String webappPath = System.getProperty(PROPERTY_APPBASE_PATH,
			DEFAULT_APPBASE_PATH);
	String catalinaBase = Bootstrap.getCatalinaBase();
	String fullWebappPath = catalinaBase + File.separator + webappPath;
	String fullSqoopWarPath = fullWebappPath + File.separator + "sqoop.war";
	String fullSqoopClassesPath = fullWebappPath + File.separator + "sqoop"
			+ File.separator + "WEB-INF" + File.separator + "classes";
	String fullSqoopLibPath = fullWebappPath + File.separator + "sqoop"
			+ File.separator + "WEB-INF" + File.separator + "lib";

	// Expand the war into the usual location, this operation is idempotent
	// (nothing bad happens if it's already expanded)
	Embedded embedded = new Embedded();
	Host host = embedded.createHost("Sqoop Tool Virtual Host",
			fullWebappPath);
	ExpandWar
			.expand(host, new URL("jar:file://" + fullSqoopWarPath + "!/"));

	// We have expanded war file, so we build the classloader from
	File[] unpacked = new File[1];
	unpacked[0] = new File(fullSqoopClassesPath);
	
	File[] packed = new File[1];
	packed[0] = new File(fullSqoopLibPath);
	
	ClassLoader loader = ClassLoaderFactory.createClassLoader(unpacked,
			packed, Thread.currentThread().getContextClassLoader());
	Thread.currentThread().setContextClassLoader(loader);

	// Finally we can call the usual ToolRunner. We have to use reflection
	// as
	// as the time of loading this class, Sqoop dependencies are not on
	// classpath.
	Class klass = Class.forName("org.apache.sqoop.tools.ToolRunner", true,
			loader);
	Method method = klass.getMethod("main", String[].class);
	method.invoke(null, (Object) args);
}