geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1161386 - in /geronimo/server/trunk/plugins/wink: geronimo-wink-builder/src/main/java/org/apache/geronimo/wink/deployment/ geronimo-wink/src/main/java/org/apache/geronimo/wink/
Date Thu, 25 Aug 2011 05:09:45 GMT
Author: xuhaihong
Date: Thu Aug 25 05:09:45 2011
New Revision: 1161386

URL: http://svn.apache.org/viewvc?rev=1161386&view=rev
Log:
Format wink integration codes, no function change

Modified:
    geronimo/server/trunk/plugins/wink/geronimo-wink-builder/src/main/java/org/apache/geronimo/wink/deployment/WinkModuleBuilderExtension.java
    geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoRestServlet.java
    geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoWinkDeloymentConfiguration.java

Modified: geronimo/server/trunk/plugins/wink/geronimo-wink-builder/src/main/java/org/apache/geronimo/wink/deployment/WinkModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wink/geronimo-wink-builder/src/main/java/org/apache/geronimo/wink/deployment/WinkModuleBuilderExtension.java?rev=1161386&r1=1161385&r2=1161386&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/wink/geronimo-wink-builder/src/main/java/org/apache/geronimo/wink/deployment/WinkModuleBuilderExtension.java
(original)
+++ geronimo/server/trunk/plugins/wink/geronimo-wink-builder/src/main/java/org/apache/geronimo/wink/deployment/WinkModuleBuilderExtension.java
Thu Aug 25 05:09:45 2011
@@ -94,25 +94,22 @@ public class WinkModuleBuilderExtension 
     /*
      * public static final EARContext.Key<Set<Resource>> JSF_FACELET_CONFIG_RESOURCES
= new
      * EARContext.Key<Set<ConfigurationResource>>() {
-     * 
+     *
      * @Override public Set<ConfigurationResource> get(Map<EARContext.Key, Object>
context) { return
      * (Set<ConfigurationResource>) context.get(this); } };
      */
 
