Start isolating Spring dependent parts.
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 2 Jan 2020 10:43:00 +0000 (11:43 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 2 Jan 2020 10:43:00 +0000 (11:43 +0100)
14 files changed:
dep/org.argeo.slc.dep.backend/pom.xml
dep/org.argeo.slc.dep.e4.rap/pom.xml
dep/org.argeo.slc.dep.minimal/pom.xml
dep/org.argeo.slc.dep.spring/.gitignore [new file with mode: 0644]
dep/org.argeo.slc.dep.spring/META-INF/MANIFEST.MF [new file with mode: 0644]
dep/org.argeo.slc.dep.spring/bnd.bnd [new file with mode: 0644]
dep/org.argeo.slc.dep.spring/pom.xml [new file with mode: 0644]
dep/pom.xml
org.argeo.slc.agent.jcr/META-INF/spring/jcr.xml
org.argeo.slc.agent/META-INF/spring/osgi.xml
org.argeo.slc.core/src/org/argeo/slc/spring/AbstractSystemExecution.java [new file with mode: 0644]
org.argeo.slc.core/src/org/argeo/slc/spring/AuthenticatedApplicationContextInitialization.java [new file with mode: 0644]
org.argeo.slc.e4/SlcMain.java [new file with mode: 0644]
org.argeo.slc.launcher/.gitignore

index baee5f8455084e13d1e6b90d6444c41a2c260e22..8816fe9f0e7d605421cb1e6be2bf1c789021ca39 100644 (file)
@@ -40,7 +40,7 @@
                <!-- SLC Minimal -->
                <dependency>
                        <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.dep.minimal</artifactId>
+                       <artifactId>org.argeo.slc.dep.spring</artifactId>
                        <version>2.1.17-SNAPSHOT</version>
                </dependency>
 
index 8ae8da5246ae74d3f05af51745dc7c2c04382b17..aea4c1ef06d82ee76f5e5095aeada3112f28a9da 100644 (file)
@@ -45,7 +45,7 @@
                </dependency>
                <dependency>
                        <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.dep.minimal</artifactId>
+                       <artifactId>org.argeo.slc.dep.spring</artifactId>
                        <version>2.1.17-SNAPSHOT</version>
                </dependency>
 
index d297a9f03b0580570a862c23c2da7d8ae78e23f8..6367fda6636b09985b1c551745229ff0407179e6 100644 (file)
@@ -1,4 +1,6 @@
-<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">
+<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">
        <modelVersion>4.0.0</modelVersion>
        <parent>
                <groupId>org.argeo.slc</groupId>
                        <artifactId>org.argeo.slc.agent.jcr</artifactId>
                        <version>2.1.17-SNAPSHOT</version>
                </dependency>
-               <!-- <dependency> -->
-               <!-- <groupId>org.argeo.slc</groupId> -->
-               <!-- <artifactId>org.argeo.slc.node.jackrabbit</artifactId> -->
-               <!-- <version>2.1.5-SNAPSHOT</version> -->
-               <!-- </dependency> -->
-
-
-               <!-- Base Spring dependency -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.spring</groupId> -->
-<!--                   <artifactId>org.springframework.beans</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.spring</groupId> -->
-<!--                   <artifactId>org.springframework.core</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.javax</groupId> -->
-<!--                   <artifactId>javax.el</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.gemini</groupId> -->
-<!--                   <artifactId>org.eclipse.gemini.blueprint.core</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.gemini</groupId> -->
-<!--                   <artifactId>org.eclipse.gemini.blueprint.extender</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.gemini</groupId> -->
-<!--                   <artifactId>org.eclipse.gemini.blueprint.io</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.misc</groupId> -->
-<!--                   <artifactId>org.aspectj.weaver</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.misc</groupId> -->
-<!--                   <artifactId>org.aopalliance</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.spring</groupId> -->
-<!--                   <artifactId>org.springframework.aop</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.spring</groupId> -->
-<!--                   <artifactId>org.springframework.context</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.spring</groupId> -->
-<!--                   <artifactId>org.springframework.expression</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.spring</groupId> -->
-<!--                   <artifactId>org.springframework.instrument</artifactId> -->
-<!--           </dependency> -->
 
-               <!-- Spring -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.spring</groupId> -->
-<!--                   <artifactId>org.springframework.aspects</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.spring</groupId> -->
-<!--                   <artifactId>org.springframework.context.support</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.spring</groupId> -->
-<!--                   <artifactId>org.springframework.jdbc</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.spring</groupId> -->
-<!--                   <artifactId>org.springframework.tx</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.spring</groupId> -->
-<!--                   <artifactId>org.springframework.web</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp.spring</groupId> -->
-<!--                   <artifactId>org.springframework.web.servlet</artifactId> -->
-<!--           </dependency> -->
 
        </dependencies>
        <profiles>
                                                        </execution>
                                                </executions>
                                        </plugin>
-                                       <!-- <plugin> -->
-                                       <!-- <groupId>org.apache.maven.plugins</groupId> -->
-                                       <!-- <artifactId>maven-dependency-plugin</artifactId> -->
-                                       <!-- <executions> -->
-                                       <!-- <execution> -->
-                                       <!-- <id>copy-argeo</id> -->
-                                       <!-- <phase>package</phase> -->
-                                       <!-- <goals> -->
-                                       <!-- <goal>copy-dependencies</goal> -->
-                                       <!-- </goals> -->
-                                       <!-- <configuration> -->
-                                       <!-- <includeTypes>jar</includeTypes> -->
-                                       <!-- <outputDirectory>${project.build.directory}/lib-argeo</outputDirectory> -->
-                                       <!-- <includeGroupIds>org.argeo.slc</includeGroupIds> -->
-                                       <!-- <excludeTransitive>true</excludeTransitive> -->
-                                       <!-- <excludeArtifactIds>org.argeo.dep.cms.node</excludeArtifactIds> -->
-                                       <!-- <includeTypes>jar</includeTypes> -->
-                                       <!-- <includeScope>runtime</includeScope> -->
-                                       <!-- <useRepositoryLayout>true</useRepositoryLayout> -->
-                                       <!-- </configuration> -->
-                                       <!-- </execution> -->
-                                       <!-- </executions> -->
-                                       <!-- </plugin> -->
                                        <plugin>
                                                <groupId>org.codehaus.mojo</groupId>
                                                <artifactId>rpm-maven-plugin</artifactId>
                                                                                                </source>
                                                                                        </sources>
                                                                                </mapping>
-                                                                               <!-- <mapping> -->
-                                                                               <!-- <directory>/usr/share/osgi/org/argeo/slc/${project.artifactId}/${project.version}</directory> -->
-                                                                               <!-- <username>root</username> -->
-                                                                               <!-- <groupname>root</groupname> -->
-                                                                               <!-- <directoryIncluded>false</directoryIncluded> -->
-                                                                               <!-- <artifact /> -->
-                                                                               <!-- </mapping> -->
                                                                        </mappings>
                                                                        <requires>
                                                                                <require>argeo-cms-node</require>
diff --git a/dep/org.argeo.slc.dep.spring/.gitignore b/dep/org.argeo.slc.dep.spring/.gitignore
new file mode 100644 (file)
index 0000000..76df179
--- /dev/null
@@ -0,0 +1,2 @@
+/target/
+/*.target
diff --git a/dep/org.argeo.slc.dep.spring/META-INF/MANIFEST.MF b/dep/org.argeo.slc.dep.spring/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..a0edd63
--- /dev/null
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0\r
+Automatic-Module-Name: org.argeo.slc.dep.spring\r
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt\r
+Bundle-ManifestVersion: 2\r
+Bundle-Name: SLC Agent based on Spring\r
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8\r
+Bundle-SymbolicName: org.argeo.slc.dep.spring\r
+Bundle-Version: 2.1.17.SNAPSHOT-r202001021027\r
+Private-Package: !*\r
+SLC-Category: org.argeo.slc\r
+SLC-ModularDistribution: default\r
diff --git a/dep/org.argeo.slc.dep.spring/bnd.bnd b/dep/org.argeo.slc.dep.spring/bnd.bnd
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/dep/org.argeo.slc.dep.spring/pom.xml b/dep/org.argeo.slc.dep.spring/pom.xml
new file mode 100644 (file)
index 0000000..05ab65c
--- /dev/null
@@ -0,0 +1,345 @@
+<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">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>dep</artifactId>
+               <version>2.1.17-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.dep.spring</artifactId>
+       <name>SLC Agent based on Spring</name>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <configuration>
+                                       <instructions>
+                                               <SLC-ModularDistribution>default</SLC-ModularDistribution>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.argeo.maven.plugins</groupId>
+                               <artifactId>argeo-osgi-plugin</artifactId>
+                               <executions>
+                                       <execution>
+                                               <id>generate-descriptors</id>
+                                               <goals>
+                                                       <goal>descriptors</goal>
+                                               </goals>
+                                               <phase>generate-resources</phase>
+                                       </execution>
+                               </executions>
+                       </plugin>
+                       <!-- <plugin> -->
+                       <!-- <groupId>org.apache.maven.plugins</groupId> -->
+                       <!-- <artifactId>maven-dependency-plugin</artifactId> -->
+                       <!-- <executions> -->
+                       <!-- <execution> -->
+                       <!-- <id>copy-dependencies</id> -->
+                       <!-- <phase>package</phase> -->
+                       <!-- <goals> -->
+                       <!-- <goal>copy-dependencies</goal> -->
+                       <!-- </goals> -->
+                       <!-- </execution> -->
+                       <!-- </executions> -->
+                       <!-- </plugin> -->
+               </plugins>
+       </build>
+       <dependencies>
+               <!-- Parent dependencies -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.dep.cms.node</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+
+               <!-- Absolutely minimal SLC Agent -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.api</artifactId>
+                       <version>2.1.17-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.core</artifactId>
+                       <version>2.1.17-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.agent</artifactId>
+                       <version>2.1.17-SNAPSHOT</version>
+               </dependency>
+
+               <!-- Base Spring dependency -->
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.beans</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.core</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.javax</groupId>
+                       <artifactId>javax.el</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.gemini</groupId>
+                       <artifactId>org.eclipse.gemini.blueprint.core</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.gemini</groupId>
+                       <artifactId>org.eclipse.gemini.blueprint.extender</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.gemini</groupId>
+                       <artifactId>org.eclipse.gemini.blueprint.io</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.misc</groupId>
+                       <artifactId>org.aspectj.weaver</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.misc</groupId>
+                       <artifactId>org.aopalliance</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.aop</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.context</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.expression</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.instrument</artifactId>
+               </dependency>
+
+               <!-- Spring -->
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.aspects</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.context.support</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.jdbc</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.tx</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.web</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.web.servlet</artifactId>
+               </dependency>
+
+               <!-- CLI Agent -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.slc</groupId> -->
+               <!-- <artifactId>org.argeo.slc.launcher</artifactId> -->
+               <!-- <version>1.1.12-SNAPSHOT</version> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.slc</groupId> -->
+               <!-- <artifactId>org.argeo.slc.agent.cli</artifactId> -->
+               <!-- <version>2.1.1-SNAPSHOT</version> -->
+               <!-- </dependency> -->
+
+               <!-- JCR Agent -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.agent.jcr</artifactId>
+                       <version>2.1.17-SNAPSHOT</version>
+               </dependency>
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.slc</groupId> -->
+               <!-- <artifactId>org.argeo.slc.node.jackrabbit</artifactId> -->
+               <!-- <version>2.1.5-SNAPSHOT</version> -->
+               <!-- </dependency> -->
+
+
+               <!-- Base Spring dependency -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.spring</groupId> -->
+<!--                   <artifactId>org.springframework.beans</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.spring</groupId> -->
+<!--                   <artifactId>org.springframework.core</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.javax</groupId> -->
+<!--                   <artifactId>javax.el</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.gemini</groupId> -->
+<!--                   <artifactId>org.eclipse.gemini.blueprint.core</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.gemini</groupId> -->
+<!--                   <artifactId>org.eclipse.gemini.blueprint.extender</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.gemini</groupId> -->
+<!--                   <artifactId>org.eclipse.gemini.blueprint.io</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.misc</groupId> -->
+<!--                   <artifactId>org.aspectj.weaver</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.misc</groupId> -->
+<!--                   <artifactId>org.aopalliance</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.spring</groupId> -->
+<!--                   <artifactId>org.springframework.aop</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.spring</groupId> -->
+<!--                   <artifactId>org.springframework.context</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.spring</groupId> -->
+<!--                   <artifactId>org.springframework.expression</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.spring</groupId> -->
+<!--                   <artifactId>org.springframework.instrument</artifactId> -->
+<!--           </dependency> -->
+
+               <!-- Spring -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.spring</groupId> -->
+<!--                   <artifactId>org.springframework.aspects</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.spring</groupId> -->
+<!--                   <artifactId>org.springframework.context.support</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.spring</groupId> -->
+<!--                   <artifactId>org.springframework.jdbc</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.spring</groupId> -->
+<!--                   <artifactId>org.springframework.tx</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.spring</groupId> -->
+<!--                   <artifactId>org.springframework.web</artifactId> -->
+<!--           </dependency> -->
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.tp.spring</groupId> -->
+<!--                   <artifactId>org.springframework.web.servlet</artifactId> -->
+<!--           </dependency> -->
+
+       </dependencies>
+       <profiles>
+               <profile>
+                       <id>rpmbuild</id>
+                       <build>
+                               <plugins>
+                                       <plugin>
+                                               <artifactId>maven-assembly-plugin</artifactId>
+                                               <executions>
+                                                       <execution>
+                                                               <id>prepare-source</id>
+                                                               <phase>package</phase>
+                                                               <goals>
+                                                                       <goal>single</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <descriptorRefs>
+                                                                               <descriptorRef>a2-source</descriptorRef>
+                                                                       </descriptorRefs>
+                                                               </configuration>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                                       <!-- <plugin> -->
+                                       <!-- <groupId>org.apache.maven.plugins</groupId> -->
+                                       <!-- <artifactId>maven-dependency-plugin</artifactId> -->
+                                       <!-- <executions> -->
+                                       <!-- <execution> -->
+                                       <!-- <id>copy-argeo</id> -->
+                                       <!-- <phase>package</phase> -->
+                                       <!-- <goals> -->
+                                       <!-- <goal>copy-dependencies</goal> -->
+                                       <!-- </goals> -->
+                                       <!-- <configuration> -->
+                                       <!-- <includeTypes>jar</includeTypes> -->
+                                       <!-- <outputDirectory>${project.build.directory}/lib-argeo</outputDirectory> -->
+                                       <!-- <includeGroupIds>org.argeo.slc</includeGroupIds> -->
+                                       <!-- <excludeTransitive>true</excludeTransitive> -->
+                                       <!-- <excludeArtifactIds>org.argeo.dep.cms.node</excludeArtifactIds> -->
+                                       <!-- <includeTypes>jar</includeTypes> -->
+                                       <!-- <includeScope>runtime</includeScope> -->
+                                       <!-- <useRepositoryLayout>true</useRepositoryLayout> -->
+                                       <!-- </configuration> -->
+                                       <!-- </execution> -->
+                                       <!-- </executions> -->
+                                       <!-- </plugin> -->
+                                       <plugin>
+                                               <groupId>org.codehaus.mojo</groupId>
+                                               <artifactId>rpm-maven-plugin</artifactId>
+                                               <executions>
+                                                       <execution>
+                                                               <id>rpm-argeo</id>
+                                                               <phase>package</phase>
+                                                               <goals>
+                                                                       <goal>rpm</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <name>slc-agent</name>
+                                                                       <mappings>
+                                                                               <mapping>
+                                                                                       <directory>/usr/share/osgi</directory>
+                                                                                       <username>root</username>
+                                                                                       <groupname>root</groupname>
+                                                                                       <filemode>644</filemode>
+                                                                                       <directoryIncluded>true</directoryIncluded>
+                                                                                       <sources>
+                                                                                               <source>
+                                                                                                       <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source</location>
+                                                                                                       <includes>
+                                                                                                               <include>**/*.jar</include>
+                                                                                                       </includes>
+                                                                                               </source>
+                                                                                       </sources>
+                                                                               </mapping>
+                                                                               <!-- <mapping> -->
+                                                                               <!-- <directory>/usr/share/osgi/org/argeo/slc/${project.artifactId}/${project.version}</directory> -->
+                                                                               <!-- <username>root</username> -->
+                                                                               <!-- <groupname>root</groupname> -->
+                                                                               <!-- <directoryIncluded>false</directoryIncluded> -->
+                                                                               <!-- <artifact /> -->
+                                                                               <!-- </mapping> -->
+                                                                       </mappings>
+                                                                       <requires>
+                                                                               <require>argeo-cms-node</require>
+                                                                       </requires>
+                                                               </configuration>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                               </plugins>
+                       </build>
+               </profile>
+       </profiles>
+</project>
\ No newline at end of file
index 2aea9b4d574c6662b4e3dd2a5f1e0e72e9052b2d..2bf7f791da5c1977e11d0243c4819cc95a91bf9e 100644 (file)
        <packaging>pom</packaging>
        <modules>
                <module>org.argeo.slc.dep.minimal</module>
-               <module>org.argeo.slc.dep.backend</module>
+               <module>org.argeo.slc.dep.spring</module>
                <module>org.argeo.slc.dep.e4.rap</module>
+               <!--  Legacy -->
+               <module>org.argeo.slc.dep.backend</module>
        </modules>
        <build>
                <plugins>
index 7f2f8b40593dc367851f164bddf62dd9a38fae76..6d31ddd1148631260c1147981ab278ec408876c7 100644 (file)
@@ -34,8 +34,7 @@
 \r
 \r
        <bean\r
-               class="org.argeo.cms.spring.AuthenticatedApplicationContextInitialization">\r
-<!--           <property name="authenticationManager" ref="authenticationManager" /> -->\r
+               class="org.argeo.slc.spring.AuthenticatedApplicationContextInitialization">\r
        </bean>\r
 \r
 \r
index b3e9aebe267c23ca448b6a8ce037455959f1a67f..79d933cd019b9b2b97826e073da66d8b7e5c9870 100644 (file)
        <service ref="modulesManager" interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
 \r
        <!-- LABEL -->\r
-       <beans:bean class="org.argeo.cms.spring.osgi.OsgiModuleLabel">\r
-               <beans:property name="bundleContext" ref="bundleContext" />\r
-       </beans:bean>\r
+<!--   <beans:bean class="org.argeo.cms.spring.osgi.OsgiModuleLabel"> -->\r
+<!--           <beans:property name="bundleContext" ref="bundleContext" /> -->\r
+<!--   </beans:bean> -->\r
 \r
        <!-- ROLES -->\r
 <!--   <reference id="userAdminService" interface="org.argeo.security.UserAdminService" /> -->\r
 \r
-       <beans:bean class="org.argeo.cms.spring.SimpleRoleRegistration"\r
+       <beans:bean class="org.argeo.maintenance.SimpleRoleRegistration"\r
                init-method="run">\r
                <beans:property name="role" value="org.argeo.slc.user" />\r
                <beans:property name="userAdmin" ref="userAdmin" />\r
diff --git a/org.argeo.slc.core/src/org/argeo/slc/spring/AbstractSystemExecution.java b/org.argeo.slc.core/src/org/argeo/slc/spring/AbstractSystemExecution.java
new file mode 100644 (file)
index 0000000..7813b9a
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.spring;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.node.NodeConstants;
+import org.argeo.slc.SlcException;
+
+/** Provides base method for executing code with system authorization. */
+abstract class AbstractSystemExecution {
+       private final static Log log = LogFactory.getLog(AbstractSystemExecution.class);
+       private final Subject subject = new Subject();
+
+       /** Authenticate the calling thread */
+       protected void authenticateAsSystem() {
+               ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
+               Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+               try {
+                       LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
+                       lc.login();
+               } catch (LoginException e) {
+                       throw new SlcException("Cannot login as system", e);
+               } finally {
+                       Thread.currentThread().setContextClassLoader(origClassLoader);
+               }
+               if (log.isTraceEnabled())
+                       log.trace("System authenticated");
+       }
+
+       protected void deauthenticateAsSystem() {
+               ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
+               Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+               try {
+                       LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
+                       lc.logout();
+               } catch (LoginException e) {
+                       throw new SlcException("Cannot logout as system", e);
+               } finally {
+                       Thread.currentThread().setContextClassLoader(origClassLoader);
+               }
+       }
+
+       protected Subject getSubject() {
+               return subject;
+       }
+}
diff --git a/org.argeo.slc.core/src/org/argeo/slc/spring/AuthenticatedApplicationContextInitialization.java b/org.argeo.slc.core/src/org/argeo/slc/spring/AuthenticatedApplicationContextInitialization.java
new file mode 100644 (file)
index 0000000..68a9cc9
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.spring;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.security.auth.Subject;
+
+import org.eclipse.gemini.blueprint.context.DependencyInitializationAwareBeanPostProcessor;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.support.AbstractBeanFactory;
+import org.springframework.beans.factory.support.SecurityContextProvider;
+import org.springframework.beans.factory.support.SimpleSecurityContextProvider;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ * Executes with a system authentication the instantiation and initialization
+ * methods of the application context where it has been defined.
+ */
+public class AuthenticatedApplicationContextInitialization extends
+               AbstractSystemExecution implements
+               DependencyInitializationAwareBeanPostProcessor, ApplicationContextAware {
+       /** If non empty, restricts to these beans */
+       private List<String> beanNames = new ArrayList<String>();
+
+       public Object postProcessBeforeInitialization(Object bean, String beanName)
+                       throws BeansException {
+               if (beanNames.size() == 0 || beanNames.contains(beanName))
+                       authenticateAsSystem();
+               return bean;
+       }
+
+       public Object postProcessAfterInitialization(Object bean, String beanName)
+                       throws BeansException {
+               if (beanNames.size() == 0 || beanNames.contains(beanName))
+                       deauthenticateAsSystem();
+               return bean;
+       }
+
+       public void setBeanNames(List<String> beanNames) {
+               this.beanNames = beanNames;
+       }
+
+       @Override
+       public void setApplicationContext(ApplicationContext applicationContext)
+                       throws BeansException {
+               if (applicationContext.getAutowireCapableBeanFactory() instanceof AbstractBeanFactory) {
+                       final AbstractBeanFactory beanFactory = ((AbstractBeanFactory) applicationContext
+                                       .getAutowireCapableBeanFactory());
+                       // retrieve subject's access control context
+                       // and set it as the bean factory security context
+                       Subject.doAs(getSubject(), new PrivilegedAction<Void>() {
+                               @Override
+                               public Void run() {
+                                       SecurityContextProvider scp = new SimpleSecurityContextProvider(
+                                                       AccessController.getContext());
+                                       beanFactory.setSecurityContextProvider(scp);
+                                       return null;
+                               }
+                       });
+               }
+       }
+}
diff --git a/org.argeo.slc.e4/SlcMain.java b/org.argeo.slc.e4/SlcMain.java
new file mode 100644 (file)
index 0000000..a4bf3cd
--- /dev/null
@@ -0,0 +1,338 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.cli;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.UUID;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+
+import org.argeo.osgi.boot.OsgiBoot;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/** Configures an SLC runtime and runs a process. */
+public class SlcMain implements PrivilegedAction<String> {
+       public final static String NIX = "NIX";
+       public final static String WINDOWS = "WINDOWS";
+       public final static String SOLARIS = "SOLARIS";
+
+       public final static String os;
+       public final static String slcDirName = ".slc";
+       final static File homeDir = new File(System.getProperty("user.home"));
+
+       static {
+               String osName = System.getProperty("os.name");
+               if (osName.startsWith("Win"))
+                       os = WINDOWS;
+               else if (osName.startsWith("Solaris"))
+                       os = SOLARIS;
+               else
+                       os = NIX;
+       }
+
+       private Long timeout = 30 * 1000l;
+       private final String[] args;
+       private final File confDir;
+       private final File dataDir;
+       private final File modulesDir;
+
+       private final List<String> bundlesToStart = new ArrayList<String>();
+
+       public SlcMain(String[] args, File confDir, File dataDir, File modulesDir) {
+               this.args = args;
+               this.confDir = confDir;
+               this.dataDir = dataDir;
+               this.modulesDir = modulesDir;
+
+               bundlesToStart.add("org.eclipse.equinox.cm");
+               bundlesToStart.add("org.argeo.cms");
+               bundlesToStart.add("org.eclipse.gemini.blueprint.extender");
+               bundlesToStart.add("org.argeo.slc.agent");
+               bundlesToStart.add("org.argeo.slc.agent.jcr");
+
+               // bundlesToStart.add("org.springframework.osgi.extender");
+               // bundlesToStart.add("org.argeo.node.repo.jackrabbit");
+               // bundlesToStart.add("org.argeo.security.dao.os");
+               // bundlesToStart.add("org.argeo.slc.node.jackrabbit");
+               // bundlesToStart.add("org.argeo.slc.agent");
+               // bundlesToStart.add("org.argeo.slc.agent.jcr");
+               // if (args.length == 0)
+               // bundlesToStart.add("org.argeo.slc.support.equinox");
+               // bundlesToStart.add("org.argeo.slc.agent.cli");
+       }
+
+       public String run() {
+               long begin = System.currentTimeMillis();
+
+               Framework framework = null;
+               try {
+                       info("## Date : " + new Date());
+                       info("## Data : " + dataDir.getCanonicalPath());
+
+                       // Start Equinox
+                       ServiceLoader<FrameworkFactory> ff = ServiceLoader.load(FrameworkFactory.class);
+                       FrameworkFactory frameworkFactory = ff.iterator().next();
+                       Map<String, String> configuration = new HashMap<String, String>();
+                       configuration.put("osgi.configuration.area", confDir.getCanonicalPath());
+                       configuration.put("osgi.instance.area", dataDir.getCanonicalPath());
+                       // Do clean
+                       configuration.put("osgi.clean", "true");
+                       if (args.length == 0) {
+                               configuration.put("osgi.console", "");
+                       }
+
+                       // Spring configs currently require System properties
+                       System.getProperties().putAll(configuration);
+
+                       framework = frameworkFactory.newFramework(configuration);
+                       framework.start();
+                       BundleContext bundleContext = framework.getBundleContext();
+
+                       // OSGi bootstrap
+                       OsgiBoot osgiBoot = new OsgiBoot(bundleContext);
+
+                       // working copy modules
+                       if (modulesDir.exists())
+                               osgiBoot.installUrls(osgiBoot.getBundlesUrls(modulesDir.getCanonicalPath() + ";in=*;ex=.gitignore"));
+
+                       // system modules
+                       if (System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BUNDLES) != null)
+                               osgiBoot.installUrls(osgiBoot.getBundlesUrls(System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BUNDLES)));
+                       else
+                               osgiBoot.installUrls(osgiBoot.getBundlesUrls(System.getProperty("user.home") + "/.slc/modules/;in=**"));
+
+                       // Start runtime
+                       osgiBoot.startBundles(bundlesToStart);
+
+                       // Find SLC Agent
+                       ServiceReference sr = null;
+                       while (sr == null) {
+                               sr = bundleContext.getServiceReference("org.argeo.slc.execution.SlcAgentCli");
+                               if (System.currentTimeMillis() - begin > timeout)
+                                       throw new RuntimeException("Cannot find SLC agent CLI");
+                               Thread.sleep(100);
+                       }
+                       Object agentCli = bundleContext.getService(sr);
+
+                       // Initialization completed
+                       long duration = System.currentTimeMillis() - begin;
+                       info("[[ Initialized in " + (duration / 1000) + "s " + (duration % 1000) + "ms ]]");
+
+                       if (args.length == 0)
+                               return null;// console mode
+
+                       // Subject.doAs(Subject.getSubject(AccessController.getContext()),
+                       // new AgentCliCall(agentCli));
+                       Class<?>[] parameterTypes = { String[].class };
+                       Method method = agentCli.getClass().getMethod("process", parameterTypes);
+                       Object[] methodArgs = { args };
+                       Object ret = method.invoke(agentCli, methodArgs);
+
+                       // Shutdown OSGi runtime
+                       framework.stop();
+                       framework.waitForStop(60 * 1000);
+
+                       return ret.toString();
+               } catch (Exception e) {
+                       // Shutdown OSGi runtime
+                       if (framework != null)
+                               try {
+                                       framework.stop();
+                                       framework.waitForStop(15 * 1000);
+                               } catch (Exception silent) {
+                               }
+                       throw new RuntimeException("Cannot run SLC command line", e);
+               } finally {
+
+               }
+       }
+
+       public static void main(String[] args) {
+               try {
+                       // Prepare directories
+                       File executionDir = new File(System.getProperty("user.dir"));
+                       File slcDir;
+                       Boolean isTransient = false;
+                       if (isTransient) {
+                               File tempDir = new File(System.getProperty("java.io.tmpdir") + "/" + System.getProperty("user.name"));
+                               slcDir = new File(tempDir, "slc-" + UUID.randomUUID().toString());
+                               slcDir.mkdirs();
+                               System.setProperty("argeo.node.repo.configuration", "osgibundle:repository-memory.xml");
+                       } else {
+                               slcDir = findSlcDir(executionDir);
+                               if (slcDir == null) {
+                                       slcDir = new File(executionDir, slcDirName);
+                                       slcDir.mkdirs();
+                                       info("## Creating an SLC node at " + slcDir + " ...");
+                               }
+                       }
+
+                       File dataDir = new File(slcDir, "data");
+                       if (!dataDir.exists())
+                               dataDir.mkdirs();
+
+                       File confDir = new File(slcDir, "conf");
+                       if (!confDir.exists())
+                               confDir.mkdirs();
+
+                       File modulesDir = new File(slcDir, "modules");
+
+                       // JAAS
+                       // File jaasFile = new File(confDir, "jaas.config");
+                       // if (!jaasFile.exists())
+                       // copyResource("/org/argeo/slc/cli/jaas.config", jaasFile);
+                       // System.setProperty("java.security.auth.login.config",
+                       // jaasFile.getCanonicalPath());
+
+                       // log4j
+                       File log4jFile = new File(confDir, "log4j.properties");
+                       if (!log4jFile.exists())
+                               copyResource("/org/argeo/slc/cli/log4j.properties", log4jFile);
+                       System.setProperty("log4j.configuration", "file://" + log4jFile.getCanonicalPath());
+                       // Run as a privileged action
+                       // LoginContext lc = new LoginContext(os);
+                       // lc.login();
+                       //
+                       // Subject subject =
+                       // Subject.getSubject(AccessController.getContext());
+                       // Subject.doAs(subject, new SlcMain(args, confDir, dataDir,
+                       // modulesDir));
+                       SlcMain slcMain = new SlcMain(args, confDir, dataDir, modulesDir);
+                       slcMain.run();
+                       if (args.length != 0)
+                               System.exit(0);
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       System.exit(1);
+               }
+       }
+
+       /**
+        * Recursively look in parent directories for a directory named
+        * {@link #slcDirName}
+        */
+       protected static File findSlcDir(File currentDir) {
+               File slcDir = new File(currentDir, slcDirName);
+               // covers the use case of running from the home directory
+               if (slcDir.exists() && slcDir.isDirectory())
+                       return slcDir;
+               File parentDir = currentDir.getParentFile();
+               if (parentDir == null)
+                       return null;
+               try {
+                       // ~/.slc reserved for agent
+                       if (parentDir.getCanonicalPath().equals(homeDir.getCanonicalPath()))
+                               return null;
+               } catch (IOException e) {
+                       throw new RuntimeException("Cannot check home directory", e);
+               }
+               return findSlcDir(parentDir);
+       }
+
+       protected static void copyResource(String resource, File targetFile) {
+               InputStream input = null;
+               FileOutputStream output = null;
+               try {
+                       input = SlcMain.class.getResourceAsStream(resource);
+                       output = new FileOutputStream(targetFile);
+                       byte[] buf = new byte[8192];
+                       while (true) {
+                               int length = input.read(buf);
+                               if (length < 0)
+                                       break;
+                               output.write(buf, 0, length);
+                       }
+               } catch (Exception e) {
+                       throw new RuntimeException("Cannot write " + resource + " file to " + targetFile, e);
+               } finally {
+                       try {
+                               input.close();
+                       } catch (Exception ignore) {
+                       }
+                       try {
+                               output.close();
+                       } catch (Exception ignore) {
+                       }
+               }
+
+       }
+
+       protected static void info(Object msg) {
+               System.out.println(msg);
+       }
+
+       protected static void err(Object msg) {
+               System.err.println(msg);
+       }
+
+       protected static void debug(Object msg) {
+               System.out.println(msg);
+       }
+
+}
+
+// private String bundlesToInstall = System.getProperty("user.home")
+// +
+// "/dev/src/slc/dep/org.argeo.slc.dep.minimal/target/dependency;in=*.jar,"
+// + System.getProperty("user.home")
+// + "/dev/src/slc/demo/modules;in=*;ex=pom.xml;ex=.svn";
+
+// ServiceTracker agentTracker = new ServiceTracker(bundleContext,
+// "org.argeo.slc.execution.SlcAgentCli", null);
+// agentTracker.open();
+// final Object agentCli = agentTracker.waitForService(30 * 1000);
+// if (agentCli == null)
+// throw new RuntimeException("Cannot find SLC agent CLI");
+
+// protected class AgentCliCall implements PrivilegedAction<String> {
+// private final Object agentCli;
+//
+// public AgentCliCall(Object agentCli) {
+// super();
+// this.agentCli = agentCli;
+// }
+//
+// public String run() {
+// try {
+// Class<?>[] parameterTypes = { String[].class };
+// Method method = agentCli.getClass().getMethod("process",
+// parameterTypes);
+// Object[] methodArgs = { args };
+// Object ret = method.invoke(agentCli, methodArgs);
+// return ret.toString();
+// } catch (Exception e) {
+// throw new RuntimeException("Cannot run "
+// + Arrays.toString(args) + " on " + agentCli, e);
+// }
+// }
+//
+// }
index b83d22266ac8aa2f8df2edef68082c789727841d..c2bdee88caec83457d7364f2bee3ca8cdd9439ab 100644 (file)
@@ -1 +1,2 @@
 /target/
+/.slc/