commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1425298 - in /commons/sandbox/privilizer/trunk: example/ maven-plugin/ maven-plugin/src/main/java/org/apache/commons/weaver/maven/ modules/ modules/privilizer/ modules/privilizer/weaver/ modules/privilizer/weaver/src/it/ modules/privilizer...
Date Sat, 22 Dec 2012 15:40:44 GMT
Author: struberg
Date: Sat Dec 22 15:40:44 2012
New Revision: 1425298

URL: http://svn.apache.org/viewvc?rev=1425298&view=rev
Log:
add an IT and fix the samples and service pickup

Added:
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/pom.xml
  (with props)
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/src/
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/src/main/
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/src/main/java/
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/src/main/java/org/
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/src/main/java/org/apache/
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/src/main/java/org/apache/commons/
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/src/main/java/org/apache/commons/weaver/
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/src/main/java/org/apache/commons/weaver/privilizer/
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/src/main/java/org/apache/commons/weaver/privilizer/test/
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/src/main/java/org/apache/commons/weaver/privilizer/test/SomeTestClass.java
  (with props)
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/settings.xml   (with
props)
Modified:
    commons/sandbox/privilizer/trunk/example/pom.xml
    commons/sandbox/privilizer/trunk/maven-plugin/pom.xml
    commons/sandbox/privilizer/trunk/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractWeaveMojo.java
    commons/sandbox/privilizer/trunk/modules/pom.xml
    commons/sandbox/privilizer/trunk/modules/privilizer/pom.xml
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/pom.xml
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerWeaver.java
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/resources/META-INF/services/org.apache.commons.weaver.spi.Weaver
    commons/sandbox/privilizer/trunk/processor/pom.xml
    commons/sandbox/privilizer/trunk/processor/src/main/java/org/apache/commons/weaver/WeaveProcessor.java
    commons/sandbox/privilizer/trunk/processor/src/main/java/org/apache/commons/weaver/spi/Weaver.java
    commons/sandbox/privilizer/trunk/processor/src/test/java/org/apache/commons/weaver/test/WeaveProcessorTest.java
    commons/sandbox/privilizer/trunk/processor/src/test/java/org/apache/commons/weaver/test/weaver/TestWeaver.java

Modified: commons/sandbox/privilizer/trunk/example/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/example/pom.xml?rev=1425298&r1=1425297&r2=1425298&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/example/pom.xml (original)
+++ commons/sandbox/privilizer/trunk/example/pom.xml Sat Dec 22 15:40:44 2012
@@ -23,7 +23,7 @@
       <artifactId>commons-weaver</artifactId>
     <version>0.1-SNAPSHOT</version>
   </parent>
-  <artifactId>commons-privilizer-example</artifactId>
+  <artifactId>commons-weaver-example</artifactId>
   <name>Commons Weaver Privilizer Example</name>
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -31,7 +31,7 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.commons</groupId>
-      <artifactId>commons-privilizer</artifactId>
+      <artifactId>commons-weaver-privilizer</artifactId>
       <version>${project.version}</version>
     </dependency>
   </dependencies>
@@ -41,16 +41,34 @@
         <groupId>org.apache.commons</groupId>
         <artifactId>commons-weaver-maven-plugin</artifactId>
         <version>${project.version}</version>
+        <configuration>
+          <weaverConfig>
+            <privilizer.accessLevel>PRIVATE</privilizer.accessLevel>
+            <privilizer.policy>ON_INIT</privilizer.policy>
+          </weaverConfig>
+        </configuration>
         <executions>
           <execution>
             <goals>
-              <goal>prepare</goal>
               <goal>weave</goal>
             </goals>
           </execution>
         </executions>
+        <dependencies>
+          <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-weaver-privilizer-api</artifactId>
+            <version>${project.version}</version>
+          </dependency>
+          <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-weaver-privilizer</artifactId>
+            <version>${project.version}</version>
+          </dependency>
+        </dependencies>
       </plugin>
     </plugins>
+
     <pluginManagement>
       <plugins>
         <!--This plugin's configuration is used to store Eclipse m2e settings only. It
