本文整理汇总了Java中atg.nucleus.Nucleus.resolveName方法的典型用法代码示例。如果您正苦于以下问题:Java Nucleus.resolveName方法的具体用法?Java Nucleus.resolveName怎么用?Java Nucleus.resolveName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atg.nucleus.Nucleus
的用法示例。
在下文中一共展示了Nucleus.resolveName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addComponent
import atg.nucleus.Nucleus; //导入方法依赖的package包/类
/**
* Adds the given object, component to Nucleus, nucleus at the path given
* by componentPath.
*
* @param nucleus
* The Nucleus instance to which the component should be added
* @param componentPath
* the component path at which the component should be added
* @param component
* the component instance to add
*/
public static void addComponent(Nucleus nucleus, String componentPath, Object component) {
// make sure it's not already there
if (nucleus.resolveName(componentPath) != null) {
return;
}
ComponentName name = ComponentName.getComponentName(componentPath);
ComponentName[] subNames = name.getSubNames();
GenericContext[] contexts = new GenericContext[subNames.length - 1];
contexts[0] = nucleus;
for (int i = 1; i < subNames.length - 1; i++) {
contexts[i] = new GenericContext();
// Make sure it's not there
GenericContext tmpContext = (GenericContext) contexts[i
- 1].getElement(subNames[i].getName());
if (tmpContext == null) {
contexts[i - 1].putElement(subNames[i].getName(), contexts[i]);
}
else {
contexts[i] = tmpContext;
}
}
contexts[contexts.length - 1].putElement(
subNames[subNames.length - 1].getName(), component
);
}
示例2: getGlobalBaseComponent
import atg.nucleus.Nucleus; //导入方法依赖的package包/类
/**
*
* @param componentName
* The component to find
* @return The component (if found); null otherwise
* @author jon pallas
*
*/
private static Object getGlobalBaseComponent(String componentName) {
Nucleus nucleus = Nucleus.getGlobalNucleus();
if (nucleus != null) {
Object o = nucleus.resolveName(componentName);
return o;
}
return null;
}
示例3: setUpAndTest
import atg.nucleus.Nucleus; //导入方法依赖的package包/类
/**
* Create a repository in the given configpath using the given repository definitions (Absolute
* paths)
* connecting to the db whose properties are specified in pDBProperties @see DBUtils
* Method pMethodName is invoked with the GSARepository passed to it as a parameter.
*
* @param pConfigPathWhereToCreateTheRepository
*
* @param definitionFiles
* @param pDBProperties
* @param pMethodName
*
* @throws Exception
*/
void setUpAndTest(File pConfigPathWhereToCreateTheRepository,
String[] definitionFiles,
Properties pDBProperties,
String pMethodName)
throws Exception {
String repositoryComponentPath = "/" + getName() + "Repository";
GSATestUtils.getGSATestUtils().initializeMinimalConfigpath(
pConfigPathWhereToCreateTheRepository,
repositoryComponentPath,
definitionFiles,
pDBProperties,
null,
null,
null,
true
);
Nucleus n = startNucleus(pConfigPathWhereToCreateTheRepository);
GSARepository r = (GSARepository) n.resolveName(repositoryComponentPath);
try {
getClass().getMethod(pMethodName, new Class[] { GSARepository.class })
.invoke(this, r);
} catch ( NoSuchMethodError e ) {
throw new AssertionError(
"Please declare a method with name "
+ pMethodName
+ " in your class. It must take an atg.adapter.gsa.GSARepository as the only parameter."
);
} finally {
// if it were null a NPE would have occurred at the earlier dereference
//if(n != null)
n.stopService();
}
}
示例4: testComponentStartup
import atg.nucleus.Nucleus; //导入方法依赖的package包/类
/**
* Start up a nucleus given a local test "configpath". In that configpath is a
* .properties file for our TestComponent
*
* @throws Exception
*/
@Test
public void testComponentStartup()
throws Exception {
File configpath = NucleusUtils.getConfigPath(this.getClass(), "config");
// Put test .properties file in configpath path
Properties props = new Properties();
File propFile = NucleusUtils.createProperties(
"test/SimpleComponentGlobalScope",
configpath,
"com.mycompany.SimpleComponent",
props
);
propFile.deleteOnExit();
List<String> initial = new ArrayList<String>();
initial.add("/test/SimpleComponentGlobalScope");
NucleusUtils.createInitial(configpath, initial);
Nucleus n = NucleusUtils.startNucleus(configpath);
SimpleComponent testComponent = null;
try {
testComponent = (SimpleComponent) n.resolveName("/test/SimpleComponentGlobalScope");
assertNotNull("Could not resolve test component", testComponent);
assertTrue(
"Test component did not start up cleanly.", testComponent.isCleanStart
);
} finally {
n.stopService();
assertNotNull(testComponent);
assertFalse(
"Test component did not shut down cleanly.", testComponent.isCleanStart
);
testComponent = null;
}
}
示例5: testSimple
import atg.nucleus.Nucleus; //导入方法依赖的package包/类
public void testSimple()
throws Exception {
// setup the repository
File configpath = new File(
"target/test-classes/config".replace(
"/", File.separator
)
);
// Define the path to our repository definition file called
// "simpleRepository.xml"
final String[] definitionFiles = { "/test/simpleRepository.xml" };
log.info("definitionFile[0]={}", definitionFiles[0]);
// Copy all related properties and definition files to the previously
// configured configpath
FileUtil.copyDirectory(
"src/test/resources/config",
configpath.getPath(),
Arrays.asList(".svn")
);
// Use the DBUtils utility class to get JDBC properties for an in memory
// HSQL DB called "testdb".
Properties props = DBUtils.getHSQLDBInMemoryDBConnection("testdb");
// Start up our database
DBUtils db = initDB(props);
boolean rollback = true;
// Setup our testing configpath
// RH: disabled logging (last argument to false) to get rid of the double
// logging statements
GSATestUtils.getGSATestUtils().initializeMinimalConfigpath(
configpath, "/SimpleRepository", definitionFiles, props, null, null, null, false
);
// Start Nucleus
Nucleus n = startNucleus(configpath);
TransactionDemarcation td = new TransactionDemarcation();
MutableRepository r = (MutableRepository) n.resolveName("/SimpleRepository");
try {
// Start a new transaction
td.begin(((GSARepository) r).getTransactionManager());
// Create the item
MutableRepositoryItem item = r.createItem("simpleItem");
item.setPropertyValue("name", "simpleName");
// Persist to the repository
r.addItem(item);
// Try to get it back from the repository
String id = item.getRepositoryId();
RepositoryItem item2 = r.getItem(id, "simpleItem");
assertNotNull(
" We did not get back the item just created from the repository.", item2
);
rollback = false;
} finally {
// End the transaction, rollback on error
td.end(rollback);
// shut down Nucleus
n.stopService();
// Shut down HSQLDB
db.shutdown();
}
}
示例6: createDynamoHttpServletRequestForSession
import atg.nucleus.Nucleus; //导入方法依赖的package包/类
/**
* Creates a new DynamoHttpServletRequest object that can be used in a
* unit test to resolve session-scoped objects.
* <p/>
* <p/>
* <p/>
* Unlike createDynamoHttpServletRequest, a response is also
* created and set on the request.
* <p/>
* <p/>
* The request is setup with
* an InputStream, OutputStream and the given set of request parameters.
* <p/>
* <p/>
* <p/>
* Note that for session resolution to work, you must have set
* the AppServerConfig component to a non-das value like "tomcat". Also
* you may need to invoke ServletUtil.setCurrentRequest() to the returned
* request, in some cases, depending on the expectations of the code
* you are invoking. If you use ServletUtil.setCurrentRequest() be
* sure to null it out at the end of your test.
*
* @param pNucleus
* the nucleus to use.
* @param pParameters
* A set of request parameters that this request should
* initially be populated with. Values can be simple Strings, or
* can beString[] or List<String> objects for multi-value
* parameters.
* @param pBufferSize
* The size in bytes of the backing buffer holding stream data for
* this request
* @param pMethod
* The HTTP method for this request. For example GET,POST,PUT
*/
public TestingDynamoHttpServletRequest createDynamoHttpServletRequestForSession(Nucleus pNucleus,
Map<String, ?> pParameters,
int pBufferSize,
String pMethod,
String pSessionId) {
if (getAppServerConfigPath() != null) {
// check AppServerConfig to make sure it is set properly for
// session-scoped resolution to work.
AppServerConfig config = (AppServerConfig) pNucleus.resolveName(getAppServerConfigPath());
if ("das".equals(config.getAppServer())) {
throw new RuntimeException(
getAppServerConfigPath() +
".appServer must be set to a non-das property (like \"Tomcat\"" +
" in order for session name resolution to work."
);
}
}
// make sure we are not a dynamo AppServer
ServletUtil.setIsDynamoAppserver(false);
TestingDynamoHttpServletRequest request = createDynamoHttpServletRequest(
pParameters, pBufferSize, pMethod, pSessionId
);
request.setResponse(createDynamoHttpServletResponse());
setExternalComponentsOnRequest(pNucleus, request);
return request;
}