Ejemplo n.º 1
0
  public void remove(final Context context, final Scope scope) {
    if (Scope.GLOBAL.equals(scope)) {
      throw new IllegalArgumentException("The context type or Scope Type must be not GLOBAL");
    }
    if (scope.getId() == null) {
      throw new IllegalArgumentException(
          "The id property of your scope parameter  must be not null");
    }

    new SynchronizationTask<Object>() {
      @Override
      protected Object execute(SessionContext ctx) {
        ScopeEntity scopeEntity = getScope(context, scope);
        if (scopeEntity != null) {
          scopeEntity.remove();
        }
        return null;
      }
    }.executeWith(chromatticLifeCycle);

    SettingData data =
        new SettingData(EventType.SETTING_REMOVE_SCOPE, new SettingScope(context, scope));
    eventManager.broadcastEvent(
        new Event<SettingServiceImpl, SettingData>(data.getEventType().toString(), this, data));
  }
Ejemplo n.º 2
0
  public void remove(final Context context) {
    if (Context.GLOBAL.equals(context)) {
      throw new IllegalArgumentException("The context type must be not GLOBAL");
    }
    if (context.getId() == null) {
      throw new IllegalArgumentException(
          "The id property of your context parameter must be not null");
    }
    new SynchronizationTask<Object>() {
      @Override
      protected Object execute(SessionContext ctx) {
        ContextEntity contextEntity = getContext(context);
        if (contextEntity != null) {
          contextEntity.remove();
        }
        return null;
      }
    }.executeWith(chromatticLifeCycle);
    SettingData data =
        new SettingData(EventType.SETTING_REMOVE_CONTEXT, new SettingContext(context));
    eventManager.broadcastEvent(
        new Event<SettingServiceImpl, SettingData>(data.getEventType().toString(), this, data));
    // TODO Auto-generated catch block

  }
Ejemplo n.º 3
0
 @Override
 public void remove(final Context c, final Scope s, final String key) {
   new SynchronizationTask<Object>() {
     @Override
     protected Object execute(SessionContext ctx) {
       ScopeEntity scope = getScope(c, s);
       if (scope == null) {
         return null; // Property doesn't exist
       } else {
         return scope.removeValue(key);
       }
     }
   }.executeWith(chromatticLifeCycle);
   SettingData data = new SettingData(EventType.SETTING_REMOVE_KEY, new SettingKey(c, s, key));
   eventManager.broadcastEvent(
       new Event<SettingServiceImpl, SettingData>(data.getEventType().toString(), this, data));
 }
Ejemplo n.º 4
0
  public void set(
      final Context context, final Scope scope, final String key, final SettingValue<?> value) {

    new SynchronizationTask<Object>() {
      @Override
      protected Object execute(SessionContext ctx) {

        ScopeEntity scopeEntity = getScope(context, scope);
        if (scopeEntity == null) {
          scopeEntity = createScope(context, scope);
        }
        scopeEntity.setValue(key, value.getValue());
        ctx.getSession().save();
        return null;
      }
    }.executeWith(chromatticLifeCycle);
    SettingData data =
        new SettingData(EventType.SETTING_SET, new SettingKey(context, scope, key), value);
    eventManager.broadcastEvent(
        new Event<SettingServiceImpl, SettingData>(data.getEventType().toString(), this, data));
  }