You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by th...@apache.org on 2007/02/20 04:42:30 UTC

svn commit: r509422 [2/3] - in /labs/droids: ./ conf/ lib/ src/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/droids/ src/java/org/apache/droids/Queue/ src/java/org/apache/droids/api/ src/java/org/apache/droids/conf/ src/java/org/apa...

Added: labs/droids/src/java/org/apache/droids/api/Queue.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/api/Queue.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/api/Queue.java (added)
+++ labs/droids/src/java/org/apache/droids/api/Queue.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.api;
+
+public interface Queue extends Pluggable, Configurable{
+    /** The name of the extension point. */
+    public final static String X_POINT_ID = Queue.class.getName();
+    public Task getTask(String id);
+    public void init(Task[] initialTask);
+    public boolean hasNext();
+    public Task next();
+    public void merge(Task[] filterLinks);
+    public int totalSize();
+}

Propchange: labs/droids/src/java/org/apache/droids/api/Queue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/api/Task.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/api/Task.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/api/Task.java (added)
+++ labs/droids/src/java/org/apache/droids/api/Task.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.api;
+
+public interface Task {
+    public String getId();
+    public String getTaskDate();
+}

Propchange: labs/droids/src/java/org/apache/droids/api/Task.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/api/URLFilter.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/api/URLFilter.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/api/URLFilter.java (added)
+++ labs/droids/src/java/org/apache/droids/api/URLFilter.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,12 @@
+package org.apache.droids.api;
+
+public interface URLFilter extends Pluggable, Configurable{
+    /** The name of the extension point. */
+    public final static String X_POINT_ID = URLFilter.class.getName();
+
+    /*
+     * Interface for a filter that transforms a URL: it can pass the original
+     * URL through or "delete" the URL by returning null
+     */
+    public String filter(String urlString);
+}

Propchange: labs/droids/src/java/org/apache/droids/api/URLFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/conf/Configuration.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/conf/Configuration.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/conf/Configuration.java (added)
+++ labs/droids/src/java/org/apache/droids/conf/Configuration.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,237 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.conf;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.ListIterator;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.droids.StringUtils;
+
+public class Configuration {
+    private XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+    private static final Log LOG = LogFactory.getLog(Configuration.class);
+
+    private static final String PROPERTY_ELEMENT = "property";
+
+    private static final String NAME_ELEMENT = "name";
+
+    private static final String VALUE_ELEMENT = "value";
+
+    private static Pattern varPat = Pattern.compile("\\$\\{[^\\}\\$\u0020]+\\}");
+
+    private static int MAX_SUBST = 20;
+
+    private ArrayList<Object> defaultResources = new ArrayList<Object>();
+
+    private ArrayList<Object> finalResources = new ArrayList<Object>();
+
+    private Properties properties;
+
+    private ClassLoader classLoader;
+    {
+        classLoader = Thread.currentThread().getContextClassLoader();
+        if (classLoader == null) {
+            classLoader = Configuration.class.getClassLoader();
+        }
+    }
+
+    public Object getObject(String cacheId) {
+        return getProps().get(cacheId);
+    }
+
+    public void addDefaultResource(String name) {
+        addResource(defaultResources, name);
+    }
+
+    private synchronized void addResource(ArrayList<Object> resources,
+            Object resource) {
+        resources.add(resource); // add to resources
+        properties = null; // trigger reload
+    }
+
+    public void addFinalResource(String name) {
+        addResource(finalResources, name);
+    }
+
+    public String[] getStrings(String name) {
+        String valueString = get(name);
+        return StringUtils.getStrings(valueString);
+    }
+
+    public String get(String name) {
+        return substituteVars(getProps().getProperty(name));
+    }
+
+    private synchronized Properties getProps() {
+        if (properties == null) {
+            Properties newProps = new Properties();
+            loadResources(newProps, defaultResources);
+            loadResources(newProps, finalResources);
+            properties = newProps;
+        }
+        return properties;
+    }
+
+    private void loadResources(Properties props, ArrayList<Object> resources) {
+        ListIterator i = resources.listIterator(resources.size());
+        // FIXME: not sure why 1 is not allowed
+        if (!i.hasNext() & resources.size() > 0) {
+            loadResource(props, resources.get(0));
+        }
+        while (i.hasNext()) {
+            loadResource(props, i.next());
+        }
+    }
+
+    private void loadResource(Properties props, Object name) {
+        URL source = null;
+        if (name instanceof URL) { // an URL resource
+            URL url = (URL) name;
+            if (url != null) {
+                LOG.info("parsing " + url);
+                source = url;
+            }
+        } else if (name instanceof String) { // a CLASSPATH resource
+            URL url = getResource((String) name);
+            if (url != null) {
+                LOG.info("parsing " + url);
+                source = url;
+            }
+        }
+        try {
+            XMLStreamReader parser = inputFactory.createXMLStreamReader(source
+                    .openStream());
+            processConfig(props, parser);
+        } catch (XMLStreamException e) {
+            LOG.error(e.getMessage());
+        } catch (IOException e) {
+            LOG.error(e.getMessage());
+        }
+    }
+
+    private void processConfig(Properties props, XMLStreamReader parser)
+            throws XMLStreamException {
+        String name = "", value = "", mode = "";
+        while (true) {
+            int event = parser.next();
+            switch (event) {
+            case XMLStreamConstants.END_DOCUMENT:
+                parser.close();
+                return;
+            case XMLStreamConstants.END_ELEMENT:
+                if (parser.getLocalName().equals(PROPERTY_ELEMENT)) {
+                    props.setProperty(name, value);
+                    name = "";
+                    value = "";
+                    mode = "";
+                } else if (parser.getLocalName().equals(NAME_ELEMENT)
+                        | parser.getLocalName().equals(VALUE_ELEMENT)) {
+                    mode = "";
+                }
+                break;
+            case XMLStreamConstants.START_ELEMENT:
+                if (parser.getLocalName().equals(NAME_ELEMENT)
+                        | parser.getLocalName().equals(VALUE_ELEMENT)) {
+                    mode = parser.getLocalName();
+                }
+                break;
+            case XMLStreamConstants.CHARACTERS:
+                if (null == mode)
+                    break;
+                else if (mode.equals(VALUE_ELEMENT)) {
+                    value = value + parser.getText().replace("\n", "").replace(" ", "");
+                } else if (mode.equals(NAME_ELEMENT)) {
+                    name = name + parser.getText().replace("\n", "").replace(" ", "");
+                }
+                break;
+            }
+        }
+    }
+
+    /** Returns the URL for the named resource. */
+    public URL getResource(String name) {
+        return classLoader.getResource(name);
+    }
+
+    private String substituteVars(String expr) {
+        if (expr == null) {
+            return null;
+        }
+        Matcher match = varPat.matcher("");
+        String eval = expr;
+        for (int s = 0; s < MAX_SUBST; s++) {
+            match.reset(eval);
+            if (!match.find()) {
+                return eval;
+            }
+            String var = match.group();
+            var = var.substring(2, var.length() - 1); // remove ${ .. }
+            String val = System.getProperty(var);
+            if (val == null) {
+                val = (String) this.getObject(var);
+            }
+            if (val == null) {
+                return eval; // return literal ${var}: var is unbound
+            }
+            // substitute
+            eval = eval.substring(0, match.start()) + val
+                    + eval.substring(match.end());
+        }
+        throw new IllegalStateException("Variable substitution depth too large: "
+                + MAX_SUBST + " " + expr);
+    }
+
+    public String get(String name, String defaultValue) {
+        return substituteVars(getProps().getProperty(name, defaultValue));
+    }
+    /** Sets the value of the <code>name</code> property. */
+    public void setObject(String name, Object value) {
+      getProps().put(name, value);
+    }
+    public Reader getConfResourceAsReader(String name) {
+        try {
+            URL url= getResource(name);
+
+            if (url == null) {
+              LOG.info(name + " not found");
+              return null;
+            } else {
+              LOG.info("found resource " + name + " at " + url);
+            }
+
+            return new InputStreamReader(url.openStream());
+          } catch (Exception e) {
+            return null;
+          }
+    }
+
+}

