Home » apache-openwebbeans-1.0.0-incubating-M3-binary » org.apache.webbeans.reservation » beans » [javadoc | source]

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    * 
    9    *       http://www.apache.org/licenses/LICENSE-2.0
   10    * 
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   package org.apache.webbeans.reservation.beans;
   18   
   19   import javax.annotation.PostConstruct;
   20   import javax.enterprise.context.RequestScoped;
   21   import javax.enterprise.inject.Default;
   22   import javax.inject.Inject;
   23   import javax.inject.Named;
   24   import javax.enterprise.inject.spi.BeanManager;
   25   
   26   import org.apache.commons.logging.Log;
   27   import org.apache.webbeans.reservation.bindings.ApplicationLog;
   28   import org.apache.webbeans.reservation.controller.RegisterController;
   29   import org.apache.webbeans.reservation.util.JSFUtility;
   30   
   31   @Named(value="register")
   32   @RequestScoped
   33   public class RegisterBean
   34   {
   35       private @Inject @ApplicationLog Log logger;
   36       
   37       private String name;
   38       
   39       private String surname;
   40       
   41       private Integer age;
   42       
   43       private String userName;
   44       
   45       private String password;
   46       
   47       private boolean admin;
   48       
   49       private @Inject @Default RegisterController personController;
   50       
   51       private @Inject @Default BeanManager manager; 
   52       
   53       public RegisterBean()
   54       {
   55           
   56       }
   57       
   58       public String register()
   59       {   
   60           
   61           logger.info("Registering the new user with user name : " + userName);
   62           
   63           personController.registerUser(userName, password, name, surname, age, admin);
   64           
   65           JSFUtility.addInfoMessage("User with name : " + userName + " is registered successfully.", "");
   66           
   67           return "login";
   68   
   69       }
   70   
   71       @PostConstruct
   72       public void init()
   73       {
   74           logger = (Log)manager.getReference(manager.getBeans("logger").iterator().next(), null, null);
   75       }
   76       
   77       
   78       /**
   79        * @return the name
   80        */
   81       public String getName()
   82       {
   83           return name;
   84       }
   85   
   86       /**
   87        * @param name the name to set
   88        */
   89       public void setName(String name)
   90       {
   91           this.name = name;
   92       }
   93   
   94       /**
   95        * @return the surname
   96        */
   97       public String getSurname()
   98       {
   99           return surname;
  100       }
  101   
  102       /**
  103        * @param surname the surname to set
  104        */
  105       public void setSurname(String surname)
  106       {
  107           this.surname = surname;
  108       }
  109   
  110       /**
  111        * @return the age
  112        */
  113       public Integer getAge()
  114       {
  115           return age;
  116       }
  117   
  118       /**
  119        * @param age the age to set
  120        */
  121       public void setAge(Integer age)
  122       {
  123           this.age = age;
  124       }
  125   
  126       /**
  127        * @return the userName
  128        */
  129       public String getUserName()
  130       {
  131           return userName;
  132       }
  133   
  134       /**
  135        * @param userName the userName to set
  136        */
  137       public void setUserName(String userName)
  138       {
  139           this.userName = userName;
  140       }
  141   
  142       /**
  143        * @return the password
  144        */
  145       public String getPassword()
  146       {
  147           return password;
  148       }
  149   
  150       /**
  151        * @param password the password to set
  152        */
  153       public void setPassword(String password)
  154       {
  155           this.password = password;
  156       }
  157   
  158       /**
  159        * @return the admin
  160        */
  161       public boolean isAdmin()
  162       {
  163           return admin;
  164       }
  165   
  166       /**
  167        * @param admin the admin to set
  168        */
  169       public void setAdmin(boolean admin)
  170       {
  171           this.admin = admin;
  172       }
  173       
  174       
  175   }

Home » apache-openwebbeans-1.0.0-incubating-M3-binary » org.apache.webbeans.reservation » beans » [javadoc | source]