Initialize and scan for root resource and provider classes using a
scanner.

@throws EFapsException on error
@return MsgFormat instance
355593
private MsgFormat init()
        throws EFapsException
    {
        if (!this.initialized) {
            for (final Class<?> clazz : new EsjpScanner().scan(EFapsFormatFactory.class)) {
                try {
                    final FormatFactory factory = (FormatFactory) clazz.newInstance();
                    final EFapsFormatFactory ano = clazz.getAnnotation(EFapsFormatFactory.class);
                    this.registry.put(ano.name(), factory);
                } catch (final InstantiationException | IllegalAccessException e) {
                    MsgFormat.LOG.error("Catched error on instantiotion", e);
                }
            }
            MsgFormat.LOG.info("registered FormatFactories: {}", this.registry);
            this.initialized = true;
        }
        return this;
    }
603170
protected function initializeSoapClient()
    {
        $this->soap = new SoapClient(
            dirname(__FILE__) . '/assets/services.wsdl',
            array(
                'user' => $this->username,
                'password' => $this->password,
                'location' => 'https://' . $this->server . '/EWS/Exchange.asmx',
                'classmap' => $this->classMap(),
                'curlopts' => $this->curl_options,
                'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
            )
        );

        return $this->soap;
    }
888851
@Override
    public Object getValue(final Object _object)
        throws EFapsException
    {
        final Instance inst = (Instance) super.getValue(_object);
        if (this.esjp == null) {
            try {
                final Class<?> clazz = Class.forName(this.className, false, EFapsClassLoader.getInstance());
                this.esjp = (IEsjpSelect) clazz.newInstance();
                final List<Instance> instances = new ArrayList<>();
                for (final Object obj : getOneSelect().getObjectList()) {
                    instances.add((Instance) super.getValue(obj));
                }
                if (this.parameters.isEmpty()) {
                    this.esjp.initialize(instances);
                } else {
                    this.esjp.initialize(instances, this.parameters.toArray(new String[this.parameters.size()]));
                }
            } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
                LOG.error("Catched error", e);
            }
        }
        return this.esjp.getValue(inst);
    }
390847
protected Instance createInstance()
        throws InstallationException
    {
        final Insert insert;
        try {
            insert = new Insert(getCiType());
            insert.add("Name", this.programName);
            if (getEFapsUUID() != null) {
                insert.add("UUID", getEFapsUUID().toString());
            }
            insert.execute();
        } catch (final EFapsException e)  {
            throw new InstallationException("Could not create " + getCiType() + " " + getProgramName(), e);
        }
        return insert.getInstance();
    }
710512
protected List<Instance> getSuper(final Instance _instance)
        throws EFapsException
    {
        final List<Instance> ret = new ArrayList<>();
        final QueryBuilder queryBldr = new QueryBuilder(getClassName4Type2Type());
        queryBldr.addWhereAttrEqValue(CIAdminProgram.Program2Program.From, _instance.getId());
        final MultiPrintQuery multi = queryBldr.getPrint();
        multi.addAttribute(CIAdminProgram.Program2Program.To);
        multi.execute();
        if (multi.next()) {
            final Instance instance = Instance.get(getClassName4Type().getType(),
                                             multi.<Long>getAttribute(CIAdminProgram.Program2Program.To));
            ret.add(instance);
            ret.addAll(getSuper(instance));
        }
        return ret;
    }
670349
@Override
    protected void initializeImpl()
    {
        String value=this.getConfigurationValue(FaxClientSpiConfigurationConstants.HTTP_CLIENT_CLASS_NAME_PROPERTY_KEY);
        if(value==null)
        {
            value=ApacheHTTPClient.class.getName();
        }

        //create HTTP client
        this.httpClient=(HTTPClient)ReflectionHelper.createInstance(value);
        
        //create configuration
        this.httpClientConfiguration=this.createHTTPClientConfiguration();

        //create fax job to HTTP request converter
        this.faxJob2HTTPRequestConverter=this.createFaxJob2HTTPRequestConverter();

        //create HTTP response handler
        this.httpResponseHandler=this.createHTTPResponseHandler();

        //get resources
        Map<FaxActionType,String> map=this.initializeFaxActionType2ResourceMap();
        this.faxActionType2ResourceMap=new HashMap<FaxActionType,String>(map);
        
        //get URL parameters
        this.urlParameters=this.initializeURLParameters();
    }
