diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AbstractProcessor.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AbstractProcessor.java deleted file mode 100644 index 3d83219..0000000 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AbstractProcessor.java +++ /dev/null @@ -1,113 +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. - */ -package br.gov.frameworkdemoiselle.internal.processor; - -import java.util.Locale; - -import javax.enterprise.inject.spi.AnnotatedCallable; -import javax.enterprise.inject.spi.BeanManager; - -import org.slf4j.Logger; - -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; -import br.gov.frameworkdemoiselle.util.Beans; -import br.gov.frameworkdemoiselle.util.ResourceBundle; - -/** - * It abstract the integration between Processor and the context; - * - * @param - * the declaring class - */ -public abstract class AbstractProcessor implements Processor { - - private BeanManager beanManager; - - private AnnotatedCallable annotatedCallable; - - private ResourceBundle bundle; - - protected static final String BUNDLE_BASE_NAME = "demoiselle-core-bundle"; - - public AbstractProcessor(final BeanManager beanManager) { - this.beanManager = beanManager; - } - - public AbstractProcessor(final AnnotatedCallable annotatedCallable, final BeanManager beanManager) { - this.annotatedCallable = annotatedCallable; - this.beanManager = beanManager; - } - - protected AnnotatedCallable getAnnotatedCallable() { - return this.annotatedCallable; - } - - protected BeanManager getBeanManager() { - return this.beanManager; - } - - /** - * Ask the bean manager for the firt instance of the declaring classe for this java member, then returns the current - * reference; - * - * @param - * DeclaringClass - * @return - */ - @SuppressWarnings("unchecked") - protected T getReferencedBean() { - Class classType = (Class) getAnnotatedCallable().getJavaMember().getDeclaringClass(); - return Beans.getReference(classType); - } - - protected ResourceBundle getBundle() { - return getBundle(BUNDLE_BASE_NAME); - } - - protected ResourceBundle getBundle(String baseName) { - if (bundle == null) { - bundle = ResourceBundleProducer.create(baseName, Locale.getDefault()); - } - - return bundle; - } - - protected Logger getLogger() { - return LoggerProducer.create(this.getClass()); - } -} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AnnotatedMethodProcessor.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AnnotatedMethodProcessor.java deleted file mode 100644 index 788588e..0000000 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AnnotatedMethodProcessor.java +++ /dev/null @@ -1,125 +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. - */ -package br.gov.frameworkdemoiselle.internal.processor; - -import java.lang.reflect.InvocationTargetException; - -import javax.enterprise.inject.spi.AnnotatedMethod; -import javax.enterprise.inject.spi.BeanManager; - -import br.gov.frameworkdemoiselle.annotation.Priority; -import br.gov.frameworkdemoiselle.exception.ApplicationException; -import br.gov.frameworkdemoiselle.message.SeverityType; - -/** - * Represents an annotated method to be processed; - * - * @param - * declaring class owner of the method - */ -public abstract class AnnotatedMethodProcessor extends AbstractProcessor implements - Comparable> { - - public AnnotatedMethodProcessor(final AnnotatedMethod annotatedMethod, final BeanManager beanManager) { - super(annotatedMethod, beanManager); - } - - public AnnotatedMethod getAnnotatedMethod() { - return (AnnotatedMethod) getAnnotatedCallable(); - } - - protected Integer getPriority(AnnotatedMethod annotatedMethod) { - Integer priority = Priority.MIN_PRIORITY; - - Priority annotation = annotatedMethod.getAnnotation(Priority.class); - if (annotation != null) { - priority = annotation.value(); - } - - return priority; - } - - public int compareTo(final AnnotatedMethodProcessor other) { - Integer orderThis = getPriority(getAnnotatedMethod()); - Integer orderOther = getPriority(other.getAnnotatedMethod()); - - return orderThis.compareTo(orderOther); - } - - public boolean process(Object... args) throws Throwable { - getLogger().info(getBundle().getString("processing", getAnnotatedMethod().getJavaMember().toGenericString())); - - try { - getAnnotatedMethod().getJavaMember().invoke(getReferencedBean(), args); - - } catch (InvocationTargetException cause) { - handleException(cause.getCause()); - } - - return true; - } - - private void handleException(Throwable cause) throws Throwable { - ApplicationException ann = cause.getClass().getAnnotation(ApplicationException.class); - - if (ann == null || SeverityType.FATAL == ann.severity()) { - throw cause; - - } else { - switch (ann.severity()) { - case INFO: - getLogger().info(cause.getMessage()); - break; - - case WARN: - getLogger().warn(cause.getMessage()); - break; - - default: - getLogger().error(getBundle().getString("processing-fail"), cause); - break; - } - } - } - - @Override - public String toString() { - return getBundle().getString("for", getClass().getSimpleName(), - getAnnotatedMethod().getJavaMember().toGenericString()); - } - -} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/Processor.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/Processor.java deleted file mode 100644 index 4147293..0000000 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/Processor.java +++ /dev/null @@ -1,45 +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. - */ -package br.gov.frameworkdemoiselle.internal.processor; - -/** - * Represents an classe that can be processed. - */ -public interface Processor { - - public boolean process(Object... args) throws Throwable; -} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/ShutdownProcessor.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/ShutdownProcessor.java deleted file mode 100644 index b40713c..0000000 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/ShutdownProcessor.java +++ /dev/null @@ -1,67 +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. - */ -package br.gov.frameworkdemoiselle.internal.processor; - -import javax.enterprise.inject.spi.AnnotatedMethod; -import javax.enterprise.inject.spi.BeanManager; - -import br.gov.frameworkdemoiselle.annotation.Priority; -import br.gov.frameworkdemoiselle.annotation.Shutdown; - -/** - * Processor for a {@code Shutdown} annotated method, making it comparable. - * - * @param - */ -public class ShutdownProcessor extends AnnotatedMethodProcessor { - - public ShutdownProcessor(AnnotatedMethod annotatedMethod, BeanManager beanManager) { - super(annotatedMethod, beanManager); - } - - @SuppressWarnings("deprecation") - protected Integer getPriority(AnnotatedMethod annotatedMethod) { - Integer priority = super.getPriority(annotatedMethod); - - if (!annotatedMethod.isAnnotationPresent(Priority.class)) { - Shutdown annotation = annotatedMethod.getAnnotation(Shutdown.class); - priority = annotation.priority(); - } - - return priority; - } -} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/StartupProcessor.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/StartupProcessor.java deleted file mode 100644 index 96cc555..0000000 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/StartupProcessor.java +++ /dev/null @@ -1,67 +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. - */ -package br.gov.frameworkdemoiselle.internal.processor; - -import javax.enterprise.inject.spi.AnnotatedMethod; -import javax.enterprise.inject.spi.BeanManager; - -import br.gov.frameworkdemoiselle.annotation.Priority; -import br.gov.frameworkdemoiselle.annotation.Startup; - -/** - * Processor for a {@code @Startup} annotated method, making it comparable. - * - * @param - */ -public class StartupProcessor extends AnnotatedMethodProcessor { - - public StartupProcessor(final AnnotatedMethod annotatedMethod, final BeanManager beanManager) { - super(annotatedMethod, beanManager); - } - - @SuppressWarnings("deprecation") - protected Integer getPriority(AnnotatedMethod annotatedMethod) { - Integer priority = super.getPriority(annotatedMethod); - - if (!annotatedMethod.isAnnotationPresent(Priority.class)) { - Startup annotation = annotatedMethod.getAnnotation(Startup.class); - priority = annotation.priority(); - } - - return priority; - } -} -- libgit2 0.21.2