All EJSP programs in the eFaps database are read and stored in the
mapping {@link #name2Source} for further using.

@see #name2Source
@throws InstallationException if ESJP Java programs could not be read
778412
protected void readESJPPrograms()
        throws InstallationException
    {
        try  {
            final QueryBuilder queryBldr = new QueryBuilder(this.esjpType);
            final MultiPrintQuery multi = queryBldr.getPrint();
            multi.addAttribute("Name");
            multi.executeWithoutAccessCheck();
            while (multi.next()) {
                final String name = multi.<String>getAttribute("Name");
                final Long id = multi.getCurrentInstance().getId();
                final String path = "/" + name.replaceAll("\\.", Matcher.quoteReplacement("/"))
                      + JavaFileObject.Kind.SOURCE.extension;
                final URI uri;
                try {
                    uri = new URI("efaps", null, path, null, null);
                } catch (final URISyntaxException e) {
                    throw new InstallationException("Could not create an URI for " + path, e);
                }
                this.name2Source.put(name, new SourceObject(uri, name, id));
            }
        } catch (final EFapsException e) {
            throw new InstallationException("Could not fetch the information about installed ESJP's", e);
        }
    }
565706
public byte[] read(final String _resourceName)
    {
        byte[] ret = null;
        EFapsClassLoader.LOG.debug("read ''", _resourceName);
        try {
            final QueryBuilder queryBuilder = new QueryBuilder(this.classType);
            queryBuilder.addWhereAttrEqValue("Name", _resourceName);
            final InstanceQuery query = queryBuilder.getCachedQuery("esjp");
            query.execute();
            if (query.next()) {
                final Checkout checkout = new Checkout(query.getCurrentValue());
                final InputStream is = checkout.executeWithoutAccessCheck();

                ret = new byte[is.available()];
                is.read(ret);
                is.close();
            }
        } catch (final EFapsException e) {
            EFapsClassLoader.LOG.error("could not access the Database for reading '{}' - {}", _resourceName, e);
        } catch (final IOException e) {
            EFapsClassLoader.LOG.error("could not read the Javaclass '{}' - {}", _resourceName, e);
        }
        return ret;
    }
1061934
public boolean loadJMXSettings() {
        Log log = config.getLog();
        
        // load settings file
        // if non-existant, nothing to load so return success
        File settingsFile = getSettingsFile();
        if (!settingsFile.exists()) { return true; }
        
        // validate file is readable
        if (!settingsFile.canRead()) {
            log.warn("Temporary directory not readable for JMX settings");
            return false;
        }
        
        // create the properties
        Properties properties = new Properties();
        
        // load the properties
        FileInputStream in = null;
        try { 
            in = new FileInputStream(settingsFile);
            properties.load(in);
        }
        catch (IOException ioe) {
            log.error("Unable to load JMX settings: " + ioe.getMessage());
            log.error(ioe);
            return false;
        }
        finally {
            try { if (in != null) { in.close(); } }
            catch (IOException e) { /* ignore */ }
        }
        
        // load the settings
        String value;
        
        value = properties.getProperty("EdenSpace");
        if (value != null) { edenSpace = new String[] { value }; }
        
        value = properties.getProperty("SurvivorSpace");
        if (value != null) { survivorSpace = new String[] { value }; }
        
        value = properties.getProperty("PermGen");
        if (value != null) { permGen = new String[] { value }; }
        
        value = properties.getProperty("TenuredGen");
        if (value != null) { tenuredGen = new String[] { value }; }
        
        value = properties.getProperty("YoungCollector");
        if (value != null) { youngCollector = new String[] { value }; }
        
        value = properties.getProperty("TenuredCollector");
        if (value != null) { tenuredCollector = new String[] { value }; }
        
        // success
        return true;
    }
1287071
protected static void setupDataSourceProviders(){
		List<String> providerProperties = new LinkedList<String>();
		for (Object key: configuration.keySet()){
			String keyName = (String)key;
			if (keyName.startsWith(PROVIDER_PROPERTY_NAME)){
				providerProperties.add(keyName);
			}
		}
		
		dataSourceProviders = new HashMap<String, DataSourceProvider>();
		for (String keyName: providerProperties){
			String providerName = keyName.substring(PROVIDER_PROPERTY_NAME.length(), keyName.length());
			String providerClassName = configuration.getProperty(keyName);
			configuration.remove(keyName);
			DataSourceProvider dsp = null;
			try {
				dsp = (DataSourceProvider)Class.forName(providerClassName).newInstance();
				dataSourceProviders.put(providerName, dsp);
			} catch (Throwable t) {
				if (t instanceof NoClassDefFoundError){
					log.debug("DataSourceProvider not initialized for '" + providerName + "' because the provider class was not found: " + t.getMessage());
				}else{
					log.error("Cannot instantiate DataSourceProvider for '" + providerName + "': " + providerClassName, t);
				}
			}
		}
	}
1093317
public void configureWebApp() throws Exception
    {
        Set tlds = new HashSet();
        
        // Find tld's from web.xml
        // When the XMLConfigurator (or other configurator) parsed the web.xml,
        // It should have created aliases for all TLDs.  So search resources aliases
        // for aliases ending in tld
        if (_context.getResourceAliases()!=null)
        {
            Iterator iter=_context.getResourceAliases().values().iterator();
            while(iter.hasNext())
            {
                String location = (String)iter.next();
                if (location!=null && location.toLowerCase().endsWith(".tld"))
                {
                    if (!location.startsWith("/"))
                        location="/WEB-INF/"+location;
                    Resource l=_context.getBaseResource().addPath(location);
                    tlds.add(l);
                }
            }
        }
        
        // Look for any tlds in WEB-INF directly.
        if (_context.getWebInf()!=null)
        {
            String[] contents = _context.getWebInf().list();
            for (int i=0;i<contents.length;i++)
            {
                if (contents[i]!=null && contents[i].toLowerCase().endsWith(".tld"))
                {
                    Resource l=_context.getWebInf().addPath(contents[i]);
                    tlds.add(l);
                }
                
            }

            // Look for any tlds in the META-INF of included jars
            Resource lib=_context.getWebInf().addPath("lib/");
            if (lib.exists() && lib.isDirectory())
            {
                contents = lib.list();
                for (int i=0;i<contents.length;i++)
                {
                    if (contents[i]!=null && contents[i].toLowerCase().endsWith(".jar"))
                    {
                        Resource l=lib.addPath(contents[i]);
                        Resource meta=Resource.newResource("jar:"+l+"!/META-INF/");
                        if (meta.exists())
                        {
                            String[] meta_contents=meta.list();
                            
                            for (int j=0;j<meta_contents.length;j++)
                            {
                                if (meta_contents[j]!=null && meta_contents[j].toLowerCase().endsWith(".tld"))
                                {
                                    Resource t=meta.addPath(meta_contents[j]);
                                    tlds.add(t);
                                }
                            }
                        }
                    }
                }
            }
        }
        
        // Create a TLD parser
        XmlParser parser = new XmlParser(false);
        
        parser.redirectEntity("web-jsptaglibrary_1_1.dtd",WebApplicationContext.class.getResource("/javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd"));
        parser.redirectEntity("web-jsptaglibrary_1_2.dtd",WebApplicationContext.class.getResource("/javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd"));
        parser.redirectEntity("web-jsptaglibrary_2_0.xsd",WebApplicationContext.class.getResource("/javax/servlet/jsp/resources/web-jsptaglibrary_2_0.xsd"));
        parser.setXpath("/taglib/listener/listener-class");
        // Parse all the discovered TLDs
        Iterator iter = tlds.iterator();
        while (iter.hasNext())
        {
            try
            {
                Resource tld = (Resource)iter.next();
                if (log.isDebugEnabled()) log.debug("TLD="+tld);
                
                XmlParser.Node root = parser.parse(tld.getURL());
                
                for (int i=0;i<root.size();i++)
                {
                    Object o=root.get(i);
                    if (o instanceof XmlParser.Node)
                    {
                        XmlParser.Node node = (XmlParser.Node)o;
                        if ("listener".equals(node.getTag()))
                        {
                            String className=node.getString("listener-class",false,true);
                            if (log.isDebugEnabled()) log.debug("listener="+className);
                            
                            try
                            {
                                Class listenerClass=getWebApplicationContext().loadClass(className);
                                EventListener l=(EventListener)listenerClass.newInstance();
                                _context.addEventListener(l);
                            }
                            catch(Exception e)
                            {
                                log.warn("Could not instantiate listener "+className,e);
                            }
                        }
                    }
                }
            }
            catch(Exception e)
            {
                log.warn(e);
            }
        }
    }
174970
protected Object processJavaColon(EJBBinding binding, JavaColonNamespace jndiType, String lookupName) throws NamingException {

        Object instance = null;

        if (binding == null) {
            return null;
        }

        // Home and remote interfaces are not supported in Liberty
        if (binding.isHome() && !homeRuntime) {
            throwCannotInstanciateUnsupported(binding, jndiType, lookupName,
                                              "JNDI_CANNOT_INSTANTIATE_HOME_CNTR4008E");
        }

        if (!binding.isLocal && !remoteRuntime) {
            throwCannotInstanciateUnsupported(binding, jndiType, lookupName,
                                              "JNDI_CANNOT_INSTANTIATE_REMOTE_CNTR4009E");
        }

        try {
            EJSHome home = binding.homeRecord.getHomeAndInitialize();

            if (binding.isHome()) {
                EJSWrapperCommon wc = home.getWrapper();
                if (binding.isLocal) {
                    instance = wc.getLocalObject();
                } else {
                    instance = home.getContainer().getEJBRuntime().getRemoteReference(wc.getRemoteWrapper());
                }
            } else {
                // Use interface name to create the business object
                if (binding.isLocal) {
                    instance = home.createLocalBusinessObject(binding.interfaceIndex, null);
                } else {
                    instance = home.createRemoteBusinessObject(binding.interfaceIndex, null);
                }
            }
        } catch (Throwable t) {
            throwCannotInstanciateObjectException(binding,
                                                  jndiType,
                                                  lookupName,
                                                  t);
        }

        return instance;
    }
953263
static void loadLibrary() {
    try {
      File dir = Files.createTempDirectory("libjsass-").toFile();
      dir.deleteOnExit();

      if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
        System.load(saveLibrary(dir, "sass"));
      }

      System.load(saveLibrary(dir, "jsass"));
    } catch (Exception exception) {
      LOG.warn(exception.getMessage(), exception);
      throw new LoaderException(exception);
    }
  }