Propchange: labs/droids/src/java/org/apache/droids/conf/Configuration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/conf/Configured.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/conf/Configured.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/conf/Configured.java (added)
+++ labs/droids/src/java/org/apache/droids/conf/Configured.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,24 @@
+package org.apache.droids.conf;
+
+import org.apache.droids.api.Configurable;
+
+/** Base class for things that may be configured with a {@link Configuration}. */
+public class Configured implements Configurable {
+
+    private Configuration conf;
+
+    /** Construct a Configured. */
+    public Configured(Configuration conf) {
+        setConf(conf);
+    }
+
+    // inherit javadoc
+    public void setConf(Configuration conf) {
+        this.conf = conf;
+    }
+
+    // inherit javadoc
+    public Configuration getConf() {
+        return conf;
+    }
+}
\ No newline at end of file

Propchange: labs/droids/src/java/org/apache/droids/conf/Configured.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/conf/DroidsConfiguration.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/conf/DroidsConfiguration.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/conf/DroidsConfiguration.java (added)
+++ labs/droids/src/java/org/apache/droids/conf/DroidsConfiguration.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.conf;
+
+public class DroidsConfiguration {
+    private static Configuration conf;
+    public static Configuration create() {
+        conf = new Configuration();
+        addDroidsResources(conf);
+        return conf;
+    }
+    private static Configuration addDroidsResources(Configuration conf) {
+        conf.addDefaultResource("droids-default.xml");
+        conf.addFinalResource("droids-site.xml");
+        return conf; 
+    }
+
+}

Propchange: labs/droids/src/java/org/apache/droids/conf/DroidsConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/crawler/DefaultCrawler.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/crawler/DefaultCrawler.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/crawler/DefaultCrawler.java (added)
+++ labs/droids/src/java/org/apache/droids/crawler/DefaultCrawler.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,56 @@
+package org.apache.droids.crawler;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.droids.api.Crawler;
+import org.apache.droids.api.Parser;
+import org.apache.droids.api.Queue;
+import org.apache.droids.conf.Configuration;
+import org.apache.droids.exception.DroidsException;
+import org.apache.droids.factory.HandlerFactory;
+import org.apache.droids.factory.ParserFactory;
+import org.apache.droids.factory.ProtocolFactory;
+import org.apache.droids.factory.QueueFactory;
+import org.apache.droids.factory.URLFiltersFactory;
+import org.apache.droids.plugin.PluginRepository;
+
+public abstract class DefaultCrawler implements Crawler{
+    public static final Log LOG = LogFactory.getLog(DefaultCrawler.class);
+    public static final String ROBOTS = "robots.txt";
+    protected Configuration conf = null;
+    protected ProtocolFactory protocolFactory;
+    protected ParserFactory parserFactory;
+    private PluginRepository pluginRepository;
+    protected URLFiltersFactory filterFactorysFactory;
+    protected HandlerFactory handlersFactory;
+    protected QueueFactory queueFactory;
+    protected String taskDate;
+    protected Parser parser;
+    protected Queue queue;
+
+    public DefaultCrawler(Configuration conf) throws DroidsException {
+        this.conf = conf;
+        initialize();
+    }
+
+    protected void initialize() throws DroidsException {
+        taskDate = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System
+                .currentTimeMillis()));
+        LOG.info("starting plugins");
+        pluginRepository = new PluginRepository(conf);
+        LOG.info("starting queue");
+        queueFactory = new QueueFactory(conf, pluginRepository);
+        LOG.info("starting protocols");
+        protocolFactory = new ProtocolFactory(conf, pluginRepository);
+        LOG.info("starting parser");
+        parserFactory = new ParserFactory(conf, pluginRepository);
+        LOG.info("starting filter");
+        filterFactorysFactory = new URLFiltersFactory(conf);
+        LOG.info("starting handler");
+        handlersFactory = new HandlerFactory(conf);
+    }
+
+}
\ No newline at end of file

