Package org.milyn.javabean.repository

Examples of org.milyn.javabean.repository.BeanId


   * @return A new or existing BeanId.
   */
  public  BeanId register(String beanIdName) {
    AssertArgument.isNotEmpty(beanIdName, "beanIdName");

    BeanId beanId = beanIdMap.get(beanIdName);
    if(beanId == null) {

      synchronized(this) {

        beanId = beanIdMap.get(beanIdName);
        if(beanId == null) {
          @SuppressWarnings("unchecked")
          HashMap<String, BeanId> newBeanIdMap = (HashMap<String, BeanId>) beanIdMap.clone();

          beanId = new BeanId(this, newBeanIdMap.size(), beanIdName);

          newBeanIdMap.put(beanIdName, beanId);

          beanIdMap = newBeanIdMap;
        }
View Full Code Here


   *
   * @see org.milyn.javabean.context.BeanContext#getBeanId(java.lang.String)
   */
  public BeanId getBeanId(String beanId) {
    AssertArgument.isNotNull(beanId, "beanId");
    BeanId beanIdObj = beanIdStore.getBeanId(beanId);

    if (beanIdObj == null) {
      beanIdObj = beanIdStore.register(beanId);
    }

View Full Code Here

   * (non-Javadoc)
   *
   * @see org.milyn.javabean.context.BeanContext#removeBean(java.lang.String)
   */
  public Object removeBean(String beanId, Fragment source) {
    BeanId beanIDObj = getBeanId(beanId);

    if (beanIDObj != null) {
      return removeBean(beanIDObj, source);
    }

View Full Code Here

    Map<String, BeanId> beanIdMap = beanIdStore.getBeanIdMap();

    int largestBeanIdIndex = -1;
    for (Entry<String, BeanId> beanIdEntry : beanIdMap.entrySet()) {
      String beanIdName = beanIdEntry.getKey();
      BeanId beanId = beanIdEntry.getValue();
      if (!beanMap.containsKey(beanIdName)) {
        beanMap.put(beanIdName, null);
      }
      if (largestBeanIdIndex < beanId.getIndex()) {
        largestBeanIdIndex = beanId.getIndex();
      }
    }
    if(largestBeanIdIndex >= 0) {
      int newEntries = (largestBeanIdIndex - entries.size()) + 1;
      entries.addAll(Collections.nCopies(newEntries, (ContextEntry) null));

      for (Entry<String, Object> beanMapEntry : beanMap.entrySet()) {

        BeanId beanId = beanIdMap.get(beanMapEntry.getKey());

        int index = beanId.getIndex();
        if (entries.get(index) == null) {

          entries.set(index, new ContextEntry(beanId, beanMapEntry));
        }
      }
View Full Code Here

     * @see java.util.Map#put(java.lang.Object, java.lang.Object)
     */
    public Object put(String key, Object value) {
      AssertArgument.isNotNull(key, "key");

      BeanId beanId = beanIdStore.getBeanId(key);

      Object old = null;
      if (beanId == null) {
        beanId = beanIdStore.register(key);
      } else {
View Full Code Here

      AssertArgument.isNotNull(key, "key");

      if (key instanceof String == false) {
        return null;
      }
      BeanId beanId = beanIdStore.getBeanId((String) key);

      return beanId == null ? null : removeBean(beanId, null);
    }
View Full Code Here

   */
  public void test_add_bean() {
        Object bean1 = new MyGoodBean();
        Object bean2 = new MyGoodBean();

        BeanId beanId1 = getBeanIdStore().register("bean1");
        BeanId beanId2 = getBeanIdStore().register("bean2");

        BeanContext BeanContext = getBeanContext();

        assertEquals(2, BeanContext.getBeanMap().size());

View Full Code Here

   */
  public void test_add_and_overwrite_bean() {
        Object bean1 = new MyGoodBean();
        Object newBean1 = new MyGoodBean();

        BeanId beanId1 = getBeanIdStore().register("bean1");

        BeanContext BeanContext = getBeanContext();

        assertNull(BeanContext.getBean(beanId1));

View Full Code Here

   */
  public void test_change_bean() {
        Object bean1 = new MyGoodBean();
        Object newBean1 = new MyGoodBean();

        BeanId beanId1 = getBeanIdStore().register("bean1");
        BeanId beanIdNE = getBeanIdStore().register("notExisting");


        BeanContext BeanContext = getBeanContext();

        BeanContext.addBean(beanId1, bean1, null);
View Full Code Here

    Object bean1 = new Object();
    Object bean2 = new Object();
    Object bean3 = new Object();
    Object bean4 = new Object();

    BeanId beanId1 = getBeanIdStore().register("bean1");

    BeanContext BeanContext = getBeanContext();
    Map<String, Object> beanMap = BeanContext.getBeanMap();

    BeanContext.addBean(beanId1, bean1, null);

    assertEquals(1, beanMap.size());
    assertEquals(bean1, beanMap.get(beanId1.getName()));

    beanMap.put("bean2", bean2);

    BeanId beanId2 = BeanContext.getBeanId("bean2");

    assertEquals(bean2, BeanContext.getBean(beanId2));
    assertEquals(bean2, beanMap.get(beanId2.getName()));

    assertTrue(beanMap.containsKey("bean2"));
    assertFalse(beanMap.containsKey("x"));

    assertTrue(beanMap.containsValue(bean1));
View Full Code Here

TOP

Related Classes of org.milyn.javabean.repository.BeanId

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.