You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by js...@apache.org on 2007/11/26 19:06:19 UTC

svn commit: r598365 - in /servicemix/branches/servicemix-4.0/runtime: ./ filemonitor/ filemonitor/src/ filemonitor/src/main/ filemonitor/src/main/java/ filemonitor/src/main/java/org/ filemonitor/src/main/java/org/apache/ filemonitor/src/main/java/org/a...

Author: jstrachan
Date: Mon Nov 26 10:06:16 2007
New Revision: 598365

URL: http://svn.apache.org/viewvc?rev=598365&view=rev
Log:
added an initial implementation of a file monitor; that watches the deploy directory for jars to deploy, config files to change or expanded bundles (which are then turned into a bundle and deployed)

Added:
    servicemix/branches/servicemix-4.0/runtime/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/pom.xml   (with props)
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitor.java   (with props)
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitorActivator.java   (with props)
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/Scanner.java   (with props)
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/resources/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/resources/META-INF/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/LICENSE.txt   (with props)
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/MANIFEST.MF   (with props)
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/NOTICE.txt   (with props)
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/spring/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/spring/camel-context.xml   (with props)
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/org/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/org/apache/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/org/apache/camel/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/org/apache/camel/example/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/org/apache/camel/example/spring/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/org/apache/camel/example/spring/MyRouteBuilder$SomeBean.class   (with props)
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/org/apache/camel/example/spring/MyRouteBuilder.class   (with props)
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/foo/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/foo/META-INF/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/foo/META-INF/MANIFEST.MF   (with props)
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/foo/foo.txt   (with props)
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/java/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/java/org/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/java/org/apache/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/java/org/apache/servicemix/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/java/org/apache/servicemix/runtime/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/java/org/apache/servicemix/runtime/filemonitor/
    servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/java/org/apache/servicemix/runtime/filemonitor/BundlePackerTest.java   (with props)

