/********************************************************************** * Copyright (c) 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html  * * Contributors: * IBM - Initial API and implementation **********************************************************************/ package net.sourceforge.phpdt.monitor.core.internal; import java.io.IOException; import java.net.Socket; import net.sourceforge.phpdt.monitor.core.IMonitor; import net.sourceforge.phpdt.monitor.core.IProtocolAdapter; import net.sourceforge.phpdt.monitor.core.IProtocolAdapterDelegate; import org.eclipse.core.runtime.IConfigurationElement; /** * */ public class ProtocolAdapter implements IProtocolAdapter { protected IConfigurationElement element; protected IProtocolAdapterDelegate delegate; protected ProtocolAdapter(IConfigurationElement element) { this.element = element; } public String getId() { return element.getAttribute("id"); } public String getName() { return element.getAttribute("name"); } public void parse(IMonitor monitor, Socket in, Socket out) throws IOException { if (delegate == null) { try { delegate = (IProtocolAdapterDelegate) element.createExecutableExtension("class"); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Could not create protocol adapter delegate: " + getId(), e); return; } } delegate.parse(monitor, in, out); } }