[JBoss Seam] - HibernateEntityConverter
by patrickr
The EntityConverter doesn't seem to work with Hibernate managed sessions, does it? Because I didn?t find a HibernateEntityConverter either, I quickly wrote one myself. Maybe someone finds this useful. Feel free to add it to the source repository.
| /**
| * This implementation of the EntityConverter is suitable for any Hibernate
| * Entity which uses annotations
| *
| * @author Patrick Ruhkopf
| */
| @Name("org.jboss.seam.ui.hibernateEntityConverter")
| @Scope(ScopeType.CONVERSATION)
| @Install(precedence = BUILT_IN)
| @Converter
| @Intercept(NEVER)
| public class HibernateEntityConverter extends EntityConverter
| {
| private ValueBinding<Session> session;
|
| private Log log = Logging.getLog(HibernateEntityConverter.class);
|
| public void setSession(ValueBinding<Session> session) {
| this.session = session;
| }
|
| private Session getSession()
| {
| if (session==null) {
| return (Session) Component.getInstance( "database" );
| }
| else {
| return session.getValue();
| }
| }
|
| @Override
| protected Object loadEntityFromPersistenceContext(Class clazz, Object id)
| {
| if (id == null || clazz == null) {
| return null;
| }
|
| if (id instanceof Serializable)
| {
| Serializable sid = (Serializable) id;
| Object entity = null;
| if (getSession() == null)
| {
| sessionNotFoundMessage();
| }
| entity = getSession().get(clazz, sid);
| if (entity == null)
| {
| invalidSelectionMessage(clazz, id);
| return null;
| }
| else
| {
| return entity;
| }
| } else {
| log.error("Converter only supports serializable ids");
| throw new ConverterException(FacesMessages.createFacesMessage(SEVERITY_ERROR,
| getErrorMessageKey(), getErrorMessage()));
| }
| }
|
| protected void sessionNotFoundMessage()
| {
| log.error("Hibernate session not found");
| throw new ConverterException(FacesMessages.createFacesMessage(SEVERITY_ERROR,
| getErrorMessageKey(), getErrorMessage()));
| }
| }
|
Taglib
| <tag>
| <tag-name>convertHibernateEntity</tag-name>
| <converter>
| <converter-id>org.jboss.seam.ui.hibernateEntityConverter</converter-id>
| </converter>
| </tag>
|
Example of components.xml if your managed Hibernate session has a different name than database
| <core:managed-hibernate-session name="myVeryDatabase"
| auto-create="true"/>
|
| <component name="org.jboss.seam.ui.hibernateEntityConverter">
| <property name="session">#{myVeryDatabase}</property>
| </component>
|
Regards
Patrick
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4040262#4040262
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4040262
19 years
[JBossCache] - ClusteredCache fails with Region activation/inactivation
by jorgemoralespou_2
Hi, I have a 2 node cache, and I use ClusterCacheLoader (JBossCache 1.4.1.SP3). I set inactiveOnStartup to true on startup of the AS, and as I deploy applications taht uses the cache, I activate the regions it uses programatically.
Problem is that when I deploy an app, in node one, it works perfectly. Then I deploy/start application in node 2, an exception is thrown.
| java.lang.NullPointerException
| at org.jboss.cache.loader.ClusteredCacheLoader.callRemote(ClusteredCacheLoader.java:98)
| at org.jboss.cache.loader.ClusteredCacheLoader.getChildrenNames(ClusteredCacheLoader.java:66)
| at org.jboss.cache.loader.AsyncCacheLoader.getChildrenNames(AsyncCacheLoader.java:157)
|
I downloaded the source code, and fixed my problem by doing this:
replaced (in ClusteredCacheLoader):
| if (((Boolean) clusteredGetResp.get(0)).booleanValue())
|
with:
| Boolean resp = (Boolean) ((clusteredGetResp!=null && clusteredGetResp.size()>0)? clusteredGetResp.get(0):null);
| if (resp !=null && resp.booleanValue())
|
Also, I have seen this is not aplicable to 2.0 branch, as it uses Java 5 features.
I don`t know if this is a bug, or I`m doing something wrong. Probably you can evaluate it better than I.
Another question is in documentation it states that whenever you want to use region activation/inactivation with cacheloader, the cacheloader should implement ExtendedCacheLoader, which ClusteredCacheLoader does not.
Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4040258#4040258
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4040258
19 years
[JBoss Portal] - Re: Login.jsp
by Antoine_h
A way to do it is :
- let the portal do the process of authentification, as it is, with the login.jsp etc...
- just change the login module (or add a new one) with the acegi login module for jboss (don't remember the exact class name, in the adapter provided with acegi)
this way, you have a principal setup by the portal, that is a Authentication class from acegi
the portal works fine with it (it just need the name of the Principal...).
this mean : not using the Acegi authentification process... if you don't really need it.
you have the "Acegi Principal" as a result, but don't touch the login process.
If you really need it : this should not be such a problem, with replacing this process instead of the tomcat/servlet one that is in portal-server.war.
after, to use Acegi security stuff, just add two filters : the httpsessionintegration... (the first one), to have the context holder setup in the session, and the jboss filter provided with acegi, to have jboss set up with this principal.
add these in the portal-server web app.
it works fine...
I will add these thing to the yet existing wiki. but I want to finish my integration before to write some explaination.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4040256#4040256
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4040256
19 years
[JBoss Seam] - Re: Interceptor Question
by xinhua
hi, CptnKirk
the app is running on JBossAS 4.0.5 GA with ejb3 container
here is my complete codes:
| import javax.interceptor.AroundInvoke;
| import javax.interceptor.InvocationContext;
|
| public class PrintoutInterceptor {
|
| @AroundInvoke
| public void printOut(InvocationContext invocation) throws Exception {
| System.out.println("Method "+invocation.getMethod()+" is called");
| invocation.proceed();
| }
| }
|
| import static java.lang.annotation.ElementType.*;
| import static java.lang.annotation.RetentionPolicy.RUNTIME;
| import java.lang.annotation.*;
| import javax.interceptor.Interceptors;
|
| @Target(METHOD)
| @Retention(RUNTIME)
| @Interceptors(PrintoutInterceptor.class)
| public @interface Printout {
| }
|
i changed the import like this :
| ....
| import org.jboss.seam.annotations.Interceptors;
| @Target(METHOD)
| @Retention(RUNTIME)
| @Interceptors(PrintoutInterceptor.class)
| public @interface Printout {
| }
|
|
it still doest work :...(
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4040249#4040249
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4040249
19 years