/*-------------------------------------------------[ Bean ]---------------------------------------------------
164341
@Override
    @SuppressWarnings("StringEquality")
    public Object getField(String name) throws UnresolvedException{
        if(name=="headers")
            return headers;
        else if(name=="version")
            return version;
        else if(name=="keep_alive")
            return isKeepAlive();
        else if(name=="content_length")
            return getContentLength();
        else if(name=="content_type")
            return getMediaType();
        else
            throw new UnresolvedException(name);
    }
627624
void process() {
        fixImports();
        if (insertRegion != null) {
            data.ensureImport(BeanDefinition.class);
            if (properties.size() > 0) {
                data.ensureImport(PropertyDefinition.class);
            }
            removeOld();
            if (data.isRootClass() && data.isExtendsDirectBean()) {
                data.ensureImport(DirectBean.class);
            }
            generateMeta();
            generateSerializationVersionId();
            generatePropertyChangeSupportField();
            generateHashCodeField();
            generateFactory();
            generateImmutableBuilderMethod();
            generateArgBasedConstructor();
            generateBuilderBasedConstructor();
            generateMetaBean();
            generateGettersSetters();
            generateSeparator();
            generateImmutableToBuilder();
            generateClone();
            generateEquals();
            generateHashCode();
            generateToString();
            generateMetaClass();
            generateBuilderClass();
            resolveImports();
            resolveIndents();
        }
    }
21558
public final void enlistBean(ContainerTx tx, BeanO bean)
    {
        bean.getActivationStrategy().atEnlist(tx, bean);
    }
939474
public Object defineBean(String name, Object bean) {
        Object ret = getELContext().getBeans().get(name);
        getELContext().getBeans().put(name, bean);
        return ret;
    }
373581
private static void checkBeanFactory(long waitTime, String bean) {
		if(beanFactory != null) {
			return;
		}

		// Jeśli czas oczekiwania jest określony, to wstrzymujemy bieżący wątek
		// do momentu ustawienia fabryki bean'ów. Dla ujemnej wartości czasu
		// oczekiwania - do skutku. Jeśli wartość jest dodatnia - aż upłynie
		// zdana ilość sekund:
		if(waitTime != 0) {
			long endTime = currentTimeMillis() + (waitTime * 1000);
			while(beanFactory == null && (waitTime < 0 || currentTimeMillis() < endTime)) {
				try {
					Thread.sleep(1000);
				} catch(InterruptedException e) {
				}
			}
		}

		if(beanFactory == null) {
			throw new BeanRetrievalException(bean,
					"Bean utils not initialized (bean factory not set)");
		}
	}
97883
@Override
    @SuppressWarnings("unchecked")
    public P get(Bean bean) {
        return (P) getter.get(bean);
    }
627879
private boolean handleBean(
    final ConfigurationContext ctx,
    final Class<?> _type,
    final Object cfg,
    final ParsedConfiguration _parsedCfg) {
    String _containerName = _parsedCfg.getContainer();
    BeanPropertyMutator m = provideMutator(cfg.getClass());
    Class<?> _targetType = m.getType(_containerName);
    if (_targetType == null) {
     return false;
    }
    if (!_targetType.isAssignableFrom(_type)) {
      throw new ConfigurationException("Type mismatch, expected: '" + _targetType.getName() + "'", _parsedCfg);
    }
    Object _bean = createBeanAndApplyConfiguration(ctx, _type, _parsedCfg);
    mutateAndCatch(cfg, m, _containerName, _bean, _parsedCfg, _bean);
    return true;
  }
527378
@Override
    public void service(final ServletRequest req, final ServletResponse resp) throws ServletException, IOException {
        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) resp;

        final String beanName = request.getPathInfo().substring(1); // remove "/"
        htorp.process(beanName, request, response);
    }
1255750
@Override
  public <T> T find(Class<T> beanType, Object id) {
    methodCalls.add(MethodCall.of("find").with("beanType", beanType, "id", id));
    WhenBeanReturn match = whenFind.findMatchById(beanType, id);
    if (match != null) {
      return (T)match.val();
    }
    return find.find(beanType, id, null);
  }
582050
public static void validateSchema(Bean bean) {
        validateId(bean);
        validatePropertyNames(bean);
        validateReferences(bean);
        validateProperties(bean);
        validatePropertyList(bean);
        validatePropertyReferences(bean);
        validatePropertyRefList(bean);
        validatePropertyRefMap(bean);
    }
352231
public void write(Bean bean, OutputStream output) throws IOException {
        write(bean, true, output);
    }
409230
public static boolean isInvalid(Object bean) {
		if (bean == null) {
			return false;
		}
		return isPrimitiveOrWrapper(bean.getClass()) 
				|| INVALID_TYPES.contains(bean.getClass())
				|| isInstanceOfInvalid(bean.getClass());
	}
249568
private boolean willWriteBean(Bean bean) {
        for (MetaProperty<?> prop : bean.metaBean().metaPropertyIterable()) {
            if (prop.style().isSerializable() || (prop.style().isDerived() && settings.isIncludeDerived())) {
                return true;
            }
        }
        return false;
    }
94319
@SuppressWarnings("unchecked")
	public static void registerPattern(String id, String pattern, ParserContext parserContext) {
		if (!"".equals(id)) { // add to sitemap only if it has an id
			BeanDefinitionRegistry registry = parserContext.getRegistry();
			BeanDefinition sitemapBean;
			try {
				sitemapBean = registry.getBeanDefinition(BEAN_ID);
			} catch (NoSuchBeanDefinitionException e) {
				sitemapBean = BeanDefinitionBuilder.genericBeanDefinition(Sitemap.class)
					.addPropertyValue(BEAN_PROP_ENTRIES, new HashMap<String, String>())
					.getBeanDefinition();
				registry.registerBeanDefinition(BEAN_ID, sitemapBean);
			}
			((Map<String, String>) sitemapBean.getPropertyValues().getPropertyValue(BEAN_PROP_ENTRIES).getValue()).put(id, pattern);
		}
	}
612184
public Map<String, Object> write(Bean bean) {
        JodaBeanUtils.notNull(bean, "bean");
        return writeBean(bean, bean.getClass());
    }
401887
private void installBean(JComponent bean) {
		try {
			componentPanel.removeAll();
			componentPanel.add(bean);

			BeanInfo beanInfo = Introspector.getBeanInfo(bean.getClass(), bean.getClass()
					.getSuperclass());
			PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();

			propertyPanel.removeAll();

			GridBagLayout gridbag = new GridBagLayout();
			GridBagConstraints c = new GridBagConstraints();
			c.fill = GridBagConstraints.BOTH;

			propertyPanel.setLayout(gridbag);

			int count = 0;

			String[] types = new String[] { "class java.util.Locale", "boolean", "int",
					"class java.awt.Color", "class java.util.Date", "class java.lang.String" };

			for (int t = 0; t < types.length; t++) {
				for (int i = 0; i < propertyDescriptors.length; i++) {
					if (propertyDescriptors[i].getWriteMethod() != null) {
						String type = propertyDescriptors[i].getPropertyType().toString();

						final PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
						final JComponent currentBean = bean;
						final Method readMethod = propertyDescriptor.getReadMethod();
						final Method writeMethod = propertyDescriptor.getWriteMethod();

						if (type.equals(types[t])
								&& (((readMethod != null) && (writeMethod != null)) || ("class java.util.Locale"
										.equals(type)))) {
							if ("boolean".equals(type)) {
								boolean isSelected = false;

								try {
									Boolean booleanObj = ((Boolean) readMethod.invoke(bean, null));
									isSelected = booleanObj.booleanValue();
								} catch (Exception e) {
									e.printStackTrace();
								}

								final JCheckBox checkBox = new JCheckBox("", isSelected);
								checkBox.addActionListener(new ActionListener() {
									public void actionPerformed(ActionEvent event) {
										try {
											if (checkBox.isSelected()) {
												writeMethod.invoke(currentBean,
														new Object[] { new Boolean(true) });
											} else {
												writeMethod.invoke(currentBean,
														new Object[] { new Boolean(false) });
											}
										} catch (Exception e) {
											e.printStackTrace();
										}
									}
								});
								addProperty(propertyDescriptors[i], checkBox, gridbag);
								count += 1;
							} else if ("int".equals(type)) {
								JSpinField spinField = new JSpinField();
								spinField.addPropertyChangeListener(new PropertyChangeListener() {
									public void propertyChange(PropertyChangeEvent evt) {
										try {
											if (evt.getPropertyName().equals("value")) {
												writeMethod.invoke(currentBean, new Object[] { evt
														.getNewValue() });
											}
										} catch (Exception e) {
										}
									}
								});

								try {
									Integer integerObj = ((Integer) readMethod.invoke(bean, null));
									spinField.setValue(integerObj.intValue());
								} catch (Exception e) {
									e.printStackTrace();
								}

								addProperty(propertyDescriptors[i], spinField, gridbag);
								count += 1;
							} else if ("class java.lang.String".equals(type)) {
								String string = "";

								try {
									string = ((String) readMethod.invoke(bean, null));
								} catch (Exception e) {
									e.printStackTrace();
								}

								JTextField textField = new JTextField(string);
								ActionListener actionListener = new ActionListener() {
									public void actionPerformed(ActionEvent e) {
										try {
											writeMethod.invoke(currentBean, new Object[] { e
													.getActionCommand() });
										} catch (Exception ex) {
										}
									}
								};

								textField.addActionListener(actionListener);

								addProperty(propertyDescriptors[i], textField, gridbag);
								count += 1;
							} else if ("class java.util.Locale".equals(type)) {
								JLocaleChooser localeChooser = new JLocaleChooser(bean);
								localeChooser.setPreferredSize(new Dimension(200, localeChooser
										.getPreferredSize().height));
								addProperty(propertyDescriptors[i], localeChooser, gridbag);
								count += 1;
							} else if ("class java.util.Date".equals(type)) {
								Date date = null;

								try {
									date = ((Date) readMethod.invoke(bean, null));
								} catch (Exception e) {
									e.printStackTrace();
								}

								JDateChooser dateChooser = new JDateChooser(date);

								dateChooser.addPropertyChangeListener(new PropertyChangeListener() {
									public void propertyChange(PropertyChangeEvent evt) {
										try {
											if (evt.getPropertyName().equals("date")) {
												writeMethod.invoke(currentBean, new Object[] { evt
														.getNewValue() });
											}
										} catch (Exception e) {
										}
									}
								});

								addProperty(propertyDescriptors[i], dateChooser, gridbag);
								count += 1;
							} else if ("class java.awt.Color".equals(type)) {
								final JButton button = new JButton();

								try {
									final Color colorObj = ((Color) readMethod.invoke(bean, null));
									button.setText("...");
									button.setBackground(colorObj);

									ActionListener actionListener = new ActionListener() {
										public void actionPerformed(ActionEvent e) {
											Color newColor = JColorChooser.showDialog(
													JCalendarDemo.this, "Choose Color", colorObj);
											button.setBackground(newColor);

											try {
												writeMethod.invoke(currentBean,
														new Object[] { newColor });
											} catch (Exception e1) {
												e1.printStackTrace();
											}
										}
									};

									button.addActionListener(actionListener);
								} catch (Exception e) {
									e.printStackTrace();
								}

								addProperty(propertyDescriptors[i], button, gridbag);
								count += 1;
							}
						}
					}
				}
			}

			URL iconURL = bean.getClass().getResource("images/" + bean.getName() + "Color16.gif");
			ImageIcon icon = new ImageIcon(iconURL);

			componentTitlePanel.setTitle(bean.getName(), icon);
			bean.invalidate();
			propertyPanel.invalidate();
			componentPanel.invalidate();
			componentPanel.repaint();
		} catch (IntrospectionException e) {
			e.printStackTrace();
		}
	}
825758
@Override
	public <T> Entity parseBean(T bean, boolean isToUnderlineCase, boolean ignoreNullValue) {
		if (StrUtil.isBlank(this.tableName)) {
			String simpleName = bean.getClass().getSimpleName();
			this.setTableName(isToUnderlineCase ? StrUtil.toUnderlineCase(simpleName) : StrUtil.lowerFirst(simpleName));
		}
		return (Entity) super.parseBean(bean, isToUnderlineCase, ignoreNullValue);
	}