Announcement Announcement Module
Collapse
No announcement yet.
Very simple question Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Very simple question

    I'm sure this must have been asked before, but I just can't find the correct search term to bring up the thread.

    I have a property I want to use called 'ZapProp'. I create a method on the class called setZapProp() and put <prop name="zapProp"/> in the beans.xml and everything is fine.

    However, I change the name of the property to <prop name="ZapProp"/>. We can't find the property.

    I get smart. I change setZapProp() to setzapProp(). Still fails.

    So I change the property to <prop name="zapProp">. That works. I cycle though getZapProp and getzapProp with the bean definition constant. Works fine.

    My question is: Is this consistant behaviour? If it is, then the warning message should probably say that properties cannot begin with a capital, not that it can't find the setter. Otherwise, we should be clear that properties may only begin with a small letter.

    Of course, I'm not an expert here, so it may just be I'm stupid

    ..r

  • #2
    Re: Very simple question

    Originally posted by rogerf
    So I change the property to <prop name="zapProp">. That works. I cycle though getZapProp and getzapProp with the bean definition constant. Works fine.

    My question is: Is this consistant behaviour?
    Yes. The basic propertyname always begins with a lowercase, and the setter/getter always begins with a set/get propertyname (and this time the property starts with an uppercase).

    If it is, then the warning message should probably say that properties cannot begin with a capital, not that it can't find the setter. Otherwise, we should be clear that properties may only begin with a small letter.
    It is normal javabean behaviour. So maybe you have made a mistake, but I guess this won`t happen again.

    Comment


    • #3
      Re: Very simple question

      [quote="Alarmnummer"]
      Originally posted by rogerf
      If it is, then the warning message should probably say that properties cannot begin with a capital, not that it can't find the setter. Otherwise, we should be clear that properties may only begin with a small letter.
      It is normal javabean behaviour. So maybe you have made a mistake, but I guess this won`t happen again.
      Most of the java beans I've seen do require the method to be set<CAP>whatever. The one exception I can think of is Jakarta Velocity. But it allows both caps and small letters for the bean definitions. Spring is the only one I've seen so far that doesn't care if the setter has a capital or not, but does require the property has a small letter.

      My main point is that when designing excptions, you probably should try to design them from the user point of view, not for the ease the of the developer.

      Basically, if the property must start with a lower case and it does not, rather than say 'cant find setter', a better error would be 'property must start with a lower case'. Or at least a DTD or contract that says what is valid.

      ..r

      Comment


      • #4
        Re: Very simple question

        Originally posted by rogerf
        My main point is that when designing excptions, you probably should try to design them from the user point of view, not for the ease the of the developer.
        *is sending you to a few opensource projects that need such advice*

        I agree.

        Basically, if the property must start with a lower case and it does not, rather than say 'cant find setter', a better error would be 'property must start with a lower case'.
        I agree.

        Comment


        • #5
          Re: Very simple question

          Originally posted by Alarmnummer
          Originally posted by rogerf
          My main point is that when designing excptions, you probably should try to design them from the user point of view, not for the ease the of the developer.
          *is sending you to a few opensource projects that need such advice*

          I agree.

          .
          If only we could get all these people who claim to believe in component systems, service architectures or whatever they are calling a well designed atomic API to actually implement one....however, spring is the best attempt at decoupling I've seen to date...

          If only they could do an API framework too...

          Comment


          • #6
            Re: Very simple question

            Originally posted by rogerf
            If only we could get all these people who claim to believe in component systems, service architectures or whatever they are calling a well designed atomic API to actually implement one....however, spring is the best attempt at decoupling I've seen to date...
            My experience so far is that it depends on the projects you are using. normally I only spend a small part of my time finding causes of exceptions. The only exceptions are Hibernate and Axis. Hibernate is a perfect source of strange exceptions. You have to dig through the sourcecode to figure out what went wrong.

            Comment


            • #7
              Re: Very simple question

              Originally posted by Alarmnummer
              My experience so far is that it depends on the projects you are using. normally I only spend a small part of my time finding causes of exceptions. The only exceptions are Hibernate and Axis. Hibernate is a perfect source of strange exceptions. You have to dig through the sourcecode to figure out what went wrong.

              If you're interested, with JDO, I think you need to jar the persistence capable objects separatly to use spring.

              Sorry, one thing I worried about in Spring is unnessary injection.

              Comment


              • #8
                Re: Very simple question

                Originally posted by rogerf
                I find my approach to project always causes me issues.....I decide what I want to do, then I make the technology do it for me.
                This is the way I like to work also. Most technologies shouldn`t be to intrusive .

                I didn't try to use spring for the cool factor, I was using it to do some extreme decoupling.
                The IOC-container of Spring is very usefull to do decoupling. In some cases you can give even further then decouple from implementation. In some cases you can seperate the producer of messages (could be a method call) from the consumer of messages. You get a very flexible design because components can be connected in a lot of different ways. I`m currently working on a Channels project to make it easy to set up such systems. I have used it in a few projects and it works like a dream.

                Sorry, one thing I worried about in Spring is unnessary injection.
                What do you mean?

                Comment


                • #9
                  Re: Very simple question

                  Originally posted by Alarmnummer
                  My experience so far is that it depends on the projects you are using. normally I only spend a small part of my time finding causes of exceptions. The only exceptions are Hibernate and Axis. Hibernate is a perfect source of strange exceptions. You have to dig through the sourcecode to figure out what went wrong.
                  axis..it does lead me to ask if you think spring jax-rpc could be used instead of axis.

                  Comment


                  • #10
                    Re: Very simple question

                    Originally posted by rogerf
                    Originally posted by Alarmnummer
                    My experience so far is that it depends on the projects you are using. normally I only spend a small part of my time finding causes of exceptions. The only exceptions are Hibernate and Axis. Hibernate is a perfect source of strange exceptions. You have to dig through the sourcecode to figure out what went wrong.
                    axis..it does lead me to ask if you think spring jax-rpc could be used instead of axis.
                    The next time I`m creating a webservice, I`m going to use XFire

                    Comment


                    • #11
                      Re: Very simple question

                      Originally posted by Alarmnummer
                      Originally posted by rogerf
                      Sorry, one thing I worried about in Spring is unnessary injection.
                      What do you mean?
                      Its a little abstract, but I think dependency injection needs to be based on service dependencies...

                      Comment


                      • #12
                        Re: Very simple question

                        Originally posted by rogerf
                        Originally posted by Alarmnummer
                        Originally posted by rogerf
                        Sorry, one thing I worried about in Spring is unnessary injection.
                        What do you mean?
                        Its a little abstract, but I think dependency injection needs to be based on service dependencies...
                        I'll be a little more consice...Any dependency *must* be in a separate project/jar

                        Comment


                        • #13
                          Re: Very simple question

                          Originally posted by Alarmnummer
                          The next time I`m creating a webservice, I`m going to use XFire
                          Does seem worth a look...thanks for the pointer.

                          Comment


                          • #14
                            Re: Very simple question

                            Originally posted by rogerf
                            Originally posted by Alarmnummer
                            Originally posted by rogerf
                            Sorry, one thing I worried about in Spring is unnessary injection.
                            What do you mean?
                            Its a little abstract, but I think dependency injection needs to be based on service dependencies...
                            Dependencies don`t have to be coarse grained. You can also use very fine grained dependencies, example:

                            Code:
                            <!-- de parser is verantwoordelijk voor het parsen van pagina`s-->
                            	<bean id="parser"
                            		  class="anchormen.kaloogaExp.parser.Parser">
                            		<!-- hier worden fe-->
                            		<constructor-arg index="0" ref="fetcherToParserChannel"/>
                            		<!-- hier worden alle succesvolle geparste pagina`s naar toe gestuurd-->
                            		<constructor-arg index="1" ref="parserOutputChannel"/>
                            		<!-- hier worden alle pagina`s naar toe gestuurd waarbij er problemen zijn opgetreden tijdens het
                            			parsen.-->
                            		<constructor-arg index="2" ref="deadLetterOutputChannel"/>
                            	</bean>
                            
                            	<bean id="parserRepeater"
                            		  class="org.jph.concurrent.repeater.StdRepeaterService"
                            		  init-method="start"
                            		  destroy-method="shutdown">
                            
                            		<!-- number of threads -->
                            		<constructor-arg index="0" value="1"/>
                            
                            		<!-- the threadfactory -->
                            		<constructor-arg index="1">
                            			<bean class="org.jph.concurrent.StdThreadFactory">
                            				<!-- priority -->
                            				<constructor-arg index="0" value="3"/>
                            				<!-- De naam van ThreadGroup waar de Threads onder vallen -->
                            				<constructor-arg index="1" value="parserRepeaters"/>
                            			</bean>
                            		</constructor-arg>
                            
                            		<!-- the task to repeat -->
                            		<constructor-arg index="2">
                            			<bean class="org.jph.spring.scheduling.MethodInvokeRunnable">
                            				<constructor-arg>
                            					<bean class="org.springframework.util.MethodInvoker">
                            						<property name="targetObject" ref="parser"/>
                            						<property name="targetMethod" value="processSingleMsg"/>
                            					</bean>
                            				</constructor-arg>
                            			</bean>
                            		</constructor-arg>
                            	</bean>
                            Here I use very fine grained en coarse grained dependency injection. I configure all objects in every small details, but I also use it to glue them together. And it works like a dream.

                            Comment


                            • #15
                              Re: Very simple question

                              Originally posted by rogerf
                              Originally posted by rogerf
                              Originally posted by Alarmnummer
                              Originally posted by rogerf
                              Sorry, one thing I worried about in Spring is unnessary injection.
                              What do you mean?
                              Its a little abstract, but I think dependency injection needs to be based on service dependencies...
                              I'll be a little more consice...Any dependency *must* be in a separate project/jar
                              Why?

                              Comment

                              Working...
                              X