// Path: fx-cdi/src/main/java/com/cathive/fx/cdi/CdiFXMLLoader.java
// class CdiFXMLLoader extends FXMLLoader {
// 
//     // Some marker strings for unspecified values.
//     public static final String LOCATION_UNSPECIFIED = "$$$LOCATION_UNSPECIFIED$$$";
//     public static final String RESOURCES_UNSPECIFIED = "$$$RESOURCES_UNSPECIFIED$$$";
//     public static final String CHARSET_UNSPECIFIED = "$$$CHARSET_UNSPECIFIED$$$";
// 
//     /**
//      * A reference to all the package names that won't work as supposed to when trying
//      * to instantiate beans from within via CDI in conjunction with FXML builders.
//      * <p>This will avoid an exception message caused by a {@link com.sun.javafx.fxml.PropertyNotFoundException}
//      * <em>'Property "${propertyName}" does not exist or is read-only'</em>.</p>
//      * @see com.sun.javafx.fxml.PropertyNotFoundException
//      */
//     private static final String[] CDI_BLACKLIST = new String[] {
//             "javafx",
//             "java.awt",
//             "javax.swing"
//     };
// 
//     /** A default (non-CDI aware) JavaFX builder factory. */
//     private final JavaFXBuilderFactory defaultBuilderFactory;
// 
//     /**
//      * Default constructor.
//      */
//     CdiFXMLLoader() {
// 
//         super();
// 
//         // Uses the currently loaded CDI implementation to look up controller classes
//         // that have been specified via "fx:controller='...'" in our FXML files.
//         this.setControllerFactory((aClass) -> CDI.current().select(aClass));
// 
//         // Initializes the default JavaFX builder factory to be used for non CDI-aware beans.
//         this.defaultBuilderFactory = new JavaFXBuilderFactory();
// 
//         this.setBuilderFactory((aClass) -> {
// 
//             // Uses the default builder factory to retrieve builders where applicable.
//             final Builder<?> defaultBuilder = defaultBuilderFactory.getBuilder(aClass);
//             if (defaultBuilder != null) {
//                 return defaultBuilder;
//             }
// 
//             // Make sure that we use a "null" builder for components that are 'blacklisted'.
//             final String packageName = aClass.getPackage().getName();
//             for (final String blacklisted : CDI_BLACKLIST) {
//                 if (packageName.startsWith(blacklisted)) {
//                     return null;
//                 }
//             }
// 
//             return new CdiFXMLComponentBuilder(aClass);
// 
//         });
// 
//     }
// 
//     @Override
//     public String toString() {
//         return String.format("[CDI-aware] %s", super.toString());
//     }
// 
// }


import com.cathive.fx.inject.core.FXMLLoaderParams;
import javafx.fxml.FXMLLoader;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.InjectionPoint;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ResourceBundle;
import static com.cathive.fx.cdi.CdiFXMLLoader.*;
/*
 * Copyright (C) 2013,2014 The Cat Hive Developers.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.cathive.fx.cdi;




/**
 * This factory is responsible for the production of CDI-aware {@link javafx.fxml.FXMLLoader} instances.
 *
 * @author Benjamin P. Jung
 */
@ApplicationScoped
class CdiFXMLLoaderFactory {

    /**
     * Create a CDI-aware FXMLLoader.
     * If an annotation of type @FXMLLoaderParams can be found, use it's parameters
     * to configure the FXMLLoader instance that shall be used to perform the loading
     * of the FXML file.
     *
     * @param injectionPoint
     *     Injection point.
     * @return
     *     A new FXMLLoader instance.
     */
    @Produces
    @FXMLLoaderParams
// Path: fx-cdi/src/main/java/com/cathive/fx/cdi/CdiFXMLLoader.java
// class CdiFXMLLoader extends FXMLLoader {
// 
//     // Some marker strings for unspecified values.
//     public static final String LOCATION_UNSPECIFIED = "$$$LOCATION_UNSPECIFIED$$$";
//     public static final String RESOURCES_UNSPECIFIED = "$$$RESOURCES_UNSPECIFIED$$$";
//     public static final String CHARSET_UNSPECIFIED = "$$$CHARSET_UNSPECIFIED$$$";
// 
//     /**
//      * A reference to all the package names that won't work as supposed to when trying
//      * to instantiate beans from within via CDI in conjunction with FXML builders.
//      * <p>This will avoid an exception message caused by a {@link com.sun.javafx.fxml.PropertyNotFoundException}
//      * <em>'Property "${propertyName}" does not exist or is read-only'</em>.</p>
//      * @see com.sun.javafx.fxml.PropertyNotFoundException
//      */
//     private static final String[] CDI_BLACKLIST = new String[] {
//             "javafx",
//             "java.awt",
//             "javax.swing"
//     };
// 
//     /** A default (non-CDI aware) JavaFX builder factory. */
//     private final JavaFXBuilderFactory defaultBuilderFactory;
// 
//     /**
//      * Default constructor.
//      */
//     CdiFXMLLoader() {
// 
//         super();
// 
//         // Uses the currently loaded CDI implementation to look up controller classes
//         // that have been specified via "fx:controller='...'" in our FXML files.
//         this.setControllerFactory((aClass) -> CDI.current().select(aClass));
// 
//         // Initializes the default JavaFX builder factory to be used for non CDI-aware beans.
//         this.defaultBuilderFactory = new JavaFXBuilderFactory();
// 
//         this.setBuilderFactory((aClass) -> {
// 
//             // Uses the default builder factory to retrieve builders where applicable.
//             final Builder<?> defaultBuilder = defaultBuilderFactory.getBuilder(aClass);
//             if (defaultBuilder != null) {
//                 return defaultBuilder;
//             }
// 
//             // Make sure that we use a "null" builder for components that are 'blacklisted'.
//             final String packageName = aClass.getPackage().getName();
//             for (final String blacklisted : CDI_BLACKLIST) {
//                 if (packageName.startsWith(blacklisted)) {
//                     return null;
//                 }
//             }
// 
//             return new CdiFXMLComponentBuilder(aClass);
// 
//         });
// 
//     }
// 
//     @Override
//     public String toString() {
//         return String.format("[CDI-aware] %s", super.toString());
//     }
// 
// }


// Path: fx-cdi/src/main/java/com/cathive/fx/cdi/CdiFXMLLoaderFactory.java
import com.cathive.fx.inject.core.FXMLLoaderParams;
import javafx.fxml.FXMLLoader;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.InjectionPoint;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ResourceBundle;
import static com.cathive.fx.cdi.CdiFXMLLoader.*;

/*
 * Copyright (C) 2013,2014 The Cat Hive Developers.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.cathive.fx.cdi;




/**
 * This factory is responsible for the production of CDI-aware {@link javafx.fxml.FXMLLoader} instances.
 *
 * @author Benjamin P. Jung
 */
@ApplicationScoped
class CdiFXMLLoaderFactory {

    /**
     * Create a CDI-aware FXMLLoader.
     * If an annotation of type @FXMLLoaderParams can be found, use it's parameters
     * to configure the FXMLLoader instance that shall be used to perform the loading
     * of the FXML file.
     *
     * @param injectionPoint
     *     Injection point.
     * @return
     *     A new FXMLLoader instance.
     */
    @Produces
    @FXMLLoaderParams
    FXMLLoader createCdiFXMLLoader(final InjectionPoint injectionPoint) {