has no influence on the Maven build itself. -->

Modified: commons/sandbox/privilizer/trunk/maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/maven-plugin/pom.xml?rev=1425298&r1=1425297&r2=1425298&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/maven-plugin/pom.xml (original)
+++ commons/sandbox/privilizer/trunk/maven-plugin/pom.xml Sat Dec 22 15:40:44 2012
@@ -27,8 +27,8 @@
   <artifactId>commons-weaver-maven-plugin</artifactId>
   <packaging>maven-plugin</packaging>
 
-  <name>Commons Privilizer Maven Plugin</name>
-  <description>Privilizing Maven goals</description>
+  <name>Commons Weaver Maven Plugin</name>
+  <description>Weaving Maven goals</description>
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

Modified: commons/sandbox/privilizer/trunk/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractWeaveMojo.java
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractWeaveMojo.java?rev=1425298&r1=1425297&r2=1425298&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractWeaveMojo.java
(original)
+++ commons/sandbox/privilizer/trunk/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractWeaveMojo.java
Sat Dec 22 15:40:44 2012
@@ -41,47 +41,6 @@ public abstract class AbstractWeaveMojo 
 
     protected abstract File getTarget();
 
-/*X TODO remove finally
-    protected FilesystemPrivilizer createWeaver() {
-        return new FilesystemPrivilizer(policy, new URLClassLoader(URLArray.fromPaths(getClasspath())),
getTarget()) {
-            @Override
-            protected boolean permitMethodWeaving(AccessLevel accessLevel) {
-                return getAccessLevel().compareTo(accessLevel) <= 0;
-            }
-        }.loggingTo(new Log() {
-
-            @Override
-            public void info(String message) {
-                getLog().info(message);
-            }
-
-            @Override
-            public void error(String message) {
-                getLog().error(message);
-            }
-
-            @Override
-            public void debug(String message) {
-                getLog().debug(message);
-            }
-
-            @Override
-            public void verbose(String message) {
-                if (verbose) {
-                    getLog().info(message);
-                } else {
-                    getLog().debug(message);
-                }
-            }
-
-            @Override
-            public void warn(String message) {
-                getLog().warn(message);
-            }
-        });
-    }
-*/
-
     @Override
     public void execute() throws MojoExecutionException
     {
@@ -103,6 +62,6 @@ public abstract class AbstractWeaveMojo 
     }
 
     protected void configure(WeaveProcessor wp) {
-
+        wp.configure(getClasspath(), getTarget(), weaverConfig);
     }
 }

Modified: commons/sandbox/privilizer/trunk/modules/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/modules/pom.xml?rev=1425298&r1=1425297&r2=1425298&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/modules/pom.xml (original)
+++ commons/sandbox/privilizer/trunk/modules/pom.xml Sat Dec 22 15:40:44 2012
@@ -1,21 +1,22 @@
 <?xml version="1.0"?>
-<!-- 
-
-  Copyright the original author or authors.
-
-  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.
-
- -->
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
 <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <modelVersion>4.0.0</modelVersion>
   <parent>
@@ -31,4 +32,13 @@
   <modules>
     <module>privilizer</module>
   </modules>
+  <dependencies>
+      <dependency>
+          <!-- we need this dependency for the reactor to correctly resolve the build
order -->
+          <groupId>org.apache.commons</groupId>
+          <artifactId>commons-weaver-maven-plugin</artifactId>
+          <version>${project.version}</version>
+          <scope>test</scope>
+      </dependency>
+  </dependencies>
 </project>

Modified: commons/sandbox/privilizer/trunk/modules/privilizer/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/modules/privilizer/pom.xml?rev=1425298&r1=1425297&r2=1425298&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/modules/privilizer/pom.xml (original)
+++ commons/sandbox/privilizer/trunk/modules/privilizer/pom.xml Sat Dec 22 15:40:44 2012
@@ -1,20 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- 
-  Copyright the original author or authors.
-
-  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.
-
- -->
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
 <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>
 

