Search in sources :

Example 91 with Property

use of org.jvnet.hk2.config.types.Property in project Payara by payara.

the class CustomResourceDeployer method toCustomJavaEEResource.

/**
 * Returns a new instance of j2ee custom resource from the given
 * config bean.
 * <p/>
 * This method gets called from the custom resource deployer
 * to convert custom-resource config bean into custom j2ee resource.
 *
 * @param rbean custom-resource config bean
 * @param resourceInfo the definition of the resources to create
 * @return new instance of j2ee custom resource
 */
public static JavaEEResource toCustomJavaEEResource(CustomResource rbean, ResourceInfo resourceInfo) {
    org.glassfish.resources.beans.CustomResource jr = new org.glassfish.resources.beans.CustomResource(resourceInfo);
    // jr.setDescription(rbean.getDescription()); // FIXME: getting error
    // sets the enable flag
    jr.setEnabled(Boolean.valueOf(rbean.getEnabled()));
    // sets the resource type
    jr.setResType(rbean.getResType());
    // sets the factory class name
    jr.setFactoryClass(rbean.getFactoryClass());
    // sets the properties
    List<Property> properties = rbean.getProperty();
    if (properties != null) {
        for (Property property : properties) {
            ResourceProperty rp = new ResourcePropertyImpl(property.getName(), property.getValue());
            jr.addProperty(rp);
        }
    }
    return jr;
}
Also used : ResourceProperty(com.sun.enterprise.repository.ResourceProperty) CustomResource(org.glassfish.resources.config.CustomResource) ResourceProperty(com.sun.enterprise.repository.ResourceProperty) Property(org.jvnet.hk2.config.types.Property)

Example 92 with Property

use of org.jvnet.hk2.config.types.Property in project Payara by payara.

the class JavaMailResourceManager method createConfigBean.

private MailResource createConfigBean(Resources param, Properties props) throws PropertyVetoException, TransactionFailure {
    MailResource newResource = param.createChild(MailResource.class);
    newResource.setJndiName(jndiName);
    newResource.setFrom(fromAddress);
    newResource.setUser(mailUser);
    newResource.setPassword(mailPassword);
    newResource.setAuth(auth);
    newResource.setHost(mailHost);
    newResource.setEnabled(enabled);
    newResource.setStoreProtocol(storeProtocol);
    newResource.setStoreProtocolClass(storeProtocolClass);
    newResource.setTransportProtocol(transportProtocol);
    newResource.setTransportProtocolClass(transportProtocolClass);
    newResource.setDebug(debug);
    if (description != null) {
        newResource.setDescription(description);
    }
    if (props != null) {
        for (java.util.Map.Entry e : props.entrySet()) {
            Property prop = newResource.createChild(Property.class);
            prop.setName((String) e.getKey());
            prop.setValue((String) e.getValue());
            newResource.getProperty().add(prop);
        }
    }
    return newResource;
}
Also used : HashMap(java.util.HashMap) Property(org.jvnet.hk2.config.types.Property) MailResource(org.glassfish.resources.javamail.config.MailResource)

Example 93 with Property

use of org.jvnet.hk2.config.types.Property in project Payara by payara.

the class MailResourceDeployer method toMailBean.

/**
 * Returns a new instance of j2ee mail resource from the given config bean.
 * <p/>
 * This method gets called from the mail resource deployer to convert mail
 * config bean into mail j2ee resource.
 *
 * @param mailResourceConfig mail-resource config bean
 * @param resourceInfo
 * @return a new instance of j2ee mail resource
 */
public static MailBean toMailBean(MailResource mailResourceConfig, ResourceInfo resourceInfo) {
    MailBean mailResource = new MailBean(resourceInfo);
    // jr.setDescription(rbean.getDescription()); // FIXME: getting error
    mailResource.setEnabled(Boolean.valueOf(mailResourceConfig.getEnabled()));
    mailResource.setStoreProtocol(mailResourceConfig.getStoreProtocol());
    mailResource.setStoreProtocolClass(mailResourceConfig.getStoreProtocolClass());
    mailResource.setTransportProtocol(mailResourceConfig.getTransportProtocol());
    mailResource.setTransportProtocolClass(mailResourceConfig.getTransportProtocolClass());
    mailResource.setMailHost((String) TranslatedConfigView.getTranslatedValue(mailResourceConfig.getHost()));
    mailResource.setUsername((String) TranslatedConfigView.getTranslatedValue(mailResourceConfig.getUser()));
    mailResource.setPassword((String) TranslatedConfigView.getTranslatedValue(mailResourceConfig.getPassword()));
    mailResource.setAuth(Boolean.valueOf(mailResourceConfig.getAuth()));
    mailResource.setMailFrom((String) TranslatedConfigView.getTranslatedValue(mailResourceConfig.getFrom()));
    mailResource.setDebug(Boolean.valueOf(mailResourceConfig.getDebug()));
    // sets the properties
    List<Property> properties = mailResourceConfig.getProperty();
    if (properties != null) {
        for (Property property : properties) {
            ResourceProperty rp = new org.glassfish.resources.api.ResourcePropertyImpl(property.getName(), property.getValue());
            mailResource.addProperty(rp);
        }
    }
    return mailResource;
}
Also used : ResourceProperty(com.sun.enterprise.repository.ResourceProperty) MailBean(org.glassfish.resources.javamail.beans.MailBean) ResourceProperty(com.sun.enterprise.repository.ResourceProperty) Property(org.jvnet.hk2.config.types.Property)

Example 94 with Property

