diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/context/ConversationContext.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/context/ConversationContext.java new file mode 100644 index 0000000..8f9cfbb --- /dev/null +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/context/ConversationContext.java @@ -0,0 +1,6 @@ +package br.gov.frameworkdemoiselle.context; + + +public interface ConversationContext extends CustomContext { + +} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/CustomContextBootstrap.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/CustomContextBootstrap.java index 5524b88..464699c 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/CustomContextBootstrap.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/CustomContextBootstrap.java @@ -5,17 +5,15 @@ import java.util.List; import javax.enterprise.event.Observes; import javax.enterprise.inject.spi.AfterBeanDiscovery; -import javax.enterprise.inject.spi.AfterDeploymentValidation; import javax.enterprise.inject.spi.Extension; import br.gov.frameworkdemoiselle.context.CustomContext; import br.gov.frameworkdemoiselle.context.StaticContext; -import br.gov.frameworkdemoiselle.internal.context.CustomContextProducer; -import br.gov.frameworkdemoiselle.internal.context.RequestContextImpl; -import br.gov.frameworkdemoiselle.internal.context.SessionContextImpl; +import br.gov.frameworkdemoiselle.internal.context.TemporaryRequestContextImpl; +import br.gov.frameworkdemoiselle.internal.context.TemporarySessionContextImpl; import br.gov.frameworkdemoiselle.internal.context.StaticContextImpl; -import br.gov.frameworkdemoiselle.internal.context.ThreadLocalViewContextImpl; -import br.gov.frameworkdemoiselle.util.Beans; +import br.gov.frameworkdemoiselle.internal.context.TemporaryConversationContextImpl; +import br.gov.frameworkdemoiselle.internal.context.TemporaryViewContextImpl; /** * This portable extension registers and starts custom contexts used by @@ -28,26 +26,6 @@ public class CustomContextBootstrap implements Extension{ private List contexts; - /*private Logger logger; - - private transient ResourceBundle bundle; - - private Logger getLogger() { - if (this.logger == null) { - this.logger = LoggerProducer.create(CoreBootstrap.class); - } - - return this.logger; - } - - private ResourceBundle getBundle() { - if (bundle == null) { - bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); - } - - return bundle; - }*/ - public void initializeContexts(@Observes AfterBeanDiscovery event){ //Cadastra os contextos contidos no demoiselle-core if (contexts==null || contexts.isEmpty()){ @@ -55,16 +33,19 @@ public class CustomContextBootstrap implements Extension{ contexts = new ArrayList(); - ctx = new RequestContextImpl(); + ctx = new TemporaryRequestContextImpl(); contexts.add(ctx); - ctx = new SessionContextImpl(); + ctx = new TemporarySessionContextImpl(); contexts.add(ctx); ctx = new StaticContextImpl(); contexts.add(ctx); - ctx = new ThreadLocalViewContextImpl(); + ctx = new TemporaryViewContextImpl(); + contexts.add(ctx); + + ctx = new TemporaryConversationContextImpl(); contexts.add(ctx); for (CustomContext c : contexts){ @@ -82,9 +63,13 @@ public class CustomContextBootstrap implements Extension{ } } - public void storeContexts(@Observes AfterDeploymentValidation event){ + public List getCustomContexts(){ + return this.contexts; + } + + /*public void storeContexts(@Observes AfterDeploymentValidation event){ CustomContextProducer producer = Beans.getReference(CustomContextProducer.class); producer.addRegisteredContexts(contexts); - } + }*/ } diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/CustomContextProducer.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/CustomContextProducer.java index 529e265..c9f5e4f 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/CustomContextProducer.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/CustomContextProducer.java @@ -1,10 +1,58 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +/* + * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the + * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE + * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is + * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part + * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework + * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You + * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see + * . + */ package br.gov.frameworkdemoiselle.internal.context; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Locale; +import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.inject.Produces; @@ -12,6 +60,7 @@ import javax.enterprise.inject.spi.InjectionPoint; import org.slf4j.Logger; +import br.gov.frameworkdemoiselle.context.ConversationContext; import br.gov.frameworkdemoiselle.context.CustomContext; import br.gov.frameworkdemoiselle.context.RequestContext; import br.gov.frameworkdemoiselle.context.SessionContext; @@ -20,10 +69,11 @@ import br.gov.frameworkdemoiselle.context.ViewContext; import br.gov.frameworkdemoiselle.internal.bootstrap.CustomContextBootstrap; import br.gov.frameworkdemoiselle.internal.implementation.StrategySelector; import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; +import br.gov.frameworkdemoiselle.util.Beans; import br.gov.frameworkdemoiselle.util.ResourceBundle; /** - * Produces instances of {@link CustomContext} to control contexts not active + * Produces instances of {@link CustomContext} to control contexts not activated * by the container * * @author serpro @@ -38,16 +88,6 @@ public class CustomContextProducer { private List contexts = new ArrayList(); - /** - * Store a list of contexts into this producer. The contexts must have - * been registered into CDI by a portable extension, this method will not do this. - * - */ - public void addRegisteredContexts(Collection contexts){ - for (CustomContext context : contexts){ - addRegisteredContext(context); - } - } /** * Store a context into this producer. The context must have @@ -66,6 +106,22 @@ public class CustomContextProducer { logger.debug( bundle.getString("bootstrap-context-already-managed", context.getClass().getCanonicalName() , context.getScope().getSimpleName() ) ); } } + + /** + * Store a list of contexts into this producer. The contexts must have + * been registered into CDI by a portable extension, this method will not do this. + * + */ + @PostConstruct + public void addRegisteredContexts(){ + CustomContextBootstrap contextBootstrap = Beans.getReference(CustomContextBootstrap.class); + + List contexts = contextBootstrap.getCustomContexts(); + + for (CustomContext context : contexts){ + addRegisteredContext(context); + } + } /** * Deactivates all registered contexts and clear the context collection @@ -80,6 +136,8 @@ public class CustomContextProducer { contexts.clear(); } + /////////////PRODUCERS/////////////////// + @Produces public RequestContext getRequestContext(InjectionPoint ip , CustomContextBootstrap extension){ return getContext(ip, extension); @@ -100,6 +158,12 @@ public class CustomContextProducer { return getContext(ip, extension); } + @Produces + public ConversationContext getConversationContext(InjectionPoint ip , CustomContextBootstrap extension){ + return getContext(ip, extension); + } + + /////////////END OF PRODUCERS/////////////////// @SuppressWarnings("unchecked") private T getContext(InjectionPoint ip , CustomContextBootstrap extension){ diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/RequestContextImpl.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/RequestContextImpl.java deleted file mode 100644 index c043acf..0000000 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/RequestContextImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -/* - * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the - * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE - * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is - * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part - * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework - * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You - * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see - * . - */ -package br.gov.frameworkdemoiselle.internal.context; - -import javax.enterprise.context.RequestScoped; -import javax.enterprise.inject.Alternative; - -import br.gov.frameworkdemoiselle.annotation.Priority; -import br.gov.frameworkdemoiselle.context.RequestContext; - -/** - * Custom request context that stores beans in a thread local store. - * - * @author serpro - * - */ -@Priority(Priority.MIN_PRIORITY) -@Alternative -public class RequestContextImpl extends AbstractThreadLocalContext implements RequestContext { - - public RequestContextImpl() { - super(RequestScoped.class); - } - -} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/SessionContextImpl.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/SessionContextImpl.java deleted file mode 100644 index 329ac12..0000000 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/SessionContextImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -/* - * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the - * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE - * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is - * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part - * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework - * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You - * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see - * . - */ -package br.gov.frameworkdemoiselle.internal.context; - -import javax.enterprise.context.SessionScoped; -import javax.enterprise.inject.Alternative; - -import br.gov.frameworkdemoiselle.annotation.Priority; -import br.gov.frameworkdemoiselle.context.SessionContext; - - -/** - * - * @author serpro - * - */ -@Priority(Priority.MIN_PRIORITY) -@Alternative -public class SessionContextImpl extends AbstractStaticContext implements SessionContext { - - public SessionContextImpl() { - super(SessionScoped.class); - } - -} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/StaticContextImpl.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/StaticContextImpl.java index 706cfb9..a45e647 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/StaticContextImpl.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/StaticContextImpl.java @@ -54,6 +54,14 @@ import br.gov.frameworkdemoiselle.annotation.Priority; import br.gov.frameworkdemoiselle.annotation.StaticScoped; import br.gov.frameworkdemoiselle.context.StaticContext; +/** + * + * Custom context that provide a single store for every thread that tries to instantiate + * beans of the {@link StaticScoped} custom scope. + * + * @author serpro + * + */ @Priority(Priority.MIN_PRIORITY) @Alternative public class StaticContextImpl extends AbstractStaticContext implements StaticContext { diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporaryConversationContextImpl.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporaryConversationContextImpl.java new file mode 100644 index 0000000..13501e9 --- /dev/null +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporaryConversationContextImpl.java @@ -0,0 +1,75 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +/* + * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the + * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE + * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is + * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part + * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework + * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You + * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see + * . + */ +package br.gov.frameworkdemoiselle.internal.context; + +import javax.enterprise.context.ConversationScoped; +import javax.enterprise.inject.Alternative; + +import br.gov.frameworkdemoiselle.annotation.Priority; +import br.gov.frameworkdemoiselle.context.ConversationContext; + +/** + * + * Temporary context meant to replace the conversation context on environments + * that doesn't provide a default context for the conversation scope. Such + * environments include desktop applications or remote JMX calls, that by CDI + * specification doesn't provide scopes and only have the application scope active. + * + * @author serpro + * + */ +@Priority(Priority.MIN_PRIORITY) +@Alternative +public class TemporaryConversationContextImpl extends AbstractStaticContext implements ConversationContext { + + public TemporaryConversationContextImpl() { + super(ConversationScoped.class); + } + +} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporaryRequestContextImpl.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporaryRequestContextImpl.java new file mode 100644 index 0000000..48d2d6c --- /dev/null +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporaryRequestContextImpl.java @@ -0,0 +1,75 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +/* + * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the + * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE + * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is + * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part + * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework + * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You + * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see + * . + */ +package br.gov.frameworkdemoiselle.internal.context; + +import javax.enterprise.context.RequestScoped; +import javax.enterprise.inject.Alternative; + +import br.gov.frameworkdemoiselle.annotation.Priority; +import br.gov.frameworkdemoiselle.context.RequestContext; + +/** + * + * Temporary context meant to replace the request context on environments + * that doesn't provide a default context for the request scope. Such + * environments include desktop applications or remote JMX calls, that by CDI + * specification doesn't provide scopes and only have the application scope active. + * + * @author serpro + * + */ +@Priority(Priority.MIN_PRIORITY) +@Alternative +public class TemporaryRequestContextImpl extends AbstractThreadLocalContext implements RequestContext { + + public TemporaryRequestContextImpl() { + super(RequestScoped.class); + } + +} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporarySessionContextImpl.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporarySessionContextImpl.java new file mode 100644 index 0000000..f141960 --- /dev/null +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporarySessionContextImpl.java @@ -0,0 +1,76 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +/* + * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the + * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE + * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is + * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part + * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework + * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You + * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see + * . + */ +package br.gov.frameworkdemoiselle.internal.context; + +import javax.enterprise.context.SessionScoped; +import javax.enterprise.inject.Alternative; + +import br.gov.frameworkdemoiselle.annotation.Priority; +import br.gov.frameworkdemoiselle.context.SessionContext; + + +/** + * + * Temporary context meant to replace the session context on environments + * that doesn't provide a default context for the session scope. Such + * environments include desktop applications or remote JMX calls, that by CDI + * specification doesn't provide scopes and only have the application scope active. + * + * @author serpro + * + */ +@Priority(Priority.MIN_PRIORITY) +@Alternative +public class TemporarySessionContextImpl extends AbstractStaticContext implements SessionContext { + + public TemporarySessionContextImpl() { + super(SessionScoped.class); + } + +} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporaryViewContextImpl.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporaryViewContextImpl.java new file mode 100644 index 0000000..b8166d2 --- /dev/null +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/TemporaryViewContextImpl.java @@ -0,0 +1,75 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +/* + * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the + * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE + * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is + * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part + * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework + * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You + * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see + * . + */ +package br.gov.frameworkdemoiselle.internal.context; + +import javax.enterprise.inject.Alternative; + +import br.gov.frameworkdemoiselle.annotation.Priority; +import br.gov.frameworkdemoiselle.annotation.ViewScoped; +import br.gov.frameworkdemoiselle.context.ViewContext; + +/** + * + * Temporary context meant to replace the view context on environments + * that doesn't provide a default context for the view scope. Such + * environments include desktop applications or remote JMX calls, that by CDI + * specification doesn't provide scopes and only have the application scope active. + * + * @author serpro + * + */ +@Priority(Priority.MIN_PRIORITY) +@Alternative +public class TemporaryViewContextImpl extends AbstractThreadLocalContext implements ViewContext { + + public TemporaryViewContextImpl() { + super(ViewScoped.class); + } + +} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/ThreadLocalViewContextImpl.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/ThreadLocalViewContextImpl.java deleted file mode 100644 index 08c0929..0000000 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/ThreadLocalViewContextImpl.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -/* - * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the - * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE - * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is - * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part - * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework - * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You - * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see - * . - */ -package br.gov.frameworkdemoiselle.internal.context; - -import javax.enterprise.inject.Alternative; - -import br.gov.frameworkdemoiselle.annotation.Priority; -import br.gov.frameworkdemoiselle.annotation.ViewScoped; -import br.gov.frameworkdemoiselle.context.ViewContext; - -@Priority(Priority.MIN_PRIORITY) -@Alternative -public class ThreadLocalViewContextImpl extends AbstractThreadLocalContext implements ViewContext { - - public ThreadLocalViewContextImpl() { - super(ViewScoped.class); - } - -} diff --git a/impl/extension/se/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/SeBootstrap.java b/impl/extension/se/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/SeBootstrap.java index 28ccfe0..d59214e 100644 --- a/impl/extension/se/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/SeBootstrap.java +++ b/impl/extension/se/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/SeBootstrap.java @@ -40,6 +40,7 @@ import javax.enterprise.event.Observes; import javax.enterprise.inject.spi.AfterDeploymentValidation; import javax.enterprise.inject.spi.Extension; +import br.gov.frameworkdemoiselle.context.ConversationContext; import br.gov.frameworkdemoiselle.context.RequestContext; import br.gov.frameworkdemoiselle.context.SessionContext; import br.gov.frameworkdemoiselle.context.ViewContext; @@ -52,19 +53,23 @@ public class SeBootstrap implements Extension { RequestContext requestContext = Beans.getReference(RequestContext.class); SessionContext sessionContext = Beans.getReference(SessionContext.class); ViewContext viewContext = Beans.getReference(ViewContext.class); + ConversationContext conversationContext = Beans.getReference(ConversationContext.class); requestContext.activate(); sessionContext.activate(); viewContext.activate(); + conversationContext.activate(); } public void removeContexts(@Observes AfterShutdownProccess event) { RequestContext requestContext = Beans.getReference(RequestContext.class); SessionContext sessionContext = Beans.getReference(SessionContext.class); ViewContext viewContext = Beans.getReference(ViewContext.class); + ConversationContext conversationContext = Beans.getReference(ConversationContext.class); requestContext.deactivate(); sessionContext.deactivate(); viewContext.deactivate(); + conversationContext.activate(); } } diff --git a/impl/extension/se/src/test/resources/demoiselle-core-bundle.properties b/impl/extension/se/src/test/resources/demoiselle-core-bundle.properties index 1d1f611..d06d244 100644 --- a/impl/extension/se/src/test/resources/demoiselle-core-bundle.properties +++ b/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} configuration-field-loaded=Configura\u00E7\u00E3o {0} atribu\u00EDda a {1} com o valor {2} configuration-attribute-is-mandatory=A configura\u00E7\u00E3o {0} \u00E9 obrigat\u00F3ria, mas n\u00E3o foi encontrada em {1} configuration-name-attribute-cant-be-empty=A nota\u00E7\u00E3o Name n\u00E3o pode estar em branco +configuration-generic-extraction-error=Ocorreu um erro durante a extra\u00E7\u00E3o do tipo {0} com o extrator {1} +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. configuration-key-not-found=Chave de configura\u00E7\u00E3o {0} n\u00E3o encontrada 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. configuration-not-conversion=N\u00E3o \u00E9 poss\u00EDvel converter o valor {0} para o tipo {1} 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 executing-all=Executando todos os \: {0} -custom-context-was-registered=O contexto {0} foi registrado -custom-context-was-unregistered=O contexto {0} foi removido +custom-context-selected=Produzindo inst\u00E2ncia do contexto {0} custom-context-was-activated=O contexto {0} foi ativado para o escopo {1} custom-context-was-deactivated=O contexto {0} foi desativado para o escopo {1} custom-context-already-activated=N\u00E3o foi poss\u00EDvel ativar o contexto {0}, o escopo {1} j\u00E1 est\u00E1 ativo no contexto {2} -- libgit2 0.21.2