Propchange: labs/droids/src/java/org/apache/droids/crawler/DefaultCrawler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/crawler/Xm02y07.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/crawler/Xm02y07.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/crawler/Xm02y07.java (added)
+++ labs/droids/src/java/org/apache/droids/crawler/Xm02y07.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.crawler;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.droids.Queue.QueueLink;
+import org.apache.droids.api.Link;
+import org.apache.droids.api.Parse;
+import org.apache.droids.api.Protocol;
+import org.apache.droids.api.Task;
+import org.apache.droids.conf.Configuration;
+import org.apache.droids.conf.DroidsConfiguration;
+import org.apache.droids.exception.DroidsException;
+import org.apache.droids.exception.ParserNotFoundException;
+import org.apache.droids.parse.Outlink;
+
+public class Xm02y07 extends DefaultCrawler {
+    public static final Log LOG = LogFactory.getLog(Xm02y07.class);
+    private Link initialLink;
+
+    public Xm02y07(Configuration conf) throws DroidsException {
+        super(conf);
+    }
+
+    public Xm02y07() throws DroidsException {
+        super(DroidsConfiguration.create());
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.droids.Crawler#crawl(java.lang.String)
+     */
+    public void crawl(String uri) throws MalformedURLException, IOException,
+            DroidsException {
+        LOG.info("url " + uri);
+        initialLink = new QueueLink(uri, taskDate);
+        queue = queueFactory.getQueue("simple");
+        queue.init((Task[])new Task[] {initialLink});
+        while (queue.hasNext()) {
+            Task link = queue.next();
+            doTask(link);
+        }
+        LOG.info("crawler-x-m02y07 reports:\nFinished initial job "+uri);
+        LOG.info("Crawled a total of "+queue.totalSize());
+        LOG.info("crawler-x-m02y07\n\nApache Droids Initial Crawler has finished crawling your page.");
+        LOG.info("\nThanks for testing, hope you liked it. \nPlease report feedback to labs@labs.apache.org.\n TIA.");
+    }
+
+    private void doTask(Task link) throws DroidsException, IOException, MalformedURLException {
+        String uri =link.getId();
+        LOG.info("uri "+uri);
+        // Protocols are used to
+        // * open the stream and
+        // * returning the contentType
+        Protocol protocol = protocolFactory.getProtocol(uri);
+        String contentType = protocol.getContentType(uri);
+        LOG.info("content type is: " + contentType);
+        try {
+            parser = parserFactory.getParser(contentType);
+        } catch (ParserNotFoundException e) {
+            /*
+             * FIXME: 
+             * discuss whether the parserFactory should return null
+             * instead throwing an excetion.
+             */
+            LOG.warn("", e);
+            parser=null;
+        }
+        // parse contains the outlinks and can be used later
+        Parse parse = null;
+        // if no parser is found we do not extract links
+        if (null != parser) {
+            try {
+                // extract links
+                parse = parser.getParse(protocol.openStream(uri), new URL(uri));
+                // all links from the page unfiltered
+                Outlink[] links = parse.getData().getOutlinks();
+                // new cleaned list
+                ArrayList<Outlink> filtered = new ArrayList<Outlink>();
+                for (int i = 0; i < links.length; i++) {
+                    Outlink outlink = links[i];
+                    String test = filterFactorysFactory.filter(outlink.getToUrl());
+                    if (null != test & !filtered.contains(outlink)) {
+                        filtered.add(outlink);
+                    }
+                }
+                // this are the links we need to follow
+                Outlink[] filterLinks = filtered.toArray(new Outlink[filtered.size()]);
+                queue.merge(filterLinks);
+            } catch (java.lang.NullPointerException e) {
+                LOG.warn("", e);
+            }
+        }
+        // pass the stream to the handlers for further processing
+        handlersFactory.handle(protocol.openStream(uri),new URL(uri));
+    }
+
+}

Propchange: labs/droids/src/java/org/apache/droids/crawler/Xm02y07.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/exception/DroidsException.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/exception/DroidsException.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/exception/DroidsException.java (added)
+++ labs/droids/src/java/org/apache/droids/exception/DroidsException.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.exception;
+
+public class DroidsException extends Exception {
+
+    private static final long serialVersionUID = -6910418914635962957L;
+    String mode;
+
+    public DroidsException(String message) {
+        super("DroidsException message:\n"+message);
+    }
+
+    public DroidsException(Throwable cause) {
+        super(cause);
+    }
+}

Propchange: labs/droids/src/java/org/apache/droids/exception/DroidsException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/exception/ParserNotFoundException.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/exception/ParserNotFoundException.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/exception/ParserNotFoundException.java (added)
+++ labs/droids/src/java/org/apache/droids/exception/ParserNotFoundException.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.exception;
+
+import org.apache.droids.exception.DroidsException;
+
+public class ParserNotFoundException extends DroidsException {
+    private static final long serialVersionUID = -7058147461702832283L;
+    private String url;
+    private String contentType;
+
+    public ParserNotFoundException(String url, String contentType) {
+      this(url, contentType,
+           "parser not found for contentType="+contentType+" url="+url);
+    }
+
+    public ParserNotFoundException(String url, String contentType, String message) {
+      super(message);
+      this.url = url;
+      this.contentType = contentType;
+    }
+
+    public ParserNotFoundException(String message) {
+        super(message);
+    }
+
+    public String getUrl() { return url; }
+    public String getContentType() { return contentType; }
+}

Propchange: labs/droids/src/java/org/apache/droids/exception/ParserNotFoundException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/exception/PluginRuntimeException.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/exception/PluginRuntimeException.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/exception/PluginRuntimeException.java (added)
+++ labs/droids/src/java/org/apache/droids/exception/PluginRuntimeException.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.exception;
+
+import org.apache.droids.exception.DroidsException;
+
+/**
+ * <code>PluginRuntimeException</code> will be thrown until a exception in the
+ * plugin managemnt occurs.
+ * 
+ */
+public class PluginRuntimeException  extends DroidsException {
+
+  private static final long serialVersionUID = 1L;
+
+  public PluginRuntimeException(Throwable cause) {
+    super(cause);
+  }
+
+  public PluginRuntimeException(String message) {
+    super(message);
+  }
+}

Propchange: labs/droids/src/java/org/apache/droids/exception/PluginRuntimeException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/exception/ProtocolNotFoundException.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/exception/ProtocolNotFoundException.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/exception/ProtocolNotFoundException.java (added)
+++ labs/droids/src/java/org/apache/droids/exception/ProtocolNotFoundException.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.exception;
+
+import org.apache.droids.exception.DroidsException;
+
+public class ProtocolNotFoundException extends DroidsException {
+    private static final long serialVersionUID = 6980937469875896426L;
+    private String url;
+
+    public ProtocolNotFoundException(String url) {
+      this(url, "protocol not found for url="+url);
+    }
+
+    public ProtocolNotFoundException(String url, String message) {
+      super(message);
+      this.url = url;
+    }
+
+    public String getUrl() { return url; }
+}

Propchange: labs/droids/src/java/org/apache/droids/exception/ProtocolNotFoundException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/factory/Factory.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/factory/Factory.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/factory/Factory.java (added)
+++ labs/droids/src/java/org/apache/droids/factory/Factory.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.factory;
+
+import org.apache.droids.conf.Configuration;
+import org.apache.droids.plugin.Extension;
+import org.apache.droids.plugin.ExtensionPoint;
+
+public class Factory {
+
+    protected ExtensionPoint extensionPoint;
+    protected Configuration conf;
+
+    public Factory() {
+        super();
+    }
+    protected Extension findExtension(String name, String string) {
+        Extension[] extensions = this.extensionPoint.getExtensions();
+
+        for (int i = 0; i < extensions.length; i++) {
+            Extension extension = extensions[i];
+
+            if (contains(name, extension.getAttribute(string)))
+                return extension;
+        }
+        return null;
+    }
+    protected boolean contains(String what, String where) {
+        String parts[] = where.split("[, ]");
+        for (int i = 0; i < parts.length; i++) {
+            if (parts[i].equals(what))
+                return true;
+        }
+        return false;
+    }
+
+}
\ No newline at end of file

Propchange: labs/droids/src/java/org/apache/droids/factory/Factory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/factory/HandlerFactory.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/factory/HandlerFactory.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/factory/HandlerFactory.java (added)
+++ labs/droids/src/java/org/apache/droids/factory/HandlerFactory.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.factory;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+
+import org.apache.droids.api.Handler;
+import org.apache.droids.conf.Configuration;
+import org.apache.droids.exception.DroidsException;
+import org.apache.droids.plugin.Extension;
+import org.apache.droids.plugin.PluginRepository;
+
+public class HandlerFactory extends Factory {
+private Handler[] handlers;
+    public HandlerFactory(Configuration conf) throws DroidsException {
+        handlers=(Handler[]) conf.getObject(Handler.class.getName());
+        if (null==handlers){
+            this.extensionPoint = PluginRepository.get(conf).getExtensionPoint(
+                    Handler.X_POINT_ID);
+            if (this.extensionPoint == null) {
+                throw new RuntimeException("x-point " + Handler.X_POINT_ID
+                        + " not found.");
+            }
+            Extension[] extensions = extensionPoint.getExtensions();
+            HashMap<String, Handler> handlerMap = new HashMap<String, Handler>();
+            for (int i = 0; i < extensions.length; i++) {
+                Extension extension = extensions[i];
+                Handler handler = (Handler) extension.getExtensionInstance();
+                if (!handlerMap.containsKey(handler.getClass().getName())) {
+                    handlerMap.put(handler.getClass().getName(), handler);
+                }
+            }
+            handlers=handlerMap.values().toArray(
+                    new Handler[0]);
+            conf.setObject(Handler.class.getName(), handlers);
+
+        }
+    }
+
+    public void handle(InputStream stream, URL url) {
+        for (int i = 0; i < this.handlers.length; i++) {
+            if (stream == null)
+                return;
+            this.handlers[i].handle(stream,url);
+        }
+        
+    }
+
+}

Propchange: labs/droids/src/java/org/apache/droids/factory/HandlerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/factory/ParserFactory.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/factory/ParserFactory.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/factory/ParserFactory.java (added)
+++ labs/droids/src/java/org/apache/droids/factory/ParserFactory.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.factory;
+
+import org.apache.droids.api.Parser;
+import org.apache.droids.conf.Configuration;
+import org.apache.droids.exception.DroidsException;
+import org.apache.droids.exception.ParserNotFoundException;
+import org.apache.droids.plugin.Extension;
+import org.apache.droids.plugin.PluginRepository;
+
+public class ParserFactory extends Factory {
+    public ParserFactory(Configuration conf, PluginRepository pluginRepository) {
+        this.conf = conf;
+        this.extensionPoint = pluginRepository.getExtensionPoint(
+                Parser.X_POINT_ID);
+        if (this.extensionPoint == null) {
+            throw new RuntimeException("x-point " + Parser.X_POINT_ID
+                    + " not found.");
+        }
+    }
+
+    public Parser getParser(String contentType) throws DroidsException {
+        String cacheId = contentType;
+        if (contentType == null)
+            throw new ParserNotFoundException(contentType);
+        if (conf.getObject(cacheId) != null) {
+            return (Parser) conf.getObject(cacheId);
+        } else {
+            Extension extension = findExtension(contentType,"contentType");
+            if (extension == null) {
+                throw new ParserNotFoundException(contentType);
+            }
+            Parser parser = null;
+            parser = (Parser) extension.getExtensionInstance();
+            return parser;
+        }
+
+    }
+}

Propchange: labs/droids/src/java/org/apache/droids/factory/ParserFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/factory/ProtocolFactory.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/factory/ProtocolFactory.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/factory/ProtocolFactory.java (added)
+++ labs/droids/src/java/org/apache/droids/factory/ProtocolFactory.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.factory;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.droids.api.Protocol;
+import org.apache.droids.conf.Configuration;
+import org.apache.droids.exception.DroidsException;
+import org.apache.droids.exception.ProtocolNotFoundException;
+import org.apache.droids.plugin.Extension;
+import org.apache.droids.plugin.PluginRepository;
+
+public class ProtocolFactory extends Factory {
+    public ProtocolFactory(Configuration conf, PluginRepository pluginRepository) {
+        this.conf = conf;
+        this.extensionPoint = pluginRepository.getExtensionPoint(
+                Protocol.X_POINT_ID);
+        if (this.extensionPoint == null) {
+            throw new RuntimeException("x-point " + Protocol.X_POINT_ID
+                + " not found.");
+          }
+    }
+
+    public Protocol getProtocol(String uri) throws DroidsException {
+        URL url;
+        try {
+            url = new URL(uri);
+            String protocolName = url.getProtocol();
+            String cacheId = Protocol.X_POINT_ID + protocolName;
+            if (protocolName == null)
+                throw new ProtocolNotFoundException(uri);
+            if (conf.getObject(cacheId) != null) {
+                return (Protocol) conf.getObject(cacheId);
+              } else {
+            Extension extension = findExtension(protocolName,"protocolName");
+            if (extension == null) {
+                throw new ProtocolNotFoundException(protocolName);
+            }
+            Protocol protocol = (Protocol) extension.getExtensionInstance();
+            return protocol;
+              }
+        } catch (MalformedURLException e) {
+            throw new ProtocolNotFoundException(uri, e.toString());
+        } catch (ProtocolNotFoundException e) {
+            throw new ProtocolNotFoundException(uri, e.toString());
+        }
+    }
+
+}

Propchange: labs/droids/src/java/org/apache/droids/factory/ProtocolFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/factory/QueueFactory.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/factory/QueueFactory.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/factory/QueueFactory.java (added)
+++ labs/droids/src/java/org/apache/droids/factory/QueueFactory.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.factory;
+
+import org.apache.droids.api.Queue;
+import org.apache.droids.conf.Configuration;
+import org.apache.droids.exception.DroidsException;
+import org.apache.droids.plugin.Extension;
+import org.apache.droids.plugin.PluginRepository;
+
+public class QueueFactory extends Factory {
+
+    public QueueFactory(Configuration conf, PluginRepository pluginRepository) {
+        this.conf = conf;
+        this.extensionPoint = pluginRepository.getExtensionPoint(Queue.X_POINT_ID);
+        if (this.extensionPoint == null) {
+            throw new RuntimeException("x-point " + Queue.X_POINT_ID
+                    + " not found.");
+        }
+    }
+
+    public Queue getQueue(String type) throws DroidsException {
+        String cacheId = Queue.X_POINT_ID + type;
+        if (conf.getObject(cacheId) != null) {
+            return (Queue) conf.getObject(cacheId);
+        } else {
+            Extension extension = findExtension(type,"queueName");
+            if (extension == null) {
+                throw new DroidsException("queueName: \""+ type+"\" not found!");
+            }
+            return (Queue) extension.getExtensionInstance();
+        }
+    }
+
+}

Propchange: labs/droids/src/java/org/apache/droids/factory/QueueFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/factory/URLFiltersFactory.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/factory/URLFiltersFactory.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/factory/URLFiltersFactory.java (added)
+++ labs/droids/src/java/org/apache/droids/factory/URLFiltersFactory.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.factory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.apache.droids.api.URLFilter;
+import org.apache.droids.conf.Configuration;
+import org.apache.droids.plugin.Extension;
+import org.apache.droids.plugin.PluginRepository;
+import org.apache.droids.exception.*;
+
+public class URLFiltersFactory extends Factory {
+    public static final String URLFILTER_ORDER = "urlfilter.order";
+
+    private URLFilter[] filters;
+
+    public URLFiltersFactory(Configuration conf) throws DroidsException {
+        this.conf = conf;
+        String order = conf.get(URLFILTER_ORDER);
+        this.filters = (URLFilter[]) conf.getObject(URLFilter.class.getName());
+        if (this.filters == null) {
+            String[] orderedFilters = null;
+            if (order != null && !order.trim().equals("")) {
+                orderedFilters = order.split("\\s+");
+            }
+            this.extensionPoint = PluginRepository.get(conf).getExtensionPoint(
+                    URLFilter.X_POINT_ID);
+            if (this.extensionPoint == null) {
+                throw new RuntimeException("x-point " + URLFilter.X_POINT_ID
+                        + " not found.");
+            }
+            Extension[] extensions = extensionPoint.getExtensions();
+            HashMap<String, URLFilter> filterMap = new HashMap<String, URLFilter>();
+            for (int i = 0; i < extensions.length; i++) {
+                Extension extension = extensions[i];
+                URLFilter filter = (URLFilter) extension.getExtensionInstance();
+                if (!filterMap.containsKey(filter.getClass().getName())) {
+                    filterMap.put(filter.getClass().getName(), filter);
+                }
+            }
+            if (orderedFilters == null) {
+                this.filters = (URLFilter[]) filterMap.values().toArray(
+                        new URLFilter[0]);
+                conf.setObject(URLFilter.class.getName(), this.filters);
+            } else {
+                ArrayList<URLFilter> filters = new ArrayList<URLFilter>();
+                for (int i = 0; i < orderedFilters.length; i++) {
+                    URLFilter filter = (URLFilter) filterMap.get(orderedFilters[i]);
+                    if (filter != null) {
+                        filters.add(filter);
+                    }
+                }
+                this.filters = (URLFilter[]) filters.toArray(new URLFilter[filters
+                        .size()]);
+                conf.setObject(URLFilter.class.getName(), this.filters);
+            }
+        }
+    }
+
+    /** Run all defined filters. Assume logical AND. */
+    public String filter(String urlString) {
+        for (int i = 0; i < this.filters.length; i++) {
+            if (urlString == null)
+                return null;
+            urlString = this.filters[i].filter(urlString);
+        }
+        return urlString;
+    }
+}

Propchange: labs/droids/src/java/org/apache/droids/factory/URLFiltersFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/handle/WriterHandler.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/handle/WriterHandler.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/handle/WriterHandler.java (added)
+++ labs/droids/src/java/org/apache/droids/handle/WriterHandler.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,37 @@
+package org.apache.droids.handle;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+
+import org.apache.droids.conf.Configuration;
+
+public class WriterHandler {
+
+    /**
+     * Pipes everything from the reader to the writer via a buffer
+     */
+    protected static void pipe(Reader reader, Writer writer) throws IOException {
+        char[] buf = new char[1024];
+        int read = 0;
+        while ((read = reader.read(buf)) >= 0) {
+            writer.write(buf, 0, read);
+        }
+        writer.flush();
+    }
+
+    protected Configuration conf;
+
+    public WriterHandler() {
+        super();
+    }
+
+    public Configuration getConf() {
+        return conf;
+    }
+
+    public void setConf(Configuration conf) {
+        this.conf=conf;
+    }
+
+}
\ No newline at end of file

Propchange: labs/droids/src/java/org/apache/droids/handle/WriterHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/parse/Outlink.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/parse/Outlink.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/parse/Outlink.java (added)
+++ labs/droids/src/java/org/apache/droids/parse/Outlink.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.parse;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.droids.api.Task;
+
+public class Outlink implements Task {
+    private String toUrl;
+    private String anchor;
+    private String taskDate=new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System
+            .currentTimeMillis()));
+    public Outlink(String toUrl, String anchor){
+        this.toUrl=toUrl;
+        this.anchor = anchor;
+    }
+    public Outlink(String toUrl){
+        this.toUrl=toUrl;
+    }
+    public String getToUrl() { return toUrl; }
+    public String getAnchor() { return anchor; }
+    public String getId() {
+        return toUrl;
+    }
+    public String getTaskDate() {
+        return taskDate;
+    }
+}