Modified: commons/sandbox/privilizer/trunk/modules/privilizer/weaver/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/modules/privilizer/weaver/pom.xml?rev=1425298&r1=1425297&r2=1425298&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/modules/privilizer/weaver/pom.xml (original)
+++ commons/sandbox/privilizer/trunk/modules/privilizer/weaver/pom.xml Sat Dec 22 15:40:44
2012
@@ -24,7 +24,7 @@
     <version>0.1-SNAPSHOT</version>
   </parent>
 
-  <artifactId>commons-privilizer</artifactId>
+  <artifactId>commons-weaver-privilizer</artifactId>
   <name>Commons Privilizer Weaver</name>
   <description>
     Privilizer provides machinery to automate the handling of Java Security access controls
in code.
@@ -57,4 +57,34 @@
       <version>2.4</version>
     </dependency>
   </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-invoker-plugin</artifactId>
+        <version>1.8</version>
+        <configuration>
+          <debug>true</debug>
+          <projectsDirectory>src/it</projectsDirectory>
+          <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+          <pomIncludes>
+            <pomInclude>*/pom.xml</pomInclude>
+          </pomIncludes>
+          <postBuildHookScript>verify</postBuildHookScript>
+          <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+          <settingsFile>src/it/settings.xml</settingsFile>
+        </configuration>
+        <executions>
+          <execution>
+            <id>integration-test</id>
+            <goals>
+              <goal>install</goal>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
 </project>

Added: commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/pom.xml?rev=1425298&view=auto
==============================================================================
--- commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/pom.xml
(added)
+++ commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/pom.xml
Sat Dec 22 15:40:44 2012
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.commons</groupId>
+  <artifactId>commons-weaver-privilizer-it</artifactId>
+  <version>@pom.version@</version>
+
+  <name>Privilizer maven-plugin IT</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-weaver-privilizer-api</artifactId>
+      <version>@pom.version@</version>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.commons</groupId>
+        <artifactId>commons-weaver-maven-plugin</artifactId>
+        <version>@pom.version@</version>
+        <configuration>
+          <weaverConfig>
+            <privilizer.accessLevel>PRIVATE</privilizer.accessLevel>
+            <privilizer.policy>ON_INIT</privilizer.policy>
+          </weaverConfig>
+        </configuration>
+        <executions>
+          <execution>
+            <goals>
+              <goal>weave</goal>
+            </goals>
+          </execution>
+        </executions>
+        <dependencies>
+          <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-weaver-privilizer-api</artifactId>
+            <version>@pom.version@</version>
+          </dependency>
+           <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-weaver-privilizer</artifactId>
+            <version>@pom.version@</version>
+           </dependency>
+        </dependencies>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/src/main/java/org/apache/commons/weaver/privilizer/test/SomeTestClass.java
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/src/main/java/org/apache/commons/weaver/privilizer/test/SomeTestClass.java?rev=1425298&view=auto
==============================================================================
--- commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/src/main/java/org/apache/commons/weaver/privilizer/test/SomeTestClass.java
(added)
+++ commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/src/main/java/org/apache/commons/weaver/privilizer/test/SomeTestClass.java
Sat Dec 22 15:40:44 2012
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.weaver.privilizer.test;
+
+import org.apache.commons.weaver.privilizer.Privileged;
+
+public class SomeTestClass
+{
+
+    public int nonWeavedMethod() {
+        return 42;
+    }
+
+    @Privileged
+    public int privilegedMethod() {
+        return 21;
+    }
+}

Propchange: commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/maven-privilizer/src/main/java/org/apache/commons/weaver/privilizer/test/SomeTestClass.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/settings.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/settings.xml?rev=1425298&view=auto
==============================================================================
--- commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/settings.xml (added)
+++ commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/settings.xml Sat Dec
22 15:40:44 2012
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<settings>
+  <profiles>
+    <profile>
+      <id>it-repo</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <repositories>
+        <repository>
+          <id>local.central</id>
+          <url>@localRepositoryUrl@</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>true</enabled>
+          </snapshots>
+        </repository>
+      </repositories>
+      <pluginRepositories>
+        <pluginRepository>
+          <id>local.central</id>
+          <url>@localRepositoryUrl@</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>true</enabled>
+          </snapshots>
+        </pluginRepository>
+      </pluginRepositories>
+    </profile>
+  </profiles>
+</settings>

