Commits

Micha Kops  committed 817d981

Dummy user provider added, CDI activation implemented.

  • Participants
  • Parent commits cf1f575

Comments (0)

Files changed (3)

 	<groupId>com.hascode.tutorial</groupId>
 	<artifactId>togglz-feature-flag-tutorial</artifactId>
 	<version>1.0.0</version>
+	<packaging>war</packaging>
 
 	<properties>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		</dependency>
 		<dependency>
 			<groupId>org.togglz</groupId>
+			<artifactId>togglz-cdi</artifactId>
+			<version>${togglz.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.togglz</groupId>
 			<artifactId>togglz-slf4j</artifactId>
 			<version>${togglz.version}</version>
 		</dependency>
 	</dependencies>
 
 	<build>
+		<defaultGoal>clean package org.glassfish:maven-embedded-glassfish-plugin:3.1.1:run</defaultGoal>
 		<plugins>
 			<plugin>
 				<artifactId>maven-compiler-plugin</artifactId>
 					<failOnMissingWebXml>false</failOnMissingWebXml>
 				</configuration>
 			</plugin>
+			<plugin>
+				<groupId>org.glassfish</groupId>
+				<artifactId>maven-embedded-glassfish-plugin</artifactId>
+				<version>3.1.1</version>
+				<configuration>
+					<goalPrefix>glassfish</goalPrefix>
+					<app>${project.build.directory}/${project.build.finalName}</app>
+					<port>8080</port>
+					<contextRoot>${project.name}</contextRoot>
+					<name>${project.name}</name>
+					<autoDelete>true</autoDelete>
+				</configuration>
+			</plugin>
 		</plugins>
 	</build>
 </project>

File src/main/java/com/hascode/tutorial/fflag/config/FeatureFlagConfiguration.java

 import org.togglz.core.manager.TogglzConfig;
 import org.togglz.core.repository.StateRepository;
 import org.togglz.core.repository.mem.InMemoryStateRepository;
+import org.togglz.core.user.FeatureUser;
+import org.togglz.core.user.SimpleFeatureUser;
 import org.togglz.core.user.UserProvider;
-import org.togglz.servlet.user.ServletUserProvider;
 
 import com.hascode.tutorial.fflag.feature.UserFeatures;
 
 
 	@Override
 	public UserProvider getUserProvider() {
-		return new ServletUserProvider(FEATURE_FLAG_ADMIN_ROLE);
+		// return new ServletUserProvider(FEATURE_FLAG_ADMIN_ROLE);
+		return new UserProvider() {
+			@Override
+			public FeatureUser getCurrentUser() {
+				return new SimpleFeatureUser("admin", true);
+			}
+		};
 	}
 
 }

File src/main/webapp/WEB-INF/beans.xml

Empty file added.