1 /**********************************************************************
2 * Copyright (c) 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM - Initial API and implementation
10 **********************************************************************/
11 package net.sourceforge.phpdt.monitor.core.internal;
13 import java.io.IOException;
14 import java.net.Socket;
16 import net.sourceforge.phpdt.monitor.core.IMonitor;
17 import net.sourceforge.phpdt.monitor.core.IProtocolAdapter;
18 import net.sourceforge.phpdt.monitor.core.IProtocolAdapterDelegate;
20 import org.eclipse.core.runtime.IConfigurationElement;
24 public class ProtocolAdapter implements IProtocolAdapter {
25 protected IConfigurationElement element;
26 protected IProtocolAdapterDelegate delegate;
28 protected ProtocolAdapter(IConfigurationElement element) {
29 this.element = element;
32 public String getId() {
33 return element.getAttribute("id");
36 public String getName() {
37 return element.getAttribute("name");
40 public void parse(IMonitor monitor, Socket in, Socket out) throws IOException {
41 if (delegate == null) {
43 delegate = (IProtocolAdapterDelegate) element.createExecutableExtension("class");
44 } catch (Exception e) {
45 Trace.trace(Trace.SEVERE, "Could not create protocol adapter delegate: " + getId(), e);
49 delegate.parse(monitor, in, out);