7119
protected List<T> readSources()
        throws EFapsException
    {
        final List<T> ret = new ArrayList<>();
        final QueryBuilder queryBldr = new QueryBuilder(getClassName4Type());
        final MultiPrintQuery multi = queryBldr.getPrint();
        multi.addAttribute(CIAdminProgram.Abstract.Name);
        multi.executeWithoutAccessCheck();
        while (multi.next()) {
            final String name = multi.<String>getAttribute(CIAdminProgram.StaticCompiled.Name);
            ret.add(getNewSource(name, multi.getCurrentInstance()));
        }
        return ret;
    }
533992
public static void setupJMF() {
        // .jmf is the place where we store the jmf.properties file used
        // by JMF. if the directory does not exist or it does not contain
        // a jmf.properties file. or if the jmf.properties file has 0 length
        // then this is the first time we're running and should continue to
        // with JMFInit
        String homeDir = System.getProperty("user.home");
        File jmfDir = new File(homeDir, ".jmf");
        String classpath = System.getProperty("java.class.path");
        classpath += System.getProperty("path.separator")
                + jmfDir.getAbsolutePath();
        System.setProperty("java.class.path", classpath);

        if (!jmfDir.exists())
            jmfDir.mkdir();

        File jmfProperties = new File(jmfDir, "jmf.properties");

        if (!jmfProperties.exists()) {
            try {
                jmfProperties.createNewFile();
            }
            catch (IOException ex) {
                LOGGER.log(Level.FINE, "Failed to create jmf.properties", ex);
            }
        }

        // if we're running on linux checkout that libjmutil.so is where it
        // should be and put it there.
        runLinuxPreInstall();

        // if (jmfProperties.length() == 0) {
        new JMFInit(null, false);
        // }

    }
