|
View:
New views
18 Messages
—
Rating Filter:
Alert me
|
|
|
Discussion about Annotations support in GWSDI want to used this Thread to comments and reviews about the Annotations support for GWSD.
I planned to start with servlets 2.5. I saw that @DeclareRoles isn't in jdk, so my question is does we add it in GWSD or used external dependancies to support theses annotations ? -- Vous pouvez me suivre sur Twitter / You can follow me on Twitter : http://twitter.com/survivant |
|
|
Re: Discussion about Annotations support in GWSDHi Sebastien,
I see that this annotation was defined by jsr250 [1]. Therefore we should be using dependency on jsr250-api.jar [2]. HTH, Hubert [1] http://jcp.org/en/jsr/detail?id=250 [2] http://www.jarvana.com/jarvana/search?search_type=archive_details&path_to_archive=/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar On Sun, Sep 20, 2009 at 4:22 PM, Survivant 00 <survivant00@...> wrote: I want to used this Thread to comments and reviews about the Annotations support for GWSD. |
|
|
Re: Discussion about Annotations support in GWSDcool thanks.
lot easier than I tough. 2009/9/20 Hubert Iwaniuk <neotyk@...> Hi Sebastien, -- Vous pouvez me suivre sur Twitter / You can follow me on Twitter : http://twitter.com/survivant |
|
|
Re: Discussion about Annotations support in GWSDhere a snippet of the Annotations for Servlet 2.5 and descriptions took from
Java™ Servlet Specification Version 2.5 MR6 Question. Do we parse classes for all theses annotations and populate the web.xml from it theses (only if the web.xml doesn't already ready define some segments) ? package grizzly; public class AnnotationParser { /* * This annotation is used to define the security roles that comprise the * security model of the application. This annotation is specified on a * class, and it typically would be used to define roles that could be * tested (i.e., by calling isUserInRole) from within the methods of the * annotated class. It could also be used to declare application roles that * are not implicitly declared as the result of their use in a * * @DeclaresRoles annotation on the class implementing the javax.servlet. * Servlet interface or a subclass thereof. Following is an example of how * this annotation would be used. * * @DeclaresRoles("BusinessAdmin") public class CalculatorServlet { //... } * Declaring @DeclaresRoles ("BusinessAdmin") is equivalent to defining the * following in the web.xml. <web-app> <security-role> * <role-name>BusinessAdmin</role-name> </security-role> </web-app> * * JSR-250 */ public void parseDeclaresRoles() throws Exception { } /* * The @EJBs annotation allows more than one @EJB annotations to be declared * on a single resource. An example: * * @EJBs({@EJB(Calculator), @EJB(ShoppingCart)}) public class * ShoppingCartServlet { //... } The example above the EJB components * ShoppingCart and Calculator are made available to ShoppingCartServlet. * The ShoppingCartServlet must still look up the references using JNDI but * the EJBs do not need to declared in the web.xml file. * * The @EJBs annotation is discussed in further detailed in section 15.5 of * the EJB 3.0 specification (JSR220). */ public void parseEJB() throws Exception { } /* * The @Resource annotation is used to declare a reference to a resource * such as a data source, Java Messaging Service (JMS) destination, or * environment entry. This annotation is equivalent to declaring a * resource-ref, message-destinationref or env-ref, or resource-env-ref * element in the deployment descriptor. The @Resource annotation is * specified on a class, method or field. The container is responsible * injecting references to resources declared by the * * @Resource annotation and mapping it to the proper JNDI resources. See the * Java EE Specification Chapter 5 for further details. An example of a * @Resource annotation follows: * * @Resource private javax.sql.DataSource catalogDS; public * getProductsByCategory() { // get a connection and execute the query * Connection conn = catalogDS.getConnection(); .. } * * JSR-250 */ public void parseResource() throws Exception { } /* * The PersistenceContexts annotation allows more than one * @PersistenceContext to be declared on a resource. The behavior the * @PersistenceContext annotation is further detailed in section 8.4.1 of * the Java Persistence document which is part of the EJB 3.0 specification * (JSR220) and in section 15.11 of the EJB 3.0 specification * * @PersistenceContext (type=EXTENDED) EntityManager em; */ public void parsePersistenceContext() throws Exception { } /* * The @PersistenceUnit annotation provides Enterprise Java Beans components * declared in a servlet a reference to a entity manager factory. The entity * manager factory is bound to a separate persistence.xml configuration file * as described in section 5.10 of the EJB 3.0 specification (JSR220). An * example: * * @PersistenceUnit EntityManagerFactory emf; The behavior the * @PersistenceUnit annotation is further detailed in section 8.4.2 of the * Java Persistence document which is part of the EJB 3.0 specification * (JSR220) and in section 15.10 of the EJB 3.0 specification. */ public void parsePersistenceUnit() throws Exception { } /* * The @PostConstruct annotation is declared on a method that does not take * any arguments, and must not throw any checked expections. The return * value must be void. The method MUST be called after the resources * injections have been completed and before any lifecycle methods on the * component are called. An example: * * @PostConstruct public void postConstruct() { ... } The example above * shows a method using the @PostConstruct annotation. */ public void parsePostConstruct() throws Exception { } /* * The @PreDestroy annotation is declared on a method of a container managed * component. The method is called prior to component being reomvoed by the * container. An example: * * @PreDestroy public void cleanup() { // clean up any open resources ... } * The method annotated with @PreDestroy must return void and must not throw * a checked exception. The method may be public, protected, package private * or private. The method must not be static however it may be final. * * JSR-250 */ public void parsePreDestroy() throws Exception { } /* * The @Resources annotation acts as a container for multiple @Resource * annotations because the Java MetaData specification does not allow for * multiple annotations with the same name on the same annotation target. An * example: * * @Resources ({ * * @Resource(name=”myDB” type=javax.sql.DataSource), * * @Resource(name=”myMQ” type=javax.jms.ConnectionFactory) }) public class * CalculatorServlet { //... } In the example above a JMS connection factory * and a data source are made available to the CalculatorServlet by means of * an @Resources annotation. The semantics of the @Resources annotation are * further detailed in the Common Annotations for the JavaTM PlatformTM * specifcation (JSR 250) section 2.4. */ public void parseResources() throws Exception { } /* * The @RunAs annotation is equivalent to the run-as element in the * deployment descriptor. The @RunAs annotation may only be defined in * classes implementing the javax.servlet.Servlet interface or a subclass * thereof. An example: * * @RunAs(“Admin”) public class CalculatorServlet { * * @EJB private ShoppingCart myCart; public void doGet(HttpServletRequest, * req, HttpServletResponse res) { //.... myCart.getTotal(); //.... } } * //.... } The @RunAs(“Admin”) statement would be equivalent to defining * the following in the web.xml. <servlet> * <servlet-name>CalculatorServlet</servlet-name> <run-as>Admin</run-as> * </servlet> The example above shows how a servlet uses the @RunAs * annotation to propagate the security identity “Admin” to an EJB component * when the myCart.getTotal() method is called. For further details on * propagating identities see SRV.14.3.1. For further details on the @RunAs * annotation refer to the Common Annotations for the JavaTM PlatformTM * specifcation (JSR 250) section 2.6 */ public void parseRunAs() throws Exception { } /* * The @WebServiceRef annotation provides a reference to a web service in a * web component in same way as a resource-ref element would in the * deployment descriptor. An example: * * @WebServiceRef private MyService service; In this example a reference to * the web service “MyService” will be injected to the class declaring the * annotation. This annotation and behavior are further detailed in the * JAX-WS Specification (JSR 224) section 7. */ public void parseWebServiceRef() throws Exception { } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub } } |
|
|
Re: Discussion about Annotations support in GWSDHi Sebastien,
Please take a look at "SRV.14.5 Annotations and Resource Injection" from Servlet 2.5 spec. Classes that annotation can be applied to:
SRV.14.5.1 @DeclaresRoles . . . . . . . . . . . . . . . . . . . . . . . . 156 SRV.14.5.2 @EJB Annotation . . . . . . . . . . . . . . . . . . . . . . . 157 SRV.14.5.3 @EJBs Annotation . . . . . . . . . . . . . . . . . . . . . . 157 SRV.14.5.4 @Resource Annotation . . . . . . . . . . . . . . . . . . . 158 SRV.14.5.5 @PersistenceContext Annotation . . . . . . . . . . . 158 SRV.14.5.6 @PersistenceContexts Annotation . . . . . . . . . . 159 SRV.14.5.7 @PersistenceUnit Annotation . . . . . . . . . . . . . . 159 SRV.14.5.8 @PersistenceUnits Annotation . . . . . . . . . . . . . 159 SRV.14.5.9 @PostConstruct Annotation . . . . . . . . . . . . . . . 160 SRV.14.5.10 @PreDestroy Annotation . . . . . . . . . . . . . . . . . 160 SRV.14.5.11 @Resources Annotation . . . . . . . . . . . . . . . . . . 161 SRV.14.5.12 @RunAs Annotation . . . . . . . . . . . . . . . . . . . . 161 SRV.14.5.13 @WebServiceRef Annotation . . . . . . . . . . . . . 162 SRV.14.5.14 @WebServiceRefs Annotation . . . . . . . . . . . . 162 I think that you could build WebApp out of annotations and merge it with one from web.xml. Same as we do now with webdefault WebApps. Do we have a ticket for it? HTH, Hubert. On Sun, Sep 20, 2009 at 10:53 PM, Survivant 00 <survivant00@...> wrote: here a snippet of the Annotations for Servlet 2.5 and descriptions took from |
|
|
Re: Discussion about Annotations support in GWSDyes I know. my question was more Which annotations we want to support ?.
for me supporting is more than just loading the config. like EJB's annotation (JSR220) we will load the annotations (if in the list supported.. ex : javax.servlet.Servlet), but after that.. we won't used most of them tight now. that's what more my question. There is a issue for that : https://grizzly.dev.java.net/issues/show_bug.cgi?id=729 WOW.. java.net is so fast today.. 2009/9/21 Hubert Iwaniuk <neotyk@...> Hi Sebastien, -- Vous pouvez me suivre sur Twitter / You can follow me on Twitter : http://twitter.com/survivant |
|
|
Re: Discussion about Annotations support in GWSDCorrect me if I'm wrong but I think we should integrate with some JNDI tree for Servet Spec implementation.
And if we will integrate with JNDI than @EJB is just looking up in correct subtree of JNDI. HTH, Hubert. On Mon, Sep 21, 2009 at 9:27 PM, Survivant 00 <survivant00@...> wrote:
yes I know. my question was more Which annotations we want to support ?. |
|
|
Re: Discussion about Annotations support in GWSDhere the first prototype
need your feedback on this one. I tried with war that I found on the web.. but I didn,t cover everything. You will need deployer to run this test. I didn't include that directly into deployer because I want to test it outside first. look need to tell the application where to look. it will check into WEB-INF/classes and WEB-INF/lib and the output it's a webapp populated with annotations found in the classes. The main concern is with @Resource. Each webserver can handle it differently.. and that's not fun. public static void main(String[] args) throws Exception { AnnotationParser parser = new AnnotationParser(); final Map.Entry<String, URLClassLoader> loaderEntry = GrizzlyWebServerDeployer.explodeAndCreateWebAppClassLoader("C:/workspace_personal/WebAnnotation/", new URLClassLoader(new URL[0])); URLClassLoader classLoader = loaderEntry.getValue(); WebApp webapp = parser.parseAnnotation(classLoader); System.out.println(webapp); } <WebApp> <ResourceRef> <description></description> <mappedName></mappedName> <resAuth>Container</resAuth> <resRefName>jdbc/TestDB</resRefName> <resSharingScope>Shareable</resSharingScope> <resType>javax.sql.DataSource</resType> </ResourceRef> <SecurityRole> <roleName>BusinessAdmin</roleName> </SecurityRole> <SecurityRole> <roleName>context</roleName> </SecurityRole> <EnvEntry> <description></description> <mappedName>Cool</mappedName> <envEntryName>contextfield</envEntryName> <envEntryType>java.lang.String</envEntryType> <envEntryValue>Cool</envEntryValue> </EnvEntry> <LifecycleCallback> <lifecycleCallbackClass>listeners.ContextListener</lifecycleCallbackClass> <lifecycleCallbackMethod>mymethod</lifecycleCallbackMethod> </LifecycleCallback> <LifecycleCallback> <lifecycleCallbackClass>grizzly.HelloWorldExample</lifecycleCallbackClass> <lifecycleCallbackMethod>pre</lifecycleCallbackMethod> </LifecycleCallback> </WebApp> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: Discussion about Annotations support in GWSDI almost finish the refactoring to enabled annotation into WarDeployer.
for testing purpose I add a AnnotationParser there. // if metadata-complete skip annotations if(!webApp.getMetadataComplete()){ logger.fine("Will append Annotations to the WebApp"); try { AnnotationParser parser = new AnnotationParser(); WebApp webAppAnot = parser.parseAnnotation((URLClassLoader)warCL); webApp.mergeWithAnnotations(webAppAnot); } catch (Throwable t) { logger.warning("Unable to load annotations : " + t.getMessage()); } } else { logger.info("Skipping Annotation for this URI : " + uri); } but I think it would be best to have one AnnotationParser that can be passed to the WarDeployer, and one by default. We could pass a Parser that support other Annotation wihtou to much trouble.. like Persistance.. WebService, Serlvet 3.0 api ... what do you think ? |
|
|
Re: Discussion about Annotations support in GWSDI almost finish the refactoring to enabled annotation into WarDeployer. Not sure if there is a sense to pass custom parsers. Theoretically our classes are open, so WebServices, Servlet 3.0 container(s) can parse our classes themselves. What deployer might do - is notify other containers about newly deployed application. Do I miss something? |
|
|
Re: Discussion about Annotations support in GWSDit's not what I mean.
Deployer is not able to detect Annotations others than Servlet 2.5, because we didn't want to put ejb or webservice API dependancies in the project (not now). So what I wanted to give is the option to load EJB annotation at runtime with a customer AnnotationDetecter when the user used WarDeployer embedded. 2009/10/6 Oleksiy Stashok <Oleksiy.Stashok@...>
-- Vous pouvez me suivre sur Twitter / You can follow me on Twitter : http://twitter.com/survivant |
|
|
Re: Discussion about Annotations support in GWSDHmm, please correct if I'm wrong...
we talk about situation, when WarDeployer could be used by Webservices, EJB and other containers? If we have 3 containers, let's say Webservices, EJB, Servlet 3.0 we can let them share single WarDeployer instance, right? In this case which custom annotation parser we need to pass, theoretically we should pass 3 parsers, one per container? On Oct 6, 2009, at 12:35 , Survivant 00 wrote: it's not what I mean. |
|
|
Re: Discussion about Annotations support in GWSDI never look it that way. I always tought about the Annotation parser for Deployer, now that we have a WarDeployer, it could change things..
let me think. Suppose that we want to use the WarDeployer in another application (embedded.. ), and this applications want to deploy a WebService and one Servlet (we will forget about EJB now, we don't support ear yet). suppose something like (don't know the syntax.. not important) new WarDeployer.deploy("/webservice"); new WarDeployer.deploy("/servlet3.0"); ok.. we only support servlet 2.5 annotations so it won't be able to find annotation unless he user provide a Parser that support theses Annotations. What I wanted to do if something like new WarDeployer.deploy("/webservice", new CustomAnnotationParser()); new WarDeployer.deploy("/servlet3.0", new CustomAnnotationParser2()); or use the same.. but it will have to be Custom until we add a Parser that support more Annotations. and if the user user GWSD, it will use the default Parser.. no only servlet 2.5 Now if it use by another container that already have Annotation support like Tomcat, GF, Jetty... They already have there WebLoader, and parse the annotation they support,, I don't see why they would like to use WarDeployer. 2009/10/6 Oleksiy Stashok <Oleksiy.Stashok@...>
-- Vous pouvez me suivre sur Twitter / You can follow me on Twitter : http://twitter.com/survivant |
|
|
Re: Discussion about Annotations support in GWSDI understand your point, but single war file may have servlet3.0 *and* webservices inside. In this situation we will need to deploy single war two times? IMO, we can make WarDeployer as some core deployer, where we can register different containers. Once application (war) gets deployed - we notify each (?) container about deployed application (war) and let containers process its configuration + annotations. Anyway this is very close to what you propose, but just my additional 2 cents :) Thank you. WBR, Alexey. I never look it that way. I always tought about the Annotation parser for Deployer, now that we have a WarDeployer, it could change things.. |
|
|
Re: Discussion about Annotations support in GWSDah ok.
if your war have Servlet+WebService.. no trouble.. just have to pass a Parser that will handle both annotation, the web.xml will be handle correctly. the problem right now it's just that we don't support all.. Maybe when we will start the next project (web container) we will add the JEE6 Annotations :) and yes we could add NotificationHandler.. Hubert.. what do you think ? 2009/10/6 Oleksiy Stashok <Oleksiy.Stashok@...>
-- Vous pouvez me suivre sur Twitter / You can follow me on Twitter : http://twitter.com/survivant |
|
|
|
|
|
Re: Discussion about Annotations support in GWSDI suggest that we try that after my commit.. like that we will be able to play with and find out what we want to refactor in all that.
maybe when we will have a roadmap :) 2009/10/6 Hubert Iwaniuk <neotyk@...> Hi, -- Vous pouvez me suivre sur Twitter / You can follow me on Twitter : http://twitter.com/survivant |
|
|
Re: Discussion about Annotations support in GWSDHi Sebastien,
On Tue, Oct 6, 2009 at 6:29 PM, Survivant 00 <survivant00@...> wrote: I suggest that we try that after my commit.. like that we will be able to play with and find out what we want to refactor in all that. +1 maybe when we will have a roadmap :) |
| Free embeddable forum powered by Nabble | Forum Help |