You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jg...@apache.org on 2007/01/02 23:40:32 UTC
svn commit: r491952 - in /geronimo/sandbox/gcache:
client/src/main/java/org/apache/geronimo/gcache/client/
client/src/main/java/org/apache/geronimo/gcache/transports/
client/src/main/java/org/apache/geronimo/gcache/transports/tcp/
client/src/main/resou...
Author: jgenender
Date: Tue Jan 2 14:40:30 2007
New Revision: 491952
URL: http://svn.apache.org/viewvc?view=rev&rev=491952
Log:
Client components
Added:
geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/client/GcacheClientConfiguration.java
geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/ClientTransport.java
geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/ClientTransportFactory.java
geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketHandler.java
geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketTransportService.java
- copied, changed from r480290, geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientTransportService.java
geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketTransportServiceFactory.java
geronimo/sandbox/gcache/client/src/main/resources/META-INF/
geronimo/sandbox/gcache/client/src/main/resources/META-INF/services/
geronimo/sandbox/gcache/client/src/main/resources/META-INF/services/org/
geronimo/sandbox/gcache/client/src/main/resources/META-INF/services/org/apache/
geronimo/sandbox/gcache/client/src/main/resources/META-INF/services/org/apache/geronimo/
geronimo/sandbox/gcache/client/src/main/resources/META-INF/services/org/apache/geronimo/gcache/
geronimo/sandbox/gcache/client/src/main/resources/META-INF/services/org/apache/geronimo/gcache/client/
geronimo/sandbox/gcache/client/src/main/resources/META-INF/services/org/apache/geronimo/gcache/client/transport/
geronimo/sandbox/gcache/client/src/main/resources/META-INF/services/org/apache/geronimo/gcache/client/transport/tcp
geronimo/sandbox/gcache/client/src/test/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketTransportServiceFactoryTest.java
Removed:
geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientTransportService.java
geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/BaseCommandVisitor.java
Modified:
geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/client/ClientConfigBuilder.java
geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/client/GCacheClient.java
geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/ClientConnectionManager.java
geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientCommandVisitor.java
geronimo/sandbox/gcache/client/src/main/resources/gcache-client-config-default.xml
geronimo/sandbox/gcache/client/src/main/xsd/gcache-client.xsd
geronimo/sandbox/gcache/client/src/test/java/org/apache/geronimo/gcache/dd/ClientConfigBuilderTest.java
geronimo/sandbox/gcache/client/src/test/resources/gcache-client-config.xml
geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/dd/GcacheConfiguration.java
geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/ConnectionManager.java
geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/TransportService.java
geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPTransportService.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/GcacheServerConfiguration.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ServerConfigBuilder.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheManager.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/ServerConnectionManager.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPServerSocketTransportService.java
geronimo/sandbox/gcache/server/src/main/xsd/gcache-server.xsd
geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/AbstractService.java
geronimo/sandbox/gcache/tests/src/test/java/org/apache/geronimo/gcache/AbstractParent.java
Modified: geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/client/ClientConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/client/ClientConfigBuilder.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/client/ClientConfigBuilder.java (original)
+++ geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/client/ClientConfigBuilder.java Tue Jan 2 14:40:30 2007
@@ -30,10 +30,10 @@
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gcache.client.dd.CacheType;
import org.apache.geronimo.gcache.client.dd.DefaultCacheType;
+import org.apache.geronimo.gcache.client.dd.DiscoveryType;
import org.apache.geronimo.gcache.client.dd.DiskStoreType;
import org.apache.geronimo.gcache.client.dd.GcacheClientConfig;
import org.apache.geronimo.gcache.client.dd.JaxbGcacheClientConfigurationFactory;
-import org.apache.geronimo.gcache.client.dd.TransportType;
import org.apache.geronimo.gcache.dd.GcacheConfiguration;
public class ClientConfigBuilder {
@@ -44,9 +44,9 @@
private static final String DEFAULT_CLASSPATH_CONFIGURATION_FILE = "gcache-client-config-default.xml";
- public GcacheConfiguration getConfig(URL fileURL) {
+ public GcacheClientConfiguration getConfig(URL fileURL) {
- GcacheConfiguration config = null;
+ GcacheClientConfiguration config = null;
ClassLoader cl = Thread.currentThread().getContextClassLoader();
// Was a file passed to us?
@@ -75,9 +75,9 @@
return config;
}
- private GcacheConfiguration processConfig(URL url) {
+ private GcacheClientConfiguration processConfig(URL url) {
try {
- GcacheConfiguration gcacheConfig = new GcacheConfiguration();
+ GcacheClientConfiguration gcacheClientConfig = new GcacheClientConfiguration();
Configuration ehcacheConfig = new Configuration();
DiskStoreConfiguration diskConfig = null;
CacheConfiguration defaultCache = null;
@@ -86,19 +86,15 @@
GcacheClientConfig config = factory.getConfig(url);
- // Get the transport
- TransportType transport = config.getTransport();
- if (transport != null) {
- gcacheConfig.setTransportName(transport.getName());
-
- URI transportURI = new URI(transport.getUri());
- gcacheConfig.setTransportUri(transportURI);
-
- String discovery = transport.getDiscoveryUri();
- if (discovery != null) {
- URI discoveryURI = new URI(discovery);
- gcacheConfig.setDiscoveryUri(discoveryURI);
- }
+ // Get the discovery
+ DiscoveryType discovery = config.getDiscovery();
+ if (discovery != null) {
+ gcacheClientConfig.setUser(discovery.getUser());
+ gcacheClientConfig.setPassword(discovery.getPassword());
+
+ URI discoveryURI = new URI(discovery.getUri());
+ gcacheClientConfig.setDiscoveryUri(discoveryURI);
+
}
// Read the disk store
@@ -143,9 +139,9 @@
ehcacheConfig.addCache(cache);
}
- gcacheConfig.setEhcacheConfig(ehcacheConfig);
+ gcacheClientConfig.setEhcacheConfig(ehcacheConfig);
- return gcacheConfig;
+ return gcacheClientConfig;
} catch (Exception e) {
throw new RuntimeException(e);
Modified: geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/client/GCacheClient.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/client/GCacheClient.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/client/GCacheClient.java (original)
+++ geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/client/GCacheClient.java Tue Jan 2 14:40:30 2007
@@ -18,36 +18,46 @@
*/
package org.apache.geronimo.gcache.client;
+import java.io.File;
+
import net.sf.ehcache.CacheManager;
import org.apache.geronimo.gcache.CacheInfoHolder;
+import org.apache.geronimo.gcache.dd.GcacheConfiguration;
import org.apache.geronimo.gcache.transports.ClientConnectionManager;
import org.apache.geronimo.gcache.transports.ConnectionManager;
import org.apache.geronimo.gcache.transports.tcp.TCPClientCommandVisitor;
public class GCacheClient {
+ private String configFile;
private CacheInfoHolder info;
private CacheManager cacheMgr;
- private ConnectionManager connectionManager;
+ private ClientConnectionManager connectionManager;
+
+ public GCacheClient(String configFile) {
+ super();
+ this.configFile = configFile;
+ }
public void start() throws Exception {
// Create a cache with the configuration from the gcache-config file
- //TODO - Pass a configuration file
-// cacheMgr = new CacheManager(config.getEhcacheConfig());
+ ClientConfigBuilder builder = new ClientConfigBuilder();
+
+ GcacheClientConfiguration config = builder.getConfig(configFile == null ? null : (new File(configFile)).toURL());
+
+ cacheMgr = new CacheManager(config.getEhcacheConfig());
cacheMgr = new CacheManager();
info = new CacheInfoHolder(cacheMgr);
info.setCommandVisitor(new TCPClientCommandVisitor(info));
connectionManager = new ClientConnectionManager(info);
-// connectionManager.setTransportURI(config.getTransportUri());
-// connectionManager.setDiscoveryURI(config.getDiscoveryUri());
+ connectionManager.setDiscoveryURI(config.getDiscoveryUri());
connectionManager.start();
}
public void stop() throws Exception{
- //TODO - Do we clear the cacheMgr??
connectionManager.stop();
}
Added: geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/client/GcacheClientConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/client/GcacheClientConfiguration.java?view=auto&rev=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/client/GcacheClientConfiguration.java (added)
+++ geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/client/GcacheClientConfiguration.java Tue Jan 2 14:40:30 2007
@@ -0,0 +1,49 @@
+/*
+ * 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.geronimo.gcache.client;
+
+import java.net.URI;
+
+import org.apache.geronimo.gcache.dd.GcacheConfiguration;
+
+public class GcacheClientConfiguration extends GcacheConfiguration {
+
+ private String user;
+ private String password;
+ private URI discoveryUri;
+
+ public URI getDiscoveryUri() {
+ return discoveryUri;
+ }
+ public void setDiscoveryUri(URI discoveryUri) {
+ this.discoveryUri = discoveryUri;
+ }
+ public String getPassword() {
+ return password;
+ }
+ public void setPassword(String password) {
+ this.password = password;
+ }
+ public String getUser() {
+ return user;
+ }
+ public void setUser(String user) {
+ this.user = user;
+ }
+}
Modified: geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/ClientConnectionManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/ClientConnectionManager.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/ClientConnectionManager.java (original)
+++ geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/ClientConnectionManager.java Tue Jan 2 14:40:30 2007
@@ -18,36 +18,93 @@
*/
package org.apache.geronimo.gcache.transports;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gcache.CacheInfoHolder;
import org.apache.geronimo.gcache.transports.discovery.DiscoveryAgentFactory;
public class ClientConnectionManager extends ConnectionManager {
+ private static Log log = LogFactory.getLog(ClientConnectionManager.class);
+
+ private boolean stopped = true;
+
public ClientConnectionManager(CacheInfoHolder info) {
super(info);
}
-
+
@Override
public void start() throws Exception {
- transport = TransportFactory.createTransportService(transportURI, info);
+
+ stopped = false;
+
if (discoveryURI != null) {
discovery = DiscoveryAgentFactory.createDiscoveryAgent(discoveryURI, info);
}
- transport.start();
-
if (discovery != null)
discovery.start();
+
}
@Override
public void stop() throws Exception {
+ stopped = true;
+
if (discovery != null)
discovery.stop();
- if (transport != null) {
- transport.stop();
+ }
+
+ private void connectToServer() throws Exception {
+ DiscoveryManager disc = info.getDiscoveryManager();
+ while (!stopped) {
+ String services[] = disc.getServices();
+
+ // If nobody is out there, then sleep for a second to listen for
+ // servers
+ if (services.length == 0) {
+ sleeper(1000);
+ continue;
+ }
+
+ //TODO - We need to identify the master here!!!!
+
+ // Ok, we have some servers, lets go for the first one in line
+ URI uri = null;
+ try {
+ uri = new URI(services[0]);
+ } catch (URISyntaxException e) {
+ // This should never happen
+ log.error(e);
+ // Take a nap
+ sleeper(1000);
+ // And try again
+ continue;
+ }
+
+ transportURI = uri;
+ transport = ClientTransportFactory.createTransportService(transportURI, info);
+ transport.setUserName(userName);
+ transport.setPassword(password);
+
+ transport.start();
+
+ return;
+
+ }
+ }
+
+ private void sleeper(int millis) {
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException e) {
+ // This really should not ever happen
+ log.error(e);
}
}
Added: geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/ClientTransport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/ClientTransport.java?view=auto&rev=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/ClientTransport.java (added)
+++ geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/ClientTransport.java Tue Jan 2 14:40:30 2007
@@ -0,0 +1,34 @@
+/*
+ * 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.geronimo.gcache.transports;
+
+public interface ClientTransport {
+
+ public boolean connect();
+
+ public void putSession(String cacheName, String sessionId, Object value);
+
+ public void putEntry(String cacheName, String sessionId, Object key, Object value);
+
+ public void removeSession(String cacheName, String session);
+
+ public void removeEntry(String cacheName, String sessionId, Object key);
+
+ public void join();
+}
Added: geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/ClientTransportFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/ClientTransportFactory.java?view=auto&rev=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/ClientTransportFactory.java (added)
+++ geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/ClientTransportFactory.java Tue Jan 2 14:40:30 2007
@@ -0,0 +1,65 @@
+/*
+ * 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.geronimo.gcache.transports;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.geronimo.gcache.CacheInfoHolder;
+import org.apache.geronimo.gcache.util.FactoryFinder;
+import org.apache.geronimo.gcache.util.IOExceptionSupport;
+
+public abstract class ClientTransportFactory {
+
+ static final private FactoryFinder transportFactoryFinder = new FactoryFinder("META-INF/services/org/apache/geronimo/gcache/client/transport/");
+ static final private ConcurrentHashMap transportFactorys = new ConcurrentHashMap();
+
+ /**
+ * @param location
+ * @return
+ * @throws IOException
+ */
+ private static ClientTransportFactory findTransportFactory(URI location) throws IOException {
+ String scheme = location.getScheme();
+ if( scheme == null )
+ throw new IOException("Transport not scheme specified: [" + location + "]");
+ ClientTransportFactory tf = (ClientTransportFactory) transportFactorys.get(scheme);
+ if (tf == null) {
+ // Try to load if from a META-INF property.
+ try {
+ tf = (ClientTransportFactory) transportFactoryFinder.newInstance(scheme);
+ transportFactorys.put(scheme, tf);
+ }
+ catch (Throwable e) {
+ throw IOExceptionSupport.create("Transport scheme NOT recognized: [" + scheme + "]", e);
+ }
+ }
+ return tf;
+ }
+
+ public static TransportService createTransportService(URI uri, CacheInfoHolder info) throws IOException {
+ ClientTransportFactory tf = findTransportFactory(uri);
+ return tf.doCreateTransportService(uri, info);
+
+ }
+
+ abstract protected TransportService doCreateTransportService(URI uri, CacheInfoHolder info) throws IOException;
+
+}
Modified: geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientCommandVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientCommandVisitor.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientCommandVisitor.java (original)
+++ geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientCommandVisitor.java Tue Jan 2 14:40:30 2007
@@ -207,5 +207,6 @@
sendAck(command);
}
-
+
+
}
Added: geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketHandler.java?view=auto&rev=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketHandler.java (added)
+++ geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketHandler.java Tue Jan 2 14:40:30 2007
@@ -0,0 +1,46 @@
+/*
+ * 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.geronimo.gcache.transports.tcp;
+
+import org.apache.geronimo.gcache.CacheInfoHolder;
+import org.apache.mina.common.IoSession;
+
+public class TCPClientSocketHandler extends TCPSocketHandler {
+
+ public TCPClientSocketHandler(CacheInfoHolder infoHolder, int threadPoolSize) {
+ super(infoHolder, threadPoolSize);
+ }
+
+ public TCPClientSocketHandler(CacheInfoHolder infoHolder) {
+ super(infoHolder);
+ }
+
+ @Override
+ public void exceptionCaught(IoSession arg0, Throwable arg1) throws Exception {
+ // TODO Auto-generated method stub
+ super.exceptionCaught(arg0, arg1);
+ }
+
+ @Override
+ public void sessionClosed(IoSession arg0) throws Exception {
+ // TODO Auto-generated method stub
+ super.sessionClosed(arg0);
+ }
+
+}
Copied: geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketTransportService.java (from r480290, geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientTransportService.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketTransportService.java?view=diff&rev=491952&p1=geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientTransportService.java&r1=480290&p2=geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketTransportService.java&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientTransportService.java (original)
+++ geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketTransportService.java Tue Jan 2 14:40:30 2007
@@ -19,42 +19,56 @@
package org.apache.geronimo.gcache.transports.tcp;
import java.net.InetSocketAddress;
-import java.net.SocketAddress;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gcache.command.BaseCommand;
+import org.apache.geronimo.gcache.command.HandShakeCommand;
+import org.apache.geronimo.gcache.command.PutEntryCommand;
+import org.apache.geronimo.gcache.command.PutSessionCommand;
+import org.apache.geronimo.gcache.command.RemoveEntryCommand;
+import org.apache.geronimo.gcache.transports.ClientTransport;
+import org.apache.geronimo.gcache.util.CipherUtil;
import org.apache.mina.common.ConnectFuture;
import org.apache.mina.common.IoHandler;
import org.apache.mina.common.IoSession;
import org.apache.mina.filter.LoggingFilter;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
-import org.apache.mina.transport.socket.nio.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
import org.apache.mina.transport.socket.nio.SocketConnector;
import org.apache.mina.transport.socket.nio.SocketConnectorConfig;
-public class TCPClientTransportService extends TCPTransportService {
+import com.apple.crypto.provider.CryptoGlobals;
+
+public class TCPClientSocketTransportService extends TCPTransportService implements ClientTransport{
+
+ private static Log log = LogFactory.getLog(TCPClientSocketTransportService.class);
+
+ private boolean stopped = true;
private IoHandler handler;
- private IoSession session;
+ private IoSession sess;
@Override
public void start() throws Exception {
- int port = tcpURI.getPort();
- String host = tcpURI.getHost();
-
- InetSocketAddress inet = new InetSocketAddress(host, port);
-
- connect(inet);
+ stopped = false;
}
@Override
public void stop() throws Exception {
+ stopped = true;
disconnect();
}
- private boolean connect(SocketAddress address) {
-
- if (session != null && session.isConnected()) {
+ public boolean connect() {
+ //Get the proper attributes
+ int port = tcpURI.getPort();
+ String host = tcpURI.getHost();
+
+ //Create an address
+ InetSocketAddress address = new InetSocketAddress(host, port);
+
+ if (sess!= null && sess.isConnected()) {
throw new IllegalStateException("Already connected. Disconnect first.");
}
@@ -82,12 +96,12 @@
handler = new TCPSocketHandler(info);
- ConnectFuture future1 = connector.connect(address, handler, cfg);
- future1.join();
- if (!future1.isConnected()) {
+ ConnectFuture future = connector.connect(address, handler, cfg);
+ future.join();
+ if (!future.isConnected()) {
return false;
}
- session = future1.getSession();
+ sess = future.getSession();
return true;
} catch (Exception e) {
@@ -96,13 +110,69 @@
}
private void disconnect() {
- if (session != null) {
- if (session.isConnected()) {
- session.getCloseFuture().join();
+ if (sess != null) {
+ if (sess.isConnected()) {
+ sess.getCloseFuture().join();
}
- session.close();
- session = null;
+ sess.close();
+ sess = null;
}
}
+ public void join() {
+ HandShakeCommand command = new HandShakeCommand();
+ command.setPublicKey(CipherUtil.publicKey);
+ }
+
+ public void putSession(String cacheName, String sessionId, Object value) {
+
+ PutSessionCommand command = new PutSessionCommand();
+
+ command.setCacheName(cacheName);
+ command.setSessionId(sessionId);
+ command.setKey(value);
+ command.setPayload(value);
+
+ send(command);
+ }
+
+ public void removeEntry(String cacheName, String sessionId, Object key) {
+ RemoveEntryCommand command = new RemoveEntryCommand();
+
+ command.setCacheName(cacheName);
+ command.setSessionId(sessionId);
+ command.setKey(key);
+
+ send(command);
+ }
+
+ public void removeSession(String cacheName, String session) {
+ PutSessionCommand command = new PutSessionCommand();
+
+ command.setCacheName(cacheName);
+ command.setSessionId(session);
+
+ send(command);
+ }
+
+ public void putEntry(String cacheName, String sessionId, Object key, Object value) {
+
+ PutEntryCommand command = new PutEntryCommand();
+
+ command.setCacheName(cacheName);
+ command.setSessionId(sessionId);
+ command.setKey(value);
+ command.setPayload(value);
+
+ send(command);
+ }
+
+ public void send(BaseCommand command){
+
+ sess.write(command);
+
+ //Request ack if setup to do so
+ command.setAttachment(sess);
+ ((TCPClientCommandVisitor)info.getCommandVisitor()).requestAck(command);
+ }
}
Added: geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketTransportServiceFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketTransportServiceFactory.java?view=auto&rev=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketTransportServiceFactory.java (added)
+++ geronimo/sandbox/gcache/client/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketTransportServiceFactory.java Tue Jan 2 14:40:30 2007
@@ -0,0 +1,51 @@
+/*
+ * 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.geronimo.gcache.transports.tcp;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Map;
+
+import org.apache.geronimo.gcache.CacheInfoHolder;
+import org.apache.geronimo.gcache.transports.ClientTransportFactory;
+import org.apache.geronimo.gcache.transports.TransportService;
+import org.apache.geronimo.gcache.util.IOExceptionSupport;
+import org.apache.geronimo.gcache.util.IntrospectionSupport;
+import org.apache.geronimo.gcache.util.URISupport;
+
+public class TCPClientSocketTransportServiceFactory extends ClientTransportFactory {
+
+ @Override
+ protected TransportService doCreateTransportService(URI uri, CacheInfoHolder info) throws IOException {
+ try {
+
+ Map options = URISupport.parseParamters(uri);
+ TCPClientSocketTransportService rc = new TCPClientSocketTransportService();
+
+ rc.setInfo(info);
+ rc.setTcpURI(uri);
+ IntrospectionSupport.setProperties(rc, options);
+ return rc;
+
+ } catch (Throwable e) {
+ throw IOExceptionSupport.create("Could not create tcp transport service: " + uri, e);
+ }
+ }
+
+}
Added: geronimo/sandbox/gcache/client/src/main/resources/META-INF/services/org/apache/geronimo/gcache/client/transport/tcp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/main/resources/META-INF/services/org/apache/geronimo/gcache/client/transport/tcp?view=auto&rev=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/main/resources/META-INF/services/org/apache/geronimo/gcache/client/transport/tcp (added)
+++ geronimo/sandbox/gcache/client/src/main/resources/META-INF/services/org/apache/geronimo/gcache/client/transport/tcp Tue Jan 2 14:40:30 2007
@@ -0,0 +1 @@
+class=org.apache.geronimo.gcache.transports.tcp.TCPClientSocketTransportServiceFactory
\ No newline at end of file
Modified: geronimo/sandbox/gcache/client/src/main/resources/gcache-client-config-default.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/main/resources/gcache-client-config-default.xml?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/main/resources/gcache-client-config-default.xml (original)
+++ geronimo/sandbox/gcache/client/src/main/resources/gcache-client-config-default.xml Tue Jan 2 14:40:30 2007
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gcache-client-config>
- <transport name="default" uri="tcp://default" discoveryUri="multicast://default" />
+ <discovery user="system" password="manager" uri="multicast://default" />
<diskStore path="${java.io.tmpdir}/gcache" />
<defaultCache maxElementsInMemory="10000" eternal="false"
timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true"
Modified: geronimo/sandbox/gcache/client/src/main/xsd/gcache-client.xsd
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/main/xsd/gcache-client.xsd?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/main/xsd/gcache-client.xsd (original)
+++ geronimo/sandbox/gcache/client/src/main/xsd/gcache-client.xsd Tue Jan 2 14:40:30 2007
@@ -25,7 +25,7 @@
<xs:complexType name="gcacheClientConfig">
<xs:sequence>
- <xs:element name="transport" type="gcache:transportType"
+ <xs:element name="discovery" type="gcache-client:discoveryType"
minOccurs="1" maxOccurs="1" />
<xs:element name="diskStore" type="gcache:diskStoreType"
minOccurs="1" maxOccurs="1" />
@@ -34,6 +34,12 @@
<xs:element name="cache" type="gcache:cacheType"
minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="discoveryType">
+ <xs:attribute name="user" use="optional" type="xs:NCName" default="system"/>
+ <xs:attribute name="password" use="optional" type="xs:NCName" default="manager"/>
+ <xs:attribute name="uri" use="optional" type="xs:NCName" />
</xs:complexType>
</xs:schema>
Modified: geronimo/sandbox/gcache/client/src/test/java/org/apache/geronimo/gcache/dd/ClientConfigBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/test/java/org/apache/geronimo/gcache/dd/ClientConfigBuilderTest.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/test/java/org/apache/geronimo/gcache/dd/ClientConfigBuilderTest.java (original)
+++ geronimo/sandbox/gcache/client/src/test/java/org/apache/geronimo/gcache/dd/ClientConfigBuilderTest.java Tue Jan 2 14:40:30 2007
@@ -24,6 +24,7 @@
import net.sf.ehcache.config.Configuration;
import org.apache.geronimo.gcache.client.ClientConfigBuilder;
+import org.apache.geronimo.gcache.client.GcacheClientConfiguration;
import org.testng.annotations.Test;
public class ClientConfigBuilderTest {
@@ -33,11 +34,11 @@
ClientConfigBuilder cb = new ClientConfigBuilder();
//Pull the configuration
- GcacheConfiguration config = cb.getConfig(null);
+ GcacheClientConfiguration config = cb.getConfig(null);
- //Server and Transport Settings
- assert config.getTransportUri().getHost().equals("default");
- assert config.getTransportUri().getScheme().equals("tcp");
+ //Discovery settings
+ assert config.getUser().equals("system");
+ assert config.getPassword().equals("manager");
assert config.getDiscoveryUri().getHost().equals("default");
assert config.getDiscoveryUri().getScheme().equals("multicast");
Added: geronimo/sandbox/gcache/client/src/test/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketTransportServiceFactoryTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/test/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketTransportServiceFactoryTest.java?view=auto&rev=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/test/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketTransportServiceFactoryTest.java (added)
+++ geronimo/sandbox/gcache/client/src/test/java/org/apache/geronimo/gcache/transports/tcp/TCPClientSocketTransportServiceFactoryTest.java Tue Jan 2 14:40:30 2007
@@ -0,0 +1,39 @@
+/*
+ * 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.geronimo.gcache.transports.tcp;
+
+import java.net.URI;
+
+import org.apache.geronimo.gcache.CacheInfoHolder;
+import org.testng.annotations.Test;
+
+public class TCPClientSocketTransportServiceFactoryTest {
+
+ @Test
+ public void testTCPClientSocketTransportServiceFactory() throws Exception{
+
+ CacheInfoHolder info = new CacheInfoHolder(null);
+ URI uri = new URI("tcp://default");
+ TCPClientSocketTransportService service = (TCPClientSocketTransportService)TCPClientSocketTransportServiceFactory.createTransportService(uri, info);
+
+ assert service instanceof TCPClientSocketTransportService;
+ assert service != null;
+ }
+
+}
Modified: geronimo/sandbox/gcache/client/src/test/resources/gcache-client-config.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/client/src/test/resources/gcache-client-config.xml?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/client/src/test/resources/gcache-client-config.xml (original)
+++ geronimo/sandbox/gcache/client/src/test/resources/gcache-client-config.xml Tue Jan 2 14:40:30 2007
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gcache-client-config>
- <transport name="default" uri="tcp://default?enableLogging=true" discoveryUri="multicast://default" />
+ <discovery user="system" password="manager" uri="multicast://default" />
<diskStore path="${java.io.tmpdir}/gcache" />
Modified: geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/dd/GcacheConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/dd/GcacheConfiguration.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/dd/GcacheConfiguration.java (original)
+++ geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/dd/GcacheConfiguration.java Tue Jan 2 14:40:30 2007
@@ -17,15 +17,11 @@
*/
package org.apache.geronimo.gcache.dd;
-import java.net.URI;
-
import net.sf.ehcache.config.Configuration;
public class GcacheConfiguration {
+
private Configuration ehcacheConfig = null;
- private String transportName;
- private URI transportUri;
- private URI discoveryUri;
public Configuration getEhcacheConfig() {
return ehcacheConfig;
@@ -33,22 +29,5 @@
public void setEhcacheConfig(Configuration ehcacheConfig) {
this.ehcacheConfig = ehcacheConfig;
}
- public String getTransportName() {
- return transportName;
- }
- public void setTransportName(String transportName) {
- this.transportName = transportName;
- }
- public URI getDiscoveryUri() {
- return discoveryUri;
- }
- public void setDiscoveryUri(URI discoveryUri) {
- this.discoveryUri = discoveryUri;
- }
- public URI getTransportUri() {
- return transportUri;
- }
- public void setTransportUri(URI transportUri) {
- this.transportUri = transportUri;
- }
+
}
Modified: geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/ConnectionManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/ConnectionManager.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/ConnectionManager.java (original)
+++ geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/ConnectionManager.java Tue Jan 2 14:40:30 2007
@@ -34,6 +34,26 @@
protected TransportService transport;
protected DiscoveryAgent discovery;
+
+ protected String userName;
+
+ protected String password;
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
public ConnectionManager(CacheInfoHolder info) {
super();
Modified: geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/TransportService.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/TransportService.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/TransportService.java (original)
+++ geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/TransportService.java Tue Jan 2 14:40:30 2007
@@ -22,7 +22,10 @@
public abstract class TransportService {
+
protected CacheInfoHolder info;
+ protected String userName;
+ protected String password;
public CacheInfoHolder getInfo() {
return info;
@@ -30,6 +33,22 @@
public void setInfo(CacheInfoHolder info) {
this.info = info;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
}
public abstract String getService() throws Exception;
Modified: geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPTransportService.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPTransportService.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPTransportService.java (original)
+++ geronimo/sandbox/gcache/common/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPTransportService.java Tue Jan 2 14:40:30 2007
@@ -31,16 +31,12 @@
public static final int DEFAULT_PORT = 4123;
public static final long DEFAULT_ACK_TIMEOUT = 10000;
- public final static String DEFAULT_USERNAME = "system";
- public final static String DEFAULT_PASSWORD = "manager";
protected URI tcpURI;
protected boolean requireMessageAck = false;
protected boolean enableLogging = false;
protected long ackTimeout = DEFAULT_ACK_TIMEOUT;
protected TCPSocketHandler handler = null;
- protected String userId = DEFAULT_USERNAME;
- protected String password = DEFAULT_PASSWORD;
public String getService() throws Exception{
if (tcpURI == null){
@@ -78,14 +74,6 @@
public void setPassword(String password) {
this.password = password;
- }
-
- public String getUserId() {
- return userId;
- }
-
- public void setUserId(String userId) {
- this.userId = userId;
}
public boolean isRequireMessageAck() {
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/GcacheServerConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/GcacheServerConfiguration.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/GcacheServerConfiguration.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/GcacheServerConfiguration.java Tue Jan 2 14:40:30 2007
@@ -18,19 +18,75 @@
*/
package org.apache.geronimo.gcache.dd;
-public class GcacheServerConfiguration extends GcacheConfiguration{
+import java.net.URI;
+
+public class GcacheServerConfiguration extends GcacheConfiguration {
private int order;
+
private String serverName;
-
+
+ private String transportName;
+
+ private String userName;
+
+ private String password;
+
+ private URI transportUri;
+
+ private URI discoveryUri;
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getTransportName() {
+ return transportName;
+ }
+
+ public void setTransportName(String transportName) {
+ this.transportName = transportName;
+ }
+
+ public URI getDiscoveryUri() {
+ return discoveryUri;
+ }
+
+ public void setDiscoveryUri(URI discoveryUri) {
+ this.discoveryUri = discoveryUri;
+ }
+
+ public URI getTransportUri() {
+ return transportUri;
+ }
+
+ public void setTransportUri(URI transportUri) {
+ this.transportUri = transportUri;
+ }
+
public int getOrder() {
return order;
}
+
public void setOrder(int order) {
this.order = order;
}
+
public String getServerName() {
return serverName;
}
+
public void setServerName(String serverName) {
this.serverName = serverName;
}
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ServerConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ServerConfigBuilder.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ServerConfigBuilder.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ServerConfigBuilder.java Tue Jan 2 14:40:30 2007
@@ -86,6 +86,8 @@
if (server != null){
gcacheConfig.setServerName(server.getServerName());
gcacheConfig.setOrder(server.getOrder());
+ gcacheConfig.setUserName(server.getUser());
+ gcacheConfig.setPassword(server.getPassword());
//Get the transport
TransportType transport = server.getTransport();
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheManager.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheManager.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheManager.java Tue Jan 2 14:40:30 2007
@@ -62,6 +62,8 @@
connectionManager.setDiscoveryURI(config.getDiscoveryUri());
connectionManager.setOrder(config.getOrder());
connectionManager.setNodeName(config.getServerName());
+ connectionManager.setUserName(config.getUserName());
+ connectionManager.setPassword(config.getPassword());
connectionManager.start();
}
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/ServerConnectionManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/ServerConnectionManager.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/ServerConnectionManager.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/ServerConnectionManager.java Tue Jan 2 14:40:30 2007
@@ -33,6 +33,8 @@
public void start() throws Exception {
transport = ServerTransportFactory.createTransportService(transportURI, info);
+ transport.setUserName(userName);
+ transport.setPassword(password);
if (discoveryURI != null) {
discovery = DiscoveryAgentFactory.createDiscoveryAgent(discoveryURI, info);
discovery.registerService(transport.getService());
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPServerSocketTransportService.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPServerSocketTransportService.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPServerSocketTransportService.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPServerSocketTransportService.java Tue Jan 2 14:40:30 2007
@@ -51,7 +51,7 @@
cfg.getFilterChain().addLast("protocolFilter", new ProtocolCodecFilter(new TCPCommandProtocolCodecFactory()));
//Add the authentication filter
- cfg.getFilterChain().addLast(TCPAuthenticationFilter.NAME, new TCPAuthenticationFilter(userId, password));
+ cfg.getFilterChain().addLast(TCPAuthenticationFilter.NAME, new TCPAuthenticationFilter(userName, password));
//Add the BulkCommandFilter for filtering when a BulkCommand is being read
cfg.getFilterChain().addLast(TCPBulkCommandFilter.NAME, new TCPBulkCommandFilter());
Modified: geronimo/sandbox/gcache/server/src/main/xsd/gcache-server.xsd
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/xsd/gcache-server.xsd?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/xsd/gcache-server.xsd (original)
+++ geronimo/sandbox/gcache/server/src/main/xsd/gcache-server.xsd Tue Jan 2 14:40:30 2007
@@ -45,5 +45,8 @@
</xs:restriction>
</xs:simpleType>
</xs:attribute>
+ <xs:attribute name="user" use="optional" type="xs:NCName" default="system"/>
+ <xs:attribute name="password" use="optional" type="xs:NCName" default="manager"/>
+
</xs:complexType>
</xs:schema>
Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/AbstractService.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/AbstractService.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/AbstractService.java (original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/AbstractService.java Tue Jan 2 14:40:30 2007
@@ -65,6 +65,8 @@
server.setAckTimeout(10000);
server.setRequireMessageAck(true);
server.setEnableLogging(true);
+ server.setUserName("system");
+ server.setPassword("manager");
server.start();
Modified: geronimo/sandbox/gcache/tests/src/test/java/org/apache/geronimo/gcache/AbstractParent.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/tests/src/test/java/org/apache/geronimo/gcache/AbstractParent.java?view=diff&rev=491952&r1=491951&r2=491952
==============================================================================
--- geronimo/sandbox/gcache/tests/src/test/java/org/apache/geronimo/gcache/AbstractParent.java (original)
+++ geronimo/sandbox/gcache/tests/src/test/java/org/apache/geronimo/gcache/AbstractParent.java Tue Jan 2 14:40:30 2007
@@ -7,6 +7,7 @@
import java.util.HashMap;
import java.util.Map;
+import org.apache.geronimo.gcache.client.GCacheClient;
import org.apache.geronimo.gcache.command.AuthCommand;
import org.apache.geronimo.gcache.command.BaseCommand;
import org.apache.geronimo.gcache.command.Command;
@@ -22,16 +23,26 @@
import org.testng.annotations.BeforeClass;
public class AbstractParent{
- GCacheManager mgr;
+ protected GCacheManager mgr;
+ protected GCacheClient client1;
+ protected GCacheClient client2;
@BeforeClass
public void setUp() throws Exception {
mgr = new GCacheManager(null);
mgr.start();
+
+ client1 = new GCacheClient(null);
+ client1.start();
+
+ client2 = new GCacheClient(null);
+ client2.start();
}
@AfterClass(alwaysRun = true)
public void shutdown() throws Exception {
+ client2.stop();
+ client1.stop();
mgr.stop();
}