1180979
@Override
    public void bindJavaApp(String name, EJBBinding bindingObject) {
        String bindingName = buildJavaAppName(name);
        ejbJavaColonHelper.addAppBinding(moduleMetaData, bindingName, bindingObject);
    }
559659
private void getEJBWithPathClasses(Set<String> classeNames, EJBEndpoint ejb, String ejbInterfaceName, ClassLoader appClassloader) {
        final String methodName = "getEJBWithPathClasses";
        if (tc.isEntryEnabled())
            Tr.entry(tc, methodName, classeNames, ejb, ejbInterfaceName);
        if (classeNames == null) {
            if (tc.isEntryEnabled())
                Tr.exit(tc, methodName, Collections.emptySet());
        }

        Class<Path> pathClass = Path.class;
        final String ejbClassName = (ejbInterfaceName == null) ? ejb.getClassName() : ejbInterfaceName;
        Class<?> c = null;
        try {
            c = appClassloader.loadClass(ejbClassName);
        } catch (ClassNotFoundException e) {

            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "getEJBWithPathClasses() exit - due to Class Not Found for " + ejbClassName + ": " + e);
            }
        }

        if (c != null && c.getAnnotation(pathClass) != null) {
            classeNames.add(ejbClassName);
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, methodName, classeNames);
    }
