Skip to content
Permalink
Browse files

Improved: Add missing ‘static’ modifier for private methods

(OFBIZ-11098)

In order to make it clear when a method is not depending on the
internal state of an object, it is a good practice to declare it as
static.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1860937 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Jun 10, 2019
1 parent 08f0b84 commit ffe2e7ffdfa36a880b81e429709b376133e5a75f
Showing with 162 additions and 154 deletions.
  1. +1 −1 ...ications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/GatewayRequest.java
  2. +2 −2 ...tions/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeApi.java
  3. +2 −2 applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java
  4. +3 −2 applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java
  5. +1 −1 applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java
  6. +3 −3 framework/base/src/main/java/org/apache/ofbiz/base/container/ComponentContainer.java
  7. +5 −5 framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerLoader.java
  8. +1 −1 framework/base/src/main/java/org/apache/ofbiz/base/util/cache/UtilCache.java
  9. +1 −1 framework/base/src/main/java/org/apache/ofbiz/base/util/string/NodeELResolver.java
  10. +1 −1 framework/base/src/main/java/org/apache/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java
  11. +22 −21 framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java
  12. +1 −1 framework/common/src/main/java/org/apache/ofbiz/common/test/PerformFindTests.java
  13. +3 −3 framework/datafile/src/main/java/org/apache/ofbiz/datafile/ModelDataFileReader.java
  14. +3 −3 framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldValue.java
  15. +1 −1 framework/entity/src/main/java/org/apache/ofbiz/entity/datasource/GenericDAO.java
  16. +3 −2 framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java
  17. +1 −1 framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelEntity.java
  18. +1 −1 framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityTestSuite.java
  19. +1 −1 framework/minilang/src/main/java/org/apache/ofbiz/minilang/SimpleMethod.java
  20. +2 −2 framework/minilang/src/main/java/org/apache/ofbiz/minilang/test/MiniLangTests.java
  21. +2 −2 framework/service/src/main/java/org/apache/ofbiz/service/ModelNotification.java
  22. +4 −4 framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java
  23. +22 −22 framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java
  24. +3 −3 framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java
  25. +1 −1 framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceInfo.java
  26. +5 −5 framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceRule.java
  27. +2 −1 framework/service/src/main/java/org/apache/ofbiz/service/engine/XMLRPCClientEngine.java
  28. +1 −1 framework/service/src/main/java/org/apache/ofbiz/service/job/JobPoller.java
  29. +1 −1 framework/start/src/main/java/org/apache/ofbiz/base/start/AdminServer.java
  30. +1 −1 framework/start/src/main/java/org/apache/ofbiz/base/start/Classpath.java
  31. +9 −9 framework/start/src/main/java/org/apache/ofbiz/base/start/Config.java
  32. +4 −4 framework/testtools/src/main/java/org/apache/ofbiz/testtools/TestRunContainer.java
  33. +1 −1 framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlEventListener.java
  34. +3 −3 framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
  35. +11 −7 framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/SOAPEventHandler.java
  36. +1 −1 framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java
  37. +1 −1 framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelMenu.java
  38. +1 −1 framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelMenuItem.java
  39. +1 −1 framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTheme.java
  40. +5 −5 framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java
  41. +22 −22 framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/fo/FoFormRenderer.java
  42. +3 −3 framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroMenuRenderer.java
