/** * Sets the bean instance for all annotated methods for a given portlet that are members of * a configured portlet class to ensure that all annotated methods of the portlet class use * the same bean instance. * * @param portletName The portlet name * @param cls The class * @param beanInstance The instance to use */ public void setPortletClassInstance(String portletName, Class<?> cls, Object beanInstance) { for (MethodIdentifier mi : getMethodIDsForPortlet(portletName)) { List<AnnotatedMethod> list = methods.get(mi); for (AnnotatedMethod am : list) { if (am.getBeanClass().equals(cls)) { am.setPortletClassInstance(beanInstance); } } } }
/** * Returns a list of methods to be invoked for the given method identifier. * * @param mi * The method identifier * @return A list of methods. may be empty. */ private List<AnnotatedMethod> getMethods(MethodIdentifier mi) { // get the method from the store. If the requested method cannot // be found, // retry with the default dispatch ID (""). if (isDebug) { LOG.debug("Retrieving method for method identifier: " + mi.toString()); } List<AnnotatedMethod> meths = methodStore.getMethods(mi); if (meths.isEmpty()) { Object id = mi.getId(); if ((id != null) && (id instanceof String) && ((String) id).length() > 0) { mi.setId(""); if (isDebug) { LOG.debug("Retrying retrieval with method identifier: " + mi.toString()); } meths = methodStore.getMethods(mi); } } return meths; }
/** * returns a String representation of all data stored. */ @Override public String toString() { StringBuilder txt = new StringBuilder(256); txt.append("\n"); txt.append(getMethodsAsString()); return txt.toString(); }
Set<String> portletNames = ams.getPortletNames(); ams.setDefaultNamespace(pad.getDefaultNamespace()); Set<MethodIdentifier> mis = ams.getMethodIDsForPortlet(pn); for (MethodIdentifier mi : mis) { if (mi.getType() == MethodType.RENDER) { String mode = (String) mi.getId(); if (mode.equalsIgnoreCase("view") || mode.equalsIgnoreCase("help") || mode.equalsIgnoreCase("edit")) { List<AnnotatedMethod> meths = ams.getMethods(mi); for (AnnotatedMethod meth : meths) { RenderMethod rm = (RenderMethod) meth.getAnnotation(); Set<MethodIdentifier> mis = ams.getMethodIDsForPortlet(pn); for (MethodIdentifier mi : mis) { if (mi.getType() == MethodType.RESOURCE) { List<AnnotatedMethod> meths = ams.getMethods(mi); for (AnnotatedMethod meth : meths) { ServeResourceMethod srm = (ServeResourceMethod) meth.getAnnotation(); for (QName qn : ams.getProcessingEventRefs(pn)) { EventDefinition ed = pad.getEventDefinition(qn); if (ed == null) { ams.removeMethod(mi); for (QName qn : ams.getPublishingEventRefs(pn)) { EventDefinition ed = pad.getEventDefinition(qn); if (ed == null) {
txt.append("Instantiating the portlets."); txt.append(" beanMgr: ").append((bm == null) ? "null" : "not null"); txt.append(", portlet names: ").append(Arrays.toString(ams.getPortletNames().toArray())); LOG.debug(txt.toString()); ams.activateMethods(bm); ams.setPortletClassInstance(pd.getPortletName(), cls, instance); for (MethodIdentifier mi : ams.getMethodIDsForPortlet(pd.getPortletName())) { for (AnnotatedMethod am : ams.getMethods(mi)) { Class<?> cls = am.getBeanClass(); if (!processedClasses.contains(cls)) { try { instance = cls.newInstance(); ams.setPortletClassInstance(pd.getPortletName(), cls, instance); } catch (Exception e) { StringBuilder txt = new StringBuilder(128);
if (!ams.getPortletNames().contains(portletName) && errors.size() == 0) { formatToErrorString(ams.getMethodsAsString().split("\n")); errorString.append("<h4>RenderStateScoped Bean Configuration:</h4>"); formatToErrorString(config.getConfigAsString().split("\n"));
newmi.setId(qn); List<AnnotatedMethod> list = getMethodList(newmi, am); if (list == null) { badQns.add(qn); List<AnnotatedMethod> list = getMethodList(mi, am); if (list == null) { return false;
/** * Scans servlet context for method annotations. * * @param ctx the servlet context */ public void scanMethodAnnotations(ServletContext ctx) { MethodAnnotationRecognizer mar = new MethodAnnotationRecognizer(methodStore, configSummary); mar.scanContext(ctx); LOG.debug("Scan complete: \n" + methodStore.getMethodsAsString()); }
/** * Scans list of files for method annotations. * (unit test execution path) * * @param files the set of files to scan */ public void scanMethodAnnotations(Set<File> files) { MethodAnnotationRecognizer mar = new MethodAnnotationRecognizer(methodStore, configSummary); mar.scanFiles(files); LOG.debug("Scan complete: \n" + methodStore.getMethodsAsString()); }