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 2006/11/02 19:36:45 UTC
svn commit: r470466 - in /geronimo/sandbox/gcache/server: ./
src/main/java/org/apache/geronimo/gcache/command/
src/main/java/org/apache/geronimo/gcache/dd/
src/main/java/org/apache/geronimo/gcache/marshal/
src/main/java/org/apache/geronimo/gcache/trans...
Author: jgenender
Date: Thu Nov 2 10:36:40 2006
New Revision: 470466
URL: http://svn.apache.org/viewvc?view=rev&rev=470466
Log:
Put in configuration with JAXB
Added:
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ConfigBuilder.java (with props)
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/GcacheConfiguration.java (with props)
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/JaxbGcacheConfigFactory.java (with props)
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/TransportFactory.java (with props)
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportServiceFactory.java (with props)
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/StringUtil.java (with props)
geronimo/sandbox/gcache/server/src/main/resources/META-INF/services/org/apache/geronimo/gcache/transport/tcp
geronimo/sandbox/gcache/server/src/main/resources/gcache-config-default.xml (with props)
geronimo/sandbox/gcache/server/src/main/xjb/
geronimo/sandbox/gcache/server/src/main/xjb/bindings.xjb
geronimo/sandbox/gcache/server/src/main/xsd/
geronimo/sandbox/gcache/server/src/main/xsd/gcache.xsd (with props)
geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/dd/
geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/dd/ConfigBuilderTest.java (with props)
geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/util/StringUtilTest.java (with props)
geronimo/sandbox/gcache/server/src/test/resources/gcache-config.xml (with props)
Modified:
geronimo/sandbox/gcache/server/pom.xml
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BulkSendCommand.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CacheBaseCommand.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommand.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/DiscoveryCommand.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/PutSessionCommand.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/marshal/MarshalAware.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/TransportService.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/discovery/DiscoveryAgent.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/discovery/multicast/MulticastDiscoveryAgent.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPAuthenticationFilter.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPCacheNotifier.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportService.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/IntrospectionSupport.java
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/URISupport.java
geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/BulkSendCommandTest.java
geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CacheBaseCommandTest.java
geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/AbstractService.java
geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TCPEndpointTest.java
geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TCPNotificationTest.java
Modified: geronimo/sandbox/gcache/server/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/pom.xml?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/pom.xml (original)
+++ geronimo/sandbox/gcache/server/pom.xml Thu Nov 2 10:36:40 2006
@@ -22,11 +22,21 @@
</dependency>
<dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
@@ -61,6 +71,14 @@
</dependencies>
<build>
<plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxb2-maven-plugin</artifactId>
+ <configuration>
+ <packageName>org.apache.geronimo.gcache.dd</packageName>
+ <extension>true</extension>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BulkSendCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BulkSendCommand.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BulkSendCommand.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BulkSendCommand.java Thu Nov 2 10:36:40 2006
@@ -19,7 +19,6 @@
package org.apache.geronimo.gcache.command;
import java.io.IOException;
-import java.nio.channels.WritableByteChannel;
import org.apache.geronimo.gcache.transports.CommandVisitor;
import org.apache.mina.common.ByteBuffer;
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CacheBaseCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CacheBaseCommand.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CacheBaseCommand.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CacheBaseCommand.java Thu Nov 2 10:36:40 2006
@@ -18,12 +18,10 @@
*/
package org.apache.geronimo.gcache.command;
+import java.io.IOException;
+
import org.apache.geronimo.gcache.util.ByteArray;
import org.apache.mina.common.ByteBuffer;
-
-import java.io.IOException;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.WritableByteChannel;
public class CacheBaseCommand extends BaseCommand {
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommand.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommand.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommand.java Thu Nov 2 10:36:40 2006
@@ -19,8 +19,6 @@
package org.apache.geronimo.gcache.command;
import java.io.IOException;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.WritableByteChannel;
import org.apache.mina.common.ByteBuffer;
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/DiscoveryCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/DiscoveryCommand.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/DiscoveryCommand.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/DiscoveryCommand.java Thu Nov 2 10:36:40 2006
@@ -17,8 +17,6 @@
*/
package org.apache.geronimo.gcache.command;
-import java.io.IOException;
-
import org.apache.mina.common.ByteBuffer;
public class DiscoveryCommand extends BaseCommand {
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/PutSessionCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/PutSessionCommand.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/PutSessionCommand.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/PutSessionCommand.java Thu Nov 2 10:36:40 2006
@@ -20,7 +20,6 @@
import java.io.IOException;
import java.nio.channels.Channels;
-import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.util.Collections;
import java.util.HashMap;
@@ -29,7 +28,6 @@
import org.apache.geronimo.gcache.transports.CommandVisitor;
import org.apache.geronimo.gcache.util.ByteArray;
-import org.apache.geronimo.gcache.util.ByteArrayInputStream;
import org.apache.geronimo.gcache.util.ByteArrayOutputStream;
import org.apache.mina.common.ByteBuffer;
Added: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ConfigBuilder.java?view=auto&rev=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ConfigBuilder.java (added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ConfigBuilder.java Thu Nov 2 10:36:40 2006
@@ -0,0 +1,155 @@
+/**
+ *
+ * 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.dd;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+
+import net.sf.ehcache.config.CacheConfiguration;
+import net.sf.ehcache.config.Configuration;
+import net.sf.ehcache.config.DiskStoreConfiguration;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gcache.util.StringUtil;
+
+public class ConfigBuilder {
+ private static final Log log = LogFactory.getLog(ConfigBuilder.class);
+
+ private static final String CLASSPATH_CONFIGURATION_FILE = "gcache-config.xml";
+ private static final String DEFAULT_CLASSPATH_CONFIGURATION_FILE = "gcache-config-default.xml";
+
+ public GcacheConfiguration getConfig(URL fileURL){
+
+ GcacheConfiguration config = null;
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+ //Was a file passed to us?
+ if (fileURL != null){
+ config = processConfig(fileURL);
+ return config;
+ }
+
+ //Is the configuration file in the path somewhere?
+ URL configURL = cl.getResource(CLASSPATH_CONFIGURATION_FILE);
+ if (configURL != null){
+ config = processConfig(configURL);
+
+ return config;
+ }
+
+ //Read the default config
+ log.warn("Using " + DEFAULT_CLASSPATH_CONFIGURATION_FILE + " for configuration. No cache configurations are loaded. Please consider having your own.");
+
+ configURL = cl.getResource(DEFAULT_CLASSPATH_CONFIGURATION_FILE);
+ if (configURL == null){
+ throw new RuntimeException(DEFAULT_CLASSPATH_CONFIGURATION_FILE + " not found, not configuration can be loaded.");
+ }
+ config = processConfig(configURL);
+ return config;
+ }
+
+ private GcacheConfiguration processConfig(URL url){
+ try {
+ GcacheConfiguration gcacheConfig = new GcacheConfiguration();
+ Configuration ehcacheConfig = new Configuration();
+ DiskStoreConfiguration diskConfig = null;
+ CacheConfiguration defaultCache = null;
+
+ GcacheConfig config = JaxbGcacheConfigFactory.getConfig(url);
+
+ // Get the server info
+ ServerType server = config.getServer();
+ if (server != null){
+ gcacheConfig.setServerName(server.getServerName());
+ gcacheConfig.setOrder(server.getOrder());
+
+ //Get the transport
+ TransportType transport = server.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);
+ }
+ }
+ }
+
+ //Read the disk store
+ DiskStoreType diskStore = config.getDiskStore();
+ if (diskStore != null) {
+ String path = diskStore.getPath();
+ diskConfig = new DiskStoreConfiguration();
+ diskConfig.setPath(StringUtil
+ .parseAndReplaceSystemProperty(path));
+ }
+
+ //Read the default cache
+ DefaultCacheType defaultType = config.getDefaultCache();
+ if (defaultType != null) {
+ defaultCache = new CacheConfiguration();
+ defaultCache.setDiskExpiryThreadIntervalSeconds(defaultType
+ .getDiskExpiryThreadIntervalSeconds());
+ defaultCache.setMaxElementsInMemory(defaultType
+ .getMaxElementsInMemory());
+ defaultCache.setEternal(defaultType.isEternal());
+ defaultCache.setDiskPersistent(defaultType.isDiskPersistent());
+ defaultCache.setOverflowToDisk(defaultType.isOverflowToDisk());
+ defaultCache.setTimeToIdleSeconds(defaultType
+ .getTimeToIdleSeconds());
+ defaultCache.setTimeToLiveSeconds(defaultType
+ .getTimeToLiveSeconds());
+ defaultCache.setMemoryStoreEvictionPolicy(defaultType.getMemoryStoreEvictionPolicy());
+ }
+
+ ehcacheConfig.setDefaultCacheConfiguration(defaultCache);
+ ehcacheConfig.addDiskStore(diskConfig);
+
+ //Read the cache list
+ List<CacheType> cacheList = config.getCaches();
+ for (CacheType cacheType : cacheList) {
+ CacheConfiguration cache = new CacheConfiguration();
+ cache.setName(cacheType.getName());
+ cache.setDiskExpiryThreadIntervalSeconds(cacheType.getDiskExpiryThreadIntervalSeconds());
+ cache.setMaxElementsInMemory(cacheType.getMaxElementsInMemory());
+ cache.setEternal(cacheType.isEternal());
+ cache.setDiskPersistent(cacheType.isDiskPersistent());
+ cache.setOverflowToDisk(cacheType.isOverflowToDisk());
+ cache.setTimeToIdleSeconds(cacheType.getTimeToIdleSeconds());
+ cache.setTimeToLiveSeconds(cacheType.getTimeToLiveSeconds());
+ cache.setMemoryStoreEvictionPolicy(cacheType.getMemoryStoreEvictionPolicy());
+
+ ehcacheConfig.addCache(cache);
+ }
+
+ gcacheConfig.setEhcacheConfig(ehcacheConfig);
+
+ return gcacheConfig;
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ConfigBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ConfigBuilder.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ConfigBuilder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/GcacheConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/GcacheConfiguration.java?view=auto&rev=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/GcacheConfiguration.java (added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/GcacheConfiguration.java Thu Nov 2 10:36:40 2006
@@ -0,0 +1,68 @@
+/**
+ *
+ * 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.dd;
+
+import java.net.URI;
+
+import net.sf.ehcache.config.Configuration;
+
+public class GcacheConfiguration {
+ private Configuration ehcacheConfig = null;
+ private int order;
+ private String serverName;
+ private String transportName;
+ private URI transportUri;
+ private URI discoveryUri;
+
+ public Configuration getEhcacheConfig() {
+ return ehcacheConfig;
+ }
+ public void setEhcacheConfig(Configuration ehcacheConfig) {
+ this.ehcacheConfig = ehcacheConfig;
+ }
+ 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;
+ }
+ 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;
+ }
+}
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/GcacheConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/GcacheConfiguration.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/GcacheConfiguration.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/JaxbGcacheConfigFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/JaxbGcacheConfigFactory.java?view=auto&rev=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/JaxbGcacheConfigFactory.java (added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/JaxbGcacheConfigFactory.java Thu Nov 2 10:36:40 2006
@@ -0,0 +1,89 @@
+/**
+ *
+ * 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.dd;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.UnmarshallerHandler;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.sax.SAXSource;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+public class JaxbGcacheConfigFactory {
+
+ public static final String SCHEMA = "http://geronimo.apache.org/xml/ns/gcache-1.0";
+
+ public static GcacheConfig getConfig(URL url) throws Exception{
+ InputStream gcacheDescriptor = null;
+
+ try {
+
+ gcacheDescriptor = url.openStream();
+
+ JAXBContext jc = JAXBContext.newInstance(GcacheConfig.class);
+ Unmarshaller u = jc.createUnmarshaller();
+ UnmarshallerHandler uh = u.getUnmarshallerHandler();
+
+ // create a new XML parser
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(true);
+ factory.setValidating(true);
+ SAXParser parser = factory.newSAXParser();
+
+ XMLReader xmlReader = parser.getXMLReader();
+
+ // Create a filter to intercept events
+ NamespaceFilter xmlFilter = new NamespaceFilter(xmlReader);
+
+ // Be sure the filter has the JAXB content handler set (or it wont
+ // work)
+ xmlFilter.setContentHandler(uh);
+ SAXSource source = new SAXSource(xmlFilter, new InputSource(
+ gcacheDescriptor));
+
+ return (GcacheConfig) u.unmarshal(source);
+
+ } finally {
+ if (gcacheDescriptor != null)
+ gcacheDescriptor.close();
+ }
+ }
+
+ // Inject the proper namespace
+ public static class NamespaceFilter extends XMLFilterImpl {
+
+ public NamespaceFilter(XMLReader arg0) {
+ super(arg0);
+ }
+
+ @Override
+ public void startElement(String arg0, String arg1, String arg2,
+ Attributes arg3) throws SAXException {
+ super.startElement(SCHEMA, arg1, arg2, arg3);
+ }
+ }
+}
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/JaxbGcacheConfigFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/JaxbGcacheConfigFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/JaxbGcacheConfigFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/marshal/MarshalAware.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/marshal/MarshalAware.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/marshal/MarshalAware.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/marshal/MarshalAware.java Thu Nov 2 10:36:40 2006
@@ -18,9 +18,6 @@
*/
package org.apache.geronimo.gcache.marshal;
-import java.io.IOException;
-import java.nio.channels.WritableByteChannel;
-
import org.apache.mina.common.ByteBuffer;
/**
Added: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/TransportFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/TransportFactory.java?view=auto&rev=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/TransportFactory.java (added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/TransportFactory.java Thu Nov 2 10:36:40 2006
@@ -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 org.apache.geronimo.gcache.CacheInfoHolder;
+import org.apache.geronimo.gcache.util.FactoryFinder;
+import org.apache.geronimo.gcache.util.IOExceptionSupport;
+
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+
+public abstract class TransportFactory {
+
+ static final private FactoryFinder transportFactoryFinder = new FactoryFinder("META-INF/services/org/apache/geronimo/gcache/transport/");
+ static final private ConcurrentHashMap transportFactorys = new ConcurrentHashMap();
+
+ /**
+ * @param location
+ * @return
+ * @throws IOException
+ */
+ private static TransportFactory findTransportFactory(URI location) throws IOException {
+ String scheme = location.getScheme();
+ if( scheme == null )
+ throw new IOException("Transport not scheme specified: [" + location + "]");
+ TransportFactory tf = (TransportFactory) transportFactorys.get(scheme);
+ if (tf == null) {
+ // Try to load if from a META-INF property.
+ try {
+ tf = (TransportFactory) 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 {
+ TransportFactory tf = findTransportFactory(uri);
+ return tf.doCreateTransportService(uri, info);
+
+ }
+
+ abstract protected TransportService doCreateTransportService(URI uri, CacheInfoHolder info) throws IOException;
+
+}
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/TransportFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/TransportFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/TransportFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/TransportService.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/TransportService.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/TransportService.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/TransportService.java Thu Nov 2 10:36:40 2006
@@ -18,9 +18,20 @@
*/
package org.apache.geronimo.gcache.transports;
+import org.apache.geronimo.gcache.CacheInfoHolder;
-public interface TransportService {
- public void start() throws Exception;
- public void stop() throws Exception;
+public abstract class TransportService {
+ protected CacheInfoHolder info;
+
+ public CacheInfoHolder getInfo() {
+ return info;
+ }
+
+ public void setInfo(CacheInfoHolder info) {
+ this.info = info;
+ }
+
+ public abstract void start() throws Exception;
+ public abstract void stop() throws Exception;
}
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/discovery/DiscoveryAgent.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/discovery/DiscoveryAgent.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/discovery/DiscoveryAgent.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/discovery/DiscoveryAgent.java Thu Nov 2 10:36:40 2006
@@ -22,12 +22,12 @@
import org.apache.geronimo.gcache.command.DiscoveryCommand;
import org.apache.geronimo.gcache.transports.TransportService;
-public interface DiscoveryAgent extends TransportService {
+public abstract class DiscoveryAgent extends TransportService {
/**
* Sets the discovery listener
* @param listener
*/
- public void setDiscoveryListener(DiscoveryListener listener);
+ public abstract void setDiscoveryListener(DiscoveryListener listener);
/**
* register a service
@@ -35,12 +35,12 @@
* @param details
* @throws IOException
*/
- void registerService(String name) throws IOException;
+ public abstract void registerService(String name) throws IOException;
/**
* A process actively using a service may see it go down before the DiscoveryAgent notices the
* service's failure. That process can use this method to notify the DiscoveryAgent of the failure
* so that other listeners of this DiscoveryAgent can also be made aware of the failure.
*/
- void serviceFailed(DiscoveryCommand command) throws IOException;
+ public abstract void serviceFailed(DiscoveryCommand command) throws IOException;
}
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/discovery/multicast/MulticastDiscoveryAgent.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/discovery/multicast/MulticastDiscoveryAgent.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/discovery/multicast/MulticastDiscoveryAgent.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/discovery/multicast/MulticastDiscoveryAgent.java Thu Nov 2 10:36:40 2006
@@ -43,7 +43,7 @@
import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong;
-public class MulticastDiscoveryAgent implements DiscoveryAgent, Runnable {
+public class MulticastDiscoveryAgent extends DiscoveryAgent implements Runnable {
Log log = LogFactory.getLog(MulticastDiscoveryAgent.class);
@@ -308,6 +308,7 @@
}
}
+ @SuppressWarnings("unchecked")
private void processAlive(String nodeName, String service) {
if (selfService == null || !service.equals(selfService)) {
AtomicLong lastKeepAlive = (AtomicLong) services.get(service);
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPAuthenticationFilter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPAuthenticationFilter.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPAuthenticationFilter.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPAuthenticationFilter.java Thu Nov 2 10:36:40 2006
@@ -51,10 +51,12 @@
@Override
public void sessionOpened(NextFilter nextFilter, IoSession sess)
throws Exception {
+
//Start up the response timeout
ScheduledFuture task = ((TCPSocketHandler) sess.getHandler()).schedule(
new TimeoutTask(sess), 5000);
sess.setAttribute(Constants.AUTH_TASK, task);
+
nextFilter.sessionCreated(sess);
}
@@ -90,7 +92,6 @@
}
//Consume the message (don't pass it on)
- nextFilter.messageReceived(sess, obj);
}
private void handleAuth(IoSession sess, Object obj) throws Exception {
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPCacheNotifier.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPCacheNotifier.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPCacheNotifier.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPCacheNotifier.java Thu Nov 2 10:36:40 2006
@@ -17,7 +17,6 @@
*/
package org.apache.geronimo.gcache.transports.tcp;
-import java.io.IOException;
import java.util.Set;
import org.apache.commons.logging.Log;
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportService.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportService.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportService.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportService.java Thu Nov 2 10:36:40 2006
@@ -21,16 +21,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.gcache.CacheInfoHolder;
import org.apache.geronimo.gcache.transports.TransportService;
import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.ThreadModel;
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;
-public class TCPSocketTransportService implements TransportService {
+public class TCPSocketTransportService extends TransportService {
private final static Log log = LogFactory.getLog(TCPSocketTransportService.class);
@@ -39,8 +37,7 @@
public final static String DEFAULT_PASSWORD = "manager";
IoAcceptor acceptor = null;
- private CacheInfoHolder info;
- private String uriString;
+ private URI tcpURI;
private boolean requireMessageAck = false;
private boolean enableLogging = false;
private long ackTimeout = DEFAULT_ACK_TIMEOUT;
@@ -48,9 +45,12 @@
private String userId = DEFAULT_USERNAME;
private String password = DEFAULT_PASSWORD;
- public TCPSocketTransportService(String uriString, CacheInfoHolder info) {
- this.info = info;
- this.uriString = uriString;
+ public URI getTcpURI() {
+ return tcpURI;
+ }
+
+ public void setTcpURI(URI tcpURI) {
+ this.tcpURI = tcpURI;
}
public String getPassword() {
@@ -94,11 +94,8 @@
}
public void start() throws Exception {
- URI uri = new URI(uriString);
- int port = uri.getPort();
- String host = uri.getHost();
- if (!uri.getScheme().equals("tcp"))
- throw new Exception("Illegal scheme, must be 'tcp'");
+ int port = tcpURI.getPort();
+ String host = tcpURI.getHost();
InetSocketAddress inet = new InetSocketAddress(host, port);
Added: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportServiceFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportServiceFactory.java?view=auto&rev=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportServiceFactory.java (added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportServiceFactory.java Thu Nov 2 10:36:40 2006
@@ -0,0 +1,50 @@
+/**
+ *
+ * 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.TransportFactory;
+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 TCPSocketTransportServiceFactory extends TransportFactory {
+
+ @Override
+ protected TransportService doCreateTransportService(URI uri, CacheInfoHolder info)
+ throws IOException {
+ try {
+
+ Map options = URISupport.parseParamters(uri);
+ TCPSocketTransportService rc = new TCPSocketTransportService();
+ rc.setInfo(info);
+ rc.setTcpURI(uri);
+ IntrospectionSupport.setProperties(rc, options);
+ return rc;
+
+ } catch (Throwable e) {
+ throw IOExceptionSupport.create("Could not create discovery agent: " + uri, e);
+ }
+ }
+
+}
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportServiceFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportServiceFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportServiceFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/IntrospectionSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/IntrospectionSupport.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/IntrospectionSupport.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/IntrospectionSupport.java Thu Nov 2 10:36:40 2006
@@ -33,17 +33,19 @@
import java.util.Map.Entry;
public class IntrospectionSupport {
- static public boolean getProperties(Object target, Map props, String optionPrefix) {
-
+
+ static public boolean getProperties(Object target, Map<String, String> props,
+ String optionPrefix) {
+
boolean rc = false;
- if( target == null )
+ if (target == null)
throw new IllegalArgumentException("target was null.");
- if( props == null )
+ if (props == null)
throw new IllegalArgumentException("props was null.");
-
- if( optionPrefix == null )
- optionPrefix="";
-
+
+ if (optionPrefix == null)
+ optionPrefix = "";
+
Class clazz = target.getClass();
Method[] methods = clazz.getMethods();
for (int i = 0; i < methods.length; i++) {
@@ -51,47 +53,47 @@
String name = method.getName();
Class type = method.getReturnType();
Class params[] = method.getParameterTypes();
- if( name.startsWith("get") && params.length==0 &&
- type!=null && isSettableType(type)) {
+ if (name.startsWith("get") && params.length == 0 && type != null
+ && isSettableType(type)) {
- try {
-
- Object value = method.invoke(target, new Object[]{});
- if( value == null )
- continue;
-
- String strValue = convertToString(value, type);
- if( strValue ==null )
- continue;
-
- name = name.substring(3,4).toLowerCase()+name.substring(4);
- props.put(optionPrefix+name, strValue);
+ try {
+
+ Object value = method.invoke(target, new Object[] {});
+ if (value == null)
+ continue;
+
+ String strValue = convertToString(value, type);
+ if (strValue == null)
+ continue;
+
+ name = name.substring(3, 4).toLowerCase()
+ + name.substring(4);
+ props.put(optionPrefix + name, strValue);
rc = true;
-
- } catch ( Throwable ignore) {
- }
-
+
+ } catch (Throwable ignore) {
+ }
+
}
}
-
+
return rc;
}
-
-
-
- static public boolean setProperties(Object target, Map props, String optionPrefix) {
+
+ static public boolean setProperties(Object target, Map props,
+ String optionPrefix) {
boolean rc = false;
- if( target == null )
+ if (target == null)
throw new IllegalArgumentException("target was null.");
- if( props == null )
+ if (props == null)
throw new IllegalArgumentException("props was null.");
-
+
for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
String name = (String) iter.next();
- if( name.startsWith(optionPrefix) ) {
+ if (name.startsWith(optionPrefix)) {
Object value = props.get(name);
name = name.substring(optionPrefix.length());
- if( setProperty(target, name, value) ) {
+ if (setProperty(target, name, value)) {
iter.remove();
rc = true;
}
@@ -99,42 +101,42 @@
}
return rc;
}
-
+
public static Map extractProperties(Map props, String optionPrefix) {
- if( props == null )
+ if (props == null)
throw new IllegalArgumentException("props was null.");
- HashMap rc = new HashMap(props.size());
-
+ HashMap<String, Object> rc = new HashMap<String, Object>(props.size());
+
for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
String name = (String) iter.next();
- if( name.startsWith(optionPrefix) ) {
+ if (name.startsWith(optionPrefix)) {
Object value = props.get(name);
name = name.substring(optionPrefix.length());
rc.put(name, value);
iter.remove();
}
}
-
+
return rc;
}
-
+
public static boolean setProperties(Object target, Map props) {
- boolean rc = false;
-
- if( target == null )
+ boolean rc = false;
+
+ if (target == null)
throw new IllegalArgumentException("target was null.");
- if( props == null )
+ if (props == null)
throw new IllegalArgumentException("props was null.");
-
+
for (Iterator iter = props.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Entry) iter.next();
- if( setProperty(target, (String) entry.getKey(), entry.getValue()) ) {
+ if (setProperty(target, (String) entry.getKey(), entry.getValue())) {
iter.remove();
- rc=true;
+ rc = true;
}
}
-
+
return rc;
}
@@ -142,15 +144,18 @@
try {
Class clazz = target.getClass();
Method setter = findSetterMethod(clazz, name);
- if( setter == null )
+ if (setter == null)
return false;
-
- // If the type is null or it matches the needed type, just use the value directly
- if( value == null || value.getClass()==setter.getParameterTypes()[0] ) {
- setter.invoke(target, new Object[]{value});
+
+ // If the type is null or it matches the needed type, just use the
+ // value directly
+ if (value == null
+ || value.getClass() == setter.getParameterTypes()[0]) {
+ setter.invoke(target, new Object[] { value });
} else {
// We need to convert it
- setter.invoke(target, new Object[]{ convert(value, setter.getParameterTypes()[0]) });
+ setter.invoke(target, new Object[] { convert(value, setter
+ .getParameterTypes()[0]) });
}
return true;
} catch (Throwable ignore) {
@@ -158,39 +163,40 @@
}
}
- private static Object convert(Object value, Class type) throws URISyntaxException {
+ private static Object convert(Object value, Class type)
+ throws URISyntaxException {
PropertyEditor editor = PropertyEditorManager.findEditor(type);
- if( editor != null ) {
+ if (editor != null) {
editor.setAsText(value.toString());
return editor.getValue();
}
- if( type == URI.class ) {
+ if (type == URI.class) {
return new URI(value.toString());
}
return null;
}
- private static String convertToString(Object value, Class type) throws URISyntaxException {
+ private static String convertToString(Object value, Class type)
+ throws URISyntaxException {
PropertyEditor editor = PropertyEditorManager.findEditor(type);
- if( editor != null ) {
+ if (editor != null) {
editor.setValue(value);
return editor.getAsText();
}
- if( type == URI.class ) {
- return ((URI)value).toString();
+ if (type == URI.class) {
+ return ((URI) value).toString();
}
return null;
}
private static Method findSetterMethod(Class clazz, String name) {
// Build the method name.
- name = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+ name = "set" + name.substring(0, 1).toUpperCase() + name.substring(1);
Method[] methods = clazz.getMethods();
for (int i = 0; i < methods.length; i++) {
Method method = methods[i];
Class params[] = method.getParameterTypes();
- if( method.getName().equals(name)
- && params.length==1
+ if (method.getName().equals(name) && params.length == 1
&& isSettableType(params[0])) {
return method;
}
@@ -199,11 +205,11 @@
}
private static boolean isSettableType(Class clazz) {
- if( PropertyEditorManager.findEditor(clazz)!=null )
+ if (PropertyEditorManager.findEditor(clazz) != null)
return true;
- if( clazz == URI.class )
+ if (clazz == URI.class)
return true;
- if( clazz == Boolean.class )
+ if (clazz == Boolean.class)
return true;
return false;
}
@@ -213,7 +219,7 @@
}
static public String toString(Object target, Class stopClass) {
- LinkedHashMap map = new LinkedHashMap();
+ LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
addFields(target, target.getClass(), stopClass, map);
StringBuffer buffer = new StringBuffer(simpleName(target.getClass()));
buffer.append(" {");
@@ -223,8 +229,7 @@
Map.Entry entry = (Map.Entry) iter.next();
if (first) {
first = false;
- }
- else {
+ } else {
buffer.append(", ");
}
buffer.append(entry.getKey());
@@ -236,37 +241,37 @@
}
protected static void appendToString(StringBuffer buffer, Object value) {
- buffer.append(value);
+ buffer.append(value);
}
static public String simpleName(Class clazz) {
String name = clazz.getName();
int p = name.lastIndexOf(".");
- if( p >= 0 ) {
- name = name.substring(p+1);
+ if (p >= 0) {
+ name = name.substring(p + 1);
}
return name;
}
-
- static private void addFields(Object target, Class startClass, Class stopClass, LinkedHashMap map) {
-
- if( startClass!=stopClass )
- addFields( target, startClass.getSuperclass(), stopClass, map );
-
+ static private void addFields(Object target, Class startClass,
+ Class stopClass, LinkedHashMap<String, Object> map) {
+
+ if (startClass != stopClass)
+ addFields(target, startClass.getSuperclass(), stopClass, map);
+
Field[] fields = startClass.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
- if( Modifier.isStatic(field.getModifiers()) ||
- Modifier.isTransient(field.getModifiers()) ||
- Modifier.isPrivate(field.getModifiers()) ) {
+ if (Modifier.isStatic(field.getModifiers())
+ || Modifier.isTransient(field.getModifiers())
+ || Modifier.isPrivate(field.getModifiers())) {
continue;
}
-
+
try {
field.setAccessible(true);
Object o = field.get(target);
- if( o!=null && o.getClass().isArray() ) {
+ if (o != null && o.getClass().isArray()) {
try {
o = Arrays.asList((Object[]) o);
} catch (Throwable e) {
@@ -277,6 +282,6 @@
e.printStackTrace();
}
}
-
+
}
}
Added: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/StringUtil.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/StringUtil.java?view=auto&rev=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/StringUtil.java (added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/StringUtil.java Thu Nov 2 10:36:40 2006
@@ -0,0 +1,48 @@
+/**
+ *
+ * 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.util;
+
+public class StringUtil {
+
+ private static final String DEFAULT_PLACEHOLDER_PREFIX = "${";
+ private static final String DEFAULT_PLACEHOLDER_SUFFIX = "}";
+
+ public static String parseAndReplaceSystemProperty(String str) {
+ StringBuffer buf = new StringBuffer(str);
+
+ int start = buf.indexOf(DEFAULT_PLACEHOLDER_PREFIX);
+ while (start != -1) {
+ int end = buf.toString().indexOf(DEFAULT_PLACEHOLDER_SUFFIX, start + DEFAULT_PLACEHOLDER_PREFIX.length());
+ if (end != -1) {
+ String prop = buf.substring(start + DEFAULT_PLACEHOLDER_PREFIX.length(), end);
+ String propVal = System.getProperty(prop);
+ if (propVal != null){
+ buf.replace(start, end + DEFAULT_PLACEHOLDER_SUFFIX.length(), propVal);
+
+ //Search for another one
+ start = buf.indexOf(DEFAULT_PLACEHOLDER_PREFIX);
+ }
+ } else {
+ start = -1;
+ }
+ }
+
+ return buf.toString();
+ }
+
+}
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/StringUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/StringUtil.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/StringUtil.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/URISupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/URISupport.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/URISupport.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/URISupport.java Thu Nov 2 10:36:40 2006
@@ -28,8 +28,6 @@
import java.util.Iterator;
import java.util.Map;
-import org.apache.geronimo.openwire.util.URISupport.CompositeData;
-
public class URISupport {
public static class CompositeData {
String scheme;
@@ -95,7 +93,7 @@
public static Map parseQuery(String uri) throws URISyntaxException{
try{
- Map rc=new HashMap();
+ Map<String, String> rc=new HashMap<String,String>();
if(uri!=null){
String[] parameters=uri.split("&");
for(int i=0;i<parameters.length;i++){
@@ -191,7 +189,7 @@
}
private static String[] splitComponents(String str) {
- ArrayList l = new ArrayList();
+ ArrayList<String> l = new ArrayList<String>();
int last=0;
int depth = 0;
Added: geronimo/sandbox/gcache/server/src/main/resources/META-INF/services/org/apache/geronimo/gcache/transport/tcp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/resources/META-INF/services/org/apache/geronimo/gcache/transport/tcp?view=auto&rev=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/resources/META-INF/services/org/apache/geronimo/gcache/transport/tcp (added)
+++ geronimo/sandbox/gcache/server/src/main/resources/META-INF/services/org/apache/geronimo/gcache/transport/tcp Thu Nov 2 10:36:40 2006
@@ -0,0 +1 @@
+class=org.apache.geronimo.gcache.transports.tcp.TCPSocketTransportServiceFactory
\ No newline at end of file
Added: geronimo/sandbox/gcache/server/src/main/resources/gcache-config-default.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/resources/gcache-config-default.xml?view=auto&rev=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/resources/gcache-config-default.xml (added)
+++ geronimo/sandbox/gcache/server/src/main/resources/gcache-config-default.xml Thu Nov 2 10:36:40 2006
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gcache-config>
+ <server order="1" serverName="gcache">
+ <transport name="default" uri="tcp://default" discoveryUri="multicast://default" />
+ </server>
+ <diskStore path="${java.io.tmpdir}/gcache" />
+ <defaultCache maxElementsInMemory="10000" eternal="false"
+ timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true"
+ diskPersistent="false" diskExpiryThreadIntervalSeconds="120"
+ memoryStoreEvictionPolicy="LRU" />
+</gcache-config>
Propchange: geronimo/sandbox/gcache/server/src/main/resources/gcache-config-default.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/main/resources/gcache-config-default.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/main/resources/gcache-config-default.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/sandbox/gcache/server/src/main/xjb/bindings.xjb
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/xjb/bindings.xjb?view=auto&rev=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/xjb/bindings.xjb (added)
+++ geronimo/sandbox/gcache/server/src/main/xjb/bindings.xjb Thu Nov 2 10:36:40 2006
@@ -0,0 +1,37 @@
+<jxb:bindings version="1.0"
+ xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
+ xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ jxb:extensionBindingPrefixes="xjc">
+ <jxb:bindings schemaLocation="../xsd/gcache.xsd" node="/xs:schema">
+ <jxb:globalBindings>
+ <xjc:simple />
+ </jxb:globalBindings>
+
+ <jxb:bindings node="//xs:complexType[@name='defaultCacheType']">
+ <jxb:bindings node=".//xs:attribute[@name='memoryStoreEvictionPolicy']">
+ <jxb:property>
+ <jxb:baseType>
+ <jxb:javaType name="String"
+ parseMethod="javax.xml.bind.DatatypeConverter.parseString"
+ printMethod="javax.xml.bind.DatatypeConverter.printString"/>
+ </jxb:baseType>
+ </jxb:property>
+ </jxb:bindings>
+ </jxb:bindings>
+
+ <jxb:bindings node="//xs:complexType[@name='cacheType']">
+ <jxb:bindings node=".//xs:attribute[@name='memoryStoreEvictionPolicy']">
+ <jxb:property>
+ <jxb:baseType>
+ <jxb:javaType name="String"
+ parseMethod="javax.xml.bind.DatatypeConverter.parseString"
+ printMethod="javax.xml.bind.DatatypeConverter.printString"/>
+ </jxb:baseType>
+ </jxb:property>
+ </jxb:bindings>
+ </jxb:bindings>
+
+ </jxb:bindings>
+
+</jxb:bindings>
Added: geronimo/sandbox/gcache/server/src/main/xsd/gcache.xsd
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/xsd/gcache.xsd?view=auto&rev=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/xsd/gcache.xsd (added)
+++ geronimo/sandbox/gcache/server/src/main/xsd/gcache.xsd Thu Nov 2 10:36:40 2006
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:gcache="http://geronimo.apache.org/xml/ns/gcache-1.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://geronimo.apache.org/xml/ns/gcache-1.0"
+ version="1.0" attributeFormDefault="unqualified"
+ elementFormDefault="qualified">
+ <xs:element name="gcache-config" type="gcache:gcacheConfigType" />
+ <xs:complexType name="gcacheConfigType">
+ <xs:sequence>
+ <xs:element name="server" type="gcache:serverType"
+ minOccurs="1" maxOccurs="1" />
+ <xs:element name="diskStore" type="gcache:diskStoreType"
+ minOccurs="1" maxOccurs="1" />
+ <xs:element name="defaultCache"
+ type="gcache:defaultCacheType" minOccurs="1" maxOccurs="1" />
+ <xs:element name="cache" type="gcache:cacheType"
+ minOccurs="0" maxOccurs="unbounded" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="serverType">
+ <xs:sequence>
+ <xs:element name="transport" type="gcache:transportType" />
+ </xs:sequence>
+ <xs:attribute name="serverName" use="required" type="xs:NCName" />
+ <xs:attribute name="order" use="required">
+ <xs:simpleType>
+ <xs:restriction base="xs:int">
+ <xs:minInclusive value="1" />
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:complexType>
+ <xs:complexType name="transportType">
+ <xs:attribute name="name" use="required" type="xs:NCName" />
+ <xs:attribute name="uri" use="required" type="xs:NCName" />
+ <xs:attribute name="discoveryUri" use="optional"
+ type="xs:NCName" />
+ </xs:complexType>
+ <xs:complexType name="diskStoreType">
+ <xs:attribute name="path" use="required" type="xs:NCName" />
+ </xs:complexType>
+ <xs:complexType name="defaultCacheType">
+ <xs:attribute name="diskExpiryThreadIntervalSeconds"
+ type="xs:int" default="120" />
+ <xs:attribute name="diskPersistent" type="xs:boolean" />
+ <xs:attribute name="eternal" use="required" type="xs:boolean" />
+ <xs:attribute name="maxElementsInMemory" use="required"
+ type="xs:int" />
+ <xs:attribute name="memoryStoreEvictionPolicy"
+ type="gcache:evictionPolicyType" default="LRU" />
+ <xs:attribute name="overflowToDisk" use="required"
+ type="xs:boolean" />
+ <xs:attribute name="timeToIdleSeconds" type="xs:int"
+ default="120" />
+ <xs:attribute name="timeToLiveSeconds" type="xs:int"
+ default="120" />
+ </xs:complexType>
+ <xs:complexType name="cacheType">
+ <xs:attribute name="diskExpiryThreadIntervalSeconds"
+ type="xs:int" default="60" />
+ <xs:attribute name="diskPersistent" type="xs:boolean" />
+ <xs:attribute name="eternal" use="required" type="xs:boolean" />
+ <xs:attribute name="maxElementsInMemory" use="required"
+ type="xs:int" />
+ <xs:attribute name="memoryStoreEvictionPolicy"
+ type="gcache:evictionPolicyType" default="LRU" />
+ <xs:attribute name="name" use="required" type="xs:NCName" />
+ <xs:attribute name="overflowToDisk" use="required"
+ type="xs:boolean" />
+ <xs:attribute name="timeToIdleSeconds" type="xs:int"
+ default="0" />
+ <xs:attribute name="timeToLiveSeconds" type="xs:int"
+ default="0" />
+ </xs:complexType>
+ <xs:simpleType name="evictionPolicyType">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="FIFO" />
+ <xs:enumeration value="LFU" />
+ <xs:enumeration value="LRU" />
+ </xs:restriction>
+ </xs:simpleType>
+</xs:schema>
\ No newline at end of file
Propchange: geronimo/sandbox/gcache/server/src/main/xsd/gcache.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/main/xsd/gcache.xsd
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/main/xsd/gcache.xsd
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/BulkSendCommandTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/BulkSendCommandTest.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/BulkSendCommandTest.java (original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/BulkSendCommandTest.java Thu Nov 2 10:36:40 2006
@@ -21,10 +21,6 @@
import org.apache.mina.common.ByteBuffer;
import org.testng.annotations.Test;
-import java.io.ByteArrayInputStream;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.Channels;
-
public class BulkSendCommandTest {
@Test
Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CacheBaseCommandTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CacheBaseCommandTest.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CacheBaseCommandTest.java (original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CacheBaseCommandTest.java Thu Nov 2 10:36:40 2006
@@ -21,10 +21,6 @@
import org.apache.mina.common.ByteBuffer;
import org.testng.annotations.Test;
-import java.io.ByteArrayInputStream;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.Channels;
-
public class CacheBaseCommandTest {
@Test
Added: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/dd/ConfigBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/dd/ConfigBuilderTest.java?view=auto&rev=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/dd/ConfigBuilderTest.java (added)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/dd/ConfigBuilderTest.java Thu Nov 2 10:36:40 2006
@@ -0,0 +1,63 @@
+/**
+ *
+ * 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.dd;
+
+import java.util.Map;
+
+import net.sf.ehcache.config.CacheConfiguration;
+import net.sf.ehcache.config.Configuration;
+
+import org.testng.annotations.Test;
+
+public class ConfigBuilderTest {
+
+ @Test
+ public void testConfigBuilder() throws Exception{
+ ConfigBuilder cb = new ConfigBuilder();
+
+ //Pull the configuration
+ GcacheConfiguration config = cb.getConfig(null);
+
+ //Server and Transport Settings
+ assert config.getServerName().equals("gcache");
+ assert config.getTransportUri().getHost().equals("default");
+ assert config.getTransportUri().getScheme().equals("tcp");
+
+ //Check for cache configs
+ Configuration ehcacheConfig = config.getEhcacheConfig();
+ assert ehcacheConfig != null;
+
+ Map configs = ehcacheConfig.getCacheConfigurations();
+ assert configs.containsKey("Test");
+ assert configs.containsKey("Test2");
+
+ //Test cache detail info
+ CacheConfiguration cacheConfig = (CacheConfiguration) configs.get("Test");
+ assert 60 == cacheConfig.getDiskExpiryThreadIntervalSeconds();
+ assert 1800 == cacheConfig.getTimeToIdleSeconds();
+ assert cacheConfig.getMemoryStoreEvictionPolicy().toString().equals("LRU");
+ assert 0 == cacheConfig.getTimeToLiveSeconds();
+
+ CacheConfiguration defaultConfig = ehcacheConfig.getDefaultCacheConfiguration();
+ assert 120 == defaultConfig.getDiskExpiryThreadIntervalSeconds();
+ assert 120 == defaultConfig.getTimeToIdleSeconds();
+ assert defaultConfig.getMemoryStoreEvictionPolicy().toString().equals("LRU");
+ assert 120 == defaultConfig.getTimeToLiveSeconds();
+ }
+
+}
Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/dd/ConfigBuilderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/dd/ConfigBuilderTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/dd/ConfigBuilderTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
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=470466&r1=470465&r2=470466
==============================================================================
--- 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 Thu Nov 2 10:36:40 2006
@@ -33,7 +33,6 @@
import org.apache.geronimo.gcache.command.CommandTypes;
import org.apache.geronimo.gcache.command.HandShakeCommand;
import org.apache.geronimo.gcache.command.PublicKeyCommand;
-import org.apache.geronimo.gcache.command.MessageAckCommand;
import org.apache.geronimo.gcache.util.CipherUtil;
import org.apache.mina.common.ByteBuffer;
import org.testng.annotations.AfterClass;
@@ -57,8 +56,9 @@
info.setCacheNotifier(new TCPCacheNotifier());
URI uri = new URI(protocol);
-
- server = new TCPSocketTransportService(protocol, info);
+
+ server = (TCPSocketTransportService)TCPSocketTransportServiceFactory.createTransportService(uri, info);
+
server.setAckTimeout(10000);
server.setRequireMessageAck(true);
server.setEnableLogging(true);
@@ -107,7 +107,7 @@
sendCommand(socket, auth);
//Get the ack
- MessageAckCommand ackCommand = (MessageAckCommand) readCommand(socket);
+ readCommand(socket);
}
protected void sendCommand(Socket socket, BaseCommand command)
Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TCPEndpointTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TCPEndpointTest.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TCPEndpointTest.java (original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TCPEndpointTest.java Thu Nov 2 10:36:40 2006
@@ -17,7 +17,6 @@
*/
package org.apache.geronimo.gcache.transports.tcp;
-import java.net.InetSocketAddress;
import java.util.Set;
import org.apache.geronimo.gcache.command.BulkSendCommand;
Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TCPNotificationTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TCPNotificationTest.java?view=diff&rev=470466&r1=470465&r2=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TCPNotificationTest.java (original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TCPNotificationTest.java Thu Nov 2 10:36:40 2006
@@ -18,7 +18,6 @@
package org.apache.geronimo.gcache.transports.tcp;
import java.net.Socket;
-import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
@@ -33,7 +32,7 @@
@Test
public void notificationTest() throws Exception{
-
+
GetCacheCommand command = new GetCacheCommand();
command.setCacheName("Notify");
Added: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/util/StringUtilTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/util/StringUtilTest.java?view=auto&rev=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/util/StringUtilTest.java (added)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/util/StringUtilTest.java Thu Nov 2 10:36:40 2006
@@ -0,0 +1,37 @@
+/**
+ *
+ * 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.util;
+
+import org.apache.geronimo.gcache.util.StringUtil;
+import org.testng.annotations.Test;
+
+public class StringUtilTest {
+
+ @Test
+ public void TestUtil(){
+
+ System.setProperty("test.me", "Hello");
+ System.setProperty("test.me.2", "World");
+
+ String input = "${test.me} ${test.me.2}";
+
+ String result = StringUtil.parseAndReplaceSystemProperty(input);
+ assert result.equals("Hello World");
+ }
+
+}
Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/util/StringUtilTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/util/StringUtilTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/util/StringUtilTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gcache/server/src/test/resources/gcache-config.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/resources/gcache-config.xml?view=auto&rev=470466
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/resources/gcache-config.xml (added)
+++ geronimo/sandbox/gcache/server/src/test/resources/gcache-config.xml Thu Nov 2 10:36:40 2006
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gcache-config>
+ <server order="1" serverName="gcache">
+ <transport name="default" uri="tcp://default" discoveryUri="multicast://default" />
+ </server>
+
+ <diskStore path="${java.io.tmpdir}/gcache" />
+
+ <defaultCache maxElementsInMemory="10000" eternal="false"
+ timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true"
+ diskPersistent="false" diskExpiryThreadIntervalSeconds="120"
+ memoryStoreEvictionPolicy="LRU" />
+
+ <cache name="Test" maxElementsInMemory="10000" eternal="false"
+ timeToIdleSeconds="1800" timeToLiveSeconds="0" overflowToDisk="true"
+ diskPersistent="false" diskExpiryThreadIntervalSeconds="60"
+ memoryStoreEvictionPolicy="LRU" />
+
+ <cache name="Test2" maxElementsInMemory="10000" eternal="false"
+ timeToIdleSeconds="0" timeToLiveSeconds="1800" overflowToDisk="false"
+ diskPersistent="true" diskExpiryThreadIntervalSeconds="60"
+ memoryStoreEvictionPolicy="LFU" />
+</gcache-config>
Propchange: geronimo/sandbox/gcache/server/src/test/resources/gcache-config.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/test/resources/gcache-config.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/test/resources/gcache-config.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml