You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2012/12/18 16:34:46 UTC
svn commit: r1423475 - in /openejb/trunk/openejb/container/openejb-core/src:
main/java/org/apache/openejb/config/
main/java/org/apache/openejb/core/managed/ test/java/org/apache/openejb/
test/java/org/apache/openejb/core/stateless/
Author: andygumbrecht
Date: Tue Dec 18 15:34:45 2012
New Revision: 1423475
URL: http://svn.apache.org/viewvc?rev=1423475&view=rev
Log:
Give StatelessPoolStatsTest more time before checking attribute.
Check for absolute URI and log module id if location is not available in ConfigurationFactory.
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimplePassivater.java
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessPoolStatsTest.java
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/iTest.java
Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=1423475&r1=1423474&r2=1423475&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java Tue Dec 18 15:34:45 2012
@@ -86,6 +86,7 @@ import static org.apache.openejb.config.
import static org.apache.openejb.config.ServiceUtils.implies;
public class ConfigurationFactory implements OpenEjbConfigurationFactory {
+
public static final String OPENEJB_JDBC_DATASOURCE_CREATOR = "openejb.jdbc.datasource-creator";
public static final String ADDITIONAL_DEPLOYMENTS = "conf/deployments.xml";
@@ -244,7 +245,7 @@ public class ConfigurationFactory implem
chain.add(new ActivationConfigPropertyOverride());
chain.add(new OutputGeneratedDescriptors());
-// chain.add(new MergeWebappJndiContext());
+ // chain.add(new MergeWebappJndiContext());
this.deployer = chain;
}
@@ -269,7 +270,8 @@ public class ConfigurationFactory implem
public static List<HandlerChainInfo> toHandlerChainInfo(final HandlerChains chains) {
final List<HandlerChainInfo> handlerChains = new ArrayList<HandlerChainInfo>();
- if (chains == null) return handlerChains;
+ if (chains == null)
+ return handlerChains;
for (final HandlerChain handlerChain : chains.getHandlerChain()) {
final HandlerChainInfo handlerChainInfo = new HandlerChainInfo();
@@ -293,6 +295,7 @@ public class ConfigurationFactory implem
}
public static class ProxyBeanClassUpdate implements DynamicDeployer {
+
@Override
public AppModule deploy(final AppModule appModule) throws OpenEJBException {
for (final EjbModule module : appModule.getEjbModules()) {
@@ -336,6 +339,7 @@ public class ConfigurationFactory implem
}
public static class Chain implements DynamicDeployer {
+
private final List<DynamicDeployer> chain = new ArrayList<DynamicDeployer>();
public boolean add(final DynamicDeployer o) {
@@ -434,9 +438,8 @@ public class ConfigurationFactory implem
sys.facilities.resources.addAll(resources);
-
-// ConnectionManagerInfo service = configureService(openejb.getConnectionManager(), ConnectionManagerInfo.class);
-// sys.facilities.connectionManagers.add(service);
+ // ConnectionManagerInfo service = configureService(openejb.getConnectionManager(), ConnectionManagerInfo.class);
+ // sys.facilities.connectionManagers.add(service);
if (openejb.getProxyFactory() != null) {
sys.facilities.intraVmServer = configureService(openejb.getProxyFactory(), ProxyFactoryInfo.class);
@@ -447,7 +450,6 @@ public class ConfigurationFactory implem
sys.containerSystem.containers.add(info);
}
-
final List<File> declaredApps = getDeclaredApps();
for (final File jarFile : declaredApps) {
@@ -486,11 +488,12 @@ public class ConfigurationFactory implem
final AppInfo appInfo = configureApplication(classLoader, appId, jarFiles);
sys.containerSystem.applications.add(appInfo);
- } else for (final File jarFile : jarFiles) {
+ } else
+ for (final File jarFile : jarFiles) {
- final AppInfo appInfo = configureApplication(jarFile);
- sys.containerSystem.applications.add(appInfo);
- }
+ final AppInfo appInfo = configureApplication(jarFile);
+ sys.containerSystem.applications.add(appInfo);
+ }
if (jarFiles.size() == 0) {
logger.warning("config.noModulesFoundToDeploy");
@@ -554,7 +557,8 @@ public class ConfigurationFactory implem
for (final Deployments deployment : deployments) {
try {
DeploymentsResolver.loadFrom(deployment, base, declaredAppsUrls);
- if (deployment.isAutoDeploy()) autoDeploy.add(deployment);
+ if (deployment.isAutoDeploy())
+ autoDeploy.add(deployment);
} catch (SecurityException se) {
logger.warning("Security check failed on deployment: " + deployment.getFile(), se);
}
@@ -577,7 +581,8 @@ public class ConfigurationFactory implem
for (final URL path : classpathAppsUrls) {
final File file = URLs.toFile(path);
- if (declaredApps != null && declaredApps.contains(file)) continue;
+ if (declaredApps != null && declaredApps.contains(file))
+ continue;
jarFiles.add(file);
}
@@ -601,8 +606,10 @@ public class ConfigurationFactory implem
for (final Map.Entry<Object, Object> entry : sysProps.entrySet()) {
final Object o = entry.getValue();
- if (!(o instanceof String)) continue;
- if (!((String) o).startsWith("new://")) continue;
+ if (!(o instanceof String))
+ continue;
+ if (!((String) o).startsWith("new://"))
+ continue;
final String name = (String) entry.getKey();
final String value = (String) entry.getValue();
@@ -620,7 +627,7 @@ public class ConfigurationFactory implem
}
protected Object toConfigDeclaration(final String name, String value) throws URISyntaxException, OpenEJBException {
-// value = value.replaceFirst("(.)#", "$1%23");
+ // value = value.replaceFirst("(.)#", "$1%23");
value = value.replaceFirst("(provider=[^#=&]+)#", "$1%23");
final URI uri = new URI(value);
@@ -823,9 +830,12 @@ public class ConfigurationFactory implem
}
for (final EjbModule ejb : appModule.getEjbModules()) {
try {
- final URL url = ejb.getModuleUri().toURL();
- if (libs != null && !libs.contains(url)) {
- EventHelper.installExtensions(new ResourceFinder("META-INF", url));
+ final URI uri = ejb.getModuleUri();
+ if (uri.isAbsolute()) {
+ final URL url = uri.toURL();
+ if (libs != null && !libs.contains(url)) {
+ EventHelper.installExtensions(new ResourceFinder("META-INF", url));
+ }
}
} catch (IllegalArgumentException iae) {
logger.debug("can't look for server event listener for module " + ejb.getModuleUri(), iae);
@@ -842,7 +852,8 @@ public class ConfigurationFactory implem
}
}
- logger.info("config.configApp", appModule.getJarLocation());
+ final String location = appModule.getJarLocation();
+ logger.info("config.configApp", null != location ? location : appModule.getModuleId());
deployer.deploy(appModule);
final AppInfoBuilder appInfoBuilder = new AppInfoBuilder(this);
@@ -850,6 +861,7 @@ public class ConfigurationFactory implem
}
private static class DefaultService {
+
private final Class<? extends org.apache.openejb.config.Service> type;
private final String id;
@@ -899,7 +911,6 @@ public class ConfigurationFactory implem
types.put(ResourceInfo.class, Resource.class);
}
-
public <T extends ServiceInfo> T configureService(final Class<? extends T> type) throws OpenEJBException {
return configureService((org.apache.openejb.config.Service) null, type);
}
@@ -907,7 +918,8 @@ public class ConfigurationFactory implem
private <T extends ServiceInfo> org.apache.openejb.config.Service getDefaultService(final Class<? extends T> type) throws OpenEJBException {
final DefaultService defaultService = defaultProviders.get(type);
- if (defaultService == null) return null;
+ if (defaultService == null)
+ return null;
final org.apache.openejb.config.Service service;
try {
@@ -920,7 +932,6 @@ public class ConfigurationFactory implem
return service;
}
-
/**
* This is the major piece of code that configures services.
* It merges the data from the <ServiceProvider> declaration
@@ -937,7 +948,8 @@ public class ConfigurationFactory implem
*/
public <T extends ServiceInfo> T configureService(org.apache.openejb.config.Service service, final Class<? extends T> infoType) throws OpenEJBException {
try {
- if (infoType == null) throw new NullPointerException("type");
+ if (infoType == null)
+ throw new NullPointerException("type");
if (service == null) {
service = getDefaultService(infoType);
@@ -946,7 +958,6 @@ public class ConfigurationFactory implem
}
}
-
final String providerType = getProviderType(service);
final ServiceProvider provider = resolveServiceProvider(service, infoType);
@@ -957,7 +968,8 @@ public class ConfigurationFactory implem
final List<String> types = new ArrayList<String>();
for (final ServiceProvider p : providers) {
for (final String type : p.getTypes()) {
- if (types.contains(type)) continue;
+ if (types.contains(type))
+ continue;
types.add(type);
sb.append(System.getProperty("line.separator"));
sb.append(" <").append(p.getService());
@@ -969,7 +981,8 @@ public class ConfigurationFactory implem
throw new NoSuchProviderException(noProviderMessage);
}
- if (service.getId() == null) service.setId(provider.getId());
+ if (service.getId() == null)
+ service.setId(provider.getId());
final Properties overrides = trim(getSystemProperties(service.getId(), provider.getService()));
@@ -1044,7 +1057,6 @@ public class ConfigurationFactory implem
specialProcessing(info);
-
return info;
} catch (NoSuchProviderException e) {
final String message = logger.fatal("configureService.failed", e, service.getId());
@@ -1086,7 +1098,6 @@ public class ConfigurationFactory implem
TopicOrQueueDefaults.process(info);
}
-
@SuppressWarnings({"unchecked"})
private ServiceProvider resolveServiceProvider(final org.apache.openejb.config.Service service, final Class infoType) throws OpenEJBException {
@@ -1113,7 +1124,7 @@ public class ConfigurationFactory implem
// try to guess quickly for know type
// DataSource
if ((service.getProperties().containsKey("JdbcDriver") || service.getProperties().containsKey("url"))
- && service.getProperties().containsKey("JtaManaged")) {
+ && service.getProperties().containsKey("JtaManaged")) {
service.setType("javax.sql.DataSource");
}
}
@@ -1163,10 +1174,12 @@ public class ConfigurationFactory implem
*
*/
public <T extends ServiceInfo> T configureService(final Class<? extends T> type, final String serviceId, final Properties declaredProperties, final String providerId, final String serviceType) throws OpenEJBException {
- if (type == null) throw new NullPointerException("type is null");
+ if (type == null)
+ throw new NullPointerException("type is null");
final Class<? extends org.apache.openejb.config.Service> serviceClass = types.get(type);
- if (serviceClass == null) throw new OpenEJBException("Unsupported service info type: " + type.getName());
+ if (serviceClass == null)
+ throw new OpenEJBException("Unsupported service info type: " + type.getName());
final org.apache.openejb.config.Service service;
try {
service = serviceClass.newInstance();
@@ -1188,7 +1201,6 @@ public class ConfigurationFactory implem
final Properties sysProps = new Properties(System.getProperties());
sysProps.putAll(SystemInstance.get().getProperties());
-
return getOverrides(sysProps, serviceId, serviceType);
}
@@ -1244,7 +1256,6 @@ public class ConfigurationFactory implem
return Arrays.asList(constructor.split("[ ,]+"));
}
-
protected List<String> getResourceIds() {
return getResourceIds(null);
}
@@ -1256,7 +1267,8 @@ public class ConfigurationFactory implem
protected List<String> getResourceIds(final String type, Properties required) {
final List<String> resourceIds = new ArrayList<String>();
- if (required == null) required = new Properties();
+ if (required == null)
+ required = new Properties();
final OpenEjbConfiguration runningConfig = getRunningConfig();
if (runningConfig != null) {
@@ -1301,7 +1313,7 @@ public class ConfigurationFactory implem
if (id.equals(resourceInfo.id)) {
return resourceInfo;
}
- for (String alias : resourceInfo.aliases) {
+ for (final String alias : resourceInfo.aliases) {
if (alias.equals(id)) {
return resourceInfo;
}
@@ -1314,7 +1326,7 @@ public class ConfigurationFactory implem
if (id.equals(resourceInfo.id)) {
return resourceInfo;
}
- for (String alias : resourceInfo.aliases) {
+ for (final String alias : resourceInfo.aliases) {
if (alias.equals(id)) {
return resourceInfo;
}
@@ -1373,17 +1385,19 @@ public class ConfigurationFactory implem
return containers;
}
-
private OpenEjbConfiguration getRunningConfig() {
return SystemInstance.get().getComponent(OpenEjbConfiguration.class);
}
-
private static class TopicOrQueueDefaults {
+
public static void process(final ServiceInfo provider) {
- if (!provider.service.equals("Resource")) return;
- if (!provider.types.contains("Topic") && !provider.types.contains("Queue")) return;
- if (!provider.className.matches("org.apache.activemq.command.ActiveMQ(Topic|Queue)")) return;
+ if (!provider.service.equals("Resource"))
+ return;
+ if (!provider.types.contains("Topic") && !provider.types.contains("Queue"))
+ return;
+ if (!provider.className.matches("org.apache.activemq.command.ActiveMQ(Topic|Queue)"))
+ return;
final String dest = provider.properties.getProperty("destination");
if (dest == null || dest.length() == 0) {
@@ -1393,6 +1407,7 @@ public class ConfigurationFactory implem
}
public static class ResourceInfoComparator implements Comparator<ResourceInfo> {
+
private final List<String> ids;
private static final int EQUAL = 0;
private static final int GREATER = 1;
@@ -1412,7 +1427,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;
}
@@ -1441,15 +1456,24 @@ public class ConfigurationFactory implem
public int hasReference(final ResourceInfo info) {
for (final Object value : info.properties.values()) {
- if (ids.contains(value)) return GREATER;
+ if (String.class.isInstance(value)) {
+ //noinspection SuspiciousMethodCalls
+ if (ids.contains(value)) {
+ return GREATER;
+ }
+ }
}
return EQUAL;
}
public String getReference(final ResourceInfo info) {
for (Object value : info.properties.values()) {
- value = ((String) value).trim();
- if (ids.contains(value)) return (String) value;
+ if (String.class.isInstance(value)) {
+ value = ((String) value).trim();
+ if (ids.contains(value)) {
+ return (String) value;
+ }
+ }
}
return null;
}
Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimplePassivater.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimplePassivater.java?rev=1423475&r1=1423474&r2=1423475&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimplePassivater.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimplePassivater.java Tue Dec 18 15:34:45 2012
@@ -55,7 +55,6 @@ public class SimplePassivater implements
if (!sessionDirectory.exists() && !sessionDirectory.mkdirs()) {
throw new java.io.IOException("Failed to create directory: " + sessionDirectory.getAbsolutePath());
-
}
logger.info("Using directory " + sessionDirectory + " for stateful session passivation");
Modified: openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessPoolStatsTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessPoolStatsTest.java?rev=1423475&r1=1423474&r2=1423475&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessPoolStatsTest.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessPoolStatsTest.java Tue Dec 18 15:34:45 2012
@@ -269,7 +269,7 @@ public class StatelessPoolStatsTest exte
assertAttribute("Flushes", 1L);
CounterBean.constructed.await(10, TimeUnit.SECONDS);
- Thread.sleep(1);
+ Thread.sleep(10);
assertAttribute("Replaced", 3L);
}
@@ -309,7 +309,7 @@ public class StatelessPoolStatsTest exte
assertAttribute("Flushes", 1L);
CounterBean.constructed.await(10, TimeUnit.SECONDS);
- Thread.sleep(1);
+ Thread.sleep(10);
assertAttribute("Replaced", 8L);
}
@@ -390,7 +390,7 @@ public class StatelessPoolStatsTest exte
assertAttribute("Aged", 5L);
CounterBean.constructed.await(10, TimeUnit.SECONDS);
- Thread.sleep(1);
+ Thread.sleep(10);
assertAttribute("Replaced", 3L);
}
@@ -426,7 +426,7 @@ public class StatelessPoolStatsTest exte
assertAttribute("Aged", 5L);
CounterBean.constructed.await(10, TimeUnit.SECONDS);
- Thread.sleep(1);
+ Thread.sleep(10);
assertAttribute("Replaced", 5L);
}
@@ -519,7 +519,7 @@ public class StatelessPoolStatsTest exte
assertAttribute("IdleTimeouts", 0L);
CounterBean.discarded.await(10, TimeUnit.SECONDS);
- Thread.sleep(1);
+ Thread.sleep(10);
assertAttribute("InstancesPooled", 3);
assertAttribute("IdleTimeouts", 2L);
Modified: openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/iTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/iTest.java?rev=1423475&r1=1423474&r2=1423475&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/iTest.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/iTest.java Tue Dec 18 15:34:45 2012
@@ -20,12 +20,12 @@ package org.apache.openejb;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.openejb.test.TestManager;
-import org.apache.openejb.test.singleton.SingletonLocalTestSuite;
import org.apache.openejb.test.entity.bmp.BmpLocalTestSuite;
import org.apache.openejb.test.entity.cmp.CmpLocalTestSuite;
import org.apache.openejb.test.entity.cmp2.Cmp2TestSuite;
import org.apache.openejb.test.entity.cmr.CmrTestSuite;
import org.apache.openejb.test.mdb.MdbTestSuite;
+import org.apache.openejb.test.singleton.SingletonLocalTestSuite;
import org.apache.openejb.test.stateful.StatefulLocalTestSuite;
import org.apache.openejb.test.stateless.StatelessLocalTestSuite;
@@ -36,6 +36,7 @@ public class iTest extends org.apache.op
/**
* To run this from your ide, set -Dopenejb.home=target/test-classes/
+ *
* @throws Exception
*/
@Override
@@ -47,7 +48,7 @@ public class iTest extends org.apache.op
// do nothing - exception ignored
}
System.setProperty("openejb.test.server", org.apache.openejb.test.IvmTestServer.class.getName());
-// System.setProperty("openejb.test.database", org.apache.openejb.test.DerbyTestDatabase.class.getName());
+ // System.setProperty("openejb.test.database", org.apache.openejb.test.DerbyTestDatabase.class.getName());
System.setProperty("openejb.test.database", org.apache.openejb.test.HsqldbTestDatabase.class.getName());
System.setProperty("openejb.test.jms", org.apache.openejb.test.ActiveMqLocalTestJms.class.getName());
@@ -77,7 +78,7 @@ public class iTest extends org.apache.op
}
public static Test suite() {
- TestSuite suite = new iTest();
+ final TestSuite suite = new iTest();
suite.addTest(SingletonLocalTestSuite.suite());
suite.addTest(StatelessLocalTestSuite.suite());
suite.addTest(StatefulLocalTestSuite.suite());