Propchange: commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/it/settings.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerWeaver.java
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerWeaver.java?rev=1425298&r1=1425297&r2=1425298&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerWeaver.java
(original)
+++ commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerWeaver.java
Sat Dec 22 15:40:44 2012
@@ -7,7 +7,7 @@ import java.lang.reflect.Method;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
+import java.util.Properties;
 import java.util.logging.Logger;
 
 import javassist.CannotCompileException;
@@ -24,6 +24,10 @@ import org.apache.commons.weaver.utils.U
  */
 public class PrivilizerWeaver implements Weaver
 {
+    public static final String CONFIG_WEAVER = "privilizer.";
+    public static final String CONFIG_ACCESS_LEVEL = CONFIG_WEAVER + "accessLevel";
+    public static final String CONFIG_POLICY = CONFIG_WEAVER + "policy";
+
     private static final Logger LOG = Logger.getLogger(PrivilizerWeaver.class.getName());
 
     private FilesystemPrivilizer privilizer;
@@ -33,15 +37,29 @@ public class PrivilizerWeaver implements
     private AccessLevel targetAccessLevel;
 
     @Override
-    public void configure(List<String> classPath, File target, Map<String, Object>
config)
+    public void configure(List<String> classPath, File target, Properties config)
     {
         LOG.info("");
+
+        String accessLevel = config.getProperty(CONFIG_ACCESS_LEVEL);
+        if (accessLevel == null || accessLevel.length() == 0) {
+            throw new IllegalArgumentException(CONFIG_ACCESS_LEVEL + " property is missing!");
+        }
+        targetAccessLevel = AccessLevel.valueOf(accessLevel);
+
+        String policyConfig = config.getProperty(CONFIG_POLICY);
+        if (policyConfig == null || policyConfig.length() == 0) {
+            throw new IllegalArgumentException(CONFIG_POLICY + " property is missing!");
+        }
+        policy = Privilizer.Policy.valueOf(policyConfig);
+
         privilizer = new FilesystemPrivilizer(policy, new URLClassLoader(URLArray.fromPaths(classPath)),
target) {
             @Override
             protected boolean permitMethodWeaving(final AccessLevel accessLevel) {
                 return targetAccessLevel.compareTo(accessLevel) <= 0;
             }
         };
+
     }
 
     @Override

Modified: commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/resources/META-INF/services/org.apache.commons.weaver.spi.Weaver
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/resources/META-INF/services/org.apache.commons.weaver.spi.Weaver?rev=1425298&r1=1425297&r2=1425298&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/resources/META-INF/services/org.apache.commons.weaver.spi.Weaver
(original)
+++ commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/resources/META-INF/services/org.apache.commons.weaver.spi.Weaver
Sat Dec 22 15:40:44 2012
@@ -16,4 +16,4 @@
 # under the License.
 
 # this class gets picked up by the WeaveProcessor
-org.apache.commons.weaver.test.weaver.TestWeaver
+org.apache.commons.weaver.privilizer.PrivilizerWeaver

Modified: commons/sandbox/privilizer/trunk/processor/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/processor/pom.xml?rev=1425298&r1=1425297&r2=1425298&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/processor/pom.xml (original)
+++ commons/sandbox/privilizer/trunk/processor/pom.xml Sat Dec 22 15:40:44 2012
@@ -1,21 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- 
-
-  Copyright the original author or authors.
-
-  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.
-
- -->
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
 <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>

Modified: commons/sandbox/privilizer/trunk/processor/src/main/java/org/apache/commons/weaver/WeaveProcessor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/processor/src/main/java/org/apache/commons/weaver/WeaveProcessor.java?rev=1425298&r1=1425297&r2=1425298&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/processor/src/main/java/org/apache/commons/weaver/WeaveProcessor.java
(original)
+++ commons/sandbox/privilizer/trunk/processor/src/main/java/org/apache/commons/weaver/WeaveProcessor.java
Sat Dec 22 15:40:44 2012
@@ -25,7 +25,7 @@ import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
+import java.util.Properties;
 import java.util.ServiceLoader;
 
 import org.apache.commons.weaver.spi.Weaver;
@@ -80,7 +80,7 @@ public class WeaveProcessor {
      * @param config additional configuration for all plugins.
      *
      */
-    public void configure(List<String> classPath, File target, Map<String, Object>
config) {
+    public void configure(List<String> classPath, File target, Properties config) {
         this.classPath = classPath;
         this.target = target;
 

Modified: commons/sandbox/privilizer/trunk/processor/src/main/java/org/apache/commons/weaver/spi/Weaver.java
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/processor/src/main/java/org/apache/commons/weaver/spi/Weaver.java?rev=1425298&r1=1425297&r2=1425298&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/processor/src/main/java/org/apache/commons/weaver/spi/Weaver.java
(original)
+++ commons/sandbox/privilizer/trunk/processor/src/main/java/org/apache/commons/weaver/spi/Weaver.java
Sat Dec 22 15:40:44 2012
@@ -22,7 +22,7 @@ import java.io.File;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.util.List;
-import java.util.Map;
+import java.util.Properties;
 
 /**
  * An implementation of a 'Weaver' takes care about
@@ -41,7 +41,7 @@ public interface Weaver
      * @param target the File path where the classes to weave reside
      * @param config additional configuration for all plugins.
      */
-    void configure(List<String> classPath, File target, Map<String, Object> config);
+    void configure(List<String> classPath, File target, Properties config);
 
     /**
      * A Weaver must return a List of Annotations he is interested in.

Modified: commons/sandbox/privilizer/trunk/processor/src/test/java/org/apache/commons/weaver/test/WeaveProcessorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/processor/src/test/java/org/apache/commons/weaver/test/WeaveProcessorTest.java?rev=1425298&r1=1425297&r2=1425298&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/processor/src/test/java/org/apache/commons/weaver/test/WeaveProcessorTest.java
(original)
+++ commons/sandbox/privilizer/trunk/processor/src/test/java/org/apache/commons/weaver/test/WeaveProcessorTest.java
Sat Dec 22 15:40:44 2012
@@ -18,8 +18,7 @@
  */
 package org.apache.commons.weaver.test;
 
-import java.util.HashMap;
-import java.util.Map;
+import java.util.Properties;
 
 import org.apache.commons.weaver.test.beans.TestBeanWithClassAnnotation;
 import org.apache.commons.weaver.test.beans.TestBeanWithMethodAnnotation;
@@ -42,7 +41,7 @@ public class WeaveProcessorTest extends 
 
         WeaveProcessor wp = WeaveProcessor.getInstance();
 
-        Map<String, Object> config = new HashMap<String, Object>();
+        Properties config = new Properties();
         config.put("configKey", "configValue");
 
         getTargetFolder();

Modified: commons/sandbox/privilizer/trunk/processor/src/test/java/org/apache/commons/weaver/test/weaver/TestWeaver.java
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/processor/src/test/java/org/apache/commons/weaver/test/weaver/TestWeaver.java?rev=1425298&r1=1425297&r2=1425298&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/processor/src/test/java/org/apache/commons/weaver/test/weaver/TestWeaver.java
(original)
+++ commons/sandbox/privilizer/trunk/processor/src/test/java/org/apache/commons/weaver/test/weaver/TestWeaver.java
Sat Dec 22 15:40:44 2012
@@ -24,6 +24,7 @@ import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.logging.Logger;
 
 import org.apache.commons.weaver.test.beans.TestAnnotation;
@@ -41,7 +42,7 @@ public class TestWeaver implements Weave
     public static List<Class> wovenClasses = new ArrayList<Class>();
 
     @Override
-    public void configure(List<String> classPath, File target, Map<String, Object>
config)
+    public void configure(List<String> classPath, File target, Properties config)
     {
         Assert.assertNotNull(config);
         Assert.assertEquals(1, config.size());



Mime
View raw message