/* package */ void ensureConstraints(List<Child> children) { Set<String> nullElements = new HashSet<String>(model.getElementNames()); for (Child child : children) { nullElements.remove(child.name); } for (String s : nullElements) { ConfigModel.Property p = model.getElement(s); for (String annotation : p.getAnnotations()) { if (annotation.equals(NotNull.class.getName())) { if (p instanceof ConfigModel.Node) { ConfigModel childModel = ((ConfigModel.Node) p).model; Dom child = document.make(getHabitat(), null, this, childModel); child.register(); children.add(new Dom.NodeChild(s, child)); // recursive call to ensure the children constraints are also respected List<Child> grandChildren = new ArrayList<Child>(); child.ensureConstraints(grandChildren); if (!grandChildren.isEmpty()) { child.setChildren(grandChildren); } child.initializationCompleted(); } } } } }
public void generate() { // 1:从配置管理里面获取相应的配置信息 ConfigModel cm = ConfigManager.getInstance().getConfigData(); if (cm.isNeedGenDAO()) { // 2:按照要求去生成相应的代码,并保存成文件 System.out.println("正在生成数据层代码文件"); } }
@Override public void onResume() { super.onResume(); LoginModel loginModel = new LoginModel(getActivity()); ConfigModel configModel = new ConfigModel(getActivity()); configModel.getConfig(); }
public Set<Type> getContractTypes() { HashSet<Type> retVal = new HashSet<Type>(); retVal.add(model.getProxyType()); return retVal; }
/** * {@link InvocationHandler} implementation that allows strongly-typed access to the * configuration. * * <p>TODO: it might be a great performance improvement to have APT generate code that does this * during the development time by looking at the interface. */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // serve java.lang.Object methods by ourselves Class<?> clazz = method.getDeclaringClass(); if (clazz == Object.class) { try { return method.invoke(this, args); } catch (InvocationTargetException e) { throw e.getTargetException(); } } if (method.getAnnotation(DuckTyped.class) != null) { return invokeDuckMethod(method, proxy, args); } if (method.getAnnotation(ConfigExtensionMethod.class) != null) { ConfigExtensionMethod cem = method.getAnnotation(ConfigExtensionMethod.class); ConfigExtensionHandler handler = (ConfigExtensionHandler) ((cem.value() != null) ? getServiceLocator().getService(ConfigExtensionHandler.class, cem.value()) : getServiceLocator().getService(ConfigExtensionHandler.class)); return invokeConfigExtensionMethod(handler, this, model.getProxyType(), args); } ConfigModel.Property p = model.toProperty(method); if (p == null) throw new IllegalArgumentException("No corresponding property found for method: " + method); if (args == null || args.length == 0) { // getter return getter(p, method.getGenericReturnType()); } else { throw new PropertyVetoException( "Instance of " + getImplementation() + " named '" + getKey() + "' is not locked for writing when invoking method " + method.getName() + " you must use transaction semantics to access it.", null); } }
/** * Invoke the user defined static method in the nested "Duck" class so that the user can define * convenience methods on the config beans. */ Object invokeDuckMethod(Method method, Object proxy, Object[] args) throws Exception { Method duckMethod = model.getDuckMethod(method); Object[] duckArgs; if (args == null) { duckArgs = new Object[] {proxy}; } else { duckArgs = new Object[args.length + 1]; duckArgs[0] = proxy; System.arraycopy(args, 0, duckArgs, 1, args.length); } try { return duckMethod.invoke(null, duckArgs); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof Exception) throw (Exception) t; if (t instanceof Error) throw (Error) t; throw e; } }
public Class<?> getImplementationClass() { Class<?> retVal = (Class<?>) model.getProxyType(); return retVal; }
/** * Returns the proxy type for this configuration object * * @param <T> the proxy type * @return the class object for the proxy type */ public <T extends ConfigBeanProxy> Class<T> getProxyType() { return model.getProxyType(); }
/** Performs injection to the given object. */ public void inject(Object target) { model.inject(this, target); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View mainView = inflater.inflate(R.layout.home_fragment, null); back = (ImageView) mainView.findViewById(R.id.top_view_back); back.setVisibility(View.GONE); title = (TextView) mainView.findViewById(R.id.top_view_text); Resources resource = this.getResources(); String ecmobileStr = resource.getString(R.string.ecmobile); title.setText(ecmobileStr); title_right_button = (LinearLayout) mainView.findViewById(R.id.top_right_button); title_right_button.setVisibility(View.VISIBLE); title_right_button.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { msgModel.unreadCount = 0; headUnreadTextView.setVisibility(View.GONE); Intent intent = new Intent(getActivity(), ShopNotifyActivity.class); startActivity(intent); getActivity().overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out); } }); headUnreadTextView = (TextView) mainView.findViewById(R.id.head_unread_num); if (null == dataModel) { dataModel = new HomeModel(getActivity()); dataModel.fetchHotSelling(); dataModel.fetchCategoryGoods(); } if (null == MsgModel.getInstance()) { msgModel = new MsgModel(getActivity()); } else { msgModel = MsgModel.getInstance(); } msgModel.addResponseListener(this); msgModel.getUnreadMessageCount(); if (null == ConfigModel.getInstance()) { ConfigModel configModel = new ConfigModel(getActivity()); configModel.getConfig(); } dataModel.addResponseListener(this); bannerView = (FrameLayout) LayoutInflater.from(getActivity()).inflate(R.layout.banner_scroll_view, null); bannerViewPager = (ViewPager) bannerView.findViewById(R.id.banner_viewpager); LayoutParams params1 = bannerViewPager.getLayoutParams(); params1.width = getDisplayMetricsWidth(); params1.height = (int) (params1.width * 1.0 / 484 * 200); bannerViewPager.setLayoutParams(params1); bannerListView = new ArrayList<View>(); bannerPageAdapter = new Bee_PageAdapter(bannerListView); bannerViewPager.setAdapter(bannerPageAdapter); bannerViewPager.setCurrentItem(0); bannerViewPager.setOnPageChangeListener( new ViewPager.OnPageChangeListener() { private int mPreviousState = ViewPager.SCROLL_STATE_IDLE; @Override public void onPageScrolled(int i, float v, int i2) {} @Override public void onPageSelected(int i) {} @Override public void onPageScrollStateChanged(int state) { // All of this is to inhibit any scrollable container from consuming our touch events as // the user is changing pages if (mPreviousState == ViewPager.SCROLL_STATE_IDLE) { if (state == ViewPager.SCROLL_STATE_DRAGGING) { mTouchTarget = bannerViewPager; } } else { if (state == ViewPager.SCROLL_STATE_IDLE || state == ViewPager.SCROLL_STATE_SETTLING) { mTouchTarget = null; } } mPreviousState = state; } }); mIndicator = (PageIndicator) bannerView.findViewById(R.id.indicator); mIndicator.setViewPager(bannerViewPager); mListView = (MyListView) mainView.findViewById(R.id.home_listview); mListView.addHeaderView(bannerView); mListView.bannerView = bannerView; mListView.setPullLoadEnable(false); mListView.setPullRefreshEnable(true); mListView.setXListViewListener(this, 0); mListView.setRefreshTime(); homeSetAdapter(); ShoppingCartModel shoppingCartModel = new ShoppingCartModel(getActivity()); shoppingCartModel.addResponseListener(this); shoppingCartModel.homeCartList(); return mainView; }