Author: ccustine
Date: Mon Feb  2 06:33:50 2009
New Revision: 739931

URL: http://svn.apache.org/viewvc?rev=739931&view=rev
Log:
SM-1782 Add JBoss Deployer to platforms module

Added:
    servicemix/smx3/branches/servicemix-3.2/platforms/jboss/
    servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/
    servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/pom.xml
    servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/
    servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/
    
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/java/
    
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/java/org/
    
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/java/org/servicemix/
    
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/java/org/servicemix/jboss/
    
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/java/org/servicemix/jboss/deployment/
    
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/java/org/servicemix/jboss/deployment/JBIDeployer.java
    
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/java/org/servicemix/jboss/deployment/JBIService.java
    servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/sar/
    
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/sar/META-INF/
    
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/sar/META-INF/jboss-service.xml
    servicemix/smx3/branches/servicemix-3.2/platforms/jboss/pom.xml
Modified:
    servicemix/smx3/branches/servicemix-3.2/platforms/pom.xml

Added: servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/pom.xml
URL: 
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/pom.xml?rev=739931&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/pom.xml 
(added)
+++ servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/pom.xml 
Mon Feb  2 06:33:50 2009
@@ -0,0 +1,221 @@
+<?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.jboss</groupId>
+        <artifactId>jboss</artifactId>
+        <version>3.2.4-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>deployer</artifactId>
+    <name>ServiceMix :: JBoss :: Deployer</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicemix</groupId>
+      <artifactId>servicemix-core</artifactId>
+      <version>${pom.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-ejb_2.1_spec</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-activation_1.0.2_spec</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-j2ee-jacc_1.0_spec</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-j2ee-management_1.0_spec</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-jms_1.1_spec</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-jta_1.0.1B_spec</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-jta_1.1_spec</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-qname_1.1_spec</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-servlet_2.4_spec</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>mx4j</groupId>
+          <artifactId>mx4j</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>mx4j</groupId>
+          <artifactId>mx4j-remote</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>xmlbeans</groupId>
+          <artifactId>xbean</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>xmlbeans</groupId>
+          <artifactId>xmlpublic</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>xml-apis</groupId>
+          <artifactId>xml-apis</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>xalan</groupId>
+          <artifactId>xalan</artifactId>
+        </exclusion>
+          <exclusion>
+              <groupId>javax.xml.stream</groupId>
+              <artifactId>stax-api</artifactId>
+          </exclusion>
+          <exclusion>
+              <groupId>stax</groupId>
+              <artifactId>stax-api</artifactId>
+          </exclusion>
+        <exclusion>
+          <groupId>commons-logging</groupId>
+          <artifactId>commons-logging</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>commons-logging</groupId>
+          <artifactId>commons-logging-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>xerces</groupId>
+          <artifactId>xercesImpl</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>jboss</groupId>
+      <artifactId>jboss-system</artifactId>
+      <version>${jboss-version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>jboss</groupId>
+      <artifactId>jboss-jmx</artifactId>
+      <version>${jboss-version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>jboss</groupId>
+      <artifactId>jboss-common</artifactId>
+      <version>${jboss-version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>wsdl4j</groupId>
+      <artifactId>wsdl4j</artifactId>
+      <version>${wsdl4j-version}</version>
+    </dependency>
+  </dependencies>
+  
+  <pluginRepositories>
+    <pluginRepository>
+      <id>codehaus.snapshots</id>
+      <url>http://snapshots.repository.codehaus.org/</url>
+    </pluginRepository>
+  </pluginRepositories>
+  <repositories>
+    <repository>
+      <id>codehaus.snapshots</id>
+      <url>http://snapshots.repository.codehaus.org/</url>
+    </repository>
+  </repositories>
+  
+  <build>
+    <defaultGoal>install</defaultGoal>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>xdoclet-maven-plugin</artifactId>
+        <version>1.0-alpha-2</version>
+        <dependencies>
+          <dependency>
+            <groupId>ant</groupId>
+            <artifactId>ant</artifactId>
+            <version>${ant-version}</version>
+          </dependency>
+        </dependencies>
+        <executions>
+          <execution>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>xdoclet</goal>
+            </goals>
+            <configuration>
+              <tasks>
+                <jmxdoclet 
destdir="${project.build.directory}/generated-sources/xdoclet">
+                  <fileset dir="${basedir}/src/main/java" includes="**/*.java" 
/>
+                  <mbeaninterface />
+                </jmxdoclet>
+              </tasks>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>jboss-packaging-maven-plugin</artifactId>
+        <version>2.0-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>sar</goal>
+            </goals>
+            <configuration>
+              
<deploymentDescriptorFile>src/sar/META-INF/jboss-service.xml</deploymentDescriptorFile>
+              <excludes>
+                <exclude>jboss:jboss-system</exclude>
+                <exclude>jboss:jboss-jmx</exclude>
+                <exclude>jboss:jboss-common</exclude>
+              </excludes>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: 
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/java/org/servicemix/jboss/deployment/JBIDeployer.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/java/org/servicemix/jboss/deployment/JBIDeployer.java?rev=739931&view=auto
==============================================================================
--- 
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/java/org/servicemix/jboss/deployment/JBIDeployer.java
 (added)
+++ 
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/java/org/servicemix/jboss/deployment/JBIDeployer.java
 Mon Feb  2 06:33:50 2009
@@ -0,0 +1,295 @@
+/*
+ * 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.servicemix.jboss.deployment;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.management.ObjectName;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.deployment.DeploymentInfo;
+import org.jboss.deployment.SubDeployer;
+import org.jboss.deployment.SubDeployerSupport;
+import org.jboss.mx.loading.LoaderRepositoryFactory;
+import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
+
+/**
+ * This is the deployer that handles picking up and deploying a JBI package out
+ * to the ServiceMix container.
+ * 
+ * @author <a href="mailto:[email protected]";>Philip Dodds</a>
+ * 
+ * @jmx.mbean name="jboss.system:service=ServiceMixDeployer"
+ *            extends="org.jboss.deployment.SubDeployerMBean"
+ */
+public class JBIDeployer extends SubDeployerSupport implements SubDeployer,
+               JBIDeployerMBean {
+
+       private ObjectName deploymentService = null;
+
+       private ObjectName jbiContainerMBean = null;
+
+       /**
+        * Returns true if this deployer can deploy the given DeploymentInfo, 
for
+        * the time being we look for the extension iar.
+        * 
+        * @return True if this deployer can deploy the given DeploymentInfo.
+        * 
+        * @jmx.managed-operation
+        */
+       public boolean accepts(DeploymentInfo di) {
+               // To be accepted the deployment's root name must end in jar or 
zip
+               String urlStr = di.url.getFile();
+               if (!urlStr.endsWith(".jar") && !urlStr.endsWith(".zip")
+                               && !urlStr.endsWith("-sm.xml")) {
+                       return false;
+               }
+
+               boolean accepts = false;
+               if (urlStr.endsWith(".jar") || urlStr.endsWith(".zip")) {
+                       // However the jar/zip must also contain an 
META-INF/jbi.xml
+                       try {
+                               URL dd = 
di.localCl.findResource("META-INF/jbi.xml");
+                               if (dd != null) {
+                                       log.debug("Found a META-INF/jbi.xml 
file, di: " + di);
+                                       accepts = true;
+                               }
+                       } catch (Exception ignore) {
+                       }
+               } else {
+                       // If is ends with -sm.xml then we just accept it
+                       accepts = true;
+               }
+
+               return accepts;
+       }
+
+       /**
+        * Describe <code>create</code> method here.
+        * 
+        * @param di
+        *            a <code>DeploymentInfo</code> value
+        * @exception DeploymentException
+        *                if an error occurs
+        * @jmx.managed-operation
+        */
+       public void create(DeploymentInfo di) throws DeploymentException {
+               try {
+                       String urlStr = di.url.getFile();
+
+                       if (jbiContainerMBean == null) {
+                               throw new DeploymentException(
+                                               "The ServiceMix JBI container 
is not defined in Deployer");
+                       }
+                       log
+                                       .info("ServiceMix deployer passing 
deployment to JBI container ["
+                                                       + 
di.url.toExternalForm() + "]");
+                       if (urlStr.endsWith(".jar") || urlStr.endsWith(".zip")) 
{
+                               getServer().invoke(jbiContainerMBean, 
"installArchive",
+                                               new Object[] { 
di.url.toExternalForm() },
+                                               new String[] { 
"java.lang.String" });
+                       } else {
+                               getServer().invoke(jbiContainerMBean, 
"installServiceMixXml",
+                                               new Object[] { 
di.url.toExternalForm() },
+                                               new String[] { 
"java.lang.String" });
+                       }
+
+               } catch (Exception e) {
+                       throw new DeploymentException(
+                                       "ServiceMix deployer unable to deploy: 
" + di, e);
+               }
+       }
+
+       public void destroy() {
+               log.info("Destroying ServiceMix deployer");
+               super.destroy();
+       }
+
+       /**
+        * The destroy method invokes destroy on the mbeans associated with the
+        * deployment in reverse order relative to create.
+        * 
+        * @param di
+        *            a <code>DeploymentInfo</code> value
+        * @jmx.managed-operation
+        */
+       public void destroy(DeploymentInfo di) {
+               try {
+                       String urlStr = di.url.getFile();
+
+                       if (jbiContainerMBean == null) {
+                               throw new DeploymentException(
+                                               "The ServiceMix JBI container 
is not defined in Deployer");
+                       }
+                       log
+                                       .info("ServiceMix deployer passing 
deployment to JBI container ["
+                                                       + 
di.url.toExternalForm() + "]");
+                       if (urlStr.endsWith(".jar") || urlStr.endsWith(".zip")) 
{
+                               getServer().invoke(jbiContainerMBean, 
"uninstallArchive",
+                                               new Object[] { 
di.url.toExternalForm() },
+                                               new String[] { 
"java.lang.String" });
+                       } else {
+                               getServer().invoke(jbiContainerMBean, 
"uninstallServiceMixXml",
+                                               new Object[] { 
di.url.toExternalForm() },
+                                               new String[] { 
"java.lang.String" });
+                       }
+               } catch (Exception e) {
+                       log.error("Unable to destroy deployment [" + 
di.getCanonicalName()
+                                       + "]");
+               }
+       }
+
+       /**
+        * Gets the JBI deployment service object name
+        * 
+        * @return The JBI deployment service object name
+        */
+       public ObjectName getDeploymentService() {
+               return deploymentService;
+       }
+
+       /**
+        * Gets the ObjectName of the JBI Container's MBean
+        * 
+        * @return The ObjectName of the JBI Container MBean
+        * 
+        * @jmx.managed-attribute
+        */
+       public ObjectName getJBIContainer() {
+               return jbiContainerMBean;
+       }
+
+       /**
+        * The destroy method invokes destroy on the mbeans associated with the
+        * deployment in reverse order relative to create.
+        * 
+        * @param serviceName
+        *            a service object name
+        * @return The associated service DeploymentInfo if found, null 
otherwise
+        * @jmx.managed-operation
+        */
+       public DeploymentInfo getService(ObjectName serviceName) {
+               return null;
+       }
+
+       /**
+        * Describe <code>init</code> method here.
+        * 
+        * @param di
+        *            a <code>DeploymentInfo</code> value
+        * @exception DeploymentException
+        *                if an error occurs
+        * @jmx.managed-operation
+        */
+       public void init(DeploymentInfo di) throws DeploymentException {
+               try {
+                 log.info("Init ServiceMix JBI Component: " + di.url);
+      log.info("Init Watcher");
+      initWatcher(di);
+      log.info("Init LoaderRepository");
+      initLoaderRepository(di);
+               } catch (Exception e) {
+                 log.error(e.getMessage());
+                       throw new DeploymentException("Error in accessing 
application metadata: ", e);
+               }
+
+               // invoke super-class initialization
+               super.init(di);
+       }
+
+  private void initWatcher(DeploymentInfo di) throws MalformedURLException {
+    // resolve the watch
+    if (di.url.getProtocol().equals("file")) {
+      File file = new File(di.url.getFile());
+      // If not directory we watch the package
+      if (!file.isDirectory()) { 
+        di.watch = di.url; 
+      }
+      // If directory we watch the xml files
+      else { 
+        di.watch = new URL(di.url, "META-INF/jbi.xml"); 
+      }
+    }
+    else { 
+      // We watch the top only, no directory support 
+      di.watch = di.url; 
+    }
+  }
+
+       /**
+        * Sets the JBI deployment service object name
+        * 
+        * @param deploymentService
+        */
+       public void setDeploymentService(ObjectName deploymentService) {
+               this.deploymentService = deploymentService;
+       }
+
+       /**
+        * Sets the ObjectName of the JBI Container's MBean
+        * 
+        * @param jbiContainerMBean
+        *            The ObjectName of the JBI Container's MBean
+        * 
+        * @jmx.managed-attribute
+        */
+       public void setJBIContainer(ObjectName jbiContainerMBean) {
+               this.jbiContainerMBean = jbiContainerMBean;
+       }
+
+       /**
+        * The <code>start</code> method starts all the mbeans in this
+        * DeploymentInfo..
+        * 
+        * @param di
+        *            a <code>DeploymentInfo</code> value
+        * @exception DeploymentException
+        *                if an error occurs
+        * @jmx.managed-operation
+        */
+       public void start(DeploymentInfo di) throws DeploymentException {
+
+       }
+
+       /**
+        * The stop method invokes stop on the mbeans associatedw ith the 
deployment
+        * in reverse order relative to create.
+        * 
+        * @param di
+        *            the <code>DeploymentInfo</code> value to stop.
+        * @jmx.managed-operation
+        */
+       public void stop(DeploymentInfo di) {
+
+       }
+       
+ /**
+  * Add the jbi scoped repository
+  *
+  * @param di
+  * the deployment info passed to deploy
+  * @throws Exception
+  */
+  protected void initLoaderRepository(DeploymentInfo di) throws Exception { 
+    LoaderRepositoryConfig lrConfig = new 
LoaderRepositoryFactory.LoaderRepositoryConfig(); 
+    lrConfig.repositoryName = new 
ObjectName("org.servicemix:loader-repository=JBIContainer"); 
+    di.setRepositoryInfo(lrConfig); 
+  }
+
+}

Added: 
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/java/org/servicemix/jboss/deployment/JBIService.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/java/org/servicemix/jboss/deployment/JBIService.java?rev=739931&view=auto
==============================================================================
--- 
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/java/org/servicemix/jboss/deployment/JBIService.java
 (added)
+++ 
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/main/java/org/servicemix/jboss/deployment/JBIService.java
 Mon Feb  2 06:33:50 2009
@@ -0,0 +1,256 @@
+/*
+ * 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.servicemix.jboss.deployment;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jbi.JBIException;
+import javax.jbi.management.DeploymentException;
+import javax.naming.InitialContext;
+
+import org.jboss.system.ServiceMBeanSupport;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.framework.AutoDeploymentService.ArchiveEntry;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+
+/**
+ * This is the deployer that handles picking up and deploying a JBI package out
+ * to the ServiceMix container.
+ *
+ * @author <a href="mailto:[email protected]";>Philip Dodds</a>
+ *
+ * @jmx.mbean name="jboss.system:service=ServiceMixJBIContainer"
+ *            extends="org.jboss.system.ServiceMBean"
+ *
+ */
+public class JBIService extends ServiceMBeanSupport implements JBIServiceMBean 
{
+    
+    private JBIContainer jbiContainer = new JBIContainer();
+    
+    private String transactionManager = "java:/TransactionManager";
+    
+    private Map containerMap = new HashMap();
+    
+    private Map archiveMap = new HashMap();
+    
+        /*
+         * (non-Javadoc)
+         *
+         * @see org.jboss.system.ServiceMBeanSupport#createService()
+         */
+    public void createService() throws Exception {
+        super.create();
+    }
+    
+    /**
+     * Helper method that performs recursive deletes on a directory
+     *
+     * @param dir
+     *            The directory to delete
+     * @return True, if successful
+     */
+    private boolean deleteDir(File dir) {
+        if (dir.isDirectory()) {
+            String[] children = dir.list();
+            for (int i = 0; i < children.length; i++) {
+                boolean success = deleteDir(new File(dir, children[i]));
+                if (!success) {
+                    return false;
+                }
+            }
+        }
+        
+        // The directory is now empty so delete it
+        return dir.delete();
+        
+    }
+    
+        /*
+         * (non-Javadoc)
+         *
+         * @see org.jboss.system.ServiceMBeanSupport#destroyService()
+         */
+    public void destroyService() {
+        log.info("Destroying ServiceMixJBIContainer");
+        super.destroy();
+    }
+    
+    /**
+     * Gets the location of the transaction manager to use
+     *
+     * @return The transaction manager
+     *
+     * @jmx.managed-attribute
+     */
+    public String getTransactionManager() {
+        return transactionManager;
+    }
+    
+    /**
+     * Request the JBI Container install the given archive
+     *
+     * @param archive
+     *            The name of the archive to install
+     *
+     * @jmx.managed-operation
+     */
+    public void installArchive(String archive) {
+        try {
+            ArchiveEntry entry = 
jbiContainer.getAutoDeploymentService().updateExternalArchive(archive, true);
+            archiveMap.put(archive, entry);
+        } catch (DeploymentException e) {
+            throw new RuntimeException(
+                    "ServiceMix JBIContainer unable to install archive ["
+                    + archive + "]", e);
+        }
+    }
+    
+    /**
+     * Request the JBI Container uninstall the given archive
+     *
+     * @param archive
+     *            The name of the archive to install
+     *
+     * @jmx.managed-operation
+     */
+    public void uninstallArchive(String archive) {
+        try {
+            ArchiveEntry entry = (ArchiveEntry) archiveMap.get(archive);
+            if (entry == null) {
+                throw new DeploymentException("No service assembly " + archive 
+ " registered!");
+            }
+            jbiContainer.getAutoDeploymentService().removeArchive(entry);
+        } catch (DeploymentException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+    
+    /**
+     * Request the JBI Container install the given ServiceMix XML
+     *
+     * @param archive
+     *            The name of the archive to install
+     *
+     * @jmx.managed-operation
+     */
+    public void installServiceMixXml(String archive) {
+        // Ok, we are going to use the spring infrastructure
+        // to create a container
+        log
+                .info("Creating ServiceMix JBI installer from XML [" + archive
+                + "]");
+        containerMap.put(archive, new ClassPathXmlApplicationContext(archive));
+    }
+    
+    /**
+     * Request the JBI Container uninstall the given ServiceMix XML
+     *
+     * @param archive
+     *            The name of the archive to install
+     *
+     * @jmx.managed-operation
+     */
+    public void uninstallServiceMixXml(String archive) {
+        // Ok, we are going to use the spring infrastructure
+        // to create a container
+        log.info("Destroying ServiceMix JBI installer from XML [" + archive
+                + "]");
+        ClassPathXmlApplicationContext context = 
(ClassPathXmlApplicationContext) containerMap
+                .get(archive);
+        if (context != null)
+            context.destroy();
+        else
+            log.warn("Unable to find deployed JBI container for XML ["
+                    + archive + "]");
+    }
+    
+    /**
+     * Sets the location of the transaction manager to use
+     *
+     * @param transactionManager
+     *
+     * @jmx.managed-attribute
+     */
+    public void setTransactionManager(String transactionManager) {
+        this.transactionManager = transactionManager;
+    }
+    
+        /*
+         * (non-Javadoc)
+         *
+         * @see org.jboss.system.ServiceMBeanSupport#startService()
+         */
+    public void startService() throws Exception {
+        
+        jbiContainer = new JBIContainer();
+        jbiContainer.setCreateMBeanServer(false);
+        jbiContainer.setMonitorInstallationDirectory(false);
+        jbiContainer.setMBeanServer(getServer());
+        jbiContainer.setCreateJmxConnector(false);
+        jbiContainer.setUseShutdownHook(false);
+        
+        // TODO Keeping the service mix configuration directory in place is a
+        // problem?
+        File rootDir = new File(System.getProperty("jboss.server.data.dir")
+        + "/ServiceMix");
+        log.debug("Checking whether ServiceMix root directory exists ["
+                + rootDir.getAbsolutePath() + "] exists[" + rootDir.exists()
+                + "]");
+        
+        if (rootDir.exists() && !deleteDir(rootDir)) {
+            throw new Exception(
+                    "Unable to delete the ServiceMix root directory at 
start-up ["
+                    + rootDir.getAbsolutePath()
+                    + "], check permissions.");
+        }
+        if (!rootDir.mkdir()) {
+            throw new Exception(
+                    "Unable to create the ServiceMix root directory at 
start-up ["
+                    + rootDir.getAbsolutePath()
+                    + "], check permissions.");
+        }
+        jbiContainer.setRootDir(rootDir.getAbsolutePath());
+        
+        // Lets get the transaction manager from JNDI
+        InitialContext initCtxt = new InitialContext();
+        Object transactionManager = initCtxt.lookup(this.transactionManager);
+        jbiContainer.setTransactionManager(transactionManager);
+        
+        jbiContainer.init();
+        jbiContainer.start();
+        super.start();
+    }
+    
+        /*
+         * (non-Javadoc)
+         *
+         * @see org.jboss.system.ServiceMBeanSupport#stopService()
+         */
+    public void stopService() {
+        try {
+            jbiContainer.stop();
+        } catch (JBIException e) {
+            log.error("Unable to stop ServiceMixJBIContainer ["
+                    + e.getMessage() + "]");
+        }
+        super.stop();
+    }
+    
+}

Added: 
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/sar/META-INF/jboss-service.xml
URL: 
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/sar/META-INF/jboss-service.xml?rev=739931&view=auto
==============================================================================
--- 
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/sar/META-INF/jboss-service.xml
 (added)
+++ 
servicemix/smx3/branches/servicemix-3.2/platforms/jboss/deployer/src/sar/META-INF/jboss-service.xml
 Mon Feb  2 06:33:50 2009
@@ -0,0 +1,42 @@
+<?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 J2EE application client deployer service -->
+<server>
+  <loader-repository>
+    org.servicemix:loader-repository=JBIContainer
+    <loader-repository-config>
+      java2ParentDelegation=false
+    </loader-repository-config>
+  </loader-repository>
+
+       <mbean code="org.servicemix.jboss.deployment.JBIDeployer"
+                    name="org.servicemix:service=Deployer">
+               <depends optional-attribute-name="JBIContainer">
+                       org.servicemix:service=JBIService
+               </depends>
+       </mbean>
+
+       <mbean code="org.servicemix.jboss.deployment.JBIService"
+                    name="org.servicemix:service=JBIService">
+               <depends>jboss:service=TransactionManager</depends>
+               <attribute 
name="TransactionManager">java:/TransactionManager</attribute>
+       </mbean>
+</server>
+

Added: servicemix/smx3/branches/servicemix-3.2/platforms/jboss/pom.xml
URL: 
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/platforms/jboss/pom.xml?rev=739931&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/platforms/jboss/pom.xml (added)
+++ servicemix/smx3/branches/servicemix-3.2/platforms/jboss/pom.xml Mon Feb  2 
06:33:50 2009
@@ -0,0 +1,44 @@
+<?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>platforms</artifactId>
+        <version>3.2.4-SNAPSHOT</version>
+    </parent>
+
+    <groupId>org.apache.servicemix.jboss</groupId>
+    <artifactId>jboss</artifactId>
+    <name>Servicemix :: JBoss</name>
+    <packaging>pom</packaging>
+  
+    <properties>
+           <jboss-version>4.0.2</jboss-version>
+           <ant-version>1.6.5</ant-version>
+    </properties>
+    
+    <modules>
+        <module>deployer</module>
+    </modules>
+
+</project>

Modified: servicemix/smx3/branches/servicemix-3.2/platforms/pom.xml
URL: 
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/platforms/pom.xml?rev=739931&r1=739930&r2=739931&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/platforms/pom.xml (original)
+++ servicemix/smx3/branches/servicemix-3.2/platforms/pom.xml Mon Feb  2 
06:33:50 2009
@@ -35,6 +35,7 @@
 
   <modules>
     <module>geronimo</module>
+    <module>jboss</module>
   </modules>
 
     <build>


Reply via email to