Propchange: labs/droids/src/java/org/apache/droids/parse/Outlink.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/parse/ParseData.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/parse/ParseData.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/parse/ParseData.java (added)
+++ labs/droids/src/java/org/apache/droids/parse/ParseData.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.parse;
+
+public class ParseData {
+    private Outlink[] outlinks;
+    public ParseData(Outlink[] outlinks) {
+        this.outlinks=outlinks;
+    }
+    /** The outlinks of the page. */
+    public Outlink[] getOutlinks() { return outlinks; }
+}

Propchange: labs/droids/src/java/org/apache/droids/parse/ParseData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/parse/ParseImpl.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/parse/ParseImpl.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/parse/ParseImpl.java (added)
+++ labs/droids/src/java/org/apache/droids/parse/ParseImpl.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.parse;
+
+import org.apache.droids.api.Parse;
+
+public class ParseImpl implements Parse {
+
+    private ParseData parseData;
+
+    private String text;
+
+    public ParseImpl(String text, ParseData parseData) {
+        this.text = text;
+        this.parseData = parseData;
+    }
+
+    public ParseData getData() {
+        return parseData;
+    }
+
+    public String getText() {
+        return text;
+    }
+
+}

Propchange: labs/droids/src/java/org/apache/droids/parse/ParseImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/plugin/Extension.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/plugin/Extension.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/plugin/Extension.java (added)
+++ labs/droids/src/java/org/apache/droids/plugin/Extension.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.plugin;
+
+import java.util.HashMap;
+
+import org.apache.droids.api.Configurable;
+import org.apache.droids.conf.Configuration;
+import org.apache.droids.exception.DroidsException;
+import org.apache.droids.exception.PluginRuntimeException;
+
+public class Extension {
+
+    private PluginDescriptor fDescriptor;
+    private String fId;
+    private String fTargetPoint;
+    private String fClazz;
+    private HashMap<String, String> fAttributes;
+    private Configuration conf;
+    private PluginRepository pluginRepository;
+
+    /**
+     * @param pDescriptor
+     *          a plugin descriptor
+     * @param pExtensionPoint
+     *          an extension porin
+     * @param pId
+     *          an unique id of the plugin
+     */
+    public Extension(PluginDescriptor pDescriptor, String pExtensionPoint,
+        String pId, String pExtensionClass, Configuration conf,
+        PluginRepository pluginRepository) {
+      fAttributes = new HashMap<String, String>();
+      setDescriptor(pDescriptor);
+      setExtensionPoint(pExtensionPoint);
+      setId(pId);
+      setClazz(pExtensionClass);
+      this.conf = conf;
+      this.pluginRepository = pluginRepository;
+    }
+
+    public Object getExtensionInstance() throws DroidsException {
+        // Must synchronize here to make sure creation and initialization
+        // of a plugin instance and it extension instance are done by
+        // one and only one thread.
+        // The same is in PluginRepository.getPluginInstance().
+        // Suggested by Stefan Groschupf <sg...@media-style.com>
+        synchronized (getId()) {
+          try {
+            PluginClassLoader loader = fDescriptor.getClassLoader();
+            Class extensionClazz = loader.loadClass(getClazz());
+            // lazy loading of Plugin in case there is no instance of the plugin
+            // already.
+           //this.pluginRepository.getPluginInstance(getDescriptor());
+            Object object = extensionClazz.newInstance();
+            if (object instanceof Configurable) {
+                ((Configurable) object).setConf(this.conf);
+              }
+            return object;
+          } catch (ClassNotFoundException e) {
+            throw new PluginRuntimeException(e);
+          } catch (InstantiationException e) {
+            throw new PluginRuntimeException(e);
+          } catch (IllegalAccessException e) {
+            throw new PluginRuntimeException(e);
+          }
+        }
+    }
+
+    public String getAttribute(String pKey) {
+        return fAttributes.get(pKey);
+    }
+
+    public Configuration getConf() {
+        return conf;
+    }
+
+    public void setConf(Configuration conf) {
+        this.conf = conf;
+    }
+
+    public HashMap<String, String> getAttributes() {
+        return fAttributes;
+    }
+
+    public void setAttributes(HashMap<String, String> attributes) {
+        fAttributes = attributes;
+    }
+
+    public String getClazz() {
+        return fClazz;
+    }
+
+    public void setClazz(String clazz) {
+        fClazz = clazz;
+    }
+
+    public PluginDescriptor getDescriptor() {
+        return fDescriptor;
+    }
+
+    public void setDescriptor(PluginDescriptor descriptor) {
+        fDescriptor = descriptor;
+    }
+
+    public String getId() {
+        return fId;
+    }
+
+    public void setId(String id) {
+        fId = id;
+    }
+
+    public String getTargetPoint() {
+        return fTargetPoint;
+    }
+
+    public void setExtensionPoint(String targetPoint) {
+        fTargetPoint = targetPoint;
+    }
+
+    public PluginRepository getPluginRepository() {
+        return pluginRepository;
+    }
+
+    public void setPluginRepository(PluginRepository pluginRepository) {
+        this.pluginRepository = pluginRepository;
+    }
+
+    public void addAttribute(String pKey, String pValue) {
+        fAttributes.put(pKey, pValue);
+    }
+
+}

