/*
* Copyright 2004,2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.carbon.tomcat.internal;
import org.apache.catalina.LifecycleException;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
//import org.osgi.service.http.HttpService;
import org.wso2.carbon.tomcat.BetterTomcat;
import org.wso2.carbon.tomcat.BetterTomcatException;
import javax.servlet.ServletException;
import java.io.File;
/**
* The OSGi BundleActivator for the BetterTomcat bundle
*/
public class BetterTomcatActivator implements BundleActivator {
private ServiceRegistration serviceRegistration;
public void start(BundleContext bundleContext) throws Exception {
// serviceRegistration = bundleContext.registerService(HttpService.class.getName(),
// new BetterTomcatHttpService(), null);
// testServer();
}
private static final String WEBAPP_PATH =
new File("/Users/azeez/projects/wso2/org/trunk/carbon/core/org.wso2.carbon" +
".tomcat/src/test/java/resources/hello").getAbsolutePath();
public void testServer() throws ServletException, LifecycleException, BetterTomcatException {
BetterTomcat tomcat = new BetterTomcat(8080);
tomcat.addWebapp("/hello", WEBAPP_PATH);
tomcat.start();
}
public void stop(BundleContext bundleContext) throws Exception {
if (serviceRegistration != null) {
serviceRegistration.unregister();
}
}
}