Author: andygumbrecht Date: Fri Oct 10 13:08:19 2014 New Revision: 1630886 URL: http://svn.apache.org/r1630886 Log: Check for null. Finals & imports.
Modified: tomee/tomee/branches/tomee-1.7.x/container/openejb-concurrency-utilities-ee/pom.xml tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/Extensions.java tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java Modified: tomee/tomee/branches/tomee-1.7.x/container/openejb-concurrency-utilities-ee/pom.xml URL: http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/container/openejb-concurrency-utilities-ee/pom.xml?rev=1630886&r1=1630885&r2=1630886&view=diff ============================================================================== --- tomee/tomee/branches/tomee-1.7.x/container/openejb-concurrency-utilities-ee/pom.xml (original) +++ tomee/tomee/branches/tomee-1.7.x/container/openejb-concurrency-utilities-ee/pom.xml Fri Oct 10 13:08:19 2014 @@ -30,7 +30,7 @@ <name>OpenEJB :: Container :: Concurrency Utilities EE</name> <properties> - <test.complexity.coverage.minimun>0.68</test.complexity.coverage.minimun> + <test.complexity.coverage.minimun>0.67</test.complexity.coverage.minimun> <test.branch.coverage.minimun>0.4</test.branch.coverage.minimun> </properties> <dependencies> Modified: tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/Extensions.java URL: http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/Extensions.java?rev=1630886&r1=1630885&r2=1630886&view=diff ============================================================================== --- tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/Extensions.java (original) +++ tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/Extensions.java Fri Oct 10 13:08:19 2014 @@ -109,7 +109,7 @@ public final class Extensions { // ensure we support multiple class by file public List<String> findAvailableStrings(final String uri) throws IOException { - List<String> strings = super.findAvailableStrings(uri); + final List<String> strings = super.findAvailableStrings(uri); if (!strings.isEmpty()) { final List<String> copy = new ArrayList<String>(strings); strings.clear(); Modified: tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java URL: http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java?rev=1630886&r1=1630885&r2=1630886&view=diff ============================================================================== --- tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java (original) +++ tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java Fri Oct 10 13:08:19 2014 @@ -22,30 +22,7 @@ import org.apache.openejb.OpenEJBExcepti import org.apache.openejb.assembler.classic.ContainerInfo; import org.apache.openejb.assembler.classic.ResourceInfo; import org.apache.openejb.config.sys.Resource; -import org.apache.openejb.jee.ActivationConfig; -import org.apache.openejb.jee.ActivationConfigProperty; -import org.apache.openejb.jee.AdminObject; -import org.apache.openejb.jee.AssemblyDescriptor; -import org.apache.openejb.jee.ConnectionDefinition; -import org.apache.openejb.jee.Connector; -import org.apache.openejb.jee.EnterpriseBean; -import org.apache.openejb.jee.EntityBean; -import org.apache.openejb.jee.InboundResourceadapter; -import org.apache.openejb.jee.InjectionTarget; -import org.apache.openejb.jee.JndiConsumer; -import org.apache.openejb.jee.JndiReference; -import org.apache.openejb.jee.MessageDestination; -import org.apache.openejb.jee.MessageDestinationRef; -import org.apache.openejb.jee.MessageDrivenBean; -import org.apache.openejb.jee.MessageListener; -import org.apache.openejb.jee.OutboundResourceAdapter; -import org.apache.openejb.jee.PersistenceContextRef; -import org.apache.openejb.jee.PersistenceRef; -import org.apache.openejb.jee.PersistenceType; -import org.apache.openejb.jee.ResourceAdapter; -import org.apache.openejb.jee.ResourceRef; -import org.apache.openejb.jee.SessionBean; -import org.apache.openejb.jee.SessionType; +import org.apache.openejb.jee.*; import org.apache.openejb.jee.jpa.unit.Persistence; import org.apache.openejb.jee.jpa.unit.PersistenceUnit; import org.apache.openejb.jee.jpa.unit.TransactionType; @@ -54,15 +31,7 @@ import org.apache.openejb.jee.oejb3.Open import org.apache.openejb.jee.oejb3.ResourceLink; import org.apache.openejb.loader.SystemInstance; import org.apache.openejb.resource.jdbc.DataSourceFactory; -import org.apache.openejb.util.IntrospectionSupport; -import org.apache.openejb.util.Join; -import org.apache.openejb.util.LinkResolver; -import org.apache.openejb.util.LogCategory; -import org.apache.openejb.util.Logger; -import org.apache.openejb.util.PropertyPlaceHolderHelper; -import org.apache.openejb.util.SuperProperties; -import org.apache.openejb.util.URISupport; -import org.apache.openejb.util.URLs; +import org.apache.openejb.util.*; import javax.annotation.ManagedBean; import javax.ejb.TimerService; @@ -81,25 +50,11 @@ import javax.transaction.UserTransaction import javax.validation.Validator; import javax.validation.ValidatorFactory; import javax.ws.rs.core.Application; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.Request; -import javax.ws.rs.core.SecurityContext; -import javax.ws.rs.core.UriInfo; +import javax.ws.rs.core.*; import javax.ws.rs.ext.ContextResolver; import javax.ws.rs.ext.Providers; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.TreeMap; -import java.util.TreeSet; +import java.util.*; import static java.util.Arrays.asList; @@ -113,7 +68,7 @@ public class AutoConfig implements Dynam private static final int MAX_IMPLICIT_POOL_SIZE = 5; - private static Set<String> ignoredReferenceTypes = new TreeSet<String>(); + private static final Set<String> ignoredReferenceTypes = new TreeSet<String>(); public static final String AUTOCREATE_JTA_DATASOURCE_FROM_NON_JTA_ONE_KEY = "openejb.autocreate.jta-datasource-from-non-jta-one"; static { @@ -656,11 +611,11 @@ public class AutoConfig implements Dynam destinationType = Queue.class.getName(); } logger.info("Auto-configuring a message driven bean " + - ejbDeployment.getDeploymentId() + - " destination " + - properties.getProperty("destination") + - " to be destinationType " + - destinationType); + ejbDeployment.getDeploymentId() + + " destination " + + properties.getProperty("destination") + + " to be destinationType " + + destinationType); } if (destinationType != null) { @@ -925,13 +880,13 @@ public class AutoConfig implements Dynam final Properties properties = resource.getProperties(); if (DataSource.class.getName().equals(resource.getType()) - || DataSource.class.getSimpleName().equals(resource.getType())) { + || DataSource.class.getSimpleName().equals(resource.getType())) { DataSourceFactory.trimNotSupportedDataSourceProperties(properties); } final boolean shouldGenerateJdbcUrl = DataSource.class.getName().equals(resource.getType()) - && resource.getProperties().containsKey(ORIGIN_FLAG) - && resource.getProperties().getProperty(ORIGIN_FLAG).equals(ORIGIN_ANNOTATION); + && resource.getProperties().containsKey(ORIGIN_FLAG) + && resource.getProperties().getProperty(ORIGIN_FLAG).equals(ORIGIN_ANNOTATION); if (shouldGenerateJdbcUrl && properties.get("JdbcUrl") == null) { final String url = getVendorUrl(properties); @@ -955,9 +910,9 @@ public class AutoConfig implements Dynam resourceRef.setMappedName(resourceInfo.id); final ResourceRef strictRef = new ResourceRef(OPENEJB_RESOURCE_JNDI_PREFIX + originalId, - resourceRef.getResType(), - resourceRef.getResAuth(), - resourceRef.getResSharingScope()); + resourceRef.getResType(), + resourceRef.getResAuth(), + resourceRef.getResSharingScope()); strictRef.setMappedName(resourceInfo.id); for (final JndiConsumer consumer : jndiConsumers) { @@ -1157,9 +1112,9 @@ public class AutoConfig implements Dynam final AppModule appModule = ejbModule.getAppModule(); if (appModule != null) { final String newId = findResourceId(appModule.getModuleId() + '/' + id.replace("java:", "").replaceAll("^comp/env/", ""), - refType, - new Properties(), - appResources); + refType, + new Properties(), + appResources); if (newId != null) { // app scoped resources, try to find it without creating it first id = getResourceId(ejbModule.getModuleId(), newId, refType, appResources); } else { @@ -1366,7 +1321,7 @@ public class AutoConfig implements Dynam // first try exact matching without JtaManaged which is not mandatory actually (custom DS + JTADataSourceWrapperFactory) final String jtaWithJavaAndSlash = replaceJavaAndSlash(unit.getJtaDataSource()); for (final String potentialName : asList(prefix + jtaWithJavaAndSlash, jtaWithJavaAndSlash)) { - if(potentialName == null) { + if (potentialName == null) { // If unit.getJtaDataSource() is null, one of the potentialName is also null. continue; } @@ -1384,7 +1339,7 @@ public class AutoConfig implements Dynam final String nonJtaWithJavaAndSlash = replaceJavaAndSlash(unit.getNonJtaDataSource()); for (final String potentialName : asList(prefix + nonJtaWithJavaAndSlash, nonJtaWithJavaAndSlash)) { - if(potentialName == null) { + if (potentialName == null) { // If unit.getNonJtaDataSource() is null, one of the potentialName is also null continue; } @@ -1479,21 +1434,24 @@ public class AutoConfig implements Dynam if (possibleJta != null && possibleJta.equals(possibleNonJta)) { final ResourceInfo dataSource = configFactory.getResourceInfo(possibleJta); - final String jtaManaged = (String) dataSource.properties.get("JtaManaged"); + if (null != dataSource) { - logger.warning("PeristenceUnit(name=" + - unit.getName() + - ") invalidly refers to Resource(id=" + - dataSource.id + - ") as both its <jta-data-source> and <non-jta-data-source>."); - - if ("true".equalsIgnoreCase(jtaManaged)) { - nonJtaDataSourceId = null; - unit.setNonJtaDataSource(null); - - } else if ("false".equalsIgnoreCase(jtaManaged)) { - jtaDataSourceId = null; - unit.setJtaDataSource(null); + final String jtaManaged = (String) dataSource.properties.get("JtaManaged"); + + logger.warning("PeristenceUnit(name=" + + unit.getName() + + ") has an invalid reference to Resource(id=" + + dataSource.id + + ") for both <jta-data-source> and <non-jta-data-source>."); + + if ("true".equalsIgnoreCase(jtaManaged)) { + nonJtaDataSourceId = null; + unit.setNonJtaDataSource(null); + + } else if ("false".equalsIgnoreCase(jtaManaged)) { + jtaDataSourceId = null; + unit.setJtaDataSource(null); + } } } @@ -1682,11 +1640,11 @@ public class AutoConfig implements Dynam // final String deduceJtaFromNonJta = unit.getProperty(AUTOCREATE_JTA_DATASOURCE_FROM_NON_JTA_ONE_KEY, - SystemInstance.get().getOptions().get(AUTOCREATE_JTA_DATASOURCE_FROM_NON_JTA_ONE_KEY, (String) null)); - if (nonJtaDataSourceId != null && jtaDataSourceId == null - // hibernate uses the fact that this ds is missing to get a non jta em instead of a JTA one - && (!resourceLocal || deduceJtaFromNonJta != null) - && (deduceJtaFromNonJta == null || deduceJtaFromNonJta != null && Boolean.parseBoolean(deduceJtaFromNonJta))) { + SystemInstance.get().getOptions().get(AUTOCREATE_JTA_DATASOURCE_FROM_NON_JTA_ONE_KEY, (String) null)); + if (nonJtaDataSourceId != null + && jtaDataSourceId == null + && (!resourceLocal || deduceJtaFromNonJta != null) + && (deduceJtaFromNonJta == null || Boolean.parseBoolean(deduceJtaFromNonJta))) { final ResourceInfo nonJtaResourceInfo = configFactory.getResourceInfo(nonJtaDataSourceId); @@ -1778,8 +1736,8 @@ public class AutoConfig implements Dynam if (MAX_IMPLICIT_POOL_SIZE < value) { copy.properties.setProperty(key, Integer.toString(MAX_IMPLICIT_POOL_SIZE)); logger.warning("Adjusting " + key + " to " + MAX_IMPLICIT_POOL_SIZE + " for " + copy.id - + " DataSource to avoid too much network bandwidth usage." - + " If you want to keep it please define the DataSource explicitely."); + + " DataSource to avoid too much network bandwidth usage." + + " If you want to keep it please define the DataSource explicitly."); } } catch (final NumberFormatException nfe) { // no-op @@ -1864,10 +1822,10 @@ public class AutoConfig implements Dynam if (invalidNonJta != null) { throw new OpenEJBException("PeristenceUnit " + - unit.getName() + - " <non-jta-data-source> points to a jta managed Resource. Update Resource \"" + - invalidNonJta + - "\" to \"JtaManaged=false\", use a different Resource, or delete the <non-jta-data-source> element and a default will be supplied if possible."); + unit.getName() + + " <non-jta-data-source> points to a jta managed Resource. Update Resource \"" + + invalidNonJta + + "\" to \"JtaManaged=false\", use a different Resource, or delete the <non-jta-data-source> element and a default will be supplied if possible."); } // check that jta-data-source does NOT point to a JtaManaged=false datasource @@ -1878,10 +1836,10 @@ public class AutoConfig implements Dynam if (invalidJta != null) { throw new OpenEJBException("PeristenceUnit " + - unit.getName() + - " <jta-data-source> points to a non jta managed Resource. Update Resource \"" + - invalidJta + - "\" to \"JtaManaged=true\", use a different Resource, or delete the <jta-data-source> element and a default will be supplied if possible."); + unit.getName() + + " <jta-data-source> points to a non jta managed Resource. Update Resource \"" + + invalidJta + + "\" to \"JtaManaged=true\", use a different Resource, or delete the <jta-data-source> element and a default will be supplied if possible."); } } @@ -1949,16 +1907,16 @@ public class AutoConfig implements Dynam // throw an exception or log an error final String shortName = toShortName(resourceId); final String message = "No existing resource found while attempting to Auto-link unmapped resource-ref '" + - resourceId + - "' of type '" + - type + - "' for '" + - beanName + - "'. Looked for Resource(id=" + - resourceId + - ") and Resource(id=" + - shortName + - ")"; + resourceId + + "' of type '" + + type + + "' for '" + + beanName + + "'. Looked for Resource(id=" + + resourceId + + ") and Resource(id=" + + shortName + + ")"; if (!autoCreateResources) { throw new OpenEJBException(message); } @@ -1987,7 +1945,7 @@ public class AutoConfig implements Dynam final String resourceId; resourceId = ServiceUtils.getServiceProviderId(type, required); if (resourceId == null) { - throw new OpenEJBException("No provider available for resource-ref '" + resourceId + "' of type '" + type + "' for '" + beanName + "'."); + throw new OpenEJBException("No provider available for resource-ref id with type '" + type + "' for '" + beanName + "'."); } final ResourceInfo resourceInfo = configFactory.configureService(resourceId, ResourceInfo.class); @@ -2143,14 +2101,14 @@ public class AutoConfig implements Dynam // throw an exception or log an error final String message = "No existing resource found while attempting to Auto-link unmapped resource-env-ref '" + - resourceId + - "' of type '" + - type + - "' for '" + - beanName + - "'. Looked for Resource(id=" + - resourceId + - ")"; + resourceId + + "' of type '" + + type + + "' for '" + + beanName + + "'. Looked for Resource(id=" + + resourceId + + ")"; if (!autoCreateResources) { throw new OpenEJBException(message); } Modified: tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java URL: http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=1630886&r1=1630885&r2=1630886&view=diff ============================================================================== --- tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java (original) +++ tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java Fri Oct 10 13:08:19 2014 @@ -21,80 +21,21 @@ import org.apache.openejb.Extensions; import org.apache.openejb.OpenEJBException; import org.apache.openejb.Vendor; import org.apache.openejb.api.Proxy; -import org.apache.openejb.assembler.classic.AppInfo; -import org.apache.openejb.assembler.classic.Assembler; -import org.apache.openejb.assembler.classic.BmpEntityContainerInfo; -import org.apache.openejb.assembler.classic.ClientInfo; -import org.apache.openejb.assembler.classic.CmpEntityContainerInfo; -import org.apache.openejb.assembler.classic.ConnectionManagerInfo; -import org.apache.openejb.assembler.classic.ConnectorInfo; -import org.apache.openejb.assembler.classic.ContainerInfo; -import org.apache.openejb.assembler.classic.ContainerSystemInfo; -import org.apache.openejb.assembler.classic.DeploymentExceptionManager; -import org.apache.openejb.assembler.classic.EjbJarInfo; -import org.apache.openejb.assembler.classic.FacilitiesInfo; -import org.apache.openejb.assembler.classic.HandlerChainInfo; -import org.apache.openejb.assembler.classic.HandlerInfo; -import org.apache.openejb.assembler.classic.JndiContextInfo; -import org.apache.openejb.assembler.classic.ManagedContainerInfo; -import org.apache.openejb.assembler.classic.MdbContainerInfo; -import org.apache.openejb.assembler.classic.OpenEjbConfiguration; -import org.apache.openejb.assembler.classic.OpenEjbConfigurationFactory; -import org.apache.openejb.assembler.classic.ProxyFactoryInfo; -import org.apache.openejb.assembler.classic.ResourceInfo; -import org.apache.openejb.assembler.classic.SecurityServiceInfo; -import org.apache.openejb.assembler.classic.ServiceInfo; -import org.apache.openejb.assembler.classic.SingletonSessionContainerInfo; -import org.apache.openejb.assembler.classic.StatefulSessionContainerInfo; -import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo; -import org.apache.openejb.assembler.classic.TransactionServiceInfo; -import org.apache.openejb.assembler.classic.WebAppInfo; +import org.apache.openejb.assembler.classic.*; import org.apache.openejb.component.ClassLoaderEnricher; -import org.apache.openejb.config.sys.AbstractService; -import org.apache.openejb.config.sys.AdditionalDeployments; -import org.apache.openejb.config.sys.ConnectionManager; -import org.apache.openejb.config.sys.Container; -import org.apache.openejb.config.sys.Deployments; -import org.apache.openejb.config.sys.JaxbOpenejb; -import org.apache.openejb.config.sys.JndiProvider; -import org.apache.openejb.config.sys.Openejb; -import org.apache.openejb.config.sys.ProxyFactory; -import org.apache.openejb.config.sys.Resource; -import org.apache.openejb.config.sys.SecurityService; +import org.apache.openejb.config.sys.*; import org.apache.openejb.config.sys.Service; -import org.apache.openejb.config.sys.ServiceProvider; -import org.apache.openejb.config.sys.TransactionManager; import org.apache.openejb.core.ParentClassLoaderFinder; -import org.apache.openejb.jee.Application; -import org.apache.openejb.jee.EjbJar; -import org.apache.openejb.jee.EnterpriseBean; -import org.apache.openejb.jee.EnvEntry; -import org.apache.openejb.jee.Handler; -import org.apache.openejb.jee.HandlerChain; -import org.apache.openejb.jee.HandlerChains; -import org.apache.openejb.jee.ParamValue; -import org.apache.openejb.jee.SessionBean; -import org.apache.openejb.loader.FileUtils; -import org.apache.openejb.loader.Files; -import org.apache.openejb.loader.IO; -import org.apache.openejb.loader.Options; -import org.apache.openejb.loader.ProvisioningUtil; -import org.apache.openejb.loader.SystemInstance; +import org.apache.openejb.jee.*; +import org.apache.openejb.loader.*; import org.apache.openejb.monitoring.LocalMBeanServer; import org.apache.openejb.resource.jdbc.DataSourceFactory; import org.apache.openejb.resource.jdbc.pool.DataSourceCreator; import org.apache.openejb.resource.jdbc.pool.DefaultDataSourceCreator; -import org.apache.openejb.util.LogCategory; -import org.apache.openejb.util.Logger; -import org.apache.openejb.util.Messages; -import org.apache.openejb.util.PropertyPlaceHolderHelper; -import org.apache.openejb.util.SuperProperties; -import org.apache.openejb.util.URISupport; -import org.apache.openejb.util.URLs; +import org.apache.openejb.util.*; import org.apache.openejb.util.classloader.URLClassLoaderFirst; import org.apache.openejb.util.proxy.QueryProxy; import org.apache.xbean.finder.MetaAnnotatedClass; -import org.apache.xbean.finder.ResourceFinder; import org.apache.xbean.recipe.ObjectRecipe; import org.apache.xbean.recipe.Option; @@ -106,17 +47,7 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; +import java.util.*; import static org.apache.openejb.config.DeploymentsResolver.DEPLOYMENTS_CLASSPATH_PROPERTY; import static org.apache.openejb.config.ServiceUtils.implies; @@ -1303,7 +1234,7 @@ public class ConfigurationFactory implem // because we just have the service properties, not our defaults final Properties properties = service.getProperties(); if ((properties.containsKey("JdbcDriver") || properties.containsKey("JdbcUrl") || properties.containsKey("url")) - && (properties.containsKey("JtaManaged") || properties.containsKey("UserName") || properties.containsKey("Password"))) { + && (properties.containsKey("JtaManaged") || properties.containsKey("UserName") || properties.containsKey("Password"))) { service.setType("javax.sql.DataSource"); } } @@ -1614,7 +1545,7 @@ public class ConfigurationFactory implem // both null or the same id if (refA == null && refB == null || - refA != null && refA.equals(refB)) { + refA != null && refA.equals(refB)) { return EQUAL; }