/*
(non-Javadoc)

@see
com.googlecode.openbeans.beancontext.BeanContext#addBeanContextMembershipListener(com.googlecode.openbeans.beancontext.BeanContextMembershipListener)
168375
@SuppressWarnings("unchecked")
	public void addBeanContextMembershipListener(BeanContextMembershipListener listener)
	{
		if (listener == null)
		{
			throw new NullPointerException();
		}
		synchronized (bcmListeners)
		{
			if (!bcmListeners.contains(listener))
			{
				bcmListeners.add(listener);
			}
		}
	}
450112
public void addEntityChangeListener(I_CmsEntityChangeListener changeListener, String changeScope) {

        if (m_observerdEntity == null) {
            throw new RuntimeException("The Observer has been cleared, no listener registration possible.");
        }
        if (!m_changeListeners.containsKey(changeScope)) {
            m_changeListeners.put(changeScope, new ArrayList<I_CmsEntityChangeListener>());
            // if changeScope==null, it is a global change listener, and we don't need a scope value
            if (changeScope != null) {
                // save the current change scope value
                m_scopeValues.put(changeScope, CmsContentDefinition.getValueForPath(m_observerdEntity, changeScope));
            }
        }
        m_changeListeners.get(changeScope).add(changeListener);
    }
941163
public void addListener(TransactionableResourceManagerListener listener)
   {
      TransactionContext ctx = contexts.get();
      if (ctx == null)
      {
         throw new IllegalStateException("There is no active transaction context");
      }
      XidContext xidCtx = ctx.getXidContext();
      if (xidCtx == null)
      {
         throw new IllegalStateException("There is no active xid context");
      }
      xidCtx.addListener(listener);
   }
924496
public void addMemberDescription(SerialFieldTag serialFieldTag, Content contentTree) {
        String serialFieldTagDesc = serialFieldTag.description().trim();
        if (!serialFieldTagDesc.isEmpty()) {
            Content serialFieldContent = new RawHtml(serialFieldTagDesc);
            Content div = HtmlTree.DIV(HtmlStyle.block, serialFieldContent);
            contentTree.addContent(div);
        }
    }
1112488
public void removeMembershipEventListener(MembershipEventListener listener)
   {
      SecurityHelper.validateSecurityPermission(PermissionConstants.MANAGE_LISTENERS);
      listeners.remove(listener);
   }
474651
public void getMembers(final GetGroupMembersCompletionListener completionListener) {
        if (isJoined()) {
            if ((null != groupID) && (groupID.length() > 0)) {
                String urlEndpoint = "/v1/channels/" + groupID + "/subscribers/";

                signalingChannel.sendRESTMessage("get", urlEndpoint, null, new RespokeSignalingChannel.RESTListener() {
                    @Override
                    public void onSuccess(Object response) {
                        JSONArray responseArray = null;

                        if (response != null) {
                            if (response instanceof JSONArray) {
                                responseArray = (JSONArray) response;
                            } else if (response instanceof String) {
                                try {
                                    responseArray = new JSONArray((String) response);
                                } catch (JSONException e) {
                                    // An exception will trigger the error handler
                                }
                            }
                        }

                        if (null != responseArray) {
                            final ArrayList<RespokeConnection> nameList = new ArrayList<RespokeConnection>();
                            RespokeClient client = clientReference.get();
                            if (null != client) {
                                for (int ii = 0; ii < responseArray.length(); ii++) {
                                    try {
                                        JSONObject eachEntry = (JSONObject) responseArray.get(ii);
                                        String newEndpointID = eachEntry.getString("endpointId");
                                        String newConnectionID = eachEntry.getString("connectionId");

                                        // Do not include ourselves in this list
                                        if (!newEndpointID.equals(client.getEndpointID())) {
                                            // Get the existing instance for this connection, or create a new one if necessary
                                            RespokeConnection connection = client.getConnection(newConnectionID, newEndpointID, false);

                                            if (null != connection) {
                                                nameList.add(connection);
                                            }
                                        }
                                    } catch (JSONException e) {
                                        // Skip unintelligible records
                                    }
                                }
                            }

                            // If certain connections present in the members array prior to this method are somehow no longer in the list received from the server, it's assumed a pending onLeave message will handle flushing it out of the client cache after this method completes
                            members.clear();
                            members.addAll(nameList);

                            new Handler(Looper.getMainLooper()).post(new Runnable() {
                                @Override
                                public void run() {
                                    if (null != completionListener) {
                                        completionListener.onSuccess(nameList);
                                    }
                                }
                            });
                        } else {
                            postGetGroupMembersError(completionListener, "Invalid response from server");
                        }
                    }

                    @Override
                    public void onError(final String errorMessage) {
                        postGetGroupMembersError(completionListener, errorMessage);
                    }
                });
            } else {
                postGetGroupMembersError(completionListener, "Group name must be specified");
            }
        } else {
            postGetGroupMembersError(completionListener, "Not a member of this group anymore.");
        }
    }
65823
public void addMember(JsonNode member) {
        User user = api.getOrCreateUser(member.get("user"));
        members.put(user.getId(), user);
        if (member.hasNonNull("nick")) {
            nicknames.put(user.getId(), member.get("nick").asText());
        }
        if (member.hasNonNull("mute")) {
            setMuted(user.getId(), member.get("mute").asBoolean());
        }
        if (member.hasNonNull("deaf")) {
            setDeafened(user.getId(), member.get("deaf").asBoolean());
        }

        for (JsonNode roleIds : member.get("roles")) {
            long roleId = Long.parseLong(roleIds.asText());
            getRoleById(roleId).map(role -> ((RoleImpl) role)).ifPresent(role -> role.addUserToCache(user));
        }

        joinedAtTimestamps.put(user.getId(), OffsetDateTime.parse(member.get("joined_at").asText()).toInstant());

        synchronized (readyConsumers) {
            if (!ready && members.size() == getMemberCount()) {
                ready = true;
                readyConsumers.forEach(consumer -> consumer.accept(this));
                readyConsumers.clear();
            }
        }
    }
1263232
protected void addMemberDesc(Element member, Content contentTree) {
        TypeElement containing = utils.getEnclosingTypeElement(member);
        String classdesc = utils.getTypeElementName(containing, true) + " ";
        if (utils.isField(member)) {
            Content resource = contents.getContent(utils.isStatic(member)
                    ? "doclet.Static_variable_in"
                    : "doclet.Variable_in", classdesc);
            contentTree.addContent(resource);
        } else if (utils.isConstructor(member)) {
            contentTree.addContent(
                    contents.getContent("doclet.Constructor_for", classdesc));
        } else if (utils.isMethod(member)) {
            Content resource = contents.getContent(utils.isStatic(member)
                    ? "doclet.Static_method_in"
                    : "doclet.Method_in", classdesc);
            contentTree.addContent(resource);
        }
        addPreQualifiedClassLink(LinkInfoImpl.Kind.INDEX, containing,
                false, contentTree);
    }
524295
protected void initialize()
	{
		// init transient fields
		bcmListeners = new ArrayList<BeanContextMembershipListener>();
		children = new HashMap();
		serializing = false;
		inNeedsGui = false;
		nonSerPCL = new PropertyChangeListener() {
			public void propertyChange(PropertyChangeEvent event)
			{
				BeanContextSupport.this.propertyChange(event);
			}
		};
	}
1335325
@Override
    public void visitClassContext(final ClassContext classContext) {
        try {
            stack = new OpcodeStack();
            memberCollections = new HashMap<>();
            memberSourceLineAnnotations = new HashMap<>();
            super.visitClassContext(classContext);
        } finally {
            stack = null;
            memberCollections = null;
            memberSourceLineAnnotations = null;
        }
    }
488050
public void addMasterListeners()
    {
        super.addMasterListeners();
                
        ((PasswordPropertiesField)this.getField(MessageTransport.PROPERTIES)).addPasswordProperty(org.jbundle.base.message.trx.transport.email.MessageReceivingPopClientProcess.POP3_PASSWORD);
        ((PasswordPropertiesField)this.getField(MessageTransport.PROPERTIES)).addPasswordProperty(org.jbundle.base.message.trx.transport.email.EmailMessageTransport.SMTP_PASSWORD);
    }
610516
public void addListeners()
    {
        String strUserName = this.getProperty(DBParams.USER_NAME);
        this.getScreenRecord().getField(UserScreenRecord.USER).setString(strUserName);
        
        String strMessage = "Login required";
        if (this.getTask() != null)
            if (this.getTask().getApplication() != null)
        {
            BaseApplication application = (BaseApplication)this.getTask().getApplication();
            strMessage = application.getResources(ResourceConstants.ERROR_RESOURCE, true).getString(strMessage);
            this.getScreenRecord().getField(UserScreenRecord.STATUS_LINE).setString(strMessage);
        }
        
        super.addListeners();
    }
799465
@Override
    final public void addConnectionEventListener(
                                                 final ConnectionEventListener listener) {

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, "addConnectionEventListener", listener);
        }

        synchronized (_connectionListeners) {
            _connectionListeners.add(listener);
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, "addConnectionEventListener");
        }

    }
896974
public void addContextMenuComponentListener(
        CmsContextMenu.ContextMenuOpenedListener.ComponentListener contextMenuComponentListener) {

        addListener(
            ContextMenuOpenedOnComponentEvent.class,
            contextMenuComponentListener,
            ContextMenuOpenedListener.ComponentListener.MENU_OPENED_FROM_COMPONENT);
    }
517114
public void addPropertyListeners()
    {
        BaseField fldProperties = this.getField(PropertiesRecord.PROPERTIES);
        if (fldProperties.getListener(CopyConvertersHandler.class) != null)
            return;
        
        this.addPropertiesFieldBehavior(this.getField(UserInfo.FRAMES), DBParams.FRAMES);
        this.addPropertiesFieldBehavior(this.getField(UserInfo.JAVA), DBParams.JAVA);
        this.addPropertiesFieldBehavior(this.getField(UserInfo.HOME), DBParams.HOME);
        this.addPropertiesFieldBehavior(this.getField(UserInfo.MENU), DBParams.MENU);
        
        this.addPropertiesFieldBehavior(this.getField(UserInfo.BANNERS), DBParams.BANNERS);
        this.addPropertiesFieldBehavior(this.getField(UserInfo.TRAILERS), DBParams.TRAILERS);
        this.addPropertiesFieldBehavior(this.getField(UserInfo.MENUBARS), DBParams.MENUBARS);
        this.addPropertiesFieldBehavior(this.getField(UserInfo.LOGOS), DBParams.LOGOS);
        this.addPropertiesFieldBehavior(this.getField(UserInfo.NAV_MENUS), DBParams.NAVMENUS);
        this.addPropertiesFieldBehavior(this.getField(UserInfo.MENU_DESC), DBParams.MENUDESC);
        this.addPropertiesFieldBehavior(this.getField(UserInfo.HELP_PAGE), MenuConstants.USER_HELP_DISPLAY);
        this.addPropertiesFieldBehavior(this.getField(UserInfo.LANGUAGE), DBParams.LANGUAGE);
        
        Record recContactType = ((ReferenceField)this.getField(UserInfo.CONTACT_TYPE_ID)).getReferenceRecord();
        this.getField(UserInfo.CONTACT_TYPE_ID).addListener(new ReadSecondaryHandler(recContactType));
        BaseField fldContactTypeCode = recContactType.getField(ContactType.CODE);
        CopyConvertersHandler listener = new CopyConvertersHandler(new PropertiesConverter(fldProperties, DBParams.CONTACT_TYPE), fldContactTypeCode);
        this.getField(UserInfo.CONTACT_TYPE_ID).addListener(listener);
        listener.setRespondsToMode(DBConstants.INIT_MOVE, false);
        listener.setRespondsToMode(DBConstants.READ_MOVE, false);
        this.addPropertiesFieldBehavior(this.getField(UserInfo.CONTACT_TYPE_ID), DBParams.CONTACT_TYPE + DBParams.ID);
        this.addPropertiesFieldBehavior(this.getField(UserInfo.CONTACT_ID), DBParams.CONTACT_ID);
    }
81866
@Override
    public void visitClassContext(ClassContext classContext) {
        try {
            if ((jcomponentClass != null) && (accessibleClass != null)) {
                JavaClass cls = classContext.getJavaClass();
                if (cls.instanceOf(jcomponentClass) && !cls.implementationOf(accessibleClass)) {
                    bugReporter.reportBug(new BugInstance(this, BugType.S508C_NON_ACCESSIBLE_JCOMPONENT.name(), NORMAL_PRIORITY).addClass(cls));
                }
            }

            stack = new OpcodeStack();
            fieldLabels = new HashSet<>();
            localLabels = new HashMap<>();
            super.visitClassContext(classContext);
            for (XField fa : fieldLabels) {
                bugReporter.reportBug(new BugInstance(this, BugType.S508C_NO_SETLABELFOR.name(), NORMAL_PRIORITY).addClass(this).addField(fa));
            }
        } catch (ClassNotFoundException cnfe) {
            bugReporter.reportMissingClass(cnfe);
        } finally {
            stack = null;
            fieldLabels = null;
            localLabels = null;
        }
    }
713122
public void addContextLifecycleListeners(
			LifecycleListener... contextLifecycleListeners) {
		Assert.notNull(contextLifecycleListeners,
				"ContextLifecycleListeners must not be null");
		this.contextLifecycleListeners.addAll(Arrays.asList(contextLifecycleListeners));
	}