本文整理了Java中org.apache.geronimo.kernel.Naming
类的一些代码示例,展示了Naming
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Naming
类的具体详情如下:
包路径:org.apache.geronimo.kernel.Naming
类名称:Naming
暂无
代码示例来源:origin: org.apache.geronimo.modules/geronimo-openejb-clustering-builder-wadi
protected AbstractName newGBeanName(DeploymentContext moduleContext, String name) {
return moduleContext.getNaming().createChildName(moduleContext.getModuleName(),
name,
GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
}
代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat-builder
earName = naming.createRootName(environment.getConfigId(), NameFactory.NULL, NameFactory.J2EE_APPLICATION);
moduleName = naming.createChildName(earName, environment.getConfigId().toString(), NameFactory.WEB_MODULE);
} else {
moduleName = naming.createChildName(earName, targetPath, NameFactory.WEB_MODULE);
代码示例来源:origin: org.apache.geronimo.modules/geronimo-security
aName = kernel.getNaming().createSiblingName(myName, name, NameFactory.KEYSTORE_INSTANCE);
GBeanData data = new GBeanData(aName, FileKeystoreInstance.getGBeanInfo());
try {
代码示例来源:origin: org.apache.geronimo.modules/geronimo-connector-builder-1_6
private void addAdminObjectGBeans(List<GBeanData> raBeans, Naming naming, AbstractName jcaResourceName, GBeanData resourceAdapterModuleData, Bundle bundle, AbstractName resourceAdapterAbstractName, GerAdminobjectType[] adminObjects) throws DeploymentException {
for (GerAdminobjectType gerAdminObject : adminObjects) {
String adminObjectInterface = gerAdminObject.getAdminobjectInterface().trim();
GBeanData adminObjectGBeanData = locateAdminObjectInfo(resourceAdapterModuleData, adminObjectInterface);
if (adminObjectGBeanData == null) {
throw new DeploymentException("No admin object declared for interface: " + adminObjectInterface);
}
for (GerAdminobjectInstanceType gerAdminObjectInstance : gerAdminObject.getAdminobjectInstanceArray()) {
GBeanData adminObjectInstanceGBeanData = new GBeanData(adminObjectGBeanData);
setDynamicGBeanDataAttributes(adminObjectInstanceGBeanData, gerAdminObjectInstance.getConfigPropertySettingArray(), bundle);
// add it
AbstractName adminObjectAbstractName = naming.createChildName(jcaResourceName, gerAdminObjectInstance.getMessageDestinationName().trim(), NameFactory.JCA_ADMIN_OBJECT);
adminObjectInstanceGBeanData.setAbstractName(adminObjectAbstractName);
if (resourceAdapterAbstractName != null) {
adminObjectInstanceGBeanData.setReferencePattern("ResourceAdapterWrapper", resourceAdapterAbstractName);
}
Set<String> implementedInterfaces = new HashSet<String>();
implementedInterfaces.add(checkClass(bundle, (String) adminObjectInstanceGBeanData.getAttribute("adminObjectInterface")));
implementedInterfaces.add(checkClass(bundle, (String) adminObjectInstanceGBeanData.getAttribute("adminObjectClass")));
adminObjectInstanceGBeanData.setServiceInterfaces(implementedInterfaces.toArray(new String[implementedInterfaces.size()]));
String jndiName = naming.toOsgiJndiName(adminObjectAbstractName);
//TODO allow specifying osig jndi name directly, like for connection factories
adminObjectInstanceGBeanData.getServiceProperties().put(OSGI_JNDI_SERVICE_NAME, jndiName);
raBeans.add(adminObjectInstanceGBeanData);
}
}
}
代码示例来源:origin: org.apache.geronimo.modules/geronimo-openejb
private AbstractName getUnqiueName(String gbeanName) {
AbstractName beanName = kernel.getNaming().createRootName(name.getArtifact(), gbeanName, "NetworkConnector");
int i = 1;
while (kernel.isLoaded(beanName)) {
beanName = kernel.getNaming().createRootName(name.getArtifact(), gbeanName + "-" + i, "NetworkConnector");
i++;
}
return beanName;
}
代码示例来源:origin: org.apache.geronimo.framework/geronimo-naming
/**
* Preprocess the value before it is bound. This is usefult for wrapping values with reference objects.
* By default, this method simply return the value.
*
* @param abstractName the abstract name of the gbean to bind
* @param value the gbean instance
* @return the value to bind or null if there was a problem
*/
@Override
protected Object preprocessVaue(AbstractName abstractName, Name name, Object value) {
if (!(value instanceof ResourceSource)) {
log.info("value at " + abstractName + " is not a ResourceSource: " + value.getClass().getName());
return null;
}
try {
if (value.getClass().getAnnotation(OsgiService.class) != null) {
String osgiJndiName = kernel.getNaming().toOsgiJndiName(abstractName);
String query = "(osgi.jndi.service.name=" + osgiJndiName + ')';
ResourceReference reference = new ResourceReference(query, value.getClass().getName());
reference.setBundle(bundleContext.getBundle());
reference.setKernel(kernel);
return reference;
}
return ((ResourceSource) value).$getResource();
} catch (Throwable throwable) {
log.info("Could not get resource from gbean at " + abstractName,throwable);
return null;
}
}
代码示例来源:origin: org.apache.geronimo.modules/geronimo-connector-builder-1_6
private void addOutboundGBeans(List<GBeanData> raBeans, Naming naming, AbstractName jcaResourceName, AbstractName resourceAdapterAbstractName, GBeanData managedConnectionFactoryPrototypeGBeanData, GerConnectiondefinitionInstanceType connectiondefinitionInstance, String transactionSupport, Bundle bundle, AbstractNameQuery connectionTrackerName, AbstractNameQuery transactionManagerName) throws DeploymentException {
GBeanData managedConnectionFactoryInstanceGBeanData = new GBeanData(managedConnectionFactoryPrototypeGBeanData);
AbstractName connectionFactoryAbstractName = naming.createChildName(jcaResourceName, connectiondefinitionInstance.getName().trim(), NameFactory.JCA_CONNECTION_FACTORY);
AbstractName managedConnectionFactoryAbstractName = naming.createChildName(connectionFactoryAbstractName, connectiondefinitionInstance.getName().trim(), NameFactory.JCA_MANAGED_CONNECTION_FACTORY);
String jndiName = connectiondefinitionInstance.getJndiName();
if (jndiName == null) {
jndiName = naming.toOsgiJndiName(connectionFactoryAbstractName);
} else {
jndiName = jndiName.trim();
代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel
public GBeanData addGBean(String name, GBeanInfo gbeanInfo, Naming naming, Environment environment) {
if (gbeanState != null) {
throw new IllegalStateException("GBeans have been serialized, so no more GBeans can be added");
}
String j2eeType = gbeanInfo.getJ2eeType();
if (j2eeType == null) j2eeType = "GBean";
AbstractName abstractName = naming.createRootName(environment.getConfigId(), name, j2eeType);
GBeanData gBeanData = new GBeanData(abstractName, gbeanInfo);
addGBean(gBeanData);
return gBeanData;
}
代码示例来源:origin: org.apache.geronimo.framework/geronimo-naming
@Override
public void setKernel(Kernel kernel) {
if(query == null) {
try {
ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
AbstractName mappedAbstractName = new AbstractName(configurationManager.getArtifactResolver().resolveInClassLoader(gbeanName.getArtifact()), gbeanName.getName());
String osgiJndiName = kernel.getNaming().toOsgiJndiName(mappedAbstractName);
query = "(osgi.jndi.service.name=" + osgiJndiName + ')';
} catch (GBeanNotFoundException e) {
logger.error("Fail to build the jndi name for " + gbeanName, e);
} catch (MissingDependencyException e) {
logger.error("Fail to build the jndi name for " + gbeanName, e);
}
}
}
}
代码示例来源:origin: org.apache.geronimo.modules/geronimo-openejb-builder
public AbstractName createEjbName(EARContext earContext, EjbModule ejbModule, EnterpriseBean enterpriseBean) {
String ejbName = enterpriseBean.getEjbName();
String type = null;
if (enterpriseBean instanceof SessionBean) {
SessionBean sessionBean = (SessionBean) enterpriseBean;
switch (sessionBean.getSessionType()) {
case STATELESS:
type = NameFactory.STATELESS_SESSION_BEAN;
break;
case STATEFUL:
type = NameFactory.STATEFUL_SESSION_BEAN;
break;
case SINGLETON:
type = NameFactory.SINGLETON_BEAN;
break;
case MANAGED:
type = NameFactory.MANAGED_BEAN;
break;
}
} else if (enterpriseBean instanceof EntityBean) {
type = NameFactory.ENTITY_BEAN;
} else if (enterpriseBean instanceof MessageDrivenBean) {
type = NameFactory.MESSAGE_DRIVEN_BEAN;
}
if (type == null) {
throw new IllegalArgumentException("Unknown enterprise bean type XXX " + enterpriseBean.getClass().getName());
}
return earContext.getNaming().createChildName(ejbModule.getModuleName(), ejbName, type);
}
代码示例来源:origin: org.apache.geronimo.modules/geronimo-jetty6-builder
earName = naming.createRootName(environment.getConfigId(), NameFactory.NULL, NameFactory.J2EE_APPLICATION);
moduleName = naming.createChildName(earName, environment.getConfigId().toString(), NameFactory.WEB_MODULE);
} else {
moduleName = naming.createChildName(earName, targetPath, NameFactory.WEB_MODULE);
代码示例来源:origin: org.apache.geronimo.modules/geronimo-connector-builder-1_6
private void addDataSourceGBean(Module module, Map<EARContext.Key, Object> sharedContext, DataSource ds)
throws DeploymentException {
String jndiName = ds.getKey();
if (lookupJndiContextMap(module, jndiName) != null) {
return;
}
String name = jndiName;
if (name.startsWith("java:")) {
name = name.substring(5);
}
EARContext earContext = module.getEarContext();
AbstractName dataSourceAbstractName = earContext.getNaming().createChildName(module.getModuleName(), name, "GBean");
DataSourceDescription dsDescription = createDataSourceDescription(ds);
String osgiJndiName = null;
if (dsDescription.getProperties() != null) {
osgiJndiName = dsDescription.getProperties().get(ConnectorModuleBuilder.OSGI_JNDI_SERVICE_NAME);
}
if (osgiJndiName == null) {
osgiJndiName = module.getEarContext().getNaming().toOsgiJndiName(dataSourceAbstractName);
}
dsDescription.setOsgiServiceName(osgiJndiName);
try {
Object ref = DataSourceService.buildReference(dsDescription);
put(jndiName, ref, ReferenceType.DATA_SOURCE, module.getJndiContext(), Collections.<InjectionTarget>emptySet(), sharedContext);
} catch (IOException e) {
throw new DeploymentException("Could not construct Reference for datasource " + dsDescription, e);
}
}
代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel
public GBeanData addGBean(String name, GBeanInfo gbeanInfo, Naming naming, Environment environment) {
if (gbeanState != null) {
throw new IllegalStateException("GBeans have been serialized, so no more GBeans can be added");
}
String j2eeType = gbeanInfo.getJ2eeType();
if (j2eeType == null) j2eeType = "GBean";
AbstractName abstractName = naming.createRootName(environment.getConfigId(), name, j2eeType);
GBeanData gBeanData = new GBeanData(abstractName, gbeanInfo);
addGBean(gBeanData);
return gBeanData;
}
代码示例来源:origin: org.apache.geronimo.modules/geronimo-activemq
protected void startConnectorWrapperGBeans(AbstractName brokerAbstractName) {
try {
BrokerService brokerService = ((BrokerServiceGBean) kernel.getGBean(brokerAbstractName)).getBrokerContainer();
List<AbstractName> connectorNames = new ArrayList<AbstractName>();
GBeanInfo gBeanInfo = new AnnotationGBeanInfoFactory().getGBeanInfo(ActiveMQTransportConnector.class);
for (TransportConnector transportConnector : brokerService.getTransportConnectors()) {
AbstractName connectorAbName = kernel.getNaming().createSiblingName(brokerAbstractName, transportConnector.getUri().toString().replace(':', '_'), GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
GBeanData gbeanData = new GBeanData(connectorAbName, gBeanInfo);
gbeanData.setAttribute("transportConnector", transportConnector);
kernel.loadGBean(gbeanData, classLoader);
kernel.startGBean(connectorAbName);
connectorNames.add(connectorAbName);
}
brokerNameConnectorNamesMap.put(brokerAbstractName, connectorNames);
} catch (Exception e) {
}
}
代码示例来源:origin: org.apache.geronimo.framework/geronimo-naming
@Override
public void setKernel(Kernel kernel) {
if(jndiName == null) {
try {
ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
AbstractName mappedAbstractName = new AbstractName(configurationManager.getArtifactResolver().resolveInClassLoader(gbeanName.getArtifact()), gbeanName.getName());
String osgiJndiName = kernel.getNaming().toOsgiJndiName(mappedAbstractName);
jndiName = prefix + osgiJndiName;
} catch (GBeanNotFoundException e) {
logger.error("Fail to build the jndi name for " + gbeanName, e);
} catch (MissingDependencyException e) {
logger.error("Fail to build the jndi name for " + gbeanName, e);
}
}
}
}
代码示例来源:origin: org.apache.geronimo.modules/geronimo-jetty6-builder
private GBeanData configureDefaultServlet(Object defaultServlet, EARContext earContext, AbstractName moduleName, Set knownServletMappings, EARContext moduleContext) throws GBeanNotFoundException, GBeanAlreadyExistsException {
GBeanData servletGBeanData = getGBeanData(kernel, defaultServlet);
AbstractName defaultServletObjectName = earContext.getNaming().createChildName(moduleName, (String) servletGBeanData.getAttribute("servletName"), NameFactory.SERVLET);
servletGBeanData.setAbstractName(defaultServletObjectName);
servletGBeanData.setReferencePattern("JettyServletRegistration", moduleName);
Set<String> defaultServletMappings = new HashSet<String>((Collection<String>) servletGBeanData.getAttribute("servletMappings"));
defaultServletMappings.removeAll(knownServletMappings);
servletGBeanData.setAttribute("servletMappings", defaultServletMappings);
moduleContext.addGBean(servletGBeanData);
return servletGBeanData;
}
代码示例来源:origin: org.apache.geronimo.modules/geronimo-openejb-builder
AbstractName earName = naming.createRootName(environment.getConfigId(), NameFactory.NULL, NameFactory.J2EE_APPLICATION);
moduleName = naming.createChildName(earName, environment.getConfigId().toString(), NameFactory.EJB_MODULE);
} else {
.getAppClientName() : parentModule.getModuleName();
moduleName = naming.createChildName(parentName, targetPath, NameFactory.EJB_MODULE);
代码示例来源:origin: org.apache.geronimo.modules/geronimo-connector-builder-1_6
AbstractName connectionManagerAbstractName = naming.createChildName(managedConnectionFactoryName, connectionfactoryInstance.getName().trim(), NameFactory.JCA_CONNECTION_MANAGER);
String jndiName = naming.toOsgiJndiName(connectionManagerAbstractName);
connectionManagerGBean.getServiceProperties().put(OSGI_JNDI_SERVICE_NAME, jndiName);
connectionManagerGBean.setAttribute("transactionSupport", transactionSupport);
代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel
public synchronized AbstractName addGBean(String name, GBeanData gbean) throws GBeanAlreadyExistsException {
AbstractName abstractName = gbean.getAbstractName();
if (abstractName != null) {
throw new IllegalArgumentException("gbean already has an abstract name: " + abstractName);
}
String j2eeType = gbean.getGBeanInfo().getJ2eeType();
if (j2eeType == null) j2eeType = "GBean";
abstractName = naming.createRootName(id, name, j2eeType);
gbean.setAbstractName(abstractName);
if (gbeans.containsKey(abstractName)) {
throw new GBeanAlreadyExistsException(gbean.getAbstractName().toString());
}
gbeans.put(abstractName, gbean);
return abstractName;
}
代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat6
public AbstractName getConnectorConfiguration(ConnectorType connectorType, List<ConnectorAttribute> connectorAttributes, WebContainer container, String uniqueName) {
GBeanInfo gbeanInfo = CONNECTOR_GBEAN_INFOS.get(connectorType);
AbstractName containerName = kernel.getAbstractNameFor(container);
AbstractName name = kernel.getNaming().createSiblingName(containerName, uniqueName, GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
GBeanData gbeanData = new GBeanData(name, gbeanInfo);
gbeanData.setAttribute("name", uniqueName);
gbeanData.setReferencePattern(ConnectorGBean.CONNECTOR_CONTAINER_REFERENCE, containerName);
Map<String, Object> initParams = new HashMap<String, Object>();
for (ConnectorAttribute connectorAttribute : connectorAttributes) {
gbeanData.setAttribute(connectorAttribute.getAttributeName(), connectorAttribute.getValue());
initParams.put(connectorAttribute.getAttributeName(), connectorAttribute.getStringValue());
}
gbeanData.setAttribute("initParams", initParams);
AbstractNameQuery query = new AbstractNameQuery(ServerInfo.class.getName());
Set set = kernel.listGBeans(query);
AbstractName serverInfo = (AbstractName) set.iterator().next();
gbeanData.setReferencePattern("ServerInfo", serverInfo);
try {
kernel.loadGBean(gbeanData, container.getClass().getClassLoader());
kernel.startGBean(name);
} catch (Exception e) {
log.error("Error when adding new tomcat connector" + uniqueName, e);
}
return name;
}
内容来源于网络,如有侵权,请联系作者删除!