Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[JBAS-8309] Initial OSGi integration

  • Loading branch information...
commit a4ef44d9b7ba6ea30f61012c82e0e75d185df55b 1 parent ca6735b
@tdiesler tdiesler authored n1hility committed
Showing with 6,239 additions and 56 deletions.
  1. +55 −13 build/build.xml
  2. +36 −1 build/pom.xml
  3. +28 −6 build/src/main/resources/domain/configuration/domain.xml
  4. +3 −0  build/src/main/resources/modules/org/jboss/as/domain/main/module.xml
  5. +47 −0 build/src/main/resources/modules/org/jboss/as/osgi/main/module.xml
  6. +1 −0  build/src/main/resources/modules/org/jboss/as/server/main/module.xml
  7. +33 −0 build/src/main/resources/modules/org/jboss/osgi/common/main/module.xml
  8. +37 −0 build/src/main/resources/modules/org/jboss/osgi/deployment/main/module.xml
  9. +47 −0 build/src/main/resources/modules/org/jboss/osgi/framework/main/module.xml
  10. +36 −0 build/src/main/resources/modules/org/jboss/osgi/resolver/main/module.xml
  11. +36 −0 build/src/main/resources/modules/org/jboss/osgi/spi/main/module.xml
  12. +35 −0 build/src/main/resources/modules/org/jboss/osgi/vfs/main/module.xml
  13. +34 −0 build/src/main/resources/modules/org/osgi/compendium/main/module.xml
  14. +33 −0 build/src/main/resources/modules/org/osgi/core/main/module.xml
  15. +27 −5 build/src/main/resources/standalone/configuration/standalone.xml
  16. +9 −4 domain/pom.xml
  17. +8 −6 domain/src/main/java/org/jboss/as/deployment/DeploymentService.java
  18. +17 −1 domain/src/main/java/org/jboss/as/deployment/chain/JarDeploymentChainSelector.java
  19. +8 −0 domain/src/main/java/org/jboss/as/deployment/module/ClassifyingModuleLoaderService.java
  20. +3 −7 domain/src/main/java/org/jboss/as/model/ServerDeploymentStartStopHandler.java
  21. +71 −0 domain/src/main/java/org/jboss/as/util/SystemPropertyActions.java
  22. +1 −1  ide-configs/eclipse/as7formatter.xml
  23. +49 −0 osgi/build.xml
  24. +151 −0 osgi/pom.xml
  25. +44 −0 osgi/src/main/java/org/jboss/as/osgi/deployment/BundleInfoAttachment.java
  26. +44 −0 osgi/src/main/java/org/jboss/as/osgi/deployment/DeploymentAttachment.java
  27. +100 −0 osgi/src/main/java/org/jboss/as/osgi/deployment/OSGiAttachmentsDeploymentProcessor.java
  28. +73 −0 osgi/src/main/java/org/jboss/as/osgi/deployment/OSGiDeploymentActivator.java
  29. +66 −0 osgi/src/main/java/org/jboss/as/osgi/deployment/OSGiDeploymentChainSelector.java
  30. +196 −0 osgi/src/main/java/org/jboss/as/osgi/deployment/OSGiDeploymentService.java
  31. +88 −0 osgi/src/main/java/org/jboss/as/osgi/deployment/OSGiManifestDeploymentProcessor.java
  32. +44 −0 osgi/src/main/java/org/jboss/as/osgi/deployment/OSGiMetaDataAttachment.java
  33. +76 −0 osgi/src/main/java/org/jboss/as/osgi/deployment/OSGiXServicesDeploymentProcessor.java
  34. +44 −0 osgi/src/main/java/org/jboss/as/osgi/deployment/XModuleAttachment.java
  35. +75 −0 osgi/src/main/java/org/jboss/as/osgi/parser/Attribute.java
  36. +74 −0 osgi/src/main/java/org/jboss/as/osgi/parser/Element.java
  37. +81 −0 osgi/src/main/java/org/jboss/as/osgi/parser/Namespace.java
  38. +47 −0 osgi/src/main/java/org/jboss/as/osgi/parser/OSGiExtension.java
  39. +80 −0 osgi/src/main/java/org/jboss/as/osgi/parser/OSGiSubsystemAdd.java
  40. +120 −0 osgi/src/main/java/org/jboss/as/osgi/parser/OSGiSubsystemElement.java
  41. +204 −0 osgi/src/main/java/org/jboss/as/osgi/parser/OSGiSubsystemElementParser.java
  42. +86 −0 osgi/src/main/java/org/jboss/as/osgi/parser/OSGiSubsystemState.java
  43. +74 −0 osgi/src/main/java/org/jboss/as/osgi/parser/OSGiSubsystemUpdate.java
  44. +168 −0 osgi/src/main/java/org/jboss/as/osgi/service/BundleManagerService.java
  45. +121 −0 osgi/src/main/java/org/jboss/as/osgi/service/Configuration.java
  46. +161 −0 osgi/src/main/java/org/jboss/as/osgi/service/FrameworkService.java
  47. +86 −0 osgi/src/main/java/org/jboss/as/osgi/service/PackageAdminService.java
  48. +23 −0 osgi/src/main/resources/META-INF/services/org.jboss.as.Extension
  49. +75 −0 osgi/src/main/resources/schema/jboss-osgi.xsd
  50. +140 −0 osgi/src/test/java/org/jboss/as/osgi/AbstractOSGiSubsystemTest.java
  51. +222 −0 osgi/src/test/java/org/jboss/as/osgi/BatchBuilderSupport.java
  52. +598 −0 osgi/src/test/java/org/jboss/as/osgi/OSGiSubsystemSupport.java
  53. +253 −0 osgi/src/test/java/org/jboss/as/osgi/deployment/OSGiDeploymentTestCase.java
  54. +27 −0 osgi/src/test/java/org/jboss/as/osgi/deployment/a/A.java
  55. +49 −0 osgi/src/test/java/org/jboss/as/osgi/deployment/b/ClientBundleActivator.java
  56. +28 −0 osgi/src/test/java/org/jboss/as/osgi/deployment/b/EchoInvoker.java
  57. +70 −0 osgi/src/test/java/org/jboss/as/osgi/deployment/b/EchoInvokerService.java
  58. +53 −0 osgi/src/test/java/org/jboss/as/osgi/deployment/b/EchoTargetService.java
  59. +47 −0 osgi/src/test/java/org/jboss/as/osgi/deployment/b/TargetBundleActivator.java
  60. +43 −0 osgi/src/test/java/org/jboss/as/osgi/deployment/b/TxLoaderActicator.java
  61. +28 −0 osgi/src/test/java/org/jboss/as/osgi/deployment/c/Echo.java
  62. +83 −0 osgi/src/test/java/org/jboss/as/osgi/parser/AbstractValidationTest.java
  63. +209 −0 osgi/src/test/java/org/jboss/as/osgi/parser/OSGiSubsystemParserTestCase.java
  64. +84 −0 osgi/src/test/java/org/jboss/as/osgi/parser/XMLValidationTestCase.java
  65. +52 −0 osgi/src/test/java/org/jboss/as/osgi/parser/XSDValidationTestCase.java
  66. +241 −0 osgi/src/test/java/org/jboss/as/osgi/xservice/BundleAccessesModuleServiceTestCase.java
  67. +138 −0 osgi/src/test/java/org/jboss/as/osgi/xservice/BundleDependsOnLocalModuleTestCase.java
  68. +264 −0 osgi/src/test/java/org/jboss/as/osgi/xservice/ModuleAccessesOSGiServiceTestCase.java
  69. +32 −0 osgi/src/test/resources/console-logging.properties
  70. +2 −0  osgi/src/test/resources/deployment/jbosgi-xservice.properties
  71. +35 −0 osgi/src/test/resources/logging.properties
  72. +29 −0 osgi/src/test/resources/modules/javax/transaction/api/main/module.xml
  73. +34 −0 osgi/src/test/resources/modules/org/jboss/common-core/main/module.xml
  74. +33 −0 osgi/src/test/resources/modules/org/jboss/logging/main/module.xml
  75. +37 −0 osgi/src/test/resources/modules/org/jboss/osgi/deployment/main/module.xml
  76. +36 −0 osgi/src/test/resources/modules/org/jboss/osgi/spi/main/module.xml
  77. +35 −0 osgi/src/test/resources/modules/org/jboss/osgi/vfs/main/module.xml
  78. +34 −0 osgi/src/test/resources/modules/org/jboss/vfs/main/module.xml
  79. +34 −0 osgi/src/test/resources/modules/org/osgi/compendium/main/module.xml
  80. +33 −0 osgi/src/test/resources/modules/org/osgi/core/main/module.xml
  81. +53 −0 osgi/src/test/resources/service/jboss-osgi-example.xml
  82. +128 −3 pom.xml
  83. +0 −5 server/src/main/java/org/jboss/as/server/ServerEnvironment.java
  84. +0 −4 server/src/main/java/org/jboss/as/server/StandardElementReaderRegistrarImpl.java