use of org.jvnet.hk2.config.types.Property in project Payara by payara.

the class ExternalJndiResourceDeployer method toExternalJndiJavaEEResource.

/**
 * Returns a new instance of j2ee external jndi resource from the given
 * config bean.
 * <p/>
 * This method gets called from the external resource
 * deployer to convert external-jndi-resource config bean into
 * external-jndi  j2ee resource.
 *
 * @param rbean external-jndi-resource config bean
 * @param resourceInfo
 * @return a new instance of j2ee external jndi resource
 */
public static org.glassfish.resources.api.JavaEEResource toExternalJndiJavaEEResource(ExternalJndiResource rbean, ResourceInfo resourceInfo) {
    org.glassfish.resources.beans.ExternalJndiResource jr = new org.glassfish.resources.beans.ExternalJndiResource(resourceInfo);
    // jr.setDescription( rbean.getDescription() ); // FIXME: getting error
    // sets the enable flag
    jr.setEnabled(Boolean.valueOf(rbean.getEnabled()));
    // sets the jndi look up name
    jr.setJndiLookupName(rbean.getJndiLookupName());
    // sets the resource type
    jr.setResType(rbean.getResType());
    // sets the factory class name
    jr.setFactoryClass(rbean.getFactoryClass());
    // sets the properties
    List<Property> properties = rbean.getProperty();
    if (properties != null) {
        for (Property property : properties) {
            ResourceProperty rp = new ResourcePropertyImpl(property.getName(), property.getValue());
            jr.addProperty(rp);
        }
    }
    return jr;
}
Also used : ResourceProperty(com.sun.enterprise.repository.ResourceProperty) ExternalJndiResource(org.glassfish.resources.config.ExternalJndiResource) ResourceProperty(com.sun.enterprise.repository.ResourceProperty) Property(org.jvnet.hk2.config.types.Property)

Example 95 with Property

use of org.jvnet.hk2.config.types.Property in project Payara by payara.

the class WarHandler method configureContextXmlAttribute.

protected void configureContextXmlAttribute(WebappClassLoader cloader, File base, DeploymentContext dc) throws XMLStreamException, IOException {
    boolean consistent = true;
    Boolean value = null;
    File warContextXml = new File(base.getAbsolutePath(), WAR_CONTEXT_XML);
    if (warContextXml.exists()) {
        ContextXmlParser parser = new ContextXmlParser(warContextXml);
        value = parser.getClearReferencesStatic();
    }
    if (value == null) {
        Boolean domainCRS = null;
        File defaultContextXml = new File(serverEnvironment.getInstanceRoot(), DEFAULT_CONTEXT_XML);
        if (defaultContextXml.exists()) {
            ContextXmlParser parser = new ContextXmlParser(defaultContextXml);
            domainCRS = parser.getClearReferencesStatic();
        }
        List<Boolean> csrs = new ArrayList<Boolean>();
        HttpService httpService = serverConfig.getHttpService();
        DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
        String vsIDs = params.virtualservers;
        List<String> vsList = StringUtils.parseStringList(vsIDs, " ,");
        if (httpService != null && vsList != null && !vsList.isEmpty()) {
            for (VirtualServer vsBean : httpService.getVirtualServer()) {
                if (vsList.contains(vsBean.getId())) {
                    Boolean csr = null;
                    Property prop = vsBean.getProperty("contextXmlDefault");
                    if (prop != null) {
                        File contextXml = new File(serverEnvironment.getInstanceRoot(), prop.getValue());
                        if (contextXml.exists()) {
                            // vs context.xml
                            ContextXmlParser parser = new ContextXmlParser(contextXml);
                            csr = parser.getClearReferencesStatic();
                        }
                    }
                    if (csr == null) {
                        csr = domainCRS;
                    }
                    csrs.add(csr);
                }
            }
            // check that it is consistent
            for (Boolean b : csrs) {
                if (b != null) {
                    if (value != null && !b.equals(value)) {
                        consistent = false;
                        break;
                    }
                    value = b;
                }
            }
        }
    }
    if (consistent) {
        if (value != null) {
            cloader.setClearReferencesStatic(value);
        }
    } else if (logger.isLoggable(Level.WARNING)) {
        logger.log(Level.WARNING, LogFacade.INCONSISTENT_CLEAR_REFERENCE_STATIC);
    }
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) HttpService(com.sun.enterprise.config.serverbeans.HttpService) ArrayList(java.util.ArrayList) JarFile(java.util.jar.JarFile) Property(org.jvnet.hk2.config.types.Property) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer)

Aggregations

Property (org.jvnet.hk2.config.types.Property)149 PropertyVetoException (java.beans.PropertyVetoException)30 HashMap (java.util.HashMap)27 Properties (java.util.Properties)22 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)22 ArrayList (java.util.ArrayList)18 ActionReport (org.glassfish.api.ActionReport)17 Map (java.util.Map)15 File (java.io.File)13 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)12 Config (com.sun.enterprise.config.serverbeans.Config)11 List (java.util.List)11 AuthRealm (com.sun.enterprise.config.serverbeans.AuthRealm)10 HttpService (com.sun.enterprise.config.serverbeans.HttpService)9 NoSuchRealmException (com.sun.enterprise.security.auth.realm.NoSuchRealmException)9 Server (com.sun.enterprise.config.serverbeans.Server)8 SystemProperty (com.sun.enterprise.config.serverbeans.SystemProperty)8 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)8 Application (com.sun.enterprise.config.serverbeans.Application)7 EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)7