432902
@Override
    protected HylaFAXClient createResourceImpl()
    {
        HylaFAXClient client=null;
        try
        {
            //create new instance
            client=this.createHylaFAXClient();
            
            //open host
            client.open(this.host,this.port);
            
            //set user
            client.user(this.userName);
            
            //set transfer mode and type
            client.mode(this.mode);
            client.type(this.type);
            
            //set password
            if(this.password!=null)
            {
                client.pass(this.password);
            }
            
            if(this.enableAdminOperations)
            {
                //enable admin operations
                client.admin(this.password);
            }
        }
        catch(RuntimeException exception)
        {
            //release client
            this.releaseResource(client);

            throw exception;
        }
        catch(Exception exception)
        {
            //release client
            this.releaseResource(client);

            throw new FaxException("General error.",exception);
        }

        return client;
    }
697695
private function getRootDse()
    {
        if (!$this->rootDse) {
            $rootDse = $this->ldap->getRootDse();
            if (!$rootDse instanceof ActiveDirectory) {
                throw new UnsupportedRootDseException($rootDse);
            }
            $this->rootDse = $rootDse;
        }

        return $this->rootDse;
    }
1041937
protected void executeMethods()
        throws EFapsException
    {
        if (this.parent != null) {
            this.parent.executeMethods();
        }
        for (final CacheMethod cacheMethod : this.cacheMethods) {
            cacheMethod.callMethod();
        }
    }
379593
@Override
    protected Map<FaxActionType,String> initializeFaxActionType2ResourceMap()
    {
        //set resources
        Map<FaxActionType,String> map=new HashMap<FaxActionType,String>();
        map.put(FaxActionType.SUBMIT_FAX_JOB,"/v1/send");
        map.put(FaxActionType.CANCEL_FAX_JOB,"/v1/faxCancel");
        map.put(FaxActionType.GET_FAX_JOB_STATUS,"/v1/faxStatus");

        return map;
    }
