Commit bb4b60d6977f2a4864c5ef6827c3ca49cbe7ef44

Authored by Dancovich
1 parent 52ee0df1
Exists in master

-Alterado nome de contextos temporários

-Acrescentado o contexto ConversationContext e sua implementação
-Alterada a forma como o produtor de contextos obtém a lista de
contextos registrado, evitando um bug causado pela ordenação das
chamadas a eventos durante o bootstrap da aplicação.
impl/core/src/main/java/br/gov/frameworkdemoiselle/context/ConversationContext.java 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +package br.gov.frameworkdemoiselle.context;
  2 +
  3 +
  4 +public interface ConversationContext extends CustomContext {
  5 +
  6 +}
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/CustomContextBootstrap.java
... ... @@ -5,17 +5,15 @@ import java.util.List;
5 5  
6 6 import javax.enterprise.event.Observes;
7 7 import javax.enterprise.inject.spi.AfterBeanDiscovery;
8   -import javax.enterprise.inject.spi.AfterDeploymentValidation;
9 8 import javax.enterprise.inject.spi.Extension;
10 9  
11 10 import br.gov.frameworkdemoiselle.context.CustomContext;
12 11 import br.gov.frameworkdemoiselle.context.StaticContext;
13   -import br.gov.frameworkdemoiselle.internal.context.CustomContextProducer;
14   -import br.gov.frameworkdemoiselle.internal.context.RequestContextImpl;
15   -import br.gov.frameworkdemoiselle.internal.context.SessionContextImpl;
  12 +import br.gov.frameworkdemoiselle.internal.context.TemporaryRequestContextImpl;
  13 +import br.gov.frameworkdemoiselle.internal.context.TemporarySessionContextImpl;
16 14 import br.gov.frameworkdemoiselle.internal.context.StaticContextImpl;
17   -import br.gov.frameworkdemoiselle.internal.context.ThreadLocalViewContextImpl;
18   -import br.gov.frameworkdemoiselle.util.Beans;
  15 +import br.gov.frameworkdemoiselle.internal.context.TemporaryConversationContextImpl;
  16 +import br.gov.frameworkdemoiselle.internal.context.TemporaryViewContextImpl;
