Commit 114731e3793189cebc990b928d17e4f1e6c7b7aa
Exists in
master
Merge branch '2.4.0' of github.com:demoiselle/framework into 2.4.0
Showing
51 changed files
with
2381 additions
and
249 deletions
Show diff stats
archetype/jsf-jpa/pom.xml
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | <parent> |
| 46 | 46 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 47 | 47 | <artifactId>demoiselle-archetype-parent</artifactId> |
| 48 | - <version>2.3.2-SNAPSHOT</version> | |
| 48 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 49 | 49 | <relativePath>../../parent/archetype</relativePath> |
| 50 | 50 | </parent> |
| 51 | 51 | ... | ... |
archetype/minimal/pom.xml
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | <parent> |
| 46 | 46 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 47 | 47 | <artifactId>demoiselle-archetype-parent</artifactId> |
| 48 | - <version>2.3.2-SNAPSHOT</version> | |
| 48 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 49 | 49 | <relativePath>../../parent/archetype</relativePath> |
| 50 | 50 | </parent> |
| 51 | 51 | ... | ... |
documentation/quickstart/pom.xml
documentation/reference/pom.xml
impl/core/pom.xml
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | <parent> |
| 45 | 45 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 46 | 46 | <artifactId>demoiselle-framework-parent</artifactId> |
| 47 | - <version>2.3.2-SNAPSHOT</version> | |
| 47 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 48 | 48 | <relativePath>../../parent/framework</relativePath> |
| 49 | 49 | </parent> |
| 50 | 50 | |
| ... | ... | @@ -72,7 +72,7 @@ |
| 72 | 72 | <dependency> |
| 73 | 73 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 74 | 74 | <artifactId>demoiselle-framework-bom</artifactId> |
| 75 | - <version>2.3.2-SNAPSHOT</version> | |
| 75 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 76 | 76 | <scope>import</scope> |
| 77 | 77 | <type>pom</type> |
| 78 | 78 | </dependency> | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoader.java
| ... | ... | @@ -43,10 +43,12 @@ import java.lang.reflect.Method; |
| 43 | 43 | import java.lang.reflect.ParameterizedType; |
| 44 | 44 | import java.lang.reflect.Type; |
| 45 | 45 | import java.net.URL; |
| 46 | -import java.util.HashSet; | |
| 46 | +import java.util.HashMap; | |
| 47 | 47 | import java.util.Iterator; |
| 48 | +import java.util.Map; | |
| 48 | 49 | import java.util.Properties; |
| 49 | -import java.util.Set; | |
| 50 | +import java.util.regex.Matcher; | |
| 51 | +import java.util.regex.Pattern; | |
| 50 | 52 | |
| 51 | 53 | import javax.validation.constraints.NotNull; |
| 52 | 54 | |
| ... | ... | @@ -114,7 +116,7 @@ public class ConfigurationLoader implements Serializable { |
| 114 | 116 | org.apache.commons.configuration.Configuration config = getConfiguration(resource, type); |
| 115 | 117 | |
| 116 | 118 | if (config != null) { |
| 117 | - String key = getKey(field, clazz, config); | |
| 119 | + Key key = new Key(field, clazz, config); | |
| 118 | 120 | Object value = getValue(key, field, config); |
| 119 | 121 | |
| 120 | 122 | validate(field, key, value, resource); |
| ... | ... | @@ -123,106 +125,21 @@ public class ConfigurationLoader implements Serializable { |
| 123 | 125 | } |
| 124 | 126 | } |
| 125 | 127 | |
| 126 | - private void setValue(Field field, String key, Object object, Object value) { | |
| 128 | + private void setValue(Field field, Key key, Object object, Object value) { | |
| 127 | 129 | if (value != null) { |
| 128 | 130 | Reflections.setFieldValue(field, object, value); |
| 129 | - getLogger().debug(getBundle().getString("configuration-field-loaded", key, field.getName(), value)); | |
| 131 | + getLogger().debug( | |
| 132 | + getBundle().getString("configuration-field-loaded", key.toString(), field.getName(), value)); | |
| 130 | 133 | } |
| 131 | 134 | } |
| 132 | 135 | |
| 133 | - private void validate(Field field, String key, Object value, String resource) { | |
| 136 | + private void validate(Field field, Key key, Object value, String resource) { | |
| 134 | 137 | if (field.isAnnotationPresent(NotNull.class) && value == null) { |
| 135 | - throw new ConfigurationException(getBundle().getString("configuration-attribute-is-mandatory", key, | |
| 136 | - resource)); | |
| 138 | + throw new ConfigurationException(getBundle().getString("configuration-attribute-is-mandatory", | |
| 139 | + key.toString(), resource)); | |
| 137 | 140 | } |
| 138 | 141 | } |
| 139 | 142 | |
| 140 | - private String getKey(final Field field, final Class<?> clazz, | |
| 141 | - final org.apache.commons.configuration.Configuration config) { | |
| 142 | - | |
| 143 | - final String prefix = getPrefix(field, clazz); | |
| 144 | - final StringBuffer key = new StringBuffer(); | |
| 145 | - | |
| 146 | - key.append(prefix); | |
| 147 | - | |
| 148 | - if (field.isAnnotationPresent(Name.class)) { | |
| 149 | - key.append(getKeyByAnnotation(field)); | |
| 150 | - } else { | |
| 151 | - key.append(getKeyByConvention(field, prefix, config)); | |
| 152 | - } | |
| 153 | - | |
| 154 | - return key.toString(); | |
| 155 | - } | |
| 156 | - | |
| 157 | - private String getPrefix(Field field, Class<?> type) { | |
| 158 | - String prefix = ""; | |
| 159 | - | |
| 160 | - Configuration classAnnotation = type.getAnnotation(Configuration.class); | |
| 161 | - if (!Strings.isEmpty(classAnnotation.prefix())) { | |
| 162 | - | |
| 163 | - prefix = classAnnotation.prefix(); | |
| 164 | - | |
| 165 | - if (prefix.charAt(prefix.length() - 1) != '.') { | |
| 166 | - getLogger().warn( | |
| 167 | - "ATENÇÃO!!! Informe o ponto (.) ao final da declaração do atributo prefix = \"" + prefix | |
| 168 | - + "\" da anotação @Configuration da classe " + type.getCanonicalName() | |
| 169 | - + " para evitar incompatibilidade com as próximas versões do Demoiselle."); | |
| 170 | - | |
| 171 | - prefix += "."; | |
| 172 | - } | |
| 173 | - } | |
| 174 | - | |
| 175 | - return prefix; | |
| 176 | - } | |
| 177 | - | |
| 178 | - private String getKeyByAnnotation(Field field) { | |
| 179 | - String key = null; | |
| 180 | - | |
| 181 | - Name nameAnnotation = field.getAnnotation(Name.class); | |
| 182 | - if (Strings.isEmpty(nameAnnotation.value())) { | |
| 183 | - throw new ConfigurationException(getBundle().getString("configuration-name-attribute-cant-be-empty")); | |
| 184 | - } else { | |
| 185 | - key = nameAnnotation.value(); | |
| 186 | - } | |
| 187 | - | |
| 188 | - return key; | |
| 189 | - } | |
| 190 | - | |
| 191 | - private String getKeyByConvention(Field field, String prefix, org.apache.commons.configuration.Configuration config) { | |
| 192 | - | |
| 193 | - Set<String> conventions = new HashSet<String>(); | |
| 194 | - conventions.add(field.getName()); | |
| 195 | - conventions.add(Strings.camelCaseToSymbolSeparated(field.getName(), ".")); | |
| 196 | - conventions.add(Strings.camelCaseToSymbolSeparated(field.getName(), "_")); | |
| 197 | - conventions.add(field.getName().toLowerCase()); | |
| 198 | - conventions.add(field.getName().toUpperCase()); | |
| 199 | - | |
| 200 | - int matches = 0; | |
| 201 | - String key = field.getName(); | |
| 202 | - for (String convention : conventions) { | |
| 203 | - if (config.containsKey(prefix + convention)) { | |
| 204 | - key = convention; | |
| 205 | - matches++; | |
| 206 | - } | |
| 207 | - } | |
| 208 | - | |
| 209 | - if (!field.getName().equals(key)) { | |
| 210 | - getLogger().warn( | |
| 211 | - "ATENÇÃO!!! Anote o atributo " + field.getName() + " da classe " | |
| 212 | - + field.getDeclaringClass().getCanonicalName() + " com @Name(\"" + key | |
| 213 | - + "\") para evitar incompatibilidade com as próximas versões do Demoiselle."); | |
| 214 | - } | |
| 215 | - | |
| 216 | - if (matches == 0) { | |
| 217 | - getLogger().debug(getBundle().getString("configuration-key-not-found", key, conventions)); | |
| 218 | - } else if (matches > 1) { | |
| 219 | - throw new ConfigurationException(getBundle().getString("ambiguous-key", field.getName(), | |
| 220 | - field.getDeclaringClass())); | |
| 221 | - } | |
| 222 | - | |
| 223 | - return key; | |
| 224 | - } | |
| 225 | - | |
| 226 | 143 | /** |
| 227 | 144 | * Returns the configuration class according to specified resource name and configuration type. |
| 228 | 145 | * |
| ... | ... | @@ -273,7 +190,7 @@ public class ConfigurationLoader implements Serializable { |
| 273 | 190 | } |
| 274 | 191 | |
| 275 | 192 | @SuppressWarnings("unchecked") |
| 276 | - private <T> T getValue(String key, Field field, org.apache.commons.configuration.Configuration config) { | |
| 193 | + private <T> T getValue(Key key, Field field, org.apache.commons.configuration.Configuration config) { | |
| 277 | 194 | Object value; |
| 278 | 195 | |
| 279 | 196 | Class<?> fieldClass = (Class<?>) field.getType(); |
| ... | ... | @@ -281,6 +198,9 @@ public class ConfigurationLoader implements Serializable { |
| 281 | 198 | if (fieldClass.isArray()) { |
| 282 | 199 | value = getArray(key, field, config); |
| 283 | 200 | |
| 201 | + } else if (fieldClass.equals(Map.class)) { | |
| 202 | + value = getMap(key, field, config); | |
| 203 | + | |
| 284 | 204 | } else if (fieldClass.equals(Properties.class)) { |
| 285 | 205 | value = getProperty(key, config); |
| 286 | 206 | |
| ... | ... | @@ -294,7 +214,38 @@ public class ConfigurationLoader implements Serializable { |
| 294 | 214 | return (T) value; |
| 295 | 215 | } |
| 296 | 216 | |
| 297 | - private <T> Object getArray(String key, Field field, org.apache.commons.configuration.Configuration config) { | |
| 217 | + private <T> Object getMap(Key key, Field field, org.apache.commons.configuration.Configuration config) { | |
| 218 | + Map<String, Object> value = null; | |
| 219 | + | |
| 220 | + String regexp = "^(" + key.getPrefix() + ")((.+)\\.)?(" + key.getName() + ")$"; | |
| 221 | + Pattern pattern = Pattern.compile(regexp); | |
| 222 | + Matcher matcher; | |
| 223 | + | |
| 224 | + String iterKey; | |
| 225 | + String mapKey; | |
| 226 | + String confKey; | |
| 227 | + | |
| 228 | + for (@SuppressWarnings("unchecked") | |
| 229 | + Iterator<String> iter = config.getKeys(); iter.hasNext();) { | |
| 230 | + iterKey = iter.next(); | |
| 231 | + matcher = pattern.matcher(iterKey); | |
| 232 | + | |
| 233 | + if (matcher.matches()) { | |
| 234 | + confKey = matcher.group(1) + (matcher.group(2) == null ? "" : matcher.group(2)) + matcher.group(4); | |
| 235 | + | |
| 236 | + if (value == null) { | |
| 237 | + value = new HashMap<String, Object>(); | |
| 238 | + } | |
| 239 | + | |
| 240 | + mapKey = matcher.group(3) == null ? "default" : matcher.group(3); | |
| 241 | + value.put(mapKey, config.getProperty(confKey)); | |
| 242 | + } | |
| 243 | + } | |
| 244 | + | |
| 245 | + return value; | |
| 246 | + } | |
| 247 | + | |
| 248 | + private <T> Object getArray(Key key, Field field, org.apache.commons.configuration.Configuration config) { | |
| 298 | 249 | Object value = null; |
| 299 | 250 | |
| 300 | 251 | Class<?> fieldClass = (Class<?>) field.getType(); |
| ... | ... | @@ -309,7 +260,7 @@ public class ConfigurationLoader implements Serializable { |
| 309 | 260 | methodName += "Array"; |
| 310 | 261 | |
| 311 | 262 | method = config.getClass().getMethod(methodName, String.class); |
| 312 | - value = method.invoke(config, key); | |
| 263 | + value = method.invoke(config, key.toString()); | |
| 313 | 264 | |
| 314 | 265 | } catch (Throwable cause) { |
| 315 | 266 | throw new ConfigurationException(getBundle().getString("error-converting-to-type", fieldClass.getName()), |
| ... | ... | @@ -319,7 +270,7 @@ public class ConfigurationLoader implements Serializable { |
| 319 | 270 | return value; |
| 320 | 271 | } |
| 321 | 272 | |
| 322 | - private <T> Object getBasic(String key, Field field, org.apache.commons.configuration.Configuration config) { | |
| 273 | + private <T> Object getBasic(Key key, Field field, org.apache.commons.configuration.Configuration config) { | |
| 323 | 274 | Object value = null; |
| 324 | 275 | |
| 325 | 276 | Class<?> fieldClass = (Class<?>) field.getType(); |
| ... | ... | @@ -333,11 +284,11 @@ public class ConfigurationLoader implements Serializable { |
| 333 | 284 | |
| 334 | 285 | if (!fieldClass.isPrimitive()) { |
| 335 | 286 | method = config.getClass().getMethod(methodName, String.class, fieldClass); |
| 336 | - value = method.invoke(config, key, null); | |
| 287 | + value = method.invoke(config, key.toString(), null); | |
| 337 | 288 | |
| 338 | - } else if (config.containsKey(key)) { | |
| 289 | + } else if (config.containsKey(key.toString())) { | |
| 339 | 290 | method = config.getClass().getMethod(methodName, String.class); |
| 340 | - value = method.invoke(config, key); | |
| 291 | + value = method.invoke(config, key.toString()); | |
| 341 | 292 | } |
| 342 | 293 | |
| 343 | 294 | } catch (Throwable cause) { |
| ... | ... | @@ -348,11 +299,11 @@ public class ConfigurationLoader implements Serializable { |
| 348 | 299 | return value; |
| 349 | 300 | } |
| 350 | 301 | |
| 351 | - private <T> Object getClass(String key, Field field, org.apache.commons.configuration.Configuration config) { | |
| 302 | + private <T> Object getClass(Key key, Field field, org.apache.commons.configuration.Configuration config) { | |
| 352 | 303 | Object value = null; |
| 353 | 304 | |
| 354 | 305 | try { |
| 355 | - String canonicalName = config.getString(key); | |
| 306 | + String canonicalName = config.getString(key.toString()); | |
| 356 | 307 | |
| 357 | 308 | if (canonicalName != null) { |
| 358 | 309 | ClassLoader classLoader = getClassLoaderForClass(canonicalName); |
| ... | ... | @@ -395,17 +346,17 @@ public class ConfigurationLoader implements Serializable { |
| 395 | 346 | return ""; |
| 396 | 347 | } |
| 397 | 348 | |
| 398 | - private Object getProperty(String key, org.apache.commons.configuration.Configuration config) { | |
| 349 | + private Object getProperty(Key key, org.apache.commons.configuration.Configuration config) { | |
| 399 | 350 | Object value = null; |
| 400 | 351 | |
| 401 | 352 | @SuppressWarnings("unchecked") |
| 402 | - Iterator<String> iterator = config.getKeys(key); | |
| 353 | + Iterator<String> iterator = config.getKeys(key.toString()); | |
| 403 | 354 | if (iterator.hasNext()) { |
| 404 | 355 | Properties props = new Properties(); |
| 405 | 356 | |
| 406 | 357 | while (iterator.hasNext()) { |
| 407 | 358 | String fullKey = iterator.next(); |
| 408 | - String prefix = key + "."; | |
| 359 | + String prefix = key.toString() + "."; | |
| 409 | 360 | String unprefixedKey = fullKey.substring(prefix.length()); |
| 410 | 361 | props.put(unprefixedKey, config.getString(fullKey)); |
| 411 | 362 | } |
| ... | ... | @@ -470,4 +421,59 @@ public class ConfigurationLoader implements Serializable { |
| 470 | 421 | |
| 471 | 422 | return bootstrap; |
| 472 | 423 | } |
| 424 | + | |
| 425 | + private class Key { | |
| 426 | + | |
| 427 | + private String prefix; | |
| 428 | + | |
| 429 | + private String name; | |
| 430 | + | |
| 431 | + private String key; | |
| 432 | + | |
| 433 | + private Key(final Field field, final Class<?> type, final org.apache.commons.configuration.Configuration config) { | |
| 434 | + | |
| 435 | + this.prefix = type.getAnnotation(Configuration.class).prefix(); | |
| 436 | + if (this.prefix == null) { | |
| 437 | + this.prefix = ""; | |
| 438 | + } | |
| 439 | + | |
| 440 | + if (field.isAnnotationPresent(Name.class)) { | |
| 441 | + this.name = getNameByAnnotation(field); | |
| 442 | + } else { | |
| 443 | + this.name = getNameByField(field); | |
| 444 | + } | |
| 445 | + | |
| 446 | + this.key = this.prefix + this.name; | |
| 447 | + } | |
| 448 | + | |
| 449 | + private String getNameByAnnotation(Field field) { | |
| 450 | + String key = null; | |
| 451 | + | |
| 452 | + Name nameAnnotation = field.getAnnotation(Name.class); | |
| 453 | + if (Strings.isEmpty(nameAnnotation.value())) { | |
| 454 | + throw new ConfigurationException(getBundle().getString("configuration-name-attribute-cant-be-empty")); | |
| 455 | + } else { | |
| 456 | + key = nameAnnotation.value(); | |
| 457 | + } | |
| 458 | + | |
| 459 | + return key; | |
| 460 | + } | |
| 461 | + | |
| 462 | + private String getNameByField(Field field) { | |
| 463 | + return field.getName(); | |
| 464 | + } | |
| 465 | + | |
| 466 | + public String getPrefix() { | |
| 467 | + return prefix; | |
| 468 | + } | |
| 469 | + | |
| 470 | + public String getName() { | |
| 471 | + return name; | |
| 472 | + } | |
| 473 | + | |
| 474 | + @Override | |
| 475 | + public String toString() { | |
| 476 | + return this.key; | |
| 477 | + } | |
| 478 | + } | |
| 473 | 479 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImpl.java
| ... | ... | @@ -202,7 +202,7 @@ public class SecurityContextImpl implements SecurityContext { |
| 202 | 202 | return Beans.getReference(SecurityConfigImpl.class); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - private void checkLoggedIn() throws NotLoggedInException { | |
| 205 | + public void checkLoggedIn() throws NotLoggedInException { | |
| 206 | 206 | if (!isLoggedIn()) { |
| 207 | 207 | ResourceBundle bundle = ResourceBundleProducer.create("demoiselle-core-bundle"); |
| 208 | 208 | throw new NotLoggedInException(bundle.getString("user-not-authenticated")); | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/security/SecurityContext.java
| ... | ... | @@ -65,6 +65,8 @@ public interface SecurityContext extends Serializable { |
| 65 | 65 | * @return {@code true} if the user is logged in |
| 66 | 66 | */ |
| 67 | 67 | boolean isLoggedIn(); |
| 68 | + | |
| 69 | + void checkLoggedIn() throws NotLoggedInException; | |
| 68 | 70 | |
| 69 | 71 | /** |
| 70 | 72 | * Checks if the logged user has permission to execute an specific operation on a specific resource. | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfigTest.java
| ... | ... | @@ -9,7 +9,6 @@ import br.gov.frameworkdemoiselle.internal.implementation.DefaultAuthenticator; |
| 9 | 9 | import br.gov.frameworkdemoiselle.internal.implementation.DefaultAuthorizer; |
| 10 | 10 | import br.gov.frameworkdemoiselle.security.Authenticator; |
| 11 | 11 | import br.gov.frameworkdemoiselle.security.Authorizer; |
| 12 | -import br.gov.frameworkdemoiselle.security.User; | |
| 13 | 12 | |
| 14 | 13 | public class SecurityConfigTest { |
| 15 | 14 | |
| ... | ... | @@ -38,7 +37,7 @@ public class SecurityConfigTest { |
| 38 | 37 | assertEquals("br.gov.frameworkdemoiselle.internal.implementation.DefaultAuthenticator", config |
| 39 | 38 | .getAuthenticatorClass().getName()); |
| 40 | 39 | } |
| 41 | - | |
| 40 | + | |
| 42 | 41 | @Test |
| 43 | 42 | public void testSetAuthorizerClass() { |
| 44 | 43 | Authorizer authorizer = new DefaultAuthorizer(); | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/MessageContextImplTest.java
| ... | ... | @@ -38,7 +38,6 @@ package br.gov.frameworkdemoiselle.internal.implementation; |
| 38 | 38 | |
| 39 | 39 | import static org.easymock.EasyMock.expect; |
| 40 | 40 | import static org.powermock.api.easymock.PowerMock.mockStatic; |
| 41 | -import static org.powermock.api.easymock.PowerMock.replay; | |
| 42 | 41 | import static org.powermock.api.easymock.PowerMock.replayAll; |
| 43 | 42 | |
| 44 | 43 | import java.util.Locale; |
| ... | ... | @@ -51,10 +50,8 @@ import org.junit.runner.RunWith; |
| 51 | 50 | import org.powermock.api.easymock.PowerMock; |
| 52 | 51 | import org.powermock.core.classloader.annotations.PrepareForTest; |
| 53 | 52 | import org.powermock.modules.junit4.PowerMockRunner; |
| 54 | -import org.powermock.reflect.Whitebox; | |
| 55 | 53 | import org.slf4j.Logger; |
| 56 | 54 | |
| 57 | -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | |
| 58 | 55 | import br.gov.frameworkdemoiselle.message.Message; |
| 59 | 56 | import br.gov.frameworkdemoiselle.message.MessageContext; |
| 60 | 57 | import br.gov.frameworkdemoiselle.message.SeverityType; |
| ... | ... | @@ -68,19 +65,19 @@ public class MessageContextImplTest { |
| 68 | 65 | MessageContext messageContext; |
| 69 | 66 | |
| 70 | 67 | Message m1; |
| 71 | - | |
| 68 | + | |
| 72 | 69 | private ResourceBundle bundle; |
| 73 | 70 | |
| 74 | 71 | @SuppressWarnings("unused") |
| 75 | 72 | @Before |
| 76 | 73 | public void before() { |
| 77 | 74 | messageContext = new MessageContextImpl(); |
| 78 | - | |
| 75 | + | |
| 79 | 76 | Locale locale = Locale.getDefault(); |
| 80 | - | |
| 77 | + | |
| 81 | 78 | mockStatic(Beans.class); |
| 82 | 79 | expect(Beans.getReference(Locale.class)).andReturn(locale).anyTimes(); |
| 83 | - | |
| 80 | + | |
| 84 | 81 | expect(Beans.getReference(ResourceBundle.class)).andReturn(bundle).anyTimes(); |
| 85 | 82 | replayAll(Beans.class); |
| 86 | 83 | |
| ... | ... | @@ -150,20 +147,20 @@ public class MessageContextImplTest { |
| 150 | 147 | messageContext.add(m1); |
| 151 | 148 | Assert.assertTrue(messageContext.getMessages().size() == 1); |
| 152 | 149 | Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(m1.getText())); |
| 153 | - Assert.assertTrue(messageContext.getMessages().get(0).getSeverity().equals(m1.getSeverity())); | |
| 150 | + Assert.assertTrue(messageContext.getMessages().get(0).getSeverity().equals(m1.getSeverity())); | |
| 154 | 151 | } |
| 155 | - | |
| 152 | + | |
| 156 | 153 | @Test |
| 157 | 154 | public void testClearMessages() { |
| 158 | 155 | Assert.assertTrue(messageContext.getMessages().isEmpty()); |
| 159 | 156 | |
| 160 | 157 | messageContext.add(m1); |
| 161 | - messageContext.add(m1, null); | |
| 162 | - | |
| 158 | + messageContext.add(m1, (Object[]) null); | |
| 159 | + | |
| 163 | 160 | Assert.assertTrue(messageContext.getMessages().size() == 2); |
| 164 | - | |
| 161 | + | |
| 165 | 162 | messageContext.clear(); |
| 166 | - | |
| 163 | + | |
| 167 | 164 | Assert.assertTrue(messageContext.getMessages().isEmpty()); |
| 168 | 165 | } |
| 169 | 166 | |
| ... | ... | @@ -171,88 +168,87 @@ public class MessageContextImplTest { |
| 171 | 168 | public void testGetMessages() { |
| 172 | 169 | Assert.assertNotNull(messageContext.getMessages()); |
| 173 | 170 | Assert.assertTrue(messageContext.getMessages().isEmpty()); |
| 174 | - | |
| 171 | + | |
| 175 | 172 | messageContext.add("key1"); |
| 176 | 173 | Assert.assertTrue(messageContext.getMessages().size() == 1); |
| 177 | - | |
| 174 | + | |
| 178 | 175 | messageContext.add("key2"); |
| 179 | 176 | Assert.assertTrue(messageContext.getMessages().size() == 2); |
| 180 | - | |
| 177 | + | |
| 181 | 178 | Assert.assertTrue(messageContext.getMessages().get(0).getText().equals("key1")); |
| 182 | 179 | Assert.assertTrue(messageContext.getMessages().get(1).getText().equals("key2")); |
| 183 | 180 | } |
| 184 | 181 | |
| 185 | -// @Test | |
| 186 | -// public void testAddMessageObjectArray() { | |
| 187 | -// Object[] param = { "1", "2" }; | |
| 188 | -// messageContext.add(m1, param); | |
| 189 | - | |
| 190 | -// Assert.assertTrue(messageContext.getMessages().size() == 1); | |
| 191 | -// Assert.assertTrue(messageContext.getMessages().contains(m1)); | |
| 192 | -// Assert.assertNotNull(messageContext.getMessages().get(0).getParameters()); | |
| 193 | -// Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); | |
| 194 | -// Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); | |
| 195 | -// } | |
| 196 | - | |
| 197 | -// @Test | |
| 198 | -// public void testAddStringObjectArray() { | |
| 199 | -// String key = "my.key"; | |
| 200 | -// Object[] param = { "1", "2" }; | |
| 201 | -// messageContext.add(key, param); | |
| 202 | -// | |
| 203 | -// Assert.assertTrue(messageContext.getMessages().size() == 1); | |
| 204 | -// Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); | |
| 205 | -// Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); | |
| 206 | -// Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); | |
| 207 | -// } | |
| 208 | -// | |
| 209 | -// @Test | |
| 210 | -// public void testAddStringLocaleObjectArray() { | |
| 211 | -// String key = "my.key"; | |
| 212 | -// Object[] param = { "1", "2" }; | |
| 213 | -// Locale locale = Locale.CANADA_FRENCH; | |
| 214 | -// messageContext.add(key, locale, param); | |
| 215 | -// | |
| 216 | -// Assert.assertTrue(messageContext.getMessages().size() == 1); | |
| 217 | -// Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); | |
| 218 | -// Assert.assertTrue(messageContext.getMessages().get(0).getLocale().equals(locale)); | |
| 219 | -// Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); | |
| 220 | -// Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); | |
| 221 | -// } | |
| 222 | -// | |
| 223 | -// @Test | |
| 224 | -// public void testAddStringLocaleSeverityTypeObjectArray() { | |
| 225 | -// String key = "my.key"; | |
| 226 | -// Object[] param = { "1", "2" }; | |
| 227 | -// Locale locale = Locale.CANADA_FRENCH; | |
| 228 | -// SeverityType severity = SeverityType.ERROR; | |
| 229 | -// messageContext.add(key, locale, severity, param); | |
| 230 | -// | |
| 231 | -// Assert.assertTrue(messageContext.getMessages().size() == 1); | |
| 232 | -// Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); | |
| 233 | -// Assert.assertTrue(messageContext.getMessages().get(0).getLocale().equals(locale)); | |
| 234 | -// Assert.assertTrue(messageContext.getMessages().get(0).getSeverity().equals(severity)); | |
| 235 | -// Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); | |
| 236 | -// Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); | |
| 237 | -// } | |
| 238 | -// | |
| 239 | -// @Test | |
| 240 | -// public void testAddStringLocaleSeverityTypeStringObjectArray() { | |
| 241 | -// String key = "my.key"; | |
| 242 | -// Object[] param = { "1", "2" }; | |
| 243 | -// Locale locale = Locale.CANADA_FRENCH; | |
| 244 | -// SeverityType severity = SeverityType.ERROR; | |
| 245 | -// String resource = "myresourcename"; | |
| 246 | -// messageContext.add(key, locale, severity, resource, param); | |
| 247 | -// | |
| 248 | -// Assert.assertTrue(messageContext.getMessages().size() == 1); | |
| 249 | -// Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); | |
| 250 | -// Assert.assertTrue(messageContext.getMessages().get(0).getLocale().equals(locale)); | |
| 251 | -// Assert.assertTrue(messageContext.getMessages().get(0).getSeverity().equals(severity)); | |
| 252 | -// Assert.assertTrue(messageContext.getMessages().get(0).getResourceName().equals(resource)); | |
| 253 | -// Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); | |
| 254 | -// Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); | |
| 255 | -// } | |
| 256 | - | |
| 257 | - | |
| 258 | -} | |
| 259 | 182 | \ No newline at end of file |
| 183 | + // @Test | |
| 184 | + // public void testAddMessageObjectArray() { | |
| 185 | + // Object[] param = { "1", "2" }; | |
| 186 | + // messageContext.add(m1, param); | |
| 187 | + | |
| 188 | + // Assert.assertTrue(messageContext.getMessages().size() == 1); | |
| 189 | + // Assert.assertTrue(messageContext.getMessages().contains(m1)); | |
| 190 | + // Assert.assertNotNull(messageContext.getMessages().get(0).getParameters()); | |
| 191 | + // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); | |
| 192 | + // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); | |
| 193 | + // } | |
| 194 | + | |
| 195 | + // @Test | |
| 196 | + // public void testAddStringObjectArray() { | |
| 197 | + // String key = "my.key"; | |
| 198 | + // Object[] param = { "1", "2" }; | |
| 199 | + // messageContext.add(key, param); | |
| 200 | + // | |
| 201 | + // Assert.assertTrue(messageContext.getMessages().size() == 1); | |
| 202 | + // Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); | |
| 203 | + // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); | |
| 204 | + // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); | |
| 205 | + // } | |
| 206 | + // | |
| 207 | + // @Test | |
| 208 | + // public void testAddStringLocaleObjectArray() { | |
| 209 | + // String key = "my.key"; | |
| 210 | + // Object[] param = { "1", "2" }; | |
| 211 | + // Locale locale = Locale.CANADA_FRENCH; | |
| 212 | + // messageContext.add(key, locale, param); | |
| 213 | + // | |
| 214 | + // Assert.assertTrue(messageContext.getMessages().size() == 1); | |
| 215 | + // Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); | |
| 216 | + // Assert.assertTrue(messageContext.getMessages().get(0).getLocale().equals(locale)); | |
| 217 | + // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); | |
| 218 | + // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); | |
| 219 | + // } | |
| 220 | + // | |
| 221 | + // @Test | |
| 222 | + // public void testAddStringLocaleSeverityTypeObjectArray() { | |
| 223 | + // String key = "my.key"; | |
| 224 | + // Object[] param = { "1", "2" }; | |
| 225 | + // Locale locale = Locale.CANADA_FRENCH; | |
| 226 | + // SeverityType severity = SeverityType.ERROR; | |
| 227 | + // messageContext.add(key, locale, severity, param); | |
| 228 | + // | |
| 229 | + // Assert.assertTrue(messageContext.getMessages().size() == 1); | |
| 230 | + // Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); | |
| 231 | + // Assert.assertTrue(messageContext.getMessages().get(0).getLocale().equals(locale)); | |
| 232 | + // Assert.assertTrue(messageContext.getMessages().get(0).getSeverity().equals(severity)); | |
| 233 | + // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); | |
| 234 | + // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); | |
| 235 | + // } | |
| 236 | + // | |
| 237 | + // @Test | |
| 238 | + // public void testAddStringLocaleSeverityTypeStringObjectArray() { | |
| 239 | + // String key = "my.key"; | |
| 240 | + // Object[] param = { "1", "2" }; | |
| 241 | + // Locale locale = Locale.CANADA_FRENCH; | |
| 242 | + // SeverityType severity = SeverityType.ERROR; | |
| 243 | + // String resource = "myresourcename"; | |
| 244 | + // messageContext.add(key, locale, severity, resource, param); | |
| 245 | + // | |
| 246 | + // Assert.assertTrue(messageContext.getMessages().size() == 1); | |
| 247 | + // Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); | |
| 248 | + // Assert.assertTrue(messageContext.getMessages().get(0).getLocale().equals(locale)); | |
| 249 | + // Assert.assertTrue(messageContext.getMessages().get(0).getSeverity().equals(severity)); | |
| 250 | + // Assert.assertTrue(messageContext.getMessages().get(0).getResourceName().equals(resource)); | |
| 251 | + // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); | |
| 252 | + // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); | |
| 253 | + // } | |
| 254 | + | |
| 255 | +} | ... | ... |
| ... | ... | @@ -0,0 +1,93 @@ |
| 1 | +<!-- | |
| 2 | + Demoiselle Framework | |
| 3 | + Copyright (C) 2010 SERPRO | |
| 4 | + ============================================================================ | |
| 5 | + This file is part of Demoiselle Framework. | |
| 6 | + | |
| 7 | + Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + as published by the Free Software Foundation. | |
| 10 | + | |
| 11 | + This program is distributed in the hope that it will be useful, | |
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + GNU General Public License for more details. | |
| 15 | + | |
| 16 | + You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + along with this program; if not, see <http://www.gnu.org/licenses /> | |
| 18 | + or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + ============================================================================ | |
| 21 | + Este arquivo é parte do Framework Demoiselle. | |
| 22 | + | |
| 23 | + O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + do Software Livre (FSF). | |
| 26 | + | |
| 27 | + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + para maiores detalhes. | |
| 31 | + | |
| 32 | + Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses /> | |
| 34 | + ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | +--> | |
| 37 | +<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"> | |
| 38 | + | |
| 39 | + <modelVersion>4.0.0</modelVersion> | |
| 40 | + | |
| 41 | + <artifactId>demoiselle-jaas</artifactId> | |
| 42 | + <packaging>jar</packaging> | |
| 43 | + | |
| 44 | + <parent> | |
| 45 | + <groupId>br.gov.frameworkdemoiselle</groupId> | |
| 46 | + <artifactId>demoiselle-extension-parent</artifactId> | |
| 47 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 48 | + <relativePath>../../../parent/extension</relativePath> | |
| 49 | + </parent> | |
| 50 | + | |
| 51 | + <name>Demoiselle Framework JAAS Extension</name> | |
| 52 | + <description> | |
| 53 | + JAAS Extension | |
| 54 | + </description> | |
| 55 | + <url>http://www.frameworkdemoiselle.gov.br</url> | |
| 56 | + | |
| 57 | + <licenses> | |
| 58 | + <license> | |
| 59 | + <name>GNU Lesser General Public License, Version 3</name> | |
| 60 | + <url>http://www.gnu.org/licenses/lgpl-3.0.txt</url> | |
| 61 | + </license> | |
| 62 | + </licenses> | |
| 63 | + | |
| 64 | + <organization> | |
| 65 | + <name>SERPRO - Serviço Federal de Processamento de Dados</name> | |
| 66 | + <url>http://www.serpro.gov.br</url> | |
| 67 | + </organization> | |
| 68 | + | |
| 69 | + <repositories> | |
| 70 | + <repository> | |
| 71 | + <id>sonatype-nexus-snapshots</id> | |
| 72 | + <name>Sonatype Nexus Snapshots</name> | |
| 73 | + <url>https://oss.sonatype.org/content/repositories/snapshots</url> | |
| 74 | + <snapshots> | |
| 75 | + <enabled>true</enabled> | |
| 76 | + </snapshots> | |
| 77 | + <releases> | |
| 78 | + <enabled>false</enabled> | |
| 79 | + </releases> | |
| 80 | + </repository> | |
| 81 | + <repository> | |
| 82 | + <id>sonatype-nexus-releases</id> | |
| 83 | + <name>Sonatype Nexus Releases</name> | |
| 84 | + <url>https://oss.sonatype.org/content/repositories/releases</url> | |
| 85 | + <snapshots> | |
| 86 | + <enabled>false</enabled> | |
| 87 | + </snapshots> | |
| 88 | + <releases> | |
| 89 | + <enabled>true</enabled> | |
| 90 | + </releases> | |
| 91 | + </repository> | |
| 92 | + </repositories> | |
| 93 | +</project> | ... | ... |
impl/extension/jaas/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/JAASConfig.java
0 → 100644
| ... | ... | @@ -0,0 +1,57 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package br.gov.frameworkdemoiselle.internal.configuration; | |
| 38 | + | |
| 39 | +import java.io.Serializable; | |
| 40 | + | |
| 41 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | |
| 42 | + | |
| 43 | +@Configuration(prefix = "frameworkdemoiselle.security") | |
| 44 | +public class JAASConfig implements Serializable { | |
| 45 | + | |
| 46 | + private static final long serialVersionUID = 1L; | |
| 47 | + | |
| 48 | + private String loginModuleName; | |
| 49 | + | |
| 50 | + public String getLoginModuleName() { | |
| 51 | + return loginModuleName; | |
| 52 | + } | |
| 53 | + | |
| 54 | + public void setLoginModuleName(String loginModuleName) { | |
| 55 | + this.loginModuleName = loginModuleName; | |
| 56 | + } | |
| 57 | +} | ... | ... |
impl/extension/jaas/src/main/java/br/gov/frameworkdemoiselle/security/Credentials.java
0 → 100644
| ... | ... | @@ -0,0 +1,74 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package br.gov.frameworkdemoiselle.security; | |
| 38 | + | |
| 39 | +import java.io.Serializable; | |
| 40 | + | |
| 41 | +import javax.enterprise.context.RequestScoped; | |
| 42 | +import javax.inject.Named; | |
| 43 | + | |
| 44 | +@Named | |
| 45 | +@RequestScoped | |
| 46 | +public class Credentials implements Serializable { | |
| 47 | + | |
| 48 | + private static final long serialVersionUID = 1L; | |
| 49 | + | |
| 50 | + private String username; | |
| 51 | + | |
| 52 | + private String password; | |
| 53 | + | |
| 54 | + public void clear() { | |
| 55 | + this.username = null; | |
| 56 | + this.password = null; | |
| 57 | + } | |
| 58 | + | |
| 59 | + public String getUsername() { | |
| 60 | + return username; | |
| 61 | + } | |
| 62 | + | |
| 63 | + public void setUsername(String username) { | |
| 64 | + this.username = username; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public String getPassword() { | |
| 68 | + return password; | |
| 69 | + } | |
| 70 | + | |
| 71 | + public void setPassword(String password) { | |
| 72 | + this.password = password; | |
| 73 | + } | |
| 74 | +} | ... | ... |
impl/extension/jaas/src/main/java/br/gov/frameworkdemoiselle/security/JAASAuthenticator.java
0 → 100644
| ... | ... | @@ -0,0 +1,215 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package br.gov.frameworkdemoiselle.security; | |
| 38 | + | |
| 39 | +import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.EXTENSIONS_L1_PRIORITY; | |
| 40 | + | |
| 41 | +import java.io.IOException; | |
| 42 | +import java.security.SecurityPermission; | |
| 43 | + | |
| 44 | +import javax.enterprise.context.SessionScoped; | |
| 45 | +import javax.enterprise.inject.Produces; | |
| 46 | +import javax.inject.Inject; | |
| 47 | +import javax.security.auth.Subject; | |
| 48 | +import javax.security.auth.callback.Callback; | |
| 49 | +import javax.security.auth.callback.CallbackHandler; | |
| 50 | +import javax.security.auth.callback.NameCallback; | |
| 51 | +import javax.security.auth.callback.PasswordCallback; | |
| 52 | +import javax.security.auth.callback.UnsupportedCallbackException; | |
| 53 | +import javax.security.auth.login.LoginContext; | |
| 54 | +import javax.security.auth.login.LoginException; | |
| 55 | + | |
| 56 | +import org.slf4j.Logger; | |
| 57 | + | |
| 58 | +import br.gov.frameworkdemoiselle.annotation.Priority; | |
| 59 | +import br.gov.frameworkdemoiselle.internal.configuration.JAASConfig; | |
| 60 | +import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | |
| 61 | +import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | |
| 62 | +import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
| 63 | +import br.gov.frameworkdemoiselle.util.Strings; | |
| 64 | + | |
| 65 | +@SessionScoped | |
| 66 | +@Priority(EXTENSIONS_L1_PRIORITY) | |
| 67 | +public class JAASAuthenticator implements Authenticator { | |
| 68 | + | |
| 69 | + private static final long serialVersionUID = 1L; | |
| 70 | + | |
| 71 | + private static ResourceBundle bundle; | |
| 72 | + | |
| 73 | + private static Logger logger; | |
| 74 | + | |
| 75 | + private User user; | |
| 76 | + | |
| 77 | + private final Subject subject; | |
| 78 | + | |
| 79 | + @Inject | |
| 80 | + private JAASConfig config; | |
| 81 | + | |
| 82 | + @Inject | |
| 83 | + private Credentials credentials; | |
| 84 | + | |
| 85 | + public JAASAuthenticator() { | |
| 86 | + this.subject = new Subject(); | |
| 87 | + } | |
| 88 | + | |
| 89 | + @Override | |
| 90 | + public boolean authenticate() { | |
| 91 | + boolean result = false; | |
| 92 | + | |
| 93 | + try { | |
| 94 | + LoginContext loginContext = createLoginContext(); | |
| 95 | + | |
| 96 | + if (loginContext != null) { | |
| 97 | + loginContext.login(); | |
| 98 | + | |
| 99 | + this.user = createUser(this.credentials.getUsername()); | |
| 100 | + this.credentials.clear(); | |
| 101 | + | |
| 102 | + result = true; | |
| 103 | + } | |
| 104 | + | |
| 105 | + } catch (LoginException cause) { | |
| 106 | + getLogger().info(cause.getMessage()); | |
| 107 | + } | |
| 108 | + | |
| 109 | + return result; | |
| 110 | + } | |
| 111 | + | |
| 112 | + @Override | |
| 113 | + public void unAuthenticate() { | |
| 114 | + this.user = null; | |
| 115 | + } | |
| 116 | + | |
| 117 | + private User createUser(final String username) { | |
| 118 | + return new User() { | |
| 119 | + | |
| 120 | + private static final long serialVersionUID = 1L; | |
| 121 | + | |
| 122 | + @Override | |
| 123 | + public String getId() { | |
| 124 | + return username; | |
| 125 | + } | |
| 126 | + | |
| 127 | + @Override | |
| 128 | + public Object getAttribute(Object key) { | |
| 129 | + return null; | |
| 130 | + } | |
| 131 | + | |
| 132 | + @Override | |
| 133 | + public void setAttribute(Object key, Object value) { | |
| 134 | + } | |
| 135 | + }; | |
| 136 | + } | |
| 137 | + | |
| 138 | + @Override | |
| 139 | + public User getUser() { | |
| 140 | + try { | |
| 141 | + | |
| 142 | +// LoginContext | |
| 143 | + | |
| 144 | +// AbstractSecurityContext. | |
| 145 | + | |
| 146 | +// Object securityContext = System.getSecurityManager().getSecurityContext(); | |
| 147 | + | |
| 148 | +// System.out.println(securityContext.toString()); | |
| 149 | + | |
| 150 | + String name = config.getLoginModuleName(); | |
| 151 | + LoginContext loginContext = new LoginContext(name, this.subject); | |
| 152 | + loginContext.login(); | |
| 153 | + | |
| 154 | + Subject subject2 = loginContext.getSubject(); | |
| 155 | + | |
| 156 | + System.out.println(subject2.toString()); | |
| 157 | + | |
| 158 | + } catch (LoginException e) { | |
| 159 | + // TODO Auto-generated catch block | |
| 160 | + e.printStackTrace(); | |
| 161 | + } | |
| 162 | + | |
| 163 | + return this.user; | |
| 164 | + } | |
| 165 | + | |
| 166 | + @Produces | |
| 167 | + public Subject getSubject() { | |
| 168 | + return this.subject; | |
| 169 | + } | |
| 170 | + | |
| 171 | + public LoginContext createLoginContext() throws LoginException { | |
| 172 | + String name = config.getLoginModuleName(); | |
| 173 | + | |
| 174 | + if (Strings.isEmpty(name)) { | |
| 175 | + throw new SecurityException(getBundle().getString("required-login-module-name")); | |
| 176 | + } | |
| 177 | + | |
| 178 | + return new LoginContext(name, this.subject, createCallbackHandler()); | |
| 179 | + } | |
| 180 | + | |
| 181 | + private CallbackHandler createCallbackHandler() { | |
| 182 | + return new CallbackHandler() { | |
| 183 | + | |
| 184 | + public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { | |
| 185 | + for (int i = 0; i < callbacks.length; i++) { | |
| 186 | + if (callbacks[i] instanceof NameCallback) { | |
| 187 | + ((NameCallback) callbacks[i]).setName(credentials.getUsername()); | |
| 188 | + | |
| 189 | + } else if (callbacks[i] instanceof PasswordCallback) { | |
| 190 | + ((PasswordCallback) callbacks[i]).setPassword(credentials.getPassword().toCharArray()); | |
| 191 | + | |
| 192 | + } else { | |
| 193 | + getLogger().error(getBundle().getString("unsupported-callback", callbacks[i])); | |
| 194 | + } | |
| 195 | + } | |
| 196 | + } | |
| 197 | + }; | |
| 198 | + } | |
| 199 | + | |
| 200 | + private static ResourceBundle getBundle() { | |
| 201 | + if (bundle == null) { | |
| 202 | + bundle = ResourceBundleProducer.create("demoiselle-jaas-bundle"); | |
| 203 | + } | |
| 204 | + | |
| 205 | + return bundle; | |
| 206 | + } | |
| 207 | + | |
| 208 | + private static Logger getLogger() { | |
| 209 | + if (logger == null) { | |
| 210 | + logger = LoggerProducer.create(JAASAuthenticator.class); | |
| 211 | + } | |
| 212 | + | |
| 213 | + return logger; | |
| 214 | + } | |
| 215 | +} | ... | ... |
impl/extension/jaas/src/main/java/br/gov/frameworkdemoiselle/security/JAASAuthorizer.java
0 → 100644
| ... | ... | @@ -0,0 +1,102 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package br.gov.frameworkdemoiselle.security; | |
| 38 | + | |
| 39 | +import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.EXTENSIONS_L1_PRIORITY; | |
| 40 | + | |
| 41 | +import java.security.Principal; | |
| 42 | +import java.security.acl.Group; | |
| 43 | +import java.util.Enumeration; | |
| 44 | + | |
| 45 | +import javax.security.auth.Subject; | |
| 46 | + | |
| 47 | +import br.gov.frameworkdemoiselle.DemoiselleException; | |
| 48 | +import br.gov.frameworkdemoiselle.annotation.Priority; | |
| 49 | +import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | |
| 50 | +import br.gov.frameworkdemoiselle.util.Beans; | |
| 51 | +import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
| 52 | + | |
| 53 | +@Priority(EXTENSIONS_L1_PRIORITY) | |
| 54 | +public class JAASAuthorizer implements Authorizer { | |
| 55 | + | |
| 56 | + private static final long serialVersionUID = 1L; | |
| 57 | + | |
| 58 | + private static ResourceBundle bundle; | |
| 59 | + | |
| 60 | + @Override | |
| 61 | + public boolean hasRole(String role) { | |
| 62 | + boolean result = false; | |
| 63 | + | |
| 64 | + Group group; | |
| 65 | + Principal member; | |
| 66 | + Enumeration<? extends Principal> enumeration; | |
| 67 | + Subject subject = Beans.getReference(Subject.class); | |
| 68 | + | |
| 69 | + for (Principal principal : subject.getPrincipals()) { | |
| 70 | + | |
| 71 | + if (principal instanceof Group) { | |
| 72 | + group = (Group) principal; | |
| 73 | + enumeration = group.members(); | |
| 74 | + | |
| 75 | + while (enumeration.hasMoreElements()) { | |
| 76 | + member = (Principal) enumeration.nextElement(); | |
| 77 | + | |
| 78 | + if (member.getName().equals(role)) { | |
| 79 | + result = true; | |
| 80 | + break; | |
| 81 | + } | |
| 82 | + } | |
| 83 | + } | |
| 84 | + } | |
| 85 | + | |
| 86 | + return result; | |
| 87 | + } | |
| 88 | + | |
| 89 | + @Override | |
| 90 | + public boolean hasPermission(String resource, String operation) { | |
| 91 | + throw new DemoiselleException(getBundle().getString("has-permission-not-supported", | |
| 92 | + RequiredPermission.class.getSimpleName())); | |
| 93 | + } | |
| 94 | + | |
| 95 | + private static ResourceBundle getBundle() { | |
| 96 | + if (bundle == null) { | |
| 97 | + bundle = ResourceBundleProducer.create("demoiselle-jaas-bundle"); | |
| 98 | + } | |
| 99 | + | |
| 100 | + return bundle; | |
| 101 | + } | |
| 102 | +} | ... | ... |
impl/extension/jaas/src/main/resources/META-INF/beans.xml
0 → 100644
| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | +<!-- | |
| 2 | + Demoiselle Framework | |
| 3 | + Copyright (C) 2010 SERPRO | |
| 4 | + ============================================================================ | |
| 5 | + This file is part of Demoiselle Framework. | |
| 6 | + | |
| 7 | + Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + as published by the Free Software Foundation. | |
| 10 | + | |
| 11 | + This program is distributed in the hope that it will be useful, | |
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + GNU General Public License for more details. | |
| 15 | + | |
| 16 | + You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + ============================================================================ | |
| 21 | + Este arquivo é parte do Framework Demoiselle. | |
| 22 | + | |
| 23 | + O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + do Software Livre (FSF). | |
| 26 | + | |
| 27 | + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + para maiores detalhes. | |
| 31 | + | |
| 32 | + Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | +--> | |
| 37 | +<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 38 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> | |
| 39 | + | |
| 40 | +</beans> | |
| 0 | 41 | \ No newline at end of file | ... | ... |
impl/extension/jaas/src/main/resources/demoiselle-jaas-bundle.properties
0 → 100644
| ... | ... | @@ -0,0 +1,38 @@ |
| 1 | +# Demoiselle Framework | |
| 2 | +# Copyright (C) 2010 SERPRO | |
| 3 | +# ---------------------------------------------------------------------------- | |
| 4 | +# This file is part of Demoiselle Framework. | |
| 5 | +# | |
| 6 | +# Demoiselle Framework is free software; you can redistribute it and/or | |
| 7 | +# modify it under the terms of the GNU Lesser General Public License version 3 | |
| 8 | +# as published by the Free Software Foundation. | |
| 9 | +# | |
| 10 | +# This program is distributed in the hope that it will be useful, | |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | +# GNU General Public License for more details. | |
| 14 | +# | |
| 15 | +# You should have received a copy of the GNU Lesser General Public License version 3 | |
| 16 | +# along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 17 | +# or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 18 | +# Fifth Floor, Boston, MA 02110-1301, USA. | |
| 19 | +# ---------------------------------------------------------------------------- | |
| 20 | +# Este arquivo é parte do Framework Demoiselle. | |
| 21 | +# | |
| 22 | +# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 23 | +# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 24 | +# do Software Livre (FSF). | |
| 25 | +# | |
| 26 | +# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 27 | +# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 28 | +# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 29 | +# para maiores detalhes. | |
| 30 | +# | |
| 31 | +# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 32 | +# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 33 | +# ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 34 | +# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 35 | + | |
| 36 | +has-permission-not-supported=N\u00E3o \u00E9 poss\u00EDvel utilizar @{0}, pois esta funcionalidade n\u00E3o \u00E9 suportada pelo JAAS | |
| 37 | +unsupported-callback=Callback n\u00E3o suportado\: {0} | |
| 38 | +required-login-module-name=\u00C9 preciso definir a propriedade frameworkdemoiselle.security.login.module.name no arquivo demoiselle.properties | ... | ... |
| ... | ... | @@ -0,0 +1,100 @@ |
| 1 | +<!-- | |
| 2 | + Demoiselle Framework | |
| 3 | + Copyright (C) 2010 SERPRO | |
| 4 | + ============================================================================ | |
| 5 | + This file is part of Demoiselle Framework. | |
| 6 | + | |
| 7 | + Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + as published by the Free Software Foundation. | |
| 10 | + | |
| 11 | + This program is distributed in the hope that it will be useful, | |
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + GNU General Public License for more details. | |
| 15 | + | |
| 16 | + You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + along with this program; if not, see <http://www.gnu.org/licenses /> | |
| 18 | + or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + ============================================================================ | |
| 21 | + Este arquivo é parte do Framework Demoiselle. | |
| 22 | + | |
| 23 | + O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + do Software Livre (FSF). | |
| 26 | + | |
| 27 | + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + para maiores detalhes. | |
| 31 | + | |
| 32 | + Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses /> | |
| 34 | + ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | +--> | |
| 37 | +<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"> | |
| 38 | + | |
| 39 | + <modelVersion>4.0.0</modelVersion> | |
| 40 | + | |
| 41 | + <artifactId>demoiselle-jdbc</artifactId> | |
| 42 | + <packaging>jar</packaging> | |
| 43 | + | |
| 44 | + <parent> | |
| 45 | + <groupId>br.gov.frameworkdemoiselle</groupId> | |
| 46 | + <artifactId>demoiselle-extension-parent</artifactId> | |
| 47 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 48 | + <relativePath>../../../parent/extension</relativePath> | |
| 49 | + </parent> | |
| 50 | + | |
| 51 | + <name>Demoiselle Framework JDBC Extension</name> | |
| 52 | + <description> | |
| 53 | + Demoiselle Framework JDBC Extension | |
| 54 | + </description> | |
| 55 | + <url>http://www.frameworkdemoiselle.gov.br</url> | |
| 56 | + | |
| 57 | + <licenses> | |
| 58 | + <license> | |
| 59 | + <name>GNU Lesser General Public License, Version 3</name> | |
| 60 | + <url>http://www.gnu.org/licenses/lgpl-3.0.txt</url> | |
| 61 | + </license> | |
| 62 | + </licenses> | |
| 63 | + | |
| 64 | + <organization> | |
| 65 | + <name>SERPRO - Serviço Federal de Processamento de Dados</name> | |
| 66 | + <url>http://www.serpro.gov.br</url> | |
| 67 | + </organization> | |
| 68 | + | |
| 69 | + <dependencies> | |
| 70 | + <dependency> | |
| 71 | + <groupId>commons-dbcp</groupId> | |
| 72 | + <artifactId>commons-dbcp</artifactId> | |
| 73 | + </dependency> | |
| 74 | + </dependencies> | |
| 75 | + | |
| 76 | + <repositories> | |
| 77 | + <repository> | |
| 78 | + <id>sonatype-nexus-snapshots</id> | |
| 79 | + <name>Sonatype Nexus Snapshots</name> | |
| 80 | + <url>https://oss.sonatype.org/content/repositories/snapshots</url> | |
| 81 | + <snapshots> | |
| 82 | + <enabled>true</enabled> | |
| 83 | + </snapshots> | |
| 84 | + <releases> | |
| 85 | + <enabled>false</enabled> | |
| 86 | + </releases> | |
| 87 | + </repository> | |
| 88 | + <repository> | |
| 89 | + <id>sonatype-nexus-releases</id> | |
| 90 | + <name>Sonatype Nexus Releases</name> | |
| 91 | + <url>https://oss.sonatype.org/content/repositories/releases</url> | |
| 92 | + <snapshots> | |
| 93 | + <enabled>false</enabled> | |
| 94 | + </snapshots> | |
| 95 | + <releases> | |
| 96 | + <enabled>true</enabled> | |
| 97 | + </releases> | |
| 98 | + </repository> | |
| 99 | + </repositories> | |
| 100 | +</project> | ... | ... |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/JDBCConfig.java
0 → 100644
| ... | ... | @@ -0,0 +1,91 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package br.gov.frameworkdemoiselle.internal.configuration; | |
| 38 | + | |
| 39 | +import java.io.Serializable; | |
| 40 | +import java.util.Map; | |
| 41 | + | |
| 42 | +import br.gov.frameworkdemoiselle.annotation.Name; | |
| 43 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | |
| 44 | + | |
| 45 | +@Configuration(prefix = "frameworkdemoiselle.persistence.") | |
| 46 | +public class JDBCConfig implements Serializable { | |
| 47 | + | |
| 48 | + private static final long serialVersionUID = 1L; | |
| 49 | + | |
| 50 | + @Name("default.datasource.name") | |
| 51 | + private String defaultDataDourceName; | |
| 52 | + | |
| 53 | + @Name("jndi.name") | |
| 54 | + private Map<String, String> jndiName; | |
| 55 | + | |
| 56 | + @Name("driver.class") | |
| 57 | + private Map<String, String> driverClass; | |
| 58 | + | |
| 59 | + @Name("url") | |
| 60 | + private Map<String, String> url; | |
| 61 | + | |
| 62 | + @Name("username") | |
| 63 | + private Map<String, String> username; | |
| 64 | + | |
| 65 | + @Name("password") | |
| 66 | + private Map<String, String> password; | |
| 67 | + | |
| 68 | + public String getDefaultDataDourceName() { | |
| 69 | + return defaultDataDourceName; | |
| 70 | + } | |
| 71 | + | |
| 72 | + public Map<String, String> getJndiName() { | |
| 73 | + return jndiName; | |
| 74 | + } | |
| 75 | + | |
| 76 | + public Map<String, String> getDriverClass() { | |
| 77 | + return driverClass; | |
| 78 | + } | |
| 79 | + | |
| 80 | + public Map<String, String> getUrl() { | |
| 81 | + return url; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public Map<String, String> getUsername() { | |
| 85 | + return username; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public Map<String, String> getPassword() { | |
| 89 | + return password; | |
| 90 | + } | |
| 91 | +} | ... | ... |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/internal/producer/ConnectionProducer.java
0 → 100644
| ... | ... | @@ -0,0 +1,160 @@ |
| 1 | +package br.gov.frameworkdemoiselle.internal.producer; | |
| 2 | + | |
| 3 | +import java.io.Serializable; | |
| 4 | +import java.sql.Connection; | |
| 5 | +import java.sql.SQLException; | |
| 6 | +import java.util.Collections; | |
| 7 | +import java.util.HashMap; | |
| 8 | +import java.util.Map; | |
| 9 | +import java.util.Set; | |
| 10 | + | |
| 11 | +import javax.annotation.PostConstruct; | |
| 12 | +import javax.annotation.PreDestroy; | |
| 13 | +import javax.enterprise.context.RequestScoped; | |
| 14 | +import javax.enterprise.inject.Default; | |
| 15 | +import javax.enterprise.inject.Produces; | |
| 16 | +import javax.enterprise.inject.spi.InjectionPoint; | |
| 17 | +import javax.inject.Inject; | |
| 18 | + | |
| 19 | +import org.slf4j.Logger; | |
| 20 | + | |
| 21 | +import br.gov.frameworkdemoiselle.DemoiselleException; | |
| 22 | +import br.gov.frameworkdemoiselle.annotation.Name; | |
| 23 | +import br.gov.frameworkdemoiselle.internal.configuration.JDBCConfig; | |
| 24 | +import br.gov.frameworkdemoiselle.internal.proxy.ConnectionProxy; | |
| 25 | +import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
| 26 | + | |
| 27 | +@RequestScoped | |
| 28 | +public class ConnectionProducer implements Serializable { | |
| 29 | + | |
| 30 | + private static final long serialVersionUID = 1L; | |
| 31 | + | |
| 32 | + @Inject | |
| 33 | + private Logger logger; | |
| 34 | + | |
| 35 | + @Inject | |
| 36 | + @Name("demoiselle-jdbc-bundle") | |
| 37 | + private ResourceBundle bundle; | |
| 38 | + | |
| 39 | + private final Map<String, Connection> cache = Collections.synchronizedMap(new HashMap<String, Connection>()); | |
| 40 | + | |
| 41 | + @Inject | |
| 42 | + private DataSourceProducer producer; | |
| 43 | + | |
| 44 | + @PostConstruct | |
| 45 | + public void init() { | |
| 46 | + for (String name : producer.getCache().keySet()) { | |
| 47 | + getConnection(name); | |
| 48 | + } | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Default | |
| 52 | + @Produces | |
| 53 | + public Connection create(InjectionPoint ip, JDBCConfig config) { | |
| 54 | + String name = getName(ip, config); | |
| 55 | + return new ConnectionProxy(name); | |
| 56 | + } | |
| 57 | + | |
| 58 | + public Connection getConnection(String name) { | |
| 59 | + Connection connection = null; | |
| 60 | + | |
| 61 | + if (cache.containsKey(name)) { | |
| 62 | + connection = cache.get(name); | |
| 63 | + | |
| 64 | + } else { | |
| 65 | + try { | |
| 66 | + connection = producer.create(name).getConnection(); | |
| 67 | + disableAutoCommit(connection); | |
| 68 | + | |
| 69 | + cache.put(name, connection); | |
| 70 | + logger.info(bundle.getString("connection-was-created", name)); | |
| 71 | + | |
| 72 | + } catch (Exception cause) { | |
| 73 | + // TODO Colocar uma mensagem amigável | |
| 74 | + throw new DemoiselleException(cause); | |
| 75 | + } | |
| 76 | + } | |
| 77 | + | |
| 78 | + return connection; | |
| 79 | + } | |
| 80 | + | |
| 81 | + private void disableAutoCommit(Connection connection) { | |
| 82 | + try { | |
| 83 | + connection.setAutoCommit(false); | |
| 84 | + | |
| 85 | + } catch (SQLException cause) { | |
| 86 | + logger.debug(bundle.getString("set-autocommit-failed")); | |
| 87 | + } | |
| 88 | + } | |
| 89 | + | |
| 90 | + private String getName(InjectionPoint ip, JDBCConfig config) { | |
| 91 | + String result; | |
| 92 | + | |
| 93 | + if (ip != null && ip.getAnnotated() != null && ip.getAnnotated().isAnnotationPresent(Name.class)) { | |
| 94 | + result = ip.getAnnotated().getAnnotation(Name.class).value(); | |
| 95 | + | |
| 96 | + } else { | |
| 97 | + result = getNameFromProperties(config); | |
| 98 | + | |
| 99 | + if (result == null) { | |
| 100 | + result = getNameFromCache(); | |
| 101 | + } | |
| 102 | + } | |
| 103 | + | |
| 104 | + return result; | |
| 105 | + } | |
| 106 | + | |
| 107 | + private String getNameFromProperties(JDBCConfig config) { | |
| 108 | + String result = config.getDefaultDataDourceName(); | |
| 109 | + | |
| 110 | + if (result != null) { | |
| 111 | + logger.debug(bundle.getString("getting-default-datasource-name-from-properties", result)); | |
| 112 | + } | |
| 113 | + | |
| 114 | + return result; | |
| 115 | + } | |
| 116 | + | |
| 117 | + private String getNameFromCache() { | |
| 118 | + String result; | |
| 119 | + Set<String> names = producer.getCache().keySet(); | |
| 120 | + | |
| 121 | + if (names.size() > 1) { | |
| 122 | + throw new DemoiselleException(bundle.getString("more-than-one-datasource-defined", | |
| 123 | + Name.class.getSimpleName())); | |
| 124 | + } else { | |
| 125 | + result = names.iterator().next(); | |
| 126 | + } | |
| 127 | + | |
| 128 | + return result; | |
| 129 | + } | |
| 130 | + | |
| 131 | + @PreDestroy | |
| 132 | + public void close() { | |
| 133 | + Connection connection; | |
| 134 | + | |
| 135 | + for (String key : cache.keySet()) { | |
| 136 | + connection = cache.get(key); | |
| 137 | + | |
| 138 | + try { | |
| 139 | + if (connection.isClosed()) { | |
| 140 | + logger.warn(bundle.getString("connection-has-already-been-closed", key)); | |
| 141 | + | |
| 142 | + } else { | |
| 143 | + connection.close(); | |
| 144 | + | |
| 145 | + logger.info(bundle.getString("connection-was-closed", key)); | |
| 146 | + } | |
| 147 | + | |
| 148 | + } catch (Exception cause) { | |
| 149 | + throw new DemoiselleException(bundle.getString("connection-close-failed", key), cause); | |
| 150 | + } | |
| 151 | + } | |
| 152 | + | |
| 153 | + cache.clear(); | |
| 154 | + } | |
| 155 | + | |
| 156 | + public Map<String, Connection> getCache() { | |
| 157 | + return cache; | |
| 158 | + } | |
| 159 | + | |
| 160 | +} | ... | ... |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/internal/producer/DataSourceProducer.java
0 → 100644
| ... | ... | @@ -0,0 +1,164 @@ |
| 1 | +package br.gov.frameworkdemoiselle.internal.producer; | |
| 2 | + | |
| 3 | +import java.io.Serializable; | |
| 4 | +import java.util.Collections; | |
| 5 | +import java.util.HashMap; | |
| 6 | +import java.util.HashSet; | |
| 7 | +import java.util.Map; | |
| 8 | +import java.util.Set; | |
| 9 | + | |
| 10 | +import javax.annotation.PostConstruct; | |
| 11 | +import javax.annotation.PreDestroy; | |
| 12 | +import javax.enterprise.context.ApplicationScoped; | |
| 13 | +import javax.inject.Inject; | |
| 14 | +import javax.naming.Context; | |
| 15 | +import javax.naming.InitialContext; | |
| 16 | +import javax.naming.NamingException; | |
| 17 | +import javax.sql.DataSource; | |
| 18 | + | |
| 19 | +import org.slf4j.Logger; | |
| 20 | + | |
| 21 | +import br.gov.frameworkdemoiselle.DemoiselleException; | |
| 22 | +import br.gov.frameworkdemoiselle.annotation.Name; | |
| 23 | +import br.gov.frameworkdemoiselle.internal.configuration.JDBCConfig; | |
| 24 | +import br.gov.frameworkdemoiselle.transaction.BasicDataSourceProxy; | |
| 25 | +import br.gov.frameworkdemoiselle.util.Beans; | |
| 26 | +import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
| 27 | + | |
| 28 | +@ApplicationScoped | |
| 29 | +public class DataSourceProducer implements Serializable { | |
| 30 | + | |
| 31 | + private static final long serialVersionUID = 1L; | |
| 32 | + | |
| 33 | + @Inject | |
| 34 | + private Logger logger; | |
| 35 | + | |
| 36 | + @Inject | |
| 37 | + @Name("demoiselle-jdbc-bundle") | |
| 38 | + private ResourceBundle bundle; | |
| 39 | + | |
| 40 | + private final Map<ClassLoader, Map<String, DataSource>> cache = Collections | |
| 41 | + .synchronizedMap(new HashMap<ClassLoader, Map<String, DataSource>>()); | |
| 42 | + | |
| 43 | + @PostConstruct | |
| 44 | + public void loadDataSources() { | |
| 45 | + ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); | |
| 46 | + | |
| 47 | + for (String dataBaseName : getDataSourceNames(contextClassLoader)) { | |
| 48 | + | |
| 49 | + try { | |
| 50 | + create(dataBaseName); | |
| 51 | + } catch (Throwable t) { | |
| 52 | + throw new DemoiselleException(t); | |
| 53 | + } | |
| 54 | + | |
| 55 | + logger.debug(bundle.getString("datasource-name-found", dataBaseName)); | |
| 56 | + } | |
| 57 | + } | |
| 58 | + | |
| 59 | + private Set<String> getDataSourceNames(ClassLoader classLoader) { | |
| 60 | + Set<String> result = new HashSet<String>(); | |
| 61 | + | |
| 62 | + JDBCConfig config = Beans.getReference(JDBCConfig.class); | |
| 63 | + | |
| 64 | + if (config.getJndiName() != null) { | |
| 65 | + result.addAll(config.getJndiName().keySet()); | |
| 66 | + } | |
| 67 | + | |
| 68 | + if (config.getDriverClass() != null) { | |
| 69 | + result.addAll(config.getDriverClass().keySet()); | |
| 70 | + } | |
| 71 | + | |
| 72 | + if (result.isEmpty()) { | |
| 73 | + throw new DemoiselleException(bundle.getString("datasource-name-not-found")); | |
| 74 | + } | |
| 75 | + | |
| 76 | + return result; | |
| 77 | + } | |
| 78 | + | |
| 79 | + public DataSource create(String dataSourceName) { | |
| 80 | + DataSource factory; | |
| 81 | + | |
| 82 | + ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); | |
| 83 | + Map<String, DataSource> localCache; | |
| 84 | + | |
| 85 | + if (cache.containsKey(contextClassLoader)) { | |
| 86 | + localCache = cache.get(contextClassLoader); | |
| 87 | + | |
| 88 | + if (localCache.containsKey(dataSourceName)) { | |
| 89 | + factory = localCache.get(dataSourceName); | |
| 90 | + | |
| 91 | + } else { | |
| 92 | + factory = initDataSource(dataSourceName); | |
| 93 | + | |
| 94 | + localCache.put(dataSourceName, factory); | |
| 95 | + cache.put(contextClassLoader, localCache); | |
| 96 | + } | |
| 97 | + | |
| 98 | + } else { | |
| 99 | + localCache = new HashMap<String, DataSource>(); | |
| 100 | + factory = initDataSource(dataSourceName); | |
| 101 | + | |
| 102 | + localCache.put(dataSourceName, factory); | |
| 103 | + cache.put(contextClassLoader, localCache); | |
| 104 | + } | |
| 105 | + | |
| 106 | + return factory; | |
| 107 | + } | |
| 108 | + | |
| 109 | + private DataSource initDataSource(String dataSourceName) { | |
| 110 | + DataSource result; | |
| 111 | + | |
| 112 | + JDBCConfig config = Beans.getReference(JDBCConfig.class); | |
| 113 | + Map<String, String> jndiMap = config.getJndiName(); | |
| 114 | + | |
| 115 | + if (jndiMap != null) { | |
| 116 | + result = initJNDIDataSource(dataSourceName, config); | |
| 117 | + | |
| 118 | + } else { | |
| 119 | + result = new BasicDataSourceProxy(dataSourceName, config, bundle); | |
| 120 | + } | |
| 121 | + | |
| 122 | + return result; | |
| 123 | + } | |
| 124 | + | |
| 125 | + private DataSource initJNDIDataSource(String dataSourceName, JDBCConfig config) { | |
| 126 | + DataSource result = null; | |
| 127 | + | |
| 128 | + try { | |
| 129 | + Context context = new InitialContext(); | |
| 130 | + String jndi = config.getJndiName().get(dataSourceName); | |
| 131 | + | |
| 132 | + result = (DataSource) context.lookup(jndi); | |
| 133 | + | |
| 134 | + } catch (NamingException cause) { | |
| 135 | + throw new DemoiselleException(bundle.getString("load-jndi-datasource-failed", dataSourceName), cause); | |
| 136 | + | |
| 137 | + } catch (ClassCastException cause) { | |
| 138 | + throw new DemoiselleException(bundle.getString("load-duplicated-configuration-failed"), cause); | |
| 139 | + } | |
| 140 | + | |
| 141 | + return result; | |
| 142 | + } | |
| 143 | + | |
| 144 | + @PreDestroy | |
| 145 | + public void close() { | |
| 146 | + cache.clear(); | |
| 147 | + } | |
| 148 | + | |
| 149 | + public Map<String, DataSource> getCache() { | |
| 150 | + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | |
| 151 | + Map<String, DataSource> result = cache.get(classLoader); | |
| 152 | + | |
| 153 | + if (result == null || result.isEmpty()) { | |
| 154 | + logger.debug(bundle.getString("datasource-not-found-in-cache")); | |
| 155 | + | |
| 156 | + for (String name : getDataSourceNames(classLoader)) { | |
| 157 | + create(name); | |
| 158 | + result = cache.get(classLoader); | |
| 159 | + } | |
| 160 | + } | |
| 161 | + | |
| 162 | + return result; | |
| 163 | + } | |
| 164 | +} | ... | ... |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/ConnectionProxy.java
0 → 100644
| ... | ... | @@ -0,0 +1,239 @@ |
| 1 | +package br.gov.frameworkdemoiselle.internal.proxy; | |
| 2 | + | |
| 3 | +import java.io.Serializable; | |
| 4 | +import java.sql.Array; | |
| 5 | +import java.sql.Blob; | |
| 6 | +import java.sql.CallableStatement; | |
| 7 | +import java.sql.Clob; | |
| 8 | +import java.sql.Connection; | |
| 9 | +import java.sql.DatabaseMetaData; | |
| 10 | +import java.sql.NClob; | |
| 11 | +import java.sql.PreparedStatement; | |
| 12 | +import java.sql.SQLClientInfoException; | |
| 13 | +import java.sql.SQLException; | |
| 14 | +import java.sql.SQLWarning; | |
| 15 | +import java.sql.SQLXML; | |
| 16 | +import java.sql.Savepoint; | |
| 17 | +import java.sql.Statement; | |
| 18 | +import java.sql.Struct; | |
| 19 | +import java.util.Map; | |
| 20 | +import java.util.Properties; | |
| 21 | + | |
| 22 | +import br.gov.frameworkdemoiselle.internal.producer.ConnectionProducer; | |
| 23 | +import br.gov.frameworkdemoiselle.util.Beans; | |
| 24 | + | |
| 25 | +public class ConnectionProxy implements Connection, Serializable { | |
| 26 | + | |
| 27 | + private static final long serialVersionUID = 1L; | |
| 28 | + | |
| 29 | + private final String dataSourceName; | |
| 30 | + | |
| 31 | + public ConnectionProxy(String dataSourceName) { | |
| 32 | + this.dataSourceName = dataSourceName; | |
| 33 | + } | |
| 34 | + | |
| 35 | + private Connection getDelegate() { | |
| 36 | + ConnectionProducer emp = Beans.getReference(ConnectionProducer.class); | |
| 37 | + return emp.getConnection(this.dataSourceName); | |
| 38 | + } | |
| 39 | + | |
| 40 | + public void clearWarnings() throws SQLException { | |
| 41 | + getDelegate().clearWarnings(); | |
| 42 | + } | |
| 43 | + | |
| 44 | + public void close() throws SQLException { | |
| 45 | + getDelegate().close(); | |
| 46 | + } | |
| 47 | + | |
| 48 | + public void commit() throws SQLException { | |
| 49 | + getDelegate().commit(); | |
| 50 | + } | |
| 51 | + | |
| 52 | + public Array createArrayOf(String typeName, Object[] elements) throws SQLException { | |
| 53 | + return getDelegate().createArrayOf(typeName, elements); | |
| 54 | + } | |
| 55 | + | |
| 56 | + public Blob createBlob() throws SQLException { | |
| 57 | + return getDelegate().createBlob(); | |
| 58 | + } | |
| 59 | + | |
| 60 | + public Clob createClob() throws SQLException { | |
| 61 | + return getDelegate().createClob(); | |
| 62 | + } | |
| 63 | + | |
| 64 | + public NClob createNClob() throws SQLException { | |
| 65 | + return getDelegate().createNClob(); | |
| 66 | + } | |
| 67 | + | |
| 68 | + public SQLXML createSQLXML() throws SQLException { | |
| 69 | + return getDelegate().createSQLXML(); | |
| 70 | + } | |
| 71 | + | |
| 72 | + public Statement createStatement() throws SQLException { | |
| 73 | + return getDelegate().createStatement(); | |
| 74 | + } | |
| 75 | + | |
| 76 | + public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) | |
| 77 | + throws SQLException { | |
| 78 | + return getDelegate().createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); | |
| 79 | + } | |
| 80 | + | |
| 81 | + public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { | |
| 82 | + return getDelegate().createStatement(resultSetType, resultSetConcurrency); | |
| 83 | + } | |
| 84 | + | |
| 85 | + public Struct createStruct(String typeName, Object[] attributes) throws SQLException { | |
| 86 | + return getDelegate().createStruct(typeName, attributes); | |
| 87 | + } | |
| 88 | + | |
| 89 | + public boolean getAutoCommit() throws SQLException { | |
| 90 | + return getDelegate().getAutoCommit(); | |
| 91 | + } | |
| 92 | + | |
| 93 | + public String getCatalog() throws SQLException { | |
| 94 | + return getDelegate().getCatalog(); | |
| 95 | + } | |
| 96 | + | |
| 97 | + public Properties getClientInfo() throws SQLException { | |
| 98 | + return getDelegate().getClientInfo(); | |
| 99 | + } | |
| 100 | + | |
| 101 | + public String getClientInfo(String name) throws SQLException { | |
| 102 | + return getDelegate().getClientInfo(name); | |
| 103 | + } | |
| 104 | + | |
| 105 | + public int getHoldability() throws SQLException { | |
| 106 | + return getDelegate().getHoldability(); | |
| 107 | + } | |
| 108 | + | |
| 109 | + public DatabaseMetaData getMetaData() throws SQLException { | |
| 110 | + return getDelegate().getMetaData(); | |
| 111 | + } | |
| 112 | + | |
| 113 | + public int getTransactionIsolation() throws SQLException { | |
| 114 | + return getDelegate().getTransactionIsolation(); | |
| 115 | + } | |
| 116 | + | |
| 117 | + public Map<String, Class<?>> getTypeMap() throws SQLException { | |
| 118 | + return getDelegate().getTypeMap(); | |
| 119 | + } | |
| 120 | + | |
| 121 | + public SQLWarning getWarnings() throws SQLException { | |
| 122 | + return getDelegate().getWarnings(); | |
| 123 | + } | |
| 124 | + | |
| 125 | + public boolean isClosed() throws SQLException { | |
| 126 | + return getDelegate().isClosed(); | |
| 127 | + } | |
| 128 | + | |
| 129 | + public boolean isReadOnly() throws SQLException { | |
| 130 | + return getDelegate().isReadOnly(); | |
| 131 | + } | |
| 132 | + | |
| 133 | + public boolean isValid(int timeout) throws SQLException { | |
| 134 | + return getDelegate().isValid(timeout); | |
| 135 | + } | |
| 136 | + | |
| 137 | + public boolean isWrapperFor(Class<?> iface) throws SQLException { | |
| 138 | + return getDelegate().isWrapperFor(iface); | |
| 139 | + } | |
| 140 | + | |
| 141 | + public String nativeSQL(String sql) throws SQLException { | |
| 142 | + return getDelegate().nativeSQL(sql); | |
| 143 | + } | |
| 144 | + | |
| 145 | + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, | |
| 146 | + int resultSetHoldability) throws SQLException { | |
| 147 | + return getDelegate().prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); | |
| 148 | + } | |
| 149 | + | |
| 150 | + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { | |
| 151 | + return getDelegate().prepareCall(sql, resultSetType, resultSetConcurrency); | |
| 152 | + } | |
| 153 | + | |
| 154 | + public CallableStatement prepareCall(String sql) throws SQLException { | |
| 155 | + return getDelegate().prepareCall(sql); | |
| 156 | + } | |
| 157 | + | |
| 158 | + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, | |
| 159 | + int resultSetHoldability) throws SQLException { | |
| 160 | + return getDelegate().prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); | |
| 161 | + } | |
| 162 | + | |
| 163 | + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) | |
| 164 | + throws SQLException { | |
| 165 | + return getDelegate().prepareStatement(sql, resultSetType, resultSetConcurrency); | |
| 166 | + } | |
| 167 | + | |
| 168 | + public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { | |
| 169 | + return getDelegate().prepareStatement(sql, autoGeneratedKeys); | |
| 170 | + } | |
| 171 | + | |
| 172 | + public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { | |
| 173 | + return getDelegate().prepareStatement(sql, columnIndexes); | |
| 174 | + } | |
| 175 | + | |
| 176 | + public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { | |
| 177 | + return getDelegate().prepareStatement(sql, columnNames); | |
| 178 | + } | |
| 179 | + | |
| 180 | + public PreparedStatement prepareStatement(String sql) throws SQLException { | |
| 181 | + return getDelegate().prepareStatement(sql); | |
| 182 | + } | |
| 183 | + | |
| 184 | + public void releaseSavepoint(Savepoint savepoint) throws SQLException { | |
| 185 | + getDelegate().releaseSavepoint(savepoint); | |
| 186 | + } | |
| 187 | + | |
| 188 | + public void rollback() throws SQLException { | |
| 189 | + getDelegate().rollback(); | |
| 190 | + } | |
| 191 | + | |
| 192 | + public void rollback(Savepoint savepoint) throws SQLException { | |
| 193 | + getDelegate().rollback(savepoint); | |
| 194 | + } | |
| 195 | + | |
| 196 | + public void setAutoCommit(boolean autoCommit) throws SQLException { | |
| 197 | + getDelegate().setAutoCommit(autoCommit); | |
| 198 | + } | |
| 199 | + | |
| 200 | + public void setCatalog(String catalog) throws SQLException { | |
| 201 | + getDelegate().setCatalog(catalog); | |
| 202 | + } | |
| 203 | + | |
| 204 | + public void setClientInfo(Properties properties) throws SQLClientInfoException { | |
| 205 | + getDelegate().setClientInfo(properties); | |
| 206 | + } | |
| 207 | + | |
| 208 | + public void setClientInfo(String name, String value) throws SQLClientInfoException { | |
| 209 | + getDelegate().setClientInfo(name, value); | |
| 210 | + } | |
| 211 | + | |
| 212 | + public void setHoldability(int holdability) throws SQLException { | |
| 213 | + getDelegate().setHoldability(holdability); | |
| 214 | + } | |
| 215 | + | |
| 216 | + public void setReadOnly(boolean readOnly) throws SQLException { | |
| 217 | + getDelegate().setReadOnly(readOnly); | |
| 218 | + } | |
| 219 | + | |
| 220 | + public Savepoint setSavepoint() throws SQLException { | |
| 221 | + return getDelegate().setSavepoint(); | |
| 222 | + } | |
| 223 | + | |
| 224 | + public Savepoint setSavepoint(String name) throws SQLException { | |
| 225 | + return getDelegate().setSavepoint(name); | |
| 226 | + } | |
| 227 | + | |
| 228 | + public void setTransactionIsolation(int level) throws SQLException { | |
| 229 | + getDelegate().setTransactionIsolation(level); | |
| 230 | + } | |
| 231 | + | |
| 232 | + public void setTypeMap(Map<String, Class<?>> map) throws SQLException { | |
| 233 | + getDelegate().setTypeMap(map); | |
| 234 | + } | |
| 235 | + | |
| 236 | + public <T> T unwrap(Class<T> iface) throws SQLException { | |
| 237 | + return getDelegate().unwrap(iface); | |
| 238 | + } | |
| 239 | +} | ... | ... |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/transaction/BasicDataSourceProxy.java
0 → 100644
| ... | ... | @@ -0,0 +1,363 @@ |
| 1 | +package br.gov.frameworkdemoiselle.transaction; | |
| 2 | + | |
| 3 | +import java.io.PrintWriter; | |
| 4 | +import java.io.Serializable; | |
| 5 | +import java.sql.Connection; | |
| 6 | +import java.sql.SQLException; | |
| 7 | +import java.util.Collection; | |
| 8 | + | |
| 9 | +import org.apache.commons.dbcp.BasicDataSource; | |
| 10 | + | |
| 11 | +import br.gov.frameworkdemoiselle.DemoiselleException; | |
| 12 | +import br.gov.frameworkdemoiselle.internal.configuration.JDBCConfig; | |
| 13 | +import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
| 14 | + | |
| 15 | +public class BasicDataSourceProxy extends BasicDataSource implements Serializable { | |
| 16 | + | |
| 17 | + private static final long serialVersionUID = 1L; | |
| 18 | + | |
| 19 | + private ResourceBundle bundle; | |
| 20 | + | |
| 21 | + private String dataSourceName; | |
| 22 | + | |
| 23 | + private JDBCConfig config; | |
| 24 | + | |
| 25 | + private transient BasicDataSource delegate; | |
| 26 | + | |
| 27 | + public BasicDataSourceProxy(String dataSourceName, JDBCConfig config, ResourceBundle bundle) { | |
| 28 | + this.dataSourceName = dataSourceName; | |
| 29 | + this.config = config; | |
| 30 | + this.bundle = bundle; | |
| 31 | + } | |
| 32 | + | |
| 33 | + private BasicDataSource getDelegate() { | |
| 34 | + if (this.delegate == null) { | |
| 35 | + BasicDataSource dataSource = new BasicDataSource(); | |
| 36 | + | |
| 37 | + try { | |
| 38 | + String driver = config.getDriverClass().get(dataSourceName); | |
| 39 | + String url = config.getUrl().get(dataSourceName); | |
| 40 | + String username = config.getUsername().get(dataSourceName); | |
| 41 | + String password = config.getPassword().get(dataSourceName); | |
| 42 | + | |
| 43 | + dataSource.setDriverClassName(driver); | |
| 44 | + dataSource.setUrl(url); | |
| 45 | + dataSource.setUsername(username); | |
| 46 | + dataSource.setPassword(password); | |
| 47 | + | |
| 48 | + } catch (ClassCastException cause) { | |
| 49 | + throw new DemoiselleException(bundle.getString("load-duplicated-configuration-failed"), cause); | |
| 50 | + } | |
| 51 | + | |
| 52 | + delegate = dataSource; | |
| 53 | + } | |
| 54 | + | |
| 55 | + return this.delegate; | |
| 56 | + } | |
| 57 | + | |
| 58 | + public boolean getDefaultAutoCommit() { | |
| 59 | + return getDelegate().getDefaultAutoCommit(); | |
| 60 | + } | |
| 61 | + | |
| 62 | + public void setDefaultAutoCommit(boolean defaultAutoCommit) { | |
| 63 | + getDelegate().setDefaultAutoCommit(defaultAutoCommit); | |
| 64 | + } | |
| 65 | + | |
| 66 | + public boolean getDefaultReadOnly() { | |
| 67 | + return getDelegate().getDefaultReadOnly(); | |
| 68 | + } | |
| 69 | + | |
| 70 | + public void setDefaultReadOnly(boolean defaultReadOnly) { | |
| 71 | + getDelegate().setDefaultReadOnly(defaultReadOnly); | |
| 72 | + } | |
| 73 | + | |
| 74 | + public int getDefaultTransactionIsolation() { | |
| 75 | + return getDelegate().getDefaultTransactionIsolation(); | |
| 76 | + } | |
| 77 | + | |
| 78 | + public void setDefaultTransactionIsolation(int defaultTransactionIsolation) { | |
| 79 | + getDelegate().setDefaultTransactionIsolation(defaultTransactionIsolation); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public String getDefaultCatalog() { | |
| 83 | + return getDelegate().getDefaultCatalog(); | |
| 84 | + } | |
| 85 | + | |
| 86 | + public void setDefaultCatalog(String defaultCatalog) { | |
| 87 | + getDelegate().setDefaultCatalog(defaultCatalog); | |
| 88 | + } | |
| 89 | + | |
| 90 | + public String getDriverClassName() { | |
| 91 | + return getDelegate().getDriverClassName(); | |
| 92 | + } | |
| 93 | + | |
| 94 | + public void setDriverClassName(String driverClassName) { | |
| 95 | + getDelegate().setDriverClassName(driverClassName); | |
| 96 | + } | |
| 97 | + | |
| 98 | + public ClassLoader getDriverClassLoader() { | |
| 99 | + return getDelegate().getDriverClassLoader(); | |
| 100 | + } | |
| 101 | + | |
| 102 | + public void setDriverClassLoader(ClassLoader driverClassLoader) { | |
| 103 | + getDelegate().setDriverClassLoader(driverClassLoader); | |
| 104 | + } | |
| 105 | + | |
| 106 | + public int getMaxActive() { | |
| 107 | + return getDelegate().getMaxActive(); | |
| 108 | + } | |
| 109 | + | |
| 110 | + public void setMaxActive(int maxActive) { | |
| 111 | + getDelegate().setMaxActive(maxActive); | |
| 112 | + } | |
| 113 | + | |
| 114 | + public int getMaxIdle() { | |
| 115 | + return getDelegate().getMaxIdle(); | |
| 116 | + } | |
| 117 | + | |
| 118 | + public void setMaxIdle(int maxIdle) { | |
| 119 | + getDelegate().setMaxIdle(maxIdle); | |
| 120 | + } | |
| 121 | + | |
| 122 | + public int getMinIdle() { | |
| 123 | + return getDelegate().getMinIdle(); | |
| 124 | + } | |
| 125 | + | |
| 126 | + public void setMinIdle(int minIdle) { | |
| 127 | + getDelegate().setMinIdle(minIdle); | |
| 128 | + } | |
| 129 | + | |
| 130 | + public int getInitialSize() { | |
| 131 | + return getDelegate().getInitialSize(); | |
| 132 | + } | |
| 133 | + | |
| 134 | + public void setInitialSize(int initialSize) { | |
| 135 | + getDelegate().setInitialSize(initialSize); | |
| 136 | + } | |
| 137 | + | |
| 138 | + public long getMaxWait() { | |
| 139 | + return getDelegate().getMaxWait(); | |
| 140 | + } | |
| 141 | + | |
| 142 | + public void setMaxWait(long maxWait) { | |
| 143 | + getDelegate().setMaxWait(maxWait); | |
| 144 | + } | |
| 145 | + | |
| 146 | + public boolean isPoolPreparedStatements() { | |
| 147 | + return getDelegate().isPoolPreparedStatements(); | |
| 148 | + } | |
| 149 | + | |
| 150 | + public void setPoolPreparedStatements(boolean poolingStatements) { | |
| 151 | + getDelegate().setPoolPreparedStatements(poolingStatements); | |
| 152 | + } | |
| 153 | + | |
| 154 | + public int getMaxOpenPreparedStatements() { | |
| 155 | + return getDelegate().getMaxOpenPreparedStatements(); | |
| 156 | + } | |
| 157 | + | |
| 158 | + public void setMaxOpenPreparedStatements(int maxOpenStatements) { | |
| 159 | + getDelegate().setMaxOpenPreparedStatements(maxOpenStatements); | |
| 160 | + } | |
| 161 | + | |
| 162 | + public boolean getTestOnBorrow() { | |
| 163 | + return getDelegate().getTestOnBorrow(); | |
| 164 | + } | |
| 165 | + | |
| 166 | + public void setTestOnBorrow(boolean testOnBorrow) { | |
| 167 | + getDelegate().setTestOnBorrow(testOnBorrow); | |
| 168 | + } | |
| 169 | + | |
| 170 | + public boolean getTestOnReturn() { | |
| 171 | + return getDelegate().getTestOnReturn(); | |
| 172 | + } | |
| 173 | + | |
| 174 | + public void setTestOnReturn(boolean testOnReturn) { | |
| 175 | + getDelegate().setTestOnReturn(testOnReturn); | |
| 176 | + } | |
| 177 | + | |
| 178 | + public long getTimeBetweenEvictionRunsMillis() { | |
| 179 | + return getDelegate().getTimeBetweenEvictionRunsMillis(); | |
| 180 | + } | |
| 181 | + | |
| 182 | + public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) { | |
| 183 | + getDelegate().setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); | |
| 184 | + } | |
| 185 | + | |
| 186 | + public int getNumTestsPerEvictionRun() { | |
| 187 | + return getDelegate().getNumTestsPerEvictionRun(); | |
| 188 | + } | |
| 189 | + | |
| 190 | + public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) { | |
| 191 | + getDelegate().setNumTestsPerEvictionRun(numTestsPerEvictionRun); | |
| 192 | + } | |
| 193 | + | |
| 194 | + public long getMinEvictableIdleTimeMillis() { | |
| 195 | + return getDelegate().getMinEvictableIdleTimeMillis(); | |
| 196 | + } | |
| 197 | + | |
| 198 | + public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) { | |
| 199 | + getDelegate().setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public boolean getTestWhileIdle() { | |
| 203 | + return getDelegate().getTestWhileIdle(); | |
| 204 | + } | |
| 205 | + | |
| 206 | + public void setTestWhileIdle(boolean testWhileIdle) { | |
| 207 | + getDelegate().setTestWhileIdle(testWhileIdle); | |
| 208 | + } | |
| 209 | + | |
| 210 | + public int getNumActive() { | |
| 211 | + return getDelegate().getNumActive(); | |
| 212 | + } | |
| 213 | + | |
| 214 | + public int getNumIdle() { | |
| 215 | + return getDelegate().getNumIdle(); | |
| 216 | + } | |
| 217 | + | |
| 218 | + public String getPassword() { | |
| 219 | + return getDelegate().getPassword(); | |
| 220 | + } | |
| 221 | + | |
| 222 | + public void setPassword(String password) { | |
| 223 | + getDelegate().setPassword(password); | |
| 224 | + } | |
| 225 | + | |
| 226 | + public String getUrl() { | |
| 227 | + return getDelegate().getUrl(); | |
| 228 | + } | |
| 229 | + | |
| 230 | + public void setUrl(String url) { | |
| 231 | + getDelegate().setUrl(url); | |
| 232 | + } | |
| 233 | + | |
| 234 | + public String getUsername() { | |
| 235 | + return getDelegate().getUsername(); | |
| 236 | + } | |
| 237 | + | |
| 238 | + public void setUsername(String username) { | |
| 239 | + getDelegate().setUsername(username); | |
| 240 | + } | |
| 241 | + | |
| 242 | + public String getValidationQuery() { | |
| 243 | + return getDelegate().getValidationQuery(); | |
| 244 | + } | |
| 245 | + | |
| 246 | + public void setValidationQuery(String validationQuery) { | |
| 247 | + getDelegate().setValidationQuery(validationQuery); | |
| 248 | + } | |
| 249 | + | |
| 250 | + public int getValidationQueryTimeout() { | |
| 251 | + return getDelegate().getValidationQueryTimeout(); | |
| 252 | + } | |
| 253 | + | |
| 254 | + public void setValidationQueryTimeout(int timeout) { | |
| 255 | + getDelegate().setValidationQueryTimeout(timeout); | |
| 256 | + } | |
| 257 | + | |
| 258 | + @SuppressWarnings("rawtypes") | |
| 259 | + public Collection getConnectionInitSqls() { | |
| 260 | + return getDelegate().getConnectionInitSqls(); | |
| 261 | + } | |
| 262 | + | |
| 263 | + @SuppressWarnings("rawtypes") | |
| 264 | + public void setConnectionInitSqls(Collection connectionInitSqls) { | |
| 265 | + getDelegate().setConnectionInitSqls(connectionInitSqls); | |
| 266 | + } | |
| 267 | + | |
| 268 | + public void setAccessToUnderlyingConnectionAllowed(boolean allow) { | |
| 269 | + getDelegate().setAccessToUnderlyingConnectionAllowed(allow); | |
| 270 | + } | |
| 271 | + | |
| 272 | + public Connection getConnection(String user, String pass) throws SQLException { | |
| 273 | + return getDelegate().getConnection(user, pass); | |
| 274 | + } | |
| 275 | + | |
| 276 | + public int getLoginTimeout() throws SQLException { | |
| 277 | + return getDelegate().getLoginTimeout(); | |
| 278 | + } | |
| 279 | + | |
| 280 | + public PrintWriter getLogWriter() throws SQLException { | |
| 281 | + return getDelegate().getLogWriter(); | |
| 282 | + } | |
| 283 | + | |
| 284 | + public void setLoginTimeout(int loginTimeout) throws SQLException { | |
| 285 | + getDelegate().setLoginTimeout(loginTimeout); | |
| 286 | + } | |
| 287 | + | |
| 288 | + public void setLogWriter(PrintWriter logWriter) throws SQLException { | |
| 289 | + getDelegate().setLogWriter(logWriter); | |
| 290 | + } | |
| 291 | + | |
| 292 | + public boolean getRemoveAbandoned() { | |
| 293 | + return getDelegate().getRemoveAbandoned(); | |
| 294 | + } | |
| 295 | + | |
| 296 | + public void setRemoveAbandoned(boolean removeAbandoned) { | |
| 297 | + getDelegate().setRemoveAbandoned(removeAbandoned); | |
| 298 | + } | |
| 299 | + | |
| 300 | + public int getRemoveAbandonedTimeout() { | |
| 301 | + return getDelegate().getRemoveAbandonedTimeout(); | |
| 302 | + } | |
| 303 | + | |
| 304 | + public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) { | |
| 305 | + getDelegate().setRemoveAbandonedTimeout(removeAbandonedTimeout); | |
| 306 | + } | |
| 307 | + | |
| 308 | + public boolean getLogAbandoned() { | |
| 309 | + return getDelegate().getLogAbandoned(); | |
| 310 | + } | |
| 311 | + | |
| 312 | + public void setLogAbandoned(boolean logAbandoned) { | |
| 313 | + getDelegate().setLogAbandoned(logAbandoned); | |
| 314 | + } | |
| 315 | + | |
| 316 | + public void addConnectionProperty(String name, String value) { | |
| 317 | + getDelegate().addConnectionProperty(name, value); | |
| 318 | + } | |
| 319 | + | |
| 320 | + public void removeConnectionProperty(String name) { | |
| 321 | + getDelegate().removeConnectionProperty(name); | |
| 322 | + } | |
| 323 | + | |
| 324 | + public void setConnectionProperties(String connectionProperties) { | |
| 325 | + getDelegate().setConnectionProperties(connectionProperties); | |
| 326 | + } | |
| 327 | + | |
| 328 | + public void close() throws SQLException { | |
| 329 | + getDelegate().close(); | |
| 330 | + } | |
| 331 | + | |
| 332 | + public boolean equals(Object arg0) { | |
| 333 | + return getDelegate().equals(arg0); | |
| 334 | + } | |
| 335 | + | |
| 336 | + public Connection getConnection() throws SQLException { | |
| 337 | + return getDelegate().getConnection(); | |
| 338 | + } | |
| 339 | + | |
| 340 | + public int hashCode() { | |
| 341 | + return getDelegate().hashCode(); | |
| 342 | + } | |
| 343 | + | |
| 344 | + public boolean isAccessToUnderlyingConnectionAllowed() { | |
| 345 | + return getDelegate().isAccessToUnderlyingConnectionAllowed(); | |
| 346 | + } | |
| 347 | + | |
| 348 | + public boolean isClosed() { | |
| 349 | + return getDelegate().isClosed(); | |
| 350 | + } | |
| 351 | + | |
| 352 | + public boolean isWrapperFor(Class<?> iface) throws SQLException { | |
| 353 | + return getDelegate().isWrapperFor(iface); | |
| 354 | + } | |
| 355 | + | |
| 356 | + public String toString() { | |
| 357 | + return getDelegate().toString(); | |
| 358 | + } | |
| 359 | + | |
| 360 | + public <T> T unwrap(Class<T> iface) throws SQLException { | |
| 361 | + return getDelegate().unwrap(iface); | |
| 362 | + } | |
| 363 | +} | ... | ... |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/transaction/JDBCTransaction.java
0 → 100644
| ... | ... | @@ -0,0 +1,175 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package br.gov.frameworkdemoiselle.transaction; | |
| 38 | + | |
| 39 | +import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.EXTENSIONS_L1_PRIORITY; | |
| 40 | + | |
| 41 | +import java.io.Serializable; | |
| 42 | +import java.sql.Connection; | |
| 43 | +import java.util.Collection; | |
| 44 | +import java.util.Collections; | |
| 45 | +import java.util.HashMap; | |
| 46 | +import java.util.Map; | |
| 47 | + | |
| 48 | +import br.gov.frameworkdemoiselle.annotation.Priority; | |
| 49 | +import br.gov.frameworkdemoiselle.internal.producer.ConnectionProducer; | |
| 50 | +import br.gov.frameworkdemoiselle.util.Beans; | |
| 51 | + | |
| 52 | +/** | |
| 53 | + * Represents the strategy destinated to manage JPA transactions. | |
| 54 | + * | |
| 55 | + * @author SERPRO | |
| 56 | + * @see Transaction | |
| 57 | + */ | |
| 58 | +@Priority(EXTENSIONS_L1_PRIORITY) | |
| 59 | +public class JDBCTransaction implements Transaction { | |
| 60 | + | |
| 61 | + private static final long serialVersionUID = 1L; | |
| 62 | + | |
| 63 | + private ConnectionProducer producer; | |
| 64 | + | |
| 65 | + private Map<Connection, Status> cache = Collections.synchronizedMap(new HashMap<Connection, Status>()); | |
| 66 | + | |
| 67 | + private ConnectionProducer getProducer() { | |
| 68 | + if (producer == null) { | |
| 69 | + producer = Beans.getReference(ConnectionProducer.class); | |
| 70 | + | |
| 71 | + for (Connection connection : producer.getCache().values()) { | |
| 72 | + if (!cache.containsKey(connection)) { | |
| 73 | + cache.put(connection, new Status()); | |
| 74 | + } | |
| 75 | + } | |
| 76 | + } | |
| 77 | + | |
| 78 | + return producer; | |
| 79 | + } | |
| 80 | + | |
| 81 | + public Collection<Connection> getDelegate() { | |
| 82 | + return getProducer().getCache().values(); | |
| 83 | + } | |
| 84 | + | |
| 85 | + @Override | |
| 86 | + public void begin() { | |
| 87 | + Status status; | |
| 88 | + for (Connection connection : getDelegate()) { | |
| 89 | + status = cache.get(connection); | |
| 90 | + status.setActive(true); | |
| 91 | + } | |
| 92 | + } | |
| 93 | + | |
| 94 | + @Override | |
| 95 | + public void commit() { | |
| 96 | + for (Connection connection : getDelegate()) { | |
| 97 | + try { | |
| 98 | + connection.commit(); | |
| 99 | + } catch (Exception cause) { | |
| 100 | + throw new TransactionException(cause); | |
| 101 | + } | |
| 102 | + } | |
| 103 | + } | |
| 104 | + | |
| 105 | + @Override | |
| 106 | + public void rollback() { | |
| 107 | + for (Connection connection : getDelegate()) { | |
| 108 | + try { | |
| 109 | + connection.rollback(); | |
| 110 | + } catch (Exception cause) { | |
| 111 | + throw new TransactionException(cause); | |
| 112 | + } | |
| 113 | + } | |
| 114 | + } | |
| 115 | + | |
| 116 | + @Override | |
| 117 | + public void setRollbackOnly() { | |
| 118 | + Status status; | |
| 119 | + for (Connection connection : getDelegate()) { | |
| 120 | + status = cache.get(connection); | |
| 121 | + status.setRollbackOnly(true); | |
| 122 | + } | |
| 123 | + } | |
| 124 | + | |
| 125 | + @Override | |
| 126 | + public boolean isActive() { | |
| 127 | + Status status; | |
| 128 | + boolean result = true; | |
| 129 | + | |
| 130 | + for (Connection connection : getDelegate()) { | |
| 131 | + status = cache.get(connection); | |
| 132 | + result = result && status.isActive(); | |
| 133 | + } | |
| 134 | + | |
| 135 | + return result; | |
| 136 | + } | |
| 137 | + | |
| 138 | + @Override | |
| 139 | + public boolean isMarkedRollback() { | |
| 140 | + Status status; | |
| 141 | + boolean result = true; | |
| 142 | + | |
| 143 | + for (Connection connection : getDelegate()) { | |
| 144 | + status = cache.get(connection); | |
| 145 | + result = result && status.isMarkedRollback(); | |
| 146 | + } | |
| 147 | + | |
| 148 | + return result; | |
| 149 | + } | |
| 150 | + | |
| 151 | + private class Status implements Serializable { | |
| 152 | + | |
| 153 | + private static final long serialVersionUID = 1L; | |
| 154 | + | |
| 155 | + private boolean active = false; | |
| 156 | + | |
| 157 | + private boolean markedRollback = false; | |
| 158 | + | |
| 159 | + public boolean isActive() { | |
| 160 | + return active; | |
| 161 | + } | |
| 162 | + | |
| 163 | + public void setActive(boolean active) { | |
| 164 | + this.active = active; | |
| 165 | + } | |
| 166 | + | |
| 167 | + public boolean isMarkedRollback() { | |
| 168 | + return markedRollback; | |
| 169 | + } | |
| 170 | + | |
| 171 | + public void setRollbackOnly(boolean markedRollback) { | |
| 172 | + this.markedRollback = markedRollback; | |
| 173 | + } | |
| 174 | + } | |
| 175 | +} | ... | ... |
impl/extension/jdbc/src/main/resources/META-INF/beans.xml
0 → 100644
| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | +<!-- | |
| 2 | + Demoiselle Framework | |
| 3 | + Copyright (C) 2010 SERPRO | |
| 4 | + ============================================================================ | |
| 5 | + This file is part of Demoiselle Framework. | |
| 6 | + | |
| 7 | + Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + as published by the Free Software Foundation. | |
| 10 | + | |
| 11 | + This program is distributed in the hope that it will be useful, | |
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + GNU General Public License for more details. | |
| 15 | + | |
| 16 | + You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + ============================================================================ | |
| 21 | + Este arquivo é parte do Framework Demoiselle. | |
| 22 | + | |
| 23 | + O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + do Software Livre (FSF). | |
| 26 | + | |
| 27 | + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + para maiores detalhes. | |
| 31 | + | |
| 32 | + Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | +--> | |
| 37 | +<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 38 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> | |
| 39 | + | |
| 40 | +</beans> | |
| 0 | 41 | \ No newline at end of file | ... | ... |
impl/extension/jdbc/src/main/resources/demoiselle-jdbc-bundle.properties
0 → 100644
| ... | ... | @@ -0,0 +1,47 @@ |
| 1 | +# Demoiselle Framework | |
| 2 | +# Copyright (C) 2010 SERPRO | |
| 3 | +# ---------------------------------------------------------------------------- | |
| 4 | +# This file is part of Demoiselle Framework. | |
| 5 | +# | |
| 6 | +# Demoiselle Framework is free software; you can redistribute it and/or | |
| 7 | +# modify it under the terms of the GNU Lesser General Public License version 3 | |
| 8 | +# as published by the Free Software Foundation. | |
| 9 | +# | |
| 10 | +# This program is distributed in the hope that it will be useful, | |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | +# GNU General Public License for more details. | |
| 14 | +# | |
| 15 | +# You should have received a copy of the GNU Lesser General Public License version 3 | |
| 16 | +# along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 17 | +# or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 18 | +# Fifth Floor, Boston, MA 02110-1301, USA. | |
| 19 | +# ---------------------------------------------------------------------------- | |
| 20 | +# Este arquivo é parte do Framework Demoiselle. | |
| 21 | +# | |
| 22 | +# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 23 | +# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 24 | +# do Software Livre (FSF). | |
| 25 | +# | |
| 26 | +# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 27 | +# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 28 | +# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 29 | +# para maiores detalhes. | |
| 30 | +# | |
| 31 | +# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 32 | +# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 33 | +# ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 34 | +# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 35 | + | |
| 36 | +more-than-one-datasource-defined=Existe mais de um banco de dados definido. Utilize @{0} no ponto de inje\u00E7\u00E3o ou defina o atributo "frameworkdemoiselle.persistence.default.datasource.name" no arquivo demoiselle.properties. | |
| 37 | +connection-was-closed=A conex\u00E3o "{0}" foi fechada. | |
| 38 | +connection-has-already-been-closed=A conex\u00E3o "{0}" j\u00E1 havia sido fechada. | |
| 39 | +connection-close-failed=Falha ao tentar fechar a conex\u00E3o "{0}" | |
| 40 | +set-autocommit-failed=Falha ao tentar executar connection.setAutoCommit(false) numa transa\u00E7\u00E3o gerenciada. N\u00E3o se preocupe, este comportamento \u00E9 esperado. | |
| 41 | +load-jndi-datasource-failed=Falha ao tentar obter a conex\u00E3o "{0}" via JNDI. | |
| 42 | +load-duplicated-configuration-failed=Falha no carregamento das configura\u00E7\u00F5es JDBC. Verifique se existem valores duplicados indevidamente no demoiselle.properties. | |
| 43 | +getting-default-datasource-name-from-properties=Obtendo a configura\u00E7\u00E3o de banco de dados padr\u00E3o "{0}" a partir do arquivo de configura\u00E7\u00E3o demoiselle.properties. | |
| 44 | +datasource-name-found=Configura\u00E7\u00E3o de banco de dados "{0}" encontrada. | |
| 45 | +datasource-not-found-in-cache=DataSource n\u00E3o encontrado para contexto atual, criando um agora. | |
| 46 | +connection-was-created=Conex\u00E3o criada a partir da configura\u00E7\u00E3o "{0}". | |
| 47 | +datasource-name-not-found=Nenhuma configura\u00E7\u00E3o de banco de dados foi encontrada no demoiselle.properties. | ... | ... |
impl/extension/jdbc/src/test/resources/META-INF/beans.xml
0 → 100644
| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | +<!-- | |
| 2 | + Demoiselle Framework | |
| 3 | + Copyright (C) 2010 SERPRO | |
| 4 | + ============================================================================ | |
| 5 | + This file is part of Demoiselle Framework. | |
| 6 | + | |
| 7 | + Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + as published by the Free Software Foundation. | |
| 10 | + | |
| 11 | + This program is distributed in the hope that it will be useful, | |
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + GNU General Public License for more details. | |
| 15 | + | |
| 16 | + You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + ============================================================================ | |
| 21 | + Este arquivo é parte do Framework Demoiselle. | |
| 22 | + | |
| 23 | + O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + do Software Livre (FSF). | |
| 26 | + | |
| 27 | + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + para maiores detalhes. | |
| 31 | + | |
| 32 | + Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | +--> | |
| 37 | +<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 38 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> | |
| 39 | + | |
| 40 | +</beans> | |
| 0 | 41 | \ No newline at end of file | ... | ... |
impl/extension/jdbc/src/test/resources/demoiselle.properties
0 → 100644
impl/extension/jpa/pom.xml
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | <parent> |
| 46 | 46 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 47 | 47 | <artifactId>demoiselle-extension-parent</artifactId> |
| 48 | - <version>2.3.2-SNAPSHOT</version> | |
| 48 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 49 | 49 | <relativePath>../../../parent/extension</relativePath> |
| 50 | 50 | </parent> |
| 51 | 51 | ... | ... |
impl/extension/jsf/pom.xml
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | <parent> |
| 45 | 45 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 46 | 46 | <artifactId>demoiselle-extension-parent</artifactId> |
| 47 | - <version>2.3.2-SNAPSHOT</version> | |
| 47 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 48 | 48 | <relativePath>../../../parent/extension</relativePath> |
| 49 | 49 | </parent> |
| 50 | 50 | ... | ... |
impl/extension/jsf/src/main/resources/META-INF/.gitignore
0 → 100644
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +/.faces-config.xml.jsfdia | ... | ... |
impl/extension/jsf/src/main/resources/META-INF/demoiselle-d.taglib.xml
0 → 100644
| ... | ... | @@ -0,0 +1,47 @@ |
| 1 | +<!-- | |
| 2 | + Demoiselle Framework | |
| 3 | + Copyright (C) 2010 SERPRO | |
| 4 | + ============================================================================ | |
| 5 | + This file is part of Demoiselle Framework. | |
| 6 | + | |
| 7 | + Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + as published by the Free Software Foundation. | |
| 10 | + | |
| 11 | + This program is distributed in the hope that it will be useful, | |
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + GNU General Public License for more details. | |
| 15 | + | |
| 16 | + You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + ============================================================================ | |
| 21 | + Este arquivo é parte do Framework Demoiselle. | |
| 22 | + | |
| 23 | + O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + do Software Livre (FSF). | |
| 26 | + | |
| 27 | + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + para maiores detalhes. | |
| 31 | + | |
| 32 | + Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | +--> | |
| 37 | +<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 38 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd" | |
| 39 | + version="2.0"> | |
| 40 | + | |
| 41 | + <namespace>http://frameworkdemoiselle.gov.br/jsf</namespace> | |
| 42 | + | |
| 43 | + <tag> | |
| 44 | + <tag-name>checkLoggedIn</tag-name> | |
| 45 | + <source>tags/br/gov/frameworkdemoiselle/checkLoggedIn.xhtml</source> | |
| 46 | + </tag> | |
| 47 | +</facelet-taglib> | ... | ... |
impl/extension/jsf/src/main/resources/META-INF/faces-config.xml
| ... | ... | @@ -34,7 +34,7 @@ |
| 34 | 34 | ou escreva para a Fundação do Software Livre (FSF) Inc., |
| 35 | 35 | 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. |
| 36 | 36 | --> |
| 37 | -<faces-config id="weld" version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 37 | +<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 38 | 38 | xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"> |
| 39 | 39 | |
| 40 | 40 | <lifecycle> | ... | ... |
impl/extension/jsf/src/main/resources/META-INF/tags/br/gov/frameworkdemoiselle/checkLoggedIn.xhtml
0 → 100644
| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | +<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" | |
| 2 | + xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> | |
| 3 | + | |
| 4 | + #{securityContext.checkLoggedIn()} | |
| 5 | + | |
| 6 | +</ui:composition> | |
| 0 | 7 | \ No newline at end of file | ... | ... |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/AuthorizationExceptionHandlerFactoryTest.java
| ... | ... | @@ -35,7 +35,7 @@ |
| 35 | 35 | * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. |
| 36 | 36 | */ |
| 37 | 37 | package br.gov.frameworkdemoiselle.internal.implementation; |
| 38 | -import org.junit.Ignore; | |
| 38 | + | |
| 39 | 39 | import static junit.framework.Assert.assertEquals; |
| 40 | 40 | import static org.easymock.EasyMock.expect; |
| 41 | 41 | import static org.powermock.api.easymock.PowerMock.replayAll; |
| ... | ... | @@ -54,7 +54,7 @@ public class AuthorizationExceptionHandlerFactoryTest { |
| 54 | 54 | |
| 55 | 55 | @Test |
| 56 | 56 | public void testGetExceptionHandler() { |
| 57 | - | |
| 57 | + | |
| 58 | 58 | ExceptionHandler jsfExceptionHandler = PowerMock.createMock(ExceptionHandler.class); |
| 59 | 59 | |
| 60 | 60 | ExceptionHandlerFactory jsfFactory = PowerMock.createMock(ExceptionHandlerFactory.class); |
| ... | ... | @@ -69,7 +69,7 @@ public class AuthorizationExceptionHandlerFactoryTest { |
| 69 | 69 | assertEquals(handler.getWrapped(), jsfExceptionHandler); |
| 70 | 70 | |
| 71 | 71 | verifyAll(); |
| 72 | - | |
| 72 | + | |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | } | ... | ... |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/ParameterImplTest.java
| ... | ... | @@ -54,7 +54,6 @@ import javax.enterprise.inject.spi.InjectionPoint; |
| 54 | 54 | import javax.faces.convert.Converter; |
| 55 | 55 | import javax.servlet.http.HttpServletRequest; |
| 56 | 56 | import javax.servlet.http.HttpSession; |
| 57 | -import javax.swing.text.View; | |
| 58 | 57 | |
| 59 | 58 | import org.easymock.EasyMock; |
| 60 | 59 | import org.junit.Before; |
| ... | ... | @@ -155,7 +154,7 @@ public class ParameterImplTest { |
| 155 | 154 | public void testGetValueWhenSessionScopedAndParameterValueNotNull() { |
| 156 | 155 | this.prepareForTestWithKeyFromNameAnnotation(); |
| 157 | 156 | expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter); |
| 158 | - | |
| 157 | + | |
| 159 | 158 | mockStatic(Beans.class); |
| 160 | 159 | expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); |
| 161 | 160 | |
| ... | ... | @@ -179,7 +178,7 @@ public class ParameterImplTest { |
| 179 | 178 | @Test |
| 180 | 179 | public void testGetValueWhenSessionScopedAndParameterValueNull() { |
| 181 | 180 | this.prepareForTestWithKeyFromNameAnnotation(); |
| 182 | - | |
| 181 | + | |
| 183 | 182 | mockStatic(Beans.class); |
| 184 | 183 | expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); |
| 185 | 184 | |
| ... | ... | @@ -200,17 +199,17 @@ public class ParameterImplTest { |
| 200 | 199 | public void testGetValueWhenRequestScoped() { |
| 201 | 200 | this.prepareForTestWithKeyFromNameAnnotation(); |
| 202 | 201 | expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter); |
| 203 | - | |
| 202 | + | |
| 204 | 203 | mockStatic(Beans.class); |
| 205 | 204 | expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); |
| 206 | - | |
| 205 | + | |
| 207 | 206 | expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); |
| 208 | 207 | expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true); |
| 209 | 208 | expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); |
| 210 | 209 | expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); |
| 211 | 210 | expect(request.getSession()).andReturn(session).anyTimes(); |
| 212 | 211 | expect(Faces.convert("1", converter)).andReturn("return"); |
| 213 | - | |
| 212 | + | |
| 214 | 213 | replayAll(); |
| 215 | 214 | param = new ParameterImpl<Long>(ip); |
| 216 | 215 | assertEquals("return", param.getValue()); |
| ... | ... | @@ -221,11 +220,11 @@ public class ParameterImplTest { |
| 221 | 220 | public void testGetValueWhenViewScopedWithParamValueNotNull() { |
| 222 | 221 | this.prepareForTestWithKeyFromNameAnnotation(); |
| 223 | 222 | expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter); |
| 224 | - Map<String, Object> map = new HashMap<String,Object>(); | |
| 225 | - | |
| 223 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 224 | + | |
| 226 | 225 | mockStatic(Beans.class); |
| 227 | 226 | expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); |
| 228 | - | |
| 227 | + | |
| 229 | 228 | expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); |
| 230 | 229 | expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); |
| 231 | 230 | expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true); |
| ... | ... | @@ -243,12 +242,12 @@ public class ParameterImplTest { |
| 243 | 242 | @Test |
| 244 | 243 | public void testGetValueWhenViewScopedWithParamValueNull() { |
| 245 | 244 | this.prepareForTestWithKeyFromNameAnnotation(); |
| 246 | - Map<String, Object> map = new HashMap<String,Object>(); | |
| 245 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 247 | 246 | map.put("name", "ops"); |
| 248 | 247 | |
| 249 | 248 | mockStatic(Beans.class); |
| 250 | 249 | expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); |
| 251 | - | |
| 250 | + | |
| 252 | 251 | expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); |
| 253 | 252 | expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); |
| 254 | 253 | expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true); |
| ... | ... | @@ -269,13 +268,13 @@ public class ParameterImplTest { |
| 269 | 268 | |
| 270 | 269 | mockStatic(Beans.class); |
| 271 | 270 | expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); |
| 272 | - | |
| 271 | + | |
| 273 | 272 | expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); |
| 274 | 273 | expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); |
| 275 | 274 | expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); |
| 276 | 275 | expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); |
| 277 | 276 | expect(Faces.convert("1", converter)).andReturn("return"); |
| 278 | - | |
| 277 | + | |
| 279 | 278 | replayAll(); |
| 280 | 279 | param = new ParameterImpl<Long>(ip); |
| 281 | 280 | assertEquals("return", param.getValue()); |
| ... | ... | @@ -288,7 +287,7 @@ public class ParameterImplTest { |
| 288 | 287 | |
| 289 | 288 | mockStatic(Beans.class); |
| 290 | 289 | expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); |
| 291 | - | |
| 290 | + | |
| 292 | 291 | expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); |
| 293 | 292 | expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); |
| 294 | 293 | expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); |
| ... | ... | @@ -307,7 +306,7 @@ public class ParameterImplTest { |
| 307 | 306 | |
| 308 | 307 | mockStatic(Beans.class); |
| 309 | 308 | expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); |
| 310 | - | |
| 309 | + | |
| 311 | 310 | expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true); |
| 312 | 311 | expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); |
| 313 | 312 | expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); | ... | ... |
impl/extension/jta/pom.xml
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | <parent> |
| 45 | 45 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 46 | 46 | <artifactId>demoiselle-extension-parent</artifactId> |
| 47 | - <version>2.3.2-SNAPSHOT</version> | |
| 47 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 48 | 48 | <relativePath>../../../parent/extension</relativePath> |
| 49 | 49 | </parent> |
| 50 | 50 | |
| ... | ... | @@ -97,4 +97,4 @@ |
| 97 | 97 | </releases> |
| 98 | 98 | </repository> |
| 99 | 99 | </repositories> |
| 100 | -</project> | |
| 101 | 100 | \ No newline at end of file |
| 101 | +</project> | ... | ... |
impl/extension/se/pom.xml
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | <parent> |
| 45 | 45 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 46 | 46 | <artifactId>demoiselle-extension-parent</artifactId> |
| 47 | - <version>2.3.2-SNAPSHOT</version> | |
| 47 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 48 | 48 | <relativePath>../../../parent/extension</relativePath> |
| 49 | 49 | </parent> |
| 50 | 50 | ... | ... |
impl/extension/servlet/pom.xml
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | <parent> |
| 45 | 45 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 46 | 46 | <artifactId>demoiselle-extension-parent</artifactId> |
| 47 | - <version>2.3.2-SNAPSHOT</version> | |
| 47 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 48 | 48 | <relativePath>../../../parent/extension</relativePath> |
| 49 | 49 | </parent> |
| 50 | 50 | ... | ... |
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/util/ServletFilter.java
| ... | ... | @@ -38,6 +38,7 @@ package br.gov.frameworkdemoiselle.util; |
| 38 | 38 | |
| 39 | 39 | import java.io.IOException; |
| 40 | 40 | |
| 41 | +import javax.security.auth.login.LoginContext; | |
| 41 | 42 | import javax.servlet.Filter; |
| 42 | 43 | import javax.servlet.FilterChain; |
| 43 | 44 | import javax.servlet.FilterConfig; |
| ... | ... | @@ -46,6 +47,7 @@ import javax.servlet.ServletRequest; |
| 46 | 47 | import javax.servlet.ServletResponse; |
| 47 | 48 | import javax.servlet.http.HttpServletRequest; |
| 48 | 49 | import javax.servlet.http.HttpServletResponse; |
| 50 | +import javax.servlet.http.HttpSession; | |
| 49 | 51 | |
| 50 | 52 | import br.gov.frameworkdemoiselle.internal.producer.HttpServletRequestProducer; |
| 51 | 53 | import br.gov.frameworkdemoiselle.internal.producer.HttpServletResponseProducer; |
| ... | ... | @@ -63,6 +65,14 @@ public class ServletFilter implements Filter { |
| 63 | 65 | Beans.getReference(HttpServletRequestProducer.class).setDelegate((HttpServletRequest) request); |
| 64 | 66 | Beans.getReference(HttpServletResponseProducer.class).setDelegate((HttpServletResponse) response); |
| 65 | 67 | |
| 68 | + LoginContext ctx = null; | |
| 69 | + HttpSession sess = (HttpSession) ((HttpServletRequest) request).getSession(false); | |
| 70 | + if (sess != null) { | |
| 71 | + ctx = (LoginContext) sess.getAttribute("ctx"); | |
| 72 | + } | |
| 73 | + | |
| 74 | + // System.out.println(ctx); | |
| 75 | + | |
| 66 | 76 | chain.doFilter(request, response); |
| 67 | 77 | } |
| 68 | 78 | ... | ... |
parent/archetype/pom.xml
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | <parent> |
| 45 | 45 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 46 | 46 | <artifactId>demoiselle-framework-parent</artifactId> |
| 47 | - <version>2.3.2-SNAPSHOT</version> | |
| 47 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 48 | 48 | <relativePath>../framework</relativePath> |
| 49 | 49 | </parent> |
| 50 | 50 | ... | ... |
parent/bom/pom.xml
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | <parent> |
| 45 | 45 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 46 | 46 | <artifactId>demoiselle-framework-parent</artifactId> |
| 47 | - <version>2.3.2-SNAPSHOT</version> | |
| 47 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 48 | 48 | <relativePath>../framework</relativePath> |
| 49 | 49 | </parent> |
| 50 | 50 | |
| ... | ... | @@ -72,32 +72,42 @@ |
| 72 | 72 | <dependency> |
| 73 | 73 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 74 | 74 | <artifactId>demoiselle-core</artifactId> |
| 75 | - <version>2.3.2-SNAPSHOT</version> | |
| 75 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 76 | 76 | </dependency> |
| 77 | 77 | <dependency> |
| 78 | 78 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 79 | 79 | <artifactId>demoiselle-jta</artifactId> |
| 80 | - <version>2.3.2-SNAPSHOT</version> | |
| 80 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 81 | + </dependency> | |
| 82 | + <dependency> | |
| 83 | + <groupId>br.gov.frameworkdemoiselle</groupId> | |
| 84 | + <artifactId>demoiselle-jdbc</artifactId> | |
| 85 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 81 | 86 | </dependency> |
| 82 | 87 | <dependency> |
| 83 | 88 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 84 | 89 | <artifactId>demoiselle-jpa</artifactId> |
| 85 | - <version>2.3.2-SNAPSHOT</version> | |
| 90 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 86 | 91 | </dependency> |
| 87 | 92 | <dependency> |
| 88 | 93 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 89 | 94 | <artifactId>demoiselle-servlet</artifactId> |
| 90 | - <version>2.3.2-SNAPSHOT</version> | |
| 95 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 91 | 96 | </dependency> |
| 92 | 97 | <dependency> |
| 93 | 98 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 94 | 99 | <artifactId>demoiselle-jsf</artifactId> |
| 95 | - <version>2.3.2-SNAPSHOT</version> | |
| 100 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 96 | 101 | </dependency> |
| 97 | 102 | <dependency> |
| 98 | 103 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 99 | 104 | <artifactId>demoiselle-se</artifactId> |
| 100 | - <version>2.3.2-SNAPSHOT</version> | |
| 105 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 106 | + </dependency> | |
| 107 | + <dependency> | |
| 108 | + <groupId>br.gov.frameworkdemoiselle</groupId> | |
| 109 | + <artifactId>demoiselle-jaas</artifactId> | |
| 110 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 101 | 111 | </dependency> |
| 102 | 112 | |
| 103 | 113 | <!-- jsr-299 api --> |
| ... | ... | @@ -252,12 +262,17 @@ |
| 252 | 262 | <version>${slf4j.version}</version> |
| 253 | 263 | </dependency> |
| 254 | 264 | |
| 255 | - <!-- configuration api+impl --> | |
| 265 | + <!-- apache commons --> | |
| 256 | 266 | <dependency> |
| 257 | 267 | <groupId>commons-configuration</groupId> |
| 258 | 268 | <artifactId>commons-configuration</artifactId> |
| 259 | 269 | <version>${commons.configuration.version}</version> |
| 260 | 270 | </dependency> |
| 271 | + <dependency> | |
| 272 | + <groupId>commons-dbcp</groupId> | |
| 273 | + <artifactId>commons-dbcp</artifactId> | |
| 274 | + <version>${commons.dbcp.version}</version> | |
| 275 | + </dependency> | |
| 261 | 276 | |
| 262 | 277 | <!-- embedded database --> |
| 263 | 278 | <dependency> |
| ... | ... | @@ -343,6 +358,7 @@ |
| 343 | 358 | <slf4j.version>1.6.1</slf4j.version> |
| 344 | 359 | <weld.version>1.1.8.Final</weld.version> |
| 345 | 360 | <commons.configuration.version>1.5</commons.configuration.version> |
| 361 | + <commons.dbcp.version>1.4</commons.dbcp.version> | |
| 346 | 362 | <hsqldb.version>1.8.0.10</hsqldb.version> |
| 347 | 363 | <jasperreports.version>4.0.1</jasperreports.version> |
| 348 | 364 | <mail.version>1.4.4</mail.version> | ... | ... |
parent/extension/pom.xml
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | <parent> |
| 45 | 45 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 46 | 46 | <artifactId>demoiselle-framework-parent</artifactId> |
| 47 | - <version>2.3.2-SNAPSHOT</version> | |
| 47 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 48 | 48 | <relativePath>../framework</relativePath> |
| 49 | 49 | </parent> |
| 50 | 50 | |
| ... | ... | @@ -71,7 +71,7 @@ |
| 71 | 71 | <dependency> |
| 72 | 72 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 73 | 73 | <artifactId>demoiselle-framework-bom</artifactId> |
| 74 | - <version>2.3.2-SNAPSHOT</version> | |
| 74 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 75 | 75 | <scope>import</scope> |
| 76 | 76 | <type>pom</type> |
| 77 | 77 | </dependency> |
| ... | ... | @@ -157,4 +157,4 @@ |
| 157 | 157 | </releases> |
| 158 | 158 | </repository> |
| 159 | 159 | </repositories> |
| 160 | -</project> | |
| 161 | 160 | \ No newline at end of file |
| 161 | +</project> | ... | ... |
parent/framework/pom.xml
parent/jsf/pom.xml
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | <parent> |
| 45 | 45 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 46 | 46 | <artifactId>demoiselle-servlet-parent</artifactId> |
| 47 | - <version>2.3.2-SNAPSHOT</version> | |
| 47 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 48 | 48 | <relativePath>../servlet</relativePath> |
| 49 | 49 | </parent> |
| 50 | 50 | ... | ... |
parent/minimal/pom.xml
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | <parent> |
| 45 | 45 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 46 | 46 | <artifactId>demoiselle-framework-parent</artifactId> |
| 47 | - <version>2.3.2-SNAPSHOT</version> | |
| 47 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 48 | 48 | <relativePath>../framework</relativePath> |
| 49 | 49 | </parent> |
| 50 | 50 | |
| ... | ... | @@ -72,7 +72,7 @@ |
| 72 | 72 | <dependency> |
| 73 | 73 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 74 | 74 | <artifactId>demoiselle-framework-bom</artifactId> |
| 75 | - <version>2.3.2-SNAPSHOT</version> | |
| 75 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 76 | 76 | <scope>import</scope> |
| 77 | 77 | <type>pom</type> |
| 78 | 78 | </dependency> | ... | ... |
parent/se/pom.xml
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | <parent> |
| 45 | 45 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 46 | 46 | <artifactId>demoiselle-extension-parent</artifactId> |
| 47 | - <version>2.3.2-SNAPSHOT</version> | |
| 47 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 48 | 48 | <relativePath>../../../parent/extension</relativePath> |
| 49 | 49 | </parent> |
| 50 | 50 | ... | ... |
parent/servlet/pom.xml
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | <parent> |
| 45 | 45 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 46 | 46 | <artifactId>demoiselle-extension-parent</artifactId> |
| 47 | - <version>2.3.2-SNAPSHOT</version> | |
| 47 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 48 | 48 | <relativePath>../extension</relativePath> |
| 49 | 49 | </parent> |
| 50 | 50 | ... | ... |
pom.xml
| ... | ... | @@ -39,7 +39,7 @@ |
| 39 | 39 | <modelVersion>4.0.0</modelVersion> |
| 40 | 40 | |
| 41 | 41 | <artifactId>demoiselle-framework-build</artifactId> |
| 42 | - <version>2.3.2-SNAPSHOT</version> | |
| 42 | + <version>2.4.0-ALPHA1-SNAPSHOT</version> | |
| 43 | 43 | <packaging>pom</packaging> |
| 44 | 44 | |
| 45 | 45 | <parent> |
| ... | ... | @@ -65,11 +65,13 @@ |
| 65 | 65 | <module>parent/se</module> |
| 66 | 66 | <module>parent/archetype</module> |
| 67 | 67 | <module>impl/core</module> |
| 68 | + <module>impl/extension/jdbc</module> | |
| 68 | 69 | <module>impl/extension/jpa</module> |
| 69 | 70 | <module>impl/extension/jsf</module> |
| 70 | 71 | <module>impl/extension/jta</module> |
| 71 | 72 | <module>impl/extension/se</module> |
| 72 | 73 | <module>impl/extension/servlet</module> |
| 74 | + <module>impl/extension/jaas</module> | |
| 73 | 75 | <module>archetype/minimal</module> |
| 74 | 76 | <module>archetype/jsf-jpa</module> |
| 75 | 77 | <module>documentation/quickstart</module> | ... | ... |