802243
@Override
    protected void initializeImpl()
    {
        //initialize
        super.initializeImpl();

        //get temporary directory
        File directory=IOHelper.getFax4jInternalTemporaryDirectory();

        //get exe path
        String fax4jExe=Fax4jExeConstants.FAX4J_EXE.toString();
        File exeFile=new File(directory,fax4jExe);
        if(exeFile.exists())
        {
            this.fax4jExecutableFileLocation=exeFile.getPath();
        }
        else
        {
            exeFile=IOHelper.getFileFromNativePath(fax4jExe);
            if(exeFile!=null)
            {
                this.fax4jExecutableFileLocation=exeFile.getPath();
            }
        }

        //get fax server name
        this.faxServerName=WindowsFaxClientSpiHelper.getServerNameFromConfiguration(this);

        //set defaults
        this.useWindowsCommandPrefix=false;
    }
1025714
private void readResources(Storepoint phoenixProject)
   {
      Resources resources = phoenixProject.getResources();
      if (resources != null)
      {
         for (net.sf.mpxj.phoenix.schema.Project.Storepoints.Storepoint.Resources.Resource res : resources.getResource())
         {
            Resource resource = readResource(res);
            readAssignments(resource, res);
         }
      }
   }
850822
public boolean setupDirectDataSourceConnection() throws DBException
    {
        if (m_JDBCConnection != null)
            return true;
        try {
            if (m_datasourceFactory == null)
            {
                String strClassName = this.getProperty(SQLParams.DATASOURCE_FACTORY);
            	strClassName = ClassServiceUtility.getFullClassName(strClassName);
                try {
                	m_datasourceFactory = (DatasourceFactory)ClassServiceUtility.getClassService().makeObjectFromClassName(strClassName);
             	    //xClass<?> c = Class.forName(strClassName);
             	    //xm_datasourceFactory = (DatasourceFactory)c.newInstance();
                } catch (Exception e) {
            		Utility.getLogger().warning("Error on create class: " + strClassName);
            		e.printStackTrace();
                }
            }
            if (m_datasourceFactory == null)
                return false;   // No factory
            ConnectionPoolDataSource poolDataSource = m_datasourceFactory.getPooledDataSource(this);
            if (poolDataSource != null)
            	if (poolDataSource.getPooledConnection() != null)
            		m_JDBCConnection = poolDataSource.getPooledConnection().getConnection();
            if (m_JDBCConnection == null)
            {   // Otherwise, just try plain datasource connection
                DataSource dataSource = m_datasourceFactory.getFakePooledDataSource(this);
                if (dataSource != null)
                    m_JDBCConnection = dataSource.getConnection();
            }
            if (m_JDBCConnection == null)
            {   // Otherwise, just try plain datasource connection
                DataSource dataSource = m_datasourceFactory.getDataSource(this);
                if (dataSource != null)
                    m_JDBCConnection = dataSource.getConnection();
                else
                    return false;   // Failure
            }
        } catch (SQLException e) {
            return false;   // Failure
        }
        return true;    // Success!
    }
