org.apache.cxf
cxf-tools-corba
diff --git a/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java b/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
index 7c72f004494..27655aac14f 100644
--- a/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
+++ b/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
@@ -155,8 +155,18 @@ private AttachmentUtil() {
}
static {
- COMMAND_MAP.addMailcap("image/*;;x-java-content-handler="
- + ImageDataContentHandler.class.getName());
+ String imageDataContentHandlerClassName = "org.apache.cxf.management.attachment.image.ImageDataContentHandler";
+
+ try {
+ Class> imageDataContentHandlerClass = Class.forName(
+ imageDataContentHandlerClassName);
+
+ COMMAND_MAP.addMailcap("image/*;;x-java-content-handler="
+ + imageDataContentHandlerClass.getName());
+ } catch (ReflectiveOperationException e) {
+ LOG.warning(() -> imageDataContentHandlerClassName.concat(
+ " cannot be found. Is cxf-rt-attachment-image present?"));
+ }
}
public static CommandMap getCommandMap() {
diff --git a/core/src/main/java/org/apache/cxf/bus/osgi/ManagedWorkQueueList.java b/core/src/main/java/org/apache/cxf/bus/osgi/ManagedWorkQueueList.java
index cd71e400c9d..3fa91037772 100644
--- a/core/src/main/java/org/apache/cxf/bus/osgi/ManagedWorkQueueList.java
+++ b/core/src/main/java/org/apache/cxf/bus/osgi/ManagedWorkQueueList.java
@@ -18,8 +18,6 @@
*/
package org.apache.cxf.bus.osgi;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.util.Dictionary;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -30,6 +28,8 @@
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.workqueue.AutomaticWorkQueueImpl;
import org.apache.cxf.workqueue.WorkQueueManager;
+import org.apache.cxf.workqueue.WorkqueueEvent;
+import org.apache.cxf.workqueue.WorkqueueEventListener;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.cm.ConfigurationException;
@@ -39,7 +39,7 @@
/**
* List of work queues that can be managed using the OSGi configuration admin service
*/
-public class ManagedWorkQueueList implements ManagedServiceFactory, PropertyChangeListener {
+public class ManagedWorkQueueList implements ManagedServiceFactory, WorkqueueEventListener {
public static final String FACTORY_PID = "org.apache.cxf.workqueues";
private static final Logger LOG = LogUtils.getL7dLogger(ManagedWorkQueueList.class);
@@ -76,9 +76,9 @@ public void deleted(String pid) {
/*
* On property changes of queue settings we update the config admin service pid of the queue
*/
- public void propertyChange(PropertyChangeEvent evt) {
+ public void processEvent(WorkqueueEvent workqueueEvent) {
try {
- AutomaticWorkQueueImpl queue = (AutomaticWorkQueueImpl)evt.getSource();
+ AutomaticWorkQueueImpl queue = (AutomaticWorkQueueImpl)workqueueEvent.getSource();
ConfigurationAdmin configurationAdmin = configAdminTracker.getService();
if (configurationAdmin != null) {
Configuration selectedConfig = findConfigForQueueName(queue, configurationAdmin);
diff --git a/core/src/main/java/org/apache/cxf/common/jaxb/SchemaCollectionContextProxy.java b/core/src/main/java/org/apache/cxf/common/jaxb/SchemaCollectionContextProxy.java
index 0c5522d6936..b34262914d5 100644
--- a/core/src/main/java/org/apache/cxf/common/jaxb/SchemaCollectionContextProxy.java
+++ b/core/src/main/java/org/apache/cxf/common/jaxb/SchemaCollectionContextProxy.java
@@ -43,6 +43,7 @@
import org.w3c.dom.Document;
+import org.apache.cxf.common.util.ClassHelper;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.common.xmlschema.SchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaElement;
@@ -135,7 +136,7 @@ public Object getBeanInfo(Class> cls) {
String name = xre == null ? "##default" : xre.name();
String namespace = xre == null ? "##default" : xre.namespace();
if ("##default".equals(name)) {
- name = java.beans.Introspector.decapitalize(cls.getSimpleName());
+ name = ClassHelper.decapitalizedSimpleName(cls);
}
if ("##default".equals(namespace) && cls.getPackage() != null) {
XmlSchema sc = cls.getPackage().getAnnotation(XmlSchema.class);
@@ -199,7 +200,7 @@ private QName getTypeQName(Class> cls, String namespace) {
String tn = xtype == null ? "##default" : xtype.name();
String tns = xtype == null ? "##default" : xtype.namespace();
if ("##default".equals(tn)) {
- tn = java.beans.Introspector.decapitalize(cls.getSimpleName());
+ tn = ClassHelper.decapitalizedSimpleName(cls);
}
if ("##default".equals(tns) || StringUtils.isEmpty(tns)) {
tns = JAXBUtils.getPackageNamespace(cls);
diff --git a/core/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java b/core/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java
index a1a5c82cc59..748bbcd0e54 100644
--- a/core/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java
+++ b/core/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java
@@ -29,7 +29,6 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
-import javax.imageio.ImageIO;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
@@ -101,7 +100,9 @@ public static void doHacks() {
try {
//Trigger a call to sun.awt.AppContext.getAppContext()
if (!skipHack("org.apache.cxf.JDKBugHacks.imageIO", "true")) {
- ImageIO.getCacheDirectory();
+ Class> imageIOClass = Class.forName("javax.imageio.ImageIO");
+ Method getCacheDirectoryMethod = imageIOClass.getDeclaredMethod("getCacheDirectory");
+ getCacheDirectoryMethod.invoke(null);
}
} catch (Throwable t) {
//ignore
diff --git a/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java b/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
index adec469fdcf..2ae4faf809c 100644
--- a/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
@@ -101,6 +101,23 @@ private Object getRealObjectInternal(Object o) {
return o instanceof Proxy ? Proxy.getInvocationHandler(o) : o;
}
+ public static String decapitalizedSimpleName(Class> clazz) {
+ if (clazz == null) {
+ return null;
+ }
+ String name = clazz.getSimpleName();
+ if (name == null || name.isEmpty()) {
+ return name;
+ }
+ if (name.length() > 1 && Character.isUpperCase(name.charAt(1))
+ && Character.isUpperCase(name.charAt(0))) {
+ return name;
+ }
+ char[] chars = name.toCharArray();
+ chars[0] = Character.toLowerCase(chars[0]);
+ return new String(chars);
+ }
+
public static Class> getRealClass(Object o) {
return getRealClass(null, o);
}
diff --git a/core/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java b/core/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java
index 146d7fc5762..7142c803bb9 100644
--- a/core/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java
@@ -19,28 +19,18 @@
package org.apache.cxf.common.util;
-import java.beans.BeanInfo;
-import java.beans.PropertyDescriptor;
import java.lang.annotation.Annotation;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
public final class ReflectionUtil {
- private static Method springBeanUtilsDescriptorFetcher;
- private static boolean springChecked;
-
private ReflectionUtil() {
// intentionally empty
}
@@ -195,61 +185,6 @@ public T run() {
});
}
- /**
- * create own array of property descriptors to:
- *
- * - prevent memory leaks by Introspector's cache
- * - get correct type for generic properties from superclass
- * that are limited to a specific type in beanClass
- * see http://bugs.sun.com/view_bug.do?bug_id=6528714
- * we cannot use BeanUtils.getPropertyDescriptors because of issue SPR-6063
- *
- * @param refClass calling class for class loading.
- * @param beanInfo Bean in question
- * @param beanClass class for bean in question
- * @param propertyDescriptors raw descriptors
- */
- public static PropertyDescriptor[] getPropertyDescriptorsAvoidSunBug(Class> refClass,
- BeanInfo beanInfo,
- Class> beanClass,
- PropertyDescriptor[] propertyDescriptors) {
- if (!springChecked) {
- try {
- springChecked = true;
- Class> cls = ClassLoaderUtils
- .loadClass("org.springframework.beans.BeanUtils", refClass);
- springBeanUtilsDescriptorFetcher
- = cls.getMethod("getPropertyDescriptor", Class.class, String.class);
- } catch (Exception e) {
- //ignore - just assume it's an unsupported/unknown annotation
- }
- }
-
- if (springBeanUtilsDescriptorFetcher != null) {
- if (propertyDescriptors != null) {
- List descriptors = new ArrayList<>(propertyDescriptors.length);
- for (int i = 0; i < propertyDescriptors.length; i++) {
- PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
- try {
- propertyDescriptor = (PropertyDescriptor)springBeanUtilsDescriptorFetcher.invoke(null,
- beanClass,
- propertyDescriptor.getName());
- if (propertyDescriptor != null) {
- descriptors.add(propertyDescriptor);
- }
- } catch (IllegalArgumentException | IllegalAccessException e) {
- throw new RuntimeException(e);
- } catch (InvocationTargetException e) {
- throw new RuntimeException(e.getCause());
- }
- }
- return descriptors.toArray(new PropertyDescriptor[0]);
- }
- return null;
- }
- return beanInfo.getPropertyDescriptors();
- }
-
/**
* Look for a specified annotation on a method. If there, return it. If not, search it's containing class.
* Assume that the annotation is marked @Inherited.
diff --git a/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java b/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
index 67dd3b4ddb8..64f7fce280a 100644
--- a/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
+++ b/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
@@ -19,8 +19,6 @@
package org.apache.cxf.workqueue;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -78,7 +76,7 @@ public class AutomaticWorkQueueImpl implements AutomaticWorkQueue {
boolean shared;
int sharedCount;
- private List changeListenerList;
+ private List workqueueEventListeners;
public AutomaticWorkQueueImpl() {
this(DEFAULT_MAX_QUEUE_SIZE);
@@ -116,20 +114,20 @@ public AutomaticWorkQueueImpl(int mqs,
this.lowWaterMark = -1 == lowWaterMark ? Integer.MAX_VALUE : lowWaterMark;
this.dequeueTimeout = dequeueTimeout;
this.name = name;
- this.changeListenerList = new ArrayList<>();
+ this.workqueueEventListeners = new ArrayList<>();
}
- public void addChangeListener(PropertyChangeListener listener) {
- this.changeListenerList.add(listener);
+ public void addChangeListener(WorkqueueEventListener listener) {
+ this.workqueueEventListeners.add(listener);
}
- public void removeChangeListener(PropertyChangeListener listener) {
- this.changeListenerList.remove(listener);
+ public void removeChangeListener(WorkqueueEventListener listener) {
+ this.workqueueEventListeners.remove(listener);
}
- public void notifyChangeListeners(PropertyChangeEvent event) {
- for (PropertyChangeListener listener : changeListenerList) {
- listener.propertyChange(event);
+ public void notifyChangeListeners(WorkqueueEvent workqueueEvent) {
+ for (WorkqueueEventListener listener : workqueueEventListeners) {
+ listener.processEvent(workqueueEvent);
}
}
@@ -530,7 +528,7 @@ public int getInitialSize() {
public void setHighWaterMark(int hwm) {
highWaterMark = hwm < 0 ? Integer.MAX_VALUE : hwm;
if (executor != null) {
- notifyChangeListeners(new PropertyChangeEvent(this, "highWaterMark",
+ notifyChangeListeners(new WorkqueueEvent(this, "highWaterMark",
this.executor.getMaximumPoolSize(), hwm));
executor.setMaximumPoolSize(highWaterMark);
}
@@ -539,24 +537,24 @@ public void setHighWaterMark(int hwm) {
public void setLowWaterMark(int lwm) {
lowWaterMark = lwm < 0 ? 0 : lwm;
if (executor != null) {
- notifyChangeListeners(new PropertyChangeEvent(this, "lowWaterMark",
+ notifyChangeListeners(new WorkqueueEvent(this, "lowWaterMark",
this.executor.getCorePoolSize(), lwm));
executor.setCorePoolSize(lowWaterMark);
}
}
public void setInitialSize(int initialSize) {
- notifyChangeListeners(new PropertyChangeEvent(this, "initialSize", this.initialThreads, initialSize));
+ notifyChangeListeners(new WorkqueueEvent(this, "initialSize", this.initialThreads, initialSize));
this.initialThreads = initialSize;
}
public void setQueueSize(int size) {
- notifyChangeListeners(new PropertyChangeEvent(this, "queueSize", this.maxQueueSize, size));
+ notifyChangeListeners(new WorkqueueEvent(this, "queueSize", this.maxQueueSize, size));
this.maxQueueSize = size;
}
public void setDequeueTimeout(long l) {
- notifyChangeListeners(new PropertyChangeEvent(this, "dequeueTimeout", this.dequeueTimeout, l));
+ notifyChangeListeners(new WorkqueueEvent(this, "dequeueTimeout", this.dequeueTimeout, l));
this.dequeueTimeout = l;
}
diff --git a/core/src/main/java/org/apache/cxf/workqueue/WorkqueueEvent.java b/core/src/main/java/org/apache/cxf/workqueue/WorkqueueEvent.java
new file mode 100644
index 00000000000..f973494038b
--- /dev/null
+++ b/core/src/main/java/org/apache/cxf/workqueue/WorkqueueEvent.java
@@ -0,0 +1,60 @@
+/**
+ * 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.cxf.workqueue;
+
+import java.util.EventObject;
+
+public class WorkqueueEvent extends EventObject {
+ private static final long serialVersionUID = 2445723027847701801L;
+
+ private final Object newValue;
+ private final Object oldValue;
+ private final String propertyName;
+
+ public WorkqueueEvent(
+ Object source, String propertyName, Object oldValue, Object newValue) {
+ super(source);
+ this.propertyName = propertyName;
+ this.newValue = newValue;
+ this.oldValue = oldValue;
+ }
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public Object getNewValue() {
+ return newValue;
+ }
+
+ public Object getOldValue() {
+ return oldValue;
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder(getClass().getName());
+ sb.append("[propertyName=").append(getPropertyName());
+ sb.append("; oldValue=").append(getOldValue());
+ sb.append("; newValue=").append(getNewValue());
+ sb.append("; source=").append(getSource());
+ return sb.append(']').toString();
+ }
+
+}
diff --git a/core/src/main/java/org/apache/cxf/workqueue/WorkqueueEventListener.java b/core/src/main/java/org/apache/cxf/workqueue/WorkqueueEventListener.java
new file mode 100644
index 00000000000..e4fd786a9de
--- /dev/null
+++ b/core/src/main/java/org/apache/cxf/workqueue/WorkqueueEventListener.java
@@ -0,0 +1,26 @@
+/**
+ * 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.cxf.workqueue;
+
+public interface WorkqueueEventListener extends java.util.EventListener {
+
+ void processEvent(WorkqueueEvent workqueueEvent);
+
+}
diff --git a/osgi/itests-felix/pom.xml b/osgi/itests-felix/pom.xml
index d30204f6740..3a163767d5c 100644
--- a/osgi/itests-felix/pom.xml
+++ b/osgi/itests-felix/pom.xml
@@ -86,7 +86,12 @@
cxf-rt-frontend-jaxws
${project.version}
-
+