Package java.util.concurrent

Examples of java.util.concurrent.ConcurrentHashMap$MapEntry


            interfaces[i] = ((JavaClass) args[i]).javaClass();
        }

        return JavaObject.wrap(recv.getRuntime(), Proxy.newProxyInstance(recv.getRuntime().getJRubyClassLoader(), interfaces, new InvocationHandler() {

            private Map parameterTypeCache = new ConcurrentHashMap();

            public Object invoke(Object proxy, Method method, Object[] nargs) throws Throwable {
                Class[] parameterTypes = (Class[]) parameterTypeCache.get(method);
                if (parameterTypes == null) {
                    parameterTypes = method.getParameterTypes();
                    parameterTypeCache.put(method, parameterTypes);
                }
                int methodArgsLength = parameterTypes.length;
                String methodName = method.getName();

                if (methodName.equals("toString") && methodArgsLength == 0) {
View Full Code Here


            } catch (IllegalAccessException iae) {
                throw runtime.newTypeError("Exception instantiating generated interface impl:\n" + iae);
            }
        } else {
            return JavaObject.wrap(recv.getRuntime(), Proxy.newProxyInstance(recv.getRuntime().getJRubyClassLoader(), interfaces, new InvocationHandler() {
                private Map parameterTypeCache = new ConcurrentHashMap();

                public Object invoke(Object proxy, Method method, Object[] nargs) throws Throwable {
                    String methodName = method.getName();
                    int length = nargs == null ? 0 : nargs.length;

                    // FIXME: wtf is this? Why would these use the class?
                    if (methodName == "toString" && length == 0) {
                        return proxy.getClass().getName();
                    } else if (methodName == "hashCode" && length == 0) {
                        return new Integer(proxy.getClass().hashCode());
                    } else if (methodName == "equals" && length == 1) {
                        Class[] parameterTypes = (Class[]) parameterTypeCache.get(method);
                        if (parameterTypes == null) {
                            parameterTypes = method.getParameterTypes();
                            parameterTypeCache.put(method, parameterTypes);
                        }
                        if (parameterTypes[0].equals(Object.class)) {
                            return Boolean.valueOf(proxy == nargs[0]);
                        }
                    }
View Full Code Here

    private String TOPIC_PREFIX = "topic.";

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public Context getInitialContext(Hashtable environment) throws NamingException
    {
        Map data = new ConcurrentHashMap();
        BufferedInputStream inputStream = null;
        try
        {

            String fileName = (environment.containsKey(Context.PROVIDER_URL))
View Full Code Here

     * @param bundleContext The <code>BundleContext</code> ultimately used to
     *      access services if there are no meta type documents.
     */
    MetaTypeServiceImpl( BundleContext bundleContext )
    {
        this.bundleMetaTypeInformation = new ConcurrentHashMap();

        bundleContext.addBundleListener( this );

        ManagedServiceTracker mst = null;
        try
View Full Code Here

                  continue;
               }
            }

            Map<String, ProtocolManager> supportedProtocols = new ConcurrentHashMap();

            String protocol = ConfigurationHelper.getStringProperty(TransportConstants.PROTOCOL_PROP_NAME, null,
                                                                    info.getParams());

            if (protocol != null)
            {
               HornetQServerLogger.LOGGER.warnDeprecatedProtocol();
               ProtocolManager protocolManager = protocolMap.get(protocol);

               if (protocolManager == null)
               {
                  throw HornetQMessageBundle.BUNDLE.noProtocolManagerFound(protocol);
               }
               else
               {
                  supportedProtocols.put(protocol, protocolManager);
               }
            }

            String protocols = ConfigurationHelper.getStringProperty(TransportConstants.PROTOCOLS_PROP_NAME, null,
                                                                     info.getParams());

            if (protocols != null)
            {
               String[] actualProtocols = protocols.split(",");

               if (actualProtocols != null)
               {
                  for (String actualProtocol : actualProtocols)
                  {
                     ProtocolManager protocolManager = protocolMap.get(actualProtocol);

                     if (protocolManager == null)
                     {
                        throw HornetQMessageBundle.BUNDLE.noProtocolManagerFound(actualProtocol);
                     }
                     else
                     {
                        supportedProtocols.put(actualProtocol, protocolManager);
                     }
                  }
               }
            }

            ClusterConnection clusterConnection = lookupClusterConnection(info);

            Acceptor acceptor = factory.createAcceptor(info.getName(),
                                                       clusterConnection,
                                                       info.getParams(),
                                                       new DelegatingBufferHandler(),
                                                       this,
                                                       threadPool,
                                                       scheduledThreadPool,
                                                       supportedProtocols.isEmpty() ? protocolMap : supportedProtocols);

            if (defaultInvmSecurityPrincipal != null && acceptor.isUnsecurable())
            {
               acceptor.setDefaultHornetQPrincipal(defaultInvmSecurityPrincipal);
            }
View Full Code Here

            bv = ((OpenJPAConfigurationImpl) _conf).brokerPlugin;
        else
            bv = (BrokerValue) _conf.getValue(BrokerValue.KEY);

        if (FinalizingBrokerImpl.class.isAssignableFrom(bv.getTemplateBrokerType(_conf))) {
            return MapBackedSet.decorate(new ConcurrentHashMap(), new Object() { });
        } else {
            return new ConcurrentReferenceHashSet<Broker>(ConcurrentReferenceHashSet.WEAK);
        }
    }
View Full Code Here

      hashMap =  new HashMap();
      populateMap(hashMap);
      System.out.println("HashMap "+(System.currentTimeMillis()-start));
     
      start=System.currentTimeMillis();
      syncMap = new ConcurrentHashMap();
      populateMap(syncMap);
      System.out.println("ConcurrentHashMap "+(System.currentTimeMillis()-start));
     
     
     
View Full Code Here

    System.out.println("hashMap " + mem + " bytes");
    hashMap.clear();
   
    // repeat for ConcurrentHashMap
    mem = displayMemoryRuntime();
    syncMap = new ConcurrentHashMap();
    populateMap(syncMap);    
    mem = displayMemoryRuntime() - mem;    
    System.out.println("ConcurrentHashMap " + mem + " bytes");
    syncMap.clear();
   
View Full Code Here

    return Boolean.valueOf(monitor_nodes(caller, on, opts));
  }

  public static boolean monitor_nodes(EHandle caller, boolean on, int opts) {
    if (on) nodes_monitors.putIfAbsent(caller, new ConcurrentHashMap());
    ConcurrentHashMap<Integer,AtomicInteger> forHandle = nodes_monitors.get(caller);
    if (forHandle==null) return false; // We're disabling but entry wasn't there.

    if (on) {
      forHandle.putIfAbsent(opts, new AtomicInteger(0));
View Full Code Here

public class ConcurrentTest extends AbstractTest {

  public void testConcurrent() {
    // Should not generate a warning
    ConcurrentHashMap map = new ConcurrentHashMap();

    assertNotNull("testConcurrent", map);
  }
View Full Code Here

TOP

Related Classes of java.util.concurrent.ConcurrentHashMap$MapEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.