63373
public function Init()
	{
		// If the $memberNodes is null then it is the first time and the member needs to be located
		if ( is_null( $this->memberPath ) )
		{
			/**
			 * @var \XBRL $taxonomy
			 */
			$taxonomy = $this->context->xbrlTaxonomy;

			// The primary item must be valid
			$piElement = $taxonomy->getElementByName( $this->primaryItem->LocalName );
			if ( ! $piElement )
			{
				// V13 requires an error
				throw XPath2Exception::withErrorCode( "xfie:invalidPrimaryItemConceptQName", "The primary item must exist in the member network" );
			}
			else if ( $piElement['substitutionGroup'] != \XBRL_Constants::$xbrliItem )
			{
				// Test V11
				$this->memberPath = "";
				return null;
			}

			$primaryItemName = "{$taxonomy->getTaxonomyXSD()}#{$piElement['id']}";

			if ( $this->linkRole instanceof Undefined || empty( $this->linkRole ) )
			{
				$primaryItems = $taxonomy->getDefinitionPrimaryItems( false );
				if ( ! isset( $primaryItems[ $primaryItemName ] ) )
				{
					$this->memberPath = "";
					$this->candidates = array();
					return null;
				}

				// $this->linkRole = $primaryItems[ $primaryItemName ]['roles'][0];
				$primaryItem = $primaryItems[ $primaryItemName ];
			}
			else
			{
				$primaryItems = $taxonomy->getDefinitionRolePrimaryItems( $this->linkRole );
				// BMS 2018-02-13 Throwing an error here is not appropriate.
				//				  The concept may not be a primary item in the network
				//				  but that just means there are no candidate members.
				if ( ! isset( $primaryItems[ $primaryItemName ] ) )
				{
					$this->memberPath = "";
					$this->candidates = array();
					return null;
				}
				$primaryItem = array( $this->linkRole => $primaryItems[ $primaryItemName ], 'roles' => array( $this->linkRole ) );
			}

			// if ( ! isset( $primaryItems[ $primaryItemName ] ) )
			// {
			// 	throw XPath2Exception::withErrorCode( "xfie:invalidPrimaryItemConceptQName", "The primary item must exist in the member network" );
			// }

			// Obtain the DRS
			$drs = $taxonomy->getPrimaryItemDRS( $primaryItem );

			// Check the dimension supplied is valid
			$dimTaxonomy = $taxonomy->getTaxonomyForNamespace( $this->dimension->NamespaceUri );
			if ( ! $dimTaxonomy )
			{
				throw XPath2Exception::withErrorCode( "xfie:invalidDimensionQName", "The dimension must exist in the member network" );
			}

			// The dimension reference MUST be valid
			$dimElement = $dimTaxonomy->getElementByName( $this->dimension->LocalName );
			if ( ! $dimElement )
			{
				// Test V12 requires an error
				throw XPath2Exception::withErrorCode( "xfie:invalidDimensionQName", "The dimension must exist in the member network" );
			}
			else if ( $dimElement['substitutionGroup'] != "xbrldt:dimensionItem" )
			{
				// Test V09 requires empty result
				$this->memberPath = "";
				return null;
			}

			// Make sure the requested member is one of the members
			$memTaxonomy = $taxonomy->getTaxonomyForNamespace( $this->member->NamespaceUri );
			$memElement = $dimTaxonomy->getElementByName( $this->member->LocalName );
			if ( ! $memElement )
			{
				$this->memberPath = "";
				return null;
			}

			$dimensionName = "{$dimTaxonomy->getTaxonomyXSD()}#{$dimElement['id']}";
			$memberName = "{$memTaxonomy->getTaxonomyXSD()}#{$memElement['id']}";
			$memberPaths = array();

			// Locate the dimension among the hypercubes
			foreach ( $drs as $hyprcubeId => $linkRoles )
			{
				foreach ( $linkRoles as $linkRole => $hypercube)
				{
					// Only use the link role provided if one is provided. Otherwise use all roles.
					if ( ! empty( $this->linkRole ) && $this->linkRole != $linkRole ) continue;

					$memberPaths = array_merge( $memberPaths, $hypercube['dimensions'][ $dimensionName ]['memberpaths'] );
				}
			}

			if ( ! $memberPaths )
			{
				$this->memberPath = "";
				return null;
			}

			if ( ! isset( $memberPaths[ $memElement['id'] ] ) )
			{
				$this->memberPath = "";
				return null;
			}

			$memberPath = null;
			foreach ( $memberPaths[ $memElement['id'] ] as $path )
			{
				if ( strpos( $path, $memberName ) !== false )
				{
					$memberPath = $path;
					break;
				}
			}

			if ( is_null( $memberPath ) )
			{
				return null;
			}

			foreach ( $memberPaths as $paths )
			{
				foreach ( $paths as $path )
				{
					// Remove self
					if ( $path == $memberPath ) continue;

					$pos = strpos( $path, $memberPath );
					if ( $pos === false || $pos != 0 ) continue;
					$this->candidates[] = $path;
				}
			}

			$this->memberPath = $memberPath;
			$this->index = 0;
		}
	}
1278086
public Instance execute()
        throws EFapsException
    {
        this.update = new Insert((IInsertStatement) getEQLStmt());
        StmtRunner.get().execute(this.update);
        return this.update.getInstance();
    }
