You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2015/07/21 20:36:26 UTC

[09/16] tomee git commit: Revert "Re-use the connection for the datasource and transaction rather than fetch another one only to throw it away later. Slightly experimental change to prevent the db pool locking up."

Revert "Re-use the connection for the datasource and transaction rather than fetch another one only to throw it away later. Slightly experimental change to prevent the db pool locking up."

This reverts commit bd7dbd0f31964df0c3ea421bc2f4aba2f51f8a2e.


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/b36eb932
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/b36eb932
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/b36eb932

Branch: refs/heads/tomee-1.7.x
Commit: b36eb93253597959691513d1522d225703491e15
Parents: 4ca69b0
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Tue Jul 21 13:37:19 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Tue Jul 21 13:37:19 2015 +0100

----------------------------------------------------------------------
 .../jdbc/managed/local/ManagedConnection.java   |   16 +-
 .../jdbc/managed/local/ManagedDataSource.java   |   28 +-
 .../resource/jdbc/ManagedDataSourceTest.java    |    4 +-
 .../MultiThreadedManagedDataSourceTest.java     |    4 +-
 .../resource/jdbc/UTManagedDataSourceTest.java  |    4 +-
 .../maven/plugin/AbstractSynchronizable.java    |  142 +-
 .../test/resources/schema/ComplexAllElement.xsd |   42 +-
 .../test/resources/schema/ComplexAllType.xsd    |   42 +-
 .../resources/schema/ComplexSequenceElement.xsd |   42 +-
 .../resources/schema/ComplexSequenceType.xsd    |   42 +-
 .../test/resources/schema/JaxRpcSpecExample.xsd |   42 +-
 .../src/test/resources/schema/SimpleElement.xsd |   42 +-
 .../src/test/resources/schema/SimpleType.xsd    |   42 +-
 .../resources/schema/SoapArrayByAttribute.xsd   |   42 +-
 .../resources/schema/SoapArrayByRestriction.xsd |   42 +-
 .../apache/openejb/client/ClientSecurity.java   |  408 ++---
 .../client/DirectConnectionStrategy.java        |   66 +-
 .../openejb/client/MulticastPulseClient.java    | 1556 +++++++++---------
 .../apache/openejb/client/ProtocolMetaData.java |  224 +--
 .../openejb/server/cxf/rs/AutoJAXRSInvoker.java |  140 +-
 .../server/cxf/rs/OpenEJBEJBInvoker.java        |  230 +--
 .../openejb/server/cxf/rs/PojoInvoker.java      |  124 +-
 .../rs/DynamicSubclassEjbDeploymentTest.java    |  260 +--
 .../cxf/rs/EJBAccessExceptionMapperTest.java    |  220 +--
 .../server/cxf/rs/EjbDeploymentTest.java        |  246 +--
 .../cxf/rs/PathParamAtClassLevelTest.java       |  148 +-
 .../server/cxf/WSSPassThroughInterceptor.java   |  132 +-
 .../server/cxf/ejb/EjbMessageContext.java       |  124 +-
 .../server/cxf/CxfJaxWsProviderTest.java        |  274 +--
 .../server/cxf/fault/AuthenticatorService.java  |   60 +-
 .../cxf/fault/AuthenticatorServiceBean.java     |   84 +-
 .../AuthenticatorServiceBeanNoHandler.java      |   82 +-
 .../server/cxf/fault/DummyInterceptor.java      |   96 +-
 .../cxf/fault/WrongPasswordException.java       |   82 +-
 .../fault/WrongPasswordRuntimeException.java    |   84 +-
 .../src/test/resources/META-INF/ejb-jar.xml     |   36 +-
 .../apache/openejb/server/cxf/fault/handler.xml |   52 +-
 .../org/apache/openejb/daemon/NTService.java    |  228 +--
 .../openejb/server/ejbd/RequestHandler.java     |   90 +-
 .../server/discovery/MulticastPulseAgent.java   | 1520 ++++++++---------
 .../multipulse                                  |    6 +-
 .../discovery/MulticastPulseAgentTest.java      | 1026 ++++++------
 .../openejb/server/rest/EJBRestServiceInfo.java |   66 +-
 .../server/rest/InternalApplication.java        |   90 +-
 .../main/resources/META-INF/openejb-server.xml  |   72 +-
 .../META-INF/org.apache.openejb.cli/stop.help   |   28 +-
 src/main/style/checkstyle.xml                   |  330 ++--
 .../apache/openejb/tck/util/ServerLocal.java    |  100 +-
 .../apache-tomee/src/main/resources/service.bat |  452 ++---
 .../main/resources/service.install.as.admin.bat |   64 +-
 .../main/resources/service.remove.as.admin.bat  |   64 +-
 tomee/apache-tomee/src/main/resources/tomee.bat |  170 +-
 .../org/apache/tomee/catalina/Contexts.java     |  296 ++--
 .../catalina/ProvisioningWebappLoader.java      |  238 +--
 .../tomee/catalina/TomcatDeploymentLoader.java  |   86 +-
 55 files changed, 5108 insertions(+), 5122 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java b/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