19 17  
20 18 /**
21 19 * This portable extension registers and starts custom contexts used by
... ... @@ -28,26 +26,6 @@ public class CustomContextBootstrap implements Extension{
28 26  
29 27 private List<CustomContext> contexts;
30 28  
31   - /*private Logger logger;
32   -
33   - private transient ResourceBundle bundle;
34   -
35   - private Logger getLogger() {
36   - if (this.logger == null) {
37   - this.logger = LoggerProducer.create(CoreBootstrap.class);
38   - }
39   -
40   - return this.logger;
41   - }
42   -
43   - private ResourceBundle getBundle() {
44   - if (bundle == null) {
45   - bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault());
46   - }
47   -
48   - return bundle;
49   - }*/
50   -
51 29 public void initializeContexts(@Observes AfterBeanDiscovery event){
52 30 //Cadastra os contextos contidos no demoiselle-core
53 31 if (contexts==null || contexts.isEmpty()){
... ... @@ -55,16 +33,19 @@ public class CustomContextBootstrap implements Extension{
55 33  
56 34 contexts = new ArrayList<CustomContext>();
57 35  
58   - ctx = new RequestContextImpl();
  36 + ctx = new TemporaryRequestContextImpl();
59 37 contexts.add(ctx);
60 38  
61   - ctx = new SessionContextImpl();
  39 + ctx = new TemporarySessionContextImpl();
62 40 contexts.add(ctx);
63 41  
64 42 ctx = new StaticContextImpl();
65 43 contexts.add(ctx);
66 44  
67   - ctx = new ThreadLocalViewContextImpl();
  45 + ctx = new TemporaryViewContextImpl();
  46 + contexts.add(ctx);
  47 +
  48 + ctx = new TemporaryConversationContextImpl();
68 49 contexts.add(ctx);
69 50  
70 51 for (CustomContext c : contexts){
... ... @@ -82,9 +63,13 @@ public class CustomContextBootstrap implements Extension{
82 63 }
83 64 }
84 65  
85   - public void storeContexts(@Observes AfterDeploymentValidation event){
  66 + public List<CustomContext> getCustomContexts(){
  67 + return this.contexts;
  68 + }
  69 +
  70 + /*public void storeContexts(@Observes AfterDeploymentValidation event){
86 71 CustomContextProducer producer = Beans.getReference(CustomContextProducer.class);
87 72 producer.addRegisteredContexts(contexts);
88   - }
  73 + }*/
89 74  
90 75 }
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/CustomContextProducer.java
  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 +/*
  38 + * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the
  39 + * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE
  40 + * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is
  41 + * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part
  42 + * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the
  43 + * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework
  44 + * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  45 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
  46 + * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see
  47 + * <http://www.gnu.org/licenses/>.
  48 + */
1 49 package br.gov.frameworkdemoiselle.internal.context;
2 50  
3 51 import java.util.ArrayList;
4   -import java.util.Collection;
5 52 import java.util.List;
6 53 import java.util.Locale;
7 54  
  55 +import javax.annotation.PostConstruct;
8 56 import javax.annotation.PreDestroy;
9 57 import javax.enterprise.context.ApplicationScoped;
10 58 import javax.enterprise.inject.Produces;
... ... @@ -12,6 +60,7 @@ import javax.enterprise.inject.spi.InjectionPoint;
12 60  
13 61 import org.slf4j.Logger;
14 62  
  63 +import br.gov.frameworkdemoiselle.context.ConversationContext;
15 64 import br.gov.frameworkdemoiselle.context.CustomContext;
16 65 import br.gov.frameworkdemoiselle.context.RequestContext;
17 66 import br.gov.frameworkdemoiselle.context.SessionContext;
... ... @@ -20,10 +69,11 @@ import br.gov.frameworkdemoiselle.context.ViewContext;
20 69 import br.gov.frameworkdemoiselle.internal.bootstrap.CustomContextBootstrap;
21 70 import br.gov.frameworkdemoiselle.internal.implementation.StrategySelector;
22 71 import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer;
  72 +import br.gov.frameworkdemoiselle.util.Beans;
23 73 import br.gov.frameworkdemoiselle.util.ResourceBundle;
24 74  
25 75 /**
26   - * Produces instances of {@link CustomContext} to control contexts not active
  76 + * Produces instances of {@link CustomContext} to control contexts not activated
27 77 * by the container
28 78 *
29 79 * @author serpro
... ... @@ -38,16 +88,6 @@ public class CustomContextProducer {
38 88  
39 89 private List<CustomContext> contexts = new ArrayList<CustomContext>();
40 90  
41   - /**
42   - * Store a list of contexts into this producer. The contexts must have
43   - * been registered into CDI by a portable extension, this method will not do this.
44   - *
45   - */
46   - public void addRegisteredContexts(Collection<CustomContext> contexts){
47   - for (CustomContext context : contexts){
48   - addRegisteredContext(context);
49   - }
50   - }
51 91  
52 92 /**
53 93 * Store a context into this producer. The context must have
... ... @@ -66,6 +106,22 @@ public class CustomContextProducer {
66 106 logger.debug( bundle.getString("bootstrap-context-already-managed", context.getClass().getCanonicalName() , context.getScope().getSimpleName() ) );
67 107 }
68 108 }
  109 +
  110 + /**
  111 + * Store a list of contexts into this producer. The contexts must have
  112 + * been registered into CDI by a portable extension, this method will not do this.
  113 + *
  114 + */
  115 + @PostConstruct
  116 + public void addRegisteredContexts(){
  117 + CustomContextBootstrap contextBootstrap = Beans.getReference(CustomContextBootstrap.class);
  118 +
  119 + List<CustomContext> contexts = contextBootstrap.getCustomContexts();
  120 +
  121 + for (CustomContext context : contexts){
  122 + addRegisteredContext(context);
  123 + }
  124 + }
69 125  
70 126 /**
71 127 * Deactivates all registered contexts and clear the context collection
... ... @@ -80,6 +136,8 @@ public class CustomContextProducer {
80 136 contexts.clear();
81 137 }
82 138  
  139 + /////////////PRODUCERS///////////////////
  140 +
83 141 @Produces
84 142 public RequestContext getRequestContext(InjectionPoint ip , CustomContextBootstrap extension){
85 143 return getContext(ip, extension);
... ... @@ -100,6 +158,12 @@ public class CustomContextProducer {
100 158 return getContext(ip, extension);
101 159 }
102 160  
  161 + @Produces
  162 + public ConversationContext getConversationContext(InjectionPoint ip , CustomContextBootstrap extension){
  163 + return getContext(ip, extension);
  164 + }
  165 +
  166 + /////////////END OF PRODUCERS///////////////////
103 167  
104 168 @SuppressWarnings("unchecked")
105 169 private <T extends CustomContext> T getContext(InjectionPoint ip , CustomContextBootstrap extension){
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/RequestContextImpl.java
... ... @@ -1,71 +0,0 @@
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   -/*
38   - * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the
39   - * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE
40   - * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is
41   - * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part
42   - * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the
43   - * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework
44   - * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
45   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
46   - * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see
47   - * <http://www.gnu.org/licenses/>.
48   - */
49   -package br.gov.frameworkdemoiselle.internal.context;
50   -
51   -import javax.enterprise.context.RequestScoped;
52   -import javax.enterprise.inject.Alternative;
53   -
54   -import br.gov.frameworkdemoiselle.annotation.Priority;
55   -import br.gov.frameworkdemoiselle.context.RequestContext;
56   -
57   -/**
58   - * Custom request context that stores beans in a thread local store.
59   - *
60   - * @author serpro
61   - *
62   - */
63   -@Priority(Priority.MIN_PRIORITY)
64   -@Alternative
65   -public class RequestContextImpl extends AbstractThreadLocalContext implements RequestContext {
66   -
67   - public RequestContextImpl() {
68   - super(RequestScoped.class);
69   - }
70   -
71   -}
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/SessionContextImpl.java
... ... @@ -1,71 +0,0 @@
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   -/*
38   - * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the
39   - * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE
40   - * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is
41   - * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part
42   - * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the
43   - * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework
44   - * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
45   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
46   - * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see
47   - * <http://www.gnu.org/licenses/>.
48   - */
49   -package br.gov.frameworkdemoiselle.internal.context;
50   -
51   -import javax.enterprise.context.SessionScoped;
52   -import javax.enterprise.inject.Alternative;
53   -
54   -import br.gov.frameworkdemoiselle.annotation.Priority;
55   -import br.gov.frameworkdemoiselle.context.SessionContext;
56   -
57   -
58   -/**
59   - *
60   - * @author serpro
61   - *
62   - */
63   -@Priority(Priority.MIN_PRIORITY)
64   -@Alternative
65   -public class SessionContextImpl extends AbstractStaticContext implements SessionContext {
66   -
67   - public SessionContextImpl() {
68   - super(SessionScoped.class);
69   - }
70   -
71   -}
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/StaticContextImpl.java
... ... @@ -54,6 +54,14 @@ import br.gov.frameworkdemoiselle.annotation.Priority;
54 54 import br.gov.frameworkdemoiselle.annotation.StaticScoped;
55 55 import br.gov.frameworkdemoiselle.context.StaticContext;
56 56  
  57 +/**
  58 + *
  59 + * Custom context that provide a single store for every thread that tries to instantiate
  60 + * beans of the {@link StaticScoped} custom scope.
  61 + *
  62 + * @author serpro
  63 + *
  64 + */
57 65 @Priority(Priority.MIN_PRIORITY)
58 66 @Alternative
59 67 public class StaticContextImpl extends AbstractStaticContext implements StaticContext {
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporaryConversationContextImpl.java 0 → 100644
... ... @@ -0,0 +1,75 @@
  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 +/*
  38 + * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the
  39 + * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE
  40 + * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is
  41 + * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part
  42 + * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the
  43 + * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework
  44 + * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  45 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
  46 + * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see
  47 + * <http://www.gnu.org/licenses/>.
  48 + */
  49 +package br.gov.frameworkdemoiselle.internal.context;
  50 +
  51 +import javax.enterprise.context.ConversationScoped;
  52 +import javax.enterprise.inject.Alternative;
  53 +
  54 +import br.gov.frameworkdemoiselle.annotation.Priority;
  55 +import br.gov.frameworkdemoiselle.context.ConversationContext;
  56 +
  57 +/**
  58 + *
  59 + * Temporary context meant to replace the conversation context on environments
  60 + * that doesn't provide a default context for the conversation scope. Such
  61 + * environments include desktop applications or remote JMX calls, that by CDI
  62 + * specification doesn't provide scopes and only have the application scope active.
  63 + *
  64 + * @author serpro
  65 + *
  66 + */
  67 +@Priority(Priority.MIN_PRIORITY)
  68 +@Alternative
  69 +public class TemporaryConversationContextImpl extends AbstractStaticContext implements ConversationContext {
  70 +
  71 + public TemporaryConversationContextImpl() {
  72 + super(ConversationScoped.class);
  73 + }
  74 +
  75 +}
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporaryRequestContextImpl.java 0 → 100644
... ... @@ -0,0 +1,75 @@
  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 +/*
  38 + * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the
  39 + * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE
  40 + * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is
  41 + * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part
  42 + * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the
  43 + * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework
  44 + * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  45 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
  46 + * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see
  47 + * <http://www.gnu.org/licenses/>.
  48 + */
  49 +package br.gov.frameworkdemoiselle.internal.context;
  50 +
  51 +import javax.enterprise.context.RequestScoped;
  52 +import javax.enterprise.inject.Alternative;
  53 +
  54 +import br.gov.frameworkdemoiselle.annotation.Priority;
  55 +import br.gov.frameworkdemoiselle.context.RequestContext;
  56 +
  57 +/**
  58 + *
  59 + * Temporary context meant to replace the request context on environments
  60 + * that doesn't provide a default context for the request scope. Such
  61 + * environments include desktop applications or remote JMX calls, that by CDI
  62 + * specification doesn't provide scopes and only have the application scope active.
  63 + *
  64 + * @author serpro
  65 + *
  66 + */
  67 +@Priority(Priority.MIN_PRIORITY)
  68 +@Alternative
  69 +public class TemporaryRequestContextImpl extends AbstractThreadLocalContext implements RequestContext {
  70 +
  71 + public TemporaryRequestContextImpl() {
  72 + super(RequestScoped.class);
  73 + }
  74 +
  75 +}
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporarySessionContextImpl.java 0 → 100644
... ... @@ -0,0 +1,76 @@
  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 +/*
  38 + * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the
  39 + * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE
  40 + * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is
  41 + * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part
  42 + * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the
  43 + * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework
  44 + * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  45 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
  46 + * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see
  47 + * <http://www.gnu.org/licenses/>.
  48 + */
  49 +package br.gov.frameworkdemoiselle.internal.context;
  50 +
  51 +import javax.enterprise.context.SessionScoped;
  52 +import javax.enterprise.inject.Alternative;
  53 +
  54 +import br.gov.frameworkdemoiselle.annotation.Priority;
  55 +import br.gov.frameworkdemoiselle.context.SessionContext;
  56 +
  57 +
  58 +/**
  59 + *
  60 + * Temporary context meant to replace the session context on environments
  61 + * that doesn't provide a default context for the session scope. Such
  62 + * environments include desktop applications or remote JMX calls, that by CDI
  63 + * specification doesn't provide scopes and only have the application scope active.
  64 + *
  65 + * @author serpro
  66 + *
  67 + */
  68 +@Priority(Priority.MIN_PRIORITY)
  69 +@Alternative
  70 +public class TemporarySessionContextImpl extends AbstractStaticContext implements SessionContext {
  71 +
  72 + public TemporarySessionContextImpl() {
  73 + super(SessionScoped.class);
  74 + }
  75 +
  76 +}
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporaryViewContextImpl.java 0 → 100644
... ... @@ -0,0 +1,75 @@
  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 +/*
  38 + * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the
  39 + * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE
  40 + * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is
  41 + * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part
  42 + * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the
  43 + * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework
  44 + * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  45 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
  46 + * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see
  47 + * <http://www.gnu.org/licenses/>.
  48 + */
  49 +package br.gov.frameworkdemoiselle.internal.context;
  50 +
  51 +import javax.enterprise.inject.Alternative;
  52 +
  53 +import br.gov.frameworkdemoiselle.annotation.Priority;
  54 +import br.gov.frameworkdemoiselle.annotation.ViewScoped;
  55 +import br.gov.frameworkdemoiselle.context.ViewContext;
  56 +
  57 +/**
  58 + *
  59 + * Temporary context meant to replace the view context on environments
  60 + * that doesn't provide a default context for the view scope. Such
  61 + * environments include desktop applications or remote JMX calls, that by CDI
  62 + * specification doesn't provide scopes and only have the application scope active.
  63 + *
  64 + * @author serpro
  65 + *
  66 + */
  67 +@Priority(Priority.MIN_PRIORITY)
  68 +@Alternative
  69 +public class TemporaryViewContextImpl extends AbstractThreadLocalContext implements ViewContext {
  70 +
  71 + public TemporaryViewContextImpl() {
  72 + super(ViewScoped.class);
  73 + }
  74 +
  75 +}
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/ThreadLocalViewContextImpl.java
... ... @@ -1,65 +0,0 @@
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   -/*
38   - * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the
39   - * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE
40   - * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is
41   - * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part
42   - * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the
43   - * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework
44   - * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
45   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
46   - * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see
47   - * <http://www.gnu.org/licenses/>.
48   - */
49   -package br.gov.frameworkdemoiselle.internal.context;
50   -
51   -import javax.enterprise.inject.Alternative;
52   -
53   -import br.gov.frameworkdemoiselle.annotation.Priority;
54   -import br.gov.frameworkdemoiselle.annotation.ViewScoped;
55   -import br.gov.frameworkdemoiselle.context.ViewContext;
56   -
57   -@Priority(Priority.MIN_PRIORITY)
58   -@Alternative
59   -public class ThreadLocalViewContextImpl extends AbstractThreadLocalContext implements ViewContext {
60   -
61   - public ThreadLocalViewContextImpl() {
62   - super(ViewScoped.class);
63   - }
64   -
65   -}
impl/extension/se/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/SeBootstrap.java
... ... @@ -40,6 +40,7 @@ import javax.enterprise.event.Observes;
40 40 import javax.enterprise.inject.spi.AfterDeploymentValidation;
41 41 import javax.enterprise.inject.spi.Extension;
42 42  
  43 +import br.gov.frameworkdemoiselle.context.ConversationContext;
43 44 import br.gov.frameworkdemoiselle.context.RequestContext;
44 45 import br.gov.frameworkdemoiselle.context.SessionContext;
45 46 import br.gov.frameworkdemoiselle.context.ViewContext;
... ... @@ -52,19 +53,23 @@ public class SeBootstrap implements Extension {
52 53 RequestContext requestContext = Beans.getReference(RequestContext.class);
53 54 SessionContext sessionContext = Beans.getReference(SessionContext.class);
54 55 ViewContext viewContext = Beans.getReference(ViewContext.class);
  56 + ConversationContext conversationContext = Beans.getReference(ConversationContext.class);
55 57  
56 58 requestContext.activate();
57 59 sessionContext.activate();
58 60 viewContext.activate();
  61 + conversationContext.activate();
59 62 }
60 63  
61 64 public void removeContexts(@Observes AfterShutdownProccess event) {
62 65 RequestContext requestContext = Beans.getReference(RequestContext.class);
63 66 SessionContext sessionContext = Beans.getReference(SessionContext.class);
64 67 ViewContext viewContext = Beans.getReference(ViewContext.class);
  68 + ConversationContext conversationContext = Beans.getReference(ConversationContext.class);
65 69  
66 70 requestContext.deactivate();
67 71 sessionContext.deactivate();
68 72 viewContext.deactivate();
  73 + conversationContext.activate();
69 74 }
70 75 }
... ...
impl/extension/se/src/test/resources/demoiselle-core-bundle.properties
... ... @@ -60,14 +60,15 @@ loading-configuration-class=Carregando a classe de configura\u00E7\u00E3o {0}
60 60 configuration-field-loaded=Configura\u00E7\u00E3o {0} atribu\u00EDda a {1} com o valor {2}
61 61 configuration-attribute-is-mandatory=A configura\u00E7\u00E3o {0} \u00E9 obrigat\u00F3ria, mas n\u00E3o foi encontrada em {1}
62 62 configuration-name-attribute-cant-be-empty=A nota\u00E7\u00E3o Name n\u00E3o pode estar em branco
  63 +configuration-generic-extraction-error=Ocorreu um erro durante a extra\u00E7\u00E3o do tipo {0} com o extrator {1}
  64 +configuration-dot-after-prefix=N\u00E3o \u00E9 necess\u00E1rio adicionar o ponto ap\u00F3s o prefixo para uma classe de configura\u00E7\u00E3o. \u00C9 recomendado que sejam retirados, pois poder\u00E3o causar erros em vers\u00F5es futuras do Framework.
63 65 configuration-key-not-found=Chave de configura\u00E7\u00E3o {0} n\u00E3o encontrada
64 66 configuration-extractor-not-found=N\u00E3o foi poss\u00EDvel encontrar a classe extratora para o atributo {0}. Implemente a interface {1} para criar sua classe extratora.
65 67 configuration-not-conversion=N\u00E3o \u00E9 poss\u00EDvel converter o valor {0} para o tipo {1}
66 68  
67 69 transaction-not-defined=Nenhuma transa\u00E7\u00E3o foi definida. Para utilizar @{0} \u00E9 preciso definir a propriedade frameworkdemoiselle.transaction.class com a estrat\u00E9gia de transa\u00E7\u00E3o desejada no arquivo demoiselle.properties
68 70 executing-all=Executando todos os \: {0}
69   -custom-context-was-registered=O contexto {0} foi registrado
70   -custom-context-was-unregistered=O contexto {0} foi removido
  71 +custom-context-selected=Produzindo inst\u00E2ncia do contexto {0}
71 72 custom-context-was-activated=O contexto {0} foi ativado para o escopo {1}
72 73 custom-context-was-deactivated=O contexto {0} foi desativado para o escopo {1}
73 74 custom-context-already-activated=N\u00E3o foi poss\u00EDvel ativar o contexto {0}, o escopo {1} j\u00E1 est\u00E1 ativo no contexto {2}
... ...