-    public WinkModuleBuilderExtension(
-            @ParamAttribute(name = "defaultEnvironment") Environment defaultEnvironment,
+    public WinkModuleBuilderExtension(@ParamAttribute(name = "defaultEnvironment") Environment
defaultEnvironment,
             @ParamReference(name = "NamingBuilders", namingType = NameFactory.MODULE_BUILDER)
NamingBuilder namingBuilders) {
         this.defaultEnvironment = defaultEnvironment;
         this.namingBuilders = namingBuilders;
     }
 
-    public void createModule(Module module, Bundle bundle, Naming naming, ModuleIDBuilder
idBuilder)
-            throws DeploymentException {
+    public void createModule(Module module, Bundle bundle, Naming naming, ModuleIDBuilder
idBuilder) throws DeploymentException {
         mergeEnvironment(module);
     }
 
-    public void createModule(Module module, Object plan, JarFile moduleFile, String targetPath,
URL specDDUrl,
-            Environment environment, Object moduleContextInfo, AbstractName earName, Naming
naming,
+    public void createModule(Module module, Object plan, JarFile moduleFile, String targetPath,
URL specDDUrl, Environment environment, Object moduleContextInfo, AbstractName earName, Naming
naming,
             ModuleIDBuilder idBuilder) throws DeploymentException {
 
         mergeEnvironment(module);
@@ -126,8 +123,8 @@ public class WinkModuleBuilderExtension 
         EnvironmentBuilder.mergeEnvironments(module.getEnvironment(), defaultEnvironment);
     }
 
-    public void installModule(JarFile earFile, EARContext earContext, Module module, Collection
configurationStores,
-            ConfigurationStore targetConfigurationStore, Collection repository) throws DeploymentException
{
+    public void installModule(JarFile earFile, EARContext earContext, Module module, Collection
configurationStores, ConfigurationStore targetConfigurationStore, Collection repository)
+            throws DeploymentException {
         if (!(module instanceof WebModule)) {
             return;
         }
@@ -140,40 +137,35 @@ public class WinkModuleBuilderExtension 
             // not a web module, nothing to do
             return;
         }
-
         WebModule webModule = (WebModule) module;
         WebApp webApp = webModule.getSpecDD();
-
         ServiceReference reference = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName());
-
         Set<Class<? extends Application>> applicationClasses = new HashSet<Class<?
extends Application>>();
-
         try {
             PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(reference);
 
-            BundleClassFinder bundleClassFinder = new BundleAssignableClassFinder(packageAdmin,
bundle,
-                    new Class<?>[] { Application.class }, new ClassDiscoveryFilter()
{
+            BundleClassFinder bundleClassFinder = new BundleAssignableClassFinder(packageAdmin,
bundle, new Class<?>[] { Application.class }, new ClassDiscoveryFilter() {
 
-                        @Override
-                        public boolean directoryDiscoveryRequired(String directory) {
-                            return true;
-                        }
+                @Override
+                public boolean directoryDiscoveryRequired(String directory) {
+                    return true;
+                }
 
-                        @Override
-                        public boolean jarFileDiscoveryRequired(String jarUrl) {
-                            return true;
-                        }
+                @Override
+                public boolean jarFileDiscoveryRequired(String jarUrl) {
+                    return true;
+                }
 
-                        @Override
-                        public boolean packageDiscoveryRequired(String packageName) {
-                            return true;
-                        }
+                @Override
+                public boolean packageDiscoveryRequired(String packageName) {
+                    return true;
+                }
 
-                        @Override
-                        public boolean rangeDiscoveryRequired(DiscoveryRange discoveryRange)
{
-                            return discoveryRange.equals(DiscoveryRange.BUNDLE_CLASSPATH);
-                        }
-                    });
+                @Override
+                public boolean rangeDiscoveryRequired(DiscoveryRange discoveryRange) {
+                    return discoveryRange.equals(DiscoveryRange.BUNDLE_CLASSPATH);
+                }
+            });
 
             Set<String> classes = bundleClassFinder.find();
 
@@ -191,12 +183,9 @@ public class WinkModuleBuilderExtension 
 
         // there's no Application sub classes found
         if (applicationClasses == null || applicationClasses.size() == 0) {
-
             /*
              * TODO jaxrs 1.1 spec section 2.3.2 If no Application subclass is present the
added servlet MUST be named ...
              */
-
-
             return;
         }
 
@@ -205,64 +194,41 @@ public class WinkModuleBuilderExtension 
          * ...
          */
         Class<? extends Application> applicationClass;
-
         BundleClassLoader bundleClassLoader = new BundleClassLoader(bundle);
-
         for (Servlet servlet : webApp.getServlet()) {
-
             List<ParamValue> params = servlet.getInitParam();
-
             for (ParamValue parm : params) {
-
                 if (parm.getParamName().trim().equals("javax.ws.rs.Application")) {
-
                     for (Class<? extends Application> clazz : applicationClasses) {
-
                         if (clazz.getName().equalsIgnoreCase(parm.getParamValue().trim()))
{
-
                             applicationClass = clazz;
-                            
-                            Class servletClass=null;
-                            
+                            Class servletClass = null;
                             try {
                                 servletClass = bundleClassLoader.loadClass(servlet.getServletClass());
                             } catch (ClassNotFoundException e) {
-                                log.warn("failed to load servlet class:"+servlet.getServletClass());
+                                log.warn("failed to load servlet class:" + servlet.getServletClass());
                             }
-                            
-                            if ((servletClass==null)||!servletClass.isAssignableFrom(HttpServlet.class)){
-                                
+                            if ((servletClass == null) || !servletClass.isAssignableFrom(HttpServlet.class))
{
                                 servlet.setServletClass(REST_SERVLET_NAME);
                             }
-                            
-
                             ParamValue paramDeploymentConfig = new ParamValue();
                             paramDeploymentConfig.setParamName("deploymentConfiguration");
                             paramDeploymentConfig.setParamValue(GeronimoWinkDeloymentConfiguration.class.getName());
                             servlet.getInitParam().add(paramDeploymentConfig);
-
                             return;
                         }
                     }
-
                 }
-
             }
-
         }
 
-
-
         /*
          * jaxrs 1.1 spec section 2.3.2 If an Application subclass is present ...
-         *  
-         *  
+         *
+         *
          * TODO It is an error for more than one application to be deployed at the same effective
servlet mapping
          */
 
-        
-       
-
         applicationClass = applicationClasses.iterator().next();
 
         Servlet restServletInfo = new Servlet();
@@ -299,27 +265,23 @@ public class WinkModuleBuilderExtension 
                     mapping = mapping + "/*";
                 }
             }
-            
-            ServletMapping restServletMapping=new ServletMapping();
+
+            ServletMapping restServletMapping = new ServletMapping();
             restServletMapping.setServletName(REST_SERVLET_NAME);
             restServletMapping.getUrlPattern().add(mapping);
             webApp.getServletMapping().add(restServletMapping);
 
+        }
 
-        } 
-        
         webApp.getServlet().add(restServletInfo);
 
-
     }
 
