Fields Summary |
---|
private static final Logger | _logger |
static final String | JMS_QUEUE |
static final String | JMS_TOPIC |
static final String | JMS_QUEUE_CONNECTION_FACTORY |
static final String | JMS_TOPIC_CONNECTION_FACTORY |
public static final String | CUSTOM_RES_TYPEgeneric resource type for jndi |
public static final String | EXT_JNDI_RES_TYPEresource type residing in an external JNDI repository |
public static final String | JDBC_RES_TYPEJDBC javax.sql.(XA)DataSource resource type |
public static final String | MAIL_RES_TYPEjava mail resource type |
public static final String | JMS_RES_TYPEjms resource type |
public static final String | PMF_RES_TYPEpersistence manager runtime configuration resource type |
public static final String | JDBC_CONN_POOL_RES_TYPEjdbc connection pool resource type |
public static final String | CONNECTOR_CONN_POOL_TYPEConnector resource type |
private com.sun.enterprise.config.ConfigContext | ctx |
private com.sun.enterprise.config.serverbeans.Resources | rBean |
private String | serverName |
private volatile J2EEResourceCollection | resources |
Methods Summary |
---|
public ResourceProperty | createProperty(java.lang.String name)
return new ResourcePropertyImpl(name);
|
public J2EEResource | createResource(int type, java.lang.String name)
J2EEResource resource = null;
switch(type) {
case J2EEResource.PMF_RESOURCE :
resource = new PMFResource(name);
break;
case J2EEResource.CUSTOM_RESOURCE :
resource = new CustomResource(name);
break;
case J2EEResource.EXTERNAL_JNDI_RESOURCE :
resource = new ExternalJndiResource(name);
break;
// START OF IASRI 4650786
case J2EEResource.MAIL_RESOURCE :
resource = new MailResource(name);
break;
// END OF IASRI 4650786
default :
throw new java.lang.IllegalArgumentException();
}
return resource;
|
private boolean | isReferenced(java.lang.String resourceName)Returns true if the given resource is referenced by this server.
return ServerHelper.serverReferencesResource(ctx, serverName, resourceName);
|
private void | loadCustomResource(J2EEResourceCollection resources)Loads all the available custom resources into the resource collection.
com.sun.enterprise.config.serverbeans.CustomResource[] jBeanSet =
rBean.getCustomResource();
if (jBeanSet == null) {
return;
}
for (int i=0; i < jBeanSet.length; i++) {
com.sun.enterprise.config.serverbeans.CustomResource next =
(com.sun.enterprise.config.serverbeans.CustomResource) jBeanSet[i];
// custom resource is not referenced by this server
if ( !isReferenced(next.getJndiName()) ) {
_logger.fine("Skipping Custom Resource:" + next.getJndiName()
+ ". It is not used by server: " + serverName);
continue;
}
// Start Bug Fix: 4693395
if (!next.isEnabled()) {
logMessageIfNotEnabled(next.getJndiName(), CUSTOM_RES_TYPE);
continue;
}
// End Bug Fix: 4693395
// convets the config bean to j2ee resource
J2EEResource jr = toCustomJ2EEResource(next);
resources.addResource(jr);
}
|
public J2EEResourceCollection | loadDefaultResourceCollection()
if (resources != null) {
return resources;
}
return loadResourceCollection(null);
|
private void | loadExternalJndiResource(J2EEResourceCollection resources)Loads all available external jndi resources into the given resource
collection.
com.sun.enterprise.config.serverbeans.ExternalJndiResource[] jBeanSet =
rBean.getExternalJndiResource();
if (jBeanSet == null) {
return;
}
for (int i=0; i<jBeanSet.length; i++) {
com.sun.enterprise.config.serverbeans.ExternalJndiResource next =
(com.sun.enterprise.config.serverbeans.ExternalJndiResource) jBeanSet[i];
// external jndi resource is not referenced by this server
if ( !isReferenced(next.getJndiName()) ) {
_logger.fine("Skipping External JNDI Resource:"
+ next.getJndiName()
+ ". It is not used by server: " + serverName);
continue;
}
// Start Bug Fix: 4693395
if (!next.isEnabled()) {
logMessageIfNotEnabled(next.getJndiName(), EXT_JNDI_RES_TYPE);
continue;
}
// End Bug Fix: 4693395
// convets the config bean to j2ee resource
J2EEResource jr = toExternalJndiJ2EEResource(next);
resources.addResource(jr);
}
|
private void | loadMailResource(J2EEResourceCollection resources)Loads all available mail resources into the given resource collection.
com.sun.enterprise.config.serverbeans.MailResource[] jBeanSet =
rBean.getMailResource();
if (jBeanSet == null) {
return;
}
for (int i = 0; i < jBeanSet.length; i++) {
com.sun.enterprise.config.serverbeans.MailResource next =
(com.sun.enterprise.config.serverbeans.MailResource)jBeanSet[i];
// mail resource is not referenced by this server
if ( !isReferenced(next.getJndiName()) ) {
_logger.fine("Skipping Mail Resource:" + next.getJndiName()
+ ". It is not used by server: " + serverName);
continue;
}
// Start Bug Fix: 4693395
if (!next.isEnabled()) {
logMessageIfNotEnabled(next.getJndiName(), MAIL_RES_TYPE);
continue;
}
// End Bug Fix: 4693395
// convets the config bean to j2ee resource
J2EEResource jr = toMailJ2EEResource(next);
resources.addResource(jr);
}
|
private void | loadPMFResource(J2EEResourceCollection resources)
com.sun.enterprise.config.serverbeans.PersistenceManagerFactoryResource[] jBeanSet = rBean.getPersistenceManagerFactoryResource();
if(jBeanSet == null) return;
for(int i = 0; i <jBeanSet.length; i++) {
com.sun.enterprise.config.serverbeans.PersistenceManagerFactoryResource next =
(com.sun.enterprise.config.serverbeans.PersistenceManagerFactoryResource) jBeanSet[i];
// PMF resource is not referenced by this server
if ( !isReferenced(next.getJndiName()) ) {
_logger.fine("Skipping PMF Resource:" + next.getJndiName()
+ ". It is not used by server: " + serverName);
continue;
}
// Start Bug Fix: 4693395
if (!next.isEnabled()) {
logMessageIfNotEnabled(next.getJndiName(), PMF_RES_TYPE);
continue;
}
// End Bug Fix: 4693395
resources.addResource(toPMFJ2EEResource(next));
}
|
public synchronized J2EEResourceCollection | loadResourceCollection(java.lang.String resourcesURL)
resources = new J2EEResourceCollectionImpl();
ServerContext sc = ApplicationServer.getServerContext();
if(sc == null) {
//IASRI 4660742 System.out.println("Not Running in server. Returning empty resources...");
// START OF IASRI 4660742
_logger.log(Level.FINE,"Not Running in server. Returning empty resources...");
// END OF IASRI 4660742
return resources;
} else {
// name of this server instance
serverName = sc.getInstanceName();
}
try {
ctx = sc.getConfigContext();
//ROB: config changes
//rBean = ServerBeansFactory.getServerBean(ctx).getResources();
rBean = ServerBeansFactory.getDomainBean(ctx).getResources();
//RAMAKANTH
if (rBean == null)
{
rBean = new Resources();
}
} catch (ConfigException ce) {
/** IASRI 4660742
ce.printStackTrace();
System.out.println("Error initializing context");
System.out.println("Returning empty resources...");
*/
// START OF IASRI 4660742
_logger.log(Level.SEVERE,"enterprise.empty_resource",ce);
_logger.log(Level.FINE,"Error initializing context. Returning empty resources...");
// END OF IASRI 4660742
return resources;
}
try {
_logger.log(Level.FINE,"Loading PMF Resource==========");
loadPMFResource(resources);
_logger.log(Level.FINE,"Loading Custom Resource==========");
loadCustomResource(resources);
_logger.log(Level.FINE,"Loading External Jndi Resource==========");
loadExternalJndiResource(resources);
// START OF IASRI 4650786
_logger.log(Level.FINE,"Loading Mail Resource==========");
loadMailResource(resources);
// END OF IASRI 4650786
// END OF IASRI 4660742
} catch (ConfigException ce) {
// IASRI 4660742 ce.printStackTrace();
// IASRI 4660742 System.out.println("Error Loading resources: "+ce.getMessage());
// START OF IASRI 4660742
_logger.log(Level.SEVERE,"enterprise.config_exception",ce);
_logger.log(Level.FINE,"Error Loading resources: "+ce.getMessage());
// END OF IASRI 4660742
throw new J2EEResourceException(ce);
}
return resources;
|
private void | logMessageIfNotEnabled(java.lang.String name, java.lang.String type)
_logger.log(Level.INFO, "enterprise.resource_disabled", new Object[] {name, type});
|
public void | storeDefaultResourceCollection(J2EEResourceCollection resources)
storeResourceCollection(resources, null);
|
public void | storeResourceCollection(J2EEResourceCollection resources, java.lang.String resourcesURL)
/* ServerContext sc = ApplicationServer.getServerContext();
if(sc == null) {
throw new J2EEResourceException("Server Not Initialized");
}
try {
ctx = sc.getConfigContext();
rBean = ConfigBean.getServerObject(ctx).getResources();
} catch (ConfigException ce) {
// IASRI 4660742 ce.printStackTrace();
// IASRI 4660742 System.out.println("Error initializing context");
// START OF IASRI 4660742
_logger.log(Level.SEVERE,"enterprise.config_exception",ce);
_logger.log(Level.FINE,"Error initializing context ");
// END OF IASRI 4660742
throw new J2EEResourceException(ce);
}
try {
rBean.removeAllChildObjects();
// IASRI 4660742 System.out.println("Saving Jdbc Connection Pool==========");
// IASRI 4660742 saveJdbcConnectionPool(resources);
// IASRI 4660742 System.out.println("Saving Jdbc Resource==========");
// IASRI 4660742 saveJdbcResource(resources);
// IASRI 4660742 System.out.println("Saving Jms Resource==========");
// IASRI 4660742 saveJmsResource(resources);
// IASRI 4660742 System.out.println("Saving PMF Resource==========");
// IASRI 4660742 savePMFResource(resources);
// IASRI 4660742 System.out.println("Saving Custom Resource==========");
// IASRI 4660742 saveCustomResource(resources);
// IASRI 4660742 System.out.println("Saving External Jndi Resource==========");
// START OF IASRI 4660742
_logger.log(Level.FINE,"Saving Jdbc Connection Pool==========");
saveJdbcConnectionPool(resources);
_logger.log(Level.FINE,"Saving Jdbc Resource==========");
saveJdbcResource(resources);
_logger.log(Level.FINE,"Saving Jms Resource==========");
saveJmsResource(resources);
_logger.log(Level.FINE,"Saving PMF Resource==========");
savePMFResource(resources);
_logger.log(Level.FINE,"Saving Custom Resource==========");
saveCustomResource(resources);
_logger.log(Level.FINE,"Saving External Jndi Resource==========");
// END OF IASRI 4660742
saveExternalJndiResource(resources);
// START OF IASRI 4650786
_logger.log(Level.FINE,"Saving Mail Resource==========");
saveMailResource(resources);
// END OF IASRI 4650786
rBean.save();
} catch (ConfigException ce) {
//IASRI 4660742 ce.printStackTrace();
//IASRI 4660742 System.out.println("Error Loading resources");
// START OF IASRI 4660742
_logger.log(Level.SEVERE,"enterprise.config_exception",ce);
_logger.log(Level.FINE,"Error Loading resources ");
// END OF IASRI 4660742
throw new J2EEResourceException(ce);
}
*/
|
public static J2EEResource | toCustomJ2EEResource(com.sun.enterprise.config.serverbeans.CustomResource rbean)Returns a new instance of j2ee custom resource from the given
config bean.
This method gets called from the custom resource deployer
to convert custom-resource config bean into custom j2ee resource.
CustomResource jr = new CustomResource( rbean.getJndiName() );
//jr.setDescription(rbean.getDescription()); // FIXME: getting error
// sets the enable flag
jr.setEnabled( rbean.isEnabled() );
// sets the resource type
jr.setResType( rbean.getResType() );
// sets the factory class name
jr.setFactoryClass( rbean.getFactoryClass() );
// sets the properties
ElementProperty[] s = rbean.getElementProperty();
if (s!= null) {
for(int j = 0; j <s.length; j++) {
com.sun.enterprise.config.serverbeans.ElementProperty next =
(com.sun.enterprise.config.serverbeans.ElementProperty) s[j];
ResourceProperty rp =
new ResourcePropertyImpl(next.getName(), next.getValue());
jr.addProperty(rp);
}
}
return jr;
|
public static J2EEResource | toExternalJndiJ2EEResource(com.sun.enterprise.config.serverbeans.ExternalJndiResource rbean)Returns a new instance of j2ee external jndi resource from the given
config bean.
This method gets called from the external resource
deployer to convert external-jndi-resource config bean into
external-jndi j2ee resource.
ExternalJndiResource jr = new ExternalJndiResource(rbean.getJndiName());
//jr.setDescription( rbean.getDescription() ); // FIXME: getting error
// sets the enable flag
jr.setEnabled( rbean.isEnabled() );
// 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
ElementProperty[] s = rbean.getElementProperty();
if (s!= null) {
for (int j=0; j<s.length; j++) {
com.sun.enterprise.config.serverbeans.ElementProperty next =
(com.sun.enterprise.config.serverbeans.ElementProperty) s[j];
ResourceProperty rp =
new ResourcePropertyImpl(next.getName(), next.getValue());
jr.addProperty(rp);
}
}
return jr;
|
public static J2EEResource | toMailJ2EEResource(com.sun.enterprise.config.serverbeans.MailResource rbean)Returns a new instance of j2ee mail resource from the given config bean.
This method gets called from the mail resource deployer to convert mail
config bean into mail j2ee resource.
MailResource jr = new MailResource(rbean.getJndiName());
//jr.setDescription(rbean.getDescription()); // FIXME: getting error
jr.setEnabled(rbean.isEnabled());
jr.setStoreProtocol(rbean.getStoreProtocol());
jr.setStoreProtocolClass(rbean.getStoreProtocolClass());
jr.setTransportProtocol(rbean.getTransportProtocol());
jr.setTransportProtocolClass(rbean.getTransportProtocolClass());
jr.setMailHost(rbean.getHost());
jr.setUsername(rbean.getUser());
jr.setMailFrom(rbean.getFrom());
jr.setDebug(rbean.isDebug());
// sets the properties
ElementProperty[] s = rbean.getElementProperty();
if (s != null) {
for (int j = 0; j < s.length; j++) {
com.sun.enterprise.config.serverbeans.ElementProperty next =
(com.sun.enterprise.config.serverbeans.ElementProperty)s[j];
ResourceProperty rp =
new ResourcePropertyImpl(next.getName(), next.getValue());
jr.addProperty(rp);
}
}
return jr;
|
public static J2EEResource | toPMFJ2EEResource(com.sun.enterprise.config.serverbeans.PersistenceManagerFactoryResource rbean)Returns a new instance of j2ee pmf resource from the given config bean.
This method gets called from the Persistence Manager Factory Resource
deployer to convert persistence-manager-resource-factory config bean into
pmf j2ee resource.
PMFResource jr = new PMFResource(rbean.getJndiName());
jr.setEnabled(rbean.isEnabled());
jr.setFactoryClass(rbean.getFactoryClass());
jr.setJdbcResourceJndiName(rbean.getJdbcResourceJndiName());
ElementProperty[] s = rbean.getElementProperty();
if (s!= null) {
for (int j = 0; j <s.length; j++) {
com.sun.enterprise.config.serverbeans.ElementProperty next1 =
(com.sun.enterprise.config.serverbeans.ElementProperty) s[j];
ResourceProperty rp = new ResourcePropertyImpl(next1.getName(),
next1.getValue());
jr.addProperty(rp);
}
}
//jr.setDescription(next.getDescription()); // FIXME add this
return jr;
|