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/09/15 17:53:49 UTC
svn commit: r446644 [2/2] - in /geronimo/sandbox/gcache/openwire: ./
src/main/java/org/apache/geronimo/openwire/
src/main/java/org/apache/geronimo/openwire/command/
src/main/java/org/apache/geronimo/openwire/state/
src/main/java/org/apache/geronimo/ope...
Modified: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/IntrospectionSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/IntrospectionSupport.java?view=diff&rev=446644&r1=446643&r2=446644
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/IntrospectionSupport.java (original)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/IntrospectionSupport.java Fri Sep 15 08:53:47 2006
@@ -4,26 +4,34 @@
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Map.Entry;
-import java.util.*;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Set;
+import java.util.Arrays;
import java.net.URISyntaxException;
import java.net.URI;
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
/**
- * Copyright 2006 The Apache Software Foundation
- * <p/>
- * Licensed 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
- * <p/>
+ * 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
- * <p/>
- * 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.
+ *
+ * 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.
*/
public class IntrospectionSupport {
@@ -31,13 +39,13 @@
static public boolean getProperties(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.");
- if( optionPrefix == null )
- optionPrefix="";
+ if (optionPrefix == null)
+ optionPrefix = "";
Class clazz = target.getClass();
Method[] methods = clazz.getMethods();
@@ -46,24 +54,24 @@
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 )
+ if (value == null)
continue;
String strValue = convertToString(value, type);
- if( strValue ==null )
+ if (strValue == null)
continue;
- name = name.substring(3,4).toLowerCase()+name.substring(4);
- props.put(optionPrefix+name, strValue);
+ name = name.substring(3, 4).toLowerCase() + name.substring(4);
+ props.put(optionPrefix + name, strValue);
rc = true;
- } catch ( Throwable ignore) {
+ } catch (Throwable ignore) {
}
}
@@ -73,20 +81,19 @@
}
-
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;
}
@@ -96,14 +103,14 @@
}
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());
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);
@@ -117,16 +124,16 @@
public static boolean setProperties(Object target, Map props) {
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.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;
}
}
@@ -137,15 +144,15 @@
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] ) {
+ 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) {
@@ -155,11 +162,11 @@
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;
@@ -167,25 +174,25 @@
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;
}
@@ -194,11 +201,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;
}
@@ -218,8 +225,7 @@
Map.Entry entry = (Map.Entry) iter.next();
if (first) {
first = false;
- }
- else {
+ } else {
buffer.append(", ");
}
buffer.append(entry.getKey());
@@ -231,20 +237,14 @@
}
protected static void appendToString(StringBuffer buffer, Object value) {
- if (value instanceof ActiveMQDestination) {
- ActiveMQDestination destination = (ActiveMQDestination) value;
- buffer.append(destination.getQualifiedName());
- }
- else {
- 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;
}
@@ -252,22 +252,22 @@
static private void addFields(Object target, Class startClass, Class stopClass, LinkedHashMap map) {
- if( startClass!=stopClass )
- addFields( target, startClass.getSuperclass(), stopClass, 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) {
Modified: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/MarshallingSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/MarshallingSupport.java?view=diff&rev=446644&r1=446643&r2=446644
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/MarshallingSupport.java (original)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/MarshallingSupport.java Fri Sep 15 08:53:47 2006
@@ -1,22 +1,35 @@
package org.apache.geronimo.openwire.util;
-import java.io.*;
-import java.util.*;
+import java.io.IOException;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.DataOutput;
+import java.io.DataInput;
+import java.io.UTFDataFormatException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+
/**
- * Copyright 2006 The Apache Software Foundation
- * <p/>
- * Licensed 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
+ * 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.
*/
public class MarshallingSupport {
Modified: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/ServiceStopper.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/ServiceStopper.java?view=diff&rev=446644&r1=446643&r2=446644
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/ServiceStopper.java (original)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/ServiceStopper.java Fri Sep 15 08:53:47 2006
@@ -8,19 +8,22 @@
import java.util.List;
/**
- * Copyright 2006 The Apache Software Foundation
- * <p/>
- * Licensed 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
+ * 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.
*/
public class ServiceStopper {
private Throwable firstException;
Modified: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/ServiceSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/ServiceSupport.java?view=diff&rev=446644&r1=446643&r2=446644
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/ServiceSupport.java (original)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/ServiceSupport.java Fri Sep 15 08:53:47 2006
@@ -6,19 +6,22 @@
import org.apache.commons.logging.LogFactory;
/**
- * Copyright 2006 The Apache Software Foundation
- * <p/>
- * Licensed 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
+ * 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.
*/
public abstract class ServiceSupport implements Service {
private static final Log log = LogFactory.getLog(ServiceSupport.class);
Modified: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/URISupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/URISupport.java?view=diff&rev=446644&r1=446643&r2=446644
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/URISupport.java (original)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/URISupport.java Fri Sep 15 08:53:47 2006
@@ -8,19 +8,22 @@
import java.io.UnsupportedEncodingException;
/**
- * Copyright 2006 The Apache Software Foundation
- * <p/>
- * Licensed 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
+ * 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.
*/
public class URISupport {
Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/wireformat/ObjectStreamWireFormatFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/wireformat/ObjectStreamWireFormatFactory.java?view=auto&rev=446644
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/wireformat/ObjectStreamWireFormatFactory.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/wireformat/ObjectStreamWireFormatFactory.java Fri Sep 15 08:53:47 2006
@@ -0,0 +1,23 @@
+package org.apache.geronimo.openwire.wireformat;
+
+/**
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.
+ */
+public class ObjectStreamWireFormatFactory implements WireFormatFactory{
+
+ public WireFormat createWireFormat() {
+ return new ObjectStreamWireFormat();
+ }
+}
Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/wireformat/ObjectStreamWireFormatFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/wireformat/ObjectStreamWireFormatFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/wireformat/ObjectStreamWireFormatFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain