You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by gn...@apache.org on 2018/01/31 20:10:04 UTC
svn commit: r1822826 [2/4] - in /aries/trunk/blueprint:
blueprint-cm/src/main/java/org/apache/aries/blueprint/compendium/cm/
blueprint-cm/src/test/java/org/apache/aries/blueprint/compendium/cm/
blueprint-core/src/main/java/org/apache/aries/blueprint/co...
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java Wed Jan 31 20:10:03 2018
@@ -113,7 +113,7 @@ public class ReferenceRecipe extends Abs
if (clz != null) interfaces.add(clz);
if (metadata instanceof ExtendedReferenceMetadata) {
- interfaces.addAll(loadAllClasses(((ExtendedReferenceMetadata)metadata).getExtraInterfaces()));
+ interfaces.addAll(loadAllClasses(((ExtendedReferenceMetadata) metadata).getExtraInterfaces()));
}
Object result;
@@ -193,14 +193,14 @@ public class ReferenceRecipe extends Abs
voidProxiedChildren();
bind(trackedServiceReference, proxy);
if (ref != oldReference) {
- if (oldReference != null && trackedService != null) {
- try {
- blueprintContainer.getBundleContext().ungetService(oldReference);
- } catch (IllegalStateException ise) {
- // In case the service no longer exists lets just cope and ignore.
+ if (oldReference != null && trackedService != null) {
+ try {
+ blueprintContainer.getBundleContext().ungetService(oldReference);
+ } catch (IllegalStateException ise) {
+ // In case the service no longer exists lets just cope and ignore.
+ }
}
- }
- trackedService = null;
+ trackedService = null;
}
monitor.notifyAll();
}
@@ -214,13 +214,13 @@ public class ReferenceRecipe extends Abs
ServiceReference oldReference = trackedServiceReference;
trackedServiceReference = null;
voidProxiedChildren();
- if(trackedService != null){
- try {
- getBundleContextForServiceLookup().ungetService(oldReference);
- } catch (IllegalStateException ise) {
- // In case the service no longer exists lets just cope and ignore.
- }
- trackedService = null;
+ if (trackedService != null) {
+ try {
+ getBundleContextForServiceLookup().ungetService(oldReference);
+ } catch (IllegalStateException ise) {
+ // In case the service no longer exists lets just cope and ignore.
+ }
+ trackedService = null;
}
monitor.notifyAll();
}
@@ -238,54 +238,54 @@ public class ReferenceRecipe extends Abs
Object result = null;
if (trackedServiceReference == null) {
if (isStarted()) {
- boolean failed = true;
- if (metadata.getAvailability() == ReferenceMetadata.AVAILABILITY_OPTIONAL &&
- metadata instanceof ExtendedReferenceMetadata) {
- if (defaultBean == null) {
- String defaultBeanId = ((ExtendedReferenceMetadata)metadata).getDefaultBean();
- if (defaultBeanId != null) {
- defaultBean = blueprintContainer.getComponentInstance(defaultBeanId);
- failed = false;
- }
- } else {
- failed = false;
- }
- result = defaultBean;
- }
-
- if (failed) {
- if (metadata.getAvailability() == ServiceReferenceMetadata.AVAILABILITY_MANDATORY) {
- LOGGER.info("Timeout expired when waiting for mandatory OSGi service reference {}", getOsgiFilter());
- throw new ServiceUnavailableException("Timeout expired when waiting for mandatory OSGi service reference: " + getOsgiFilter(), getOsgiFilter());
- } else {
- LOGGER.info("No matching service for optional OSGi service reference {}", getOsgiFilter());
- throw new ServiceUnavailableException("No matching service for optional OSGi service reference: " + getOsgiFilter(), getOsgiFilter());
+ boolean failed = true;
+ if (metadata.getAvailability() == ReferenceMetadata.AVAILABILITY_OPTIONAL &&
+ metadata instanceof ExtendedReferenceMetadata) {
+ if (defaultBean == null) {
+ String defaultBeanId = ((ExtendedReferenceMetadata) metadata).getDefaultBean();
+ if (defaultBeanId != null) {
+ defaultBean = blueprintContainer.getComponentInstance(defaultBeanId);
+ failed = false;
+ }
+ } else {
+ failed = false;
+ }
+ result = defaultBean;
+ }
+
+ if (failed) {
+ if (metadata.getAvailability() == ServiceReferenceMetadata.AVAILABILITY_MANDATORY) {
+ LOGGER.info("Timeout expired when waiting for mandatory OSGi service reference {}", getOsgiFilter());
+ throw new ServiceUnavailableException("Timeout expired when waiting for mandatory OSGi service reference: " + getOsgiFilter(), getOsgiFilter());
+ } else {
+ LOGGER.info("No matching service for optional OSGi service reference {}", getOsgiFilter());
+ throw new ServiceUnavailableException("No matching service for optional OSGi service reference: " + getOsgiFilter(), getOsgiFilter());
+ }
}
- }
} else {
throw new ServiceUnavailableException("The Blueprint container is being or has been destroyed: " + getOsgiFilter(), getOsgiFilter());
}
} else {
-
- if (trackedService == null) {
- trackedService = getServiceSecurely(trackedServiceReference);
- }
-
- if (trackedService == null) {
- throw new IllegalStateException("getService() returned null for " + trackedServiceReference);
- }
-
- result = trackedService;
+
+ if (trackedService == null) {
+ trackedService = getServiceSecurely(trackedServiceReference);
+ }
+
+ if (trackedService == null) {
+ throw new IllegalStateException("getService() returned null for " + trackedServiceReference);
+ }
+
+ result = trackedService;
}
return result;
}
}
private BlueprintEvent createWaitingevent() {
- return new BlueprintEvent(BlueprintEvent.WAITING,
- blueprintContainer.getBundleContext().getBundle(),
- blueprintContainer.getExtenderBundle(),
- new String[] { getOsgiFilter() });
+ return new BlueprintEvent(BlueprintEvent.WAITING,
+ blueprintContainer.getBundleContext().getBundle(),
+ blueprintContainer.getExtenderBundle(),
+ new String[]{getOsgiFilter()});
}
private ServiceReference getServiceReference() throws InterruptedException {
@@ -298,21 +298,21 @@ public class ReferenceRecipe extends Abs
}
private void voidProxiedChildren() {
- if(proxyChildBeanClasses != null) {
- synchronized(proxiedChildren) {
- for(Iterator<WeakReference<Voidable>> it = proxiedChildren.iterator(); it.hasNext();) {
+ if (proxyChildBeanClasses != null) {
+ synchronized (proxiedChildren) {
+ for (Iterator<WeakReference<Voidable>> it = proxiedChildren.iterator(); it.hasNext(); ) {
Voidable v = it.next().get();
- if(v == null)
+ if (v == null)
it.remove();
else
- v.voidReference();
+ v.voidReference();
}
}
}
}
public void addVoidableChild(Voidable v) {
- if(proxyChildBeanClasses != null) {
+ if (proxyChildBeanClasses != null) {
synchronized (proxiedChildren) {
proxiedChildren.add(new WeakReference<Voidable>(v));
}
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java Wed Jan 31 20:10:03 2018
@@ -217,7 +217,7 @@ public class ServiceRecipe extends Abstr
}
protected ServiceReference getReference() {
- ServiceRegistration reg = registration.get();
+ ServiceRegistration reg = registration.get();
if (reg == null) {
throw new IllegalStateException("Service is not registered");
} else {
@@ -226,7 +226,7 @@ public class ServiceRecipe extends Abstr
}
protected void setProperties(Dictionary props) {
- ServiceRegistration reg = registration.get();
+ ServiceRegistration reg = registration.get();
if (reg == null) {
throw new IllegalStateException("Service is not registered");
} else {
@@ -254,22 +254,22 @@ public class ServiceRecipe extends Abstr
Object service = this.service;
// We need the real service ...
if (bundle != null) {
- if (service instanceof ServiceFactory) {
- service = ((ServiceFactory) service).getService(bundle, registration);
- }
- if (service == null) {
- throw new IllegalStateException("service is null");
- }
- // Check if the service actually implement all the requested interfaces
- validateClasses(service);
- // We're not really interested in the service, but perform some sanity checks nonetheless
+ if (service instanceof ServiceFactory) {
+ service = ((ServiceFactory) service).getService(bundle, registration);
+ }
+ if (service == null) {
+ throw new IllegalStateException("service is null");
+ }
+ // Check if the service actually implement all the requested interfaces
+ validateClasses(service);
+ // We're not really interested in the service, but perform some sanity checks nonetheless
} else {
- if (!(service instanceof ServiceFactory)) {
- // Check if the service actually implement all the requested interfaces
- validateClasses(service);
- }
+ if (!(service instanceof ServiceFactory)) {
+ // Check if the service actually implement all the requested interfaces
+ validateClasses(service);
+ }
}
-
+
return service;
}
@@ -361,7 +361,7 @@ public class ServiceRecipe extends Abstr
* So we need to set the registration object in case registration listeners call
* getServiceReference().
*/
- this.registration.compareAndSet(null, registration);
+ this.registration.compareAndSet(null, registration);
return internalGetService(bundle, registration);
}
@@ -409,29 +409,29 @@ public class ServiceRecipe extends Abstr
* @throws ClassNotFoundException
*/
private Collection<Class<?>> getClassesForProxying(Object template) throws ClassNotFoundException {
- Collection<Class<?>> classes;
- switch (metadata.getAutoExport()) {
- case ServiceMetadata.AUTO_EXPORT_INTERFACES:
- classes = ReflectionUtils.getImplementedInterfacesAsClasses(new HashSet<Class<?>>(), template.getClass());
- break;
- case ServiceMetadata.AUTO_EXPORT_CLASS_HIERARCHY:
- case ServiceMetadata.AUTO_EXPORT_ALL_CLASSES:
- classes = ProxyUtils.asList(template.getClass());
- break;
- default:
- classes = new HashSet<Class<?>>(convertStringsToClasses(metadata.getInterfaces()));
- break;
- }
- return classes;
- }
+ Collection<Class<?>> classes;
+ switch (metadata.getAutoExport()) {
+ case ServiceMetadata.AUTO_EXPORT_INTERFACES:
+ classes = ReflectionUtils.getImplementedInterfacesAsClasses(new HashSet<Class<?>>(), template.getClass());
+ break;
+ case ServiceMetadata.AUTO_EXPORT_CLASS_HIERARCHY:
+ case ServiceMetadata.AUTO_EXPORT_ALL_CLASSES:
+ classes = ProxyUtils.asList(template.getClass());
+ break;
+ default:
+ classes = new HashSet<Class<?>>(convertStringsToClasses(metadata.getInterfaces()));
+ break;
+ }
+ return classes;
+ }
private Collection<? extends Class<?>> convertStringsToClasses(
- List<String> interfaces) throws ClassNotFoundException {
- Set<Class<?>> classes = new HashSet<Class<?>>();
- for(String s : interfaces) {
- classes.add(blueprintContainer.loadClass(s));
- }
- return classes;
+ List<String> interfaces) throws ClassNotFoundException {
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ for (String s : interfaces) {
+ classes.add(blueprintContainer.loadClass(s));
+ }
+ return classes;
}
private void createExplicitDependencies() {
@@ -476,7 +476,7 @@ public class ServiceRecipe extends Abstr
callbacksToCall = new ArrayList<DestroyCallback>(destroyCallbacks);
destroyCallbacks.clear();
}
- for(DestroyCallback cbk : callbacksToCall) {
+ for (DestroyCallback cbk : callbacksToCall) {
cbk.callback();
}
}
@@ -522,21 +522,20 @@ public class ServiceRecipe extends Abstr
}
}
}
-
- private class TriggerServiceFactory implements ServiceFactory
- {
- private ServiceRecipe serviceRecipe;
- private ComponentMetadata cm;
- private ServiceMetadata sm;
+
+ private class TriggerServiceFactory implements ServiceFactory {
+ private ServiceRecipe serviceRecipe;
+ private ComponentMetadata cm;
+ private ServiceMetadata sm;
private boolean isQuiesceAvailable;
- public TriggerServiceFactory(ServiceRecipe serviceRecipe, ServiceMetadata cm)
- {
- this.serviceRecipe = serviceRecipe;
- this.cm = cm;
- this.sm = cm;
+
+ public TriggerServiceFactory(ServiceRecipe serviceRecipe, ServiceMetadata cm) {
+ this.serviceRecipe = serviceRecipe;
+ this.cm = cm;
+ this.sm = cm;
this.isQuiesceAvailable = isClassAvailable("org.apache.aries.quiesce.participant.QuiesceParticipant");
- }
-
+ }
+
public Object getService(Bundle bundle, ServiceRegistration registration) {
Object original = ServiceRecipe.this.getService(bundle, registration);
LOGGER.debug(LOG_ENTRY, "getService", original);
@@ -561,8 +560,8 @@ public class ServiceRecipe extends Abstr
try {
Bundle b = FrameworkUtil.getBundle(original.getClass());
if (b == null) {
- // we have a class from the framework parent, so use our bundle for proxying.
- b = blueprintContainer.getBundleContext().getBundle();
+ // we have a class from the framework parent, so use our bundle for proxying.
+ b = blueprintContainer.getBundleContext().getBundle();
}
InvocationListener collaborator = CollaboratorFactory.create(cm, interceptors);
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/CollectionRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/CollectionRecipe.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/CollectionRecipe.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/CollectionRecipe.java Wed Jan 31 20:10:03 2018
@@ -83,10 +83,10 @@ public class CollectionRecipe extends Ab
Object value;
if (recipe != null) {
try {
- conversionType = defaultConversionType.getRawClass();
+ conversionType = defaultConversionType.getRawClass();
if (recipe instanceof ValueRecipe) {
- conversionType = ((ValueRecipe)recipe).getValueType();
- }
+ conversionType = ((ValueRecipe) recipe).getValueType();
+ }
value = convert(recipe.create(), conversionType);
} catch (Exception e) {
throw new ComponentDefinitionException("Unable to convert value " + recipe + " to type " + conversionType, e);
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/MapRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/MapRecipe.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/MapRecipe.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/MapRecipe.java Wed Jan 31 20:10:03 2018
@@ -64,7 +64,7 @@ public class MapRecipe extends AbstractR
}
private ReifiedType getType(Object o) {
- ReifiedType type;
+ ReifiedType type;
if (o instanceof Class) {
type = new ReifiedType((Class) o);
} else if (o instanceof String) {
@@ -112,29 +112,27 @@ public class MapRecipe extends AbstractR
instance.put(key, value);
}
} catch (Exception e) {
- throw new ComponentDefinitionException(e);
+ throw new ComponentDefinitionException(e);
}
return instance;
}
- protected ReifiedType workOutConversionType(Recipe entry, ReifiedType defaultType) {
- if (entry instanceof ValueRecipe)
- {
- return getType(((ValueRecipe) entry).getValueType());
- } else
- {
- return defaultType;
- }
- }
+ protected ReifiedType workOutConversionType(Recipe entry, ReifiedType defaultType) {
+ if (entry instanceof ValueRecipe) {
+ return getType(((ValueRecipe) entry).getValueType());
+ } else {
+ return defaultType;
+ }
+ }
public void put(Recipe key, Recipe value) {
if (key == null) throw new NullPointerException("key is null");
- entries.add(new Recipe[] { key, value});
+ entries.add(new Recipe[]{key, value});
}
- public void putAll(Map<Recipe,Recipe> map) {
+ public void putAll(Map<Recipe, Recipe> map) {
if (map == null) throw new NullPointerException("map is null");
- for (Map.Entry<Recipe,Recipe> entry : map.entrySet()) {
+ for (Map.Entry<Recipe, Recipe> entry : map.entrySet()) {
Recipe key = entry.getKey();
Recipe value = entry.getValue();
put(key, value);
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/ValueRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/ValueRecipe.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/ValueRecipe.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/ValueRecipe.java Wed Jan 31 20:10:03 2018
@@ -52,20 +52,20 @@ public class ValueRecipe extends Abstrac
try {
Type type = getValueType();
return convert(value.getStringValue(), type);
- } catch (Exception e) {
+ } catch (Exception e) {
throw new ComponentDefinitionException(e);
}
}
- protected Type getValueType() {
- Type type = Object.class;
- if (this.type instanceof Type) {
- type = (Type) this.type;
- } else if (this.type instanceof String) {
- type = loadClass((String) this.type);
- }
- return type;
- }
+ protected Type getValueType() {
+ Type type = Object.class;
+ if (this.type instanceof Type) {
+ type = (Type) this.type;
+ } else if (this.type instanceof String) {
+ type = loadClass((String) this.type);
+ }
+ return type;
+ }
@Override
public String toString() {
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/ext/PropertyPlaceholder.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/ext/PropertyPlaceholder.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/ext/PropertyPlaceholder.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/ext/PropertyPlaceholder.java Wed Jan 31 20:10:03 2018
@@ -210,7 +210,7 @@ public class PropertyPlaceholder extends
if (evaluator == null) {
return super.retrieveValue(expression);
} else {
- return evaluator.evaluate(expression, new Dictionary<String, String>(){
+ return evaluator.evaluate(expression, new Dictionary<String, String>() {
@Override
public String get(Object key) {
return getProperty((String) key);
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/ext/impl/ExtNamespaceHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/ext/impl/ExtNamespaceHandler.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/ext/impl/ExtNamespaceHandler.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/ext/impl/ExtNamespaceHandler.java Wed Jan 31 20:10:03 2018
@@ -185,9 +185,9 @@ public class ExtNamespaceHandler impleme
} else if (node instanceof Element && nodeNameEquals(node, ADDITIONAL_INTERFACES)) {
return decorateAdditionalInterfaces(node, component, context);
} else if (node instanceof Element && nodeNameEquals(node, BEAN)) {
- return context.parseElement(BeanMetadata.class, component, (Element)node);
+ return context.parseElement(BeanMetadata.class, component, (Element) node);
} else if (node instanceof Element && nodeNameEquals(node, REFERENCE)) {
- RefMetadata rd = context.parseElement(RefMetadata.class, component, (Element)node);
+ RefMetadata rd = context.parseElement(RefMetadata.class, component, (Element) node);
return createReference(context, rd.getComponentId());
} else if (node instanceof Attr && nodeNameEquals(node, DAMPING_ATTRIBUTE)) {
return decorateDamping(node, component, context);
@@ -207,12 +207,12 @@ public class ExtNamespaceHandler impleme
if (!(component instanceof MutableReferenceMetadata)) {
throw new ComponentDefinitionException("Expected an instanceof MutableReferenceMetadata");
}
- MutableReferenceMetadata mrm = (MutableReferenceMetadata)component;
+ MutableReferenceMetadata mrm = (MutableReferenceMetadata) component;
List<String> list = new ArrayList<String>();
Node nd = node.getFirstChild();
while (nd != null) {
if (nd instanceof Element && nodeNameEquals(nd, INTERFACE_VALUE)) {
- list.add(((Element)nd).getTextContent());
+ list.add(((Element) nd).getTextContent());
}
nd = nd.getNextSibling();
}
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/namespace/NamespaceHandlerRegistryImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/namespace/NamespaceHandlerRegistryImpl.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/namespace/NamespaceHandlerRegistryImpl.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/namespace/NamespaceHandlerRegistryImpl.java Wed Jan 31 20:10:03 2018
@@ -671,7 +671,7 @@ public class NamespaceHandlerRegistryImp
public void registerHandler(URI uri, NamespaceHandler handler) {
if (namespaces.contains(uri) && handlers.get(uri) == null) {
- if (findCompatibleNamespaceHandler(uri) != null) {
+ if (findCompatibleNamespaceHandler(uri) != null) {
for (Listener listener : listeners) {
try {
listener.namespaceHandlerRegistered(uri);
@@ -812,12 +812,12 @@ public class NamespaceHandlerRegistryImp
}
}
- public static class LRUMap<K,V> extends AbstractMap<K,V> {
+ public static class LRUMap<K, V> extends AbstractMap<K, V> {
private final int bound;
- private final LinkedList<Entry<K,V>> entries = new LinkedList<Entry<K,V>>();
+ private final LinkedList<Entry<K, V>> entries = new LinkedList<Entry<K, V>>();
- private static class LRUEntry<K,V> implements Entry<K,V> {
+ private static class LRUEntry<K, V> implements Entry<K, V> {
private final K key;
private final V value;
@@ -847,7 +847,7 @@ public class NamespaceHandlerRegistryImp
if (key == null) {
throw new NullPointerException();
}
- for (Entry<K,V> e : entries) {
+ for (Entry<K, V> e : entries) {
if (e.getKey().equals(key)) {
entries.remove(e);
entries.addFirst(e);
@@ -862,7 +862,7 @@ public class NamespaceHandlerRegistryImp
throw new NullPointerException();
}
V old = null;
- for (Entry<K,V> e : entries) {
+ for (Entry<K, V> e : entries) {
if (e.getKey().equals(key)) {
entries.remove(e);
old = e.getValue();
@@ -870,7 +870,7 @@ public class NamespaceHandlerRegistryImp
}
}
if (value != null) {
- entries.addFirst(new LRUEntry<K,V>(key, value));
+ entries.addFirst(new LRUEntry<K, V>(key, value));
while (entries.size() > bound) {
entries.removeLast();
}
@@ -879,7 +879,7 @@ public class NamespaceHandlerRegistryImp
}
public Set<Entry<K, V>> entrySet() {
- return new AbstractSet<Entry<K,V>>() {
+ return new AbstractSet<Entry<K, V>>() {
public Iterator<Entry<K, V>> iterator() {
return entries.iterator();
}
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/Collaborator.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/Collaborator.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/Collaborator.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/Collaborator.java Wed Jan 31 20:10:03 2018
@@ -52,33 +52,30 @@ public class Collaborator implements Inv
/**
* Invoke the preCall method on the interceptor
- *
- * @param o
- * : The Object being invoked
- * @param m
- * : method
- * @param parameters
- * : method paramters
+ *
+ * @param o : The Object being invoked
+ * @param m : method
+ * @param parameters : method paramters
* @throws Throwable
*/
public Object preInvoke(Object o, Method m, Object[] parameters)
throws Throwable {
Deque<StackElement> stack = new ArrayDeque<StackElement>(interceptors.size());
if (interceptors != null) {
- try{
- for (Interceptor im : interceptors) {
- Collaborator.StackElement se = new StackElement(im);
+ try {
+ for (Interceptor im : interceptors) {
+ Collaborator.StackElement se = new StackElement(im);
- // should we do this before or after the preCall ?
- stack.push(se);
+ // should we do this before or after the preCall ?
+ stack.push(se);
- // allow exceptions to propagate
- se.setPreCallToken(im.preCall(cm, m, parameters));
+ // allow exceptions to propagate
+ se.setPreCallToken(im.preCall(cm, m, parameters));
+ }
+ } catch (Throwable t) {
+ postInvokeExceptionalReturn(stack, o, m, t);
+ throw t;
}
- } catch (Throwable t) {
- postInvokeExceptionalReturn(stack, o, m, t);
- throw t;
- }
}
return stack;
}
@@ -86,12 +83,12 @@ public class Collaborator implements Inv
/**
* Called when the method is called and returned normally
*/
- public void postInvoke(Object token, Object o, Method method,
- Object returnType) throws Throwable {
-
+ public void postInvoke(Object token, Object o, Method method,
+ Object returnType) throws Throwable {
+
Deque<StackElement> calledInterceptors =
- (Deque<StackElement>) token;
- if(calledInterceptors != null) {
+ (Deque<StackElement>) token;
+ if (calledInterceptors != null) {
while (!calledInterceptors.isEmpty()) {
Collaborator.StackElement se = calledInterceptors.pop();
try {
@@ -111,10 +108,10 @@ public class Collaborator implements Inv
* Called when the method is called and returned with an exception
*/
public void postInvokeExceptionalReturn(Object token, Object o, Method method,
- Throwable exception) throws Throwable {
+ Throwable exception) throws Throwable {
Throwable tobeRethrown = null;
Deque<StackElement> calledInterceptors =
- (Deque<StackElement>) token;
+ (Deque<StackElement>) token;
while (!calledInterceptors.isEmpty()) {
Collaborator.StackElement se = calledInterceptors.pop();
@@ -127,7 +124,7 @@ public class Collaborator implements Inv
if (tobeRethrown == null) {
tobeRethrown = t;
} else {
- LOGGER.warn("Discarding post-call with interceptor exception", t);
+ LOGGER.warn("Discarding post-call with interceptor exception", t);
}
}
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/ProxyUtils.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/ProxyUtils.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/ProxyUtils.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/ProxyUtils.java Wed Jan 31 20:10:03 2018
@@ -22,29 +22,26 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
-public class ProxyUtils
-{
- public static final Callable<Object> passThrough(final Object target)
- {
- return new Callable<Object>() {
- public Object call() throws Exception {
- return target;
- }
- };
- }
-
- public static final List<Class<?>> asList(Class<?> ... classesArray)
- {
- List<Class<?>> classes = new ArrayList<Class<?>>();
- for (Class<?> clazz : classesArray) {
- classes.add(clazz);
+public class ProxyUtils {
+ public static final Callable<Object> passThrough(final Object target) {
+ return new Callable<Object>() {
+ public Object call() throws Exception {
+ return target;
+ }
+ };
+ }
+
+ public static final List<Class<?>> asList(Class<?>... classesArray) {
+ List<Class<?>> classes = new ArrayList<Class<?>>();
+ for (Class<?> clazz : classesArray) {
+ classes.add(clazz);
+ }
+ return classes;
+ }
+
+ public static final List<Class<?>> asList(Class<?> clazz) {
+ List<Class<?>> classes = new ArrayList<Class<?>>();
+ classes.add(clazz);
+ return classes;
}
- return classes;
- }
- public static final List<Class<?>> asList(Class<?> clazz)
- {
- List<Class<?>> classes = new ArrayList<Class<?>>();
- classes.add(clazz);
- return classes;
- }
}
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/SingleInterceptorCollaborator.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/SingleInterceptorCollaborator.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/SingleInterceptorCollaborator.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/SingleInterceptorCollaborator.java Wed Jan 31 20:10:03 2018
@@ -56,9 +56,9 @@ public class SingleInterceptorCollaborat
throws Throwable {
Object callToken = NON_INVOKED;
try {
- callToken = interceptor.preCall(cm, m, parameters);
+ callToken = interceptor.preCall(cm, m, parameters);
} catch (Throwable t) {
- // using null token here to be consistent with what Collaborator does
+ // using null token here to be consistent with what Collaborator does
postInvokeExceptionalReturn(null, o, m, t);
throw t;
}
@@ -68,10 +68,10 @@ public class SingleInterceptorCollaborat
/**
* Called when the method is called and returned normally
*/
- public void postInvoke(Object token, Object o, Method method,
- Object returnType) throws Throwable {
+ public void postInvoke(Object token, Object o, Method method,
+ Object returnType) throws Throwable {
- if(token != NON_INVOKED) {
+ if (token != NON_INVOKED) {
try {
interceptor.postCallWithReturn(cm, method, returnType, token);
} catch (Throwable t) {
@@ -85,7 +85,7 @@ public class SingleInterceptorCollaborat
* Called when the method is called and returned with an exception
*/
public void postInvokeExceptionalReturn(Object token, Object o, Method method,
- Throwable exception) throws Throwable {
+ Throwable exception) throws Throwable {
try {
interceptor.postCallWithException(cm, method, exception, token);
} catch (Throwable t) {
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/ExtendedBlueprintContainer.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/ExtendedBlueprintContainer.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/ExtendedBlueprintContainer.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/ExtendedBlueprintContainer.java Wed Jan 31 20:10:03 2018
@@ -72,8 +72,8 @@ public interface ExtendedBlueprintContai
* Throws IllegalArgumentException if the bean metadata does not exist in this blueprint container
* Throws ComponentDefinitionException if the injection process fails - this may have rendered the supplied Object unusable by partially completing the injection process
*/
- void injectBeanInstance(BeanMetadata bmd, Object o)
- throws IllegalArgumentException, ComponentDefinitionException;
+ void injectBeanInstance(BeanMetadata bmd, Object o)
+ throws IllegalArgumentException, ComponentDefinitionException;
ExecutorService getExecutors();
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/ParserService.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/ParserService.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/ParserService.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/ParserService.java Wed Jan 31 20:10:03 2018
@@ -25,64 +25,64 @@ import org.apache.aries.blueprint.Compon
import org.osgi.framework.Bundle;
public interface ParserService {
-
- /**
- * Parse a single InputStream containing blueprint xml. No validation will be performed. The caller
- * is responsible for closing the InputStream afterwards.
- * @param is InputStream containing blueprint xml.
- * @param clientBundle The client's bundle
- * @return ComponentDefinitionRegistry containing metadata generated by the parser.
- * @throws Exception
- */
- ComponentDefinitionRegistry parse (InputStream is, Bundle clientBundle) throws Exception;
-
- /**
- * Parse a single InputStream containing blueprint xml. The caller is responsible for
- * closing the InputStream afterwards.
- * @param is Input stream containing blueprint xml
- * @param clientBundle The client's bundle
- * @param validate Indicates whether or not to validate the blueprint xml
- * @return ComponentDefinitionRegistry containing metadata generated by the parser.
- * @throws Exception
- */
- ComponentDefinitionRegistry parse (InputStream is, Bundle clientBundle, boolean validate) throws Exception;
-
- /**
- * Parse blueprint xml referred to by a single URL. No validation will be performed.
- * @param url URL reference to the blueprint xml to parse
- * @param clientBundle The client's bundle
- * @return ComponentDefinitionRegistry containing metadata generated by the parser.
- * @throws Exception
- */
- ComponentDefinitionRegistry parse (URL url, Bundle clientBundle) throws Exception;
-
- /**
- * Parse blueprint xml referred to by a single URL.
- * @param url URL reference to the blueprint xml to parse
- * @param clientBundle The client's bundle
- * @param validate Indicates whether or not to validate the blueprint xml
- * @return ComponentDefinitionRegistry containing metadata generated by the parser.
- * @throws Exception
- */
- ComponentDefinitionRegistry parse (URL url, Bundle clientBundle, boolean validate) throws Exception;
-
- /**
- * Parse blueprint xml referred to by a list of URLs. No validation will be performed.
- * @param urls URL reference to the blueprint xml to parse
- * @param clientBundle The client's bundle
- * @return ComponentDefinitionRegistry containing metadata generated by the parser.
- * @throws Exception
- */
- ComponentDefinitionRegistry parse (List<URL> urls, Bundle clientBundle) throws Exception;
-
- /**
- * Parse blueprint xml referred to by a list of URLs.
- * @param urls URL reference to the blueprint xml to parse
- * @param clientBundle The client's bundle
- * @param validate Indicates whether or not to validate the blueprint xml
- * @return ComponentDefinitionRegistry containing metadata generated by the parser.
- * @throws Exception
- */
- ComponentDefinitionRegistry parse (List<URL> urls, Bundle clientBundle, boolean validate) throws Exception;
-
+
+ /**
+ * Parse a single InputStream containing blueprint xml. No validation will be performed. The caller
+ * is responsible for closing the InputStream afterwards.
+ * @param is InputStream containing blueprint xml.
+ * @param clientBundle The client's bundle
+ * @return ComponentDefinitionRegistry containing metadata generated by the parser.
+ * @throws Exception
+ */
+ ComponentDefinitionRegistry parse(InputStream is, Bundle clientBundle) throws Exception;
+
+ /**
+ * Parse a single InputStream containing blueprint xml. The caller is responsible for
+ * closing the InputStream afterwards.
+ * @param is Input stream containing blueprint xml
+ * @param clientBundle The client's bundle
+ * @param validate Indicates whether or not to validate the blueprint xml
+ * @return ComponentDefinitionRegistry containing metadata generated by the parser.
+ * @throws Exception
+ */
+ ComponentDefinitionRegistry parse(InputStream is, Bundle clientBundle, boolean validate) throws Exception;
+
+ /**
+ * Parse blueprint xml referred to by a single URL. No validation will be performed.
+ * @param url URL reference to the blueprint xml to parse
+ * @param clientBundle The client's bundle
+ * @return ComponentDefinitionRegistry containing metadata generated by the parser.
+ * @throws Exception
+ */
+ ComponentDefinitionRegistry parse(URL url, Bundle clientBundle) throws Exception;
+
+ /**
+ * Parse blueprint xml referred to by a single URL.
+ * @param url URL reference to the blueprint xml to parse
+ * @param clientBundle The client's bundle
+ * @param validate Indicates whether or not to validate the blueprint xml
+ * @return ComponentDefinitionRegistry containing metadata generated by the parser.
+ * @throws Exception
+ */
+ ComponentDefinitionRegistry parse(URL url, Bundle clientBundle, boolean validate) throws Exception;
+
+ /**
+ * Parse blueprint xml referred to by a list of URLs. No validation will be performed.
+ * @param urls URL reference to the blueprint xml to parse
+ * @param clientBundle The client's bundle
+ * @return ComponentDefinitionRegistry containing metadata generated by the parser.
+ * @throws Exception
+ */
+ ComponentDefinitionRegistry parse(List<URL> urls, Bundle clientBundle) throws Exception;
+
+ /**
+ * Parse blueprint xml referred to by a list of URLs.
+ * @param urls URL reference to the blueprint xml to parse
+ * @param clientBundle The client's bundle
+ * @param validate Indicates whether or not to validate the blueprint xml
+ * @return ComponentDefinitionRegistry containing metadata generated by the parser.
+ * @throws Exception
+ */
+ ComponentDefinitionRegistry parse(List<URL> urls, Bundle clientBundle, boolean validate) throws Exception;
+
}
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/BundleDelegatingClassLoader.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/BundleDelegatingClassLoader.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/BundleDelegatingClassLoader.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/BundleDelegatingClassLoader.java Wed Jan 31 20:10:03 2018
@@ -56,27 +56,25 @@ public class BundleDelegatingClassLoader
protected Class<?> findClass(final String name) throws ClassNotFoundException {
try {
return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
- public Class<?> run() throws ClassNotFoundException
- {
+ public Class<?> run() throws ClassNotFoundException {
return bundle.loadClass(name);
}
-
+
});
} catch (PrivilegedActionException e) {
Exception cause = e.getException();
- if (cause instanceof ClassNotFoundException) throw (ClassNotFoundException)cause;
- else throw (RuntimeException)cause;
- }
+ if (cause instanceof ClassNotFoundException) throw (ClassNotFoundException) cause;
+ else throw (RuntimeException) cause;
+ }
}
protected URL findResource(final String name) {
URL resource = AccessController.doPrivileged(new PrivilegedAction<URL>() {
- public URL run()
- {
+ public URL run() {
return bundle.getResource(name);
}
- });
+ });
if (classLoader != null && resource == null) {
resource = classLoader.getResource(name);
}
@@ -86,26 +84,25 @@ public class BundleDelegatingClassLoader
protected Enumeration<URL> findResources(final String name) throws IOException {
Enumeration<URL> urls;
try {
- urls = AccessController.doPrivileged(new PrivilegedExceptionAction<Enumeration<URL>>() {
+ urls = AccessController.doPrivileged(new PrivilegedExceptionAction<Enumeration<URL>>() {
@SuppressWarnings("unchecked")
- public Enumeration<URL> run() throws IOException
- {
- return (Enumeration<URL>)bundle.getResources(name);
+ public Enumeration<URL> run() throws IOException {
+ return (Enumeration<URL>) bundle.getResources(name);
}
});
} catch (PrivilegedActionException e) {
Exception cause = e.getException();
- if (cause instanceof IOException) throw (IOException)cause;
- else throw (RuntimeException)cause;
+ if (cause instanceof IOException) throw (IOException) cause;
+ else throw (RuntimeException) cause;
}
if (urls == null) {
urls = Collections.enumeration(new ArrayList<URL>());
}
- return urls;
+ return urls;
}
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/HeaderParser.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/HeaderParser.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/HeaderParser.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/HeaderParser.java Wed Jan 31 20:10:03 2018
@@ -28,7 +28,7 @@ import java.util.Map;
*
* @version $Rev$, $Date$
*/
-public class HeaderParser {
+public class HeaderParser {
/**
* Parse a given OSGi header into a list of paths
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/JavaUtils.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/JavaUtils.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/JavaUtils.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/JavaUtils.java Wed Jan 31 20:10:03 2018
@@ -52,7 +52,7 @@ public final class JavaUtils {
public static Version getBundleVersion(Bundle bundle) {
Dictionary headers = bundle.getHeaders();
- String version = (String)headers.get(Constants.BUNDLE_VERSION);
+ String version = (String) headers.get(Constants.BUNDLE_VERSION);
return (version != null) ? Version.parseVersion(version) : Version.emptyVersion;
}
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/ReflectionUtils.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/ReflectionUtils.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/ReflectionUtils.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/ReflectionUtils.java Wed Jan 31 20:10:03 2018
@@ -211,8 +211,8 @@ public class ReflectionUtils {
if (properties[index] == null) {
Set<String> propertyNames = new HashSet<String>();
- Map<String,Method> getters = new HashMap<String, Method>();
- Map<String,List<Method>> setters = new HashMap<String, List<Method>>();
+ Map<String, Method> getters = new HashMap<String, Method>();
+ Map<String, List<Method>> setters = new HashMap<String, List<Method>>();
Set<String> illegalProperties = new HashSet<String>();
for (Method method : getPublicMethods(clazz)) {
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/ServiceUtil.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/ServiceUtil.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/ServiceUtil.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/ServiceUtil.java Wed Jan 31 20:10:03 2018
@@ -23,14 +23,13 @@ public final class ServiceUtil {
private ServiceUtil() {
}
- public static void safeUnregisterService(ServiceRegistration<?> reg)
- {
- if(reg != null) {
- try {
- reg.unregister();
- } catch (IllegalStateException e) {
- //This can be safely ignored
+ public static void safeUnregisterService(ServiceRegistration<?> reg) {
+ if (reg != null) {
+ try {
+ reg.unregister();
+ } catch (IllegalStateException e) {
+ //This can be safely ignored
+ }
}
- }
}
}
Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/generics/ClassUtil.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/generics/ClassUtil.java?rev=1822826&r1=1822825&r2=1822826&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/generics/ClassUtil.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/generics/ClassUtil.java Wed Jan 31 20:10:03 2018
@@ -28,22 +28,20 @@ import java.util.*;
* @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
* @since 1.0
*/
-public final class ClassUtil
-{
+public final class ClassUtil {
public static final Map<Class<?>, Class<?>> PRIMITIVE_TO_WRAPPERS_MAP;
- static
- {
+ static {
Map<Class<?>, Class<?>> primitiveToWrappersMap = new HashMap<Class<?>, Class<?>>();
- primitiveToWrappersMap.put(Integer.TYPE,Integer.class);
- primitiveToWrappersMap.put(Float.TYPE,Float.class);
- primitiveToWrappersMap.put(Double.TYPE,Double.class);
- primitiveToWrappersMap.put(Character.TYPE,Character.class);
- primitiveToWrappersMap.put(Long.TYPE,Long.class);
- primitiveToWrappersMap.put(Byte.TYPE,Byte.class);
- primitiveToWrappersMap.put(Short.TYPE,Short.class);
- primitiveToWrappersMap.put(Boolean.TYPE,Boolean.class);
- primitiveToWrappersMap.put(Void.TYPE,Void.class);
+ primitiveToWrappersMap.put(Integer.TYPE, Integer.class);
+ primitiveToWrappersMap.put(Float.TYPE, Float.class);
+ primitiveToWrappersMap.put(Double.TYPE, Double.class);
+ primitiveToWrappersMap.put(Character.TYPE, Character.class);
+ primitiveToWrappersMap.put(Long.TYPE, Long.class);
+ primitiveToWrappersMap.put(Byte.TYPE, Byte.class);
+ primitiveToWrappersMap.put(Short.TYPE, Short.class);
+ primitiveToWrappersMap.put(Boolean.TYPE, Boolean.class);
+ primitiveToWrappersMap.put(Void.TYPE, Void.class);
PRIMITIVE_TO_WRAPPERS_MAP = Collections.unmodifiableMap(primitiveToWrappersMap);
}
@@ -52,26 +50,21 @@ public final class ClassUtil
/*
* Private constructor
*/
- private ClassUtil()
- {
+ private ClassUtil() {
throw new UnsupportedOperationException();
}
- public static boolean isSame(Type type1, Type type2)
- {
- if ((type1 instanceof Class) && ((Class<?>)type1).isPrimitive())
- {
+ public static boolean isSame(Type type1, Type type2) {
+ if ((type1 instanceof Class) && ((Class<?>) type1).isPrimitive()) {
type1 = PRIMITIVE_TO_WRAPPERS_MAP.get(type1);
}
- if ((type2 instanceof Class) && ((Class<?>)type2).isPrimitive())
- {
+ if ((type2 instanceof Class) && ((Class<?>) type2).isPrimitive()) {
type2 = PRIMITIVE_TO_WRAPPERS_MAP.get(type2);
}
return type1 == type2;
}
- public static Class<?> getPrimitiveWrapper(Class<?> clazz)
- {
+ public static Class<?> getPrimitiveWrapper(Class<?> clazz) {
return PRIMITIVE_TO_WRAPPERS_MAP.get(clazz);
}
@@ -148,76 +141,52 @@ public final class ClassUtil
/**
* Return raw class type for given type.
+ *
* @param type base type instance
* @return class type for given type
*/
- public static Class<?> getClazz(Type type)
- {
- if(type instanceof ParameterizedType)
- {
- ParameterizedType pt = (ParameterizedType)type;
- return (Class<?>)pt.getRawType();
- }
- else if(type instanceof Class)
- {
- return (Class<?>)type;
- }
- else if(type instanceof GenericArrayType)
- {
- GenericArrayType arrayType = (GenericArrayType)type;
+ public static Class<?> getClazz(Type type) {
+ if (type instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) type;
+ return (Class<?>) pt.getRawType();
+ } else if (type instanceof Class) {
+ return (Class<?>) type;
+ } else if (type instanceof GenericArrayType) {
+ GenericArrayType arrayType = (GenericArrayType) type;
return Array.newInstance(getClazz(arrayType.getGenericComponentType()), 0).getClass();
- }
- else if (type instanceof WildcardType)
- {
- WildcardType wildcardType = (WildcardType)type;
+ } else if (type instanceof WildcardType) {
+ WildcardType wildcardType = (WildcardType) type;
Type[] bounds = wildcardType.getUpperBounds();
- if (bounds.length > 1)
- {
+ if (bounds.length > 1) {
throw new IllegalArgumentException("Illegal use of wild card type with more than one upper bound: " + wildcardType);
- }
- else if (bounds.length == 0)
- {
+ } else if (bounds.length == 0) {
return Object.class;
- }
- else
- {
+ } else {
return getClass(bounds[0]);
}
- }
- else if (type instanceof TypeVariable)
- {
- TypeVariable<?> typeVariable = (TypeVariable<?>)type;
- if (typeVariable.getBounds().length > 1)
- {
+ } else if (type instanceof TypeVariable) {
+ TypeVariable<?> typeVariable = (TypeVariable<?>) type;
+ if (typeVariable.getBounds().length > 1) {
throw new IllegalArgumentException("Illegal use of type variable with more than one bound: " + typeVariable);
- }
- else
- {
+ } else {
Type[] bounds = typeVariable.getBounds();
- if (bounds.length == 0)
- {
+ if (bounds.length == 0) {
return Object.class;
- }
- else
- {
+ } else {
return getClass(bounds[0]);
}
}
- }
- else
- {
+ } else {
throw new IllegalArgumentException("Unsupported type " + type);
}
}
- public static boolean isRawClassEquals(Type ipType, Type apiType)
- {
+ public static boolean isRawClassEquals(Type ipType, Type apiType) {
Class ipClass = getRawPrimitiveType(ipType);
- Class apiClass = getRawPrimitiveType(apiType);
+ Class apiClass = getRawPrimitiveType(apiType);
- if (ipClass == null || apiClass == null)
- {
+ if (ipClass == null || apiClass == null) {
// we found some illegal generics
return false;
}
@@ -225,19 +194,15 @@ public final class ClassUtil
return ipClass.equals(apiClass);
}
- private static Class getRawPrimitiveType(Type type)
- {
- if (type instanceof Class)
- {
- if (((Class) type).isPrimitive())
- {
+ private static Class getRawPrimitiveType(Type type) {
+ if (type instanceof Class) {
+ if (((Class) type).isPrimitive()) {
return getPrimitiveWrapper((Class) type);
}
return (Class) type;
}
- if (type instanceof ParameterizedType)
- {
+ if (type instanceof ParameterizedType) {
return getRawPrimitiveType(((ParameterizedType) type).getRawType());
}