Added: servicemix/branches/servicemix-4.0/runtime/filemonitor/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/filemonitor/pom.xml?rev=598365&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/filemonitor/pom.xml (added)
+++ servicemix/branches/servicemix-4.0/runtime/filemonitor/pom.xml Mon Nov 26 10:06:16 2007
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <!--
+
+      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.
+  -->
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicemix</groupId>
+    <artifactId>servicemix</artifactId>
+    <version>4.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>org.apache.servicemix.runtime.filemonitor</artifactId>
+  <packaging>bundle</packaging>
+  <name>ServiceMix Runtime :: File Monitor</name>
+
+  <description>This bundle monitors the deploy directory for new OSGi bundles in jar form, expanded form or for configuration file changes and undeploys/redeploys them</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicemix.bundles</groupId>
+      <artifactId>org.apache.servicemix.bundles.ant</artifactId>
+      <version>1.7.0-4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>org.osgi.core</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>org.osgi.foundation</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>javax.servlet</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+
+    <!-- testing -->
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>1.3.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${junit.version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+            <Export-Package>${pom.artifactId}</Export-Package>
+            <DynamicImport-Package>*</DynamicImport-Package>
+            <Bundle-Activator>org.apache.servicemix.runtime.filemonitor.FileMonitorActivator</Bundle-Activator>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: servicemix/branches/servicemix-4.0/runtime/filemonitor/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitor.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitor.java?rev=598365&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitor.java (added)
+++ servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitor.java Mon Nov 26 10:06:16 2007
@@ -0,0 +1,458 @@
+/**
+ *
+ * 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.servicemix.runtime.filemonitor;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Jar;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * Watches a deploy directory for files that are added, updated or removed then processing them.
+ * Currently we support OSGi bundles, OSGi configuration files and expanded directories of OSGi bundles.
+ *
+ * @version $Revision: 1.1 $
+ */
+public class FileMonitor {
+    public final static String DEPLOY_DIR = "org.apache.servicemix.filemonitor.monitorDir";
+    public final static String GENERATED_JAR_DIR = "org.apache.servicemix.filemonitor.generatedJarDir";
+    public final static String SCAN_INTERVAL = "org.apache.servicemix.filemonitor.scanInterval";
+    protected static final String ALIAS_KEY = "_alias_factory_pid";
+    private FileMonitorActivator activator;
+    private File deployDir = new File("./deploy");
+    private File generateDir = new File("./data/generated-bundles");
+    private Scanner scanner = new Scanner();
+    private Project project = new Project();
+    private long scanInterval = 500L;
+    private boolean loggedConfigAdminWarning;
+    private boolean changedBundles;
+    private boolean debug;
+
+    public FileMonitor() {
+    }
+
+    public FileMonitor(FileMonitorActivator activator, Dictionary properties) {
+        this.activator = activator;
+
+        File value = getFileValue(properties, DEPLOY_DIR);
+        if (value != null) {
+            deployDir = value;
+        }
+        value = getFileValue(properties, GENERATED_JAR_DIR);
+        if (value != null) {
+            generateDir = value;
+        }
+        Long i = getLongValue(properties, SCAN_INTERVAL);
+        if (i != null) {
+            scanInterval = i;
+        }
+    }
+
+    public void start() {
+        deployDir.mkdirs();
+        generateDir.mkdirs();
+
+        List dirs = new ArrayList();
+        dirs.add(deployDir);
+        scanner.setScanDirs(dirs);
+        scanner.setScanInterval(scanInterval);
+
+        scanner.addListener(new Scanner.BulkListener() {
+            public void filesChanged(List filenames) throws Exception {
+                onFilesChanged(filenames);
+            }
+        });
+
+        log("Starting to monitor the deploy directory: " + deployDir + " every " + scanInterval + " millis");
+        log("Will generate bundles from expanded source directories to: " + generateDir);
+
+        scanner.start();
+    }
+
+    public void stop() {
+        scanner.stop();
+    }
+
+    // Properties
+    //-------------------------------------------------------------------------
+
+    public BundleContext getContext() {
+        return activator.getContext();
+    }
+
+    public FileMonitorActivator getActivator() {
+        return activator;
+    }
+
+    public void setActivator(FileMonitorActivator activator) {
+        this.activator = activator;
+    }
+
+    public File getDeployDir() {
+        return deployDir;
+    }
+
+    public void setDeployDir(File deployDir) {
+        this.deployDir = deployDir;
+    }
+
+    public File getGenerateDir() {
+        return generateDir;
+    }
+
+    public void setGenerateDir(File generateDir) {
+        this.generateDir = generateDir;
+    }
+
+    public Project getProject() {
+        return project;
+    }
+
+    public void setProject(Project project) {
+        this.project = project;
+    }
+
+    public long getScanInterval() {
+        return scanInterval;
+    }
+
+    public void setScanInterval(long scanInterval) {
+        this.scanInterval = scanInterval;
+    }
+
+    public boolean isDebug() {
+        return debug;
+    }
+
+    public void setDebug(boolean debug) {
+        this.debug = debug;
+    }
+
+    // Implementation methods
+    //-------------------------------------------------------------------------
+
+    protected void onFilesChanged(List filenames) {
+        changedBundles = false;
+        Set<File> bundleJarsCreated = new HashSet<File>();
+
+        for (Object filename : filenames) {
+            String name = filename.toString();
+
+            // now lets iterate to find the parent directory
+            File file = new File(name);
+            try {
+                debug("File changed: " + filename + " with type: " + filename.getClass().getName());
+                File jardir = getExpandedBundleRootDirectory(file);
+                if (jardir != null) {
+                    if (file.exists() && !bundleJarsCreated.contains(jardir)) {
+                        bundleJarsCreated.add(jardir);
+                        createBundleJar(jardir);
+                        deployBundle(jardir);
+                    }
+                }
+                else if (name.endsWith(".jar")) {
+                    if (file.exists()) {
+                        deployBundle(file);
+                    }
+                    else {
+                        undeployBundle(file);
+                    }
+                }
+                else if (name.endsWith(".cfg")) {
+                    if (file.exists()) {
+                        updateConfiguration(file);
+                    }
+                    else {
+                        deleteConfiguration(file);
+                    }
+                }
+            }
+            catch (Exception e) {
+                warn("Failed to process: " + file + ". Reason: " + e);
+            }
+        }
+        if (changedBundles) {
+            refreshPackages();
+        }
+    }
+
+    protected void deployBundle(File file) throws FileNotFoundException, BundleException {
+        changedBundles = true;
+        log("Deloying: " + file.getAbsolutePath());
+
+        InputStream in = new FileInputStream(file);
+
+        try {
+            Bundle bundle = getBundleForJarFile(file);
+            if (bundle != null) {
+                bundle.update(in);
+                log("Updated: " + file.getAbsolutePath());
+            }
+            else {
+                bundle = getContext().installBundle(file.getAbsolutePath(), in);
+                if (!isBundleFragment(bundle)) {
+                    bundle.start();
+                }
+                log("Installed: " + file.getAbsolutePath());
+            }
+        }
+        finally {
+            closeQuietly(in);
+        }
+    }
+
+    protected void undeployBundle(File file) throws BundleException {
+        changedBundles = true;
+        Bundle bundle = getBundleForJarFile(file);
+        if (bundle == null) {
+            warn("Could not find Bundle for file: " + file.getAbsolutePath());
+        }
+        else {
+            bundle.stop();
+            bundle.uninstall();
+        }
+    }
+
+    protected Bundle getBundleForJarFile(File file) {
+        String absoluteFilePath = file.getAbsolutePath();
+        Bundle bundles[] = getContext().getBundles();
+        for (int i = 0; i < bundles.length; i++) {
+            Bundle bundle = bundles[i];
+            String location = bundle.getLocation();
+            File locationFile = new File(location);
+            String absoluteLocation = locationFile.getAbsolutePath();
+            if (absoluteFilePath.equals(absoluteLocation)) {
+                return bundle;
+            }
+        }
+        return null;
+    }
+
+    protected void updateConfiguration(File file) throws IOException, InvalidSyntaxException {
+        ConfigurationAdmin configurationAdmin = activator.getConfigurationAdmin();
+        if (configurationAdmin == null) {
+            if (!loggedConfigAdminWarning) {
+                warn("No ConfigurationAdmin so cannot deploy configurations");
+                loggedConfigAdminWarning = true;
+            }
+        }
+        else {
+            Properties properties = new Properties();
+            InputStream in = new FileInputStream(file);
+            try {
+                properties.load(in);
+                closeQuietly(in);
+                String[] pid = parsePid(file);
+                Hashtable hashtable = new Hashtable();
+                hashtable.putAll(properties);
+                if (pid[1] != null) {
+                    hashtable.put(ALIAS_KEY, pid[1]);
+                }
+
+                Configuration config = getConfiguration(pid[0], pid[1]);
+                if (config.getBundleLocation() != null) {
+                    config.setBundleLocation(null);
+                }
+                config.update(hashtable);
+            }
+            finally {
+                closeQuietly(in);
+            }
+        }
+    }
+
+    protected void deleteConfiguration(File file) throws IOException, InvalidSyntaxException {
+        String[] pid = parsePid(file);
+        Configuration config = getConfiguration(pid[0], pid[1]);
+        config.delete();
+    }
+
+    protected Configuration getConfiguration(String pid, String factoryPid) throws IOException, InvalidSyntaxException {
+        ConfigurationAdmin configurationAdmin = activator.getConfigurationAdmin();
+        if (factoryPid != null) {
+            Configuration[] configs = configurationAdmin.listConfigurations("(|(" + ALIAS_KEY + "=" + pid + ")(.alias_factory_pid=" + factoryPid + "))");
+            if (configs == null || configs.length == 0) {
+                return configurationAdmin.createFactoryConfiguration(pid, null);
+            }
+            else {
+                return configs[0];
+            }
+        }
+        else {
+            return configurationAdmin.getConfiguration(pid, null);
+        }
+    }
+
+    protected String[] parsePid(File file) {
+        String path = file.getName();
+        String pid = path.substring(0, path.length() - 4);
+        int n = pid.indexOf('-');
+        if (n > 0) {
+            String factoryPid = pid.substring(n + 1);
+            pid = pid.substring(0, n);
+            return new String[]{pid, factoryPid};
+        }
+        else {
+            return new String[]{pid, null};
+        }
+    }
+
+    protected PackageAdmin getPackageAdmin() {
+        ServiceTracker packageAdminTracker = activator.getPackageAdminTracker();
+        if (packageAdminTracker != null) {
+            try {
+                return (PackageAdmin) packageAdminTracker.waitForService(5000L);
+            }
+            catch (InterruptedException e) {
+                // ignore
+            }
+        }
+        return null;
+    }
+
+    protected boolean isBundleFragment(Bundle bundle) {
+        PackageAdmin packageAdmin = getPackageAdmin();
+        if (packageAdmin != null) {
+            return packageAdmin.getBundleType(bundle) == PackageAdmin.BUNDLE_TYPE_FRAGMENT;
+        }
+        return false;
+    }
+
+    protected void refreshPackages() {
+        PackageAdmin packageAdmin = getPackageAdmin();
+        if (packageAdmin != null) {
+            packageAdmin.refreshPackages(null);
+        }
+    }
+
+    protected void createBundleJar(File dir) throws BundleException {
+        Jar jar = new Jar();
+        jar.setProject(project);
+        File destFile = new File(generateDir, dir.getName() + ".jar");
+        if (destFile.exists()) {
+            undeployBundle(destFile);
+            destFile.delete();
+        }
+        log("Creating jar:  " + destFile + " from dir: " + dir);
+        jar.setDestFile(destFile);
+        jar.setManifest(new File(new File(dir, "META-INF"), "MANIFEST.MF"));
+        jar.setBasedir(dir);
+
+        jar.init();
+        jar.perform();
+    }
+
+    /**
+     * Returns the root directory of the expanded OSGi bundle if the file is part of an expanded OSGi bundle
+     * or null if it is not
+     */
+    protected File getExpandedBundleRootDirectory(File file) throws IOException {
+        File parent = file.getParentFile();
+        String rootPath = deployDir.getCanonicalPath();
+        if (file.isDirectory()) {
+            if (file.getCanonicalPath().equals(rootPath)) {
+                return null;
+            }
+            if (containsManifest(file)) {
+                return file;
+            }
+        }
+        String parentPath = parent.getCanonicalPath();
+        if (parent != null && !parentPath.equals(rootPath) && parentPath.startsWith(rootPath)) {
+            return getExpandedBundleRootDirectory(parent);
+        }
+        return null;
+    }
+
+    /**
+     * Returns true if the given directory contains a valid manifest file
+     */
+    protected boolean containsManifest(File dir) {
+        File metaInfDir = new File(dir, "META-INF");
+        if (metaInfDir.exists() && metaInfDir.isDirectory()) {
+            File manifest = new File(metaInfDir, "MANIFEST.MF");
+            return manifest.exists() && !manifest.isDirectory();
+        }
+        return false;
+    }
+
+    protected File getFileValue(Dictionary properties, String key) {
+        Object value = properties.get(key);
+        if (value instanceof File) {
+            return (File) value;
+        }
+        else if (value != null) {
+            return new File(value.toString());
+        }
+        return null;
+    }
+
+    protected Long getLongValue(Dictionary properties, String key) {
+        Object value = properties.get(key);
+        if (value instanceof Long) {
+            return (Long) value;
+        }
+        else if (value != null) {
+            return Long.parseLong(value.toString());
+        }
+        return null;
+    }
+
+    protected void closeQuietly(Closeable in) {
+        try {
+            in.close();
+        }
+        catch (IOException e) {
+            warn("Failed to close stream. " + e);
+        }
+    }
+
+    protected void debug(String message) {
+        if (debug) {
+            System.out.println("DEBUG: " + message);
+        }
+    }
+
+    protected void log(String message) {
+        System.out.println("INFO: " + message);
+    }
+
+    protected void warn(String message) {
+        System.out.println("WARN: " + message);
+    }
+}

Propchange: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitorActivator.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitorActivator.java?rev=598365&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitorActivator.java (added)
+++ servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitorActivator.java Mon Nov 26 10:06:16 2007
@@ -0,0 +1,132 @@
+/**
+ *
+ * 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.servicemix.runtime.filemonitor;
+
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedServiceFactory;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class FileMonitorActivator implements BundleActivator, ManagedServiceFactory {
+    private BundleContext context;
+    private ServiceTracker packageAdminTracker;
+    private ServiceTracker configurationAdminTracker;
+    private Map<String, FileMonitor> fileMonitors = new HashMap<String, FileMonitor>();
+
+    // BundleActivator interface
+    //-------------------------------------------------------------------------
+    public void start(BundleContext context) throws Exception {
+        this.context = context;
+
+        Hashtable properties = new Hashtable();
+        properties.put(Constants.SERVICE_PID, getName());
+        context.registerService(ManagedServiceFactory.class.getName(), this, properties);
+
+        packageAdminTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null);
+        packageAdminTracker.open();
+
+        configurationAdminTracker = new ServiceTracker(context, ConfigurationAdmin.class.getName(), null);
+        configurationAdminTracker.open();
+
+        Hashtable initialProperties = new Hashtable();
+        setPropertiesFromContext(initialProperties,
+                FileMonitor.DEPLOY_DIR,
+                FileMonitor.GENERATED_JAR_DIR,
+                FileMonitor.SCAN_INTERVAL
+        );
+        updated("initialPid", initialProperties);
+    }
+
+    public void stop(BundleContext context) throws Exception {
+        Collection<FileMonitor> fileMonitors = this.fileMonitors.values();
+        for (FileMonitor monitor : fileMonitors) {
+            try {
+                monitor.stop();
+            }
+            catch (Exception e) {
+                // Ignore
+            }
+        }
+        this.fileMonitors.clear();
+
+        configurationAdminTracker.close();
+        packageAdminTracker.close();
+    }
+
+    // ManagedServiceFactory interface
+    //-------------------------------------------------------------------------
+    public String getName() {
+        return "org.apache.servicemix.runtime.filemonitor.FileMonitor";
+    }
+
+    public void updated(String pid, Dictionary properties) throws ConfigurationException {
+        deleted(pid);
+        FileMonitor monitor = new FileMonitor(this, properties);
+        fileMonitors.put(pid, monitor);
+        monitor.start();
+    }
+
+    public void deleted(String pid) {
+        FileMonitor monitor = fileMonitors.remove(pid);
+        if (monitor != null) {
+            monitor.stop();
+        }
+    }
+
+    // Properties
+    //-------------------------------------------------------------------------
+    public BundleContext getContext() {
+        return context;
+    }
+
+    public ServiceTracker getConfigurationAdminTracker() {
+        return configurationAdminTracker;
+    }
+
+    public ServiceTracker getPackageAdminTracker() {
+        return packageAdminTracker;
+    }
+
+    public ConfigurationAdmin getConfigurationAdmin() {
+        return (ConfigurationAdmin) getConfigurationAdminTracker().getService();
+    }
+
+    // Implementation methods
+    //-------------------------------------------------------------------------
+    protected void setPropertiesFromContext(Hashtable properties, String... keys) {
+        for (String key : keys) {
+            Object value = context.getProperty(key);
+            if (value != null) {
+                properties.put(key, value);
+            }
+        }
+    }
+}

Propchange: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitorActivator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/Scanner.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/Scanner.java?rev=598365&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/Scanner.java (added)
+++ servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/Scanner.java Mon Nov 26 10:06:16 2007
@@ -0,0 +1,456 @@
+//========================================================================
+//$Id: Scanner.java 2180 2007-10-31 04:01:26Z janb $
+//Copyright 2006 Mort Bay Consulting Pty. Ltd.
+//------------------------------------------------------------------------
+//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.apache.servicemix.runtime.filemonitor;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * Scanner
+ * <p/>
+ * Utility for scanning a directory for added, removed and changed
+ * files and reporting these events via registered Listeners.
+ * <p/>
+ * From the <a href="http://jetty.codehaus.org/">Jetty Util project</a>
+ *
+ * @version $Revision: 1.1 $
+ */
+public class Scanner {
+    private long _scanInterval;
+    private List _listeners = Collections.synchronizedList(new ArrayList());
+    private Map _prevScan = Collections.EMPTY_MAP;
+    private FilenameFilter _filter;
+    private List _scanDirs;
+    private volatile boolean _running = false;
+    private boolean _reportExisting = true;
+    private Timer _timer;
+    private TimerTask _task;
+
+    /**
+     * Listener
+     * <p/>
+     * Marker for notifications re file changes.
+     */
+    public interface Listener {
+    }
+
+    public interface DiscreteListener extends Listener {
+        public void fileChanged(String filename) throws Exception;
+
+        public void fileAdded(String filename) throws Exception;
+
+        public void fileRemoved(String filename) throws Exception;
+    }
+
+    public interface BulkListener extends Listener {
+        public void filesChanged(List filenames) throws Exception;
+    }
+
+    /**
+     *
+     */
+    public Scanner() {
+    }
+
+    /**
+     * Get the scan interval
+     *
+     * @return interval between scans in millis
+     */
+    public long getScanInterval() {
+        return _scanInterval;
+    }
+
+    /**
+     * Set the scan interval
+     *
+     * @param scanInterval pause between scans in millis
+     */
+    public synchronized void setScanInterval(long scanInterval) {
+        this._scanInterval = scanInterval;
+
+        if (_running) {
+            stop();
+
+            _timer = newTimer();
+            _task = newTimerTask();
+
+            schedule(_timer, _task);
+            _running = true;
+        }
+    }
+
+    /**
+     * Set the location of the directory to scan.
+     *
+     * @param dir
+     * @deprecated use setScanDirs(List dirs) instead
+     */
+    public void setScanDir(File dir) {
+        _scanDirs = new ArrayList();
+        _scanDirs.add(dir);
+    }
+
+    /**
+     * Get the location of the directory to scan
+     *
+     * @return
+     * @deprecated use getScanDirs() instead
+     */
+    public File getScanDir() {
+        return (_scanDirs == null ? null : (File) _scanDirs.get(0));
+    }
+
+    public void setScanDirs(List dirs) {
+        _scanDirs = dirs;
+    }
+
+    public List getScanDirs() {
+        return _scanDirs;
+    }
+
+    /**
+     * Apply a filter to files found in the scan directory.
+     * Only files matching the filter will be reported as added/changed/removed.
+     *
+     * @param filter
+     */
+    public void setFilenameFilter(FilenameFilter filter) {
+        this._filter = filter;
+    }
+
+    /**
+     * Get any filter applied to files in the scan dir.
+     *
+     * @return
+     */
+    public FilenameFilter getFilenameFilter() {
+        return _filter;
+    }
+
+    /**
+     * Whether or not an initial scan will report all files as being
+     * added.
+     *
+     * @param reportExisting if true, all files found on initial scan will be
+     *                       reported as being added, otherwise not
+     */
+    public void setReportExistingFilesOnStartup(boolean reportExisting) {
+        this._reportExisting = reportExisting;
+    }
+
+    /**
+     * Add an added/removed/changed listener
+     *
+     * @param listener
+     */
+    public synchronized void addListener(Listener listener) {
+        if (listener == null) {
+            return;
+        }
+
+        _listeners.add(listener);
+    }
+
+    /**
+     * Remove a registered listener
+     *
+     * @param listener the Listener to be removed
+     */
+    public synchronized void removeListener(Listener listener) {
+        if (listener == null) {
+            return;
+        }
+        _listeners.remove(listener);
+    }
+
+    /**
+     * Start the scanning action.
+     */
+    public synchronized void start() {
+        if (_running) {
+            return;
+        }
+
+        _running = true;
+
+        if (_reportExisting) {
+            // if files exist at startup, report them
+            scan();
+        }
+        else {
+            //just register the list of existing files and only report changes
+            _prevScan = scanFiles();
+        }
+
+        _timer = newTimer();
+        _task = newTimerTask();
+
+        schedule(_timer, _task);
+    }
+
+    public TimerTask newTimerTask() {
+        return new TimerTask() {
+            public void run() {
+                scan();
+            }
+        };
+    }
+
+    public Timer newTimer() {
+        return new Timer(true);
+    }
+
+    public void schedule(Timer timer, TimerTask task) {
+        if (timer == null) {
+            throw new IllegalArgumentException("Timer is null");
+        }
+        if (task == null) {
+            throw new IllegalArgumentException("TimerTask is null");
+        }
+
+        if (getScanInterval() > 0) {
+            timer.scheduleAtFixedRate(task, getScanInterval(), getScanInterval());
+        }
+    }
+
+    /**
+     * Stop the scanning.
+     */
+    public synchronized void stop() {
+        if (_running) {
+            _running = false;
+            _timer.cancel();
+            _task.cancel();
+            _task = null;
+            _timer = null;
+        }
+    }
+
+    /**
+     * Perform a pass of the scanner and report changes
+     */
+    public void scan() {
+        Map currentScan = scanFiles();
+        reportDifferences(currentScan, _prevScan);
+        _prevScan = currentScan;
+    }
+
+    /**
+     * Recursively scan all files in the designated directories.
+     *
+     * @return Map of name of file to last modified time
+     */
+    public Map scanFiles() {
+        if (_scanDirs == null) {
+            return Collections.EMPTY_MAP;
+        }
+
+        HashMap scanInfo = new HashMap();
+        Iterator itor = _scanDirs.iterator();
+        while (itor.hasNext()) {
+            File dir = (File) itor.next();
+
+            if ((dir != null) && (dir.exists())) {
+                scanFile(dir, scanInfo);
+            }
+        }
+
+        return scanInfo;
+    }
+
+    /**
+     * Report the adds/changes/removes to the registered listeners
+     *
+     * @param currentScan the info from the most recent pass
+     * @param oldScan     info from the previous pass
+     */
+    public void reportDifferences(Map currentScan, Map oldScan) {
+        List bulkChanges = new ArrayList();
+
+        Set oldScanKeys = new HashSet(oldScan.keySet());
+        Iterator itor = currentScan.entrySet().iterator();
+        while (itor.hasNext()) {
+            Map.Entry entry = (Map.Entry) itor.next();
+            if (!oldScanKeys.contains(entry.getKey())) {
+                debug("File added: " + entry.getKey());
+                reportAddition((String) entry.getKey());
+                bulkChanges.add(entry.getKey());
+            }
+            else if (!oldScan.get(entry.getKey()).equals(entry.getValue())) {
+                debug("File changed: " + entry.getKey());
+                reportChange((String) entry.getKey());
+                oldScanKeys.remove(entry.getKey());
+                bulkChanges.add(entry.getKey());
+            }
+            else {
+                oldScanKeys.remove(entry.getKey());
+            }
+        }
+
+        if (!oldScanKeys.isEmpty()) {
+
+            Iterator keyItor = oldScanKeys.iterator();
+            while (keyItor.hasNext()) {
+                String filename = (String) keyItor.next();
+                debug("File removed: " + filename);
+                reportRemoval(filename);
+                bulkChanges.add(filename);
+            }
+        }
+
+        if (!bulkChanges.isEmpty()) {
+            reportBulkChanges(bulkChanges);
+        }
+    }
+
+    /**
+     * Get last modified time on a single file or recurse if
+     * the file is a directory.
+     *
+     * @param f           file or directory
+     * @param scanInfoMap map of filenames to last modified times
+     */
+    private void scanFile(File f, Map scanInfoMap) {
+        try {
+            if (!f.exists()) {
+                return;
+            }
+
+            if (f.isFile()) {
+                if ((_filter == null) || ((_filter != null) && _filter.accept(f.getParentFile(), f.getName()))) {
+                    String name = f.getCanonicalPath();
+                    long lastModified = f.lastModified();
+                    scanInfoMap.put(name, new Long(lastModified));
+                }
+            }
+            else if (f.isDirectory()) {
+                File[] files = f.listFiles();
+                for (int i = 0; i < files.length; i++) {
+                    scanFile(files[i], scanInfoMap);
+                }
+            }
+        }
+        catch (IOException e) {
+            warn("Error scanning watched files", e);
+        }
+    }
+
+    /**
+     * Report a file addition to the registered FileAddedListeners
+     *
+     * @param filename
+     */
+    private void reportAddition(String filename) {
+        Iterator itor = _listeners.iterator();
+        while (itor.hasNext()) {
+            try {
+                Object l = itor.next();
+                if (l instanceof DiscreteListener) {
+                    ((DiscreteListener) l).fileAdded(filename);
+                }
+            }
+            catch (Exception e) {
+                warn(e);
+            }
+            catch (Error e) {
+                warn(e);
+            }
+        }
+    }
+
+    /**
+     * Report a file removal to the FileRemovedListeners
+     *
+     * @param filename
+     */
+    private void reportRemoval(String filename) {
+        Iterator itor = _listeners.iterator();
+        while (itor.hasNext()) {
+            try {
+                Object l = itor.next();
+                if (l instanceof DiscreteListener) {
+                    ((DiscreteListener) l).fileRemoved(filename);
+                }
+            }
+            catch (Exception e) {
+                warn(e);
+            }
+            catch (Error e) {
+                warn(e);
+            }
+        }
+    }
+
+    /**
+     * Report a file change to the FileChangedListeners
+     *
+     * @param filename
+     */
+    private void reportChange(String filename) {
+        Iterator itor = _listeners.iterator();
+        while (itor.hasNext()) {
+            try {
+                Object l = itor.next();
+                if (l instanceof DiscreteListener) {
+                    ((DiscreteListener) l).fileChanged(filename);
+                }
+            }
+            catch (Exception e) {
+                warn(e);
+            }
+            catch (Error e) {
+                warn(e);
+            }
+        }
+    }
+
+    private void reportBulkChanges(List filenames) {
+        Iterator itor = _listeners.iterator();
+        while (itor.hasNext()) {
+            try {
+                Object l = itor.next();
+                if (l instanceof BulkListener) {
+                    ((BulkListener) l).filesChanged(filenames);
+                }
+            }
+            catch (Exception e) {
+                warn(e);
+            }
+            catch (Error e) {
+                warn(e);
+            }
+        }
+    }
+
+    protected void debug(String message) {
+        // TODO replace with clogging or OSGi Log
+
+    }
+
+    protected void warn(Throwable t) {
+        // TODO replace with clogging or OSGi Log
+        System.out.println("WARN: " + t);
+        t.printStackTrace();
+    }
+
+    protected void warn(String message, Throwable t) {
+        // TODO replace with clogging or OSGi Log
+        System.out.println("WARN: " + message + " " + t);
+        t.printStackTrace();
+    }
+}

Propchange: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/Scanner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/LICENSE.txt
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/LICENSE.txt?rev=598365&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/LICENSE.txt (added)
+++ servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/LICENSE.txt Mon Nov 26 10:06:16 2007
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
+

Propchange: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/MANIFEST.MF?rev=598365&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/MANIFEST.MF (added)
+++ servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/MANIFEST.MF Mon Nov 26 10:06:16 2007
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Created-By: 1.5.0_07 (Apple Computer, Inc.)
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Import-Package: org.apache.camel.builder,org.apache.camel.example.spri
+ ng;version=1.3.0.SNAPSHOT,org.apache.camel.model,org.apache.camel.spr
+ ing
+Include-Resource: src/main/resources
+Bnd-LastModified: 1195835480265
+Export-Package: org.apache.camel.example.spring;uses:="org.apache.came
+ l.model,org.apache.camel.builder,org.apache.camel.spring";version=1.3
+ .0.SNAPSHOT
+Bundle-Version: 1.3.0.SNAPSHOT
+Bundle-Name: camel-example-spring
+Bundle-Description: An example showing how to work with Camel and Spri
+ ng
+Private-Package: META-INF.spring
+Bundle-DocURL: http://www.apache.org/
+Bundle-Vendor: Apache Software Foundation
+Bundle-ManifestVersion: 2
+Implementation-Title: Apache Camel
+Bundle-SymbolicName: org.apache.camel.camel-example-spring
+Tool: Bnd-0.0.160
+Implementation-Version: 1.3-SNAPSHOT
+

Propchange: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/NOTICE.txt
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/NOTICE.txt?rev=598365&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/NOTICE.txt (added)
+++ servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/NOTICE.txt Mon Nov 26 10:06:16 2007
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

Propchange: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/NOTICE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/spring/camel-context.xml
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/spring/camel-context.xml?rev=598365&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/spring/camel-context.xml (added)
+++ servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/spring/camel-context.xml Mon Nov 26 10:06:16 2007
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!--
+
+  The default Application Context used by the org.apache.camel.spring.Main if there
+  is no /META-INF/sprint.xml
+
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
+
+  <camelContext id="camel" useJmx="true" mbeanServer="mbeanServer"
+                xmlns="http://activemq.apache.org/camel/schema/spring">
+    <package>org.apache.camel.example.spring</package>
+  </camelContext>
+
+  <!-- lets configure the default ActiveMQ broker URL -->
+  <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
+    <property name="connectionFactory">
+      <bean class="org.apache.activemq.ActiveMQConnectionFactory">
+        <property name="brokerURL" value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
+      </bean>
+    </property>
+  </bean>
+
+  <!-- Use JMX -->
+  <bean id="agent" class="org.apache.camel.spring.SpringInstrumentationAgent">
+    <property name="MBeanServer" ref="mbeanServer"/>
+  </bean>
+
+  <!--
+    this bean needs to be eagerly pre-instantiated in order for the exporting to occur;
+    this means that it must not be marked as lazily initialized
+  -->
+  <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean">
+    <property name="defaultDomain" value="org.apache.camel.test"/>
+  </bean>
+  <bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
+    <property name="port" value="1099"/>
+  </bean>
+  <bean id="serverConnector"
+        class="org.springframework.jmx.support.ConnectorServerFactoryBean" depends-on="registry">
+    <property name="objectName" value="connector:name=rmi"/>
+    <property name="serviceUrl"
+              value="service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi"/>
+    <property name="threaded" value="true"/>
+    <property name="daemon" value="true"/>
+  </bean>
+
+</beans>

Propchange: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/META-INF/spring/camel-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/org/apache/camel/example/spring/MyRouteBuilder$SomeBean.class
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/org/apache/camel/example/spring/MyRouteBuilder%24SomeBean.class?rev=598365&view=auto
==============================================================================
Binary file - no diff available.

Propchange: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/org/apache/camel/example/spring/MyRouteBuilder$SomeBean.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/org/apache/camel/example/spring/MyRouteBuilder.class
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/org/apache/camel/example/spring/MyRouteBuilder.class?rev=598365&view=auto
==============================================================================
Binary file - no diff available.

Propchange: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/camel-example-spring/org/apache/camel/example/spring/MyRouteBuilder.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/foo/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/foo/META-INF/MANIFEST.MF?rev=598365&view=auto
==============================================================================
    (empty)

Propchange: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/foo/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/foo/foo.txt
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/foo/foo.txt?rev=598365&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/foo/foo.txt (added)
+++ servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/foo/foo.txt Mon Nov 26 10:06:16 2007
@@ -0,0 +1 @@
+Hey!
\ No newline at end of file

Propchange: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/data/foo/foo.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/java/org/apache/servicemix/runtime/filemonitor/BundlePackerTest.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/java/org/apache/servicemix/runtime/filemonitor/BundlePackerTest.java?rev=598365&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/java/org/apache/servicemix/runtime/filemonitor/BundlePackerTest.java (added)
+++ servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/java/org/apache/servicemix/runtime/filemonitor/BundlePackerTest.java Mon Nov 26 10:06:16 2007
@@ -0,0 +1,46 @@
+/**
+ *
+ * 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.servicemix.runtime.filemonitor;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+import org.apache.commons.io.FileUtils;
+import org.apache.servicemix.runtime.filemonitor.FileMonitor;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class BundlePackerTest extends TestCase {
+    public void testFiles() throws Exception {
+        File bundleDir = new File("target/deploy");
+        File unpackDir = new File("target/data");
+        FileUtils.deleteDirectory(unpackDir);
+
+        bundleDir.mkdirs();
+        unpackDir.mkdirs();
+
+        FileUtils.copyDirectory(new File("src/test/data"), unpackDir);
+
+/*
+        FileMonitor packer = new FileMonitor(bundleDir, unpackDir);
+        packer.scan();
+*/
+    }
+
+}

Propchange: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/test/java/org/apache/servicemix/runtime/filemonitor/BundlePackerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native