10 Replies Latest reply on Jul 10, 2007 10:02 AM by alesj

    What is going on with aliases?

       

       public class AbstractKernelDeployment extends JBossObject
       implements KernelDeployment, MutableLifecycleHolder, Serializable
       {
      - private static final long serialVersionUID = 1;
      + private static final long serialVersionUID = 2l;
      
       /** The name of the deployment */
       protected String name;
      @@ -92,7 +92,7 @@
       protected ControllerMode mode;
      
       /** The aliases */
      - protected Set<NamedAliasMetaData> aliases;
      + protected List<NamedAliasMetaData> aliases;
      


      None of this makes any sense to me. I don't remember you discussing
      any of these changes?

      The order of the aliases cannot matter and you can't have an alias more than once.
      So why a List when a Set describes exactly what is required.

      Also what does it mean for a deployment rather than a bean to have an alias?
      Is this a Spring thing?

      As far as I can tell, your DeploymentAliasMetaDataDeployer is just going to fail
      when a deployment has more than one bean in it.
      You will try to apply the alias names to all the beans in the deployment.
      Only one of the beans can have an alias. It must be unique!

      Also, the component deployer was not intended for this kind of thing.

      The idea of a component is to represent a part of a deployment,
      e.g. a single ejb in an ejb jar or single bean in a -beans.xml
      soon I will be using the components to assign scopes for the MetaDataRepository
      where instance=component-name
      This kind of hack is just going to confuse things.
      There should be only one scope not a scope for every alias.


        • 1. Re: What is going on with aliases?

          Ok, I see what you are doing.
          Each alias is associated with a name

          <deployment xmlns="urn:jboss:bean-deployer:2.0">
           <alias name="Test">MyAlias</alias>
          </deployment>
          


          So you're saying I want to alias the context "Test" with the new name "MyAlias".
          And this is a seperate deployment to where "Test" is defined.

          It's an interesting idea. But if this really is the solution then it needs some
          kind of marker in the component to say it is "NOT REAL", otherwise other
          stuff built on the deployers like what I'm going to do with the metadata
          repository and jsr77 or what the profile service is doing
          is going to get very confused. :-)

          • 2. Re: What is going on with aliases?

            Looking at the code, I think this should also work to alias JMX contexts?
            but it obviously needs testing.

            • 3. Re: What is going on with aliases?
              alesj

               

              "adrian@jboss.org" wrote:

              None of this makes any sense to me. I don't remember you discussing
              any of these changes?

              The order of the aliases cannot matter and you can't have an alias more than once.
              So why a List when a Set describes exactly what is required.

              I agree, I'll put the Set back.
              Though I'll need a list, but I don't.

              "adrian@jboss.org" wrote:

              Also what does it mean for a deployment rather than a bean to have an alias?
              Is this a Spring thing?

              Yup, this was originally taken from Spring.
              But I think they have a full implementation - the one mentioned on the JIRA. Which I think we initially don't need .

              "adrian@jboss.org" wrote:

              As far as I can tell, your DeploymentAliasMetaDataDeployer is just going to fail
              when a deployment has more than one bean in it.
              You will try to apply the alias names to all the beans in the deployment.
              Only one of the beans can have an alias. It must be unique!

              Also, the component deployer was not intended for this kind of thing.

              The idea of a component is to represent a part of a deployment,
              e.g. a single ejb in an ejb jar or single bean in a -beans.xml
              soon I will be using the components to assign scopes for the MetaDataRepository
              where instance=component-name
              This kind of hack is just going to confuse things.
              There should be only one scope not a scope for every alias.

              I don't understand this.
              How else do you think to deploy this, if not as a component?
              Or is this not relevant anymore due to next posts?

              • 4. Re: What is going on with aliases?
                alesj

                 

                "adrian@jboss.org" wrote:
                Ok, I see what you are doing.
                Each alias is associated with a name

                <deployment xmlns="urn:jboss:bean-deployer:2.0">
                 <alias name="Test">MyAlias</alias>
                </deployment>
                


                So you're saying I want to alias the context "Test" with the new name "MyAlias".
                And this is a seperate deployment to where "Test" is defined.

                Yup.
                This is the point.
                e.g. you have a deployment which already uses a lot of different names for the bean you have defined earlier.
                You simply add a deployment alias.

                "adrian@jboss.org" wrote:

                It's an interesting idea. But if this really is the solution then it needs some
                kind of marker in the component to say it is "NOT REAL", otherwise other
                stuff built on the deployers like what I'm going to do with the metadata
                repository and jsr77 or what the profile service is doing
                is going to get very confused. :-)

                :-)
                Do we have this kind of marker?
                Or better, how/where do I add it? ;-)

                • 5. Re: What is going on with aliases?
                  alesj

                   

                  "adrian@jboss.org" wrote:
                  Looking at the code, I think this should also work to alias JMX contexts?
                  but it obviously needs testing.

                  I think it should work.
                  I'm just about to do more tests for JMX names.

                  • 6. Re: What is going on with aliases?
                    alesj

                    I'll change the order of DeploymentAliasMetaDataDeployer by renaming it to AliasMetaDataDeployer.
                    Not that it matters in state machine ;-), but I think it is less confusing.
                    This way 2nd deployment will resolve the alias bean right away.

                    • 7. Re: What is going on with aliases?
                      alesj

                       

                      "alesj" wrote:
                      I'll change the order of DeploymentAliasMetaDataDeployer by renaming it to AliasMetaDataDeployer.
                      Not that it matters in state machine ;-), but I think it is less confusing.
                      This way 2nd deployment will resolve the alias bean right away.


                      Bad choice, since that way the joined-beans.xml test case doesn't work.

                      In order to have AliasMDDeployer after BeanMDDeployer we need to run resolveContexts() on the Controller, checking if some existing beans get resolved due to 'added' context.
                      But I don't see the equivalent behavior on the removal of the alias.

                      • 8. Re: What is going on with aliases?

                        If this is really going to work, then the aliases need to be a true dependencies.

                        i.e. if I do

                        <deployment>
                         <alias name="Tomcat">JBossWeb</alias>
                        </deployment>
                        
                        <deployment>
                         <bean name="X">
                         <depends>JBossWeb</depends>
                         </bean>
                        


                        This shouldn't fail because "Tomcat" is not deployed yet. It should wait
                        until Tomcat is deployed.
                        And bean "X" should get undeployed when Tomcat is undeployed.

                        Unless you can support these semantics then adding aliases outside
                        of the deployment that creates the original isn't going to work.

                        • 9. Re: What is going on with aliases?
                          alesj

                           

                          "adrian@jboss.org" wrote:

                          And bean "X" should get undeployed when Tomcat is undeployed.

                          OK, this one works OOTB - see AliasDeployerUnitTestCase.testAliasDependency.

                          I'll add a true alias dependency next.

                          • 10. Re: What is going on with aliases?
                            alesj

                             

                            "alesj" wrote:

                            I'll add a true alias dependency next.


                            I've added a new ControllerContext for alias being true dependency - see AbstractController.AliasControllerContext.

                            I've renamed previous 'demand' test case to AliasDeployerUnitTestCase.testAliasDemand, so now the _real_ dependency test case is under AliasDeployerUnitTestCase.testAliasDependency.