@@ -407,7 +407,7 @@ public String toXml() {
* The value of the node being created.
* @return An XML node as a String in <nodName>nodeValue</nodeName> format
*/
private String createNode(String nodeName, String nodeValue) {
private static String createNode(String nodeName, String nodeValue) {
return "<" + nodeName + ">" + nodeValue + "</" + nodeName + ">";
}
}
@@ -207,7 +207,7 @@ public PcChargeApi send() throws IOException, GeneralException {

}

private boolean checkIn(String name) {
private static boolean checkIn(String name) {
for (String element : validOut) {
if (name.equals(element)) {
return false;
@@ -216,7 +216,7 @@ private boolean checkIn(String name) {
return true;
}

private boolean checkOut(String name) {
private static boolean checkOut(String name) {
for (String element : validIn) {
if (name.equals(element)) {
return false;
@@ -204,7 +204,7 @@ public RitaApi send() throws IOException, GeneralException {
throw new IllegalStateException("Cannot send output object");
}

private boolean checkIn(String name) {
private static boolean checkIn(String name) {
for (String element : validOut) {
if (name.equals(element)) {
return false;
@@ -213,7 +213,7 @@ private boolean checkIn(String name) {
return true;
}

private boolean checkOut(String name) {
private static boolean checkOut(String name) {
for (String element : validIn) {
if (name.equals(element)) {
return false;
@@ -796,7 +796,7 @@ public void calcAndAddTax(GenericValue shipAddress, boolean skipEmptyAddresses)
csi.clearAllTaxInfo();
continue;
}
List<List<? extends Object>> taxReturn = this.getTaxAdjustments(dispatcher, "calcTax", serviceContext);
List<List<? extends Object>> taxReturn = getTaxAdjustments(dispatcher, "calcTax", serviceContext);

if (Debug.verboseOn()) {
Debug.logVerbose("ReturnList: " + taxReturn, module);
@@ -908,7 +908,8 @@ public void calcAndAddTax(GenericValue shipAddress, boolean skipEmptyAddresses)
}

// Calc the tax adjustments.
private List<List<? extends Object>> getTaxAdjustments(LocalDispatcher dispatcher, String taxService, Map<String, Object> serviceContext) throws GeneralException {
private static List<List<? extends Object>> getTaxAdjustments(LocalDispatcher dispatcher, String taxService,
Map<String, Object> serviceContext) throws GeneralException {
Map<String, Object> serviceResult = null;

try {
@@ -213,7 +213,7 @@ public void addOrIncreaseLine(String orderId, String orderItemSeqId, String ship
this.runEvents(PackingEvent.EVENT_CODE_ADD);
}

private BigDecimal numAvailableItems(GenericValue res) {
private static BigDecimal numAvailableItems(GenericValue res) {
// In simple situations, the reserved quantity will match the quantity from the order item.
// If there is a back order, quantity from order may exceed quantity currently reserved and on hand.
// resQty should never exceed the quantity from the order item, because that quantity was the quantity reserved in the first place.
@@ -91,7 +91,7 @@ public boolean start() {
*
* @param componentsClassPath a list of classpaths for all components
*/
private void loadClassPathForAllComponents(List<Classpath> componentsClassPath) {
private static void loadClassPathForAllComponents(List<Classpath> componentsClassPath) {
List<URL> allComponentUrls = new ArrayList<>();
for(Classpath classPath : componentsClassPath) {
try {
@@ -256,7 +256,7 @@ private void loadComponentWithDependency() throws IOException, ComponentExceptio
* @param location directory location of the component
* @return The component configuration
*/
private ComponentConfig retrieveComponentConfig(String name, String location) {
private static ComponentConfig retrieveComponentConfig(String name, String location) {
ComponentConfig config = null;
try {
config = ComponentConfig.getComponentConfig(name, location);
@@ -331,7 +331,7 @@ private void loadComponent(ComponentConfig config) throws IOException, Component
* @return the constructed classpath
* @throws IOException
*/
private Classpath buildClasspathFromComponentConfig(ComponentConfig config) throws IOException {
private static Classpath buildClasspathFromComponentConfig(ComponentConfig config) throws IOException {
Classpath classPath = new Classpath();
String configRoot = config.getRootLocation().replace('\\', '/');
configRoot = configRoot.endsWith("/") ? configRoot : configRoot + "/";
@@ -81,15 +81,16 @@ public synchronized void load(Config config, List<StartupCommand> ofbizCommands)
startLoadedContainers();
}

private Collection<ContainerConfig.Configuration> retrieveOfbizContainers(String configFile) throws StartupException {
private static Collection<ContainerConfig.Configuration> retrieveOfbizContainers(String configFile)
throws StartupException {
try {
return ContainerConfig.getConfigurations(configFile);
} catch (ContainerException e) {
throw new StartupException(e);
}
}

private List<ContainerConfig.Configuration> filterContainersHavingMatchingLoaders(List<String> loaders,
private static List<ContainerConfig.Configuration> filterContainersHavingMatchingLoaders(List<String> loaders,
Collection<ContainerConfig.Configuration> containerConfigs) {
return containerConfigs.stream()
.filter(containerCfg ->
@@ -99,7 +100,7 @@ public synchronized void load(Config config, List<StartupCommand> ofbizCommands)
.collect(Collectors.toList());
}

private List<Container> loadContainersFromConfigurations(List<ContainerConfig.Configuration> containerConfigs,
private static List<Container> loadContainersFromConfigurations(List<ContainerConfig.Configuration> containerConfigs,
Config config, List<StartupCommand> ofbizCommands) throws StartupException {

List<Container> loadContainers = new ArrayList<>();
@@ -112,8 +113,7 @@ public synchronized void load(Config config, List<StartupCommand> ofbizCommands)
return loadContainers;
}

private Container loadContainer(String configFile,
ContainerConfig.Configuration containerCfg,
private static Container loadContainer(String configFile, ContainerConfig.Configuration containerCfg,
List<StartupCommand> ofbizCommands) throws StartupException {
// load the container class
ClassLoader loader = Thread.currentThread().getContextClassLoader();
@@ -196,7 +196,7 @@ public void setPropertiesParams(String settingsResourceName, String[] propNames)
}
}

private Object fromKey(Object key) {
private static Object fromKey(Object key) {
return key == null ? ObjectType.NULL : key;
}

@@ -137,7 +137,7 @@ public void setValue(ELContext context, Object base, Object property, Object val
}
}

private final boolean isResolvable(Object base) {
private final static boolean isResolvable(Object base) {
return base != null && (base instanceof Node || base instanceof NodeImpl);
}

@@ -267,7 +267,7 @@ public void testQuietly() {
everythingTest();
}

private void everythingTest() {
private static void everythingTest() {
Map<String, Object> testMap = new HashMap<>();
testMap.put("date", new java.util.Date(1234567890));
testMap.put("usd", "USD");
@@ -164,7 +164,7 @@ public String getName() {
return name;
}

private Property retrieveTomcatEngineConfig(ContainerConfig.Configuration cc) throws ContainerException {
private static Property retrieveTomcatEngineConfig(ContainerConfig.Configuration cc) throws ContainerException {
List<ContainerConfig.Configuration.Property> engineProps = cc.getPropertiesWithValue("engine");
if (UtilValidate.isEmpty(engineProps)) {
throw new ContainerException("Cannot load CatalinaContainer; no engines defined.");
@@ -175,7 +175,7 @@ private Property retrieveTomcatEngineConfig(ContainerConfig.Configuration cc) th
return engineProps.get(0);
}

private Tomcat prepareTomcatServer(ContainerConfig.Configuration cc,
private static Tomcat prepareTomcatServer(ContainerConfig.Configuration cc,
ContainerConfig.Configuration.Property engineConfig) throws ContainerException {

System.setProperty(Globals.CATALINA_HOME_PROP, System.getProperty("ofbiz.home") + "/" +
@@ -205,7 +205,7 @@ private Tomcat prepareTomcatServer(ContainerConfig.Configuration cc,
return tomcat;
}

private Engine prepareTomcatEngine(Tomcat tomcat, Property engineConfig) {
private static Engine prepareTomcatEngine(Tomcat tomcat, Property engineConfig) {
Engine engine = tomcat.getEngine();
engine.setName(engineConfig.name);

@@ -218,7 +218,7 @@ private Engine prepareTomcatEngine(Tomcat tomcat, Property engineConfig) {
return engine;
}

private Host prepareHost(Tomcat tomcat, List<String> virtualHosts) {
private static Host prepareHost(Tomcat tomcat, List<String> virtualHosts) {
Host host;

if (UtilValidate.isEmpty(virtualHosts)) {
@@ -240,7 +240,7 @@ private Host prepareHost(Tomcat tomcat, List<String> virtualHosts) {
return host;
}

private Host prepareVirtualHost(Tomcat tomcat, List<String> virtualHosts) {
private static Host prepareVirtualHost(Tomcat tomcat, List<String> virtualHosts) {
// assume that the first virtual-host will be the default; additional virtual-hosts will be aliases
String hostName = virtualHosts.get(0);
Host host;
@@ -262,7 +262,7 @@ private Host prepareVirtualHost(Tomcat tomcat, List<String> virtualHosts) {
return host;
}

private Property prepareTomcatClustering(Host host, Property engineConfig) throws ContainerException {
private static Property prepareTomcatClustering(Host host, Property engineConfig) throws ContainerException {
Property clusterProp = null;

List<Property> clusterProps = engineConfig.getPropertiesWithValue("cluster");
@@ -291,7 +291,7 @@ private Property prepareTomcatClustering(Host host, Property engineConfig) throw
return clusterProp;
}

private NioReceiver prepareChannelReceiver(Property clusterProp) throws ContainerException {
private static NioReceiver prepareChannelReceiver(Property clusterProp) throws ContainerException {
NioReceiver listener = new NioReceiver();

String tla = ContainerConfig.getPropertyValue(clusterProp, "tcp-listen-host", "auto");
@@ -312,7 +312,7 @@ private NioReceiver prepareChannelReceiver(Property clusterProp) throws Containe
return listener;
}

private ReplicationTransmitter prepareChannelSender(Property clusterProp) throws ContainerException {
private static ReplicationTransmitter prepareChannelSender(Property clusterProp) throws ContainerException {
ReplicationTransmitter trans = new ReplicationTransmitter();
try {
MultiPointSender mps = (MultiPointSender)Class.forName(ContainerConfig.getPropertyValue(clusterProp,
@@ -324,7 +324,7 @@ private ReplicationTransmitter prepareChannelSender(Property clusterProp) throws
return trans;
}

private McastService prepareChannelMcastService(Property clusterProp) throws ContainerException {
private static McastService prepareChannelMcastService(Property clusterProp) throws ContainerException {
McastService mcast = new McastService();

String mcb = ContainerConfig.getPropertyValue(clusterProp, "mcast-bind-addr", null);
@@ -349,7 +349,7 @@ private McastService prepareChannelMcastService(Property clusterProp) throws Con
return mcast;
}

private ClusterManager prepareClusterManager(Property clusterProp) throws ContainerException {
private static ClusterManager prepareClusterManager(Property clusterProp) throws ContainerException {
String mgrClassName = ContainerConfig.getPropertyValue(clusterProp, "manager-class", "org.apache.catalina.ha.session.DeltaManager");
try {
return (ClusterManager)Class.forName(mgrClassName).getDeclaredConstructor().newInstance();
@@ -358,14 +358,14 @@ private ClusterManager prepareClusterManager(Property clusterProp) throws Contai
}
}

private ReplicationValve prepareClusterValve(Property clusterProp) {
private static ReplicationValve prepareClusterValve(Property clusterProp) {
ReplicationValve clusterValve = new ReplicationValve();
String defaultValveFilter = ".*\\.gif;.*\\.js;.*\\.jpg;.*\\.htm;.*\\.html;.*\\.txt;.*\\.png;.*\\.css;.*\\.ico;.*\\.htc;";
clusterValve.setFilter(ContainerConfig.getPropertyValue(clusterProp, "rep-valve-filter", defaultValveFilter));
return clusterValve;
}

private List<Valve> prepareTomcatEngineValves(Property engineConfig) throws ContainerException {
private static List<Valve> prepareTomcatEngineValves(Property engineConfig) throws ContainerException {
List<Valve> engineValves = new ArrayList<>();

// configure the CrossSubdomainSessionValve
@@ -410,7 +410,7 @@ private ReplicationValve prepareClusterValve(Property clusterProp) {
return engineValves;
}

private List<Connector> prepareTomcatConnectors(Configuration configuration) throws ContainerException {
private static List<Connector> prepareTomcatConnectors(Configuration configuration) throws ContainerException {
List<Property> connectorProps = configuration.getPropertiesWithValue("connector");
if (UtilValidate.isEmpty(connectorProps)) {
throw new ContainerException("Cannot load CatalinaContainer; no connectors defined!");
@@ -421,7 +421,7 @@ private ReplicationValve prepareClusterValve(Property clusterProp) {
.collect(Collectors.toList());
}

private Connector prepareConnector(Property connectorProp) {
private static Connector prepareConnector(Property connectorProp) {
Connector connector = new Connector(ContainerConfig.getPropertyValue(connectorProp, "protocol", "HTTP/1.1"));
connector.setPort(ContainerConfig.getPropertyValue(connectorProp, "port", 0) + Start.getInstance().getConfig().portOffset);
if ("true".equals(ContainerConfig.getPropertyValue(connectorProp, "upgradeProtocol", "false"))) {
@@ -445,7 +445,7 @@ private Connector prepareConnector(Property connectorProp) {
return connector;
}

private void loadWebapps(Tomcat tomcat, ContainerConfig.Configuration configuration, Property clusterProp) {
private static void loadWebapps(Tomcat tomcat, ContainerConfig.Configuration configuration, Property clusterProp) {
ScheduledExecutorService executor = ExecutionPool.getScheduledExecutor(new ThreadGroup(module),
"catalina-startup", Runtime.getRuntime().availableProcessors(), 0, true);
List<Future<Context>> futures = new ArrayList<>();
@@ -473,7 +473,7 @@ private void loadWebapps(Tomcat tomcat, ContainerConfig.Configuration configurat
executor.shutdown();
}

private List<String> getWebappMounts(ComponentConfig.WebappInfo webappInfo) {
private static List<String> getWebappMounts(ComponentConfig.WebappInfo webappInfo) {
List<String> allAppsMounts = new ArrayList<>();
String engineName = webappInfo.server;
String mount = webappInfo.getContextRoot();
@@ -486,7 +486,7 @@ private void loadWebapps(Tomcat tomcat, ContainerConfig.Configuration configurat
return allAppsMounts;
}

private Callable<Context> createCallableContext(Tomcat tomcat, ComponentConfig.WebappInfo appInfo,
private static Callable<Context> createCallableContext(Tomcat tomcat, ComponentConfig.WebappInfo appInfo,
Property clusterProp, ContainerConfig.Configuration configuration) {

Debug.logInfo("Creating context [" + appInfo.name + "]", module);
@@ -500,7 +500,7 @@ private void loadWebapps(Tomcat tomcat, ContainerConfig.Configuration configurat
};
}

private StandardContext prepareContext(Host host, ContainerConfig.Configuration configuration,
private static StandardContext prepareContext(Host host, ContainerConfig.Configuration configuration,
ComponentConfig.WebappInfo appInfo, Property clusterProp) throws ContainerException {

StandardContext context = new StandardContext();
@@ -560,7 +560,7 @@ private StandardContext prepareContext(Host host, ContainerConfig.Configuration
return context;
}

private String getWebappRootLocation(ComponentConfig.WebappInfo appInfo) {
private static String getWebappRootLocation(ComponentConfig.WebappInfo appInfo) {
String location = appInfo.componentConfig.getRootLocation() + appInfo.location;
location = location.replace('\\', '/');
if (location.endsWith("/")) {
@@ -569,15 +569,16 @@ private String getWebappRootLocation(ComponentConfig.WebappInfo appInfo) {
return location;
}

private String getWebappMountPoint(ComponentConfig.WebappInfo appInfo) {
private static String getWebappMountPoint(ComponentConfig.WebappInfo appInfo) {
String mount = appInfo.mountPoint;
if (mount.endsWith("/*")) {
mount = mount.substring(0, mount.length() - 2);
}
return mount;
}

private boolean isContextDistributable(ContainerConfig.Configuration configuration, String location) throws ContainerException {
private static boolean isContextDistributable(ContainerConfig.Configuration configuration, String location)
throws ContainerException {
String webXmlFilePath = new StringBuilder().append("file:///").append(location).append("/WEB-INF/web.xml").toString();
boolean appIsDistributable = ContainerConfig.getPropertyValue(configuration, "apps-distributable", true);
try {
@@ -42,7 +42,7 @@ public PerformFindTests(String name) {
super(name);
}

private List<GenericValue> getCompleteList(Map<String, Object> context) {
private static List<GenericValue> getCompleteList(Map<String, Object> context) {
List<GenericValue> foundElements = new LinkedList<>();
try (EntityListIterator listIt = (EntityListIterator) context.get("listIt")) {
if (listIt != null) {
@@ -66,7 +66,7 @@ public ModelDataFileReader(URL readerURL) throws DataFileException {
this.modelDataFiles = Collections.unmodifiableMap(createModelDataFiles());
}

private ModelDataFile createModelDataFile(Element dataFileElement) {
private static ModelDataFile createModelDataFile(Element dataFileElement) {
ModelDataFile dataFile = new ModelDataFile();
String tempStr;

@@ -163,7 +163,7 @@ private ModelDataFile createModelDataFile(Element dataFileElement) {
return result;
}

private ModelField createModelField(Element fieldElement) {
private static ModelField createModelField(Element fieldElement) {
ModelField field = new ModelField();
String tempStr;

@@ -203,7 +203,7 @@ private ModelField createModelField(Element fieldElement) {
return field;
}

private ModelRecord createModelRecord(Element recordElement) {
private static ModelRecord createModelRecord(Element recordElement) {
ModelRecord record = new ModelRecord();
String tempStr;

0 comments on commit ffe2e7f

Please sign in to comment.
You can’t perform that action at this time.