index 5a8c4c7..25e1727 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
@@ -35,10 +35,13 @@ import java.lang.reflect.Method;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 public class ManagedConnection implements InvocationHandler {
     private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB_RESOURCE_JDBC, ManagedConnection.class);
 
+    private static final Map<Integer, Map<Transaction, Connection>> CONNECTION_BY_TX_BY_DS = new ConcurrentHashMap<Integer, Map<Transaction, Connection>>();
+
     private final TransactionManager transactionManager;
     private final LocalXAResource xaResource;
     protected Connection delegate;
@@ -52,7 +55,7 @@ public class ManagedConnection implements InvocationHandler {
         transactionManager = txMgr;
         closed = false;
         xaResource = new LocalXAResource(delegate);
-        connectionByTx = ManagedConnectionsByTransactionByDatasource.get(ds);
+        connectionByTx = CONNECTION_BY_TX_BY_DS.get(ds.hashCode());
     }
 
     public XAResource getXAResource() throws SQLException {
@@ -192,6 +195,17 @@ public class ManagedConnection implements InvocationHandler {
         }
     }
 
+    public static void pushDataSource(final CommonDataSource ds) {
+        CONNECTION_BY_TX_BY_DS.put(ds.hashCode(), new ConcurrentHashMap<Transaction, Connection>());
+    }
+
+    public static void cleanDataSource(final CommonDataSource ds) {
+        final Map<Transaction, Connection> map = CONNECTION_BY_TX_BY_DS.remove(ds.hashCode());
+        if (map != null) {
+            map.clear();
+        }
+    }
+
     private static class ClosingSynchronization implements Synchronization {
         private final Connection connection;
         private final Map<Transaction, Connection> mapToCleanup;

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java b/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
index f57b9d8..0c074f9 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
@@ -21,10 +21,7 @@ import org.apache.openejb.util.reflection.Reflections;
 
 import javax.sql.CommonDataSource;
 import javax.sql.DataSource;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
-
 import java.io.PrintWriter;
 import java.lang.reflect.Proxy;
 import java.sql.Connection;
@@ -43,7 +40,7 @@ public class ManagedDataSource implements DataSource {
         delegate = ds;
         hashCode = hc;
         transactionManager = txMgr;
-        ManagedConnectionsByTransactionByDatasource.pushDataSource(this);
+        ManagedConnection.pushDataSource(this);
     }
 
     public ManagedDataSource(final DataSource ds, final TransactionManager txMgr) {
@@ -52,26 +49,7 @@ public class ManagedDataSource implements DataSource {
 
     @Override
     public Connection getConnection() throws SQLException {
-        
-        Transaction transaction = null;
-        
-        try {
-            transaction = transactionManager.getTransaction();
-        } catch (final SystemException e) {
-            // ignore
-        }
-        
-        Connection connection = null;
-        
-        if (transaction != null) {
-            connection = ManagedConnectionsByTransactionByDatasource.get(this, transaction);
-        }
-        
-        if (connection == null) {
-            connection = delegate.getConnection();
-        }
-        
-        return managed(connection);
+        return managed(delegate.getConnection());
     }
 
     @Override
@@ -123,7 +101,7 @@ public class ManagedDataSource implements DataSource {
     }
 
     public void clean() {
-        ManagedConnectionsByTransactionByDatasource.cleanDataSource(this);
+        ManagedConnection.cleanDataSource(this);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/ManagedDataSourceTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/ManagedDataSourceTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/ManagedDataSourceTest.java
index 6279f6c..e959693 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/ManagedDataSourceTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/ManagedDataSourceTest.java
@@ -20,7 +20,6 @@ import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.SingletonBean;
 import org.apache.openejb.junit.ApplicationComposer;
 import org.apache.openejb.resource.jdbc.managed.local.ManagedConnection;
-import org.apache.openejb.resource.jdbc.managed.local.ManagedConnectionsByTransactionByDatasource;
 import org.apache.openejb.testing.Configuration;
 import org.apache.openejb.testing.Module;
 import org.junit.After;
@@ -37,7 +36,6 @@ import javax.ejb.TransactionAttribute;
 import javax.ejb.TransactionAttributeType;
 import javax.sql.DataSource;
 import javax.transaction.Transaction;
-
 import java.lang.reflect.Field;
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -202,7 +200,7 @@ public class ManagedDataSourceTest {
 
     @After
     public void checkTxMapIsEmpty() throws Exception { // avoid memory leak
-        final Field map = ManagedConnectionsByTransactionByDatasource.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
+        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
         map.setAccessible(true);
         final Map<DataSource, Map<Transaction, Connection>> instance = (Map<DataSource, Map<Transaction, Connection>>) map.get(null);
         assertEquals(1, instance.size());

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java
index f538783..15288fe 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java
@@ -20,7 +20,6 @@ import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.SingletonBean;
 import org.apache.openejb.junit.ApplicationComposer;
 import org.apache.openejb.resource.jdbc.managed.local.ManagedConnection;
-import org.apache.openejb.resource.jdbc.managed.local.ManagedConnectionsByTransactionByDatasource;
 import org.apache.openejb.testing.Configuration;
 import org.apache.openejb.testing.Module;
 import org.junit.After;
@@ -35,7 +34,6 @@ import javax.ejb.LocalBean;
 import javax.ejb.Singleton;
 import javax.sql.DataSource;
 import javax.transaction.Transaction;
-
 import java.lang.reflect.Field;
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -196,7 +194,7 @@ public class MultiThreadedManagedDataSourceTest {
 
     @After
     public void checkTxMapIsEmpty() throws Exception { // avoid memory leak
-        final Field map = ManagedConnectionsByTransactionByDatasource.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
+        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
         map.setAccessible(true);
         final Map<DataSource, Map<Transaction, Connection>> instance = (Map<DataSource, Map<Transaction, Connection>>) map.get(null);
         assertEquals(1, instance.size());

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/UTManagedDataSourceTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/UTManagedDataSourceTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/UTManagedDataSourceTest.java
index 821a761..146a5b3 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/UTManagedDataSourceTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/UTManagedDataSourceTest.java
@@ -20,7 +20,6 @@ import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.SingletonBean;
 import org.apache.openejb.junit.ApplicationComposer;
 import org.apache.openejb.resource.jdbc.managed.local.ManagedConnection;
-import org.apache.openejb.resource.jdbc.managed.local.ManagedConnectionsByTransactionByDatasource;
 import org.apache.openejb.testing.Configuration;
 import org.apache.openejb.testing.Module;
 import org.junit.After;
@@ -37,7 +36,6 @@ import javax.ejb.TransactionManagementType;
 import javax.sql.DataSource;
 import javax.transaction.Transaction;
 import javax.transaction.UserTransaction;
-
 import java.lang.reflect.Field;
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -213,7 +211,7 @@ public class UTManagedDataSourceTest {
 
     @After
     public void checkTxMapIsEmpty() throws Exception { // avoid memory leak
-        final Field map = ManagedConnectionsByTransactionByDatasource.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
+        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
         map.setAccessible(true);
         final Map<DataSource, Map<Transaction, Connection>> instance = (Map<DataSource, Map<Transaction, Connection>>) map.get(null);
         assertEquals(1, instance.size());

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractSynchronizable.java
----------------------------------------------------------------------
diff --git a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractSynchronizable.java b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractSynchronizable.java
index 1244882..488e372 100644
--- a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractSynchronizable.java
+++ b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractSynchronizable.java
@@ -1,71 +1,71 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.openejb.maven.plugin;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-public abstract class AbstractSynchronizable {
-    protected int updateInterval;
-    protected List<String> extensions;
-    protected List<String> updateOnlyExtensions;
-    protected String regex;
-    protected Map<File, File> updates;
-
-    public abstract Map<File, File> updates();
-
-    public int getUpdateInterval() {
-        return updateInterval;
-    }
-
-    public void setUpdateInterval(final int updateInterval) {
-        this.updateInterval = updateInterval;
-    }
-
-    public List<String> getExtensions() {
-        if (extensions == null) {
-            extensions = new ArrayList<String>();
-        }
-        return extensions;
-    }
-
-    public void setExtensions(final List<String> extensions) {
-        this.extensions = extensions;
-    }
-
-    public String getRegex() {
-        return regex;
-    }
-
-    public void setRegex(final String regex) {
-        this.regex = regex;
-    }
-
-    public List<String> getUpdateOnlyExtenions() {
-        if (updateOnlyExtensions == null) {
-            updateOnlyExtensions = new ArrayList<String>();
-        }
-        return updateOnlyExtensions;
-    }
-
-    public void setUpdateOnlyExtensions(final List<String> updateOnlyExtensions) {
-        this.updateOnlyExtensions = updateOnlyExtensions;
-    }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.maven.plugin;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public abstract class AbstractSynchronizable {
+    protected int updateInterval;
+    protected List<String> extensions;
+    protected List<String> updateOnlyExtensions;
+    protected String regex;
+    protected Map<File, File> updates;
+
+    public abstract Map<File, File> updates();
+
+    public int getUpdateInterval() {
+        return updateInterval;
+    }
+
+    public void setUpdateInterval(final int updateInterval) {
+        this.updateInterval = updateInterval;
+    }
+
+    public List<String> getExtensions() {
+        if (extensions == null) {
+            extensions = new ArrayList<String>();
+        }
+        return extensions;
+    }
+
+    public void setExtensions(final List<String> extensions) {
+        this.extensions = extensions;
+    }
+
+    public String getRegex() {
+        return regex;
+    }
+
+    public void setRegex(final String regex) {
+        this.regex = regex;
+    }
+
+    public List<String> getUpdateOnlyExtenions() {
+        if (updateOnlyExtensions == null) {
+            updateOnlyExtensions = new ArrayList<String>();
+        }
+        return updateOnlyExtensions;
+    }
+
+    public void setUpdateOnlyExtensions(final List<String> updateOnlyExtensions) {
+        this.updateOnlyExtensions = updateOnlyExtensions;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/server/openejb-axis/src/test/resources/schema/ComplexAllElement.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/ComplexAllElement.xsd b/server/openejb-axis/src/test/resources/schema/ComplexAllElement.xsd
index 4821609..df9ef21 100644
--- a/server/openejb-axis/src/test/resources/schema/ComplexAllElement.xsd
+++ b/server/openejb-axis/src/test/resources/schema/ComplexAllElement.xsd
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
--->
-
-<!-- $Rev$ $Date$ -->
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
 <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
         xmlns:tns="X"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/server/openejb-axis/src/test/resources/schema/ComplexAllType.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/ComplexAllType.xsd b/server/openejb-axis/src/test/resources/schema/ComplexAllType.xsd
index 9409581..f9dd8b4 100644
--- a/server/openejb-axis/src/test/resources/schema/ComplexAllType.xsd
+++ b/server/openejb-axis/src/test/resources/schema/ComplexAllType.xsd
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
--->
-
-<!-- $Rev$ $Date$ -->
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
 <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
         xmlns:tns="X"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/server/openejb-axis/src/test/resources/schema/ComplexSequenceElement.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/ComplexSequenceElement.xsd b/server/openejb-axis/src/test/resources/schema/ComplexSequenceElement.xsd
index f59ab72..36299e3 100644
--- a/server/openejb-axis/src/test/resources/schema/ComplexSequenceElement.xsd
+++ b/server/openejb-axis/src/test/resources/schema/ComplexSequenceElement.xsd
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
--->
-
-<!-- $Rev$ $Date$ -->
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
 <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
         xmlns:tns="X"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/server/openejb-axis/src/test/resources/schema/ComplexSequenceType.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/ComplexSequenceType.xsd b/server/openejb-axis/src/test/resources/schema/ComplexSequenceType.xsd
index 0484e30..34dbf99 100644
--- a/server/openejb-axis/src/test/resources/schema/ComplexSequenceType.xsd
+++ b/server/openejb-axis/src/test/resources/schema/ComplexSequenceType.xsd
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
--->
-
-<!-- $Rev$ $Date$ -->
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
 <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
         xmlns:tns="X"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/server/openejb-axis/src/test/resources/schema/JaxRpcSpecExample.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/JaxRpcSpecExample.xsd b/server/openejb-axis/src/test/resources/schema/JaxRpcSpecExample.xsd
index 65eb581..a1bba13 100644
--- a/server/openejb-axis/src/test/resources/schema/JaxRpcSpecExample.xsd
+++ b/server/openejb-axis/src/test/resources/schema/JaxRpcSpecExample.xsd
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
--->
-
-<!-- $Rev$ $Date$ -->
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
 <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
         xmlns:tns="X"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/server/openejb-axis/src/test/resources/schema/SimpleElement.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/SimpleElement.xsd b/server/openejb-axis/src/test/resources/schema/SimpleElement.xsd
index 3f483e3..9d4bd82 100644
--- a/server/openejb-axis/src/test/resources/schema/SimpleElement.xsd
+++ b/server/openejb-axis/src/test/resources/schema/SimpleElement.xsd
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
--->
-
-<!-- $Rev$ $Date$ -->
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
 <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
         xmlns:tns="X"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/server/openejb-axis/src/test/resources/schema/SimpleType.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/SimpleType.xsd b/server/openejb-axis/src/test/resources/schema/SimpleType.xsd
index 894c3b4..83339ae 100644
--- a/server/openejb-axis/src/test/resources/schema/SimpleType.xsd
+++ b/server/openejb-axis/src/test/resources/schema/SimpleType.xsd
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
--->
-
-<!-- $Rev$ $Date$ -->
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
 <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
         xmlns:tns="X"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/server/openejb-axis/src/test/resources/schema/SoapArrayByAttribute.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/SoapArrayByAttribute.xsd b/server/openejb-axis/src/test/resources/schema/SoapArrayByAttribute.xsd
index 1f63eed..5696c61 100644
--- a/server/openejb-axis/src/test/resources/schema/SoapArrayByAttribute.xsd
+++ b/server/openejb-axis/src/test/resources/schema/SoapArrayByAttribute.xsd
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
--->
-
-<!-- $Rev$ $Date$ -->
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
 <xsd:schema
         targetNamespace="X"
         xmlns:tns="X"

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/server/openejb-axis/src/test/resources/schema/SoapArrayByRestriction.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/SoapArrayByRestriction.xsd b/server/openejb-axis/src/test/resources/schema/SoapArrayByRestriction.xsd
index ab4c67b..9b61fcc 100644
--- a/server/openejb-axis/src/test/resources/schema/SoapArrayByRestriction.xsd
+++ b/server/openejb-axis/src/test/resources/schema/SoapArrayByRestriction.xsd
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
--->
-
-<!-- $Rev$ $Date$ -->
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
 <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
         xmlns:tns="X"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/server/openejb-client/src/main/java/org/apache/openejb/client/ClientSecurity.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/ClientSecurity.java b/server/openejb-client/src/main/java/org/apache/openejb/client/ClientSecurity.java
index 99cacd1..1990958 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/ClientSecurity.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/ClientSecurity.java
@@ -1,204 +1,204 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.openejb.client;
-
-import javax.security.auth.login.FailedLoginException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.rmi.RemoteException;
-
-public class ClientSecurity {
-
-    public static final String IDENTITY_RESOLVER_STRATEGY = "openejb.client.identityResolver";
-
-    private static ServerMetaData server;
-    private static IdentityResolver identityResolver;
-    private static Object staticClientIdentity;
-    private static final InheritableThreadLocal<Object> threadClientIdentity = new InheritableThreadLocal<Object>();
-
-    static {
-        // determine the server uri
-        final String serverUri = System.getProperty("openejb.server.uri");
-
-        if (serverUri != null) {
-            // determine the server location
-            try {
-                final URI location = new URI(serverUri);
-                server = new ServerMetaData(location);
-            } catch (final Exception e) {
-                if (!serverUri.contains("://")) {
-                    try {
-                        final URI location = new URI("oejb://" + serverUri);
-                        server = new ServerMetaData(location);
-                    } catch (final URISyntaxException ignored) {
-                    }
-                }
-            }
-        }
-    }
-
-    public static ServerMetaData getServer() {
-        return server;
-    }
-
-    public static void setServer(final ServerMetaData server) {
-        ClientSecurity.server = server;
-    }
-
-    /**
-     * Login the spedified user using the specified password.  This is a global login for the
-     * entire Java Virtural Machine.  If you would like to have a thread scoped login, use
-     * ClientSecurity.login(username, password, true);
-     * </p>
-     * This is the equivalent of ClientSecurity.login(username, password, false);
-     *
-     * @param username the user to login
-     * @param password the password for the user
-     * @throws FailedLoginException if the username and password combination are not valid or
-     *                              if there is a problem communiating with the server
-     */
-    public static void login(final String username, final String password) throws FailedLoginException {
-        login(username, password, false);
-    }
-
-    /**
-     * Login the spedified user using the specified password either globally for the
-     * entire Java Virtural Machine or scoped to the thread.
-     * </p>
-     * When using thread scoped login, you should logout in a finally block.  This particularly
-     * when using thread pools.  If a thread is returned to the pool with a login attached to the
-     * thread the next user of that thread will inherit the thread scoped login.
-     *
-     * @param username     the user to login
-     * @param password     the password for the user
-     * @param threadScoped if true the login is scoped to the thread; otherwise the login is global
-     *                     for the entire Java Virtural Machine
-     * @throws FailedLoginException if the username and password combination are not valid or
-     *                              if there is a problem communiating with the server
-     */
-    public static void login(final String username, final String password, final boolean threadScoped) throws FailedLoginException {
-        final Object clientIdentity = directAuthentication(username, password, server);
-        if (threadScoped) {
-            threadClientIdentity.set(clientIdentity);
-        } else {
-            staticClientIdentity = clientIdentity;
-        }
-        identityResolver = new SimpleIdentityResolver();
-    }
-
-    /**
-     * Clears the thread and global login data.
-     */
-    public static void logout() {
-        threadClientIdentity.set(null);
-        staticClientIdentity = null;
-    }
-
-    /**
-     * This is a helper method for login modules. Directly authenticates with the server using the specified
-     * username and password returning the identity token for the client.  This methods does not store the
-     * identity token and the caller must arrange for the to be available to the OpenEJB proxies via an
-     * IdentityResolver.
-     *
-     * @param username the username for authentication
-     * @param password the password for authentication
-     * @param server   ServerMetaData
-     * @return the client identity token
-     * @throws FailedLoginException if the username password combination is not valid
-     */
-    public static Object directAuthentication(final String username, final String password, final ServerMetaData server) throws FailedLoginException {
-        return directAuthentication(null, username, password, server);
-    }
-
-    public static Object directAuthentication(final String securityRealm, final String username, final String password, final ServerMetaData server) throws FailedLoginException {
-        // authenticate
-        final AuthenticationRequest authReq = new AuthenticationRequest(securityRealm, username, password);
-        final AuthenticationResponse authRes;
-        try {
-            authRes = (AuthenticationResponse) Client.request(authReq, new AuthenticationResponse(), server);
-        } catch (final RemoteException e) {
-            throw (FailedLoginException) new FailedLoginException("Unable to authenticate with server " + server).initCause(e);
-        }
-
-        // check the response
-        if (authRes.getResponseCode() != ResponseCodes.AUTH_GRANTED) {
-            throw (FailedLoginException) new FailedLoginException("This principal is not authenticated.").initCause(authRes.getDeniedCause());
-        }
-
-        // return the response object
-        return authRes.getIdentity().getClientIdentity();
-    }
-
-    public static Object getIdentity() {
-        return getIdentityResolver().getIdentity();
-    }
-
-    public static IdentityResolver getIdentityResolver() {
-        if (identityResolver == null) {
-            final String strategy = System.getProperty(IDENTITY_RESOLVER_STRATEGY);
-            if (strategy == null) {
-                identityResolver = new JaasIdentityResolver();
-            } else {
-                // find the strategy class
-                final ResourceFinder finder = new ResourceFinder("META-INF/");
-                final Class identityResolverClass;
-                try {
-                    identityResolverClass = finder.findClass(IdentityResolver.class.getName() + "/" + strategy);
-                } catch (final Exception e) {
-                    throw new IllegalArgumentException("Could not find client identity strategy '" + strategy + "'");
-                }
-
-                // verify the interface
-                if (!IdentityResolver.class.isAssignableFrom(identityResolverClass)) {
-                    throw new IllegalArgumentException("Client identity strategy '" + strategy + "' " +
-                        "class '" + identityResolverClass.getName() + "' does not implement the " +
-                        "interface '" + IdentityResolver.class.getSimpleName() + "'");
-                }
-
-                // create the class
-                try {
-                    identityResolver = (IdentityResolver) identityResolverClass.newInstance();
-                } catch (final Exception e) {
-                    throw new IllegalArgumentException("Unable to create client identity strategy '" + strategy + "' " +
-                        "class '" + identityResolverClass.getName() + "'", e);
-                }
-            }
-
-        }
-        return identityResolver;
-    }
-
-    public static void setIdentityResolver(final IdentityResolver identityResolver) {
-        ClientSecurity.identityResolver = identityResolver;
-    }
-
-    private ClientSecurity() {
-    }
-
-    public static class SimpleIdentityResolver implements IdentityResolver {
-
-        @Override
-        public Object getIdentity() {
-            Object clientIdentity = threadClientIdentity.get();
-            if (clientIdentity == null) {
-                clientIdentity = staticClientIdentity;
-            }
-            return clientIdentity;
-        }
-    }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.client;
+
+import javax.security.auth.login.FailedLoginException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.rmi.RemoteException;
+
+public class ClientSecurity {
+
+    public static final String IDENTITY_RESOLVER_STRATEGY = "openejb.client.identityResolver";
+
+    private static ServerMetaData server;
+    private static IdentityResolver identityResolver;
+    private static Object staticClientIdentity;
+    private static final InheritableThreadLocal<Object> threadClientIdentity = new InheritableThreadLocal<Object>();
+
+    static {
+        // determine the server uri
+        final String serverUri = System.getProperty("openejb.server.uri");
+
+        if (serverUri != null) {
+            // determine the server location
+            try {
+                final URI location = new URI(serverUri);
+                server = new ServerMetaData(location);
+            } catch (final Exception e) {
+                if (!serverUri.contains("://")) {
+                    try {
+                        final URI location = new URI("oejb://" + serverUri);
+                        server = new ServerMetaData(location);
+                    } catch (final URISyntaxException ignored) {
+                    }
+                }
+            }
+        }
+    }
+
+    public static ServerMetaData getServer() {
+        return server;
+    }
+
+    public static void setServer(final ServerMetaData server) {
+        ClientSecurity.server = server;
+    }
+
+    /**
+     * Login the spedified user using the specified password.  This is a global login for the
+     * entire Java Virtural Machine.  If you would like to have a thread scoped login, use
+     * ClientSecurity.login(username, password, true);
+     * </p>
+     * This is the equivalent of ClientSecurity.login(username, password, false);
+     *
+     * @param username the user to login
+     * @param password the password for the user
+     * @throws FailedLoginException if the username and password combination are not valid or
+     *                              if there is a problem communiating with the server
+     */
+    public static void login(final String username, final String password) throws FailedLoginException {
+        login(username, password, false);
+    }
+
+    /**
+     * Login the spedified user using the specified password either globally for the
+     * entire Java Virtural Machine or scoped to the thread.
+     * </p>
+     * When using thread scoped login, you should logout in a finally block.  This particularly
+     * when using thread pools.  If a thread is returned to the pool with a login attached to the
+     * thread the next user of that thread will inherit the thread scoped login.
+     *
+     * @param username     the user to login
+     * @param password     the password for the user
+     * @param threadScoped if true the login is scoped to the thread; otherwise the login is global
+     *                     for the entire Java Virtural Machine
+     * @throws FailedLoginException if the username and password combination are not valid or
+     *                              if there is a problem communiating with the server
+     */
+    public static void login(final String username, final String password, final boolean threadScoped) throws FailedLoginException {
+        final Object clientIdentity = directAuthentication(username, password, server);
+        if (threadScoped) {
+            threadClientIdentity.set(clientIdentity);
+        } else {
+            staticClientIdentity = clientIdentity;
+        }
+        identityResolver = new SimpleIdentityResolver();
+    }
+
+    /**
+     * Clears the thread and global login data.
+     */
+    public static void logout() {
+        threadClientIdentity.set(null);
+        staticClientIdentity = null;
+    }
+
+    /**
+     * This is a helper method for login modules. Directly authenticates with the server using the specified
+     * username and password returning the identity token for the client.  This methods does not store the
+     * identity token and the caller must arrange for the to be available to the OpenEJB proxies via an
+     * IdentityResolver.
+     *
+     * @param username the username for authentication
+     * @param password the password for authentication
+     * @param server   ServerMetaData
+     * @return the client identity token
+     * @throws FailedLoginException if the username password combination is not valid
+     */
+    public static Object directAuthentication(final String username, final String password, final ServerMetaData server) throws FailedLoginException {
+        return directAuthentication(null, username, password, server);
+    }
+
+    public static Object directAuthentication(final String securityRealm, final String username, final String password, final ServerMetaData server) throws FailedLoginException {
+        // authenticate
+        final AuthenticationRequest authReq = new AuthenticationRequest(securityRealm, username, password);
+        final AuthenticationResponse authRes;
+        try {
+            authRes = (AuthenticationResponse) Client.request(authReq, new AuthenticationResponse(), server);
+        } catch (final RemoteException e) {
+            throw (FailedLoginException) new FailedLoginException("Unable to authenticate with server " + server).initCause(e);
+        }
+
+        // check the response
+        if (authRes.getResponseCode() != ResponseCodes.AUTH_GRANTED) {
+            throw (FailedLoginException) new FailedLoginException("This principal is not authenticated.").initCause(authRes.getDeniedCause());
+        }
+
+        // return the response object
+        return authRes.getIdentity().getClientIdentity();
+    }
+
+    public static Object getIdentity() {
+        return getIdentityResolver().getIdentity();
+    }
+
+    public static IdentityResolver getIdentityResolver() {
+        if (identityResolver == null) {
+            final String strategy = System.getProperty(IDENTITY_RESOLVER_STRATEGY);
+            if (strategy == null) {
+                identityResolver = new JaasIdentityResolver();
+            } else {
+                // find the strategy class
+                final ResourceFinder finder = new ResourceFinder("META-INF/");
+                final Class identityResolverClass;
+                try {
+                    identityResolverClass = finder.findClass(IdentityResolver.class.getName() + "/" + strategy);
+                } catch (final Exception e) {
+                    throw new IllegalArgumentException("Could not find client identity strategy '" + strategy + "'");
+                }
+
+                // verify the interface
+                if (!IdentityResolver.class.isAssignableFrom(identityResolverClass)) {
+                    throw new IllegalArgumentException("Client identity strategy '" + strategy + "' " +
+                        "class '" + identityResolverClass.getName() + "' does not implement the " +
+                        "interface '" + IdentityResolver.class.getSimpleName() + "'");
+                }
+
+                // create the class
+                try {
+                    identityResolver = (IdentityResolver) identityResolverClass.newInstance();
+                } catch (final Exception e) {
+                    throw new IllegalArgumentException("Unable to create client identity strategy '" + strategy + "' " +
+                        "class '" + identityResolverClass.getName() + "'", e);
+                }
+            }
+
+        }
+        return identityResolver;
+    }
+
+    public static void setIdentityResolver(final IdentityResolver identityResolver) {
+        ClientSecurity.identityResolver = identityResolver;
+    }
+
+    private ClientSecurity() {
+    }
+
+    public static class SimpleIdentityResolver implements IdentityResolver {
+
+        @Override
+        public Object getIdentity() {
+            Object clientIdentity = threadClientIdentity.get();
+            if (clientIdentity == null) {
+                clientIdentity = staticClientIdentity;
+            }
+            return clientIdentity;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/b36eb932/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java b/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java
index c066c9f..56d2623 100755
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java
@@ -1,33 +1,33 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.openejb.client;
-
-import java.io.IOException;
-
-public class DirectConnectionStrategy implements ConnectionStrategy {
-
-    @Override
-    public Connection connect(final ClusterMetaData cluster, final ServerMetaData server) throws IOException {
-        final Connection connection = ConnectionManager.getConnection(server.getLocation());
-
-        // Grabbing the URI from the associated connection allows the ConnectionFactory to
-        // employ discovery to find and connect to a server.  We then attempt to connect
-        // to the discovered server rather than repeat the discovery process again.
-        cluster.setLastLocation(connection.getURI());
-        return connection;
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.client;
+
+import java.io.IOException;
+
+public class DirectConnectionStrategy implements ConnectionStrategy {
+
+    @Override
+    public Connection connect(final ClusterMetaData cluster, final ServerMetaData server) throws IOException {
+        final Connection connection = ConnectionManager.getConnection(server.getLocation());
+
+        // Grabbing the URI from the associated connection allows the ConnectionFactory to
+        // employ discovery to find and connect to a server.  We then attempt to connect
+        // to the discovered server rather than repeat the discovery process again.
+        cluster.setLastLocation(connection.getURI());
+        return connection;
+    }
+}