מישהו פה התעסק עם SPRING?

yael800

New member
מישהו פה התעסק עם SPRING?

אני רוצה להגדיר אובייקט כ SINGLETON ואין בעיה עם זה כל עוד אני משתמשת ב DTD:
singleton = "false" (the default is true) <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "העניין target=_blank rel=nofollow>http://www.springframework.org/dtd/spring-beans.dtd">
העניין הוא שאני מגדירה בקובץ טרנזקציות אשל להגדרות האלה שלא כלולות כ BEAN אני באותו קובת XML לא מגדירה את השורה של ה DTD מלמעלה, אלא מגדירה את השורות הבאות, מה עליי להוסיף להן ע"מ שאוכל להשתמש ב singleton = "false"?
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <aop:config> <aop:advisor pointcut="execution(* tx*(..))" advice-ref="txAdvice"/> </aop:config> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="tx*" propagation="REQUIRED"/> </tx:attributes> </tx:advice>​
 

guznik

New member
אני מציע לשדרג

קודם כל אני מציע לך לשדרג כמה דברים: במקום לעבוד עם DTD תעברי לעבוד עם Schema ובמקום הגדרת טרנזקציות ב-XML תשתמשי ב-@Transactional. בקשר לבעיה עצמה, אני חושב שבגרסה האחרונה המאפיין singleton בוטל (הוא כבר נחשב deprecated). במקום זה ניתן להשתמש במאפיין scope וערך ברירת המחדל שלו היא singleton. יש פירוט מעמיק בפרק על Bean Scopes בתיעוד של Spring.
 

yael800

New member
וואי

המון תודה, נשמע שאתה מבין, באשר לשידרוג - טוב לדעת אבל זה לא לעכשיו והמערכת לא תלוי רק בי. בקשר ל SCOPE: יש לי את הקובץ הבא כאשר איפה שהכוכבית זה CLASS שאני רוצה שלא יהיה SINGLETON, אני מבינה שהדיפולט זה כן, או שבלי ה DTD הם לא SINGLETONS?
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="${jndi.name.prefix}jdbc/EglueMS"/> </bean> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <aop:config> <aop:advisor pointcut="execution(* tx*(..))" advice-ref="txAdvice"/> </aop:config> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="tx*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> <bean id="abstractService" abstract="true" class="com.eglue.infra.service.AbstractService"> </bean> <bean id="jdbcTemplate" class="com.eglue.infra.utils.db.EglueJdbcTemplate"> <property name="dataSource"> <ref local="dataSource"/> </property> </bean> <bean id="jdbcDaoSupport" class="org.springframework.jdbc.core.support.JdbcDaoSupport" abstract="true"> <property name="jdbcTemplate"> <ref bean="jdbcTemplate"/> </property> </bean> <bean id="abstractJdbcDao" abstract="true" parent="jdbcDaoSupport" class="com.eglue.infra.data.dao.AbstractJdbcDao"></bean> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename" value="MessagesServices"/> </bean> <bean id="analyticMessageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename" value="AnalyticMessagesServices"/> </bean> <bean id="abstractGetNextValProcedure" abstract="true" class="com.eglue.infra.data.dao.AbstractGetNextValProcedure"> <property name="nextValProcedureNamesBean" > <ref local="nextValProcedureNamesBean"/> </property> </bean> <bean id="getNextValProcedure" class="com.eglue.infra.data.dao.GetNextValProcedure" parent="abstractGetNextValProcedure" *** singleton="false" *** > <property name="nextValProcedureNamesBean" > <ref local="nextValProcedureNamesBean"/> </property> </bean> <bean id="nextValProcedureNamesBean" class="com.eglue.infra.db.NextValProcedureNamesBean" > <property name="tableNameNextValProcName"> <value>${get.next.val.table.name.proc.name}</value> </property> </bean> </beans>​
אתה יכול בבקשה להראות לי בטכלס איך אני מוסיפה לאובייקט הספציפי הזה::GetNextValProcedure SCOPE? אי מבינה לאחר קריאה שאני צריכה לממש את הממשק
org.springframework.beans.factory.config.Scope interface​
? יש לך דוגמית או כיוון בשבילי בבקשההההה? אלף תודות והמשך יום מקסים!
 

guznik

New member
scope

אין קשר ל-DTD. המקביל של singleton=false זה scope=prototype prototype זה אחד ה-scopes שבאים עם Spring ואת לא צריכה לממש אותו. המשמעות היא שבכל פעם שיש גישה ל-bean נוצר instance חדש.
 

yael800

New member
מממ

זה בעצם לא קשור ל SINGLETON, אלא בכל מקרה, בעלייה של ה WEBLOGIC, משהו ניראה לי שקשור להגדרת לטרנזקציות. אני משתמשת ב SPRING 2.06
 

yael800

New member
אז ככה

זה אכן עובד, אבל בעלייה של ה WEBLOGIC שלי אני מקבלת הודעה:
[INFO] Loading properties file from class path resource [eglue-infra-env.properties] [INFO] Bean 'org.springframework.aop.config.internalAutoProxyCreator' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) [INFO] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@119015b: defining beans​
משהו שקשור עכשיו ל internalAutoProxyCreator, זה אומר לך משהו? המון המון תודה לך, יעל.
 

guznik

New member
אני לא רואה בעיה

אלה לא הודעות שגיאה, רק Log. כל מה שברמת INFO לא צריך להדאיג אותך.
 
למעלה