556889
private void setProperties(final Instance _instance)
        throws EFapsException
    {
        final QueryBuilder queryBldr = new QueryBuilder(CIAdminCommon.Property);
        queryBldr.addWhereAttrEqValue(CIAdminCommon.Property.Abstract, _instance.getId());
        final MultiPrintQuery multi = queryBldr.getPrint();
        multi.addAttribute(CIAdminCommon.Property.Name, CIAdminCommon.Property.Value);
        multi.executeWithoutAccessCheck();
        while (multi.next()) {
            super.setProperty(multi.<String>getAttribute(CIAdminCommon.Property.Name),
                            multi.<String>getAttribute(CIAdminCommon.Property.Value));
        }
    }
1000994
public static JasperDesign getJasperDesign(final Instance _instance)
        throws EFapsException
    {
        final Checkout checkout = new Checkout(_instance);
        final InputStream source = checkout.execute();
        JasperDesign jasperDesign = null;
        try {
            JasperUtil.LOG.debug("Loading JasperDesign for :{}", _instance);
            final DefaultJasperReportsContext reportContext = DefaultJasperReportsContext.getInstance();
            final JRXmlLoader loader = new JRXmlLoader(reportContext,
                            JRXmlDigesterFactory.createDigester(reportContext));
            jasperDesign = loader.loadXML(source);
        } catch (final ParserConfigurationException e) {
            throw new EFapsException(JasperUtil.class, "getJasperDesign", e);
        } catch (final SAXException e) {
            throw new EFapsException(JasperUtil.class, "getJasperDesign", e);
        } catch (final JRException e) {
            throw new EFapsException(JasperUtil.class, "getJasperDesign", e);
        }
        return jasperDesign;
    }
789811
public static MfpDiagnostics initialize() {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "initialize");

    // We should only do this once
    if (singleton == null) {
      singleton = new MfpDiagnostics();
      singleton.register(packageList);
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "initialize");
    return singleton;
  }
