Java 类com.hazelcast.core.HazelcastInstanceAware 实例源码

项目:hazelcast-archive    文件:Serializer.java   
public Object readObject(final Data data) {
    if ((data == null) || (data.buffer == null) || (data.buffer.length == 0)) {
        return null;
    }
    byte[] byteArray = data.buffer;
    final Object obj = toObject(byteArray);
    if (obj instanceof HazelcastInstanceAware) {
        ((HazelcastInstanceAware) obj).setHazelcastInstance(ThreadContext.get().getCurrentFactory());
    }
    return obj;
}
项目:health-and-care-developer-network    文件:HazelcastManagedContext.java   
public final Object initialize(Object obj) {
    if (obj instanceof HazelcastInstanceAware) {
        ((HazelcastInstanceAware) obj).setHazelcastInstance(factory);
    }

    if (hasExternalContext) {
        obj = externalContext.initialize(obj);
    }
    return obj;
}
项目:castmapr    文件:AbstractMapReduceTask.java   
protected Map<KeyOut, ValueOut> finalReduceStep( Map<KeyOut, List<ValueOut>> groupedResponses )
{
    Map<KeyOut, ValueOut> reducedResults = new HashMap<KeyOut, ValueOut>();

    if ( reducer instanceof HazelcastInstanceAware )
    {
        ( (HazelcastInstanceAware) reducer ).setHazelcastInstance( hazelcastInstance );
    }

    // Final local reduce step
    for ( Entry<KeyOut, List<ValueOut>> entry : groupedResponses.entrySet() )
    {
        if ( isDistributableReducer() )
        {
            reducedResults.put( entry.getKey(), reducer.reduce( entry.getKey(), entry.getValue().iterator() ) );
        }
        else
        {
            List results = new ArrayList( groupedResponses.size() );
            for ( Object value : prepareIntermediateResults( entry.getValue() ) )
            {
                // Eventually aggregate subresults to one big result list
                if ( value instanceof List )
                {
                    for ( Object innerValue : ( (List) value ) )
                    {
                        results.add( innerValue );
                    }
                }
                else
                {
                    results.add( value );
                }
            }
            if ( reducer != null )
            {
                reducedResults.put( entry.getKey(), reducer.reduce( entry.getKey(), results.iterator() ) );
            }
            else
            {
                reducedResults.put( entry.getKey(), (ValueOut) results );
            }
        }
    }
    return reducedResults;
}