private Object readResolve() throws ObjectStreamException { // look for the instance by uuid Object result = SessionFactoryObjectFactory.getInstance(uuid); if (result==null) { // in case we were deserialized in a different JVM, look for an instance with the same name // (alternatively we could do an actual JNDI lookup here....) result = SessionFactoryObjectFactory.getNamedInstance(name); if (result==null) { throw new InvalidObjectException("Could not find a stub SessionFactory named: " + name); } else { log.debug("resolved stub SessionFactory by name"); } } else { log.debug("resolved stub SessionFactory by uid"); } return result; }
private SessionFactory locateSessionFactory() { String jndiName = properties.getProperty(Environment.SESSION_FACTORY_NAME); if (jndiName != null) { return (SessionFactory)SessionFactoryObjectFactory.getNamedInstance(jndiName);
public Object getObjectInstance(Object reference, Name name, Context ctx, Hashtable env) throws Exception { log.debug("JNDI lookup: " + name); String uid = (String) ( (Reference) reference ).get(0).getContent(); return getInstance(uid); }
SessionFactoryStub(HibernateService service) { this.service = service; this.name = service.getJndiName(); try { uuid = (String) UUID_GENERATOR.generate(null, null); } catch (Exception e) { throw new AssertionFailure("Could not generate UUID"); } SessionFactoryObjectFactory.addInstance( uuid, name, this, service.getProperties() ); }
SessionFactoryObjectFactory.removeInstance(uuid, name, properties);
/** * Custom deserialization hook used during Session deserialization. * * @param ois The stream from which to "read" the factory * @throws IOException */ static SessionFactoryImpl deserialize(ObjectInputStream ois) throws IOException, ClassNotFoundException { String uuid = ois.readUTF(); boolean isNamed = ois.readBoolean(); String name = null; if ( isNamed ) { name = ois.readUTF(); } Object result = SessionFactoryObjectFactory.getInstance( uuid ); if ( result == null ) { log.trace( "could not locate session factory by uuid [" + uuid + "] during session deserialization; trying name" ); if ( isNamed ) { result = SessionFactoryObjectFactory.getNamedInstance( name ); } if ( result == null ) { throw new InvalidObjectException( "could not resolve session factory during session deserialization [uuid=" + uuid + ", name=" + name + "]" ); } } return ( SessionFactoryImpl ) result; }
public Object getObjectInstance(Object reference, Name name, Context ctx, Hashtable env) throws Exception { log.debug("JNDI lookup: " + name); String uid = (String) ( (Reference) reference ).get(0).getContent(); return getInstance(uid); }
SessionFactoryStub(HibernateService service) { this.service = service; this.name = service.getJndiName(); try { uuid = (String) UUID_GENERATOR.generate(null, null); } catch (Exception e) { throw new AssertionFailure("Could not generate UUID"); } SessionFactoryObjectFactory.addInstance( uuid, name, this, service.getProperties() ); }
SessionFactoryObjectFactory.removeInstance(uuid, name, properties);
private Object readResolve() throws ObjectStreamException { // look for the instance by uuid Object result = SessionFactoryObjectFactory.getInstance(uuid); if (result==null) { // in case we were deserialized in a different JVM, look for an instance with the same name // (alternatively we could do an actual JNDI lookup here....) result = SessionFactoryObjectFactory.getNamedInstance(name); if (result==null) { throw new InvalidObjectException("Could not find a stub SessionFactory named: " + name); } else { log.debug("resolved stub SessionFactory by name"); } } else { log.debug("resolved stub SessionFactory by uid"); } return result; }
private SessionFactory locateSessionFactory() { String jndiName = properties.getProperty(Environment.SESSION_FACTORY_NAME); if (jndiName != null) { return (SessionFactory)SessionFactoryObjectFactory.getNamedInstance(jndiName);
/** * @see StatisticsServiceMBean#setSessionFactoryJNDIName(java.lang.String) */ public void setSessionFactoryJNDIName(String sfJNDIName) { this.sfJNDIName = sfJNDIName; try { Object obj = new InitialContext().lookup(sfJNDIName); if (obj instanceof Reference) { Reference ref = (Reference) obj; setSessionFactory( (SessionFactory) SessionFactoryObjectFactory.getInstance( (String) ref.get(0).getContent() ) ); } else { setSessionFactory( (SessionFactory) obj ); } } catch (NameNotFoundException e) { log.error("No session factory with JNDI name " + sfJNDIName, e); setSessionFactory(null); } catch (NamingException e) { log.error("Error while accessing session factory with JNDI name " + sfJNDIName, e); setSessionFactory(null); } catch (ClassCastException e) { log.error("JNDI name " + sfJNDIName + " does not handle a session factory reference", e); setSessionFactory(null); } }
throw new AssertionFailure("Could not generate UUID"); SessionFactoryObjectFactory.addInstance(uuid, name, this, properties);
private Object readResolve() throws ObjectStreamException { log.trace("Resolving serialized SessionFactory"); // look for the instance by uuid Object result = SessionFactoryObjectFactory.getInstance(uuid); if (result==null) { // in case we were deserialized in a different JVM, look for an instance with the same name // (alternatively we could do an actual JNDI lookup here....) result = SessionFactoryObjectFactory.getNamedInstance(name); if (result==null) { throw new InvalidObjectException("Could not find a SessionFactory named: " + name); } else { log.debug("resolved SessionFactory by name"); } } else { log.debug("resolved SessionFactory by uid"); } return result; }
private SessionFactory locateSessionFactory() { String jndiName = properties.getProperty(Environment.SESSION_FACTORY_NAME); if (jndiName != null) { return (SessionFactory)SessionFactoryObjectFactory.getNamedInstance(jndiName);
/** * @see StatisticsServiceMBean#setSessionFactoryJNDIName(java.lang.String) */ public void setSessionFactoryJNDIName(String sfJNDIName) { this.sfJNDIName = sfJNDIName; try { Object obj = new InitialContext().lookup(sfJNDIName); if (obj instanceof Reference) { Reference ref = (Reference) obj; setSessionFactory( (SessionFactory) SessionFactoryObjectFactory.getInstance( (String) ref.get(0).getContent() ) ); } else { setSessionFactory( (SessionFactory) obj ); } } catch (NameNotFoundException e) { log.error("No session factory with JNDI name " + sfJNDIName, e); setSessionFactory(null); } catch (NamingException e) { log.error("Error while accessing session factory with JNDI name " + sfJNDIName, e); setSessionFactory(null); } catch (ClassCastException e) { log.error("JNDI name " + sfJNDIName + " does not handle a session factory reference", e); setSessionFactory(null); } }
throw new AssertionFailure("Could not generate UUID"); SessionFactoryObjectFactory.addInstance(uuid, name, this, properties);
private Object readResolve() throws ObjectStreamException { log.trace("Resolving serialized SessionFactory"); // look for the instance by uuid Object result = SessionFactoryObjectFactory.getInstance(uuid); if (result==null) { // in case we were deserialized in a different JVM, look for an instance with the same name // (alternatively we could do an actual JNDI lookup here....) result = SessionFactoryObjectFactory.getNamedInstance(name); if (result==null) { throw new InvalidObjectException("Could not find a SessionFactory named: " + name); } else { log.debug("resolved SessionFactory by name"); } } else { log.debug("resolved SessionFactory by uid"); } return result; }
private SessionFactory locateSessionFactory() { String jndiName = properties.getProperty(Environment.SESSION_FACTORY_NAME); if (jndiName != null) { return (SessionFactory)SessionFactoryObjectFactory.getNamedInstance(jndiName);