380729
public SupportProvider newDefaultInstance() {
        try {
            return clazz.newInstance();
        } catch (InstantiationException e) {
            throw new RuntimeException("Failed to instantiate " + clazz, e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException("Failed to instantiate " + clazz, e);
        }
    }
893383
public static void initialize()
        throws EFapsException
    {
        try {
            final SystemConfiguration config = EFapsSystemConfiguration.get();
            if (config != null) {
                final int timeout = config.getAttributeValueAsInteger(KernelSettings.JMS_TIMEOOUT);
                if (timeout > 0) {
                    JmsSession.setSessionTimeout(timeout);
                }
            }

            //JMS-Configuration
            final SystemConfiguration configJms = SystemConfiguration.get(
                            UUID.fromString("65b6a1a8-c979-4471-b175-774593f1acd7"));
            final boolean active = configJms != null && configJms.getAttributeValueAsBoolean(JmsHandler.ACTIVEJMS);

            if (active) {
            // this check is necessary for first install and update
                if (CIAdminCommon.JmsAbstract.getType() != null) {
                    // remove any existing
                    JmsHandler.stop();
                    final Context ctx = new InitialContext();
                    final QueryBuilder queryBldr = new QueryBuilder(CIAdminCommon.JmsAbstract);
                    final MultiPrintQuery multi = queryBldr.getPrint();
                    multi.addAttribute(CIAdminCommon.JmsAbstract.Type,
                                    CIAdminCommon.JmsAbstract.Name,
                                    CIAdminCommon.JmsAbstract.ConnectionFactoryJNDI,
                                    CIAdminCommon.JmsAbstract.DestinationJNDI);
                    final SelectBuilder sel = new SelectBuilder().linkto(CIAdminCommon.JmsAbstract.ESJPLink)
                                    .file().label();
                    multi.addSelect(sel);
                    if (multi.executeWithoutAccessCheck()) {
                        //TODO add scanning
                    }
                    while (multi.next()) {
                        final Type type = multi.<Type>getAttribute(CIAdminCommon.JmsAbstract.Type);
                        final String connectionFactoryJNDI = multi
                                        .<String>getAttribute(CIAdminCommon.JmsAbstract.ConnectionFactoryJNDI);
                        final String destinationJNDI = multi
                                        .<String>getAttribute(CIAdminCommon.JmsAbstract.DestinationJNDI);
                        final String name = multi.<String>getAttribute(CIAdminCommon.JmsAbstract.Name);
                        final String esjp = multi.<String>getSelect(sel);

                        final Session session;
                        if (type.isKindOf(CIAdminCommon.JmsQueueAbstract.getType())) {
                            final QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) ctx
                                            .lookup(connectionFactoryJNDI);
                            final QueueConnection queueConnection;
                            if (JmsHandler.QUEUE2QUECONN.containsKey(connectionFactoryJNDI)) {
                                queueConnection = JmsHandler.QUEUE2QUECONN.get(connectionFactoryJNDI);
                            } else {
                                queueConnection = queueConnectionFactory.createQueueConnection();
                            }
                            JmsHandler.QUEUE2QUECONN.put(connectionFactoryJNDI, queueConnection);
                            session = queueConnection.createQueueSession(false,
                                            Session.AUTO_ACKNOWLEDGE);
                            queueConnection.start();
                        } else {
                            final TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) ctx
                                            .lookup(connectionFactoryJNDI);
                            final TopicConnection topicConn;
                            if (JmsHandler.TOPIC2QUECONN.containsKey(connectionFactoryJNDI)) {
                                topicConn = JmsHandler.TOPIC2QUECONN.get(connectionFactoryJNDI);
                            } else {
                                topicConn = topicConnectionFactory.createTopicConnection();
                            }
                            JmsHandler.TOPIC2QUECONN.put(connectionFactoryJNDI, topicConn);
                            if (type.isKindOf(CIAdminCommon.JmsTopicDurableConsumer.getType())) {
                                topicConn.setClientID(org.efaps.db.Context.getThreadContext().getPath() + ":" + name);
                            }
                            session = topicConn.createTopicSession(true, Session.AUTO_ACKNOWLEDGE);
                            topicConn.start();
                        }
                        final Destination dest = (Destination) ctx.lookup(destinationJNDI);

                        if (type.isKindOf(CIAdminCommon.JmsQueueProducer.getType())
                                        || type.isKindOf(CIAdminCommon.JmsTopicProducer.getType())) {
                            final MessageProducer producer;
                            if (type.isKindOf(CIAdminCommon.JmsQueueProducer.getType())) {
                                producer = session.createProducer(dest);
                            } else {
                                producer = ((TopicSession) session).createPublisher((Topic) dest);
                            }
                            producer.setDeliveryMode(DeliveryMode.PERSISTENT);
                            JmsHandler.NAME2DEF.put(name, new JmsDefinition(name, producer, session));
                        } else {
                            final MessageConsumer consumer;
                            if (type.isKindOf(CIAdminCommon.JmsQueueConsumer.getType())) {
                                consumer = session.createConsumer(dest);
                            } else if (type.isKindOf(CIAdminCommon.JmsTopicDurableConsumer.getType())) {
                                consumer = session.createDurableSubscriber((Topic) dest, name);
                            } else {
                                consumer = ((TopicSession) session).createSubscriber((Topic) dest);
                            }
                            @SuppressWarnings("unchecked")
                            final Class<? extends MessageListener> clazz = (Class<? extends MessageListener>) Class
                                            .forName(esjp.trim(), false, EFapsClassLoader.getInstance());
                            final MessageListener myListener = clazz.newInstance();
                            consumer.setMessageListener(myListener);
                        }

                    }
                }
            }
        } catch (final NamingException e) {
            // this means that a definition cannot be found.
            JmsHandler.LOG.warn("Naming exception for JMS", e);
        } catch (final JMSException e) {
            // this means normally that e.g. no jms server was found
            JmsHandler.LOG.error("JMS not working!!!!!!!", e);
        } catch (final ClassNotFoundException e) {
            throw new EFapsException("ClassNotFoundException", e);
        } catch (final InstantiationException e) {
            throw new EFapsException("InstantiationException", e);
        } catch (final IllegalAccessException e) {
            throw new EFapsException("IllegalAccessException", e);
        }
    }