-    public void addGBeans(EARContext earContext, Module module, Bundle bundle, Collection
repository)
-            throws DeploymentException {
+    public void addGBeans(EARContext earContext, Module module, Bundle bundle, Collection
repository) throws DeploymentException {
 
     }
 
-    protected ClassFinder createWinkClassFinder(List<FacesConfig> facesConfigs, Set<Class<?>>
annotatedJAXRSClasses,
-            Bundle bundle) throws DeploymentException {
+    protected ClassFinder createWinkClassFinder(List<FacesConfig> facesConfigs, Set<Class<?>>
annotatedJAXRSClasses, Bundle bundle) throws DeploymentException {
         List<Class<?>> managedBeanClasses = new ArrayList<Class<?>>();
         for (FacesConfig facesConfig : facesConfigs) {
             for (FacesManagedBean managedBean : facesConfig.getManagedBean()) {
@@ -349,8 +311,7 @@ public class WinkModuleBuilderExtension 
 
     private boolean hasRestApplicationAsServlet(WebApp webApp) {
         for (Servlet servlet : webApp.getServlet()) {
-            if (servlet.getServletClass() != null
-                    && REST_APPLICATION_AS_SERVLET_NAME.equals(servlet.getServletClass().trim()))
{
+            if (servlet.getServletClass() != null && REST_APPLICATION_AS_SERVLET_NAME.equals(servlet.getServletClass().trim()))
{
                 return true;
             }
         }

Modified: geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoRestServlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoRestServlet.java?rev=1161386&r1=1161385&r2=1161386&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoRestServlet.java
(original)
+++ geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoRestServlet.java
Thu Aug 25 05:09:45 2011
@@ -6,15 +6,15 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
- * under the License.    
+ * under the License.
  */
 
 package org.apache.geronimo.wink;
@@ -35,60 +35,49 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class GeronimoRestServlet extends RestServlet {
-    
 
     private static final String DEPLOYMENT_CONF_PARAM = "deploymentConfiguration";
 
-    private static final Logger logger               =
-                                                         LoggerFactory
-                                                             .getLogger(GeronimoRestServlet.class);
+    private static final Logger logger = LoggerFactory.getLogger(GeronimoRestServlet.class);
 
-    private static final long   serialVersionUID     = -1920970727031271538L;
+    private static final long serialVersionUID = -1920970727031271538L;
 
     @Override
-    protected DeploymentConfiguration createDeploymentConfiguration()
-        throws ClassNotFoundException, InstantiationException, IllegalAccessException {
-       
-        DeploymentConfiguration deploymentConfiguration=null;
+    protected DeploymentConfiguration createDeploymentConfiguration() throws ClassNotFoundException,
InstantiationException, IllegalAccessException {
+
+        DeploymentConfiguration deploymentConfiguration = null;
         BundleContext bundleContext = (BundleContext) this.getServletContext().getAttribute("osgi-bundlecontext");
         ClassLoader deploymentClassLoader = new BundleClassLoader(bundleContext.getBundle());
         ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
         try {
             Thread.currentThread().setContextClassLoader(deploymentClassLoader);
-            deploymentConfiguration=super.createDeploymentConfiguration();
+            deploymentConfiguration = super.createDeploymentConfiguration();
         } finally {
             Thread.currentThread().setContextClassLoader(oldContextClassLoader);
         }
-
         return deploymentConfiguration;
-        
     }
-    
+
     @Override
-    protected RequestProcessor createRequestProcessor() throws ClassNotFoundException,
-    InstantiationException, IllegalAccessException, IOException {
-    
-        RequestProcessor requestProcessor=null;
+    protected RequestProcessor createRequestProcessor() throws ClassNotFoundException, InstantiationException,
IllegalAccessException, IOException {
+
+        RequestProcessor requestProcessor = null;
         BundleContext bundleContext = (BundleContext) this.getServletContext().getAttribute("osgi-bundlecontext");
         ClassLoader deploymentClassLoader = new BundleClassLoader(bundleContext.getBundle());
         ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
         try {
             Thread.currentThread().setContextClassLoader(deploymentClassLoader);
-            requestProcessor=super.createRequestProcessor();
+            requestProcessor = super.createRequestProcessor();
         } finally {
             Thread.currentThread().setContextClassLoader(oldContextClassLoader);
         }
-
         return requestProcessor;
     }
-    
-    
-    
+
     @SuppressWarnings("unchecked")
     @Override
-    protected Application getApplication(DeploymentConfiguration configuration) throws ClassNotFoundException,
-            InstantiationException, IllegalAccessException {
-        
+    protected Application getApplication(DeploymentConfiguration configuration) throws ClassNotFoundException,
InstantiationException, IllegalAccessException {
+
         Class<? extends Application> appClass = null;
         String initParameter = getInitParameter(APPLICATION_INIT_PARAM);
         if (initParameter != null) {
@@ -96,13 +85,13 @@ public class GeronimoRestServlet extends
                 logger.info(Messages.getMessage("restServletJAXRSApplicationInitParam", //$NON-NLS-1$
                         initParameter, APPLICATION_INIT_PARAM));
             }
-            
+
             BundleContext bundleContext = (BundleContext) this.getServletContext().getAttribute("osgi-bundlecontext");
             ClassLoader deploymentClassLoader = new BundleClassLoader(bundleContext.getBundle());
             ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
             try {
                 Thread.currentThread().setContextClassLoader(deploymentClassLoader);
-                appClass = (Class<? extends Application>) ClassUtils.loadClass(initParameter);
+                appClass = ClassUtils.loadClass(initParameter);
             } finally {
                 Thread.currentThread().setContextClassLoader(oldContextClassLoader);
             }
@@ -111,16 +100,10 @@ public class GeronimoRestServlet extends
             // for injection
             ObjectFactory<? extends Application> of = configuration.getOfFactoryRegistry().getObjectFactory(appClass);
             configuration.addApplicationObjectFactory(of);
-
             return of.getInstance(null);
-            
-        } else {
 
+        } else {
             throw new IllegalAccessException("Can find init parameter: " + APPLICATION_INIT_PARAM
+ " for rest servelt");
-
         }
-
-        
     }
-
 }

Modified: geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoWinkDeloymentConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoWinkDeloymentConfiguration.java?rev=1161386&r1=1161385&r2=1161386&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoWinkDeloymentConfiguration.java
(original)
+++ geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoWinkDeloymentConfiguration.java
Thu Aug 25 05:09:45 2011
@@ -1,12 +1,10 @@
-package org.apache.geronimo.wink;
-
 
+package org.apache.geronimo.wink;
 
 import org.apache.wink.server.internal.DeploymentConfiguration;
 
 public class GeronimoWinkDeloymentConfiguration extends DeploymentConfiguration {
-    
-    
+
     /* TODO: add EJB,OWB beans support for wink integration*/
 
 }



Mime
View raw message