@Override public void afterPropertiesSet() throws Exception { if (this.portletClass == null) { throw new IllegalArgumentException("portletClass is required"); } if (!Portlet.class.isAssignableFrom(this.portletClass)) { throw new IllegalArgumentException("portletClass [" + this.portletClass.getName() + "] needs to implement interface [javax.portlet.Portlet]"); } if (this.portletName == null) { this.portletName = this.beanName; } PortletConfig config = this.portletConfig; if (config == null || !this.useSharedPortletConfig) { config = new DelegatingPortletConfig(); } this.portletInstance = (Portlet) this.portletClass.newInstance(); this.portletInstance.init(config); }
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof Portlet) { PortletConfig config = this.portletConfig; if (config == null || !this.useSharedPortletConfig) { config = new DelegatingPortletConfig(beanName, this.portletContext, this.portletConfig); } try { ((Portlet) bean).init(config); } catch (PortletException ex) { throw new BeanInitializationException("Portlet.init threw exception", ex); } } return bean; }
public void afterPropertiesSet() throws Exception { if (this.portletClass == null) { throw new IllegalArgumentException("portletClass is required"); } if (!Portlet.class.isAssignableFrom(this.portletClass)) { throw new IllegalArgumentException("portletClass [" + this.portletClass.getName() + "] needs to implement interface [javax.portlet.Portlet]"); } if (this.portletName == null) { this.portletName = this.beanName; } PortletConfig config = this.portletConfig; if (config == null || !this.useSharedPortletConfig) { config = new DelegatingPortletConfig(); } this.portletInstance = (Portlet) this.portletClass.newInstance(); this.portletInstance.init(config); }
@Test public void beanMgrTest() throws Exception { assertNotNull(bm); Set<Bean<?>> beans = bm.getBeans(TestPortlet1.class); Bean<?> bean = bm.resolve(beans); assertNotNull(bean); CreationalContext<?> coco = bm.createCreationalContext(bean); assertNotNull(coco); Object obj = bm.getReference(bean, TestPortlet1.class, coco); assertNotNull(obj); assertTrue(obj instanceof GenericPortlet); assertTrue(obj instanceof Portlet); assertTrue(obj instanceof HeaderPortlet); assertTrue(obj instanceof EventPortlet); assertTrue(obj instanceof ResourceServingPortlet); Object obj2 = bm.getReference(bean, TestPortlet1.class, coco); assertNotNull(obj2); assertFalse(obj.equals(obj2)); assertFalse(obj == obj2); }
@Test public void appScopedTest() throws Exception { assertNotNull(bm); Set<Bean<?>> beans = bm.getBeans(TestPortlet1AppScoped.class); Bean<?> bean = bm.resolve(beans); assertNotNull(bean); CreationalContext<?> coco = bm.createCreationalContext(bean); assertNotNull(coco); Object obj = bm.getReference(bean, TestPortlet1AppScoped.class, coco); assertNotNull(obj); assertTrue(obj instanceof GenericPortlet); assertTrue(obj instanceof Portlet); assertTrue(obj instanceof HeaderPortlet); assertTrue(obj instanceof EventPortlet); assertTrue(obj instanceof ResourceServingPortlet); Object obj2 = bm.getReference(bean, TestPortlet1AppScoped.class, coco); assertNotNull(obj2); assertTrue(obj.equals(obj2)); assertTrue(obj == obj2); }
@Override public ModelAndView handleRender(RenderRequest request, RenderResponse response, Object handler) throws Exception { ((Portlet) handler).render(request, response); return null; }
@Override public void init(PortletConfig portletConfig) throws PortletException { super.init(portletConfig); LiferayPortletConfig liferayPortletConfig = (LiferayPortletConfig)portletConfig; com.liferay.portal.kernel.model.Portlet portlet = liferayPortletConfig.getPortlet(); PortletApp portletApp = portlet.getPortletApp(); ServletContextPool.put( portletApp.getServletContextName(), portletApp.getServletContext()); }
@Override public void start(BundleContext bundleContext) throws Exception { Dictionary<String, Object> properties = new Hashtable<>(); properties.put( "com.liferay.portlet.display-category", "category.sample"); properties.put("com.liferay.portlet.instanceable", "true"); properties.put("javax.portlet.display-name", "OSGi API Portlet"); properties.put( "javax.portlet.security-role-ref", new String[] {"power-user", "user"}); _serviceRegistration = bundleContext.registerService( Portlet.class, new OSGiAPIPortlet(), properties); }
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof Portlet) { PortletConfig config = this.portletConfig; if (config == null || !this.useSharedPortletConfig) { config = new DelegatingPortletConfig(beanName, this.portletContext, this.portletConfig); } try { ((Portlet) bean).init(config); } catch (PortletException ex) { throw new BeanInitializationException("Portlet.init threw exception", ex); } } return bean; }
@Override public void start() throws Exception { if (Vertx.currentContext().config().getBoolean("loaded_globally")) { if (Portlet.class.getClassLoader() == MyVerticle.class.getClassLoader()) { throw new Exception("System dependency not loaded by the correct loader"); } } else { if (Portlet.class.getClassLoader() != MyVerticle.class.getClassLoader()) { throw new Exception("System dependency not loaded by the correct loader"); } } }
@Test public void appScopedTest2Coco() throws Exception { assertNotNull(bm); Set<Bean<?>> beans = bm.getBeans(TestPortlet1AppScoped.class); Bean<?> bean = bm.resolve(beans); assertNotNull(bean); CreationalContext<?> coco1 = bm.createCreationalContext(bean); assertNotNull(coco1); Object obj = bm.getReference(bean, TestPortlet1AppScoped.class, coco1); assertNotNull(obj); assertTrue(obj instanceof GenericPortlet); assertTrue(obj instanceof Portlet); assertTrue(obj instanceof HeaderPortlet); assertTrue(obj instanceof EventPortlet); assertTrue(obj instanceof ResourceServingPortlet); CreationalContext<?> coco2 = bm.createCreationalContext(bean); assertNotNull(coco2); Object obj2 = bm.getReference(bean, TestPortlet1AppScoped.class, coco2); assertNotNull(obj2); assertTrue(obj.equals(obj2)); assertTrue(obj == obj2); }
@Test public void appScopedTest2Coco2Bean() throws Exception { assertNotNull(bm); Set<Bean<?>> beans1 = bm.getBeans(TestPortlet1AppScoped.class); Bean<?> bean1 = bm.resolve(beans1); assertNotNull(bean1); CreationalContext<?> coco1 = bm.createCreationalContext(bean1); assertNotNull(coco1); Object obj = bm.getReference(bean1, TestPortlet1AppScoped.class, coco1); assertNotNull(obj); assertTrue(obj instanceof GenericPortlet); assertTrue(obj instanceof Portlet); assertTrue(obj instanceof HeaderPortlet); assertTrue(obj instanceof EventPortlet); assertTrue(obj instanceof ResourceServingPortlet); Set<Bean<?>> beans2 = bm.getBeans(TestPortlet1AppScoped.class); Bean<?> bean2 = bm.resolve(beans2); assertNotNull(bean2); CreationalContext<?> coco2 = bm.createCreationalContext(bean2); assertNotNull(coco2); Object obj2 = bm.getReference(bean2, TestPortlet1AppScoped.class, coco2); assertNotNull(obj2); assertTrue(obj.equals(obj2)); assertTrue(obj == obj2); assertEquals(bean1, bean2); assertNotEquals(coco1, coco2); }
public void processFilter(ActionRequest req, ActionResponse res, Portlet portlet, PortletContext portletContext) throws IOException, PortletException { this.portlet = portlet; this.loader = Thread.currentThread().getContextClassLoader(); this.portletContext = portletContext; doFilter(req, res); }
public void processFilter(RenderRequest req, RenderResponse res, Portlet portlet, PortletContext portletContext) throws IOException, PortletException { this.portlet = portlet; this.loader = Thread.currentThread().getContextClassLoader(); this.portletContext = portletContext; doFilter(req, res); }
public void invokePostInit(HttpServletRequest request) throws IllegalArgumentException, IllegalStateException { PortletsSetupModule portletsSetupModule = getProcessedPortletsSetupModule(); Portlet portlet = getPortletForModule(portletsSetupModule); try { portletsSetupModule.invokePostInit(request, portlet); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(portletsSetupModule.getModuleError(e.getMessage(),request.getLocale())); } if(portletsSetupModule.isPostInitPhaseProcessed() && postInitPortletsSetupModules.isEmpty()){ setPostInitSetupDone(); } }
private Portlet getPortletForModule(PortletsSetupModule portletsSetupModule){ Portlet portlet = null; String contextName = portletsSetupModule.getContextName(); String portletName = portletsSetupModule.getPortletName(); if(null != portletName && !"".equals(portletName)) portlet = portlets.get(contextName).get(portletName); return portlet; }
@Override public boolean supports(Object handler) { return (handler instanceof Portlet); }
@Override public void handleAction(ActionRequest request, ActionResponse response, Object handler) throws Exception { ((Portlet) handler).processAction(request, response); }
@Override public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException { if (bean instanceof Portlet) { ((Portlet) bean).destroy(); } }
public boolean supports(Object handler) { return (handler instanceof Portlet); }
public void handleAction(ActionRequest request, ActionResponse response, Object handler) throws Exception { ((Portlet) handler).processAction(request, response); }
public ModelAndView handleRender(RenderRequest request, RenderResponse response, Object handler) throws Exception { ((Portlet) handler).render(request, response); return null; }
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException { if (bean instanceof Portlet) { ((Portlet) bean).destroy(); } }
/** * @see org.apache.pluto.container.FilterManager#processFilter(javax.portlet.RenderRequest, javax.portlet.RenderResponse, javax.portlet.Portlet, javax.portlet.PortletContext) */ @Override public void processFilter(RenderRequest req, RenderResponse res, Portlet portlet,PortletContext portletContext) throws PortletException, IOException{ filterchain.processFilter(req, res, portlet, portletContext); }
/** * @see org.apache.pluto.container.FilterManager#processFilter(javax.portlet.ActionRequest, javax.portlet.ActionResponse, javax.portlet.Portlet, javax.portlet.PortletContext) */ @Override public void processFilter(ActionRequest req, ActionResponse res, Portlet portlet,PortletContext portletContext) throws PortletException, IOException{ filterchain.processFilter(req, res, portlet, portletContext); }
public Portlet getPortletInstance() { return portletInstance; }
public void invokePostInit(HttpServletRequest request, Portlet portlet) throws IllegalArgumentException { if(moduleDef.getPostInitModule()) throw new IllegalArgumentException("Not implemented !!!"); throw new IllegalArgumentException("Not supported"); }
void processFilter(ActionRequest req, ActionResponse res, Portlet portlet, PortletContext portletContext) throws PortletException, IOException;
void processFilter(RenderRequest req, RenderResponse res, Portlet portlet, PortletContext portletContext) throws PortletException, IOException;
public Portlet getPortletInstance();
public void invokePostInit(HttpServletRequest request, Portlet portlet) throws IllegalArgumentException;
public void loadPortletsSetupModules(String setupModsPath, PortletWebApplication portletWebApplication, Map<String, Portlet> portlets, ClassLoader classloader);