View
68 build/build.xml
@@ -158,7 +158,9 @@
<maven-resource group="org.jboss.spec.javax.xml.ws" artifact="jboss-jaxws-api_2.2_spec"/>
</module-def>
- <module-def name="org.apache.log4j">
+ <module-def name="org.apache.commons.logging"/>
+
+ <module-def name="org.apache.log4j">
<maven-resource group="log4j" artifact="log4j"/>
</module-def>
@@ -214,6 +216,10 @@
<maven-resource group="org.jboss.as" artifact="jboss-as-naming"/>
</module-def>
+ <module-def name="org.jboss.as.osgi">
+ <maven-resource group="org.jboss.as" artifact="jboss-as-osgi"/>
+ </module-def>
+
<module-def name="org.jboss.as.process-manager">
<maven-resource group="org.jboss.as" artifact="jboss-as-process-manager"/>
</module-def>
@@ -248,8 +254,8 @@
<maven-resource group="org.jboss.as" artifact="jboss-as-threads"/>
</module-def>
- <module-def name="org.jboss.jandex">
- <maven-resource group="org.jboss" artifact="jandex"/>
+ <module-def name="org.jboss.common-core">
+ <maven-resource group="org.jboss" artifact="jboss-common-core"/>
</module-def>
<module-def name="org.jboss.integration.jboss-jca-spi">
@@ -273,6 +279,10 @@
<maven-resource group="org.jboss.ironjacamar" artifact="ironjacamar-deployers-common"/>
<maven-resource group="org.jboss.ironjacamar" artifact="ironjacamar-validator"/>
</module-def>
+
+ <module-def name="org.jboss.jandex">
+ <maven-resource group="org.jboss" artifact="jandex"/>
+ </module-def>
<module-def name="org.jboss.jts">
<maven-resource group="org.jboss.jbossts" artifact="jbossjts"/>
@@ -312,6 +322,34 @@
<maven-resource group="org.jboss.netty" artifact="netty"/>
</module-def>
+ <module-def name="org.jboss.osgi.common">
+ <maven-resource group="org.jboss.osgi.common" artifact="jboss-osgi-common"/>
+ </module-def>
+
+ <module-def name="org.jboss.osgi.deployment">
+ <maven-resource group="org.jboss.osgi.deployment" artifact="jboss-osgi-deployment"/>
+ </module-def>
+
+ <module-def name="org.jboss.osgi.framework">
+ <maven-resource group="org.jboss.osgi.framework" artifact="jbosgi-framework-core"/>
+ </module-def>
+
+ <module-def name="org.jboss.osgi.spi">
+ <maven-resource group="org.jboss.osgi" artifact="jboss-osgi-spi"/>
+ </module-def>
+
+ <module-def name="org.jboss.osgi.resolver">
+ <maven-resource group="org.jboss.osgi.resolver" artifact="jbosgi-resolver-api"/>
+ <maven-resource group="org.jboss.osgi.resolver" artifact="jbosgi-resolver-spi"/>
+ <maven-resource group="org.jboss.osgi.resolver" artifact="jbosgi-resolver-felix"/>
+ <maven-resource group="org.jboss.osgi.resolver" artifact="jbosgi-resolver-metadata"/>
+ </module-def>
+
+ <module-def name="org.jboss.osgi.vfs">
+ <maven-resource group="org.jboss.osgi.vfs" artifact="jboss-osgi-vfs"/>
+ <maven-resource group="org.jboss.osgi.vfs" artifact="jboss-osgi-vfs30"/>
+ </module-def>
+
<module-def name="org.jboss.remoting3">
<maven-resource group="org.jboss.remoting3" artifact="jboss-remoting"/>
</module-def>
@@ -320,12 +358,12 @@
<maven-resource group="org.jboss.threads" artifact="jboss-threads"/>
</module-def>
- <module-def name="org.jboss.stdio">
- <maven-resource group="org.jboss.stdio" artifact="jboss-stdio"/>
+ <module-def name="org.jboss.staxmapper">
+ <maven-resource group="org.jboss" artifact="staxmapper"/>
</module-def>
- <module-def name="org.jboss.xnio">
- <maven-resource group="org.jboss.xnio" artifact="xnio-api"/>
+ <module-def name="org.jboss.stdio">
+ <maven-resource group="org.jboss.stdio" artifact="jboss-stdio"/>
</module-def>
<module-def name="org.jboss.xnio.nio">
@@ -336,19 +374,23 @@
<maven-resource group="org.jboss" artifact="jboss-vfs"/>
</module-def>
- <module-def name="org.jboss.common-core">
- <maven-resource group="org.jboss" artifact="jboss-common-core"/>
+ <module-def name="org.jboss.xnio">
+ <maven-resource group="org.jboss.xnio" artifact="xnio-api"/>
</module-def>
-
- <module-def name="org.jboss.staxmapper">
- <maven-resource group="org.jboss" artifact="staxmapper"/>
+
+ <module-def name="org.osgi.core">
+ <maven-resource group="org.osgi" artifact="org.osgi.core"/>
+ </module-def>
+
+ <module-def name="org.osgi.compendium">
+ <maven-resource group="org.osgi" artifact="org.osgi.compendium"/>
</module-def>
<module-def name="org.picketbox">
<maven-resource group="org.picketbox" artifact="jboss-security-spi"/>
<maven-resource group="org.picketbox" artifact="jbosssx"/>
<maven-resource group="org.picketbox" artifact="picketbox-bare"/>
- </module-def>
+ </module-def>
<module-def name="org.slf4j.jcl-over-slf4j">
<maven-resource group="org.slf4j" artifact="jcl-over-slf4j"/>
View
37 build/pom.xml
@@ -125,6 +125,11 @@
<dependency>
<groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
</dependency>
@@ -134,6 +139,11 @@
</dependency>
<dependency>
+ <groupId>org.jboss.arquillian.protocol</groupId>
+ <artifactId>arquillian-osgi-bundle</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-connector</artifactId>
</dependency>
@@ -185,6 +195,11 @@
<dependency>
<groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-osgi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.as</groupId>
<artifactId>jboss-as-remoting</artifactId>
</dependency>
@@ -330,9 +345,29 @@
<dependency>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
- </dependency>
+ </dependency>
<dependency>
+ <groupId>org.jboss.osgi.common</groupId>
+ <artifactId>jboss-osgi-common</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jbosgi-framework-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.osgi.resolver</groupId>
+ <artifactId>jbosgi-resolver-felix</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs30</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.remoting3</groupId>
<artifactId>jboss-remoting</artifactId>
</dependency>
View
34 build/src/main/resources/domain/configuration/domain.xml
@@ -36,15 +36,16 @@
urn:jboss:domain:resourceadapters:1.0 jboss-resource-adapters.xsd">
<extensions>
- <extension module="org.jboss.as.threads"/>
- <extension module="org.jboss.as.remoting"/>
- <extension module="org.jboss.as.transactions"/>
- <extension module="org.jboss.as.naming"/>
+ <extension module="org.jboss.as.connector"/>
<extension module="org.jboss.as.jmx"/>
- <extension module="org.jboss.as.sar"/>
<extension module="org.jboss.as.managed-beans"/>
<extension module="org.jboss.as.messaging"/>
- <extension module="org.jboss.as.connector"/>
+ <extension module="org.jboss.as.naming"/>
+ <extension module="org.jboss.as.osgi"/>
+ <extension module="org.jboss.as.remoting"/>
+ <extension module="org.jboss.as.sar"/>
+ <extension module="org.jboss.as.threads"/>
+ <extension module="org.jboss.as.transactions"/>
</extensions>
<profiles>
@@ -78,6 +79,27 @@
</subsystem>
<subsystem xmlns="urn:jboss:domain:datasources:1.0" />
<subsystem xmlns="urn:jboss:domain:resourceadapters:1.0" />
+ <subsystem xmlns="urn:jboss:domain:osgi:1.0">
+ <properties>
+ <property name="org.jboss.osgi.system.modules">
+ org.apache.log4j
+ </property>
+ <property name="org.osgi.framework.system.packages.extra">
+ org.apache.log4j;version=1.2,
+ org.jboss.logging;version=3.0,
+ org.jboss.osgi.deployment.deployer;version=1.0,
+ org.jboss.osgi.deployment.interceptor;version=1.0,
+ org.jboss.osgi.spi;version=1.0,
+ org.jboss.osgi.spi.capability;version=1.0,
+ org.jboss.osgi.spi.util;version=1.0,
+ org.jboss.osgi.testing;version=1.0
+ </property>
+ </properties>
+ <modules>
+ <module identifier="org.osgi.compendium"/>
+ <module identifier="org.jboss.osgi.common" start="true"/>
+ </modules>
+ </subsystem>
<subsystem xmlns="urn:jboss:domain:messaging:1.0">
<persistence-enabled>false</persistence-enabled>
<journal-type>NIO</journal-type>
View
3  build/src/main/resources/modules/org/jboss/as/domain/main/module.xml
@@ -40,6 +40,9 @@
<module name="org.jboss.marshalling"/>
<module name="org.jboss.modules"/>
<module name="org.jboss.msc"/>
+ <module name="org.jboss.osgi.spi"/>
+ <module name="org.jboss.osgi.vfs"/>
+ <module name="org.osgi.core"/>
<module name="system"/>
</dependencies>
</module>
View
47 build/src/main/resources/modules/org/jboss/as/osgi/main/module.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+<module xmlns="urn:jboss:module:1.0" name="org.jboss.as.osgi">
+
+ <resources>
+ <!-- Insert resources here -->
+ </resources>
+
+ <dependencies>
+ <module name="org.jboss.as.domain"/>
+ <module name="org.jboss.as.server"/>
+ <module name="org.jboss.logging"/>
+ <module name="org.jboss.msc"/>
+ <module name="org.jboss.vfs"/>
+ <module name="org.jboss.osgi.deployment"/>
+ <module name="org.jboss.osgi.framework"/>
+ <module name="org.jboss.osgi.resolver"/>
+ <module name="org.jboss.osgi.spi"/>
+ <module name="org.jboss.osgi.vfs"/>
+ <module name="org.jboss.staxmapper"/>
+ <module name="org.osgi.compendium"/>
+ <module name="org.osgi.core"/>
+ <module name="system"/>
+ </dependencies>
+</module>
View
1  build/src/main/resources/modules/org/jboss/as/server/main/module.xml
@@ -45,6 +45,7 @@
<module name="org.jboss.as.domain"/>
<module name="org.jboss.as.logging"/>
<module name="org.jboss.as.naming"/>
+ <module name="org.jboss.as.osgi"/>
<module name="org.jboss.as.process-manager"/>
<module name="org.jboss.as.protocol"/>
<module name="org.jboss.as.remoting"/>
View
33 build/src/main/resources/modules/org/jboss/osgi/common/main/module.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+<module xmlns="urn:jboss:module:1.0" name="org.jboss.osgi.common">
+
+ <resources>
+ <!-- Insert resources here -->
+ </resources>
+
+ <dependencies>
+ </dependencies>
+</module>
View
37 build/src/main/resources/modules/org/jboss/osgi/deployment/main/module.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+<module xmlns="urn:jboss:module:1.0" name="org.jboss.osgi.deployment">
+
+ <resources>
+ <!-- Insert resources here -->
+ </resources>
+
+ <dependencies>
+ <module name="org.jboss.logging"/>
+ <module name="org.jboss.osgi.spi"/>
+ <module name="org.jboss.osgi.vfs"/>
+ <module name="org.osgi.core"/>
+ </dependencies>
+</module>
View
47 build/src/main/resources/modules/org/jboss/osgi/framework/main/module.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+<module xmlns="urn:jboss:module:1.0" name="org.jboss.osgi.framework">
+
+ <resources>
+ <!-- Insert resources here -->
+ </resources>
+
+ <dependencies>
+ <module name="org.jboss.logging"/>
+ <module name="org.jboss.msc"/>
+ <module name="org.jboss.osgi.deployment"/>
+ <module name="org.jboss.osgi.spi"/>
+ <module name="org.jboss.osgi.resolver"/>
+ <module name="org.jboss.osgi.vfs"/>
+ <module name="org.jboss.vfs"/>
+ <module name="org.osgi.core"/>
+ <module name="org.osgi.compendium"/>
+ <module name="system" export="true">
+ <exports>
+ <include path="org/jboss/modules"/>
+ </exports>
+ </module>
+ </dependencies>
+</module>
View
36 build/src/main/resources/modules/org/jboss/osgi/resolver/main/module.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+<module xmlns="urn:jboss:module:1.0" name="org.jboss.osgi.resolver">
+
+ <resources>
+ <!-- Insert resources here -->
+ </resources>
+
+ <dependencies>
+ <module name="org.jboss.logging"/>
+ <module name="org.jboss.osgi.spi"/>
+ <module name="org.osgi.core"/>
+ </dependencies>
+</module>
View
36 build/src/main/resources/modules/org/jboss/osgi/spi/main/module.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+<module xmlns="urn:jboss:module:1.0" name="org.jboss.osgi.spi">
+
+ <resources>
+ <!-- Insert resources here -->
+ </resources>
+
+ <dependencies>
+ <module name="org.jboss.logging"/>
+ <module name="org.jboss.osgi.vfs"/>
+ <module name="org.osgi.core"/>
+ </dependencies>
+</module>
View
35 build/src/main/resources/modules/org/jboss/osgi/vfs/main/module.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+<module xmlns="urn:jboss:module:1.0" name="org.jboss.osgi.vfs">
+
+ <resources>
+ <!-- Insert resources here -->
+ </resources>
+
+ <dependencies>
+ <module name="org.jboss.logging"/>
+ <module name="org.jboss.vfs"/>
+ </dependencies>
+</module>
View
34 build/src/main/resources/modules/org/osgi/compendium/main/module.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+<module xmlns="urn:jboss:module:1.0" name="org.osgi.compendium">
+
+ <resources>
+ <!-- Insert resources here -->
+ </resources>
+
+ <dependencies>
+ <module name="org.osgi.core"/>
+ </dependencies>
+</module>
View
33 build/src/main/resources/modules/org/osgi/core/main/module.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+<module xmlns="urn:jboss:module:1.0" name="org.osgi.core">
+
+ <resources>
+ <!-- Insert resources here -->
+ </resources>
+
+ <dependencies>
+ </dependencies>
+</module>
View
32 build/src/main/resources/standalone/configuration/standalone.xml
@@ -38,15 +38,16 @@
<name>Standalone</name>
<extensions>
+ <extension module="org.jboss.as.connector"/>
<extension module="org.jboss.as.jmx"/>
- <extension module="org.jboss.as.sar"/>
- <extension module="org.jboss.as.threads"/>
+ <extension module="org.jboss.as.managed-beans"/>
+ <extension module="org.jboss.as.messaging"/>
<extension module="org.jboss.as.naming"/>
+ <extension module="org.jboss.as.osgi"/>
<extension module="org.jboss.as.remoting"/>
+ <extension module="org.jboss.as.sar"/>
+ <extension module="org.jboss.as.threads"/>
<extension module="org.jboss.as.transactions"/>
- <extension module="org.jboss.as.managed-beans"/>
- <extension module="org.jboss.as.messaging"/>
- <extension module="org.jboss.as.connector"/>
</extensions>
<profile name="something">
@@ -83,6 +84,27 @@
</subsystem>
<subsystem xmlns="urn:jboss:domain:datasources:1.0" />
<subsystem xmlns="urn:jboss:domain:resourceadapters:1.0" />
+ <subsystem xmlns="urn:jboss:domain:osgi:1.0">
+ <properties>
+ <property name="org.jboss.osgi.system.modules">
+ org.apache.log4j
+ </property>
+ <property name="org.osgi.framework.system.packages.extra">
+ org.apache.log4j;version=1.2,
+ org.jboss.logging;version=3.0,
+ org.jboss.osgi.deployment.deployer;version=1.0,
+ org.jboss.osgi.deployment.interceptor;version=1.0,
+ org.jboss.osgi.spi;version=1.0,
+ org.jboss.osgi.spi.capability;version=1.0,
+ org.jboss.osgi.spi.util;version=1.0,
+ org.jboss.osgi.testing;version=1.0
+ </property>
+ </properties>
+ <modules>
+ <module identifier="org.osgi.compendium"/>
+ <module identifier="org.jboss.osgi.common" start="true"/>
+ </modules>
+ </subsystem>
<subsystem xmlns="urn:jboss:domain:messaging:1.0">
<persistence-enabled>false</persistence-enabled>
<journal-type>NIO</journal-type>
View
13 domain/pom.xml
@@ -54,6 +54,11 @@
<dependencies>
<dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.spec.javax.annotation</groupId>
<artifactId>jboss-annotations-api_1.1_spec</artifactId>
</dependency>
@@ -104,16 +109,16 @@
</dependency>
<dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-spi</artifactId>
</dependency>
-
+
+ <!-- Test Dependencies -->
<dependency>
<groupId>org.jboss.marshalling</groupId>
<artifactId>jboss-marshalling-river</artifactId>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
View
14 domain/src/main/java/org/jboss/as/deployment/DeploymentService.java
@@ -24,7 +24,6 @@
import java.io.Closeable;
-import org.jboss.logging.Logger;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartContext;
@@ -33,14 +32,13 @@
import org.jboss.vfs.VFSUtils;
/**
- * Service that represents a deployment. Should be used as a dependency for all services registered for the deployment.
- * The life-cycle of this service should be used to control the life-cycle of the deployment.
+ * Service that represents a deployment. Should be used as a dependency for all services registered for the deployment. The
+ * life-cycle of this service should be used to control the life-cycle of the deployment.
*
* @author John E. Bailey
*/
public class DeploymentService implements Service<Void> {
public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append("deployment");
- private static Logger logger = Logger.getLogger("org.jboss.as.deployment");
private final Closeable deploymentMount;
@@ -51,8 +49,12 @@ public DeploymentService(Closeable deploymentMount) {
this.deploymentMount = deploymentMount;
}
+ public static ServiceName getServiceName(String deploymentName) {
+ return DeploymentService.SERVICE_NAME.append(deploymentName.replace('.', '_'));
+ }
+
/**
- * Start the deployment. This will re-mount the deployment root if service is restarted.
+ * Start the deployment. This will re-mount the deployment root if service is restarted.
*
* @param context The start context
* @throws StartException if any problems occur
@@ -61,7 +63,7 @@ public void start(StartContext context) throws StartException {
}
/**
- * Stop the deployment. This will close the virtual file mount.
+ * Stop the deployment. This will close the virtual file mount.
*
* @param context The stop context
*/
View
18 domain/src/main/java/org/jboss/as/deployment/chain/JarDeploymentChainSelector.java
@@ -22,16 +22,27 @@
package org.jboss.as.deployment.chain;
+import org.jboss.as.deployment.attachment.ManifestAttachment;
import org.jboss.as.deployment.attachment.VirtualFileAttachment;
import org.jboss.as.deployment.unit.DeploymentUnitContext;
+import java.io.IOException;
+import java.util.jar.Manifest;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
/**
* Deployment chain selector which determines whether the jar deployment chain should handle this deployment.
*
* @author John E. Bailey
+ * @author Thomas.Diesler@jboss.com
*/
public class JarDeploymentChainSelector implements DeploymentChainProvider.Selector {
+
+ private static final Logger log = Logger.getLogger("org.jboss.as.deployment");
+
private static final String ARCHIVE_EXTENSION = ".jar";
private static final String DESCRIPTOR_PATH = "META-INF";
@@ -43,6 +54,11 @@
*/
public boolean supports(final DeploymentUnitContext deploymentUnitContext) {
VirtualFile virtualFile = VirtualFileAttachment.getVirtualFileAttachment(deploymentUnitContext);
- return virtualFile.getName().toLowerCase().endsWith(ARCHIVE_EXTENSION) || virtualFile.getChild(DESCRIPTOR_PATH).exists();
+
+ if (! (virtualFile.getName().toLowerCase().endsWith(ARCHIVE_EXTENSION) || virtualFile.getChild(DESCRIPTOR_PATH).exists()))
+ return false;
+
+ // OSGi deployments are not handled by the jar deployer chain
+ return !BundleInfo.isValidateBundleManifest(ManifestAttachment.getManifestAttachment(deploymentUnitContext));
}
}
View
8 domain/src/main/java/org/jboss/as/deployment/module/ClassifyingModuleLoaderService.java
@@ -24,6 +24,7 @@
import java.util.HashMap;
import java.util.Map;
+
import org.jboss.modules.ClassifyingModuleLoader;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleLoader;
@@ -44,6 +45,13 @@
private final Map<String, ModuleLoader> delegates = new HashMap<String, ModuleLoader>();
/**
+ * Gets the module loader
+ */
+ public ModuleLoader getModuleLoader() {
+ return classifyingModuleLoader;
+ }
+
+ /**
* Creates the classifying module loader with the current set of delegates, and registers a module
* loader selector.
*
View
10 domain/src/main/java/org/jboss/as/model/ServerDeploymentStartStopHandler.java
@@ -80,7 +80,7 @@
final BatchBuilder batchBuilder, final ServiceContainer serviceContainer,
final UpdateResultHandler<? super ServerDeploymentActionResult, P> resultHandler, final P param) {
try {
- ServiceName deploymentServiceName = getDeploymentServiceName(deploymentName);
+ ServiceName deploymentServiceName = DeploymentService.getServiceName(deploymentName);
// Add a listener so we can get ahold of the DeploymentService
batchBuilder.addListener(new DeploymentServiceTracker<P>(resultHandler, param));
@@ -94,7 +94,7 @@
<P> void redeploy(final String deploymentName, final String runtimeName, final byte[] deploymentHash,
final ServiceContainer serviceContainer, final UpdateResultHandler<? super ServerDeploymentActionResult, P> resultHandler, final P param) {
try {
- ServiceName deploymentServiceName = getDeploymentServiceName(deploymentName);
+ ServiceName deploymentServiceName = DeploymentService.getServiceName(deploymentName);
@SuppressWarnings("unchecked")
final ServiceController<DeploymentService> controller = (ServiceController<DeploymentService>) serviceContainer.getService(deploymentServiceName);
if(controller != null && controller.getMode() != ServiceController.Mode.REMOVE) {
@@ -126,7 +126,7 @@
<P> void undeploy(final String deploymentName, final ServiceContainer serviceContainer,
final UpdateResultHandler<? super ServerDeploymentActionResult, P> resultHandler, final P param) {
try {
- ServiceName deploymentServiceName = getDeploymentServiceName(deploymentName);
+ ServiceName deploymentServiceName = DeploymentService.getServiceName(deploymentName);
@SuppressWarnings("unchecked")
final ServiceController<DeploymentService> controller = (ServiceController<DeploymentService>) serviceContainer.getService(deploymentServiceName);
if(controller != null) {
@@ -207,10 +207,6 @@ private ServerDeploymentRepository getDeploymentRepository(ServiceContainer serv
return serviceController.getValue();
}
- private static ServiceName getDeploymentServiceName(String deploymentName) {
- return DeploymentService.SERVICE_NAME.append(deploymentName.replace('.', '_'));
- }
-
// private static String getFullyQualifiedDeploymentPath(String name) {
// final String fileName = name;
// String path = System.getProperty("jboss.server.deploy.dir");
View
71 domain/src/main/java/org/jboss/as/util/SystemPropertyActions.java
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.as.util;
+
+// $Id$
+
+import java.security.PrivilegedAction;
+import java.security.AccessController;
+
+/**
+ * Priviledged actions for the package
+ *
+ * @author Scott.Stark@jboss.org
+ * @author Thomas.Diesler@jboss.com
+ */
+@SuppressWarnings("rawtypes")
+public class SystemPropertyActions {
+
+ interface SysProps {
+ SysProps NON_PRIVILEDGED = new SysProps() {
+ public String getProperty(final String name, final String defaultValue) {
+ return System.getProperty(name, defaultValue);
+ }
+ };
+ SysProps PRIVILEDGED = new SysProps() {
+ @SuppressWarnings("unchecked")
+ public String getProperty(final String name, final String defaultValue) {
+ PrivilegedAction action = new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty(name, defaultValue);
+ }
+ };
+ return (String) AccessController.doPrivileged(action);
+ }
+ };
+
+ String getProperty(String name, String defaultValue);
+ }
+
+ public static String getProperty(String name) {
+ return getProperty(name, null);
+ }
+
+ public static String getProperty(String name, String defaultValue) {
+ String prop;
+ if (System.getSecurityManager() == null)
+ prop = SysProps.NON_PRIVILEDGED.getProperty(name, defaultValue);
+ else
+ prop = SysProps.PRIVILEDGED.getProperty(name, defaultValue);
+ return prop;
+ }
+}
View
2  ide-configs/eclipse/as7formatter.xml
@@ -195,7 +195,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="128"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
View
49 osgi/build.xml
@@ -0,0 +1,49 @@
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+<project name="module-repository" basedir="." default="modules">
+
+ <property name="module.repo.src.dir" value="src/test/resources/modules"/>
+ <property name="module.repo.output.dir" value="target/test-modules"/>
+
+ <import file="../build/lib.xml"/>
+
+ <target name="modules">
+
+ <!-- Test modules. Keep alphabetical -->
+
+ <module-def name="javax.transaction.api">
+ <maven-resource group="org.jboss.spec.javax.transaction" artifact="jboss-transaction-api_1.1_spec"/>
+ </module-def>
+
+ </target>
+
+ <target name="clean-target">
+ <delete dir="target"/>
+ </target>
+
+ <target name="clean" depends="clean-target">
+ <delete file="maven-ant-tasks.jar"/>
+ </target>
+
+ <target name="all" depends="clean-target, modules"/>
+</project>
View
151 osgi/pom.xml
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+<!--
+ Set these VM properties in your IDE debugger
+
+ -Dmodule.path=${workspace_loc:jboss-as-osgi/target/test-modules}
+ -Djava.util.logging.config.file=${workspace_loc:jboss-as-osgi/src/test/resources}/console-logging.properties
+-->
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-parent</artifactId>
+ <version>7.0.0.Beta1-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-osgi</artifactId>
+ <version>7.0.0.Beta1-SNAPSHOT</version>
+
+ <name>JBoss Application Server: OSGi Subsystem</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-server</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.deployment</groupId>
+ <artifactId>jboss-osgi-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jbosgi-framework-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.resolver</groupId>
+ <artifactId>jbosgi-resolver-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+
+ <!-- Provided Dependencies -->
+ <dependency>
+ <groupId>org.jboss.osgi.resolver</groupId>
+ <artifactId>jbosgi-resolver-felix</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs30</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Test Dependencies -->
+ <dependency>
+ <groupId>org.jboss.spec.javax.transaction</groupId>
+ <artifactId>jboss-transaction-api_1.1_spec</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- Build -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.4</version>
+ <inherited>false</inherited>
+ <executions>
+ <execution>
+ <id>build-dist</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>test-compile</phase>
+ <configuration>
+ <tasks>
+ <ant antfile="build.xml" inheritRefs="true">
+ <target name="modules"/>
+ </ant>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>${surefire.system.args}</argLine>
+ <systemProperties>
+ <property>
+ <name>java.util.logging.config.file</name>
+ <value>src/test/resources/logging.properties</value>
+ </property>
+ <property>
+ <name>module.path</name>
+ <value>${project.build.directory}/test-modules</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
View
44 osgi/src/main/java/org/jboss/as/osgi/deployment/BundleInfoAttachment.java
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.osgi.deployment;
+
+import org.jboss.as.deployment.AttachmentKey;
+import org.jboss.as.deployment.unit.DeploymentUnitContext;
+import org.jboss.osgi.spi.util.BundleInfo;
+
+/**
+ * Utility to help attach and retrieve a BundleInfo from a deployment context.
+ *
+ * @author Thomas.Diesler@jboss.com
+ */
+public class BundleInfoAttachment {
+ public static final AttachmentKey<BundleInfo> KEY = AttachmentKey.create(BundleInfo.class);
+
+ public static void attachBundleInfo(final DeploymentUnitContext context, final BundleInfo info) {
+ context.putAttachment(KEY, info);
+ }
+
+ public static BundleInfo getBundleInfoAttachment(final DeploymentUnitContext context) {
+ return context.getAttachment(KEY);
+ }
+}
View
44 osgi/src/main/java/org/jboss/as/osgi/deployment/DeploymentAttachment.java
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.osgi.deployment;
+
+import org.jboss.as.deployment.AttachmentKey;
+import org.jboss.as.deployment.unit.DeploymentUnitContext;
+import org.jboss.osgi.deployment.deployer.Deployment;
+
+/**
+ * Utility to help attach and retrieve a Deployment from a deployment context.
+ *
+ * @author Thomas.Diesler@jboss.com
+ */
+public class DeploymentAttachment {
+ public static final AttachmentKey<Deployment> KEY = AttachmentKey.create(Deployment.class);
+
+ public static void attachDeployment(final DeploymentUnitContext context, final Deployment dep) {
+ context.putAttachment(KEY, dep);
+ }
+
+ public static Deployment getDeploymentAttachment(final DeploymentUnitContext context) {
+ return context.getAttachment(KEY);
+ }
+}
View
100 osgi/src/main/java/org/jboss/as/osgi/deployment/OSGiAttachmentsDeploymentProcessor.java
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.osgi.deployment;
+
+import org.jboss.as.deployment.DeploymentPhases;
+import org.jboss.as.deployment.attachment.VirtualFileAttachment;
+import org.jboss.as.deployment.module.MountHandle;
+import org.jboss.as.deployment.unit.DeploymentUnitContext;
+import org.jboss.as.deployment.unit.DeploymentUnitProcessingException;
+import org.jboss.as.deployment.unit.DeploymentUnitProcessor;
+import org.jboss.osgi.deployment.deployer.Deployment;
+import org.jboss.osgi.deployment.deployer.DeploymentFactory;
+import org.jboss.osgi.metadata.OSGiMetaData;
+import org.jboss.osgi.resolver.XModule;
+import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.osgi.vfs.AbstractVFS;
+import org.jboss.vfs.VirtualFile;
+import org.osgi.framework.Version;
+
+/**
+ * Processes deployments that have OSGi metadata attached.
+ *
+ * If so, it creates an {@link OSGiDeploymentService}.
+ *
+ * @author Thomas.Diesler@jboss.com
+ * @since 20-Sep-2010
+ */
+public class OSGiAttachmentsDeploymentProcessor implements DeploymentUnitProcessor {
+
+ public static final long PRIORITY = DeploymentPhases.INSTALL_SERVICES.plus(100L);
+
+ @Override
+ public void processDeployment(DeploymentUnitContext context) throws DeploymentUnitProcessingException {
+
+ // Check if we already have an OSGi deployment
+ Deployment deployment = DeploymentAttachment.getDeploymentAttachment(context);
+
+ // Check for attached BundleInfo
+ BundleInfo info = BundleInfoAttachment.getBundleInfoAttachment(context);
+ if (deployment == null && info != null) {
+ deployment = DeploymentFactory.createDeployment(info);
+ deployment.addAttachment(BundleInfo.class, info);
+ DeploymentAttachment.attachDeployment(context, deployment);
+ }
+
+ // Check for attached OSGiMetaData
+ OSGiMetaData metadata = OSGiMetaDataAttachment.getOSGiMetaDataAttachment(context);
+ if (deployment == null && metadata != null) {
+ VirtualFile virtualFile = VirtualFileAttachment.getVirtualFileAttachment(context);
+ String location = virtualFile.getPathName();
+ String symbolicName = metadata.getBundleSymbolicName();
+ Version version = metadata.getBundleVersion();
+ deployment = DeploymentFactory.createDeployment(AbstractVFS.adapt(virtualFile), location, symbolicName, version);
+ deployment.addAttachment(OSGiMetaData.class, metadata);
+ DeploymentAttachment.attachDeployment(context, deployment);
+ }
+
+ // Check for attached XModule
+ XModule resModule = XModuleAttachment.getXModuleAttachment(context);
+ if (deployment == null && resModule != null) {
+ VirtualFile virtualFile = VirtualFileAttachment.getVirtualFileAttachment(context);
+ String location = virtualFile.getPathName();
+ String symbolicName = resModule.getName();
+ Version version = resModule.getVersion();
+ deployment = DeploymentFactory.createDeployment(AbstractVFS.adapt(virtualFile), location, symbolicName, version);
+ deployment.addAttachment(XModule.class, resModule);
+ DeploymentAttachment.attachDeployment(context, deployment);
+ }
+
+ // Create the {@link OSGiDeploymentService}
+ if (deployment != null) {
+
+ // Prevent garbage collection of the MountHandle which will close the file
+ MountHandle mount = context.getAttachment(MountHandle.ATTACHMENT_KEY);
+ deployment.addAttachment(MountHandle.class, mount);
+
+ OSGiDeploymentService.addService(context);
+ }
+ }
+}
View
73 osgi/src/main/java/org/jboss/as/osgi/deployment/OSGiDeploymentActivator.java
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.osgi.deployment;
+
+import org.jboss.as.deployment.chain.DeploymentChain;
+import org.jboss.as.deployment.chain.DeploymentChainImpl;
+import org.jboss.as.deployment.chain.DeploymentChainProcessorInjector;
+import org.jboss.as.deployment.chain.DeploymentChainProvider;
+import org.jboss.as.deployment.chain.DeploymentChainProviderInjector;
+import org.jboss.as.deployment.chain.DeploymentChainProviderService;
+import org.jboss.as.deployment.chain.DeploymentChainService;
+import org.jboss.as.deployment.chain.JarDeploymentActivator;
+import org.jboss.as.deployment.unit.DeploymentUnitProcessor;
+import org.jboss.as.deployment.unit.DeploymentUnitProcessorService;
+import org.jboss.msc.service.BatchBuilder;
+import org.jboss.msc.service.BatchServiceBuilder;
+import org.jboss.msc.service.ServiceName;
+import org.jboss.msc.value.Value;
+import org.jboss.msc.value.Values;
+
+/**
+ * Service activator which installs the various service required for OSGi deployments.
+ *
+ * @author Thomas.Diesler@jboss.com
+ * @since 07-Oct-2010
+ */
+public class OSGiDeploymentActivator {
+ public static final long OSGI_DEPLOYMENT_CHAIN_PRIORITY = JarDeploymentActivator.JAR_DEPLOYMENT_CHAIN_PRIORITY + 1000L;
+ public static final ServiceName OSGI_DEPLOYMENT_CHAIN_SERVICE_NAME = DeploymentChain.SERVICE_NAME.append("osgi");
+
+ /**
+ * Activate the services required for service deployments.
+ */
+ public void activate(final BatchBuilder batchBuilder) {
+ batchBuilder.addServiceValueIfNotExist(DeploymentChainProviderService.SERVICE_NAME, new DeploymentChainProviderService());
+
+ final Value<DeploymentChain> deploymentChainValue = Values.immediateValue((DeploymentChain)new DeploymentChainImpl(OSGI_DEPLOYMENT_CHAIN_SERVICE_NAME.toString())) ;
+ final DeploymentChainService deploymentChainService = new DeploymentChainService(deploymentChainValue);
+ batchBuilder.addService(OSGI_DEPLOYMENT_CHAIN_SERVICE_NAME, deploymentChainService)
+ .addDependency(DeploymentChainProviderService.SERVICE_NAME, DeploymentChainProvider.class, new DeploymentChainProviderInjector<DeploymentChain>(deploymentChainValue, new OSGiDeploymentChainSelector(), OSGI_DEPLOYMENT_CHAIN_PRIORITY));
+
+ addDeploymentProcessor(batchBuilder, new OSGiManifestDeploymentProcessor(), OSGiManifestDeploymentProcessor.PRIORITY);
+ addDeploymentProcessor(batchBuilder, new OSGiAttachmentsDeploymentProcessor(), OSGiAttachmentsDeploymentProcessor.PRIORITY);
+ }
+
+ private <T extends DeploymentUnitProcessor> BatchServiceBuilder<T> addDeploymentProcessor(final BatchBuilder batchBuilder, final T deploymentUnitProcessor, final long priority) {
+ final DeploymentUnitProcessorService<T> deploymentUnitProcessorService = new DeploymentUnitProcessorService<T>(deploymentUnitProcessor);
+ ServiceName serviceName = OSGI_DEPLOYMENT_CHAIN_SERVICE_NAME.append(deploymentUnitProcessor.getClass().getName());
+ BatchServiceBuilder<T> serviceBuilder = batchBuilder.addService(serviceName, deploymentUnitProcessorService);
+ DeploymentChainProcessorInjector<T> injector = new DeploymentChainProcessorInjector<T>(deploymentUnitProcessorService, priority);
+ return serviceBuilder.addDependency(OSGI_DEPLOYMENT_CHAIN_SERVICE_NAME, DeploymentChain.class, injector);
+ }
+}
View
66 osgi/src/main/java/org/jboss/as/osgi/deployment/OSGiDeploymentChainSelector.java
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.osgi.deployment;
+
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.jboss.as.deployment.attachment.ManifestAttachment;
+import org.jboss.as.deployment.attachment.VirtualFileAttachment;
+import org.jboss.as.deployment.chain.DeploymentChainProvider;
+import org.jboss.as.deployment.unit.DeploymentUnitContext;
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * Deployment chain selector which determines whether the OSGi deployment chain should handle this deployment.
+ *
+ * @author Thomas.Diesler@jboss.com
+ */
+public class OSGiDeploymentChainSelector implements DeploymentChainProvider.Selector {
+
+ private static final Logger log = Logger.getLogger("org.jboss.as.deployment");
+
+ private static final String ARCHIVE_EXTENSION = ".jar";
+
+ /**
+ * Determine where this deployment is supported by OSGi deployer chain.
+ *
+ * @param virtualFile The deployment file
+ * @return true if this is s service deployment, and false if not
+ */
+ public boolean supports(final DeploymentUnitContext context) {
+
+ VirtualFile virtualFile = VirtualFileAttachment.getVirtualFileAttachment(context);
+ boolean jarMatch = virtualFile.getName().toLowerCase().endsWith(ARCHIVE_EXTENSION);
+ boolean pathMatch = virtualFile.getChild(JarFile.MANIFEST_NAME).exists();
+ if (!jarMatch || !pathMatch)
+ return false;
+
+ Manifest manifest = ManifestAttachment.getManifestAttachment(context);
+
+ // Check whether this is a valid OSGi deployment
+ return BundleInfo.isValidateBundleManifest(manifest);
+ }
+}
View
196 osgi/src/main/java/org/jboss/as/osgi/deployment/OSGiDeploymentService.java
@@ -0,0 +1,196 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.osgi.deployment;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+import org.jboss.as.deployment.DeploymentService;
+import org.jboss.as.deployment.unit.DeploymentUnitContext;
+import org.jboss.as.osgi.service.FrameworkService;
+import org.jboss.as.osgi.service.PackageAdminService;
+import org.jboss.logging.Logger;
+import org.jboss.msc.service.AbstractServiceListener;
+import org.jboss.msc.service.BatchBuilder;
+import org.jboss.msc.service.BatchServiceBuilder;
+import org.jboss.msc.service.Service;
+import org.jboss.msc.service.ServiceContainer;
+import org.jboss.msc.service.ServiceController;
+import org.jboss.msc.service.ServiceController.Mode;
+import org.jboss.msc.service.ServiceName;
+import org.jboss.msc.service.StartContext;
+import org.jboss.msc.service.StartException;
+import org.jboss.msc.service.StopContext;
+import org.jboss.msc.value.InjectedValue;
+import org.jboss.osgi.deployment.deployer.DeployerService;
+import org.jboss.osgi.deployment.deployer.Deployment;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * Service responsible for creating and managing the life-cycle of an OSGi deployment.
+ *
+ * @author Thomas.Diesler@jboss.com
+ * @since 20-Sep-2010
+ */
+public class OSGiDeploymentService implements Service<Deployment> {
+
+ private static final Logger log = Logger.getLogger("org.jboss.as.osgi");
+ private static final OSGiDeploymentListener listener = new OSGiDeploymentListener();
+
+ public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append("osgi.deployment");
+ public static boolean enableListener = true;
+
+ private final Deployment deployment;
+ private InjectedValue<BundleContext> injectedContext = new InjectedValue<BundleContext>();
+
+ private OSGiDeploymentService(Deployment deployment) {
+ this.deployment = deployment;
+ }
+
+ public static void addService(DeploymentUnitContext context) {
+
+ // Attach the {@link DeploymentService} name so we remove that service on Bundle.uninstall()
+ ServiceName deploymentServiceName = DeploymentService.getServiceName(context.getName());
+ Deployment deployment = DeploymentAttachment.getDeploymentAttachment(context);
+ deployment.addAttachment(ServiceName.class, deploymentServiceName);
+
+ BatchBuilder batchBuilder = context.getBatchBuilder();
+ OSGiDeploymentService service = new OSGiDeploymentService(deployment);
+ ServiceName serviceName = OSGiDeploymentService.SERVICE_NAME.append(deploymentServiceName.getSimpleName());
+ BatchServiceBuilder<Deployment> serviceBuilder = batchBuilder.addService(serviceName, service);
+ serviceBuilder.addDependency(FrameworkService.SERVICE_NAME, BundleContext.class, service.injectedContext);
+ serviceBuilder.addDependency(PackageAdminService.SERVICE_NAME);
+ serviceBuilder.addDependency(deploymentServiceName);
+ serviceBuilder.setInitialMode(Mode.IMMEDIATE);
+ if (enableListener)
+ serviceBuilder.addListener(listener);
+ }
+
+ /**
+ * Install the Bundle associated with this deployment.
+ *
+ * @param context The start context
+ */
+ public synchronized void start(StartContext context) throws StartException {
+
+ // Get the OSGi system context
+ ServiceController<?> controller = context.getController();
+ ServiceContainer serviceContainer = controller.getServiceContainer();
+
+ // Make sure the Framework does not shut down when the last bundle gets removed
+ ServiceController<?> frameworkController = serviceContainer.getService(FrameworkService.SERVICE_NAME);
+ frameworkController.setMode(Mode.IMMEDIATE);
+
+ log.infof("Installing deployment: %s", deployment);
+ try {
+ boolean autoStart = deployment.isAutoStart();
+ deployment.setAutoStart(false);
+ Bundle bundle = getDeployerService().deploy(deployment);
+ deployment.addAttachment(Bundle.class, bundle);
+ deployment.setAutoStart(autoStart);
+ } catch (Throwable t) {
+ throw new StartException("Failed to install deployment: " + deployment, t);
+ }
+ }
+
+ /**
+ * Uninstall the Bundle associated with this deployment.
+ *
+ * @param context The stop context.
+ */
+ public synchronized void stop(StopContext context) {
+ log.infof("Uninstalling deployment: %s", deployment);
+ try {
+ getDeployerService().undeploy(deployment);
+ } catch (Throwable t) {
+ log.errorf(t, "Failed to uninstall deployment: %s", deployment);
+ }
+ }
+
+ @Override
+ public Deployment getValue() throws IllegalStateException {
+ return deployment;
+ }
+
+ // Get the OSGi {@link DeployerService}
+ private DeployerService getDeployerService() {
+ BundleContext sysContext = injectedContext.getValue();
+ ServiceReference sref = sysContext.getServiceReference(DeployerService.class.getName());
+ return (DeployerService) sysContext.getService(sref);
+ }
+
+ static class OSGiDeploymentListener extends AbstractServiceListener<Deployment> {
+
+ private final Set<Deployment> startedDeployments = new CopyOnWriteArraySet<Deployment>();
+ private final Set<Deployment> pendingDeployments = new CopyOnWriteArraySet<Deployment>();
+
+ @Override
+ public void listenerAdded(ServiceController<? extends Deployment> controller) {
+ pendingDeployments.add(controller.getValue());
+ }
+
+ @Override
+ public void serviceStarted(ServiceController<? extends Deployment> controller) {
+ startedDeployments.add(controller.getValue());
+ processDeployment(controller);
+ }
+
+ @Override
+ public void serviceFailed(ServiceController<? extends Deployment> controller, StartException reason) {
+ processDeployment(controller);
+ }
+
+ private void processDeployment(ServiceController<? extends Deployment> controller) {
+ controller.removeListener(this);
+ Set<Deployment> bundlesToStart = null;
+ synchronized (this) {
+ pendingDeployments.remove(controller.getValue());
+ if (pendingDeployments.isEmpty()) {
+ bundlesToStart = new HashSet<Deployment>(startedDeployments);
+ startedDeployments.clear();
+ }
+ }
+
+ if (bundlesToStart != null) {
+ ServiceContainer serviceContainer = controller.getServiceContainer();
+ PackageAdmin packageAdmin = PackageAdminService.getServiceValue(serviceContainer);
+ for (Deployment deployment : bundlesToStart) {
+ Bundle bundle = deployment.getAttachment(Bundle.class);
+ if (packageAdmin.getBundleType(bundle) != PackageAdmin.BUNDLE_TYPE_FRAGMENT) {
+ log.infof("Starting bundle: %s", bundle);
+ try {
+ bundle.start();
+ } catch (BundleException ex) {
+ log.errorf(ex, "Cannot start bundle: %s", bundle);
+ }
+ }
+ }
+ }
+ }
+ }
+}
View
88 osgi/src/main/java/org/jboss/as/osgi/deployment/OSGiManifestDeploymentProcessor.java
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.osgi.deployment;
+
+import java.io.IOException;
+import java.util.jar.Manifest;
+
+import org.jboss.as.deployment.DeploymentPhases;
+import org.jboss.as.deployment.attachment.ManifestAttachment;
+import org.jboss.as.deployment.attachment.VirtualFileAttachment;
+import org.jboss.as.deployment.unit.DeploymentUnitContext;
+import org.jboss.as.deployment.unit.DeploymentUnitProcessingException;
+import org.jboss.as.deployment.unit.DeploymentUnitProcessor;
+import org.jboss.osgi.deployment.deployer.Deployment;
+import org.jboss.osgi.deployment.deployer.DeploymentFactory;
+import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.osgi.vfs.AbstractVFS;
+import org.jboss.vfs.VFSUtils;
+import org.jboss.vfs.VirtualFile;
+import org.osgi.framework.BundleException;
+
+/**
+ * Processes deployments that contain a valid OSGi manifest.
+ *
+ * @author Thomas.Diesler@jboss.com
+ * @since 20-Sep-2010
+ */
+public class OSGiManifestDeploymentProcessor implements DeploymentUnitProcessor {
+
+ public static final long PRIORITY = DeploymentPhases.PARSE_DESCRIPTORS.plus(100L);
+
+ @Override
+ public void processDeployment(DeploymentUnitContext context) throws DeploymentUnitProcessingException {
+
+ // Check if we already have an OSGi deployment
+ Deployment deployment = DeploymentAttachment.getDeploymentAttachment(context);
+ if (deployment != null)
+ return;
+
+ // Get the manifest from the deployment's virtual file
+ VirtualFile virtualFile = VirtualFileAttachment.getVirtualFileAttachment(context);
+ Manifest manifest = ManifestAttachment.getManifestAttachment(context);
+ if (manifest == null) {
+ // Check if this virtual file contains a valid OSGi manifest
+ // If so attach the BundleInfo and the Deployment abstraction
+ try {
+ manifest = VFSUtils.getManifest(virtualFile);
+ if (manifest != null)
+ ManifestAttachment.attachManifest(context, manifest);
+ } catch (IOException ex) {
+ throw new DeploymentUnitProcessingException("Cannot read manifest from: " + virtualFile);
+ }
+ }
+
+ // Nothing to do if this is not a valid manifest
+ if (BundleInfo.isValidateBundleManifest(manifest)) {
+ // Construct and attach the {@link BundleInfo} and {@link Deployment}
+ try {
+ BundleInfo info = BundleInfo.createBundleInfo(AbstractVFS.adapt(virtualFile));
+ deployment = DeploymentFactory.createDeployment(info);
+ BundleInfoAttachment.attachBundleInfo(context, info);
+ DeploymentAttachment.attachDeployment(context, deployment);
+ } catch (BundleException ex) {
+ throw new DeploymentUnitProcessingException("Cannot create bundle deployment from: " + virtualFile);
+ }
+ }
+ }
+}
View
44 osgi/src/main/java/org/jboss/as/osgi/deployment/OSGiMetaDataAttachment.java
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.osgi.deployment;
+
+import org.jboss.as.deployment.AttachmentKey;
+import org.jboss.as.deployment.unit.DeploymentUnitContext;
+import org.jboss.osgi.metadata.OSGiMetaData;
+
+/**
+ * Utility to help attach and retrieve a OSGiMetaData from a deployment context.
+ *
+ * @author Thomas.Diesler@jboss.com
+ */
+public class OSGiMetaDataAttachment {
+ public static final AttachmentKey<OSGiMetaData> KEY = AttachmentKey.create(OSGiMetaData.class);
+
+ public static void attachOSGiMetaData(final DeploymentUnitContext context, final OSGiMetaData metadata) {
+ context.putAttachment(KEY, metadata);
+ }
+
+ public static OSGiMetaData getOSGiMetaDataAttachment(final DeploymentUnitContext context) {
+ return context.getAttachment(KEY);
+ }
+}
View
76 osgi/src/main/java/org/jboss/as/osgi/deployment/OSGiXServicesDeploymentProcessor.java
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.osgi.deployment;
+
+import java.io.IOException;
+
+import org.jboss.as.deployment.attachment.VirtualFileAttachment;
+import org.jboss.as.deployment.unit.DeploymentUnitContext;
+import org.jboss.as.deployment.unit.DeploymentUnitProcessingException;
+import org.jboss.as.deployment.unit.DeploymentUnitProcessor;
+import org.jboss.osgi.deployment.deployer.Deployment;
+import org.jboss.osgi.deployment.deployer.DeploymentFactory;
+import org.jboss.osgi.metadata.OSGiMetaData;
+import org.jboss.osgi.metadata.OSGiMetaDataBuilder;
+import org.jboss.osgi.vfs.AbstractVFS;
+import org.jboss.vfs.VirtualFile;
+import org.osgi.framework.Version;
+
+/**
+ * Processes deployments that contain META-INF/jbosgi-xservice.properties
+ *
+ * @author Thomas.Diesler@jboss.com
+ * @since 20-Sep-2010
+ */
+public class OSGiXServicesDeploymentProcessor implements DeploymentUnitProcessor {
+
+ // private static final Logger log = Logger.getLogger("org.jboss.as.osgi");
+
+ @Override
+ public void processDeployment(DeploymentUnitContext context) throws DeploymentUnitProcessingException {
+
+ // Check if we already have an OSGi deployment
+ Deployment deployment = DeploymentAttachment.getDeploymentAttachment(context);
+ if (deployment != null)
+ return;
+
+ // Get the OSGi XService properties
+ String resName = "META-INF/jbosgi-xservice.properties";
+ VirtualFile virtualFile = VirtualFileAttachment.getVirtualFileAttachment(context);
+ VirtualFile xserviceFile = virtualFile.getChild(resName);
+ if (xserviceFile.exists()) {
+ try {
+ OSGiMetaData metadata = OSGiMetaDataBuilder.load(xserviceFile.openStream());
+ String location = virtualFile.getPathName();
+ String symbolicName = metadata.getBundleSymbolicName();
+ Version version = metadata.getBundleVersion();
+ deployment = DeploymentFactory.createDeployment(AbstractVFS.adapt(virtualFile), location, symbolicName, version);
+ deployment.addAttachment(OSGiMetaData.class, metadata);
+ OSGiMetaDataAttachment.attachOSGiMetaData(context, metadata);
+ DeploymentAttachment.attachDeployment(context, deployment);
+ } catch (IOException ex) {
+ throw new DeploymentUnitProcessingException("Cannot parse: " + xserviceFile);
+ }
+ }
+ }
+}
View
44 osgi/src/main/java/org/jboss/as/osgi/deployment/XModuleAttachment.java
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.osgi.deployment;
+
+import org.jboss.as.deployment.AttachmentKey;
+import org.jboss.as.deployment.unit.DeploymentUnitContext;
+import org.jboss.osgi.resolver.XModule;
+
+/**
+ * Utility to help attach and retrieve a XModule from a deployment context.
+ *
+ * @author Thomas.Diesler@jboss.com
+ */
+public class XModuleAttachment {
+ public static final AttachmentKey<XModule> KEY = AttachmentKey.create(XModule.class);
+
+ public static void attachXModule(final DeploymentUnitContext context, final XModule metadata) {
+ context.putAttachment(KEY, metadata);
+ }
+
+ public static XModule getXModuleAttachment(final DeploymentUnitContext context) {
+ return context.getAttachment(KEY);
+ }
+}
View
75 osgi/src/main/java/org/jboss/as/osgi/parser/Attribute.java
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.osgi.parser;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Attributes used with the OSGi subsystem elements.
+ *
+ * @author Thomas.Diesler@jboss.com
+ * @since 13-Sep-2010
+ */
+public enum Attribute {
+ UNKNOWN(null),
+ IDENTIFIER("identifier"),
+ NAME("name"),
+ START("start"),
+ VALUE("value"),
+ ;
+ private final String name;
+
+ Attribute(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get the local name of this attribute.
+ *
+ * @return the local name
+ */
+ public String getLocalName() {
+ return name;
+ }
+
+ private static final Map<String, Attribute> MAP;
+
+ static {
+ final Map<String, Attribute> map = new HashMap<String, Attribute>();
+ for (Attribute element : values()) {
+ final String name = element.getLocalName();
+ if (name != null) map.put(name, element);
+ }
+ MAP = map;
+ }
+
+ public static Attribute forName(String localName) {
+ final Attribute element = MAP.get(localName);
+ return element == null ? UNKNOWN : element;
+ }
+
+ public String toString() {
+ return getLocalName();
+ }
+}
View
74 osgi/src/main/java/org/jboss/as/osgi/parser/Element.java
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.