diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ApplicationLifecycleEvent.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ApplicationLifecycleEvent.java
index 537249c..69ef2ec 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ApplicationLifecycleEvent.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ApplicationLifecycleEvent.java
@@ -1,6 +1,42 @@
+/*
+ * 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.
+ */
package br.gov.frameworkdemoiselle.internal.bootstrap;
-public interface ApplicationLifecycleEvent {
+interface ApplicationLifecycleEvent {
boolean removeProcessors();
}
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/BeforeApplicationFinalization.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/BeforeApplicationFinalization.java
index e8e6f46..796902b 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/BeforeApplicationFinalization.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/BeforeApplicationFinalization.java
@@ -1,3 +1,39 @@
+/*
+ * 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.
+ */
package br.gov.frameworkdemoiselle.internal.bootstrap;
public interface BeforeApplicationFinalization extends ApplicationLifecycleEvent {
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/BeforeApplicationInitialization.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/BeforeApplicationInitialization.java
index 90ce216..040f9ea 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/BeforeApplicationInitialization.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/BeforeApplicationInitialization.java
@@ -1,3 +1,39 @@
+/*
+ * 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.
+ */
package br.gov.frameworkdemoiselle.internal.bootstrap;
public interface BeforeApplicationInitialization extends ApplicationLifecycleEvent {
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImpl.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImpl.java
index ae83d1f..6d82a72 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImpl.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImpl.java
@@ -36,8 +36,6 @@
*/
package br.gov.frameworkdemoiselle.internal.implementation;
-import java.util.Locale;
-
import javax.inject.Named;
import br.gov.frameworkdemoiselle.internal.configuration.SecurityConfig;
@@ -179,9 +177,7 @@ public class SecurityContextImpl implements SecurityContext {
private void checkLoggedIn() throws NotLoggedInException {
if (!isLoggedIn()) {
- Locale locale = Beans.getReference(Locale.class);
- ResourceBundle bundle = ResourceBundleProducer.create("demoiselle-core-bundle", locale);
-
+ ResourceBundle bundle = ResourceBundleProducer.create("demoiselle-core-bundle");
throw new NotLoggedInException(bundle.getString("user-not-authenticated"));
}
}
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/StrategySelector.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/StrategySelector.java
index 6fe8e2f..2a2b71a 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/StrategySelector.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/StrategySelector.java
@@ -1,3 +1,39 @@
+/*
+ * 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.
+ */
package br.gov.frameworkdemoiselle.internal.implementation;
import java.io.FileNotFoundException;
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/TrancationContextImpl.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/TrancationContextImpl.java
index ed97790..aad1a9e 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/TrancationContextImpl.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/TrancationContextImpl.java
@@ -16,8 +16,9 @@ public class TrancationContextImpl implements TransactionContext {
private static final long serialVersionUID = 1L;
@Override
- public Transaction currentTransaction() {
- return StrategySelector.getReference("frameworkdemoiselle.transaction.class", Transaction.class, DefaultTransaction.class);
+ public Transaction getCurrentTransaction() {
+ return StrategySelector.getReference("frameworkdemoiselle.transaction.class", Transaction.class,
+ DefaultTransaction.class);
}
}
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionInfo.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionInfo.java
index d56211f..6f0af4c 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionInfo.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionInfo.java
@@ -1,11 +1,45 @@
+/*
+ * 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.
+ */
package br.gov.frameworkdemoiselle.internal.implementation;
import java.io.Serializable;
import javax.enterprise.context.RequestScoped;
-//TODO Inter [NQ]: considerar a necessidade da criação de um contexto de transação para manter a coerência com as demais funcionalidades que possuem um contexto.
-//Resposta: não foi feito porque só foi identificado uma funcionalidade (getCurrentTransaction). Aguardar novas ideias.
@RequestScoped
public class TransactionInfo implements Serializable {
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/interceptor/TransactionalInterceptor.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/interceptor/TransactionalInterceptor.java
index f5f80be..35ab593 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/interceptor/TransactionalInterceptor.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/interceptor/TransactionalInterceptor.java
@@ -38,20 +38,20 @@ package br.gov.frameworkdemoiselle.internal.interceptor;
import java.io.Serializable;
-import javax.enterprise.inject.Instance;
-import javax.inject.Inject;
+import javax.enterprise.context.ContextNotActiveException;
import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
import org.slf4j.Logger;
-import br.gov.frameworkdemoiselle.annotation.Name;
import br.gov.frameworkdemoiselle.exception.ApplicationException;
import br.gov.frameworkdemoiselle.internal.implementation.TransactionInfo;
+import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;
import br.gov.frameworkdemoiselle.transaction.Transaction;
import br.gov.frameworkdemoiselle.transaction.TransactionContext;
import br.gov.frameworkdemoiselle.transaction.Transactional;
+import br.gov.frameworkdemoiselle.util.Beans;
import br.gov.frameworkdemoiselle.util.ResourceBundle;
@Interceptor
@@ -60,22 +60,41 @@ public class TransactionalInterceptor implements Serializable {
private static final long serialVersionUID = 1L;
- private final Instance context;
+ private TransactionContext transactionContext;
- private final Logger logger;
+ private TransactionInfo transactionInfo;
- private final ResourceBundle bundle;
+ private ResourceBundle bundle;
- private final Instance info;
+ private Logger logger;
- @Inject
- public TransactionalInterceptor(Instance context, Instance info,
- Logger logger, @Name("demoiselle-core-bundle") ResourceBundle bundle) {
- this.context = context;
- this.info = info;
- this.logger = logger;
- this.bundle = bundle;
+ private TransactionContext getTransactionContext() {
+ if (this.transactionContext == null) {
+ this.transactionContext = Beans.getReference(TransactionContext.class);
+ }
+
+ return this.transactionContext;
+ }
+
+ private TransactionInfo newTransactionInfo() {
+ TransactionInfo instance;
+
+ try {
+ instance = Beans.getReference(TransactionInfo.class);
+
+ } catch (ContextNotActiveException cause) {
+ instance = new TransactionInfo();
+ }
+
+ return instance;
+ }
+
+ private TransactionInfo getTransactionInfo() {
+ if (this.transactionInfo == null) {
+ this.transactionInfo = newTransactionInfo();
+ }
+ return this.transactionInfo;
}
@AroundInvoke
@@ -84,9 +103,7 @@ public class TransactionalInterceptor implements Serializable {
Object result = null;
try {
- this.logger.debug(bundle.getString("transactional-execution", ic.getMethod().toGenericString()));
- info.get().incrementCounter();
-
+ getLogger().debug(getBundle().getString("transactional-execution", ic.getMethod().toGenericString()));
result = ic.proceed();
} catch (Exception cause) {
@@ -94,7 +111,6 @@ public class TransactionalInterceptor implements Serializable {
throw cause;
} finally {
- info.get().decrementCounter();
complete(ic);
}
@@ -102,20 +118,22 @@ public class TransactionalInterceptor implements Serializable {
}
private void initiate(final InvocationContext ic) {
- Transaction tx = this.context.get().currentTransaction();
- TransactionInfo ctx = this.info.get();
+ Transaction transaction = getTransactionContext().getCurrentTransaction();
+ TransactionInfo transactionInfo = getTransactionInfo();
- if (!tx.isActive()) {
- tx.begin();
- ctx.markAsOwner();
- this.logger.info(bundle.getString("begin-transaction"));
+ if (!transaction.isActive()) {
+ transaction.begin();
+ transactionInfo.markAsOwner();
+ getLogger().info(getBundle().getString("begin-transaction"));
}
+
+ transactionInfo.incrementCounter();
}
private void handleException(final Exception cause) {
- Transaction tx = this.context.get().currentTransaction();
+ Transaction transaction = getTransactionContext().getCurrentTransaction();
- if (!tx.isMarkedRollback()) {
+ if (!transaction.isMarkedRollback()) {
boolean rollback = false;
ApplicationException annotation = cause.getClass().getAnnotation(ApplicationException.class);
@@ -124,30 +142,47 @@ public class TransactionalInterceptor implements Serializable {
}
if (rollback) {
- tx.setRollbackOnly();
- this.logger.info(bundle.getString("transaction-marked-rollback", cause.getMessage()));
+ transaction.setRollbackOnly();
+ getLogger().info(getBundle().getString("transaction-marked-rollback", cause.getMessage()));
}
}
}
private void complete(final InvocationContext ic) {
- Transaction tx = this.context.get().currentTransaction();
- TransactionInfo ctx = this.info.get();
+ Transaction transaction = getTransactionContext().getCurrentTransaction();
+ TransactionInfo transactionInfo = getTransactionInfo();
+ transactionInfo.decrementCounter();
- if (ctx.getCounter() == 0 && tx.isActive()) {
+ if (transactionInfo.getCounter() == 0 && transaction.isActive()) {
- if (ctx.isOwner()) {
- if (tx.isMarkedRollback()) {
- tx.rollback();
- this.logger.info(bundle.getString("transaction-rolledback"));
+ if (transactionInfo.isOwner()) {
+ if (transaction.isMarkedRollback()) {
+ transaction.rollback();
+ getLogger().info(getBundle().getString("transaction-rolledback"));
} else {
- tx.commit();
- this.logger.info(bundle.getString("transaction-commited"));
+ transaction.commit();
+ getLogger().info(getBundle().getString("transaction-commited"));
}
}
- } else if (ctx.getCounter() == 0 && !tx.isActive()) {
- this.logger.info(bundle.getString("transaction-already-finalized"));
+ } else if (transactionInfo.getCounter() == 0 && !transaction.isActive()) {
+ getLogger().info(getBundle().getString("transaction-already-finalized"));
+ }
+ }
+
+ private ResourceBundle getBundle() {
+ if (this.bundle == null) {
+ this.bundle = ResourceBundleProducer.create("demoiselle-core-bundle");
}
+
+ return this.bundle;
+ }
+
+ private Logger getLogger() {
+ if (this.logger == null) {
+ this.logger = Beans.getReference(Logger.class);
+ }
+
+ return this.logger;
}
}
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/transaction/TransactionContext.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/transaction/TransactionContext.java
index 24de0b7..1742b06 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/transaction/TransactionContext.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/transaction/TransactionContext.java
@@ -45,5 +45,5 @@ import java.io.Serializable;
*/
public interface TransactionContext extends Serializable {
- Transaction currentTransaction();
+ Transaction getCurrentTransaction();
}
--
libgit2 0.21.2