Package javax.naming

Examples of javax.naming.RefAddr


           
            //Construct the desired AdministeredObject
            Object newobj = Class.forName(ref.getClassName()).newInstance();

            //version number MUST exist and it MUST be this version or a supported version
            RefAddr versionAddr = ref.get(REF_VERSION);

            //Support reading previous object versions here (2.0, 2.1 etc.). Floor is 2.0
            if (versionAddr == null || !(newobj instanceof com.sun.messaging.AdministeredObject)) {
                //if version number does not exist or it is not an AdministeredObject
                throw new MissingVersionNumberException();
            } else {
                version = (String)versionAddr.getContent();
                //Support reading previous object versions here (2.0, 2.1 etc.). Floor is 2.0
                if ( ! (AO_VERSION_STR.equals(version) ||
                        AO_VERSION_STR_JMQ3B.equals(version) ||
                        AO_VERSION_STR_JMQ2.equals(version)) ){
                    //Reference contains a bad version number
                    throw new UnsupportedVersionNumberException(version);
                }
                if (ref.size() < 2) {
                    //Reference is corrupted
                    throw new CorruptedConfigurationPropertiesException();
                }
                RefAddr readOnlyAddr = ref.get(REF_READONLY);
                if ("true".equals((String)readOnlyAddr.getContent())) {
                    //Reference has readOnly set
                    readOnly = true;
                }
                ((AdministeredObject)newobj).storedVersion = version;
            }

            RefAddr refaddr;                                                                              
            String refContent;
            //Skip the version # and r/o flag (start at 2)
            //System.out.println("AOtoString="+ newobj.toString());
            for (int i = 2; i < ref.size(); i++) {
                refaddr = ref.get(i);
                refContent = (String)refaddr.getContent();
                //System.out.println("gOI:ref#="+i+"; refCntnt="+refContent);
                //Guard against null values coming back from JNDI
                //Some service-providers will return `null'; others will return "" (empty string)
                if (refContent == null) {
                    refContent = "";
                }
                //If property fails to set then ignore since we may have looked up a newer object
                try {
                    //XXX RFE:tharakan
                    //Need to add support migrating 2.x properties to 3.x
                    //System.out.println("gOI:settingProp");
                    //System.out.println("gOI:propName="+refaddr.getType());
                    ((AdministeredObject)newobj).setProperty(refaddr.getType(), refContent);
                    //System.out.println("gOI:propName="+refaddr.getType()+" set successfully");
                } catch (Exception bpe) {
                    //Ignore exception
                    //System.out.println("gOI:propName="+refaddr.getType()+" exception; "+bpe.getMessage());
                    //bpe.printStackTrace();
View Full Code Here


                } else {
                    throw new MissingVersionNumberException();
                }
            }
            //version number MUST exist and it MUST be the same as AO_VERSION_STR_JMQ1
            RefAddr versionAddr = ref.get(REF_VERSION);
            if (versionAddr == null) {
                //version number does not exist
                throw new MissingVersionNumberException();
            } else {
                String version = null;
                if (!AO_VERSION_STR_JMQ1.equals(version = (String)versionAddr.getContent())) {
                    //version number does not match
                    throw new UnsupportedVersionNumberException(version);
                }
                ((AdministeredObject)destObj).storedVersion = version;
            }
            RefAddr destAddr = ref.get(REF_DESTNAME);
            if (destAddr != null) {
                    destObj.setProperty(DestinationConfiguration.imqDestinationName,
                                            (String)destAddr.getContent());
                    return destObj;
            } else {
                    throw new CorruptedConfigurationPropertiesException();
            }
        }
View Full Code Here

        String password = null;
       
        Enumeration refs = reference.getAll();
        while (refs.hasMoreElements())
        {
            RefAddr refAddr = (RefAddr)refs.nextElement();
            String name = refAddr.getType();          
            String value =  (String)refAddr.getContent();
            if (name.equalsIgnoreCase("user"))
                user = value;
            else if (name.equalsIgnoreCase("pwd"))
                password = value;
            else
View Full Code Here

    }
   
    public void testResourceReference ()
    throws Exception
    {
        RefAddr refAddr = new StringRefAddr("val", "10");
        Reference ref = new Reference(SomeObject.class.getName(), refAddr, SomeObjectFactory.class.getName(), null);
       
        InitialContext icontext = new InitialContext();
        Resource resource = new Resource (null, "resourceByRef", ref);
        NamingEntry ne = NamingEntryUtil.lookupNamingEntry(null, "resourceByRef");
View Full Code Here

         */
        public Object getObjectInstance(Object arg0, Name arg1, Context arg2, Hashtable arg3) throws Exception
        {
            Reference ref = (Reference)arg0;
           
            RefAddr refAddr = ref.get(0);
            String valueName = refAddr.getType();
            if (!valueName.equalsIgnoreCase("val"))
                throw new RuntimeException("Unrecognized refaddr type = "+valueName);
          
            String value = (String)refAddr.getContent();
           
            return new SomeObject(Integer.parseInt(value.trim()));
         
        }
View Full Code Here

         * @return
         * @throws NamingException
         */
        public Reference getReference() throws NamingException
        {
            RefAddr refAddr = new StringRefAddr("val", String.valueOf(getValue()));
            Reference ref = new Reference(SomeOtherObject.class.getName(), refAddr, SomeOtherObjectFactory.class.getName(), null);
            return ref;
        }
View Full Code Here

         */
        public Object getObjectInstance(Object arg0, Name arg1, Context arg2, Hashtable arg3) throws Exception
        {
          Reference ref = (Reference)arg0;
           
            RefAddr refAddr = ref.get(0);
            String valueName = refAddr.getType();
            if (!valueName.equalsIgnoreCase("val"))
                throw new RuntimeException("Unrecognized refaddr type = "+valueName);
          
            String value = (String)refAddr.getContent();
           
            return new SomeOtherObject(value.trim());
        }
View Full Code Here

        } catch (ClassNotFoundException e) {
            throw new DeploymentException("Could not load resource-env-ref entry class " + type, e);
        }
        if (gerResourceEnvRef != null && gerResourceEnvRef.isSetReferenceClass()) {
            String clazz = gerResourceEnvRef.getReferenceClass();
            RefAddr addr = null;
            if (gerResourceEnvRef.isSetStringAddrType()) {
                String refAddrType = getStringValue(gerResourceEnvRef.getStringAddrType());
                String refAddr = getStringValue(gerResourceEnvRef.getStringAddr());
                addr = new StringRefAddr(refAddrType, refAddr);
            } else {
View Full Code Here

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oas = new ObjectOutputStream(baos);
        oas.writeObject(dataSourceDescription);
        oas.flush();
        byte[] content = baos.toByteArray();
        RefAddr addr = new BinaryRefAddr(DataSourceDescription.class.getName(), content);
        return new Reference(DataSourceService.class.getName(), addr, DataSourceGBeanObjectFactory.class.getName(), null);
    }
View Full Code Here

        if ((obj == null) || !(obj instanceof Reference))
            return null;
        Reference ref = (Reference) obj;
        if (!"javax.sql.DataSource".equals(ref.getClassName()))
            return null;
        RefAddr ra;
        ra = ref.get("rawDataSource");
        if (ra == null)
            throw new RuntimeException("mising rawDataSource name");
        String rawDS = ra.getContent().toString();
        ra = ref.get("threadsCount");
        if (ra == null)
            throw new RuntimeException("mising rawDataSource name");
        int tc = Integer.parseInt(ra.getContent().toString());
        return create(rawDS, tc);
    }
View Full Code Here

TOP

Related Classes of javax.naming.RefAddr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.