sure,thanks a lot!
actually my project is quit simple.
this is module directory structure:
[img]http://conv.kuaipan.cn/getmedia/?f=27455093108530177&v=1&copts=pw:400,h:400&acc_params=entryid:27455093108530177,pickupCode:&t=1404888878[/img]
this is AcmeModule.java:
[code]package com.acme;
import info.magnolia.module.ModuleLifecycle;
import info.magnolia.module.ModuleLifecycleContext;
import info.magnolia.module.blossom.module.BlossomModuleSupport;
/**
* This class manages the lifecycle of the acmeModule module. It starts and
stops Spring when Magnolia starts up and
* shuts down. The dispatcher servlet we create here is a servlet but its
managed internally and never exposed to the
* outside world. A request will never reach this servlet directly. It is only
accessed by Magnolia to render the
* templates, areas and components and display the dialogs managed by the
servlet.
*/
public class AcmeModule extends BlossomModuleSupport implements ModuleLifecycle
{
public void start(ModuleLifecycleContext moduleLifecycleContext) {
if (moduleLifecycleContext.getPhase() ==
ModuleLifecycleContext.PHASE_SYSTEM_STARTUP) {
super.initRootWebApplicationContext("classpath:/applicationContext.xml");
super.initBlossomDispatcherServlet("blossom",
"classpath:/blossom-servlet.xml");
}
}
public void stop(ModuleLifecycleContext moduleLifecycleContext) {
if (moduleLifecycleContext.getPhase() ==
ModuleLifecycleContext.PHASE_SYSTEM_SHUTDOWN) {
super.destroyDispatcherServlets();
super.closeRootWebApplicationContext();
}
}
}
[/code]
this is MainTemplate.java:
[code]package com.acme;
import info.magnolia.module.blossom.annotation.Area;
import info.magnolia.module.blossom.annotation.AvailableComponentClasses;
import info.magnolia.module.blossom.annotation.DialogFactory;
import info.magnolia.module.blossom.annotation.Template;
import info.magnolia.module.xplan.TextComponent;
import info.magnolia.ui.dialog.config.DialogBuilder;
import info.magnolia.ui.framework.config.UiConfig;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Template(id = "acmeModule:components/main", title = "Main")
@Controller
public class MainTemplate {
@DialogFactory("frontpage-properties")
public void frontPageProperties(UiConfig cfg, DialogBuilder dialog) {
dialog.form().tabs(
cfg.forms.tab("Properties").fields(
cfg.fields.text("headline").label("Headline").description("The text to use as a
headline")
)
);
}
@RequestMapping("/main")
public String render() {
return "pages/mainTemplate.ftl";
}
@Area("Content")
@AvailableComponentClasses({TextComponent.class})
public static class ContentArea {
@RequestMapping("/main/content")
public String render() {
return "areas/contentArea.jsp";
}
}
}
[/code]
this is AcmeModuleVersionHandler.java:
[code]package com.acme.setup;
import info.magnolia.module.DefaultModuleVersionHandler;
/**
* This class is optional and lets you manager the versions of your module,
* by registering "deltas" to maintain the module's configuration, or other
type of content.
* If you don't need this, simply remove the reference to this class in the
module descriptor xml.
*/
public class AcmeModuleVersionHandler extends DefaultModuleVersionHandler {
}[/code]
this is acmeModule.xml:
[code]<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module SYSTEM "module.dtd" >
<module>
<name>acmeModule</name>
<displayName>${project.name}</displayName>
<description>${project.description}</description>
<class>com.acme.AcmeModule</class>
<versionHandler>com.acme.setup.AcmeModuleVersionHandler</versionHandler>
<version>${project.version}</version>
<dependencies>
<dependency>
<name>core</name>
<version>5.2.3/*</version>
</dependency>
<dependency>
<name>rendering</name>
<version>5.2.3/*</version>
</dependency>
<dependency>
<name>templating</name>
<version>5.2.3/*</version>
</dependency>
<dependency>
<name>templating-jsp</name>
<version>5.2.3/*</version>
</dependency>
<dependency>
<name>blossom</name>
<version>3.0.2/*</version>
</dependency>
</dependencies>
</module>[/code]
this is applicationContext.xml:
[code]<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:blossom="http://www.magnolia-cms.com/schema/blossom"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.magnolia-cms.com/schema/blossom
http://www.magnolia-cms.com/schema/blossom.xsd">
</beans>[/code]
this is blossom-servlet.xml:
[code]<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config/>
<context:component-scan base-package="com.acme" use-default-filters="false">
<context:include-filter type="annotation"
expression="info.magnolia.module.blossom.annotation.Template"/>
<context:include-filter type="annotation"
expression="info.magnolia.module.blossom.annotation.Area"/>
<context:include-filter type="annotation"
expression="info.magnolia.module.blossom.annotation.DialogFactory"/>
<context:include-filter type="annotation"
expression="info.magnolia.module.blossom.annotation.VirtualURIMapper"/>
</context:component-scan>
<bean
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="customArgumentResolvers">
<list>
<bean
class="info.magnolia.module.blossom.web.BlossomHandlerMethodArgumentResolver" />
</list>
</property>
</bean>
<bean class="info.magnolia.module.blossom.preexecution.BlossomHandlerMapping">
<property name="targetHandlerMappings">
<list>
<bean
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
<property name="useSuffixPatternMatch" value="false" />
</bean>
<bean
class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
</list>
</property>
</bean>
<bean
class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
<bean class="info.magnolia.module.blossom.view.UuidRedirectViewResolver">
<property name="order" value="1" />
</bean>
<!-- JSP - renders all views that end with .jsp -->
<bean class="info.magnolia.module.blossom.view.TemplateViewResolver">
<property name="order" value="2"/>
<property name="prefix" value="/acmeModule/templates/"/>
<property name="viewNames" value="*.jsp"/>
<property name="viewRenderer">
<bean class="info.magnolia.module.blossom.view.JspTemplateViewRenderer">
<!-- If you need the DAM templating functions in JSPs uncomment this
block to have them set as an attribute named 'damfn'.
<property name="contextAttributes">
<map>
<entry key="damfn">
<bean
class="info.magnolia.rendering.renderer.ContextAttributeConfiguration">
<property name="name" value="damfn"/>
<property name="componentClass"
value="info.magnolia.dam.asset.functions.DamTemplatingFunctions"/>
</bean>
</entry>
</map>
</property>
-->
</bean>
</property>
</bean>
<!-- Freemarker - renders all views that end with .ftl -->
<bean class="info.magnolia.module.blossom.view.TemplateViewResolver">
<property name="order" value="3"/>
<property name="prefix" value="/acmeModule/"/>
<property name="viewNames" value="*.ftl"/>
<property name="viewRenderer">
<bean
class="info.magnolia.module.blossom.view.FreemarkerTemplateViewRenderer">
<property name="contextAttributes">
<map>
<entry key="cms">
<bean
class="info.magnolia.rendering.renderer.ContextAttributeConfiguration">
<property name="name" value="cms"/>
<property name="componentClass"
value="info.magnolia.templating.freemarker.Directives"/>
</bean>
</entry>
<entry key="cmsfn">
<bean
class="info.magnolia.rendering.renderer.ContextAttributeConfiguration">
<property name="name" value="cmsfn"/>
<property name="componentClass"
value="info.magnolia.templating.functions.TemplatingFunctions"/>
</bean>
</entry>
<!-- If you need the DAM templating functions in Freemarker
uncomment this block to have them set as an attribute named 'damfn'.
<entry key="damfn">
<bean
class="info.magnolia.rendering.renderer.ContextAttributeConfiguration">
<property name="name" value="damfn"/>
<property name="componentClass"
value="info.magnolia.dam.asset.functions.DamTemplatingFunctions"/>
</bean>
</entry>
-->
</map>
</property>
</bean>
</property>
</bean>
</beans>[/code]
this is the output show:Registered templates []
[code]2014-07-09 15:09:57,056 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Looking for URL mappings in
application context: WebApplicationContext for namespace 'blossom-servlet':
startup date [Wed Jul 09 15:09:55 CST 2014]; parent: Root WebApplicationContext
2014-07-09 15:09:57,083 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'org.springframework.context.annotation.internalConfigurationAnnotationProcessor':
no URL paths identified
2014-07-09 15:09:57,083 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'org.springframework.context.annotation.internalAutowiredAnnotationProcessor':
no URL paths identified
2014-07-09 15:09:57,083 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'org.springframework.context.annotation.internalRequiredAnnotationProcessor':
no URL paths identified
2014-07-09 15:09:57,083 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'org.springframework.context.annotation.internalCommonAnnotationProcessor': no
URL paths identified
2014-07-09 15:09:57,084 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0':
no URL paths identified
2014-07-09 15:09:57,084 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'info.magnolia.module.blossom.preexecution.BlossomHandlerMapping#0': no URL
paths identified
2014-07-09 15:09:57,084 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter#0': no URL
paths identified
2014-07-09 15:09:57,084 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'info.magnolia.module.blossom.view.UuidRedirectViewResolver#0': no URL paths
identified
2014-07-09 15:09:57,084 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'info.magnolia.module.blossom.view.TemplateViewResolver#0': no URL paths
identified
2014-07-09 15:09:57,084 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'info.magnolia.module.blossom.view.TemplateViewResolver#1': no URL paths
identified
2014-07-09 15:09:57,084 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0':
no URL paths identified
2014-07-09 15:09:57,084 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'info.magnolia.module.blossom.template.TemplateExporter#0': no URL paths
identified
2014-07-09 15:09:57,084 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'info.magnolia.module.blossom.dialog.DialogExporter#0': no URL paths identified
2014-07-09 15:09:57,084 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'info.magnolia.module.blossom.urimapping.AnnotatedVirtualURIMappingExporter#0':
no URL paths identified
2014-07-09 15:09:57,084 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'info.magnolia.module.blossom.urimapping.VirtualURIMappingExporter#0': no URL
paths identified
2014-07-09 15:09:57,084 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'servletConfig': no URL paths identified
2014-07-09 15:09:57,084 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'messageSource': no URL paths identified
2014-07-09 15:09:57,084 DEBUG
work.web.servlet.handler.BeanNameUrlHandlerMapping: Rejected bean name
'applicationEventMulticaster': no URL paths identified
...
2014-07-09 15:09:57,938 DEBUG
lia.module.blossom.render.BlossomDispatcherServlet: Published
WebApplicationContext of servlet 'blossom' as ServletContext attribute with
name [org.springframework.web.servlet.FrameworkServlet.CONTEXT.blossom]
2014-07-09 15:09:57,938 DEBUG
k.beans.factory.support.DefaultListableBeanFactory: Returning cached instance
of singleton bean 'info.magnolia.module.blossom.template.TemplateExporter#0'
2014-07-09 15:09:57,938 DEBUG
k.beans.factory.support.DefaultListableBeanFactory: Returning cached instance
of singleton bean 'info.magnolia.module.blossom.dialog.DialogExporter#0'
2014-07-09 15:09:57,938 DEBUG
k.beans.factory.support.DefaultListableBeanFactory: Returning cached instance
of singleton bean
'info.magnolia.module.blossom.urimapping.AnnotatedVirtualURIMappingExporter#0'
2014-07-09 15:09:57,938 DEBUG
k.beans.factory.support.DefaultListableBeanFactory: Returning cached instance
of singleton bean
'info.magnolia.module.blossom.urimapping.VirtualURIMappingExporter#0'
2014-07-09 15:09:57,939 INFO
.magnolia.module.blossom.template.TemplateExporter: Registered templates []
2014-07-09 15:09:57,939 INFO
lia.module.blossom.render.BlossomDispatcherServlet: FrameworkServlet 'blossom':
initialization completed in 1956 ms
2014-07-09 15:09:57,939 DEBUG
lia.module.blossom.render.BlossomDispatcherServlet: Servlet 'blossom'
configured successfully
2014-07-09 15:09:57,939 DEBUG info.magnolia.cms.util.ObservationUtil
: Registering event listener for path [/modules/acmeModule/config][/code]
--
Context is everything:
http://forum.magnolia-cms.com/forum/thread.html?threadId=f7b42663-0858-4430-b888-255a316c7fcb
----------------------------------------------------------------
For list details, see: http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------