Propchange: labs/droids/src/java/org/apache/droids/plugin/Extension.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/plugin/ExtensionBean.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/plugin/ExtensionBean.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/plugin/ExtensionBean.java (added)
+++ labs/droids/src/java/org/apache/droids/plugin/ExtensionBean.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.plugin;
+
+public class ExtensionBean {
+    private String extensionId = "", name = "", point = "", implementationId = "",
+            implementationClass = "";
+
+    public String getExtensionId() {
+        return extensionId;
+    }
+
+    public void setExtensionId(String extensionId) {
+        this.extensionId = extensionId;
+    }
+
+    public String getImplementationClass() {
+        return implementationClass;
+    }
+
+    public void setImplementationClass(String implementationClass) {
+        this.implementationClass = implementationClass;
+    }
+
+    public String getImplementationId() {
+        return implementationId;
+    }
+
+    public void setImplementationId(String implementationId) {
+        this.implementationId = implementationId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPoint() {
+        return point;
+    }
+
+    public void setPoint(String point) {
+        this.point = point;
+    }
+}

Propchange: labs/droids/src/java/org/apache/droids/plugin/ExtensionBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/plugin/ExtensionPoint.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/plugin/ExtensionPoint.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/plugin/ExtensionPoint.java (added)
+++ labs/droids/src/java/org/apache/droids/plugin/ExtensionPoint.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.plugin;
+
+import java.util.ArrayList;
+
+/**
+ * The <code>ExtensionPoint</code> provide meta information of a extension
+ * point.
+ * 
+ */
+public class ExtensionPoint {
+  private String ftId;
+  private String fName;
+  private String fSchema;
+  private ArrayList<Extension> fExtensions;
+  /**
+   * Constructor
+   * 
+   * @param pId
+   *          unique extension point Id
+   * @param pName
+   *          name of the extension poin
+   * @param pSchema
+   *          xml schema of the extension point
+   */
+  public ExtensionPoint(String pId, String pName, String pSchema) {
+    setId(pId);
+    setName(pName);
+    setSchema(pSchema);
+    fExtensions = new ArrayList<Extension>();
+  }
+
+  /**
+   * Returns the unique id of the extension point.
+   * 
+   * @return String
+   */
+  public String getId() {
+    return ftId;
+  }
+
+  /**
+   * Returns the name of the extension point.
+   * 
+   * @return String
+   */
+  public String getName() {
+    return fName;
+  }
+
+  /**
+   * Returns a path to the xml schema of a extension point.
+   * 
+   * @return String
+   */
+  public String getSchema() {
+    return fSchema;
+  }
+
+  /**
+   * Sets the extensionPointId.
+   * 
+   * @param pId extension point id
+   */
+  private void setId(String pId) {
+    ftId = pId;
+  }
+
+  /**
+   * Sets the extension point name.
+   * 
+   * @param pName
+   */
+  private void setName(String pName) {
+    fName = pName;
+  }
+
+  /**
+   * Sets the schema.
+   * 
+   * @param pSchema
+   */
+  private void setSchema(String pSchema) {
+    fSchema = pSchema;
+  }
+
+/**
+ * Install a coresponding extension to this extension point.
+ * 
+ * @param extension
+ */
+public void addExtension(Extension extension) {
+  fExtensions.add(extension);
+}
+
+/**
+ * Returns a array of extensions that lsiten to this extension point
+ * 
+ * @return Extension[]
+ */
+public Extension[] getExtensions() {
+  return fExtensions.toArray(new Extension[fExtensions.size()]);
+}
+ 
+}

Propchange: labs/droids/src/java/org/apache/droids/plugin/ExtensionPoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/plugin/Plugin.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/plugin/Plugin.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/plugin/Plugin.java (added)
+++ labs/droids/src/java/org/apache/droids/plugin/Plugin.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.plugin;
+
+import org.apache.droids.conf.Configuration;
+
+public class Plugin {
+    private PluginDescriptor fDescriptor;
+    protected Configuration conf;
+
+    public Plugin(PluginDescriptor pDescriptor, Configuration conf) {
+        setDescriptor(pDescriptor);
+        this.conf = conf;
+      }
+    /**
+     * Returns the plugin descriptor
+     * 
+     * @return PluginDescriptor
+     */
+    public PluginDescriptor getDescriptor() {
+      return fDescriptor;
+    }
+    /**
+     * @param descriptor The descriptor to set
+     */
+    private void setDescriptor(PluginDescriptor descriptor) {
+      fDescriptor = descriptor;
+    }
+
+}

Propchange: labs/droids/src/java/org/apache/droids/plugin/Plugin.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/plugin/PluginClassLoader.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/plugin/PluginClassLoader.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/plugin/PluginClassLoader.java (added)
+++ labs/droids/src/java/org/apache/droids/plugin/PluginClassLoader.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.plugin;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * The <code>PluginClassLoader</code> contains only classes of the runtime
+ * libraries setuped in the plugin manifest file and exported libraries of
+ * plugins that are required pluguin. Libraries can be exported or not. Not
+ * exported libraries are only used in the plugin own
+ * <code>PluginClassLoader</code>. Exported libraries are available for
+ * <code>PluginClassLoader</code> of plugins that depends on these plugins.
+ * 
+ */
+public class PluginClassLoader extends URLClassLoader {
+  /**
+   * Construtor
+   * 
+   * @param urls
+   *          Array of urls with own libraries and all exported libraries of
+   *          plugins that are required to this plugin
+   * @param parent
+   */
+  public PluginClassLoader(URL[] urls, ClassLoader parent) {
+    super(urls, parent);
+  }
+}

Propchange: labs/droids/src/java/org/apache/droids/plugin/PluginClassLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/droids/src/java/org/apache/droids/plugin/PluginDescriptor.java
URL: http://svn.apache.org/viewvc/labs/droids/src/java/org/apache/droids/plugin/PluginDescriptor.java?view=auto&rev=509422
==============================================================================
--- labs/droids/src/java/org/apache/droids/plugin/PluginDescriptor.java (added)
+++ labs/droids/src/java/org/apache/droids/plugin/PluginDescriptor.java Mon Feb 19 19:42:25 2007
@@ -0,0 +1,284 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.droids.plugin;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.droids.conf.Configuration;
+
+/**
+ * The <code>PluginDescriptor</code> provide access to all meta information of
+ * a nutch-plugin, as well to the internationalizable resources and the plugin
+ * own classloader. There are meta information about <code>Plugin</code>,
+ * <code>ExtensionPoint</code> and <code>Extension</code>. To provide
+ * access to the meta data of a plugin via a descriptor allow a lazy loading
+ * mechanism.
+ * 
+ * @author joa23
+ */
+public class PluginDescriptor {
+  private String fPluginPath;
+  private String fPluginClass = Plugin.class.getName();
+  private String fPluginId;
+  private String fVersion;
+  private String fName;
+  private String fProviderName;
+  private ArrayList<ExtensionPoint> fExtensionPoints = new ArrayList<ExtensionPoint>();
+  private ArrayList<String> fDependencies = new ArrayList<String>();
+  private ArrayList<URL> fExportedLibs = new ArrayList<URL>();
+  private ArrayList<URL> fNotExportedLibs = new ArrayList<URL>();
+  private ArrayList<Extension> fExtensions = new ArrayList<Extension>();
+private PluginClassLoader fClassLoader;
+  public static final Log LOG = LogFactory.getLog(PluginDescriptor.class);
+  /**
+   * Constructor
+   * 
+   * @param pId
+   * @param pVersion
+   * @param pName
+   * @param pProviderName
+   * @param pPluginclazz
+   * @param pPath
+   */
+  public PluginDescriptor(String pId, String pVersion, String pName,
+      String pProviderName, String pPluginclazz, String pPath,
+      Configuration conf) {
+    setPath(pPath);
+    setPluginId(pId);
+    setVersion(pVersion);
+    setName(pName);
+    setProvidername(pProviderName);
+
+    if (pPluginclazz != null)
+      setPluginClass(pPluginclazz);
+  }
+
+  /**
+   * @param pPath
+   */
+  private void setPath(String pPath) {
+    fPluginPath = pPath;
+  }
+
+  /**
+   * Returns the name of the plugin.
+   * 
+   * @return String
+   */
+  public String getName() {
+    return fName;
+  }
+
+  /**
+   * @param providerName
+   */
+  private void setProvidername(String providerName) {
+    fProviderName = providerName;
+  }
+
+  /**
+   * @param name
+   */
+  private void setName(String name) {
+    fName = name;
+  }
+
+  /**
+   * @param version
+   */
+  private void setVersion(String version) {
+    fVersion = version;
+  }
+
+  /**
+   * Returns the fully qualified name of the class which implements the abstarct
+   * <code>Plugin</code> class.
+   * 
+   * @return the name of this plug-in's runtime class or <code>null</code>.
+   */
+  public String getPluginClass() {
+    return fPluginClass;
+  }
+
+  /**
+   * Returns the unique identifier of the plug-in or <code>null</code>.
+   * 
+   * @return String
+   */
+  public String getPluginId() {
+    return fPluginId;
+  }
+
+  /**
+   * Returns an array of extensions.
+   * 
+   * @return Exception[]
+   */
+  public Extension[] getExtensions() {
+    return fExtensions.toArray(new Extension[fExtensions.size()]);
+  }
+
+  /**
+   * Adds a extension.
+   * 
+   * @param pExtension
+   */
+  public void addExtension(Extension pExtension) {
+    fExtensions.add(pExtension);
+  }
+
+  /**
+   * Sets the pluginClass.
+   * 
+   * @param pluginClass
+   *          The pluginClass to set
+   */
+  private void setPluginClass(String pluginClass) {
+    fPluginClass = pluginClass;
+  }
+
+  /**
+   * Sets the plugin Id.
+   * 
+   * @param pluginId
+   *          The pluginId to set
+   */
+  private void setPluginId(String pluginId) {
+    fPluginId = pluginId;
+  }
+
+  /**
+   * Adds a extension point.
+   * 
+   * @param extensionPoint
+   */
+  public void addExtensionPoint(ExtensionPoint extensionPoint) {
+    fExtensionPoints.add(extensionPoint);
+  }
+
+  /**
+   * Returns a array of extension points.
+   * 
+   * @return ExtensionPoint[]
+   */
+  public ExtensionPoint[] getExtenstionPoints() {
+    return fExtensionPoints
+        .toArray(new ExtensionPoint[fExtensionPoints.size()]);
+  }
+
+  /**
+   * Returns a array of plugin ids.
+   * 
+   * @return String[]
+   */
+  public String[] getDependencies() {
+    return fDependencies.toArray(new String[fDependencies.size()]);
+  }
+
+  /**
+   * Adds a dependency
+   * 
+   * @param pId id of the dependent plugin
+   */
+  public void addDependency(String pId) {
+    fDependencies.add(pId);
+  }
+
+  /**
+   * Adds a exported library with a relative path to the plugin directory.
+   * 
+   * @param pLibPath
+   */
+  public void addExportedLibRelative(String pLibPath)
+      throws MalformedURLException {
+    URL url = new File(getPluginPath() + File.separator + pLibPath).toURL();
+    fExportedLibs.add(url);
+  }
+
+  /**
+   * Returns the directory path of the plugin.
+   * 
+   * @return String
+   */
+  public String getPluginPath() {
+    return fPluginPath;
+  }
+
+  /**
+   * Returns a array exported librareis as URLs
+   * 
+   * @return URL[]
+   */
+  public URL[] getExportedLibUrls() {
+    return fExportedLibs.toArray(new URL[0]);
+  }
+
+  /**
+   * Adds a not exported library with a plugin directory relative path.
+   * 
+   * @param pLibPath
+   */
+  public void addNotExportedLibRelative(String pLibPath)
+      throws MalformedURLException {
+    URL url = new File(getPluginPath() + File.separator + pLibPath).toURL();
+    fNotExportedLibs.add(url);
+  }
+
+  /**
+   * Returns a array of libraries as URLs that are not exported by the plugin.
+   * 
+   * @return URL[]
+   */
+  public URL[] getNotExportedLibUrls() {
+    return fNotExportedLibs.toArray(new URL[fNotExportedLibs.size()]);
+  }
+
+  public String getProviderName() {
+    return fProviderName;
+  }
+
+  public String getVersion() {
+    return fVersion;
+  }
+
+public PluginClassLoader getClassLoader() {
+    if (fClassLoader != null)
+        return fClassLoader;
+      ArrayList<URL> arrayList = new ArrayList<URL>();
+      arrayList.addAll(fExportedLibs);
+      arrayList.addAll(fNotExportedLibs);
+    /*  File file = new File(getPluginPath());
+      try {
+        for (File file2 : file.listFiles()) {
+          if (file2.getAbsolutePath().endsWith("properties"))
+            arrayList.add(file2.getParentFile().toURL());
+        }
+      } catch (MalformedURLException e) {
+        LOG.debug(getPluginId() + " " + e.toString());
+      }*/
+      URL[] urls = arrayList.toArray(new URL[arrayList.size()]);
+      fClassLoader = new PluginClassLoader(urls, PluginDescriptor.class
+          .getClassLoader());
+      return fClassLoader;
+}
+}
+

Propchange: labs/droids/src/java/org/apache/droids/plugin/PluginDescriptor.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org