226666
private Map<String, IEsjpSelect> getEsjpSelect(final List<Instance> _instances)
        throws Exception
    {
        final Map<String, IEsjpSelect> ret = new HashMap<>();
        if (!_instances.isEmpty()) {
            for (final Entry<String, AbstractSelect> entry : getAlias2Selects().entrySet()) {
                if (entry.getValue() instanceof ExecSelect) {
                    final Class<?> clazz = Class.forName(entry.getValue().getSelect(), false, EFapsClassLoader
                                    .getInstance());
                    final IEsjpSelect esjp = (IEsjpSelect) clazz.newInstance();
                    final List<String> parameters = ((ExecSelect) entry.getValue()).getParameters();
                    if (parameters.isEmpty()) {
                        esjp.initialize(_instances);
                    } else {
                        esjp.initialize(_instances, parameters.toArray(new String[parameters.size()]));
                    }
                    ret.put(entry.getKey(), esjp);
                }
            }
        }
        return ret;
    }
424710
protected void readFromDB()
        throws EFapsException
    {
        readFromDBAttributes();
        this.roles.clear();
        for (final Role role : getRolesFromDB()) {
            add(role);
        }
        this.groups.clear();
        for (final Group group : getGroupsFromDB(null)) {
            add(group);
        }
        this.companies.clear();
        for (final Company company : getCompaniesFromDB(null)) {
            add(company);
        }
        this.associations.clear();
        for (final Association association : getAssociationsFromDB(null)) {
            add(association);
        }
    }
457105
private void checkProgramInstance()
    {
        try {
            if (EventDefinition.LOG.isDebugEnabled()) {
                EventDefinition.LOG.debug("checking Instance: {} - {}", this.resourceName, this.methodName);
            }
            if (!EFapsClassLoader.getInstance().isOffline()) {
                final Class<?> cls = Class.forName(this.resourceName, true, EFapsClassLoader.getInstance());
                final Method method = cls.getMethod(this.methodName, new Class[] { Parameter.class });
                final Object progInstance = cls.newInstance();
                if (EventDefinition.LOG.isDebugEnabled()) {
                    EventDefinition.LOG.debug("found Class: {} and method {}", progInstance, method);
                }
            }
        } catch (final ClassNotFoundException e) {
            EventDefinition.LOG.error("could not find Class: '{}'", this.resourceName, e);
        } catch (final InstantiationException e) {
            EventDefinition.LOG.error("could not instantiat Class: '{}'", this.resourceName, e);
        } catch (final IllegalAccessException e) {
            EventDefinition.LOG.error("could not access Class: '{}'", this.resourceName, e);
        } catch (final SecurityException e) {
            EventDefinition.LOG.error("could not access Class: '{}'", this.resourceName, e);
        } catch (final NoSuchMethodException e) {
            EventDefinition.LOG.error("could not find method: '{}' in class '{}'",
                            new Object[] { this.methodName, this.resourceName, e });
        }
    }