Skip to content

Commit

Permalink
Fix Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mgoellnitz committed Sep 23, 2022
1 parent 3943f05 commit 4df8c2c
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 224 deletions.
29 changes: 15 additions & 14 deletions src/main/java/dinistiq/Dinistiq.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@
/**
* The dinistiq main class.
*
* By instanciating this class the bean creation and injection process will be started. Subsequent calls to the
* API methods support retrieval of the singleton beans according to type, annotation, or type and annotation.
* By instanciating this class the bean creation and injection process will be
* started. Subsequent calls to the API methods support retrieval of the
* singleton beans according to type, annotation, or type and annotation.
*/
public class Dinistiq {

Expand Down Expand Up @@ -709,13 +710,13 @@ private void fillMap(Object bean, Properties mapProperties) {

/**
* Call all methods off a given bean with injection annotations.
*
*
* @param bean bean to handle
* @param key key of the bean in the scope
* @param beanProperties
* @param dependencies
* @param beanClassName full name of the class of the given bean
* @throws SecurityException
* @throws SecurityException
*/
private void callMethodsWithAnnotatedInjection(Object bean, String key, Properties beanProperties, Map<String, Set<Object>> dependencies, String beanClassName) {
for (Method m : bean.getClass().getMethods()) {
Expand All @@ -737,15 +738,15 @@ private void callMethodsWithAnnotatedInjection(Object bean, String key, Properti

/**
* Prepare parameters for injection call.
*
*
* @param isBoolean tell if a boolean is to be injected
* @param propertyValue string description of the value
* @param parameterType type of the parameter
* @param isCollection tell if collection is to be injected
* @param dependencies dependencies in scope
* @param key
* @return parameter array of size 1
* @throws NumberFormatException
* @throws NumberFormatException
*/
private Object[] prepareParameter(boolean isBoolean, String propertyValue, Class<?> parameterType, boolean isCollection, Map<String, Set<Object>> dependencies, String key) {
Object[] parameters = new Object[1];
Expand Down Expand Up @@ -788,13 +789,13 @@ private Object[] prepareParameter(boolean isBoolean, String propertyValue, Class

/**
* Inject manually set vales from from properties files into bean.
*
*
* @param bean bean to handle injection for
* @param beanClassName full name of class of the bean
* @param beanProperties properties file contents
* @param key key the bean was given
* @param dependencies already collected dependencies
* @throws SecurityException
* @throws SecurityException
*/
private void injectPropertiesFromFiles(Object bean, String beanClassName, Properties beanProperties, String key, Map<String, Set<Object>> dependencies) {
// TODO: Deal with scopes - do we need a second scope variable besides beans to hold "dependent" scope beans while injecting?
Expand Down Expand Up @@ -891,7 +892,7 @@ private void injectDependencies(String key, Object bean, Map<String, Set<Object>

/**
* Read relevant properties files from class path.
*
*
* @param classResolver class resolver used for properties files discovery
* @return joint properties files contents
* @throws IOException thrown on file handling problems
Expand All @@ -913,16 +914,16 @@ private Properties readBeanListFromPropertiesFiles(ClassResolver classResolver)


/**
* Instanciate beans from the properties files and from annotations taking
* Instanciate beans from the properties files and from annotations taking
* constructor injection dependencies into account.
*
*
* @param classes list of classes for instanciation
* @param names list of names for the instances - must be in same order as above
* @param dependencies already collected dependencies
*/
private void instanciateBeans(List<Class<?>> classes, List<String> names, Map<String, Set<Object>> dependencies) {
int ripCord = 10;
List<Class<?>> classList = classes;
List<Class<?>> classList = classes;
List<String> nameList = names;
while ((ripCord>0)&&(!classList.isEmpty())) {
LOG.debug("instanciateBeans() trying {} beans: {}", nameList.size(), classList);
Expand All @@ -946,7 +947,7 @@ private void instanciateBeans(List<Class<?>> classes, List<String> names, Map<St

/**
* Sort beans according to dependencies.
*
*
* @param dependencies dependencies in the scope
*/
private void sortBeans(Map<String, Set<Object>> dependencies) {
Expand Down Expand Up @@ -1073,7 +1074,7 @@ public Dinistiq(ClassResolver classResolver, Map<String, Object> externalBeans)
LOG.warn("() while injecting dependencies for "+key, ioe);
}
} // for

sortBeans(dependencies);
if (!dependencies.isEmpty()) {
throw new RuntimeException("Circular bean injection and initialization dependencies detected after "+(System.currentTimeMillis()-start)+"ms"+" "+dependencies);
Expand Down
108 changes: 54 additions & 54 deletions src/test/java/dinistiq/test/components/ConstructorInjection.java
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
/**
*
* Copyright 2014-2020 Martin Goellnitz
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package dinistiq.test.components;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import lombok.Getter;


/**
* Test injections of contructor parameters.
*/
@Named
@Singleton
public class ConstructorInjection {

@Getter
private String string;


/**
* Constructor with injection point in parameter list.
*/
@Inject
public ConstructorInjection(@Named("b") String string) {
this.string = string;
}


/**
* Unused constrctor - exception in error cases.
*/
public ConstructorInjection() {
this("wrong default");
}

} // ConstructorInjection
/**
*
* Copyright 2014-2020 Martin Goellnitz
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package dinistiq.test.components;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import lombok.Getter;


/**
* Test injections of contructor parameters.
*/
@Named
@Singleton
public class ConstructorInjection {

@Getter
private String string;


/**
* Constructor with injection point in parameter list.
*/
@Inject
public ConstructorInjection(@Named("b") String string) {
this.string = string;
}


/**
* Unused constrctor - exception in error cases.
*/
public ConstructorInjection() {
this("wrong default");
}

} // ConstructorInjection
70 changes: 35 additions & 35 deletions src/test/java/dinistiq/test/components/InitialBean.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
/**
*
* Copyright 2014-2020 Martin Goellnitz
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package dinistiq.test.components;

import javax.inject.Inject;
import lombok.Getter;


/**
* Test vehicle class used as member of the set of beans passed over before
* bean scan and injection application.
*/
public class InitialBean {

@Inject
@Getter
private TestInterface test;

} // InitialBean
/**
*
* Copyright 2014-2020 Martin Goellnitz
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package dinistiq.test.components;

import javax.inject.Inject;
import lombok.Getter;


/**
* Test vehicle class used as member of the set of beans passed over before
* bean scan and injection application.
*/
public class InitialBean {

@Inject
@Getter
private TestInterface test;

} // InitialBean
Loading

0 comments on commit 4df8c2c

Please sign in to comment.