com.alibaba.dubbo.common.utils.Holder Java Examples
The following examples show how to use
com.alibaba.dubbo.common.utils.Holder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtensionLoader.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
/** * Find the extension with the given name. If the specified name is not found, then {@link IllegalStateException} * will be thrown.查找具有给定名称的扩展名。如果没有找到指定的名称,那么将抛出IllegalStateException。 */ @SuppressWarnings("unchecked") public T getExtension(String name) { if (name == null || name.length() == 0) throw new IllegalArgumentException("Extension name == null"); if ("true".equals(name)) { return getDefaultExtension(); } Holder<Object> holder = cachedInstances.get(name); if (holder == null) { cachedInstances.putIfAbsent(name, new Holder<Object>()); holder = cachedInstances.get(name); } Object instance = holder.get(); if (instance == null) { synchronized (holder) { instance = holder.get(); if (instance == null) { instance = createExtension(name); holder.set(instance); } } } return (T) instance; }
Example #2
Source File: ExtensionLoader.java From dubbox with Apache License 2.0 | 6 votes |
/** * 返回指定名字的扩展。如果指定名字的扩展不存在,则抛异常 {@link IllegalStateException}. * * @param name * @return */ @SuppressWarnings("unchecked") public T getExtension(String name) { if (name == null || name.length() == 0) throw new IllegalArgumentException("Extension name == null"); if ("true".equals(name)) { return getDefaultExtension(); } Holder<Object> holder = cachedInstances.get(name); if (holder == null) { cachedInstances.putIfAbsent(name, new Holder<Object>()); holder = cachedInstances.get(name); } Object instance = holder.get(); if (instance == null) { synchronized (holder) { instance = holder.get(); if (instance == null) { instance = createExtension(name); holder.set(instance); } } } return (T) instance; }
Example #3
Source File: ExtensionLoader.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
/** * 返回指定名字的扩展。如果指定名字的扩展不存在,则抛异常 {@link IllegalStateException}. * * @param name * @return */ @SuppressWarnings("unchecked") public T getExtension(String name) { if (name == null || name.length() == 0) throw new IllegalArgumentException("Extension name == null"); if ("true".equals(name)) { return getDefaultExtension(); } Holder<Object> holder = cachedInstances.get(name); if (holder == null) { cachedInstances.putIfAbsent(name, new Holder<Object>()); holder = cachedInstances.get(name); } Object instance = holder.get(); if (instance == null) { synchronized (holder) { instance = holder.get(); if (instance == null) { instance = createExtension(name); holder.set(instance); } } } return (T) instance; }
Example #4
Source File: ExtensionLoader.java From dubbo3 with Apache License 2.0 | 6 votes |
/** * 返回指定名字的扩展。如果指定名字的扩展不存在,则抛异常 {@link IllegalStateException}. * * @param name extension name * @return extension */ @SuppressWarnings("unchecked") public T getExtension(String name) { if (name == null || name.length() == 0) throw new IllegalArgumentException("Extension name == null"); if ("true".equals(name)) { return getDefaultExtension(); } Holder<Object> holder = cachedInstances.get(name); if (holder == null) { cachedInstances.putIfAbsent(name, new Holder<Object>()); holder = cachedInstances.get(name); } Object instance = holder.get(); if (instance == null) { synchronized (holder) { instance = holder.get(); if (instance == null) { instance = createExtension(name); holder.set(instance); } } } return (T) instance; }
Example #5
Source File: ExtensionLoader.java From dubbox with Apache License 2.0 | 6 votes |
/** * 返回指定名字的扩展。如果指定名字的扩展不存在,则抛异常 {@link IllegalStateException}. * * @param name * @return */ @SuppressWarnings("unchecked") public T getExtension(String name) { if (name == null || name.length() == 0) throw new IllegalArgumentException("Extension name == null"); if ("true".equals(name)) { return getDefaultExtension(); } Holder<Object> holder = cachedInstances.get(name); if (holder == null) { cachedInstances.putIfAbsent(name, new Holder<Object>()); holder = cachedInstances.get(name); } Object instance = holder.get(); if (instance == null) { synchronized (holder) { instance = holder.get(); if (instance == null) { instance = createExtension(name); holder.set(instance); } } } return (T) instance; }
Example #6
Source File: ExtensionLoader.java From dubbox with Apache License 2.0 | 6 votes |
/** * 返回指定名字的扩展。如果指定名字的扩展不存在,则抛异常 {@link IllegalStateException}. * * @param name * @return */ @SuppressWarnings("unchecked") public T getExtension(String name) { if (name == null || name.length() == 0) throw new IllegalArgumentException("Extension name == null"); if ("true".equals(name)) { return getDefaultExtension(); } Holder<Object> holder = cachedInstances.get(name); if (holder == null) { cachedInstances.putIfAbsent(name, new Holder<Object>()); holder = cachedInstances.get(name); } Object instance = holder.get(); if (instance == null) { synchronized (holder) { instance = holder.get(); if (instance == null) { instance = createExtension(name); holder.set(instance); } } } return (T) instance; }
Example #7
Source File: ExtensionLoader.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
/** * Get extension's instance. Return <code>null</code> if extension is not found or is not initialized. Pls. note * that this method will not trigger extension load. * <p> * In order to trigger extension load, call {@link #getExtension(String)} instead. * * @see #getExtension(String) * 得到扩展的实例。如果没有找到扩展名或没有初始化扩展名,则返回null。请注意,此方法不会触发扩展负载。 为了触发扩展负载,可以调用getExtension(String)。 */ @SuppressWarnings("unchecked") public T getLoadedExtension(String name) { if (name == null || name.length() == 0) throw new IllegalArgumentException("Extension name == null"); Holder<Object> holder = cachedInstances.get(name); if (holder == null) { cachedInstances.putIfAbsent(name, new Holder<Object>()); holder = cachedInstances.get(name); } return (T) holder.get(); }
Example #8
Source File: ExtensionLoader.java From dubbox with Apache License 2.0 | 5 votes |
/** * 返回扩展点实例,如果没有指定的扩展点或是还没加载(即实例化)则返回<code>null</code>。注意:此方法不会触发扩展点的加载。 * <p /> * 一般应该调用{@link #getExtension(String)}方法获得扩展,这个方法会触发扩展点加载。 * * @see #getExtension(String) */ @SuppressWarnings("unchecked") public T getLoadedExtension(String name) { if (name == null || name.length() == 0) throw new IllegalArgumentException("Extension name == null"); Holder<Object> holder = cachedInstances.get(name); if (holder == null) { cachedInstances.putIfAbsent(name, new Holder<Object>()); holder = cachedInstances.get(name); } return (T) holder.get(); }
Example #9
Source File: ExtensionLoader.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
/** * 返回扩展点实例,如果没有指定的扩展点或是还没加载(即实例化)则返回<code>null</code>。注意:此方法不会触发扩展点的加载。 * <p /> * 一般应该调用{@link #getExtension(String)}方法获得扩展,这个方法会触发扩展点加载。 * * @see #getExtension(String) */ @SuppressWarnings("unchecked") public T getLoadedExtension(String name) { if (name == null || name.length() == 0) throw new IllegalArgumentException("Extension name == null"); Holder<Object> holder = cachedInstances.get(name); if (holder == null) { cachedInstances.putIfAbsent(name, new Holder<Object>()); holder = cachedInstances.get(name); } return (T) holder.get(); }
Example #10
Source File: ExtensionLoader.java From dubbo3 with Apache License 2.0 | 5 votes |
/** * 返回扩展点实例,如果没有指定的扩展点或是还没加载(即实例化)则返回<code>null</code>。注意:此方法不会触发扩展点的加载。 * <p/> * 一般应该调用{@link #getExtension(String)}方法获得扩展,这个方法会触发扩展点加载。 * * @see #getExtension(String) */ @SuppressWarnings("unchecked") public T getLoadedExtension(String name) { if (name == null || name.length() == 0) throw new IllegalArgumentException("Extension name == null"); Holder<Object> holder = cachedInstances.get(name); if (holder == null) { cachedInstances.putIfAbsent(name, new Holder<Object>()); holder = cachedInstances.get(name); } return (T) holder.get(); }
Example #11
Source File: ExtensionLoader.java From dubbox with Apache License 2.0 | 5 votes |
/** * 返回扩展点实例,如果没有指定的扩展点或是还没加载(即实例化)则返回<code>null</code>。注意:此方法不会触发扩展点的加载。 * <p /> * 一般应该调用{@link #getExtension(String)}方法获得扩展,这个方法会触发扩展点加载。 * * @see #getExtension(String) */ @SuppressWarnings("unchecked") public T getLoadedExtension(String name) { if (name == null || name.length() == 0) throw new IllegalArgumentException("Extension name == null"); Holder<Object> holder = cachedInstances.get(name); if (holder == null) { cachedInstances.putIfAbsent(name, new Holder<Object>()); holder = cachedInstances.get(name); } return (T) holder.get(); }
Example #12
Source File: ExtensionLoader.java From dubbox with Apache License 2.0 | 5 votes |
/** * 返回扩展点实例,如果没有指定的扩展点或是还没加载(即实例化)则返回<code>null</code>。注意:此方法不会触发扩展点的加载。 * <p /> * 一般应该调用{@link #getExtension(String)}方法获得扩展,这个方法会触发扩展点加载。 * * @see #getExtension(String) */ @SuppressWarnings("unchecked") public T getLoadedExtension(String name) { if (name == null || name.length() == 0) throw new IllegalArgumentException("Extension name == null"); Holder<Object> holder = cachedInstances.get(name); if (holder == null) { cachedInstances.putIfAbsent(name, new Holder<Object>()); holder = cachedInstances.get(name); } return (T) holder.get(); }