You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2013/11/26 14:02:05 UTC
svn commit: r1545645 - in
/tomee/tomee/trunk/server/openejb-client/src/main/java/org/apache/openejb/client:
ConnectionManager.java DirectConnectionStrategy.java
Author: jlmonteiro
Date: Tue Nov 26 13:02:04 2013
New Revision: 1545645
URL: http://svn.apache.org/r1545645
Log:
OPENEJB-2048 Add a DirectConnectionFactory to the client side for simple cases
Added:
tomee/tomee/trunk/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java (with props)
Modified:
tomee/tomee/trunk/server/openejb-client/src/main/java/org/apache/openejb/client/ConnectionManager.java
Modified: tomee/tomee/trunk/server/openejb-client/src/main/java/org/apache/openejb/client/ConnectionManager.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-client/src/main/java/org/apache/openejb/client/ConnectionManager.java?rev=1545645&r1=1545644&r2=1545645&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-client/src/main/java/org/apache/openejb/client/ConnectionManager.java (original)
+++ tomee/tomee/trunk/server/openejb-client/src/main/java/org/apache/openejb/client/ConnectionManager.java Tue Nov 26 13:02:04 2013
@@ -50,6 +50,7 @@ public class ConnectionManager {
registerFactory("failover", new FailoverConnectionFactory());
registerStrategy("sticky", new StickyConnectionStrategy());
+ registerStrategy("direct", new DirectConnectionStrategy());
registerStrategy("sticky+random", new StickyConnectionStrategy(new RandomConnectionStrategy()));
registerStrategy("sticky+round", new StickyConnectionStrategy(new RoundRobinConnectionStrategy()));
registerStrategy("random", new RandomConnectionStrategy());
Added: tomee/tomee/trunk/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java?rev=1545645&view=auto
==============================================================================
--- tomee/tomee/trunk/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java (added)
+++ tomee/tomee/trunk/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java Tue Nov 26 13:02:04 2013
@@ -0,0 +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(ClusterMetaData cluster, 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;
+ }
+}
Propchange: tomee/tomee/trunk/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java
------------------------------------------------------------------------------
svn:executable = *