/******************************************************************************* * Copyright (c) 2010 Eteration A.S. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * - This code is based on WTP SDK frameworks and Tomcat Server Adapters * org.eclipse.jst.server.core * org.eclipse.jst.server.ui * * Naci Dai and Murat Yener, Eteration A.S. *******************************************************************************/ package org.eclipse.libra.framework.core; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.wst.server.core.IRuntimeWorkingCopy; import org.eclipse.wst.server.core.IServerType; import org.eclipse.wst.server.core.IServerWorkingCopy; import org.eclipse.wst.server.core.ServerCore; import org.eclipse.wst.server.core.internal.provisional.ServerLocatorDelegate; /** * */ @SuppressWarnings("restriction") public class OSGIFrameworkInstanceLocatorDelegate extends ServerLocatorDelegate { @Override public void searchForServers(String host, final IServerSearchListener listener, final IProgressMonitor monitor) { OSGIFrameworkLocatorDelegate.IRuntimeSearchListener listener2 = new OSGIFrameworkLocatorDelegate.IRuntimeSearchListener() { public void runtimeFound(IRuntimeWorkingCopy runtime) { String runtimeTypeId = runtime.getRuntimeType().getId(); String serverTypeId = runtimeTypeId.substring(0, runtimeTypeId.length() - 8); IServerType serverType = ServerCore.findServerType(serverTypeId); try { IServerWorkingCopy server = serverType.createServer(serverTypeId, null, runtime, monitor); listener.serverFound(server); } catch (Exception e) { Trace.trace(Trace.WARNING, "Could not create OSGI runtime instance", e); } } }; OSGIFrameworkLocatorDelegate.searchForRuntimes2(null, listener2, monitor); } }