@SuppressWarnings("unchecked")
  @Override
  public TransactionalObject getTransactionalObject(String serviceName, String name) {
    if (transaction.getState() != Transaction.State.ACTIVE) {
      throw new TransactionNotActiveException(
          "No transaction is found while accessing "
              + "transactional object -> "
              + serviceName
              + "["
              + name
              + "]!");
    }
    TransactionalObjectKey key = new TransactionalObjectKey(serviceName, name);
    TransactionalObject obj = txnObjectMap.get(key);
    if (obj != null) {
      return obj;
    }

    final Object service = nodeEngine.getService(serviceName);
    if (service instanceof TransactionalService) {
      nodeEngine.getProxyService().initializeDistributedObject(serviceName, name);
      obj = ((TransactionalService) service).createTransactionalObject(name, transaction);
      txnObjectMap.put(key, obj);
    } else {
      throw new IllegalArgumentException("Service[" + serviceName + "] is not transactional!");
    }
    return obj;
  }
예제 #2
0
 private void initializeListeners(Config config) {
   for (final ListenerConfig listenerCfg : config.getListenerConfigs()) {
     Object listener = listenerCfg.getImplementation();
     if (listener == null) {
       try {
         listener = ClassLoaderUtil.newInstance(configClassLoader, listenerCfg.getClassName());
       } catch (Exception e) {
         logger.severe(e);
       }
     }
     if (listener instanceof HazelcastInstanceAware) {
       ((HazelcastInstanceAware) listener).setHazelcastInstance(hazelcastInstance);
     }
     if (listener instanceof DistributedObjectListener) {
       final ProxyServiceImpl proxyService = (ProxyServiceImpl) nodeEngine.getProxyService();
       proxyService.addProxyListener((DistributedObjectListener) listener);
     } else if (listener instanceof MembershipListener) {
       clusterService.addMembershipListener((MembershipListener) listener);
     } else if (listener instanceof MigrationListener) {
       partitionService.addMigrationListener((MigrationListener) listener);
     } else if (listener instanceof LifecycleListener) {
       hazelcastInstance.lifecycleService.addLifecycleListener((LifecycleListener) listener);
     } else if (listener != null) {
       final String error = "Unknown listener type: " + listener.getClass();
       Throwable t = new IllegalArgumentException(error);
       logger.warning(error, t);
     }
   }
 }
예제 #3
0
 @Override
 public ProxyService getProxyService() {
   return nodeEngine.getProxyService();
 }